<template>
  <div>
    <a-page-header
      style="background-color: #FFFFFF;"
      :title= customer.info.cardName
      sub-title=""
      @back="showTaskList"
    >
      <!--  基本信息  -->
      <a-card :bordered="false" title="基本信息" style="margin-top: 10px;">
        <a-descriptions  :column="2" :bordered="true">
          <a-descriptions-item label="证件编号">{{customer.info.cardNo}}</a-descriptions-item>
          <a-descriptions-item label="客户名称" >{{customer.info.cardName}}</a-descriptions-item>
<!--          <a-descriptions-item label="证件地址" >{{customer.info.idCardAddress}}</a-descriptions-item>-->
          <a-descriptions-item label="新办号码">{{customer.info.newPhone}}</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="showByCardNo(record)">查看</a>
             </span>
            <template v-slot:numberResults="text, record">
              <a-badge :status="text | statusTypeFilter" :text="text | statusFilter"/>
            </template>

            <template v-slot:status="text, record">
              <a-badge :color="record | statusEscalationColor"  :text="record | escalationFilter"/>
            </template>

          </a-table>
        </div>
      </a-card>

<!--      &lt;!&ndash;   操作日志   &ndash;&gt;-->
<!--      <a-card :bordered="false" title="操作日志1" style="margin-top: 10px;">-->

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

<!--             <span slot="action" slot-scope="text, record">-->
<!--               <a @click="showByCardNo(record)">查看</a>-->
<!--             </span>-->
<!--            <template v-slot:numberResults="text, record">-->
<!--              <a-badge :status="text | statusTypeFilter" :text="text | statusFilter"/>-->
<!--            </template>-->

<!--            <template v-slot:status="text, record">-->
<!--              <a-badge :color="record | statusEscalationColor"  :text="record | escalationFilter"/>-->
<!--            </template>-->

