<template>
  <div class="app-container">
    <el-form label-width="100px">
      <el-row>
        <el-col :span="6">
          <el-form-item label="关键字搜索">
            <el-input v-model="KEYWORDS" placeholder="搜索姓名、单位名称、特种作业证书编号"/>
          </el-form-item>
        </el-col>
        <!--        <el-col :span="6">-->
        <!--          <el-form-item label="人员类型">-->
        <!--            <el-select ref="PTYPE" v-model="PTYPE" title="人员类型" style="width: 100%;">-->
        <!--              <el-option v-for="item in typeList" :key="item.ID" :label="item.NAME" :value="item.NAME" />-->
        <!--            </el-select>-->
        <!--          </el-form-item>-->
        <!--        </el-col>-->
        <el-col :span="6">
          <el-form-item label="作业类别">
            <el-select ref="JOB_TYPE" v-model="JOB_TYPE" title="作业类别" style="width: 100%;">
              <el-option v-for="item in jobtypeList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID" />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="6">
          <el-form-item label-width="10px">
            <el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="getQuery">
              搜索
            </el-button>
            <el-button v-waves class="filter-item" type="success" icon="el-icon-refresh" @click="goKeyReset">
              重置
            </el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      v-loading="listLoading"
      ref="multipleTable"
      :data="varList"
      :row-key="getRowKey"
      :header-cell-style="{
        'font-weight': 'bold',
        'color': '#000'
      }"
      tooltip-effect="dark"
      border
      fit
      highlight-current-row
    >
      <el-table-column
        :reserve-selection="true"
        :selectable="selectable"
        type="selection"
        width="55"
        align="center"/>
      <el-table-column type="index" label="序号" width="50" align="center" />
      <el-table-column prop="CREATOR_CORP_NAME" label="添加单位" />
      <el-table-column prop="CREATOR_NAME" label="添加人" />
      <el-table-column prop="UNITS_NAME" label="单位名称" >
        <template slot-scope="{row}">
          <template v-if="row.UNITS_ID == CORPINFO_ID" >
            {{ CORP_NAME }}
          </template>
          <template v-else>
            {{ row.UNITS_NAME }}
          </template>
        </template>
      </el-table-column>
      <!--<el-table-column prop="JOBTYPE" label="作业类别" />
      <el-table-column prop="OPERATIONITEM" label="操作项目" />-->
      <el-table-column prop="NAME" label="姓名" width="100" />
      <!--<el-table-column prop="SEX" label="性别" width="50" />
      <el-table-column prop="CERTIFICATE_NUM" label="作业证书编号" />
      <el-table-column prop="REVIEWTIME" label="复审时间" width="120" />-->
      <el-table-column label="操作" align="left" width="400">
        <template slot-scope="{row}">
          <el-button v-show="edit" type="success" icon="el-icon-edit" size="mini" @click="resetPwd(row.PERSONNELMANAGEMENT_ID,row.NAME)">重置密码</el-button>
          <el-button v-show="edit" type="success" icon="el-icon-view" size="mini" @click="gosee(row.PERSONNELMANAGEMENT_ID)">查看</el-button>
          <el-button v-show="del" :disabled="loginUserId !== row.CREATOR" type="danger" icon="el-icon-delete" size="mini" @click="handleDelete(row.PERSONNELMANAGEMENT_ID)">删除</el-button>
          <el-button v-show="edit" :disabled="loginUserId !== row.CREATOR" type="primary" icon="el-icon-edit" size="mini" @click="handleEdit(row.PERSONNELMANAGEMENT_ID)">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>

    <div class="page-btn-group">
      <div>
        <el-button v-show="add" type="primary" icon="el-icon-plus" @click="handleAdd">新增</el-button>
        <el-button v-show="del" type="danger" icon="el-icon-delete" plain @click="batchDel">删除</el-button>
      </div>
      <pagination :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="getList" />
    </div>
    <el-dialog :visible.sync="dialogFormEdit" :title="dialogType==='edit'?'修改':'新增'" width="600px" top="5vh">
      <el-form ref="form" :rules="rules" :model="form" label-width="140px" style="width: 500px;">
        <el-form-item label="单位名称" prop="UNITS_ID">
          <el-select v-model="form.UNITS_ID" placeholder="请选择" filterable style="width: 100%;">
            <el-option v-for="item in unitsnameList" :key="item.UNITS_ID" :label="item.UNITS_NAME" :value="item.UNITS_ID" />
          </el-select>
        </el-form-item>
        <el-form-item label="作业类别" prop="JOB_TYPE">
          <el-select v-model="form.JOB_TYPE" placeholder="这里选择作业类别..." style="width: 100%" @change="changeType">
            <el-option v-for="item in jobtypeList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID"/>
          </el-select>
        </el-form-item>
        <el-form-item label="操作项目" prop="OPERATIONITEM">
          <el-select v-model="form.OPERATIONITEM" clearable placeholder="这里选择操作项目..." style="width: 100%">
            <el-option v-for="item in operationitemList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.NAME" />
          </el-select>
        </el-form-item>
        <el-form-item label="手机号码" prop="PHONENUM">
          <el-input id="PHONENUM" ref="PHONENUM" v-model="form.PHONENUM" maxlength="255" placeholder="这里输入手机号码..." title="手机号码"/>
        </el-form-item>
        <el-form-item label="姓名" prop="NAME">
          <el-input id="NAME" ref="NAME" v-model="form.NAME" maxlength="255" placeholder="这里输入姓名..." title="姓名"/>
        </el-form-item>
        <el-form-item label="性别" prop="SEX">
          <el-select v-model="form.SEX" clearable placeholder="这里选择性别..." style="width: 100%">
            <el-option v-for="item in sexList" :key="item.ID" :label="item.NAME" :value="item.NAME" />
          </el-select>
        </el-form-item>
        <el-form-item label="作业证书编号" prop="CERTIFICATE_NUM">
          <el-input id="CERTIFICATE_NUM" ref="CERTIFICATE_NUM" v-model="form.CERTIFICATE_NUM" maxlength="255" placeholder="这里输入作业证书编号..." title="作业证书编号"/>
        </el-form-item>
        <el-form-item label="复审时间" prop="REVIEWTIME">
          <el-date-picker v-model="form.REVIEWTIME" value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%" type="date" placeholder="选择日期"/>
        </el-form-item>
        <el-form-item label="身份证号码" prop="IDENTITYCARD">
          <el-input id="IDENTITYCARD" ref="IDENTITYCARD" v-model="form.IDENTITYCARD" maxlength="255" placeholder="这里输入身份证号码..." title="身份证号码"/>
        </el-form-item>
        <el-form-item label="发证机关" prop="LICENSING">
          <el-input id="LICENSING" ref="LICENSING" v-model="form.LICENSING" maxlength="255" placeholder="这里输入发证机关..." title="发证机关"/>
        </el-form-item>
        <el-form-item label="有效期" prop="VALID_TIME">
          <el-date-picker
            v-model="form.VALID_TIME"
            style="width: 100%;"
            type="daterange"
            unlink-panels
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd"
            class="filter-item" />
        </el-form-item>
        <!--        <el-form-item label="用户名" prop="USERNAME">-->
        <!--          <el-input v-model="form.USERNAME" placeholder="默认用户手机号码..."/>-->
        <!--          <a style="color: red">-->
        <!--          <span>如果修改手机号，登录密码则会变成初始密码“Aa@123456789”</span></a>-->
        <!--        </el-form-item>-->
        <!--        <el-form-item v-if="dialogType != 'edit'" label="密码" prop="PASSWORD">-->
        <!--          <el-input v-model="form.userPASSWORD" show-password placeholder="这里输入密码..." />-->
        <!--        </el-form-item>-->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormEdit = false">取 消</el-button>
        <el-button type="primary" @click="confirm">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog :visible.sync="dialogFormsee" title="查看" width="600px" top="5vh">
      <el-form ref="form" :model="form" label-width="140px" style="width: 500px;">
        <!--        <el-form-item label="人员类型" prop="PTYPE">-->
        <!--          <el-input ref="NAME" v-model="form.PTYPE" disabled maxlength="255" title="姓名"/>-->
        <!--        </el-form-item>-->
        <el-form-item label="单位名称" prop="UNITS_ID">
          <el-select v-model="form.UNITS_ID" disabled placeholder="请选择" style="width: 100%;">
            <el-option v-for="item in unitsnameList" :key="item.UNITS_ID" :label="item.UNITS_NAME" :value="item.UNITS_ID" />
          </el-select>
        </el-form-item>
        <el-form-item label="作业类别" prop="JOB_TYPE">
          <el-select v-model="form.JOB_TYPE" disabled placeholder="这里选择作业类别..." style="width: 100%" @change="changeType">
            <el-option v-for="item in jobtypeList" :key="item.DICTIONARIES_ID" :label="item.NAME" :value="item.DICTIONARIES_ID"/>
          </el-select>
        </el-form-item>
        <el-form-item label="操作项目" prop="OPERATIONITEM">
          <el-input ref="OPERATIONITEM" v-model="form.OPERATIONITEM" disabled maxlength="255" title="操作项目"/>
        </el-form-item>
        <el-form-item label="姓名" prop="NAME">
          <el-input ref="NAME" v-model="form.NAME" maxlength="255" disabled placeholder="这里输入姓名..." title="姓名"/>
        </el-form-item>
        <el-form-item label="性别" prop="SEX">
          <el-select v-model="form.SEX" clearable disabled placeholder="这里选择性别..." style="width: 100%">
            <el-option v-for="item in sexList" :key="item.ID" :label="item.NAME" :value="item.NAME" />
          </el-select>
        </el-form-item>
        <el-form-item label="作业证书编号" prop="CERTIFICATE_NUM">
          <el-input ref="CERTIFICATE_NUM" v-model="form.CERTIFICATE_NUM" maxlength="255" disabled placeholder="这里输入作业证书编号..." title="作业证书编号"/>
        </el-form-item>
        <el-form-item label="复审时间" prop="REVIEWTIME">
          <el-date-picker v-model="form.REVIEWTIME" disabled value-format="yyyy-MM-dd" format="yyyy-MM-dd" style="width: 100%" type="date" placeholder="选择日期"/>
        </el-form-item>
        <el-form-item label="手机号码" prop="PHONENUM">
          <el-input ref="PHONENUM" v-model="form.PHONENUM" maxlength="255" disabled placeholder="这里输入手机号码..." title="手机号码"/>
        </el-form-item>
        <el-form-item label="身份证号码" prop="IDENTITYCARD">
          <el-input ref="IDENTITYCARD" v-model="form.IDENTITYCARD" maxlength="255" disabled placeholder="这里输入身份证号码..." title="身份证号码"/>
        </el-form-item>
        <el-form-item label="发证机关" prop="LICENSING">
          <el-input ref="LICENSING" v-model="form.LICENSING" maxlength="255" disabled placeholder="这里输入发证机关..." title="发证机关"/>
        </el-form-item>
        <el-form-item label="有效期" prop="VALID_TIME">
          <el-date-picker
            v-model="form.VALID_TIME"
            disabled
            style="width: 100%;"
            type="daterange"
            unlink-panels
            value-format="yyyy-MM-dd"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            format="yyyy-MM-dd"
            class="filter-item" />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogFormsee = false">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import Pagination from '@/components/Pagination' // 通过 el-pagination二次打包
