<template>
|
<el-dialog title="资格证书" :visible.sync="open" width="50%" append-to-body>
|
<div class="app-container home">
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="mini"
|
@click="openEdit({},'add')"
|
v-hasPermi="['system:experts:add']"
|
>新增</el-button>
|
</el-col>
|
<!-- <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>-->
|
</el-row>
|
<el-table v-loading="loading" :data="dataList">
|
<el-table-column type="index" label="序号" width="55" align="center" />
|
<el-table-column label="证书名称" align="center" prop="name"/>
|
<el-table-column label="资格类型" align="center" prop="qualificationType" />
|
<el-table-column label="作业类别" align="center" prop="jobCategory" />
|
<el-table-column label="操作项目" align="center" prop="operationItems" />
|
<el-table-column label="有效期至" align="center" prop="expiredTime"/>
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<template #default="scope">
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-edit"
|
@click="openEdit(scope.row,'edit')"
|
>编辑</el-button>
|
<el-button
|
size="mini"
|
type="text"
|
icon="el-icon-delete"
|
@click="handleDelete(scope.row,scope.index)"
|
v-hasPermi="['system:experts:remove']"
|
>删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<el-dialog :title="title" :visible.sync="dialogVisible" width="50%" append-to-body>
|
<el-form :model="form" :rules="rules" ref="ruleForm" label-width="200px">
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="证书名称" prop="name">
|
<el-input v-model="form.name"></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="资格类型" prop="operateTypeId">
|
<el-cascader
|
v-model="form.operateTypeId"
|
:options="typeList"
|
style="width: 100%"
|
:props="{ expandTrigger: 'hover', value: 'id',label: 'name',emitPath: false}"
|
@change="handleChange"></el-cascader>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="20">
|
<el-form-item label="过期时间" prop="expiredTime">
|
<el-date-picker
|
v-model="form.expiredTime"
|
value-format="yyyy-MM-dd"
|
style="width: 100%">
|
</el-date-picker>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
<div style="width: 100%;padding-bottom: 30px;display: flex;justify-content: center">
|
<el-button type="primary" @click="submit()">提交</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</el-dialog>
|
</template>
|
|
<script>
|
|
// import { verifySimplePhone, verifyIdCard } from "@/utils/validate";
|
import {addCert, editCert, delCert} from "@/api/coalMine/people";
|
import {getOperatePage} from "@/api/coalMine/operateType";
|
|
export default {
|
name: "certDialog",
|
dicts: [],
|
components: { },
|
data() {
|
return {
|
open: false,
|
id: null,
|
dialogVisible: false,
|
title: '新增证书',
|
loading: false,
|
dataList: [],
|
typeList: [],
|
form: {
|
name: '',
|
id: null,
|
staffId: null,
|
expiredTime: '',
|
operateTypeId: null
|
},
|
rules: {
|
name: [{ required: true, message: "请填写证书名称", trigger: "blur" }],
|
expiredTime: [{ required: true, message: "请选择过期时间", trigger: "blur" }],
|
operateTypeId: [{ required: true, message: "请选择资格类型", trigger: "blur" }]
|
}
|
};
|
},
|
created() {
|
|
},
|
methods: {
|
openDialog(data){
|
this.dataList = data.cmStaffQas
|
this.id = data.id
|
this.getList()
|
this.open = true
|
},
|
|
async getList() {
|
this.loading = true;
|
const res = await getOperatePage({name: ''})
|
if(res.code == 200){
|
this.typeList = this.handleTree(res.data, "id");
|
}else{
|
this.$message({
|
type: 'warning',
|
message: res.msg
|
});
|
}
|
this.loading = false;
|
},
|
|
openEdit(data,type){
|
this.dialogVisible = true
|
if(type == 'add'){
|
this.title='新增证书'
|
this.form = {
|
name: '',
|
id: null,
|
staffId: this.id,
|
expiredTime: '',
|
operateTypeId: null
|
}
|
}else {
|
this.title='编辑证书'
|
for(let i in data){
|
if(this.isKey(i,this.form)){
|
this.form[i] = data[i]
|
}
|
}
|
}
|
},
|
isKey(key,obj){
|
return key in obj
|
},
|
handleDelete(row,index){
|
this.$confirm('此操作将永久删除该条数据, 是否继续?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(async () => {
|
const res = await delCert(row.id)
|
if(res.code == 200){
|
this.$message({
|
type: 'success',
|
message: '删除成功!'
|
});
|
this.dialogVisible = false
|
this.open = false
|
this.$emit('closeDialog')
|
}else{
|
this.$message({
|
type: 'warning',
|
message: res.msg
|
});
|
}
|
}).catch(() => {
|
|
});
|
},
|
async submit(){
|
this.$refs["ruleForm"].validate(async(valid) =>{
|
if(valid) {
|
const obj = JSON.parse(JSON.stringify(this.form))
|
// console.log(obj.qualification[1],'obj',this.findNameById(this.typeList,obj.qualification[1]))
|
// if(obj.qualification.length == 2){
|
// obj.qualificationType = this.findNameById(this.typeList,obj.qualification[0])
|
// obj.jobCategory = this.findNameById(this.typeList,obj.qualification[1])
|
// obj.operateTypeId = this.obj.qualification[1]
|
// }
|
// if(obj.qualification.length == 3){
|
// obj.qualificationType = this.findNameById(this.typeList,obj.qualification[0])
|
// obj.jobCategory = this.findNameById(this.typeList,obj.qualification[1])
|
// obj.operationItems = this.findNameById(this.typeList,obj.qualification[2])
|
// obj.operateTypeId = obj.qualification[2]
|
// }
|
if(this.title == '新增证书'){
|
const {id,...data} = obj
|
const res = await addCert(data)
|
if(res.code == 200){
|
this.$message({
|
type:'success',
|
message: res.msg
|
})
|
this.dialogVisible = false
|
this.open = false
|
this.$emit('closeDialog')
|
}else{
|
this.$message({
|
type:'warning',
|
message: res.msg
|
})
|
}
|
}else{
|
const res= await editCert(obj)
|
if(res.code == 200){
|
this.$message({
|
type:'success',
|
message: res.msg
|
})
|
this.dialogVisible = false
|
this.open = false
|
this.$emit('closeDialog')
|
}else{
|
this.$message({
|
type:'warning',
|
message: res.msg
|
})
|
}
|
}
|
}else{
|
this.$message({
|
type:'warning',
|
message:'请完善必填信息'
|
})
|
}
|
})
|
},
|
|
findNameById(data,id){
|
for(const node of data){
|
if(node.id == id){
|
return node.name
|
}
|
if(node.children){
|
const foundName = this.findNameById(node.children,id)
|
if(foundName){
|
return foundName
|
}
|
}
|
}
|
return null
|
},
|
|
handleChange(){
|
|
},
|
handleQuery(){
|
|
},
|
resetQuery(){
|
|
},
|
}
|
};
|
</script>
|
|
<style scoped lang="scss">
|
.home {}
|
</style>
|