<!--          </a-table>-->
<!--        </div>-->
<!--      </a-card>-->
    </a-page-header>

  </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: 'CustomerHistorys',
  mixins: [JeecgListMixin,mixinDevice],
  components: {
    CompanyCheckCheck,
    CompanyCheckDetail
  },
  props: {
    customer: {
      type: Object,
      require: true
    }
  },
  filters: {
    statusTypeFilter(type) {
      const statusTypeMap = {
        '1': 'success',
        '2': 'processing',
        '3': 'warning',
        '4': 'warning',
        '3,4': 'warning',
        '4,3': 'warning',
      }
      return statusTypeMap[type]
    },
    statusFilter(status) {
      const statusMap = {
        '1': '非高危',
        '2': '上报关停',
        '3': '上报蓝名单',
        '4': '上报紫名单',
        '3,4':'上报蓝/紫名单',
        '4,3':'上报蓝/紫名单',
      }
      return statusMap[status]
    },
    statusEscalation(type) {
      const statusTypeMap = {
        '1': 'success',
        '0': 'warning',
      }
      return statusTypeMap[type]
    },
    statusEscalationColor(record) {
      let statusTypeMap ={}
      if(record.numberResults.indexOf('1')!==-1){
        statusTypeMap = {
          '2': 'green',
          '1': 'yellow',
          '0': 'green',
        }
      }else {
        statusTypeMap = {
          '2': 'green',
          '1': 'yellow',
          '0': 'gray',
        }
      }


      return statusTypeMap[record.status]
    },

    currentFilter(status) {
      const statusMap = {
        '0': status.businessAddress,
        '1':'已报分公司',
        '2': '已完成'
      }
      return statusMap[status.status]
    },
    statusCurrentColor(type) {
      const statusTypeMap = {
        '2': 'green',
        '1': 'yellow',
        '0': 'gray',
      }
      console.log(statusTypeMap[type]+"aaa")
      return statusTypeMap[type]
    },

    escalationFilter(record) {
      let statusMap ={}
      if(record.numberResults.indexOf('1')!==-1){
        statusMap = {
          '0': '新建未报(无需上报)',
          '1':'已报分公司',
          '2': '已报省公司'
        }
      }else {
        statusMap = {
          '0': '新建未报',
          '1':'已报分公司',
          '2': '已报省公司'
        }
      }
      // statusMap = {
      //   '0': '新建未报',
      //   '1':'已报分公司',
      //   '2': '上报成功'
      // }
      return statusMap[record.status]
    },
  },
  data(){
    return{
      sysCompany:[],
      optionsWithDisabled:
        [{
          text: '非高危',
          value: '1',
        }, {
          text: '上报关停',
          value: '2',

        }, {
          text: '上报蓝名单',
          value: '3',
        },{
          text: '上报紫名单',
          value: '4',
        }],
      columnsLog: [
        {
          title: '操作时间',
          align: "center",
          dataIndex: 'updateTime',
        },
        {
          title: '操作人',
          align: "center",
          dataIndex: 'updateBy',
        },
        {
          title: '操作类型',
          align: "center",
          dataIndex: 'operateType',
        },
      ],
      array:[],  //创建一个数组
      form:{
        value:[]  //接收每个input框的值
      },
      labelCol1ProMaxPlus: {
        labelCol: {
          span: 12
        },
        wrapperCol: {
          span: 12
        }
      },
      numberResults: [],
      isDisabled:true,
       columns: [
        {
          title: '证件编号',
          align: "center",
          dataIndex: 'cardNo',
          scopedSlots: {customRender: 'cardNo'}

        }, {
          title: '客户名称',
          align: "center",
          dataIndex: 'cardName'
        }, {
          title: '创建人',
          align: "center",
          sorter: (a, b) =>a.createBy.localeCompare(b.createBy),
          dataIndex: 'createBy'
        }, {
          title: '创建时间',
          align: "center",
          //sorter: true,
          sorter:(a, b) => { return a.createTime>= b.createTime? 1 : -1 },
          width: 100,
          dataIndex: 'createTime'
        }, {
          title: '创建人归属部门',
          width: 100,
          align: "center",
          sorter: (a, b) =>a.businessAddress.localeCompare(b.businessAddress),
          dataIndex: 'businessAddress'
        },{
          title: '上报时间',
          align: "center",
          dataIndex: 'upTime',
          sorter:(a, b) => { return a.upTime> b.upTime? 1 : -1 },
          scopedSlots: {customRender: 'upTime'}
        },
        {
          title: '办理电话',
          align: "center",
          width: 200,
          dataIndex: 'newPhone',
          scopedSlots: {customRender: 'newPhone'}
        },{
          title: '当前处理部门',
          align: "center",
          dataIndex: 'currentDept',
        },
        {
          title: '研判结果',
          align: "center",
          sorter: (a, b) =>a.numberResults.localeCompare(b.numberResults),
          dataIndex: 'numberResults',
          scopedSlots: {customRender: 'numberResults'},
        },{
          title: '上报状态',
          align: "center",
          sorter: (a, b) => a.status - b.status,
          dataIndex: 'status',
          scopedSlots: {customRender: 'status'}
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          scopedSlots: {customRender: 'action'}
        }
      ],
      description: '稽核业务列表',
      ipaginationLog:{
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      dataSourceLog:[],
      sysBusinessHallList: "",
      labelCol: { span: 1 },
      wrapperCol: { span: 23 },
       showType:'checktask',
      url: {
        //list: "businessReminderCard/list",
      },
      showHistory:''
    }
  },
  created() {
    this.initTable();
    this.init()

  },
  methods:{
    init(){

      let queryTable={
        //businessReminderCardId:this.customer.info.id,
        cardNo :this.customer.info.cardNo,
        cardName :this.customer.info.cardName
      }
      getAction("/businessReminderCard/getBusinessReminderCardLogs",queryTable).then(resp=>{
        if(resp.success){
          this.dataSourceLog=resp.result
        }
      })
    },
    initTable(){
      let queryTable={
        cardName:this.customer.info.cardName,
        cardNo:this.customer.info.cardNo
      }
      getAction("businessReminderCard/listAll",queryTable).then(resp=>{
        if(resp.success){
          this.dataSource=resp.result.records
        }
      })
    },
    showByCardNo(record){
      this.$emit("customerHistory",record)
    },
    showTaskList(){
      this.$emit("customerList",this.customer)
    },
  }
}

</script>