Administrator
2022-06-07 df1e8ff8136e947ce90b5b52be46d472ffd73850
新增证件管理,证书管理和上岗证管理
1 files modified
5 files added
2752 ■■■■■ changed files
src/api/accreditationRecords/accreditationRecords.js 93 ●●●●● patch | view | raw | blame | history
src/assets/js/print.js 123 ●●●●● patch | view | raw | blame | history
src/components/liu-legend/Legend.vue 54 ●●●●● patch | view | raw | blame | history
src/main.js 32 ●●●● patch | view | raw | blame | history
src/views/accreditationRecords/accreditationRecords.vue 1038 ●●●●● patch | view | raw | blame | history
src/views/accreditationRecords/accreditationRecordsPaper.vue 1412 ●●●●● patch | view | raw | blame | history
src/api/accreditationRecords/accreditationRecords.js
New file
@@ -0,0 +1,93 @@
import request from '@/router/axios';
export const getList = (current, size, params) => {
    return request({
        url: '/api/accreditationRecords/page',
        method: 'get',
        params: {
            current,
            size,
            ...params
        }
    })
}
export const getAccreditationRecords = (id) => {
    return request({
        url: '/api/accreditationRecords/details',
        method: 'get',
        params: {
            id,
        }
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/accreditationRecords/remove',
        method: 'post',
        params: {
            ids,
        }
    })
}
export const submit = (row) => {
    return request({
        url: '/api/accreditationRecords/submit',
        method: 'post',
        data: row
    })
}
export const add = (row) => {
    return request({
        url: '/api/accreditationRecords/save',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/accreditationRecords/update',
        method: 'post',
        data: row
    })
}
export const audit = (row) => {
    return request({
        url: '/api/accreditationRecords/audit',
        method: 'post',
        data: row
    })
}
export const batchAudit = (row) => {
    return request({
        url: '/api/accreditationRecords/batchAudit',
        method: 'post',
        data: row
    })
}
export const securityApply = (row) => {
    return request({
        url: '/api/accreditationRecords/securityApply',
        method: 'post',
        data: row
    })
}
export const batchAccreditation = (row) => {
    return request({
        url: '/api/accreditationRecords/batchAccreditation',
        method: 'post',
        data: row
    })
}
src/assets/js/print.js
New file
@@ -0,0 +1,123 @@
const Print = function (dom, options) {
    if (!(this instanceof Print)) return new Print(dom, options);
    this.options = this.extend({
        noPrint: '.no-print',
        onStart: function () {},
        onEnd: function () {}
    }, options);
    if ((typeof dom) === "string") {
        this.dom = document.querySelector(dom);
    } else {
        this.dom = dom;
    }
    this.init();
};
Print.prototype = {
    init: function () {
        let content = this.getStyle() + this.getHtml();
        this.writeIframe(content);
    },
    extend: function (obj, obj2) {
        for (let k in obj2) {
            obj[k] = obj2[k];
        }
        return obj;
    },
    getStyle: function () {
        let str = "";
        let styles = document.querySelectorAll('style,link');
        for (let i = 0; i < styles.length; i++) {
            str += styles[i].outerHTML;
        }
        str += "<style>" + (this.options.noPrint ? this.options.noPrint : '.no-print') + "{display:none;}</style>";
        return str;
    },
    getHtml: function () {
        let inputs = document.querySelectorAll('input');
        let textareas = document.querySelectorAll('textarea');
        let selects = document.querySelectorAll('select');
        for (let k in inputs) {
            if (inputs[k].type === "checkbox" || inputs[k].type === "radio") {
                if (inputs[k].checked === true) {
                    inputs[k].setAttribute('checked', "checked");
                } else {
                    inputs[k].removeAttribute('checked');
                }
            } else if (inputs[k].type === "text") {
                inputs[k].setAttribute('value', inputs[k].value);
            }
        }
        for (let k2 in textareas) {
            if (textareas[k2].type === 'textarea') {
                textareas[k2].innerHTML = textareas[k2].value;
            }
        }
        for (let k3 in selects) {
            if (selects[k3].type === 'select-one') {
                let child = selects[k3].children;
                for (let i in child) {
                    if (child[i].tagName === 'OPTION') {
                        if (child[i].selected === true) {
                            child[i].setAttribute('selected', "selected");
                        } else {
                            child[i].removeAttribute('selected');
                        }
                    }
                }
            }
        }
        return this.dom.outerHTML;
    },
    writeIframe: function (content) {
        let w;
        let doc;
        let iframe = document.createElement('iframe');
        let f = document.body.appendChild(iframe);
        iframe.id = "myIframe";
        iframe.style = "position:absolute;width:0;height:0;top:-10px;left:-10px;";
        w = f.contentWindow || f.contentDocument;
        doc = f.contentDocument || f.contentWindow.document;
        doc.open();
        doc.write(content);
        doc.close();
        this.toPrint(w, function () {
            document.body.removeChild(iframe);
        });
    },
    toPrint: function (w, cb) {
        let _this = this;
        w.onload = function () {
            try {
                setTimeout(function () {
                    w.focus();
                    typeof _this.options.onStart === 'function' && _this.options.onStart();
                    if (!w.document.execCommand('print', false, null)) {
                        w.print();
                    }
                    typeof _this.options.onEnd === 'function' && _this.options.onEnd();
                    w.close();
                    cb && cb();
                });
            } catch (err) {
                console.log('err', err);
            }
        };
    }
};
const MyPlugin = {};
MyPlugin.install = function (Vue, options) {
    // 4. 添加实例方法
    Vue.prototype.$print = Print;
};
export default MyPlugin;
src/components/liu-legend/Legend.vue
New file
@@ -0,0 +1,54 @@
<template>
  <span id="l-legendOur">
    <span v-for="(value,index) in datas" :key="index" class="l-l-o">
      <span class="l-l-Img" :style="{backgroundColor: value.color}"></span>
      <span class="l-l-Text">{{value.text}}</span>
    </span>
  </span>
