<template>
  <div>
    <a-page-header
      style="background-color: #FFFFFF;"
      :title="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.networkAccessTime}}</a-descriptions-item>
          <a-descriptions-item label="客户经理">{{taskInfo.info.accountManager}}</a-descriptions-item>
          <a-descriptions-item label="经理电话" >{{taskInfo.info.accountManagerPhone}}</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="任务状态">{{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'
        },

        {
          title: '用户编号',
          align: "center",
          dataIndex: 'userNo'
        },
        {
          title: '入网时间',
          align: "center",
          dataIndex: 'networkAccessTime'
        },
        {
          title: '用户状态',
          align: "center",
          dataIndex: 'userState'
        },
        {
          title: '用户发展员工',
          align: "center",
          dataIndex: 'staffName'
        },
        {
          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",
      },
      showHistory:''
    }
  },
  created() {
    this.initTable();
    this.init()
  },
  methods:{
    init(){
      let queryList={
        customerNo:this.taskInfo.info.customerNo,
        customerName:this.taskInfo.info.customerName
      }
      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){
      this.taskInfo.info=record
      this.$emit("goCheckCheck",this.taskInfo)
    },
  }
}

</script>