<template>
  <div class="app-container">
    <SearchForm :model="queryParams" @query="getList"   label-width="120px" :buttonOffSet="6" :buttonSpan="6">
      <Input label="audit.businessCode" prop="businessCode" @keyup="getList" :span="6"/>
      <Input label="audit.businessName" prop="businessName" @keyup="getList" :span="6"/>
      <DictSelect label="audit.auditProcess" prop="auditFlow" dict-type="audit_flow" @keyup="getList" :span="6"/>
      <Input label="audit.description" prop="businessDesc" @keyup="getList" :span="6"/>
      <!-- <DictSelect label="audit.auditStatus" prop="status" dict-type="audit_status" :span="6"/>
      <SysUserSelect label="audit.applicant" prop="userId" :span="6"/> -->
    </SearchForm>
    <Table ref="table" :list="getFlowList" :defaultParams="queryParams">
      <template #default>
        <Column label="audit.auditCode" prop="id" fixed="left" :min-width="100" />
        <Column label="audit.businessCode" prop="businessCode" fixed="left" :min-width="100" />
        <Column label="audit.businessName" prop="businessName" fixed="left" :min-width="100" />
        <DictColumn label="audit.auditProcess" prop="auditFlow" dictType="audit_flow" />
        <Column label="audit.description" prop="businessDesc" />
        <Column label="audit.applicant">
          <template #default="{ row }">
            {{ row.promoterInfo && row.promoterInfo.nickName }}
          </template>
        </Column>
        <Column label="common.handle">
          <template #default="{ row }">
            <custom-link label="common.watchLink" @handleClick="watchDetail(row)"/>
            <!--          <custom-link label="common."-->
            <!--          <el-link type="warning" v-if="row.status === 2" @click="toDetail(row)">去审批</el-link>-->
            <custom-link label="audit.goAudit"
            v-if="(row.status != 2 && row.status != 3) && ( $store.state.user.userInfo.userId == 1 || ($store.state.user.userInfo.userId != 1 && row.promoter != $store.state.user.userInfo.userId))"
            @handleClick="toDetail(row)"/>
          </template>
        </Column>
      </template>
    </Table>
  </div>
</template>

<script>
import { getFlowList } from '@/api/audit/flow'
// import CustomLink from "../../components/element/CustomLink";
// import DictSelect from "../../components/element/form/items/DictSelect";
// import SysUserSelect from "../../components/element/form/items/SysUserSelect";
// import EmployeeSelect from "../../components/element/form/items/EmployeeSelect";

export default {
  name: 'Center',
  // components: {EmployeeSelect, SysUserSelect, DictSelect, CustomLink},
  data(){
    return {
      queryParams:{}
    }
  },
  activated() {
    this.$refs.table.getList()
  },
  mounted() {
    this.$refs.table.getList()
  },
  methods: {
    getFlowList,
    getList(){
      this.$refs.table.getList()
    },
    toDetail({ auditFlow, businessId }) {
      const query = { id: businessId, auditFlow }
      let name = ''
      switch (auditFlow) {
        case 1:
          name = 'ProductionDetail'
          break;

        default:
          break;
      }
      // this.$router.push({ name, query })
      this.$tab.openPage('审批明细','/audit/auditDetail',{businessId:businessId,auditFlow:auditFlow,type:1})
    },
    watchDetail({ auditFlow, businessId }) {
      const query = { id: businessId, auditFlow }
      let name = ''
      switch (auditFlow) {
        case 1:
          name = 'ProductionDetail'
          break;

        default:
          break;
      }
      // this.$router.push({ name, query })
      this.$tab.openPage('审批明细','/audit/auditDetail',{businessId:businessId,auditFlow:auditFlow,type:2})
    }
  },
}
</script>
