<template>
  <div>
    <a-card :bordered="false">
      <div>
<!--        <a-tabs v-has="'user:userStatistics:tab'" :active-key="currentTab" default-active-key="all"-->
<!--                @change="tabChange">-->
<!--          <a-tab-pane key="all" :tab="tabAll"></a-tab-pane>-->
<!--          <a-tab-pane key="undo" :tab="tabUndo"></a-tab-pane>-->
<!--          <a-tab-pane key="uncheck" :tab="tabUncheck"></a-tab-pane>-->
<!--          <a-tab-pane key="checked" :tab="tabChecked"></a-tab-pane>-->
<!--        </a-tabs>-->

<!--        <a-tabs v-has="'admin:userStatistics:tab'" :active-key="currentTab" default-active-key="all"-->
<!--                @change="tabChange">-->
<!--          <a-tab-pane key="all" :tab="tabAll"></a-tab-pane>-->
<!--          <a-tab-pane key="undo" :tab="tabUndo"></a-tab-pane>-->
<!--          <a-tab-pane key="uncheck" :tab="tabUncheck"></a-tab-pane>-->
<!--          <a-tab-pane key="checked" :tab="tabChecked"></a-tab-pane>-->
<!--          <a-tab-pane key="del" :tab="tabDelCheck"></a-tab-pane>-->
<!--        </a-tabs>-->
      </div>


      <!-- 查询区域 -->
      <div class="table-page-search-wrapper">
        <a-form layout="inline" @keyup.enter.native="searchQuery">
          <a-row :gutter="24">
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="客户名称">
                <j-input placeholder="请输入客户名称" v-model="queryParam.cardName"></j-input>
              </a-form-item>
            </a-col>
            <a-col :xl="6" :lg="7" :md="8" :sm="24">
              <a-form-item label="证件编号">
                <j-input placeholder="请输入证件编号" v-model="queryParam.cardNo"></j-input>
              </a-form-item>
            </a-col>
            <a-col :span="6">
              <a-form-model-item label="  判研结果 " :labelCol="{ span:5}"   :wrapperCol="{ span: 8 }">
                <a-select placeholder="请选择判研结果"  v-model="queryParam.numberResults"  mode="tags">
                  <a-select-option v-for="item in optionsWithDisabled"   :value="item.value">
                    {{ item.text }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>


            </a-col>



            <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left;overflow: hidden;" class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" style="margin-left: 8px">重置</a-button>
              <a @click="handleToggleSearch" style="margin-left: 8px">
                {{ toggleSearchStatus ? '收起' : '展开' }}
                <a-icon :type="toggleSearchStatus ? 'up' : 'down'"/>
              </a>
            </span>
            </a-col>


          </a-row>
          <template v-if="toggleSearchStatus">
          <a-row  :gutter="24">



            <a-col :span="6">
              <a-form-model-item label="  上报状态 " :labelCol="{ span:5}"   :wrapperCol="{ span: 8 }">
                <a-select placeholder="请选择上报状态"  v-model="queryParam.status" >
                  <a-select-option v-for="item in statusList"   :value="item.value">
                    {{ item.text }}
                  </a-select-option>
                </a-select>
              </a-form-model-item>


            </a-col>
            <a-col :span="6">
              <a-form-item label="  办理电话 " :labelCol="{ span:5}"   :wrapperCol="{ span: 8 }">
                <j-input placeholder="请输入办理电话" v-model="queryParam.newPhone"></j-input>
              </a-form-item>
            </a-col>

            <a-col :span="6">
              <a-form-item label="  创建人 " :labelCol="{ span:5}"   :wrapperCol="{ span: 8 }">
                <j-input placeholder="请输入创建人" v-model="queryParam.createBy"></j-input>
              </a-form-item>
            </a-col>

          </a-row>

          <a-row>


            <a-col :span="11" >
              <a-form-item label="创建时间"  prop="industry"      :labelCol="{ span:9}"   :wrapperCol="{ span: 10 }">
                <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" class="query-group-cust"
                        id ="cardStartTime"  v-model="queryParam.createDateStart" ></j-date>
                <span class="query-group-split-cust"></span>
                <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" class="query-group-cust"
                        id="cardEndTime"  v-model="queryParam.createDateEnd" ></j-date>
              </a-form-item>
            </a-col>
            <a-col :span="7" style='margin-left: 30px'>
              <a-form-item label="创建人归属部门"  >
                <j-input placeholder="请输入营业厅" v-model="queryParam.businessAddress" style="width: 220px;"></j-input>
              </a-form-item>
            </a-col>
            </a-row>

            <a-row>


              <a-col :span="11" >
                <a-form-item label="上报时间"  prop="industry"      :labelCol="{ span:9}"   :wrapperCol="{ span: 10 }">
                  <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" class="query-group-cust"
                          id ="upTimeStart"  v-model="queryParam.upTimeStart" ></j-date>
                  <span class="query-group-split-cust"></span>
                  <j-date :show-time="true" date-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" class="query-group-cust"
                          id="upTimeEnd"  v-model="queryParam.upTimeEnd" ></j-date>
                </a-form-item>
              </a-col>

            </a-row>
          </template>
        </a-form>
      </div>

      <!-- 操作按钮区域 -->
      <div class="table-operator">
<!--        <a-button type="primary" icon="download" @click="handleExportXls('入网统计')">导出</a-button>-->
        <a-button type="primary" icon="download" v-has="'userStatistic:excel'" @click="excelOutExcel()">导出</a-button>
        <a-button type="primary" icon="download" v-has="'userStatistic:excelUp'" @click="excelOutUp()">导出并上报</a-button>
        <!-- 高级查询区域 -->
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <a-menu slot="overlay">
            <a-menu-item key="1" @click="showImproveAndUploadList" v-has="'access:check:lists:up'">
              <a-icon type="up"/>
              上报
            </a-menu-item>
          </a-menu>
          <a-button style="margin-left: 8px"> 批量操作
            <a-icon type="down"/>
          </a-button>
        </a-dropdown>
      </div>

      <!-- table区域-begin -->
      <div>
        <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
          <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择 <a
          style="font-weight: 600">{{ selectedRowKeys.length }}</a>项
          <a style="margin-left: 24px" @click="onClearSelected">清空</a>
        </div>

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


          <template slot="action" slot-scope="text, record">
            <div>
            <span v-has="'userStatistics:list:update'" v-show=" currentTab != 'del'">
              <a @click="showImproveAndUpload(record)">修改</a>
              <a-divider type="vertical"/>
            </span>

              <span v-has="'userStatistics:up'" v-show=" currentTab != 'del'">
              <a @click="showImproveAndUploadAdmin(record,'2')">上报</a>
              <a-divider type="vertical"/>
            </span>
              <span v-has="'userStatistics:list:upCom'" v-show=" currentTab != 'del'">
              <a @click="showImproveAndUploadAdminCom(record,'1')">上报分公司</a>
              <a-divider type="vertical"/>
            </span>

              <span v-has="'userStatistics:list:notice'" v-show=" currentTab != 'del'">
              <a @click="noticeDeal(record)">通知</a>
              <a-divider type="vertical"/>
            </span>

              <span v-has="'userStatistics:list:restore:id'" v-show=" currentTab  == 'del'">
              <a @click="restoreById(record)">恢复</a>
              <a-divider type="vertical"/>
            </span>

              <span v-has="'userStatistics:list:remove:id'" v-show=" currentTab  == 'del'">
              <a @click="removeById(record)">彻底删除</a>
              <a-divider type="vertical"/>
            </span>


<!--              <a-dropdown v-show =" currentTab != 'del'">-->
<!--                <a class="ant-dropdown-link">更多-->
<!--                  <a-icon type="down"/>-->
<!--                </a>-->
<!--                <a-menu slot="overlay">-->

<!--                  <a-menu-item v-has="'del:userStatistics:list:row:delete'">-->
<!--                    <a @click="delFlagById(record)">删除</a>-->
<!--                  </a-menu-item>-->

<!--                </a-menu>-->
<!--              </a-dropdown>-->
            </div>

          </template>
          <template v-slot:status="text, record">
            <a-badge :color="text | statusEscalationColor"  :text="text | escalationFilter"/>
          </template>
          <template v-slot:createBy="text, record">
            <a @click="showByCreateBy(record)">{{text}}</a>
          </template>
          <template v-slot:sysBusinessHall="text, record">
            <div>{{getSysCompany(text)}}</div>
          </template>
          <template v-slot:cardNo="text, record">
            <a @click="showByCardNo(record)">{{text}}</a>
          </template>
          <template v-slot:cardName="text, record">
            <a @click="showByCardName(record)">{{text}}</a>
          </template>
          <template v-slot:phone="text, record">
            <a @click="showByPhone(record)">{{text}}</a>
          </template>
          <template v-slot:numberResults="text, record">
            <a-badge :status="text | statusTypeFilter" :text="text | statusFilter"/>
          </template>
          <template v-slot:newPhone="text, record">
            <div>{{newPhone(text)}}</div>
          </template>
          <template v-slot:newBusinessAddress="text, record">
            <div>{{getSysCompany(text)}}</div>
          </template>
          <template v-slot:rowIndex="text,records,index">
            {{ (ipagination.current - 1) * ipagination.pageSize + Number(index) + 1 }}
          </template>
          <template v-slot:current="text, record">
<!--            <div>{{currentCom(record)}}</div>-->
<!--            if (record.status==='0'){-->
<!--            return record.businessAddress-->
<!--            }-->
<!--            if (record.status==='1'){-->
<!--            return '已报分公司'-->
<!--            }-->
<!--            if (record.status==='2'){-->
<!--            return '已完成'-->
<!--            }-->
<!--            <div v-if="record.status==='0'"  style="color: red">{{ record.businessAddress }}</div>-->
<!--            <div v-if="record.status==='1'"  style="color: yellow">{{ 已报分公司 }}</div>-->
<!--            <div v-if="record.status==='2'"  style="color: greenyellow">{{ 已完成 }}</div>-->
            <a-badge :color=" record.status  | statusCurrentColor"  :text="record | currentFilter "/>
          </template>
        </a-table>

      </div>

    </a-card>


  </div>
</template>

<script>
import { getAction, postAction, deleteAction, downFile } from '@api/manage'
import {JeecgListMixin} from '@/mixins/JeecgListMixin'
import '@/assets/less/TableExpand.less'

export default {
  name: "userStatistics",
  mixins: [JeecgListMixin],
  inject: ['closeCurrent'],
  data() {
    return {
      excelName:'入网统计',
      optionsWithDisabled:
        [{
          text: '非高危',
          value: '1',
        }, {
          text: '上报关停',
          value: '2',

        }, {
          text: '上报蓝/紫',
          value: '3',
        } ],
      statusList:
        [{
          text: '上报成功',
          value: '2',
        },{
          text: '已报分公司',
          value: '1',
        }, {
          text: '新建未报',
          value: '0',
        }],
      company:'',
      sysCompany: [],
      ipagination:{
        current: 1,
        pageSize: 10,
        pageSizeOptions: ['10', '20', '30','300'],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条"
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0
      },
      numberResults: [],
      /**统计标签*/
      currentTab: 'all',
      tabAll: '全部（0）',
      tabUndo: '非高危（0）',
      tabUncheck: '上报蓝紫名单（0）',
      tabChecked: '上报关停（0）',
      tabDelCheck: "已删除（0）",
      allCount: 0,
      tabUndoCount: 0,
      tabUncheckCount: 0,
      tabCheckedCount: 0,
      delCount: 0,
      /* table选中keys*/
      selectedRowKeys: [],
      /* table选中records*/
      selectionRows: [],
      /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
      queryParam: {},
      url: {
        getType:"/businessReminderCard/type",
        getCompany: "/sysCompany/list",
        typeCount: "/businessReminderCard/type/count",
        list: "/businessReminderCard/list",
        delete: "/businessReminderCard/delete/flagById",
        removeById: "/businessReminderCard/deleteById",
        restoreById: "/businessReminderCard/restoreById",
        notice: "/smsCheck/customerInfo/notice",
        exportXlsUrl: "/businessReminderCard/exportXls",
        exportXlsUrlUp: "/businessReminderCard/exportXlsUp",
      },
      /**表单
       * 入网用户统计：身份证号/姓名/办理电话/创建人/创建人所属营业厅/更新人/更新人营业厅/研判结果/
       * */
      columns: [
        // {
        //   title: '#',
        //   dataIndex: '',
        //   key: 'rowIndex',
        //   width: 60,
        //   align: "center",
        //   scopedSlots: {customRender: 'rowIndex'}
        // },
        {
          title: '证件编号',
          align: "center",
          sorter: true,
          dataIndex: 'cardNo',
          scopedSlots: {customRender: 'cardNo'}

        }, {
          title: '客户名称',
          align: "center",
          sorter: true,
          dataIndex: 'cardName'
         // scopedSlots: {customRender: 'cardName'}
        }, {
          title: '创建人',
          align: "center",
          sorter: true,
          dataIndex: 'createBy'
         // scopedSlots: {customRender: 'createBy'}
        }, {
          title: '创建时间',
          align: "center",
          sorter: true,
          width: 100,
          dataIndex: 'createTime'
        }, {
          title: '创建人归属部门',
          width: 100,
          align: "center",
          sorter: true,
          dataIndex: 'businessAddress'
          //scopedSlots: {customRender: 'sysBusinessHall'}

        },{
          title: '上报时间',
          align: "center",
          sorter: true,
          dataIndex: 'upTime'
          //scopedSlots: {customRender: 'sysBusinessHall'}
        },

      {
          title: '办理电话',
          align: "center",
          sorter: true,
          width: 200,
          dataIndex: 'newPhone',
          scopedSlots: {customRender: 'newPhone'}
        },
        {
          title: '研判结果',
          align: "center",
          sorter: true,
          dataIndex: 'numberResults',
          scopedSlots: {customRender: 'numberResults'},
          /*customRender: function (text, record, index) {
            if (text == '1') {
              return '非高危';
            } else if (text == '2') {
              return '上报蓝紫名单';
            } else if (text == '3') {
              return '上报关停';
            }
            return '';
          }*/
        },{
          title: '当前处理部门',
          align: "center",
          sorter: true,
          dataIndex: 'businessAddress',
          fixed: 'right',
          scopedSlots: {customRender: 'current'}
          //scopedSlots: {customRender: 'sysBusinessHall'}

        },{
          title: '上报状态',
          align: "center",
          sorter: true,
          dataIndex: 'status',
          fixed: 'right',
          scopedSlots: {customRender: 'status'}
        },
        {
          title: '操作',
          dataIndex: 'action',
          align: "center",
          fixed: 'right',
          scopedSlots: {customRender: 'action'}
        }
      ],
    }
  },
  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(type) {
      const statusTypeMap = {
        '2': 'green',
        '1': 'yellow',
        '0': 'gray',
      }
      console.log(statusTypeMap[type])
      return statusTypeMap[type]
    },

    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])
      return statusTypeMap[type]
    },

    escalationFilter(status) {
      const statusMap = {
        '0': '新建未报',
        '1':'已报分公司',
        '2': '上报成功'
      }
      return statusMap[status]
    },
  },
  created() {
    /**获取研判结果统计数*/
    this.typeCount();
    this.getSysCompanyData();


  },
  methods: {

    excelOutExcel(){
      this.handleExportXls(this.excelName)
      //this.handleExportXlsData(this.excelName,'0',"out")

    },
    excelOutUp(){

      if (this.selectionRows.length===0){
        return this.$message.warning('请重新选择数据...', 3);
      }
      for (let i = 0; i < this.selectionRows.length; i++) {
        if(this.selectionRows[i].status==='2'){
          return this.$message.warning('选中数据中存在上报成功的数据...', 3);
        }
      }
      for (let i = 0; i < this.selectionRows.length; i++) {
        if(this.selectionRows[i].status==='0'){
          return this.$message.warning('选中数据中存在新建未报的数据...', 3);
        }
      }
      for (let s = 0; s < this.selectionRows.length; s++) {
        if(this.selectionRows[s].numberResults.indexOf('1')!==-1){
          return this.$message.warning('选中数据存在非高危数据（请重新选择）...', 3);
        }
      }
      this.excelOut();
      this.loadData();
      this.selectionRows=[];


    },
    excelOut(){
      // if (this.queryParam.numberResults!==undefined&&this.queryParam.numberResults!==null && this.queryParam.numberResults.length===1){
      //   if (this.queryParam.numberResults[0]==="3"){
      //     this.handleExportXlsData('上报紫名单','4')
      //     this.handleExportXlsData('上报蓝名单','3')
      //   }
      // }else {
      //   this.handleExportXls(this.excelName)
      // }
      if (this.getQueryParams().numberResults!==undefined && this.getQueryParams().numberResults.indexOf('3')!==-1){
        this.handleExportXlsData('上报紫名单','4',"up")
        this.handleExportXlsData('上报蓝名单','3',"up")
      }
      if (this.getQueryParams().numberResults!==undefined && this.getQueryParams().numberResults.indexOf('1')!==-1){
        this.handleExportXlsData('非高危','1',"up")
      }
      if (this.getQueryParams().numberResults!==undefined && this.getQueryParams().numberResults.indexOf('2')!==-1){
        this.handleExportXlsData('上报关停','2',"up")
      }
      if (this.getQueryParams().numberResults===undefined  || this.getQueryParams().numberResults.length===0){
        let url = this.url.getType;
        const params = {
          params:  this.selectionRows
        };
        postAction(url,  this.selectionRows).then(res => {
          if (res.success) {
            if (res.result.indexOf('2')!==-1){
              this.handleExportXlsData('上报关停','2',"up")
            }
            if (res.result.indexOf('1')!==-1){
              this.handleExportXlsData('非高危','1',"up")
            }
            if (res.result.indexOf('3')!==-1 || res.result.indexOf('4,3')!==-1 || res.result.indexOf('3,4')!==-1 || res.result.indexOf('4')!==-1) {
              this.handleExportXlsData('上报紫名单','4',"up")
              this.handleExportXlsData('上报蓝名单','3',"up")
            }
          }
        })

      }
      this.showImproveAndUploadList();
    },
    handleExportXlsData(fileName,num,info){
      if(!fileName || typeof fileName != "string"){
        fileName = "导出文件"
      }
      let param = this.getQueryParams();

      if (info==="up"){
        param.numberResults=[];
        param.numberResults[0]=num;
      }
      if(this.selectedRowKeys && this.selectedRowKeys.length>0){
        param['selections'] = this.selectedRowKeys.join(",")
      }
      console.log("导出参数",param)
      downFile(this.url.exportXlsUrlUp,param).then((data)=>{
        if (!data) {
          this.$message.warning("文件下载失败")
          return
        }
        if (typeof window.navigator.msSaveBlob !== 'undefined') {
          window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
        }else{
          let url = window.URL.createObjectURL(new Blob([data],{type: 'application/vnd.ms-excel'}))
          let link = document.createElement('a')
          link.style.display = 'none'
          link.href = url
          link.setAttribute('download', fileName+'.xls')
          document.body.appendChild(link)
          link.click()
          document.body.removeChild(link); //下载完成移除元素
          window.URL.revokeObjectURL(url); //释放掉blob对象
        }
      })
    },
    // getSysCompanyData(){
    //   let data = {
    //
    //   };
    //   getAction(this.url.getCompany, data).then((res) => {
    //     if (res.success) {
    //       let result = res.result;
    //       console.log(result + "result");
    //       if (result != null) {
    //         this.sysCompany = result;
    //       }
    //     }
    //   })
    // },
    // getSysCompany(id) {
    //
    //   for (var item of this.sysCompany) {
    //
    //     for (var it of item.sysBusinessHallList) {
    //       if (it.id === id) {
    //         return it.name
    //       }
    //     }
    //
    //   }
    // },


    newPhone(newPhones){
      var phone='';
      newPhones = newPhones.split(',');
      for (var item of  newPhones) {

          phone+=item+' '

      }
      return phone
    },
    currentCom(record){
      //新建未报
      if (record.status==='0'){
        return record.businessAddress
      }
      if (record.status==='1'){
        return '已报分公司'
      }
      if (record.status==='2'){
        return '已完成'
      }
    },
    showByCreateBy(record){

      this.selectRefresh();
      this.selectedRowKeys = [];
      this.selectionRows = [];

    },
    showByBusinessAddresse(record){
      let queryParam = {
        "businessAddress":record.businessAddress,
        "cardNo":this.queryParam.cardNo,
        "cardName":this.queryParam.cardName,
        "newPhone":this.queryParam.newPhone,
        "createDateStart":this.queryParam.createDateStart,
        "createDateEnd":this.queryParam.createDateEnd
      }
      this.loadData(null,queryParam);
      this.selectedRowKeys = [];
      this.selectionRows = [];

    },
    showByPhone(record){
      this.selectRefresh();
      this.selectedRowKeys = [];
      this.selectionRows = [];

    },
    showByCardNo(record){
      // let queryParam = {
      //   "cardNo":record.cardNo,
      //   "cardName":this.queryParam.cardName
      // }
      // this.loadData(null,queryParam);
      // this.selectedRowKeys = [];
      // this.selectionRows = [];

      // this.$router.go({
      //   path:'/networkAccess/registration',
      //   query: {
      //     close:true
      //   }
      // })
      //this.$router.push({path: '/networkAccess/registrationSelect', query: {id: record.id,cardNo: record.cardNo,isDisabled:true}});
      this.$router.push({path: '/networkAccess/registrationSelect', query: {id: record.id}});
    },
    showByCardName(record){
      this.selectRefresh();
      this.selectedRowKeys = [];
      this.selectionRows = [];

    },

    /**标签监听*/
    tabChange(key) {
      this.url.list = "/businessReminderCard/list"
      if (key == "all") {
        this.numberResults = null;
        this.queryParam.numberResults_MultiString = this.numberResults;
        this.currentTab = 'all';
      } else if (key == "undo") {
        this.numberResults = "1";
        this.queryParam.numberResults_MultiString = this.numberResults;
        this.currentTab = 'undo';
      } else if (key == "uncheck") {
        this.numberResults = "2";
        this.queryParam.numberResults_MultiString = this.numberResults;
        this.currentTab = 'uncheck';
      } else if (key == "checked") {
        this.numberResults = "3";
        this.queryParam.numberResults_MultiString = this.numberResults;
        this.currentTab = 'checked';
      } else if (key == "del") {
        this.numberResults = null
        this.url.list = '/businessReminderCard/delete/list'
        this.queryParam.numberResults_MultiString = this.numberResults;
        this.currentTab = 'del';
      }

      this.loadData(1);

    },

    searchQuery() {
      this.loadData(1);
      this.selectedRowKeys = [];
      this.selectionRows = [];
      //this.loadTabNumber(this.task.id);
    },
    /**统计数量*/
    typeCount() {
      let that = this;
      let url = that.url.typeCount;
      getAction(url, {}).then(res => {
        if (res.success) {
          let result = res.result;
          that.tabAll = '全部（' + result.count + '）';
          console.log(that.tabAll)
          that.tabUndo = '非高危（' + result.unCount + '）';
          that.tabUncheck = '上报蓝紫名单（' + result.uncheckCount + '）';
          that.tabChecked = '上报关停（' + result.closeCount + '）';
          that.tabDelCheck = '已删除（' + result.delCount + '）';
        } else {

        }
      }).finally(() => {

      })

    },
    getDate(){
      var today = new Date();
      var dd = String(today.getDate()).padStart(2, '0');
      var mm = String(today.getMonth() + 1).padStart(2, '0');
      var yyyy = today.getFullYear();

      today =  yyyy+'-'+ mm+'-' +dd;
      return today;
    },
    /**修改*/
    showImproveAndUpload(record) {
      if (!record.createTime.match(RegExp(this.getDate()))){
        return this.$message.warning('非当天创建 禁止修改', 3);
      }
      //校验
      let data = {
        ids: [record.id],
      }
      postAction("/businessReminderCard/check",{ids: data.ids} ).then((res) => {
        if (!res.success) {
         return  this.$message.warning(res.message, 3);
        }
        this.$router.push({path: '/networkAccess/registrationUpdate', query: {id: record.id}});
      })

    },
    showImproveAndUploadAdminCom(record,status) {
      //上报分公司
       if (record.status==='1'){
         return this.$message.warning('上报状态为已上报分公司 请勿重复操作', 3);
       }
      if (record.status==='2'){
        return this.$message.warning('上报状态为已上报 请勿重复操作', 3);
      }
      let data = {
        ids: [record.id],
      }
      postAction("/businessReminderCard/escalationCom",{ids: data.ids} ).then((res) => {
        if (res.success) {
          this.$message.success(res.message, 3);
          this.loadData(1);
        } else {
          this.$message.error(res.message);
        }
      })
    },
    showImproveAndUploadAdmin(record,status) {
      //上报
      if (record.status==='0'){
        return this.$message.warning('上报状态为新建未报 请先进行上报分公司', 3);
      }
      if (record.status==='2'){
        return this.$message.warning('上报状态为已上报 请勿重复操作', 3);
      }
      let data = {
        ids: [record.id],
      }
      postAction("/businessReminderCard/escalation",{ids: data.ids} ).then((res) => {
        if (res.success) {
          this.$message.success(res.message, 3);
          this.loadData(1);
        } else {
          this.$message.error(res.message);
        }
      })
    },
    selectRefresh(){
      let queryParam = {
        "cardNo":this.queryParam.cardNo,
        "cardName":record.cardName,
        "newPhone":this.queryParam.newPhone,
        "createDateStart":this.queryParam.createDateStart,
        "createDateEnd":this.queryParam.createDateEnd,
        "sysBusinessHall":this.queryParam.sysBusinessHall,
        "status":this.queryParam.status
      }
      this.loadData(null,queryParam);
    },
    showImproveAndUploadList() {
      for (let i = 0; i < this.selectionRows.length; i++) {
        if(this.selectionRows[i].status==='2'){
          return this.$message.warning('选中数据中存在上报成功的数据...', 3);
        }
      }
      for (let i = 0; i < this.selectionRows.length; i++) {
        if(this.selectionRows[i].status==='0'){
          return this.$message.warning('选中数据中存在新建未报的数据...', 3);
        }
      }
      for (let s = 0; s < this.selectionRows.length; s++) {
        if(this.selectionRows[s].numberResults.indexOf('1')!==-1){
          return this.$message.warning('选中数据存在非高危数据（请重新选择）...', 3);
        }
      }

      let data = {
        ids: this.selectedRowKeys,
      }
      postAction("/businessReminderCard/escalation",data ).then((res) => {
        if (res.success) {
          this.$message.success(res.message, 3);
          this.loadData(1);

        } else {
          this.$message.error(res.message);
        }
      })
    },
    /**详情*/
    showCheckDetail(record) {
      let id = record.id;
      this.$router.push({path: '/networkAccess/registrationDetails', query: {id: record.id}});
    },
    /**删除*/
    delFlagById(record){
      let id = record.id;
      let that = this;
      let url = that.url.delete;
      deleteAction(url, {id: id}).then(res => {
        if (res.success) {
          this.typeCount();
          this.$message.success("删除成功", 7);
          this.loadData(1);
        } else {
          this.$message.error("删除失败", 7);
        }
      });
    },
    /**彻底删除*/
    removeById(record) {
      let id = record.id;
      let that = this;
      let url = that.url.removeById;
      getAction(url, {id: id}).then(res => {
        if (res.success) {
          this.typeCount();
          this.$message.success("删除成功", 7);
          this.loadData(1);
        } else {
          this.$message.error("删除失败", 7);
        }
      });
    },
    /**恢复*/
    restoreById(record) {
      let id = record.id;
      let that = this;
      let url = that.url.restoreById;
      getAction(url, {id: id}).then(res => {
        if (res.success) {
          this.typeCount();
          this.$message.success("恢复成功", 7);
          this.loadData(1);
        } else {
          this.$message.error("恢复失败", 7);
        }
      });
    },
    /**通知*/
    noticeDeal(record) {
      let that = this;
      that.$message.info('已通知业务员，对入网信息进行修改！');
    }

  },
}
</script>

<style scoped>

</style>