<template>
  <div>
    <a-page-header
      style="background-color: #FFFFFF;"
      :title="!taskInfo.info.customerName ? '暂无客户名称':taskInfo.info.customerName"
      sub-title=""
      @back="showTaskList"
    >
      <!--  基本信息  -->
      <a-card :bordered="false" title="客户名称" style="margin-top: 10px;">
        <a-descriptions  :column="2" :bordered="true">
          <a-descriptions-item label="客户编号">{{taskInfo.info.customerNo}}</a-descriptions-item>
          <a-descriptions-item label="客户名称" >{{!taskInfo.info.customerName ? '暂无客户名称':taskInfo.info.customerName}}</a-descriptions-item>
        </a-descriptions>
      </a-card>
      <!--   客户信息列表   -->
      <a-card :bordered="false" title="客户列表" style="margin-top: 10px;">

        <div>
          <a-table
            ref="table"
            size="middle"
            :scroll="{x:true}"
            bordered
            rowKey="id"
            :columns="columns"
            :dataSource="dataSource"
            :pagination="ipagination"
            :loading="loading"
            class="j-table-force-nowrap"
            @change="handleTableChange">

             <span slot="action" slot-scope="text, record">
               <a @click="showCheckCheck(record)">查看</a>
             </span>

            <template v-slot:checkState="status">
              <a-badge :status="status | statusTypeFilter" :text="status | statusFilter"/>
            </template>
          </a-table>
        </div>
      </a-card>
    </a-page-header>

    <a-card :bordered="false" title="稽核任务" style="margin-top: 10px;">
      <a-form-model
        ref="ruleForm"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <a-card :bordered="false" v-for="(taskCheck,taskindex) in taskCheckInfo" :key="taskindex">
          <a-descriptions  :bordered="true" >
            <a-descriptions-item label="任务名称">{{taskCheck.taskName}}</a-descriptions-item>
            <a-descriptions-item label="开始时间">{{taskCheck.taskStartTime}}</a-descriptions-item>
            <a-descriptions-item label="结束时间">{{taskCheck.taskEndTime}}</a-descriptions-item>
            <a-descriptions-item label="任务类型">{{taskType(taskCheck.type)}}</a-descriptions-item>
            <a-descriptions-item label="任务状态">{{taskCheck.taskState_dictText}}</a-descriptions-item>
            <a-descriptions-item label="任务描述" :span="2">{{taskCheck.description}}</a-descriptions-item>
          </a-descriptions>
          <!--  稽核任务动态  -->
          <company-check-detail/>

        </a-card>
      </a-form-model>
    </a-card>
  </div>
</template>
<script>
import CompanyCheckCheck from "@views/company/CompanyCheckCheck";
import CompanyCheckDetail from "@views/company/CompanyCheckDetail";
import {getAction} from "@api/manage";
import {JeecgListMixin} from "@/mixins/JeecgListMixin";
import {mixinDevice} from "@/utils/mixin";
export default {
  name: 'CompanyTaskList',
  mixins: [JeecgListMixin,mixinDevice],
  components: {
    CompanyCheckCheck,
    CompanyCheckDetail
  },
  props: {
    taskInfo: {
      type: Object,
      require: true
    }
  },
  filters: {
    statusTypeFilter(type) {
      const statusTypeMap = {
        '0': 'error',
        '1': 'error',
        '2': 'warning',
        '3': 'warning',
        '4': 'processing',
        '5': 'success'
      }
      return statusTypeMap[type]
    },
    statusFilter(status) {
      const statusMap = {
        '0': '未处理',
        '1': '未完善',
        '2': '待稽核',
        '3': '待稽核',
        '4': '待整改',
        '5': '通过'
      }
      return statusMap[status]
    }
  },
  data(){
    return{
      columns: [
        {
          title: '#',
          dataIndex: '',
          key: 'rowIndex',
          width: 60,
          align: "center",
          customRender: function (t, r, index) {
            return parseInt(index) + 1;
          }
        },
        {
          title: '服务号码',
          align: "center",
          dataIndex: 'smsNumber',
          customRender: function (text, record, index) {
            if (!text){
               return '暂无'
            }
            return text;
          }
        },
        {
          title: '入网时间',
          align: "center",
          dataIndex: 'networkAccessTime'
        },
        {
          title: '客户经理',
          align: "center",
          dataIndex: 'staffName'
        },
        {
          title: '客户经理工号',
          align: "center",
          dataIndex: 'staffNo'
        },
        {
          title: '创建时间',
          align: "center",
          dataIndex: 'createTime'
        },
        {
          title: '客户信息类型',
          align: "center",
          dataIndex: 'type',
          customRender: function (text, record, index) {
            console.log(text)
            let checkStateName = ''
            if (!text){
              checkStateName = '无'
            }
            if (text === 1){
              checkStateName = '行短'
            }
            if (text === 2){
              checkStateName = '物联网'
            }
            if (text === 3){
              checkStateName = '特审复开'
            }
            if (text === 4){
              checkStateName = '中继线'
            }
            return checkStateName
          }
        },
        {
          title: '资料状态',
          align: "center",
          dataIndex: 'checkState',
          scopedSlots: {customRender: 'checkState'}
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: {customRender: 'action'}
        }
      ],
      description: '稽核业务列表',
      labelCol: { span: 1 },
      wrapperCol: { span: 23 },
      taskCheckInfo:{},
      showType:'checktask',
      url: {
        list: "/smsCheck/customerInfo/staff/list",
      },
      queryParam:{
        customerNo:this.taskInfo.info.customerNo,
      },
      showHistory:''
    }
  },
  created() {
    this.queryParam.customerNo = this.taskInfo.info.customerNo
    this.initTable();
    this.init();
  },
  methods:{
    init(){
     let queryList={
        customerNo:this.taskInfo.info.customerNo,
      }
      getAction("/smsCheck/customerInfo/selectTaskList",queryList).then(resp=>{
        if(resp.success){
          this.taskCheckInfo =resp.result.records

        }
      })
    },
    initTable(){
      let queryTable={
        customerNo:this.taskInfo.info.customerNo,
        /*taskId:this.taskInfo.task.id*/
      }

      /*getAction("/smsCheck/customerInfo/list",queryTable).then(resp=>{
        if(resp.success){
          this.dataSource=resp.result.records
        }
      })*/
    },
    showTaskList(){
      let taskInfo = Object.assign({}, this.task);
      this.$emit("goCompany",taskInfo)
    },
    showCheckCheck(record){
      let type = record.type;
      if (type === 1){
        this.$router.push({path: '/sms/check/TaskUploadDataSelect', query: {id: record.id}});
      }
      if (type === 2){
        this.$router.push({path: '/lotCheck/modules/TaskCheckAudit', query: {id: record.id}});
      }
      if (type === 3){

      }
      if (type === 4){

      }
      //this.taskInfo.info=record
      //this.$emit("goCheckCheck",this.taskInfo)
    },
    taskType(type){
      if (type === 1){
        return '行短';
      }
      if (type === 2){
        return '物联网';
      }
      if (type === 3){
        return '防诈复开'
      }
      if (type === 4){
        return '中继线'
      }
    }
  }
}

</script>