<template>

  <div>
    <a-page-header
      style="background-color: #FFFFFF;"
      title="稽核详情-客户详情"
      sub-title=""
      @back="showCheckList"
    >
      <a-descriptions :title="checkInfo.info.customerName" :column="3" :bordered="false">
        <a-descriptions-item label="客户编号">{{checkInfo.info.customerNo}}</a-descriptions-item>
        <a-descriptions-item label="服务号码">{{checkInfo.info.smsNumber}}</a-descriptions-item>
        <a-descriptions-item label="用户编号">{{checkInfo.info.userNo}}</a-descriptions-item>
        <a-descriptions-item label="入网时间">{{checkInfo.info.networkAccessTime}}</a-descriptions-item>
        <a-descriptions-item label="用户状态" :span="2">{{checkInfo.info.userState}}</a-descriptions-item>
        <a-descriptions-item label="员工姓名">{{checkInfo.info.staffName}}</a-descriptions-item>
        <a-descriptions-item label="员工工号">{{checkInfo.info.staffNo}}</a-descriptions-item>
      </a-descriptions>
    </a-page-header>

    <a-card :bordered="false" style="margin-top: 10px;">
      <a-form-model
        ref="ruleForm"
        :label-col="labelCol"
        :wrapper-col="wrapperCol"
      >
        <a-card title="业务基本情况内容" :bordered="true">
          <a-descriptions :bordered="false">
            <a-descriptions-item label="用户开通状态">{{checkInfo.info.userOpenState}}</a-descriptions-item>
            <a-descriptions-item label="码号" :span="2">{{checkInfo.info.smsNumberPrefix}}</a-descriptions-item>
            <a-descriptions-item label="详细用途" :span="3">{{checkInfo.info.smsNumberUsage}}</a-descriptions-item>
            <a-descriptions-item label="使用单位联系人">{{checkInfo.info.customerContacts}}</a-descriptions-item>
            <a-descriptions-item label="手机号" :span="2">{{checkInfo.info.customerContactsPhone}}</a-descriptions-item>
            <a-descriptions-item label="客户经理">{{checkInfo.info.accountManager}}</a-descriptions-item>
            <a-descriptions-item label="手机号" :span="2">{{checkInfo.info.accountManagerPhone}}</a-descriptions-item>
          </a-descriptions>

        </a-card>

        <a-card title="业务规范性内容" :bordered="true">
          <a-descriptions :bordered="false">
            <a-descriptions-item label="合同到期时间">{{checkInfo.info.contractExpireTime}}</a-descriptions-item>
            <a-descriptions-item label="码号证书到期时间">{{checkInfo.info.smsNumberCertificateExpireTime}}</a-descriptions-item>
            <a-descriptions-item label="备案通知到期时间">{{checkInfo.info.recordNoticeExpireTime}}</a-descriptions-item>
            <a-descriptions-item label="增值业务许可证到期时间">{{checkInfo.info.valueAddedLicenceExpireTime}}</a-descriptions-item>
            <a-descriptions-item label="营业执照到期时间" :span="2">{{checkInfo.info.businessLicenceExpireTime}}</a-descriptions-item>
            <a-descriptions-item label="合同签署主体与实际开通客户是否一致">{{checkInfo.info.contractOpenCustomerSame}}</a-descriptions-item>
            <a-descriptions-item label="是否有集团价格审批" :span="2">{{checkInfo.info.groupPriceApproval}}</a-descriptions-item>
            <a-descriptions-item label="资料是否完整">{{checkInfo.info.dataComplete}}</a-descriptions-item>
            <a-descriptions-item label="是否完成整改" :span="2">{{checkInfo.info.rectifyReformOver}}</a-descriptions-item>

          </a-descriptions>

        </a-card>

        <a-card title="附件资料" :bordered="true">


          <div style="background-color: rgba(236,236,236,0); padding: 0px">
            <a-row :gutter="16">
              <a-col :span="6">

                  <a-card title="资料类型选择">
                    <a-radio-group @change="fileTypeClick" v-model:value="radioValue" button-style="solid" style="width: 250px">

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.businessContract].len
                               :show-zero=fileTypeBadge[fileType.businessContract].showZero
                               :number-style=fileTypeBadge[fileType.businessContract].numberStyle
                      >
                        <a-radio-button style="display: flex" :value=fileType.businessContract>业务合同</a-radio-button>
                      </a-badge>


                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.smsNumberCertificate].len
                               :show-zero=fileTypeBadge[fileType.smsNumberCertificate].showZero
                               :number-style=fileTypeBadge[fileType.smsNumberCertificate].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.smsNumberCertificate>
                          号码证书
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.recordNotice].len
                               :show-zero=fileTypeBadge[fileType.recordNotice].showZero
                               :number-style=fileTypeBadge[fileType.recordNotice].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.recordNotice>
                          备案通知
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.groupPriceApproval].len
                               :show-zero=fileTypeBadge[fileType.groupPriceApproval].showZero
                               :number-style=fileTypeBadge[fileType.groupPriceApproval].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.groupPriceApproval>
                          集团政企价格审批单
                        </a-radio-button>
                      </a-badge>


                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.businessLicence].len
                               :show-zero=fileTypeBadge[fileType.businessLicence].showZero
                               :number-style=fileTypeBadge[fileType.businessLicence].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.businessLicence>
                          营业执照
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.customerIntroductionLetter].len
                               :show-zero=fileTypeBadge[fileType.customerIntroductionLetter].showZero
                               :number-style=fileTypeBadge[fileType.customerIntroductionLetter].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.customerIntroductionLetter>
                          集团政企价格审批单
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.handlerIdNumberCopy].len
                               :show-zero=fileTypeBadge[fileType.handlerIdNumberCopy].showZero
                               :number-style=fileTypeBadge[fileType.handlerIdNumberCopy].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.handlerIdNumberCopy>
                          经办人身份复印件
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.crmScreenshot].len
                               :show-zero=fileTypeBadge[fileType.crmScreenshot].showZero
                               :number-style=fileTypeBadge[fileType.crmScreenshot].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.crmScreenshot>
                          CRM 行短业务截图
                        </a-radio-button>
                      </a-badge>

                      <a-badge class="badge-width-100" :count=fileTypeBadge[fileType.valueAddedLicence].len
                               :show-zero=fileTypeBadge[fileType.valueAddedLicence].showZero
                               :number-style=fileTypeBadge[fileType.valueAddedLicence].numberStyle>
                        <a-radio-button style="display: flex" :value=fileType.valueAddedLicence>
                          增值业务许可证
                        </a-radio-button>
                      </a-badge>

                    </a-radio-group>
                  </a-card>
              </a-col>
              <a-col :span="18">
                <a-card title="资料详情" :bordered="false">
                  <a-list item-layout="vertical" :data-source="delList">
                    <a-list-item slot="renderItem" slot-scope="item, index">
                      <!--                <pdf
                                        ref="pdf"
                                        :src="item.url">
                                      </pdf>-->


                      <a-list-item-meta
                        :description=item.information
                      >
                        <a slot="title" :href=item.href>{{ item.title }}</a>

                        <a-avatar
                          slot="avatar"
                          :src=item.url
                          icon="file"
                        />
                      </a-list-item-meta>
                      <iframe
                        frameborder="1"
                        :src=item.href
                        ref="ifr"
                        width="100%"
                        height="560px"
                        scrolling="auto">
                      </iframe>
                    </a-list-item>
                  </a-list>
                </a-card>
              </a-col>
            </a-row>
          </div>

