<template>
  <div style="height: 1300px;overflow: auto;">
    <!--<Card>
      <Row style="margin: 10px 0;" type="flex">
        <Col span="10" order="1">
          &lt;!&ndash;高级检索&ndash;&gt;
          &lt;!&ndash;<seniorModal ref="senior" keyValue2 clear :pageName="$options.name" :fieldList="fieldList"
                       :commonList="commonList"
                       @seniorFind="reloadData" :item.sync="searchForm"></seniorModal>&ndash;&gt;
        </Col>
        <Col span="4" order="2" style="text-align: left">
          &lt;!&ndash;复合排序&ndash;&gt;
          &lt;!&ndash;<customSort ref="customSort" :sortParams.sync="sortParams" @reload-data="reloadData"
                      :searchForm.sync="searchForm"></customSort>&ndash;&gt;
        </Col>
        <Col span="10" order="3" style="text-align: right">
          &lt;!&ndash;<Button @click="priceSchemeBatchDelete"  type="primary">批量删除</Button>&ndash;&gt;
          &lt;!&ndash;通用导出excel组件&ndash;&gt;
          &lt;!&ndash;<exportExcel :dataColumns="dataColumns" :selectedData="selectedData" :tableData="tableData" :excelName="'priceSchemeExcel'"
                       :searchForm="searchForm" @export-data="exportData" :getData="this.getList"></exportExcel>&ndash;&gt;
        </Col>
      </Row>

    </Card>-->
    <card>
      <workbench-tree :group="rootGroup"></workbench-tree>
    </card>
  </div>
</template>

<script>
  import {getWorkbench} from '../workflow-api'
  import workbenchTree from './workbench-tree.vue'
  let $this;
  export default {
    name: 'workflowApplyList',
    components: {
      workbenchTree,
    },
    data() {
      return {
        rootGroup: { },
        searchForm: {},
        showModal: false,
        showWorkflowDetailsModal: false,
        modalParams: {},
        workflowDetailsModalParams: {},
        nowPriceScheme: {},
        dataCount: 0,
        pageSize: 10,
        columns: [
          { title: '业务标题', key: '', render: (h, params) =>  h('span', params.row.processVariables.busTitle),  sortable: true, show: true },
          /*{ title: '所属区域', key: '', render: (h, params) =>  h('span', params.row.processVariables.areaName),  sortable: true, show: true },*/
          { title: '业务类型', key: '', render: (h, params) =>  h('span', params.row.processVariables.busName),  sortable: true, show: true },
          { title: '当前状态', key: 'nowStep',  sortable: true, show: true },
          /*{ title: '申请数量', key: '', render: (h, params) =>  h('span', params.row.processVariables.applySum), width: 180, sortable: true, show: true },*/
          { title: '申请时间', key: '', render: (h, params) =>  h('span', params.row.processVariables.startTime),  sortable: true, show: true},
          { title: '当前步骤', key: 'nowStep', width: 180, sortable: true, show: true},
          { title: '操作', key: 'action', width: 250, align: 'center',slot:'actions', show: true }
        ],
        loading: true,
        commonList: [

        ],//固化常用列表
        fieldList: [//用户可以自行选择查询的字段列表及配置

        ]
      }
    },
    methods: {
      showWorkflowHis(row) {
        getWorkflowTaskList({processInstanceId: row.id}).then(res => {
          this.hisTasks = res.data;

          console.log(this.hisTasks)
        }).catch(err => {
          this.$Message.error('查询审批历史失败！')
          console.log(err)
        });
      },
      workflowDetailsView (row) {
        this.showWorkflowDetailsModal = true;
        this.workflowDetailsModalParams = {title:'详情',flag:'view',bean:row};
      },
      reloadData() {
        getWorkbench(this.$config.systemCode).then(res => {
          if (res.data.result) {
            this.rootGroup = res.data.result
          }
        }).catch(err => {
          this.rootGroup = {};
          this.$Message.error('查询失败！')
          console.log(err)
        })
      },
    },
    mounted() {
      this.reloadData();
      $this = this;
    }
  }
</script>

<style>

</style>