</template>
<script>
export default ({
    props:['datas'],
    data(){
        return{
            datalist:[//示例数据格式
                {
                    color: 'rgb(236, 83, 37)',
                    text: '掉线'
                },
                {
                    color: 'rgb(49, 49, 49)',
                    text: '在线'
                }
            ]
        }
    }
})
</script>
<style lang="scss" >
#l-legendOur{
    position: absolute;
    right: 100px;
    top: 5px;
    .l-l-o{
        color: rgba($color: #000000, $alpha: .8);
        color: rgb(49, 49, 49);
        position: relative;
        right: 150px;
        margin-left: 10px;
        font-size: 14px;
        font-weight: 500;
        font-family: 'Chinese Quote,-apple-system,BlinkMacSystemFont,Segoe UI,PingFang SC,Hiragino Sans GB,Microsoft YaHei,Helvetica Neue,Helvetica,Arial,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol';
    }
    .l-l-Img{
        display: inline-block;
        width: 10px;
        height: 10px;
        // border: 1px solid rgb(17, 198, 253);
        border-radius: 3px;
        margin-right: 8px;
    }
}
</style>
src/main.js
@@ -12,13 +12,13 @@
import "@/store/onresize";
import {
  loadStyle
    loadStyle
} from './util/util'
import * as urls from '@/config/env';
import Element from 'element-ui';
import {
  iconfontUrl,
  iconfontVersion
    iconfontUrl,
    iconfontVersion
} from '@/config/env';
import i18n from './lang'; // Internationalization
import './styles/common.scss';
@@ -38,31 +38,33 @@
Vue.use(router);
Vue.use(VueAxios, axios);
Vue.use(Element, {
  i18n: (key, value) => i18n.t(key, value)
    i18n: (key, value) => i18n.t(key, value)
});
Vue.use(window.AVUE, {
  size: 'small',
  tableSize: 'small',
  calcHeight: 65,
  i18n: (key, value) => i18n.t(key, value)
    size: 'small',
    tableSize: 'small',
    calcHeight: 65,
    i18n: (key, value) => i18n.t(key, value)
});
// 注册全局容器
Vue.component('basicContainer', basicContainer);
Vue.component('basicBlock', basicBlock);
Vue.component('thirdRegister', thirdRegister);
import Print from '@/assets/js/print';
Vue.use(Print);
Vue.component('Map', Map);
Vue.component('avueUeditor', avueUeditor);
// 加载相关url地址
Object.keys(urls).forEach(key => {
  Vue.prototype[key] = urls[key];
    Vue.prototype[key] = urls[key];
});
// 加载website
Vue.prototype.website = website;
// 动态加载阿里云字体库
iconfontVersion.forEach(ele => {
  loadStyle(iconfontUrl.replace('$key', ele));
    loadStyle(iconfontUrl.replace('$key', ele));
});
Vue.config.productionTip = false;
@@ -70,10 +72,10 @@
var myVue = new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
    router,
    store,
    i18n,
    render: h => h(App)
}).$mount('#app');
export default myVue
export default myVue
src/views/accreditationRecords/accreditationRecords.vue
New file
@@ -0,0 +1,1038 @@
<template>
  <basic-container
    :class="[
      'desk1',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      :search.sync="questionBankSearch"
      @row-update="rowUpdate"
      @row-save="rowSave"
      :before-open="beforeOpen"
      @filter="filterChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          icon="el-icon-delete"
          v-if="permission.accreditationRecords_batch_delete"
          plain
          @click="handleDelete"
          >删 除
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.accreditationRecords_export"
          @click="handleExport"
          >保安员证信息导出
        </el-button>
        <el-button
          type="primary"
          size="small"
          plain
          v-if="permission.accreditationRecords_worker_batch_audit || check"
          icon="el-icon-collection-tag"
          @click="handleSecurityAudit"
          >批量审批
        </el-button>
        <el-button
          type="primary"
          size="small"
          plain
          style="display:none"
          v-if="permission.accreditationRecords_status"
          icon="el-icon-collection-tag"
          @click="handleBatch"
          >已制证
        </el-button>
        <span>
          <Legend :datas="datalistLIU"></Legend>
        </span>
        <!-- v-if="permission.notice_delete" -->
      </template>
      <template slot-scope="{ row }" slot="category">
        <el-tag>{{ row.categoryName }}</el-tag>
      </template>
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          style="display: none"
          :size="size"
          :type="type"
          v-if="permission.notice_upload"
          @click="handleUploadPage(row)"
          >附件上传
        </el-button>
        <el-button
          :type="type"
          :size="size"
          v-if="permission.accreditationRecords_worker_audit || check"
          icon="el-icon-folder-checked"
          @click="handleAudit(row)"
          >审核
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="auditStatus">
        <el-tag class="dtype">
          {{
            row.auditStatus == 1
              ? "待审核"
              : row.auditStatus == 2
              ? "审核通过"
              : "审核不通过"
          }}
          <i class="zc" v-if="row.auditStatus == 2"></i>
          <i class="yj" v-if="row.auditStatus == 3"></i>
          <i class="gz" v-if="row.auditStatus == 1"></i>
        </el-tag>
      </template>
      <template slot-scope="{ row }" slot="deptName">
        <el-tag>{{ row.deptName }}</el-tag>
      </template>
      <template slot-scope="{ row }" slot="sex">
        <el-tag>{{
          row.sex == "1" ? "男" : row.sex == "2" ? "女" : ""
        }}</el-tag>
      </template>
    </avue-crud>
    <el-dialog
      title="证书申请审核"
      :visible.sync="dialogFormVisible"
      modal-append-to-body="false"
      append-to-body="true"
      :close-on-click-model="true"
    >
      <avue-form
        ref="formAudit"
        v-model="Audit"
        :option="optionAudit"
        @reset-change="emptytChange"
        @submit="submit"
      ></avue-form>
    </el-dialog>
    <el-dialog
      title="批量审批"
      append-to-body
      :visible.sync="dialogBatchAudit"
      width="900px"
      @close="closeDialog"
    >
      <avue-form
        ref="formBatchAudit"
        v-model="batchAudit"
        :option="optionBatchAudit"
        @reset-change="emptytChange"
        @submit="submitBatchAudit"
      ></avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
