<template>
    <div class="app-container">
      <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
        <el-form-item label="身份证号" prop="idNumber">
          <el-input
            v-model="queryParams.idNumber"
            placeholder="请输入身份证号"
            clearable maxlength="20"
            style="width: 300px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <el-input
            v-model="queryParams.name"
            placeholder="请输入姓名"
            clearable maxlength="20"
            style="width: 300px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="证件编号" prop="certificateNo">
          <el-input
            v-model="queryParams.certificateNo"
            placeholder="请输入证件编号"
            clearable maxlength="20"
            style="width: 300px"
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
          <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
        </el-form-item>
      </el-form>

      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            @click="handleAdd"
          >新增</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="danger"
            plain
            size="mini"
            @click="handleDelete"
          >删除</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport" 
          >导出</el-button>
        </el-col>
        <el-col :span="1.5">
          <el-upload
              ref="upload"
              :limit="1"
              accept=".xlsx, .xls"
              :headers="upload.headers"
              :action="upload.url"
              :show-file-list="false"
              :disabled="upload.isUploading"
              :on-progress="handleFileUploadProgress"
              :on-success="handleFileSuccess"
          >
              <el-button
                type="success"
                size="mini"
                >导入
            </el-button>
          </el-upload>
        </el-col>
        <el-col :span="1.5">
          <el-button
              size="mini"
              @click="importTemplate"
              >模板下载
          </el-button>
        </el-col>
        <el-col :span="1.5">
          <el-button
            type="primary"
            plain
            icon="el-icon-plus"
            size="mini"
            :disabled="multiple"
            @click="handleTask" 
          >一人多证核验</el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>
      <el-table v-loading="loading" :data="tableListData" @selection-change="handleSelectionChange" height="800">
        <el-table-column type="selection" width="55" align="center"/>
        <el-table-column label="序号" align="center" width="80" type="index">
          <template slot-scope="scope">
            <span>{{(queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1}}</span>
          </template>
        </el-table-column> 
        <el-table-column label="姓名" align="center" prop="name" :show-overflow-tooltip="true" width="120"/>
        <el-table-column label="身份证号" align="center" prop="idNumber" :show-overflow-tooltip="true" width="180"/>
         <!-- <el-table-column label="部门" align="center" prop="deptFullName" :show-overflow-tooltip="true" width="250"/> 
        <el-table-column label="出生日期" align="center" width="120" prop="birthday" :show-overflow-tooltip="true"/>
        <el-table-column label="出生地点" align="center" prop="birthAddr" :show-overflow-tooltip="true"/> -->
        <el-table-column label="证件类型" align="center" prop="certificateTypeName" :show-overflow-tooltip="true"/>
        <el-table-column label="证件编号" align="center" prop="certificateNo" :show-overflow-tooltip="true" width="180">
          <template slot-scope="scope">
            <span style="color: #1890ff;cursor: pointer;" @click="openLog(scope.row)">{{scope.row.certificateNo}}</span>
          </template>
        </el-table-column>
        <el-table-column label="签发地"   align="center" prop="issueAddr" :show-overflow-tooltip="true"/>
        <el-table-column label="签发日期" align="center" width="120" prop="issueDay" :show-overflow-tooltip="true"/>
        <el-table-column label="有效期至" align="center" width="120" prop="issueLifespan" :show-overflow-tooltip="true"/>
        <el-table-column label="设备编号" align="center" prop="deviceNo" :show-overflow-tooltip="true"/>
        <el-table-column label="槽位编号" align="center" prop="soltNo" :show-overflow-tooltip="true"/>
        <el-table-column label="当前状态" align="center" prop="stateName" :show-overflow-tooltip="true">
          <template slot-scope="scope">
              <!-- <dict-tag :options="dict.type.dev_status" :value="scope.row.deviceState"/> -->
              <span v-if="scope.row.state==0" style="color: #FF7322;font-size: 15px;">{{scope.row.stateName}}</span>
              <span v-if="scope.row.state==1" style="color: #FEE838;font-size: 15px;">{{scope.row.stateName}}</span>
              <span v-if="scope.row.state==2" style="color: #03DF6D;font-size: 15px;">{{scope.row.stateName}}</span>
              <span v-if="scope.row.state==3" style="color: #FEE838;font-size: 15px;">{{scope.row.stateName}}</span>
              <span v-if="scope.row.state==4" style="color: #FF7322;font-size: 15px;">{{scope.row.stateName}}</span>
          </template>
        </el-table-column>
        <el-table-column label="操作"     align="center" width="200" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button v-if="scope.row.state==0||scope.row.state==4"
              size="mini"
              type="text"
              @click="handleUpdate(scope.row)"
            >编辑</el-button>
            <el-button v-if="scope.row.state==0||scope.row.state==4"
              size="mini"
              type="text"
              style="color: red;"
              @click="handleDelete(scope.row)"
            >删除</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />

      <!-- 添加或修改参数配置对话框 -->
      <el-dialog :title="title+''" :visible.sync="open" width="800px" append-to-body> 
        <el-form ref="baseForm" :model="baseForm" :rules="baseFormRules" label-width="80px"> 
          <el-row>
            <el-col :span="12">
              <el-form-item label="姓名" prop="name">
                <el-input  v-model="baseForm.name" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col>
            <el-col el-col :span="12" v-if="baseForm.deptId !== 0">
              <el-form-item label="">
                  <el-button
                      type="success"
                      size="mini"
                        @click="handleSelect()"
                      >选择人员
                  </el-button>
              </el-form-item> 
            </el-col>
            <el-col :span="12" v-if="baseForm.deptId !== 0">
              <el-form-item label="单位" prop="deptId" style="width: 100%;">
                  <treeselect
                      v-model="baseForm.deptId"
                      :options="deptOptions"
                      :normalizer="normalizer"
                      placeholder="选择单位"
                  />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="手机号码" prop="phone">
                  <el-input  v-model="baseForm.phone" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col> 
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="身份证号" prop="idNumber">
                  <el-input  v-model="baseForm.idNumber" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="出生日期" prop="birthday">
                  <el-date-picker
                      v-model="baseForm.birthday"
                      type="date"
                      placeholder="选择日期"
                      format="yyyy-MM-dd"
                      value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="出生地点" prop="birthAddr">
                  <el-input  v-model="baseForm.birthAddr" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证件类型" prop="certificateType">
                  <el-select v-model="baseForm.certificateType" placeholder="证件类型" clearable>
                    <el-option
                      v-for="dict in dict.type.sys_certificate_type"
                      :key="dict.value"
                      :label="dict.label"
                      :value="dict.value"
                    />
                  </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="证件编号" prop="certificateNo">
                  <el-input  v-model="baseForm.certificateNo" :readonly="isReadOnly" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="签发地" prop="issueAddr">
                  <el-input  v-model="baseForm.issueAddr" placeholder="请输入" maxlength="30" clearable/>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="签发日期" prop="issueDay">
                  <el-date-picker
                    v-model="baseForm.issueDay"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy-MM-dd"
                    value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="有效期至" prop="issueLifespan">
                  <el-date-picker
                    v-model="baseForm.issueLifespan"
                    type="date"
                    placeholder="选择日期"
                    format="yyyy-MM-dd"
                    value-format="yyyy-MM-dd"></el-date-picker>
              </el-form-item>
            </el-col> 
            <el-col :span="12">
                <el-form-item label-width="120px" label="是否电子标签"  prop="isEle">
                  <el-radio-group v-model="baseForm.isEle" size="small">
                    <el-radio label="1">是</el-radio>
                    <el-radio label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
            </el-col> 
            <el-col :span="12">
                <el-form-item v-if="isCreateFlage" label-width="120px" label="是否创建账号"  prop="isCreate">
                  <el-radio-group v-model="baseForm.isCreate" size="small">
                    <el-radio @change="handleRadioChange('1')" label="1">是</el-radio>
                    <el-radio @change="handleRadioChange('0')" label="0">否</el-radio>
                  </el-radio-group>
                </el-form-item>
                <el-form-item v-if="userNameFlage" label="用户名" prop="userName">
                    <el-input  v-model="baseForm.userName" placeholder="请输入" maxlength="30" clearable/>
                </el-form-item>
            </el-col>
          </el-row>
        </el-form>  
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm">确 定</el-button>
          <el-button @click="cancel">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 选择人员 -->
      <el-dialog title="选择系统人员" :visible.sync="openSelectUser" width="600px" append-to-body> 
        <el-form ref="baseForm2" :model="baseForm2" :rules="baseFormRules" label-width="100px">
          <el-row>
            <el-col :span="24">
                <el-form-item label="姓名" prop="userId">
                    <el-select
                      v-model="baseForm2.userId"
                      placeholder="请选择"
                      filterable
                      clearable
                      style="width: 100%"
                    >
                      <el-option
                        v-for="item in allUserList"
                        :key="item.userId"
                        :label="item.userName"
                        :value="item.userId"
                        @click.native="getCorpAndDept(item)"
                      />
                    </el-select>
                </el-form-item> 
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
                <el-form-item label="手机号码" prop="phone">
                    <el-input style="width: 100%;background-color:#DAE1EE;" v-model="baseForm2.phone" readonly="true" maxlength="30" clearable/>
                </el-form-item>
            </el-col>
          </el-row> 
        </el-form> 
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="submitForm2">确 定</el-button>
          <el-button @click="cancel2">取 消</el-button>
        </div>
      </el-dialog>
      <!-- 核验任务下达 -->
      <el-dialog title="核验任务下达" :visible.sync="openTask" width="600px" append-to-body> 
            <el-form ref="taskForm" :model="taskForm" :rules="taskRules" label-width="120px"> 
            <el-row>
                <el-col :span="24">
                    <el-form-item label="核验截止日期" prop="verificationDate">
                        <el-date-picker
                            v-model="taskForm.verificationDate"
                            type="date"
                            placeholder="选择日期"
                            format="yyyy-MM-dd" style="width: 100%;"
                            value-format="yyyy-MM-dd"></el-date-picker>
                    </el-form-item>
                </el-col> 
            </el-row> 
            </el-form> 
            <div slot="footer" class="dialog-footer">
            <el-button type="primary" @click="submitTask">确 定</el-button>
            <el-button @click="cancelTask">取 消</el-button>
            </div>
        </el-dialog> 
    </div>
  </template>

  <script>
    import {
        listDept,
        getDept,
        delDept,
        addDept,
        updateDept,
        listDeptExcludeChild,
    } from '@/api/system/dept'
    import { getCertificateInfoListPageApi,addCertificateInfoApi, updateCertificateInfoApi,
     deleteCertificateInfoApi,getSysUserListApi } from "@/api/certificateManage/index";
    import base64 from 'base-64';
    import { getToken } from '@/utils/auth'
    import { downloadFileByUrl } from '@/utils/download'
    import Treeselect from '@riophae/vue-treeselect'
    import '@riophae/vue-treeselect/dist/vue-treeselect.css'
    export default {
        name: "certificateInfo",
        dicts: ["sys_certificate_type"],
        components: { Treeselect },
        data() {
            return {
                // 遮罩层
                loading: true,
                // 选中数组
                ids: [],
                // 非单个禁用
                single: true,
                // 非多个禁用
                multiple: true,
                // 显示搜索条件
                showSearch: true,
                // 总条数
                total: 0,
                //表格数据
                tableListData: [],
                // 弹出层标题
                title: "",
                // 是否显示弹出层
                open: false,
                checked: false,
                isCreateFlage:true,
                userNameFlage:false,
                certificateNos:[],
                isReadOnly:false,
                openSelectUser:false, 
                selectItme:{},
                allUserList:[],
                // 部门树选项
                deptOptions: [],
                // 查询参数
                queryParams: {
                    pageNum: 1,
                    pageSize: 10,
                    idNumber:null,//身份证号
                    name:null,//姓名
                    certificateNo:null,//证件编号
                },
                activeName:"baseSetting",
                deviceData:{},
                // 表单参数
                baseForm: {
                    deptId:null,
                    name:"",
                    idNumber:"",
                    birthday:"",
                    birthAddr:"",
                    certificateType:"",
                    certificateTypeName:"",
                    certificateNo:"",
                    issueAddr:"",
                    issueDay:"",
                    issueLifespan:"0",
                    createTime:"",
                    phone:"",
                    userId:"",
                    isEle:""
                },
                baseForm2: {
                    userId:"",
                    phone:""
                },
                // 表单校验
                baseFormRules: {
                    deptId: [
                        { required: true, message: "部门不能为空", trigger: "blur" }
                    ],
                    name: [
                        { required: true, message: "姓名不能为空", trigger: "blur" }
                    ],
                    idNumber: [
                        { required: true, message: "身份证不能为空", trigger: "blur" },
                        { validator: this.validateIDCard, trigger: 'blur' }
                    ],
                    certificateType: [
                        { required: true, message: "证件类型不能为空", trigger: "blur" }
                    ],
                    certificateNo: [
                        { required: true, message: "证件编号不能为空", trigger: "blur" }
                    ],
                    issueDay: [
                        { required: true, message: "签发日期不能为空", trigger: "blur" }
                    ],
                    phone: [
                        { required: true, message: "手机号码不能为空", trigger: "blur" },
                        { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
                    ],
                    issueLifespan: [
                        { required: true, message: "有效期不能为空", trigger: "blur" }
                    ]
                },
                logTableData:[],//异常弹窗
                // 总条数
                dialogTotal: 0,
                //当前菜谱
                openMenu:false,
                 //导入参数
                upload: {
                   // 是否禁用上传
                   isUploading: false,
                   // 设置上传的请求头部
                   headers: { Authorization: 'Bearer ' + getToken() },
                   // 上传的地址
                   url: process.env.VUE_APP_BASE_API + '/certificate/certificate_manage/certificateInfo/import',
                },
                //远程校验弹窗
                openTask: false,
                // 表单参数
                taskForm: {
                    verificationDate:""
                }, 
                // 表单校验
                taskRules: { 
                    verificationDate: [
                        {
                            required: true,
                            message: '核验截止日期不能为空',
                            trigger: 'blur',
                        },
                    ]
                },
            };
        },
        mounted(){
            this.getList();

        },

        methods: {
            validateIDCard(rule, value, callback) {
              // 15位身份证正则表达式
              const reg15 = /^[1-9]\d{7}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}$/;
              // 18位身份证正则表达式
              const reg18 = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}(\d|X|x)$/;
              if (reg15.test(value) || reg18.test(value)) {
                callback(); // 验证通过，无错误信息提示
              } else {
                callback(new Error('请输入有效的身份证号')); // 验证失败，显示错误信息提示
              }
            },
            handleRadioChange(val){
              if(val==1){
                this.userNameFlage=true;
                this.baseFormRules= {
                    deptId: [
                        { required: true, message: "部门不能为空", trigger: "blur" }
                    ],
                    name: [
                        { required: true, message: "姓名不能为空", trigger: "blur" }
                    ],
                    idNumber: [
                        { required: true, message: "身份证不能为空", trigger: "blur" },
                        { validator: this.validateIDCard, trigger: 'blur' }
                    ],
                    certificateType: [
                        { required: true, message: "证件类型不能为空", trigger: "blur" }
                    ],
                    certificateNo: [
                        { required: true, message: "证件编号不能为空", trigger: "blur" }
                    ],
                    issueDay: [
                        { required: true, message: "签发日期不能为空", trigger: "blur" }
                    ],
                    phone: [
                        { required: true, message: "手机号码不能为空", trigger: "blur" },
                        { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
                    ],
                    issueLifespan: [
                        { required: true, message: "有效期不能为空", trigger: "blur" }
                    ],
                    userName: [
                        { required: true, message: "用户名不能为空", trigger: "blur" }
                    ]
                }
              }else{
                this.userNameFlage=false;
                this.baseFormRules= {
                    deptId: [
                        { required: true, message: "部门不能为空", trigger: "blur" }
                    ],
                    name: [
                        { required: true, message: "姓名不能为空", trigger: "blur" }
                    ],
                    idNumber: [
                        { required: true, message: "身份证不能为空", trigger: "blur" },
                        { validator: this.validateIDCard, trigger: 'blur' }
                    ],
                    certificateType: [
                        { required: true, message: "证件类型不能为空", trigger: "blur" }
                    ],
                    certificateNo: [
                        { required: true, message: "证件编号不能为空", trigger: "blur" }
                    ],
                    issueDay: [
                        { required: true, message: "签发日期不能为空", trigger: "blur" }
                    ],
                    phone: [
                        { required: true, message: "手机号码不能为空", trigger: "blur" },
                        { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号', trigger: 'blur' }
                    ],
                    issueLifespan: [
                        { required: true, message: "有效期不能为空", trigger: "blur" }
                    ]
                }
              }
            },
            /** 搜索按钮操作 */
            handleQuery() {
                this.queryParams.pageNum = 1;
                this.getList();
            },
            /** 重置按钮操作 */
            resetQuery() {
                this.resetForm("queryForm");
                this.handleQuery();
            },
            /** 查询列表 */
            getList() {
                this.loading = true;
                let param = {
                    "pageNum":this.queryParams.pageNum,
                    "pageSize":this.queryParams.pageSize,
                    "idNumber":this.queryParams.idNumber,
                    "name":this.queryParams.name,
                    "certificateNo":this.queryParams.certificateNo
                }
                console.log("param",param)
                // let str = base64.encode(JSON.stringify(param))
                // console.log({"content":str})
                getCertificateInfoListPageApi(param).then(response => {
                    this.tableListData = response.rows;
                    this.total = Number(response.total);
                    this.loading = false;
                });
            },
            // 表单重置
            reset() {
                this.baseForm = {
                    deptId:null,
                    name:"",
                    idNumber:"",
                    birthday:"",
                    birthAddr:"",
                    certificateType:"",
                    certificateTypeName:"",
                    certificateNo:"",
                    issueAddr:"",
                    issueDay:"",
                    issueLifespan:"",
                    isEle:"0",isCreate:"0"
                };
                this.resetForm("baseForm");
            },
            /** 新增按钮操作 */
            handleAdd() {
                this.reset();
                this.open = true;
                this.isReadOnly=false;
                this.title = "新增";
                listDept().then((response) => {
                    this.deptOptions = this.handleTree(response.data, 'deptId')
                })
                console.log("this.baseForm",this.baseForm);
            },
            /** 电子标签*/
            handleCheckedOne(value, type) {
              console.log(type,value)
            },
            handleCheckedTwo(value, type) {
              console.log(type,value)
            },
            /** 转换部门数据结构 */
            normalizer(node) {
                if (node.children && !node.children.length) {
                    delete node.children
                }
                return {
                    id: node.deptId,
                    label: node.deptName,
                    children: node.children,
                }
            },
            /** 修改按钮操作 */
            handleUpdate(row) {
                this.reset();
                this.open = true;
                this.isReadOnly=true;
                this.baseForm = Object.assign({}, row)
                listDept().then((response) => {
                    this.deptOptions = this.handleTree(response.data, 'deptId')
                })
                this.title = "修改";
            },
            handleTabClick(tab, event) {
                console.log(tab, event);
            },
            /** 提交按钮 */
            submitForm: function() {
                console.log("this.baseForm",this.baseForm);
                this.$refs["baseForm"].validate(valid => {
                if (valid) {
                    if (this.baseForm.createTime != undefined) {
                        updateCertificateInfoApi(this.baseForm).then(response => {
                            this.$modal.msgSuccess("修改成功");
                            this.open = false;
                            this.getList();
                        });
                    } else {
                        addCertificateInfoApi(this.baseForm).then(response => {
                            this.$modal.msgSuccess("新增成功");
                            this.open = false;
                            this.getList();
                        });
                    }
                }
                });
            },
            // 取消按钮
            cancel() {
                this.open = false;
                this.reset();
            },
            handleSelect(){
              this.openSelectUser = true; 
              getSysUserListApi({}).then(response => {
                console.log("response",response);
                this.allUserList=response;
                this.$set(this.baseForm2,"userId",this.baseForm.userId)
                this.$set(this.baseForm2,"phone",this.baseForm.phone)
              });
            },
            getCorpAndDept(val){
              console.log("getCorpAndDept",val)
              this.selectItme=val;
              this.$set(this.baseForm2,"phone",this.selectItme.phone)
              this.$set(this.baseForm2,"userId",this.selectItme.userId)
            },
            /** 提交按钮 */
            submitForm2: function() {
                console.log("this.baseForm2",this.baseForm2);
                this.$refs["baseForm2"].validate(valid => {
                  if (valid) {
                      this.$set(this.baseForm,"phone",this.selectItme.phone)
                      this.$set(this.baseForm,"name",this.selectItme.userName)  
                      this.$set(this.baseForm,"userId",this.selectItme.userId)
                      this.$set(this.baseForm,"deptId",this.selectItme.deptId) 
                      this.openSelectUser = false;
                      this.isCreateFlage=false;
                  }
                });
            },
            // 取消按钮
            cancel2() {
                this.openSelectUser = false;
            },
            /** 删除按钮操作 */
            handleDelete(row) {
              var certificateNoRow="";
                if(row!=undefined &&row.certificateNo!=null&&row.certificateNo!=undefined){
                      certificateNoRow=row.certificateNo.split(" ");
                }
                const certificateNos = certificateNoRow || this.certificateNos;
                console.log("certificateNos",certificateNos);
                this.$modal.confirm('是否确认删除数据项？').then(() => {
                  deleteCertificateInfoApi({certificateNos:certificateNos}).then(response => {
                      console.log("deleteCertificateInfoApi",response);
                      this.getList();
                      this.$modal.msgSuccess("删除成功");
                      return;
                  });
                }).catch(() => {});
            },
            formatDate(date) {
                // 格式化为 YYYY-MM-DD
                const year = date.getFullYear();
                const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始
                const day = String(date.getDate()).padStart(2, '0');
                return `${year}-${month}-${day}`;
            },
            /** 导出按钮操作 */
            handleExport() {
              this.download('certificate/certificate_manage/certificateInfo/export', {
                ...this.queryParams
              }, `证件信息_${new Date().getTime()}.xlsx`);
            },
            // 文件上传中处理
            handleFileUploadProgress(event, file, fileList) {
                this.upload.isUploading = true
            },
            // 文件上传成功处理
            handleFileSuccess(response, file, fileList) {
                console.log(response)
                this.upload.isUploading = false
                this.$refs.upload.clearFiles()
                if(response.code==200){
                    this.$modal.msgSuccess(response.msg);
                    this.getList();
                }else{
                    this.$modal.msgError(response.msg);
                }
            },
            /** 下载模板操作 */
            importTemplate() {
              let url = window.location.origin + '/glweb/template/证件信息模板.xlsx';
              console.log(url)
              downloadFileByUrl(url)
            },
            /** 批量删除 */
            handleBatchDel(){

            },
            // 多选框选中数据
            handleSelectionChange(selection) {
              this.certificateNos = selection.map(item => item.certificateNo) 
              // 更新单选和多选状态
              this.single = selection.length !== 1
              this.multiple = !selection.length
            },
            /** 远程校验按钮操作 */
            handleTask() {
                this.resetTask() 
                this.openTask = true 
            },
            // 取消按钮
            cancelTask() {
                this.openTask = false
                this.resetTask()
            },
            // 表单重置
            resetTask() {
                this.taskForm = {
                    verificationDate:""
                } 
                this.resetForm('taskForm') 
            },
            /** 提交按钮 */
            submitTask: function () {
                this.$refs['taskForm'].validate((valid) => { 
                    let param = Object.assign({},this.taskForm)
                    console.log(param) 
                    if (valid) {  
                        //     updateUser(param).then((response) => {
                        //         this.$modal.msgSuccess('修改成功')
                        //         this.openTask = false
                        //         this.getList()
                        //     })  
                    }
                })
            },
            openLog(row){ 
              this.$router.push({ path: "/certificate/certificateManage/certificateLogList",query: {certificateInfoRowData:JSON.stringify(row)} });
            }
        }
    };
  </script>
  <style scoped lang="scss">
    .form-title{
        display: flex;
        align-items: flex-end;
        // width: 100%;
        // height: 40px;
        background: #e7f0fa;
        border-left: 3px solid #46a6ff;
        margin: 10px 0;
        padding: 5px;
    }
    .form-item{
        width: 100%;
        font-size: 14px !important;
    }
  </style>