import { requestFN } from '@/utils/request'
import waves from '@/directive/waves' // waves directive

export default {
  components: { Pagination },
  directives: { waves },
  data() {
    // eslint-disable-next-line no-unused-vars
    var hasCertificate = (rule, value, callback) => {
      if (value) {
        requestFN(
          '/personnelmanagement/hasCertificate',
          {
            CERTIFICATE_NUM: value,
            PERSONNELMANAGEMENT_ID: this.form.PERSONNELMANAGEMENT_ID
          }
        ).then((data) => {
          if (!data.pd) {
            callback()
          } else {
            callback(new Error('作业证书编号重复'))
          }
        }).catch((e) => {

        })
      } else {
        callback()
      }
    }
    var hasPhone = (rule, value, callback) => {
      requestFN(
        '/personnelmanagement/hasPhone',
        {
          PHONENUM: value,
          PERSONNELMANAGEMENT_ID: this.form.PERSONNELMANAGEMENT_ID

        }
      ).then((data) => {
        if (data.pd) {
          callback(new Error('手机号码重复'))
        }
        callback()
      }).catch((e) => {
        callback()
      })
    }
    return {
      CORP_NAME: JSON.parse(sessionStorage.getItem('user')).CORP_NAME,
      CORPINFO_ID: JSON.parse(sessionStorage.getItem('user')).CORPINFO_ID,
      listLoading: true,
      add: false,
      del: false,
      edit: false,
      loginUserId: JSON.parse(sessionStorage.getItem('user')).USER_ID,
      defaultProps: {
        value: 'id',
        children: 'nodes',
        label: 'name'
      },
      listQuery: {
        page: 1,
        limit: 20
      },
      total: 0,
      KEYWORDS: '',
      PTYPE: '',
      JOB_TYPE: '',
      VALID_TIME: [],
      VALID_STIME: '',
      VALID_ETIME: '',
      varList: [],
      unitsnameList: [],
      pd: [],
      form: {
        userPASSWORD: 'Aa@123456789', // 密码
        CORPINFO_ID: '', // 添加单位
        CREATOR: '',
        UNITS_ID: '', // 单位名称
        PTYPE: '', // 人员类型
        JOB_TYPE: '', // 作业类别
        OPERATIONITEM: '', // 操作项目
        NAME: '', // 姓名
        SEX: '', // 性别
        CERTIFICATE_NUM: '', // 作业证书编号
        REVIEWTIME: '', // 复审时间
        PHONENUM: '', // 手机号码
        IDENTITYCARD: '', // 身份证号码
        LICENSING: '', // 发证机关
        VALID_TIME: ''// 有效期
      },
      multipleSelectionAll: [], // 所有选中的数据包含跨页数据
      multipleSelection: [], // 当前页选中的数据
      dialogFormEdit: false,
      dialogFormsee: false,
      dialogType: 'add',
      rules: {
        UNITS_ID: [{ required: true, message: '单位名称不能为空' }],
        //   PTYPE: [{ required: true, message: '人员类型不能为空', trigger: 'blur' }],
        //   JOB_TYPE: [{ required: true, message: '作业类别不能为空', trigger: 'blur' }],
        //   OPERATIONITEM: [{ required: true, message: '操作项目不能为空', trigger: 'blur' }],
        NAME: [{ required: true, message: '姓名不能为空', trigger: 'blur' }],
        //   SEX: [{ required: true, message: '性别不能为空', trigger: 'blur' }],
        //   CERTIFICATE_NUM: [{ required: true, message: '作业证书编号不能为空', trigger: 'blur' },
        //     { validator: hasCertificate, trigger: 'blur' }
        //   ],
        //   REVIEWTIME: [{ required: true, message: '请选择复审时间', trigger: 'blur' }],
        PHONENUM: [{ required: true, message: '手机号码不能为空', trigger: 'blur' },
          { min: 11, max: 11, message: '请输入11位手机号码', trigger: 'blur' },
          {
            pattern: /^(13[0-9]|14[01456879]|15[0-35-9]|16[2567]|17[0-8]|18[0-9]|19[0-35-9])\d{8}$/,
            message: '请输入正确的手机号码'
          },
          { validator: hasPhone, trigger: 'blur' }]

        // IDENTITYCARD: [{ required: true, message: '身份证号码不能为空', trigger: 'blur' },
        //   {
        //     pattern: /^\d{6}(18|19|20)?\d{2}(0[1-9]|1[0-2])(([0-2][1-9])|10|20|30|31)\d{3}(\d|X|x)$/,
        //     message: '请输入正确的身份证号'
        //   }]
      //   LICENSING: [{ required: true, message: '发证机关不能为空', trigger: 'blur' }],
      //   VALID_TIME: [{ required: true, message: '请选择有效期', trigger: 'blur' }]
      },
      jobtypeList: [],
      operationitemList: [],
      typeList: [
        { ID: '0', NAME: '分公司人员' },
        { ID: '1', NAME: '相关方人员' }
      ],
      sexList: [
        { ID: '0', NAME: '男' },
        { ID: '1', NAME: '女' }
      ]
    }
  },
  watch: {
    VALID_TIME: function(newData, oldData) {
      if (!newData) {
        this.VALID_TIME = ['', '']
        this.getQuery()
      }
    },
    'form.JOB_TYPE': {
      handler(newVal, oldVal) {
        if (oldVal) {
          this.form.OPERATIONITEM = ''
        }
        if (newVal) {
          this.changeType(newVal)
        }
      }
    }
  },
  created() {
    this.getList()
    this.getJobTypeList()
    this.getUnitList()
  },
  methods: {

    getRowKey(row) {
      return row.PERSONNELMANAGEMENT_ID
    },
    // 搜索
    getQuery() {
      this.$refs.multipleTable.clearSelection()
      this.getList()
    },
    goKeyReset() {
      this.KEYWORDS = ''
      this.PTYPE = ''
      this.JOB_TYPE = ''
      this.getQuery()
    },

    // 获取列表
    getList() {
      this.listLoading = true
      requestFN(
        '/personnelmanagement/list?showCount=' + this.listQuery.limit + '&currentPage=' + this.listQuery.page,
        {
          KEYWORDS: this.KEYWORDS,
          PTYPE: this.PTYPE,
          JOB_TYPE: this.JOB_TYPE
        }
      ).then((data) => {
        this.listLoading = false
        this.varList = data.varList
        this.total = data.page.totalResult
        this.hasButton()
        this.pd = data.pd
      }).catch((e) => {
        this.listLoading = false
      })
    },
    selectable(row, index) {
      return row.CREATOR === this.loginUserId
    },
    // 添加
    handleAdd() {
      this.dialogType = 'add'
      this.resetForm()
      this.operationitemList = []
      this.getDict()
      this.dialogFormEdit = true
    },
    // 查看
    gosee(ID) {
      this.resetForm()
      this.getDict()
      this.dialogType = 'see'
      requestFN(
        '/personnelmanagement/goEdit',
        {
          PERSONNELMANAGEMENT_ID: ID
        }
      ).then((data) => {
        this.form = Object.assign({}, data.pd) // copy obj
        // this.form.VALID_TIME = [this.form.VALID_STIME, this.form.VALID_ETIME]
        this.$set(this.form, 'VALID_TIME', Object.assign([], [this.form.VALID_STIME, this.form.VALID_ETIME]))
        if (this.form.PTYPE == '分公司人员') {
          this.form.UNITS_ID = this.CORP_NAME
        } else if (this.form.PTYPE == '相关方人员') {
          // this.form.UNITS_ID = this.UNITS_NAME
        }
      }).catch((e) => {
        this.listLoading = false
      })
      this.dialogFormsee = true
    },
    // 修改
    handleEdit(ID) {
      this.resetForm()
      this.getDict()
      this.dialogType = 'edit'
      requestFN(
        '/personnelmanagement/goEdit',
        {
          PERSONNELMANAGEMENT_ID: ID
        }
      ).then((data) => {
        this.form = Object.assign({}, data.pd) // copy obj
        // this.form.VALID_TIME = [this.form.VALID_STIME, this.form.VALID_ETIME]
        this.$set(this.form, 'VALID_TIME', Object.assign([], [this.form.VALID_STIME, this.form.VALID_ETIME]))
        if (this.form.PTYPE == '分公司人员') {
          this.form.UNITS_ID = this.CORP_NAME
        } else if (this.form.PTYPE == '相关方人员') {
          // this.form.UNITS_ID = this.UNITS_NAME
        }
      }).catch((e) => {
        this.listLoading = false
      })
      this.dialogFormEdit = true
    },
    // 保存
    confirm() {
      if (this.form.VALID_TIME.length != 0) {
        this.form.VALID_STIME = this.form.VALID_TIME[0]
        this.form.VALID_ETIME = this.form.VALID_TIME[1]
      }
      // else {
      //   this.$message.warning('请选择有效期时间')
      //   return false
      // }
      if (this.form.PTYPE == '分公司人员') {
        this.form.UNITS_ID = this.CORPINFO_ID
      } else if (this.form.PTYPE == '相关方人员') {
        // this.form.UNITS_ID = this.UNITS_NAME
      }
      this.$refs.form.validate(valid => {
        if (valid) {
          this.listLoading = true
          requestFN(
            '/personnelmanagement/' + this.dialogType,
            this.form
          ).then((data) => {
            this.listLoading = false
            this.dialogFormEdit = false
            this.getList()
          }).catch((e) => {
            this.listLoading = false
          })
        } else {
          return false
        }
      })
    },
    resetPwd(id, name) {
      this.$confirm('是否将[' + name + ']的密码重置为<span style=\'color:red\'>Aa@123456789</span>?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
        dangerouslyUseHTMLString: true
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/personnelmanagement/resetPwd',
          {
            PERSONNELMANAGEMENT_ID: id
          }
        ).then(() => {
          this.$message({
            message: '重置成功',
            type: 'success'
          })
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },
    handleDelete(id) {
      this.$confirm('确定要删除吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/personnelmanagement/delete',
          {
            PERSONNELMANAGEMENT_ID: id
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },

    batchDel() {
      const _selectData = this.$refs.multipleTable.selection
      if (_selectData == null || _selectData.length == 0) {
        this.$message({
          message: '请选中要删除的项...',
          type: 'error'
        })
        return false
      }
      const ids = _selectData.map((item, index) => {
        return item.PERSONNELMANAGEMENT_ID
      }).join(',')

      this.$confirm('确定要删除选中的数据吗?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        this.listLoading = true
        requestFN(
          '/personnelmanagement/deleteAll',
          {
            DATA_IDS: ids
          }
        ).then(() => {
          this.$message({
            message: '删除成功',
            type: 'success'
          })
          this.listLoading = false
          this.varList = []
          this.listQuery.page = 1
          this.$refs.multipleTable.clearSelection()
          this.getList()
        }).catch((e) => {
          this.listLoading = false
        })
      }).catch(() => {
      })
    },
    // 判断按钮权限，用于是否显示按钮
    hasButton: function() {
      var keys = 'personnelmanagement:add,personnelmanagement:del,personnelmanagement:edit,toExcel'
      requestFN(
        '/head/hasButton',
        {
          keys: keys
        }
      ).then((data) => {
        this.add = data.personnelmanagementfhadminadd		// 新增权限
        this.del = data.personnelmanagementfhadmindel		// 删除权限
        this.edit = data.personnelmanagementfhadminedit	// 修改权限
      }).catch((e) => {
        this.listLoading = false
      })
    },
    // 获取数据字典数据
    getJobTypeList() {
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: 'a8bfd4554af54ee2b816f3007d8baea6'
        }
      ).then((data) => {
        this.jobtypeList = data.list
      }).catch((e) => {
      })
    },
    changeType(DICTIONARIES_ID) {
      requestFN(
        '/dictionaries/getLevels',
        {
          DICTIONARIES_ID: DICTIONARIES_ID
        }
      ).then((data) => {
        this.operationitemList = data.list
      }).catch((e) => {
      })
    },

    getUnitList() {
      requestFN(
        '/units/listAll',
        {}
      ).then((data) => {
        this.unitsnameList = data.varList
      }).catch((e) => {
      })
    },

    changeName(NAME) {
      if (NAME === '相关方人员') {
        this.form.UNITS_ID = ''
      }
    },
    // 获取数据字典数据
    getDict: function() {
      // requestFN(
      //   '/dictionaries/getLevels',
      //   {
      //     DICTIONARIES_ID: 'd07e370c737f413abe29bd2c2c604e01'
      //   }
      // ).then((data) => {
      //   this.jobtypeList = data.list
      // })
    },
    resetForm() {
      this.form = {
        CORPINFO_ID: '', // 添加单位
        CREATOR: '',
        UNITS_ID: '', // 单位名称
        PTYPE: '', // 人员类型
        JOB_TYPE: '', // 作业类别
        OPERATIONITEM: '', // 操作项目
        NAME: '', // 姓名
        SEX: '', // 性别
        CERTIFICATE_NUM: '', // 作业证书编号
        REVIEWTIME: '', // 复审时间
        PHONENUM: '', // 手机号码
        IDENTITYCARD: '', // 身份证号码
        LICENSING: '', // 发证机关
        VALID_TIME: ''// 有效期
      }
    }
  }
}

</script>