import {
  getList,
  remove,
  update,
  add,
  getAccreditationRecords,
  batchAccreditation,
  audit,
  batchAudit
} from "@/api/accreditationRecords/accreditationRecords";
import { getDept } from "@/api/system/dept";
import { mapGetters } from "vuex";
import { mapState } from "vuex";
import Qs from "qs";
import { getToken } from "@/util/auth";
import Legend from "@/components/liu-legend/Legend";
export default {
  components: {
    Legend
  },
  data() {
    return {
      datalistLIU: [
        {
          color: "#29C093",
          text: "审核通过"
        },
        {
          color: "#F34A4A",
          text: "审核不通过"
        },
        {
          color: "#F48F57",
          text: "待审核"
        }
      ],
      check: false,
      form: {},
      query: {},
      questionBankSearch: {},
      loading: true,
      deptCategory: "",
      deptId: "",
      permissionAdd: "",
      permissionDelete: "",
      permissionView: "",
      permissionEdit: "",
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      Audit: {},
      dialogFormVisible: false,
      dialogBatchAudit: false,
      optionAudit: {
        height: "auto",
        calcHeight: 30,
        dialogWidth: 1000,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true, //liu
        index: true,
        stripe: true,
        viewBtn: false,
        addBtn: false,
        editBtn: false,
        selection: true,
        excelBtn: false,
        menuWidth: 230,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "审核状态",
            search: true,
            searchSpan: 5,
            span: 24,
            prop: "auditStatus",
            slot: true,
            editDisplay: false,
            addDisplay: false,
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择审核类型",
                trigger: "blur"
              }
            ],
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            span: 24,
            type: "textarea",
            prop: "auditDetail"
          }
        ]
      },
      batchAudit: {
        number: 0
      },
      optionBatchAudit: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true, //liu
        index: true,
        stripe: true,
        viewBtn: true,
        selection: false,
        excelBtn: false,
        menuWidth: 380,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "所选保安人数",
            prop: "number",
            span: 24,
            value: 0,
            disabled: true,
            labelWidth: 110
          },
          {
            label: "审核状态",
            search: true,
            searchSpan: 5,
            span: 24,
            prop: "auditStatus",
            slot: true,
            editDisplay: false,
            addDisplay: false,
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择审核类型",
                trigger: "blur"
              }
            ],
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            span: 24,
            type: "textarea",
            prop: "auditDetail"
          }
        ]
      },
      choiceList: [],
      selectionList: [],
      option: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        tip: true,
        reserveSelection: true,
        searchShow: true,
        searchMenuSpan: 6,
        align: "center",
        border: true,
        index: true,
        stripe: true,
        viewBtn: true,
        selection: true,
        excelBtn: false,
        addBtnText: "发布",
        addTitle: "发布",
        saveBtnText: "发布",
        menuWidth: 210,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        searchIndex: 5, //收缩展示数量
        column: [
          {
            label: "申请时间",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            searchSpan: 5,
            rules: [
              {
                required: true,
                message: "请输入申请时间",
                trigger: "blur"
              }
            ]
          },
          {
            label: "姓名",
            prop: "realName",
            search: true,
            searchSpan: 3,
            width: 100,
            searchLabelWidth: 50
            // display: false,
          },
          // {
          //   label: "企业名称",
          //   searchLabelWidth: "110",
          //   // prop: "deptName",
          //   prop: "deptId",
          //   type: "tree",
          //   dicUrl:
          //     "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
          //   props: {
          //     label: "title",
          //     value: "id",
          //   },
          //   // hide: true,
          //   slot: true,
          //   searchSpan: 5,
          //   display: false,
          //   search: true,
          //   minWidth: 260,
          // },
          {
            label: "企业名称",
            searchLabelWidth: "90",
            prop: "deptName",
            slot: true,
            searchSpan: 5,
            search: true,
            overHidden: true,
            minWidth: 160
          },
          {
            label: "性别",
            prop: "sex",
            width: 80,
            type: "select",
            display: false
          },
          {
            label: "身份证号码",
            prop: "idCardNo",
            search: true,
            searchLabelWidth: 90,
            searchSpan: 5,
            width: 140
          },
          {
            label: "年龄",
            prop: "age",
            width: 60
          },
          {
            label: "照片",
            prop: "avatar",
            type: "upload",
            listType: "picture-img",
            width: 60
          },
          {
            label: "保安证编号",
            prop: "securityNumber",
            search: true,
            searchLabelWidth: 90,
            width: 110,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请人",
            prop: "applyName",
            // search: true,
            searchLabelWidth: 90,
            minWidth: 80,
            // searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请人所在单位",
            prop: "applyUnit",
            search: true,
            searchLabelWidth: 120,
            minWidth: 120,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请时间",
            prop: "createTime",
            // search: true,
            searchLabelWidth: 90,
            width: 140,
            // searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "有无照片",
            prop: "isAvatar",
            type: "select",
            search: true,
            searchLabelWidth: 90,
            minWidth: 105,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false,
            hide: true,
            display: false,
            dicData: [
              {
                label: "全部",
                value: 3
              },
              {
                label: "有",
                value: 1
              },
              {
                label: "无",
                value: 2
              }
            ]
          },
          {
            label: "审核状态",
            prop: "auditStatus",
            type: "select",
            search: true,
            searchLabelWidth: 90,
            width: 110,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false,
            hide: false,
            display: false,
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            prop: "auditDetail",
            minWidth: 105,
            addDisplay: false,
            editDisplay: false,
            hide: false,
            display: false
          },
          {
            label: "是否制证",
            prop: "status",
            type: "select",
            slot: true,
            search: true,
            editDisplay: false,
            addDisplay: false,
            searchSpan: 4,
            width: 80,
            dicData: [
              {
                label: "全部",
                value: 3
              },
              {
                label: "已制证",
                value: 2
              },
              {
                label: "未制证",
                value: 1
              }
            ]
          }
        ]
      },
      data: []
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(null, false),
        viewBtn: this.vaildData(
          this.permission.accreditationRecords_view,
          false
        ),
        delBtn: this.vaildData(
          this.permission.accreditationRecords_delete,
          false
        ),
        editBtn: this.vaildData(null, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapState({
      userInfo: state => state.user.userInfo
    })
  },
  mounted() {
    this.getDeptInfo(this.userInfo.dept_id);
    this.$store.commit("setWindowSizeHeightAdd");
  },
  created() {
    if (this.userInfo.role_name == "上岗证办理管理员") {
      this.questionBankSearch["status"] = 1;
      this.questionBankSearch["auditStatus"] = 2;
      this.option.reserveSelection = false;
      this.option.tip = false;
      this.option.selection = false;
    }
    if (this.userInfo.role_name == "公安管理员") {
      //判断是否为市局管理员
      if (this.userInfo.jurisdiction == "1372091709474910209") {
        this.check = true;
      } else {
        this.check = false;
      }
    }
  },
  methods: {
    //审核
    handleAudit(row) {
      this.dialogFormVisible = true;
      this.Audit = row;
    },
    //审核
    submit(row, done, loading) {
      const data = {
        id: row.id,
        type: 1,
        auditStatus: row.auditStatus,
        auditDetail: row.auditDetail,
        auditUser: this.userInfo.Id
      };
      audit(data).then(
        () => {
          this.dialogFormVisible = false;
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    //证书批量审核
    handleSecurityAudit() {
      if (this.choiceList.length == 0) {
        this.$message({
          message: "未选择保安员",
          type: "warning"
        });
        return;
      }
      this.dialogBatchAudit = true;
      this.batchAudit.number = this.choiceList.length;
    },
    //批量审批
    submitBatchAudit(row, done, loading) {
      var that = this;
      let cho = this.choiceList;
      let str = "";
      for (let k in cho) {
        str += cho[k].id;
        if (k != cho.length - 1) {
          str += ",";
        }
      }
      const data = {
        ids: str,
        type: 1,
        auditStatus: row.auditStatus,
        auditDetail: row.auditDetail,
        auditUser: this.userInfo.Id
      };
      //提交申请
      batchAudit(data).then(
        () => {
          this.onLoad(this.page);
          that.$refs.formBatchAudit.resetFields();
          that.dialogBatchAudit = false;
          this.$message({
            type: "success",
            message: "操作成功"
          });
          //清除选项
          that.$refs.crud.toggleSelection();
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    //证书批量修改为已制证
    handleBatch() {
      if (this.choiceList.length === 0) {
        this.$message.warning("请勾选至少一位持证保安员");
        return;
      }
      this.$confirm("共选择人数" + this.choiceList.length + "人,确定已制证?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          let cho = this.choiceList;
          let str = "";
          for (let k in cho) {
            str += cho[k].id;
            if (k != cho.length - 1) {
              str += ",";
            }
          }
          const data = {
            ids: str,
            createUser: this.userInfo.user_id,
            type: 1
          };
          return batchAccreditation(data);
        })
        .then(() => {
          this.onLoad(this.page, this.questionBankSearch);
          this.$refs.crud.toggleSelection();
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    //获取当前用户部门信息
    getDeptInfo(deptId) {
      var that = this;
      getDept(deptId).then(res => {
        var deptCategory = res.data.data.deptCategory;
        deptCategory == 1
          ? (that.deptCategory = true)
          : (that.deptCategory = false);
      });
    },
    //跳转到附件列表页面
    handleUploadPage(row) {
      this.$router.push({
        path: `/resource/uploadNotice`,
        query: {
          deptId: row.deptId,
          noticeId: row.id
        }
      });
    },
    rowSave(row, done, loading) {
      if (this.deptCategory) {
        row.category = 1;
      } else {
        row.category = 2;
      }
      row["type"] = 1;
      row.deptId = this.deptId;
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      // if (this.deptCategory) {
      //   row.category = 1;
      // }else{
      //   row.category = 2;
      // }
      row.deptId = this.deptId;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      this.selectionList = list;
      this.choiceList = [];
      for (let k in list) {
        this.choiceList.push({
          id: list[k].id
        });
      }
    },
    selectionClear() {
      this.selectionList = [];
      // this.$refs.crud.toggleSelection();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page, this.questionBankSearch);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getAccreditationRecords(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.questionBankSearch);
    },
    onLoad(page, params = {}) {
      params = this.questionBankSearch;
      this.deptId = JSON.parse(
        window.localStorage.getItem("saber-userInfo")
      ).content.dept_id;
      const { releaseTimeRange } = this.query;
      params["type"] = 1;
      if (this.userInfo.role_name == "保安公司管理员") {
        //如果是保安公司管理员
        params["deptId"] = this.userInfo.dept_id;
      }
      if (this.userInfo.role_name == "培训公司管理员") {
        //如果是培训公司管理员
        params["createUser"] = this.userInfo.Id;
      }
      if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        //如果是公安管理员
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      let values = {
        ...params
      };
      if (releaseTimeRange) {
        values = {
          ...params,
          startTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query
        };
        values.releaseTimeRange = null;
      }
      this.loading = true;
      getList(page.currentPage, page.pageSize, values).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.$store.commit("setWindowSizeHeightAdd");
        this.selectionClear();
      });
    },
    //保安员证信息导出
    handleExport() {
      this.$confirm("是否导出保安员证信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.questionBankSearch;
        if (releaseTimeRange) {
          this.questionBankSearch["startTime"] = releaseTimeRange[0];
          this.questionBankSearch["endTime"] = releaseTimeRange[1];
        }
        var data = {
          type: 1,
          applyUnit: this.questionBankSearch.applyUnit,
          deptName: this.questionBankSearch.deptName,
          idCardNo: this.questionBankSearch.idCardNo,
          auditStatus: this.questionBankSearch.auditStatus,
          realName: this.questionBankSearch.realName,
          securityNumber: this.questionBankSearch.securityNumber,
          startTime: this.questionBankSearch.startTime,
          endTime: this.questionBankSearch.endTime,
          isAvatar: this.questionBankSearch.isAvatar,
          status: this.questionBankSearch.status
        };
        //导出
        if (this.userInfo.role_name == "保安公司管理员") {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        if (this.userInfo.role_name == "培训公司管理员") {
          //如果是培训公司管理员
          data["createUser"] = this.userInfo.Id;
        }
        if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
          //如果是公安管理员
          data["jurisdiction"] = this.userInfo.jurisdiction;
        }
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/accreditationRecords/export-security-paper?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.dtype {
  width: 100%;
  padding-left: 0px;
}
.dx {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 6px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #dfdfdf;
}
.zc {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #29c093;
}
.yj {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #f34a4a;
}
.gz {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #f48f57;
}
</style>
src/views/accreditationRecords/accreditationRecordsPaper.vue
New file
@@ -0,0 +1,1412 @@
<template>
  <basic-container
    :class="[
      'desk1',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      ref="crud"
      @row-del="rowDel"
      v-model="form"
      :permission="permissionList"
      :search.sync="questionBankSearch"
      @row-update="rowUpdate"
      @row-save="rowSave"
      :before-open="beforeOpen"
      @filter="filterChange"
      @search-change="searchChange"
      @search-reset="searchReset"
      @selection-change="selectionChange"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
    >
      <template slot-scope="{ row }" slot="auditStatus">
        <el-tag class="dtype">
          {{
            row.auditStatus == 1
              ? "待审核"
              : row.auditStatus == 2
              ? "审核通过"
              : "审核不通过"
          }}
          <i class="zc" v-if="row.auditStatus == 2"></i>
          <i class="yj" v-if="row.auditStatus == 3"></i>
          <i class="gz" v-if="row.auditStatus == 1"></i>
        </el-tag>
      </template>
      <template slot="menuLeft">
        <el-button
          style="display: none"
          type="danger"
          size="small"
          icon="el-icon-delete"
          v-if="permission.accreditationRecords_paper_delete || check"
          plain
          @click="handleDelete"
          >删 除
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.accreditationRecords_paper_export || check"
          @click="handleExport"
          >制证申请信息导出
        </el-button>
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.accreditationRecords_paper_exports || check"
          @click="handleExportPaper"
          >证书打印信息导出
        </el-button>
        <el-button
          type="primary"
          size="small"
          plain
          v-if="permission.accreditationRecords_batch_audit || check"
          icon="el-icon-collection-tag"
          @click="handleSecurityAudit"
          >批量审批
        </el-button>
        <!--图例 components-->
        <span>
          <Legend :datas="datalistLIU"></Legend>
        </span>
      </template>
      <template slot-scope="{ row }" slot="category">
        <el-tag>{{ row.categoryName }}</el-tag>
      </template>
      <!-- <template slot-scope="{ row }" slot="userType">
        {{ row.userType == 6 ? "已制证" : row.userType == 7 ? "未制证" : "" }}
      </template> -->
      <template slot-scope="{ type, size, row }" slot="menu">
        <el-button
          style="display: none"
          :size="size"
          :type="type"
          v-if="permission.notice_upload"
          @click="handleUploadPage(row)"
          >附件上传
        </el-button>
        <!-- <el-button
          v-if="!deptCategory"
          :size="size"
          :type="type"
          @click="handleUploadPage(row)"
          >附件查看
        </el-button> -->
        <el-button
          :type="type"
          :size="size"
          v-if="permission.accreditationRecords_audit || check"
          icon="el-icon-folder-checked"
          @click="handleAudit(row)"
          >审核
        </el-button>
        <el-button
          icon="el-icon-edit"
          :size="size"
          :type="type"
          v-if="permission.accreditationRecords_paper"
          :disabled="row.auditStatus != 2"
          @click.stop="certificateClick(row)"
          >证书打印
        </el-button>
        <!-- v-if="permission.paper_audit_check" -->
      </template>
      <template slot-scope="{ row }" slot="deptName">
        <el-tag>{{ row.deptName }}</el-tag>
      </template>
      <template slot-scope="{ row }" slot="sex">
        <el-tag>{{
          row.sex == "1" ? "男" : row.sex == "2" ? "女" : ""
        }}</el-tag>
      </template>
    </avue-crud>
    <el-dialog
      title="证书申请审核"
      :visible.sync="dialogFormVisible"
      modal-append-to-body="false"
      append-to-body="true"
      :close-on-click-model="true"
    >
      <avue-form
        ref="formAudit"
        v-model="Audit"
        :option="optionAudit"
        @reset-change="emptytChange"
        @submit="submit"
      ></avue-form>
    </el-dialog>
    <el-dialog
      title="批量审批"
      append-to-body
      :visible.sync="dialogBatchAudit"
      width="900px"
      @close="closeDialog"
    >
      <avue-form
        ref="formBatchAudit"
        v-model="batchAudit"
        :option="optionBatchAudit"
        @reset-change="emptytChange"
        @submit="submitBatchAudit"
      ></avue-form>
    </el-dialog>
    <div style="position: fixed; top: 9999px; width: 100%; height: 100%">
      <div class="certificate_box" id="certificateDom">
        <div class="security_main" ref="certificateBox">
          <div class="security_m_l_titleName widt">
            {{ certificateObj.realName }}
          </div>
          <div class="security_m_r_o_jg widt">南昌市公安局</div>
          <div class="security_m_l_titlepaperTimenian widt">
            {{ certificateYear }}
          </div>
          <div class="security_m_l_titlepaperTimeyue widt">
            {{ certificateMonth }}
          </div>
          <div class="security_m_l_downsecuritynumber widt">
            {{ certificateObj.securityNumber }}
          </div>
          <div class="security_m_r_o_right widt">
            {{ certificateObj.realName }}
          </div>
          <div class="security_m_r_o_rightbirthday widt">
            {{
              certificateObj.idCardNo
                ? certificateObj.idCardNo.slice(6, 10) +
                  "." +
                  certificateObj.idCardNo.slice(10, 12) +
                  "." +
                  certificateObj.idCardNo.slice(12, 14)
                : ""
            }}
          </div>
          <div class="security_m_r_o_rightaddress security_m_r_o_l_r widt">
            {{ certificateObj.registered }}
          </div>
          <div class="security_m_r_o_rightcardid">
            {{ certificateObj.idCardNo }}
          </div>
        </div>
      </div>
    </div>
  </basic-container>
</template>
<script>
import {
  getList,
  remove,
  update,
  add,
  getAccreditationRecords,
  audit,
  batchAudit
} from "@/api/accreditationRecords/accreditationRecords";
import { updatePaperTime } from "@/api/system/user";
import { getDept } from "@/api/system/dept";
import { mapGetters } from "vuex";
import { mapState } from "vuex";
import Qs from "qs";
import { getToken } from "@/util/auth";
import Legend from "@/components/liu-legend/Legend";
export default {
  components: {
    Legend
  },
  data() {
    return {
      check: false,
      certificateYear: null,
      certificateMonth: null,
      certificateFlag: false,
      certificateObj: {
        realName: "",
        securityNumber: "",
        idCardNo: "",
        registered: ""
      },
      datalistLIU: [
        {
          color: "#29C093",
          text: "审核通过"
        },
        {
          color: "#F34A4A",
          text: "审核不通过"
        },
        {
          color: "#F48F57",
          text: "待审核"
        }
      ],
      Audit: {},
      dialogFormVisible: false,
      dialogBatchAudit: false,
      optionAudit: {
        height: "auto",
        calcHeight: 30,
        dialogWidth: 1000,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true, //liu
        index: true,
        stripe: true,
        viewBtn: false,
        addBtn: false,
        editBtn: false,
        selection: true,
        excelBtn: false,
        menuWidth: 230,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "审核状态",
            search: true,
            searchSpan: 5,
            span: 24,
            prop: "auditStatus",
            slot: true,
            editDisplay: false,
            addDisplay: false,
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择审核类型",
                trigger: "blur"
              }
            ],
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            span: 24,
            type: "textarea",
            prop: "auditDetail"
          }
        ]
      },
      batchAudit: {
        number: 0
      },
      optionBatchAudit: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: true, //liu
        index: true,
        stripe: true,
        viewBtn: true,
        selection: false,
        excelBtn: false,
        menuWidth: 380,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "所选保安人数",
            prop: "number",
            span: 24,
            value: 0,
            disabled: true,
            labelWidth: 110
          },
          {
            label: "审核状态",
            search: true,
            searchSpan: 5,
            span: 24,
            prop: "auditStatus",
            slot: true,
            editDisplay: false,
            addDisplay: false,
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择审核类型",
                trigger: "blur"
              }
            ],
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            span: 24,
            type: "textarea",
            prop: "auditDetail"
          }
        ]
      },
      choiceList: [],
      form: {},
      query: {},
      questionBankSearch: {},
      loading: true,
      deptCategory: "",
      deptId: "",
      permissionAdd: "",
      permissionDelete: "",
      permissionView: "",
      permissionEdit: "",
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      selectionList: [],
      option: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        searchShow: true,
        searchMenuSpan: 6,
        selection: true,
        reserveSelection: true,
        align: "center",
        tip: true,
        border: true,
        index: true,
        stripe: true,
        viewBtn: false,
        // selection: true,
        excelBtn: false,
        addBtnText: "发布",
        addTitle: "发布",
        saveBtnText: "发布",
        menuWidth: 180,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        searchIndex: 5, //收缩展示数量
        column: [
          {
            label: "申请时间",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            searchSpan: 5,
            rules: [
              {
                required: true,
                message: "请输入申请时间",
                trigger: "blur"
              }
            ]
          },
          {
            label: "姓名",
            prop: "realName",
            search: true,
            searchSpan: 3,
            width: 90,
            searchLabelWidth: 50
            // display: false,
          },
          // {
          //   label: "企业名称",
          //   searchLabelWidth: "110",
          //   // prop: "deptName",
          //   prop: "deptId",
          //   type: "tree",
          //   dicUrl:
          //     "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
          //   props: {
          //     label: "title",
          //     value: "id",
          //   },
          //   // hide: true,
          //   slot: true,
          //   searchSpan: 5,
          //   display: false,
          //   search: true,
          //   minWidth: 260,
          // },
          {
            label: "企业名称",
            prop: "deptName",
            // type: "tree",
            // dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
            // props: {
            //     label: "title",
            //     value: "id",
            // },
            slot: true,
            searchSpan: 5,
            search: true,
            overHidden: true,
            minWidth: 200
          },
          {
            label: "性别",
            prop: "sex",
            width: 60,
            type: "select",
            display: false
          },
          {
            label: "身份证号码",
            prop: "idCardNo",
            search: true,
            searchLabelWidth: 90,
            minWidth: 110,
            searchSpan: 5
          },
          {
            label: "年龄",
            prop: "age",
            width: 50
          },
          {
            label: "照片",
            prop: "avatar",
            type: "upload",
            listType: "picture-img",
            width: 60
          },
          {
            label: "保安证编号",
            prop: "securityNumber",
            search: true,
            searchLabelWidth: 90,
            minWidth: 90,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请人",
            prop: "applyName",
            // search: true,
            searchLabelWidth: 90,
            width: 80,
            // searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请人所在单位",
            prop: "applyUnit",
            search: true,
            searchLabelWidth: 120,
            minWidth: 160,
            searchSpan: 5,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "申请时间",
            prop: "createTime",
            // search: true,
            searchLabelWidth: 90,
            minWidth: 105,
            // searchSpan: 4,
            addDisplay: false,
            editDisplay: false
            // hide: true,
          },
          {
            label: "审核状态",
            prop: "auditStatus",
            type: "select",
            search: true,
            searchLabelWidth: 90,
            width: 110,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false,
            hide: false,
            display: false,
            dicData: [
              {
                label: "待审核",
                value: 1
              },
              {
                label: "审核通过",
                value: 2
              },
              {
                label: "审核不通过",
                value: 3
              }
            ]
          },
          {
            label: "审核明细",
            prop: "auditDetail",
            minWidth: 105,
            addDisplay: false,
            editDisplay: false,
            hide: false,
            display: false
          },
          {
            label: "是否制证",
            prop: "status",
            type: "select",
            slot: true,
            search: true,
            editDisplay: false,
            addDisplay: false,
            searchSpan: 4,
            width: 69,
            dicData: [
              {
                label: "全部",
                value: 3
              },
              {
                label: "已制证",
                value: 2
              },
              {
                label: "未制证",
                value: 1
              }
            ]
          },
          {
            label: "有无照片",
            prop: "isAvatar",
            type: "select",
            search: true,
            searchLabelWidth: 90,
            minWidth: 105,
            searchSpan: 4,
            addDisplay: false,
            editDisplay: false,
            hide: true,
            display: false,
            dicData: [
              {
                label: "全部",
                value: 3
              },
              {
                label: "有",
                value: 1
              },
              {
                label: "无",
                value: 2
              }
            ]
          }
        ]
      },
      data: []
    };
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(null, false),
        viewBtn: this.vaildData(
          this.permission.accreditationRecords_paper_view,
          false
        ),
        delBtn: this.vaildData(null, false),
        editBtn: this.vaildData(null, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapState({
      userInfo: state => state.user.userInfo
    })
  },
  mounted() {
    this.getDeptInfo(this.userInfo.dept_id);
    this.$store.commit("setWindowSizeHeightAdd");
    // if (this.userInfo.roleName == "办证管理员") {
    //   this.search["userType"] = 7;
    // }
  },
  created() {
    if (this.userInfo.role_name == "办证管理员") {
      this.questionBankSearch["status"] = 1;
      this.questionBankSearch["auditStatus"] = 2;
    }
    if (this.userInfo.role_name == "公安管理员") {
      //判断是否为市局管理员
      if (this.userInfo.jurisdiction == "1372091709474910209") {
        this.check = true;
        // this.vaildData(this.permission.accreditationRecords_paper_delete, false);
      } else {
        this.check = false;
        // this.vaildData(null, false);
      }
    }
  },
  methods: {
    //获取当前用户部门信息
    getDeptInfo(deptId) {
      var that = this;
      getDept(deptId).then(res => {
        var deptCategory = res.data.data.deptCategory;
        deptCategory == 1
          ? (that.deptCategory = true)
          : (that.deptCategory = false);
      });
    },
    //跳转到附件列表页面
    handleUploadPage(row) {
      this.$router.push({
        path: `/resource/uploadNotice`,
        query: {
          deptId: row.deptId,
          noticeId: row.id
        }
      });
    },
    rowSave(row, done, loading) {
      if (this.deptCategory) {
        row.category = 1;
      } else {
        row.category = 2;
      }
      row["type"] = 1;
      row.deptId = this.deptId;
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    //行点击事件
    certificateClick(row) {
      var that = this;
      if (row) {
        var time = this.getNewTime();
        this.certificateYear = time[0];
        this.certificateMonth = time[1];
        this.certificateObj = row;
        setTimeout(() => {
          that.Print();
        }, 500);
      }
    },
    Print() {
      if (
        this.certificateObj.registered == "" ||
        this.certificateObj.registered == null
      ) {
        this.$message({ message: "请完善身份证住址信息", type: "warning" });
        return;
      }
      //更新发证时间
      var printDom = document.getElementById("certificateDom");
      printDom.style.position = "absolute";
      printDom.style.top = "-25.0%";
      printDom.style.left = "-23%";
      printDom.style.width = "120%";
      printDom.style.height = "100%";
      printDom.style.fontFamily = "SimSun";
      this.$print("#certificateDom", {
        noPrint: ".noPrint",
        onStart: () => {
          // console.log('打印开始', Date.parse(new Date()));
        },
        onEnd: () => {
          this.updateUserInfo();
          // console.log('打印完成', Date.parse(new Date()));
        }
      });
    },
    getNewTime() {
      var nowTime = new Date();
      var oneHoursAgo = new Date(
        new Date(nowTime).getTime() - 1 * 60 * 60 * 1000
      );
      var oneHoursAgoY = oneHoursAgo.getFullYear();
      var oneHoursAgoM =
        oneHoursAgo.getMonth() + 1 < 10
          ? "0" + (oneHoursAgo.getMonth() + 1)
          : oneHoursAgo.getMonth() + 1;
      /**
       * @return 返回1小时,2小时,3小时,4小时,24小时
       */
      return [oneHoursAgoY, oneHoursAgoM];
    },
    //更新用户发证时间
    updateUserInfo() {
      var nowTime = new Date();
      var oneHoursAgo = new Date(
        new Date(nowTime).getTime() - 1 * 60 * 60 * 1000
      );
      var oneHoursAgoY = oneHoursAgo.getFullYear();
      var oneHoursAgoM =
        oneHoursAgo.getMonth() + 1 < 10
          ? "0" + (oneHoursAgo.getMonth() + 1)
          : oneHoursAgo.getMonth() + 1;
      var day = oneHoursAgo.getDay();
      var date = oneHoursAgoY + "-" + oneHoursAgoM + "-" + day;
      const data = {
        id: this.certificateObj.userId,
        userType: 6,
        paperTime: date
      };
      updatePaperTime(data);
      this.onLoad(this.page);
    },
    //批量审批
    submitBatchAudit(row, done, loading) {
      var that = this;
      let cho = this.choiceList;
      let str = "";
      for (let k in cho) {
        str += cho[k].id;
        if (k != cho.length - 1) {
          str += ",";
        }
      }
      const data = {
        ids: str,
        type: 2,
        auditStatus: row.auditStatus,
        auditDetail: row.auditDetail,
        auditUser: this.userInfo.Id
      };
      //提交申请
      batchAudit(data).then(
        () => {
          this.onLoad(this.page);
          that.$refs.formBatchAudit.resetFields();
          that.dialogBatchAudit = false;
          this.$message({
            type: "success",
            message: "操作成功"
          });
          //清除选项
          that.$refs.crud.toggleSelection();
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      // if (this.deptCategory) {
      //   row.category = 1;
      // }else{
      //   row.category = 2;
      // }
      row.deptId = this.deptId;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    //证书批量审核
    handleSecurityAudit() {
      if (this.choiceList.length == 0) {
        this.$message({
          message: "未选择保安员",
          type: "warning"
        });
        return;
      }
      this.dialogBatchAudit = true;
      this.batchAudit.number = this.choiceList.length;
    },
    rowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
        });
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    //审核
    handleAudit(row) {
      this.dialogFormVisible = true;
      this.Audit = row;
    },
    //审核
    submit(row, done, loading) {
      const data = {
        id: row.id,
        type: 2,
        auditStatus: row.auditStatus,
        auditDetail: row.auditDetail,
        auditUser: this.userInfo.Id
      };
      audit(data).then(
        () => {
          this.dialogFormVisible = false;
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          done();
        },
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    selectionChange(list) {
      // this.selectionList = list;
      this.choiceList = [];
      for (let k in list) {
        this.choiceList.push({
          id: list[k].id
        });
      }
    },
    selectionClear() {
      this.selectionList = [];
      //下面注释防止翻页后选中的数据被清除
      // this.$refs.crud.toggleSelection();
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getAccreditationRecords(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
      done();
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      params = this.questionBankSearch;
      this.deptId = JSON.parse(
        window.localStorage.getItem("saber-userInfo")
      ).content.dept_id;
      const { releaseTimeRange } = this.query;
      // params["jurisdiction"] = this.jurisdiction;
      params["type"] = 2;
      if (this.userInfo.role_name == "保安公司管理员") {
        //如果是保安公司管理员
        params["deptId"] = this.userInfo.dept_id;
      }
      if (this.userInfo.role_name == "培训公司管理员") {
        //如果是培训公司管理员
        params["createUser"] = this.userInfo.Id;
      }
      if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        //如果是公安管理员
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      let values = {
        ...params
      };
      if (releaseTimeRange) {
        values = {
          ...params,
          startTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query
        };
        values.releaseTimeRange = null;
      }
      this.loading = true;
      getList(page.currentPage, page.pageSize, values).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.$store.commit("setWindowSizeHeightAdd");
        this.selectionClear();
      });
    },
    //保安员证信息导出
    handleExport() {
      this.$confirm("是否导出证书制证信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.questionBankSearch;
        if (releaseTimeRange) {
          this.questionBankSearch["startTime"] = releaseTimeRange[0];
          this.questionBankSearch["endTime"] = releaseTimeRange[1];
        }
        var data = {
          type: 2,
          status: this.questionBankSearch.status,
          applyUnit: this.questionBankSearch.applyUnit,
          auditStatus: this.questionBankSearch.auditStatus,
          deptName: this.questionBankSearch.deptName,
          idCardNo: this.questionBankSearch.idCardNo,
          realName: this.questionBankSearch.realName,
          securityNumber: this.questionBankSearch.securityNumber,
          startTime: this.questionBankSearch.startTime,
          endTime: this.questionBankSearch.endTime,
          isAvatar: this.questionBankSearch.isAvatar
        };
        // data['Blade-Auth'] = getToken;
        //导出
        if (this.userInfo.role_name == "保安公司管理员") {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        if (this.userInfo.role_name == "培训公司管理员") {
          //如果是培训公司管理员
          data["createUser"] = this.userInfo.Id;
        }
        if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
          //如果是公安管理员
          data["jurisdiction"] = this.userInfo.jurisdiction;
        }
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/accreditationRecords/export-security-book-paper?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    //保安员证信息导出
    handleExportPaper() {
      this.$confirm("是否导出证书打印信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.questionBankSearch;
        if (releaseTimeRange) {
          this.questionBankSearch["startTime"] = releaseTimeRange[0];
          this.questionBankSearch["endTime"] = releaseTimeRange[1];
        }
        var data = {
          type: 2,
          status: this.questionBankSearch.status,
          applyUnit: this.questionBankSearch.applyUnit,
          auditStatus: this.questionBankSearch.auditStatus,
          deptName: this.questionBankSearch.deptName,
          idCardNo: this.questionBankSearch.idCardNo,
          realName: this.questionBankSearch.realName,
          securityNumber: this.questionBankSearch.securityNumber,
          startTime: this.questionBankSearch.startTime,
          endTime: this.questionBankSearch.endTime,
          isAvatar: this.questionBankSearch.isAvatar
        };
        //导出
        if (this.userInfo.role_name == "保安公司管理员") {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        if (this.userInfo.role_name == "培训公司管理员") {
          //如果是培训公司管理员
          data["createUser"] = this.userInfo.Id;
        }
        if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
          //如果是公安管理员
          data["jurisdiction"] = this.userInfo.jurisdiction;
        }
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/accreditationRecords/export-security-book-papers?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.box {
  height: 800px;
}
.el-scrollbar {
  height: 100%;
}
.box .el-scrollbar__wrap {
  overflow: scroll;
}
.rowClickSelf {
  &:hover {
    cursor: pointer;
  }
}
//保安证  本子
.certificate_box {
  width: 100%;
  height: 90%;
  background-color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font: normal 18px "SimSuncss" !important;
}
.security_main {
  width: 630px;
  height: 512px;
  //   border: 1px solid rgba($color: #a5a5a5, $alpha: 0.5);
  // display: flex;
  // align-items: center;
  // justify-content: space-around;
  // background-size: 100% 100%;
  // background-repeat: no-repeat;
  position: relative;
}
// 标题
$upTop: 45px;
$downTop: 265px; //整体高度
//经国家保安员考试审查合格。<br />特颁此证。
.security_main-title {
  position: absolute;
  top: $upTop;
  left: 34px;
  line-height: 45px;
  letter-spacing: 3px;
}
//发证公安机关&nbsp;(印章)
.security_m_l_center {
  position: absolute;
  top: 270px;
  left: 30px;
  line-height: 40px;
}
//证件编号 &nbsp;
.security_m_l_down {
  position: absolute;
  top: 379px;
  left: 32px;
}
$rightLeft: 343px;
$rightFontSize: 18px;
$rightWidth: 77px;
$lineHigeht: 30px;
//姓名
.security_m_r_a {
  position: absolute;
  top: $downTop;
  left: $rightLeft;
  width: $rightWidth;
  text-align: justify;
  text-align-last: justify;
}
//出生年月
.security_m_r_b {
  position: absolute;
  top: $downTop + $lineHigeht * 1;
  left: $rightLeft;
  width: $rightWidth;
  text-align: justify;
  text-align-last: justify;
}
//地址
.security_m_r_c {
  position: absolute;
  top: $downTop + $lineHigeht * 2;
  left: $rightLeft;
  width: $rightWidth;
  text-align: justify;
  text-align-last: justify;
}
//公民身份证
.security_m_r_d {
  position: absolute;
  top: 363px;
  left: $rightLeft;
  width: $rightWidth;
  text-align: justify;
  text-align-last: justify;
}
//照片
// width: calc(358px / 22px);
// height: calc(441px / 22px);
.security_m_r_imgs {
  width: calc(358px / 3);
  height: calc(441px / 3);
  position: absolute;
  top: $upTop;
  left: 421px;
  img {
    width: 100%;
    height: 100%;
  }
}
// 内容
// 抬头名字
.security_m_l_titleName {
  position: absolute;
  top: 45px;
  left: 121px;
  right: 0;
  line-height: 45px;
  letter-spacing: 3px;
}
//发证时间
$timeTop: 312px; //整体高度
//年
.security_m_l_titlepaperTimenian {
  position: absolute;
  top: $timeTop;
  left: 109px;
  line-height: 40px;
}
//月
.security_m_l_titlepaperTimeyue {
  position: absolute;
  top: $timeTop;
  left: 168px;
  line-height: 40px;
}
//日
.security_m_l_titlepaperTimeri {
  position: absolute;
  top: $timeTop;
  left: 159px;
  line-height: 40px;
}
//证件编号
.security_m_l_downsecuritynumber {
  position: absolute;
  top: 386px; //整体高度
  left: 145px;
}
//内容
// 姓名
$centerLeft: 458px;
.security_m_r_o_right {
  position: absolute;
  top: $downTop + $lineHigeht * 0-2px;
  left: $centerLeft;
  // width: $rightWidth;
}
// 生日
.security_m_r_o_rightbirthday {
  position: absolute;
  top: $downTop + $lineHigeht * 1-4px;
  left: $centerLeft;
  // width: $rightWidth;
}
// 地址
.security_m_r_o_rightaddress {
  position: absolute;
  top: $downTop + $lineHigeht * 2 -6px;
  left: $centerLeft;
  width: 185px;
}
// 身份证
.security_m_r_o_rightcardid {
  position: absolute;
  top: $downTop + $lineHigeht * 4 +10px;
  left: $centerLeft;
  // width: $rightWidth;
}
//背景图
.security_main_backImge {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image: url(/img/securityCertificate/bazsss.png);
  background-size: 100% 100%;
  background-repeat: no-repeat;
}
.security_m_r_o_jg {
  position: absolute;
  top: 272px;
  left: 200px;
  line-height: 40px;
  letter-spacing: 2px;
}
.dtype {
  width: 100%;
  padding-left: 0px;
}
.dx {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 6px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #dfdfdf;
}
.zc {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #29c093;
}
.yj {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #f34a4a;
}
.gz {
  position: absolute;
  top: 50%;
  margin-top: -5px;
  margin-left: 4px;
  width: 10px;
  height: 10px;
  border-radius: 30%;
  background: #f48f57;
}
</style>