<!--          <a-descriptions :column="1" :bordered="false">
            <a-descriptions-item label="业务合同" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="号码证书" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="备案通知" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="集团政企价格审批单" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="营业执照" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="客户介绍信" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="经办人身份证复印件" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>
            <a-descriptions-item label="在CRM没有行短业务的截图" :span="2">
              <a-space><a v-for="(file,index) in fileList" :href="handlePreview(file)" target="_blank">{{'附件' + (index + 1)}}</a></a-space>
            </a-descriptions-item>

          </a-descriptions>-->

        </a-card>

        <a-form-model-item :wrapper-col="{ span: 14, offset: 4 }" style="margin-top: 10px;">
          <a-space>
            <a-button @click="showCheckList">
              返回
            </a-button>
          </a-space>
        </a-form-model-item>

      </a-form-model>

    </a-card>

  </div>

</template>

<script>

import { httpAction, getAction } from '@api/manage'
import '@/assets/less/TableExpand.less'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
let Base64 = require('js-base64').Base64

export default {
  name: 'TaskCheckDetail',
  mixins:[JeecgListMixin],
  props: {
    checkInfo: {
      type: Object,
      require: true
    }
  },
  data () {
    return {
      delList:[],
      radioValue: "businessContract",
      fileType: {
        businessContract: "businessContract",
        smsNumberCertificate: "smsNumberCertificate",
        recordNotice: "recordNotice",
        groupPriceApproval: "groupPriceApproval",
        businessLicence: "businessLicence",
        customerIntroductionLetter: "customerIntroductionLetter",
        handlerIdNumberCopy: "handlerIdNumberCopy",
        crmScreenshot: "crmScreenshot",
        valueAddedLicence: "valueAddedLicence"
      },
      fileTypeBadge: {
        "businessContract": {
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "smsNumberCertificate":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "recordNotice":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "groupPriceApproval":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "businessLicence":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "customerIntroductionLetter":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "handlerIdNumberCopy":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "crmScreenshot":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
        "valueAddedLicence":{
          len: 0,
          showZero: true,
          numberStyle: {
            backgroundColor: '#fa073f'
          }
        },
      },
      description: '稽核详情页面',
      labelCol: { span: 1 },
      wrapperCol: { span: 23 },
      url: {
        list: "/smsCheck/customerInfo/list",
        listData: "/smsCheck/customerData/list"
      },
      autoSearch: false,
      fileList: [
        {text: '附件', url: "http://202.85.214.182:9001/default/by2_1650088480055.jpg"},
        {text: '附件', url: "http://202.85.214.182:9001/default/《Nginx代理系统常用手册》电子书_1650129698991.pdf"}
      ],
    }
  },
  created() {
    this.customerDataList();
    this.badgeCount()
  },
  methods: {
    fileTypeClick(a, event) {
      this.customerDataList();
    },

    customerDataList() {
      let model = {
        "infoId": this.checkInfo.info.id
      }
      httpAction(this.url.listData, model, "post")
        .then((res) => {
          if (res.success) {
            let records = res.result.records;
            if (records.length > 0) {
              this.delList = [];
              let record = records[0];
              let recordElement = record[this.radioValue];
              if (recordElement != null || recordElement != undefined) {
                let splitList = recordElement.split(",");
                for (var i in splitList) {
                  let splitListElement = splitList[i];
                  let split = splitListElement.split("/");
                  let splitElement = split[split.length - 1];
                  let del = {
                    title: splitElement,
                    href: window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(Base64.encode((splitListElement))),
                    information: "上传用户：" + record.createBy,
                    url: splitListElement
                  }
                  this.delList.push(del)
                }
              } else {
                this.delList = [];
              }
              console.log( this.delList)
            } else {
              this.delList = [];
            }

          } else {
            this.$message.error('查询资料信息失败')
          }
        }).finally(() => {

      })
    },
    badgeCount() {
      //this.fileTypeBadge = []
      let model = {
        "infoId": this.checkInfo.info.id
      }
      httpAction(this.url.listData, model, "post")
        .then((res) => {
          if (res.success) {
            res = res.result.records
            if (res.length > 0 && res != null) {
              let data = res[0];
              for (var i in this.fileType) {
                let fileTypeElement = this.fileType[i];
                let datum = data[fileTypeElement];
                let badge = {};
                if (datum == null) {

                } else {
                  let length = datum.split(",").length;
                  let showZero = length > 0 ? false : true;
                  badge = {
                    len: parseInt(length),
                    showZero: showZero,
                    numberStyle: {
                      backgroundColor: "#52c41a"
                    }
                  }
                    this.fileTypeBadge[fileTypeElement] = badge;
                }
                console.log(this.fileTypeBadge)

              }

            }

          } else {
            /* for (var i in this.fileType) {
               let fileTypeElement = this.fileType[i];
               let badge = {
                 len: 0,
                 showZero: true,
                 style: {}

               }
               this.fileTypeBadge[fileTypeElement] = badge;
             }*/
          }
        })
    },

    // 显示列表页面
    showList() {
      this.$emit('goList');
    },
    // 显示列表页面
    showCheckList() {
      let taskInfo = this.checkInfo.task;
      this.$emit('goCheckList', taskInfo);
    },
    handlePreview(record) {
      if (record && record.url) {
        let url = window._CONFIG['onlinePreviewDomainURL'] + '?url=' + encodeURIComponent(Base64.encode((record.url)))
        return url;
      }
    },
  }
}
</script>

<style scoped>
.badge-width-100{
  width: 100%;
}

</style>