<template>
|
<div class="system-add-menu-container">
|
<el-dialog :visible.sync="ifShowApproveRuleDialog" :title="title" :close-on-click-modal="false">
|
<el-form :model="approveRuleForm" label-width="120px" ref="approveRuleFormRef" :rules="approveRuleFormRules">
|
<el-col :span="24">
|
<el-form-item label="任务名称" prop="ruleName">
|
<el-input v-model="approveRuleForm.ruleName" :disabled="!disabled" class="input-add" placeholder="请填写任务名称"> </el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="部门名称" prop="depId">
|
<el-select v-model="approveRuleForm.depId" @change="clearValue" :disabled="!disabled" placeholder="请选择作业类型" class="input-add">
|
<el-option v-for="item in departmentList" :key="item.id" :value="item.id" :label="item.department"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="作业类型" prop="workType">
|
<el-select v-model="approveRuleForm.workType" @change="clearValue" :disabled="!disabled" placeholder="请选择作业类型" class="input-add">
|
<el-option v-for="item in workTypeList" :key="item.id" :value="item.id" :label="item.name"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24" v-if="approveRuleForm.workType === 3 || approveRuleForm.workType === 6 || approveRuleForm.workType === 8 || approveRuleForm.workType === 1">
|
<el-form-item label="作业等级" prop="workLevel">
|
<el-select v-model="approveRuleForm.workLevel" :disabled="!disabled" placeholder="请选择作业等级" class="input-add">
|
<el-option v-for="item in workLevelList" :key="item.id" :value="item.id" :label="item.name"></el-option>
|
</el-select>
|
</el-form-item>
|
</el-col>
|
<el-col :span="24">
|
<el-form-item label="创建审批链">
|
<div style="width: 100%;padding-bottom: 10px" v-show="disabled">
|
<el-button type="primary" size="default" @click="openApproveLevelDialog('新增', '')">新增审批层级</el-button>
|
</div>
|
<div style="width: 100%; margin-left: -30px">
|
<div v-for="(item, index) in approveRuleForm.stepList" class="stepItem">
|
<div class="stepNum">{{ index + 1 }}</div>
|
<div class="stepCard">
|
<el-card class="box-card">
|
<div class="text item">
|
层级名称:<span>{{ item.stepName }}</span>
|
</div>
|
<!-- <div class="text item">-->
|
<!-- 所属设备区域:<span>{{ item.regionId }}</span>-->
|
<!-- </div>-->
|
<div class="text item" v-for="i in typeList">
|
<div v-if="i.id === item.type">
|
审批层级:<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<!-- <div class="text item">-->
|
<!-- 关联RFID:<span>{{ item.rfidId }}</span>-->
|
<!-- </div>-->
|
<div class="text item">
|
审批人:<span>{{
|
JSON.parse(JSON.stringify(
|
item.unitList
|
.map((item) => {
|
// for(let i in userList){
|
// debugger
|
// if(userList[i].id === item.bindUid){
|
// return userList[i].realname
|
// }
|
// }
|
return userList.find((i) => i.id === item.bindUid).realname;
|
})
|
.join('、')
|
))
|
}}</span>
|
</div>
|
<!-- <div class="text item">-->
|
<!-- 巡检指标:<span>{{ item.quotaId }}</span>-->
|
<!-- </div>-->
|
<div class="text item" v-for="i in timeList">
|
<div v-if="i.id === item.continueTimeUnit">
|
审批有效时长:<span>{{ item.continueTime }}</span>
|
<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<!-- <div class="text item">-->
|
<!-- 数据填报类型:<span>{{ item.thisReportType }}</span>-->
|
<!-- </div>-->
|
<div class="text item">
|
审批项:<span>{{
|
item.itemList
|
.map((item) => {
|
return item.itemName;
|
})
|
.join('、')
|
}}</span>
|
</div>
|
</el-card>
|
</div>
|
<div v-show="disabled">
|
<el-button type="primary" style="margin-left: 10px;margin-bottom: 10px" size="default" @click="openApproveLevelDialog('修改', item)">修改</el-button>
|
<el-button type="danger" size="default" @click="deleteApproveLevel(index, item)">删除</el-button>
|
</div>
|
</div>
|
</div>
|
</el-form-item>
|
</el-col>
|
</el-form>
|
<template #footer>
|
<div v-show="disabled" class="dialog-footer" align="right">
|
<el-button type="warning" @click="ifShowApproveRuleDialog = false" size="default" plain>取消</el-button>
|
<el-button type="primary" @click="submitApproveRule()" size="default">确认</el-button>
|
</div>
|
</template>
|
</el-dialog>
|
<approve-level-dialog ref="approveLevelDialogRef" @addApprovalLevel="achieveApprovalLevel"></approve-level-dialog>
|
</div>
|
</template>
|
|
<script>
|
import approveLevelDialog from './approveLevelDialog.vue';
|
|
export default {
|
name: 'approveRuleDialog',
|
components: {approveLevelDialog},
|
data() {
|
return {
|
title: '',
|
pointTitle: '',
|
disabled: true,
|
ifShowApproveRuleDialog: false,
|
inspectPointForm: {
|
id: null,
|
stepName: null,
|
stepSerial: null,
|
type: null,
|
continueTime: null,
|
continueTimeUnit: null,
|
unitList: [],
|
itemList: []
|
},
|
approveRuleForm: {
|
id: null,
|
ruleName: null,
|
depId: null,
|
workType: null,
|
workLevel: null,
|
stepList: []
|
},
|
approveRuleFormRules: {
|
ruleName: [{required: true, message: '请填写规则名称', trigger: 'blur'}],
|
depId: [{required: true, message: '请选择部门', trigger: 'change'}],
|
workLevel: [{required: true, message: '请选择作业等级', trigger: 'change'}],
|
workType: [{required: true, message: '请选择作业类型', trigger: 'cahnge'}]
|
},
|
departmentList: [],
|
userList: [],
|
typeList: [
|
{id: 1, name: '单人'},
|
{id: 2, name: '多人'},
|
{id: 3, name: '分析人'}
|
],
|
timeList: [
|
{id: 1, name: '日'},
|
{id: 2, name: '时'},
|
{id: 3, name: '分'}
|
],
|
workTypeList: [
|
{id: 1, name: '动火作业'},
|
{id: 2, name: '受限空间作业'},
|
{id: 3, name: '吊装作业'},
|
{id: 4, name: '动土作业'},
|
{id: 5, name: '断路作业'},
|
{id: 6, name: '高处作业'},
|
{id: 7, name: '临时用电作业'},
|
{id: 8, name: '盲板抽堵作业'}
|
],
|
workLevelList: []
|
}
|
},
|
created() {
|
|
},
|
methods: {
|
openApproveLevelDialog(type, value) {
|
this.$refs.approveLevelDialogRef.showApproveLevelDialog(type, value, this.userList);
|
},
|
|
achieveApprovalLevel(value, title) {
|
if (title === '新增审批层级') {
|
if (this.approveRuleForm.stepList.length === 0) {
|
value.stepSerial = 1;
|
this.approveRuleForm.stepList.push(value);
|
} else {
|
value.stepSerial = (this.approveRuleForm.stepList[this.approveRuleForm.stepList.length - 1].stepSerial) +1;
|
this.approveRuleForm.stepList.push(value);
|
}
|
} else {
|
let result = this.approveRuleForm.stepList.findIndex((item) => item.stepSerial === value.stepSerial);
|
// this.approveRuleForm.stepList[result] = JSON.parse(JSON.stringify(value));
|
this.$set(this.approveRuleForm.stepList,result,value)
|
}
|
},
|
|
showApproveRuleDialog(type, value, departmentList, userList, workTypeList) {
|
this.ifShowApproveRuleDialog = true;
|
this.userList = userList;
|
this.workTypeList = workTypeList;
|
this.departmentList = departmentList;
|
this.$nextTick(()=>{
|
this.$refs["approveRuleFormRef"].clearValidate()
|
})
|
if (type === '新增') {
|
this.disabled = true;
|
this.title = '新增审批规则';
|
this.approveRuleForm = {
|
id: null,
|
ruleName: null,
|
depId: null,
|
workType: null,
|
workLevel: null,
|
stepList: []
|
};
|
} else if (type === '修改') {
|
this.disabled = true;
|
this.title = '修改审批规则';
|
this.approveRuleForm = JSON.parse(JSON.stringify(value));
|
this.setValue(value.workType);
|
} else {
|
this.disabled = false;
|
this.title = '查看审批规则';
|
this.setValue(value.workType);
|
this.approveRuleForm = JSON.parse(JSON.stringify(value));
|
}
|
},
|
|
deleteApproveLevel(index, item) {
|
this.approveRuleForm.stepList.splice(index, 1);
|
},
|
|
clearValue() {
|
if (this.approveRuleForm.workType === 1) {
|
this.approveRuleForm.workLevel = null;
|
this.workLevelList = [
|
{id: 3, name: '特级动火作业'},
|
{id: 1, name: '一级动火作业'},
|
{id: 2, name: '二级动火作业'}
|
];
|
} else if (this.approveRuleForm.workType === 3) {
|
this.approveRuleForm.workLevel = null;
|
this.workLevelList = [
|
{id: 8, name: '一级吊装作业'},
|
{id: 9, name: '二级吊装作业'},
|
{id: 10, name: '三级吊装作业'}
|
];
|
} else if (this.approveRuleForm.workType === 6) {
|
this.approveRuleForm.workLevel = null;
|
this.workLevelList = [
|
{id: 7, name: '特级高处作业'},
|
{id: 4, name: '一级高处作业'},
|
{id: 5, name: '二级高处作业'},
|
{id: 6, name: '三级高处作业'},
|
];
|
} else if (this.approveRuleForm.workType === 8) {
|
this.approveRuleForm.workLevel = null;
|
this.workLevelList = [
|
{id: 11, name: '抽盲板作业'},
|
{id: 12, name: '堵盲板作业'}
|
];
|
} else {
|
this.approveRuleForm.workLevel = null;
|
this.workLevelList = [];
|
}
|
},
|
|
setValue(workType) {
|
if (workType === 1) {
|
this.workLevelList = [
|
{id: 3, name: '特级动火作业'},
|
{id: 1, name: '一级动火作业'},
|
{id: 2, name: '二级动火作业'},
|
];
|
} else if (workType === 3) {
|
this.workLevelList = [
|
{id: 8, name: '一级吊装作业'},
|
{id: 9, name: '二级吊装作业'},
|
{id: 10, name: '三级吊装作业'}
|
];
|
} else if (workType === 6) {
|
this.workLevelList = [
|
{id: 7, name: '四级高处作业'},
|
{id: 4, name: '一级高处作业'},
|
{id: 5, name: '二级高处作业'},
|
{id: 6, name: '三级高处作业'}
|
];
|
} else if (workType === 8) {
|
this.workLevelList = [
|
{id: 11, name: '抽盲板作业'},
|
{id: 12, name: '堵盲板作业'}
|
];
|
} else {
|
this.workLevelList = [];
|
}
|
},
|
|
parseNumber(type, value) {
|
if (type === '时间单位') {
|
return this.timeList.find((item) => item.id === value).name;
|
}
|
},
|
|
submitApproveRule() {
|
this.$refs["approveRuleFormRef"].validate(async (valid) => {
|
if (valid) {
|
if (this.title === '新增审批规则') {
|
let res = await approveRuleApi().addApproveRule(this.approveRuleForm);
|
if (res.data.code === '200') {
|
this.$message({
|
type: 'success',
|
message: '审批规则新增成功',
|
duration: 2000
|
});
|
this.ifShowApproveRuleDialog = false;
|
this.$emit('refreshApproveRule');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await approveRuleApi().modApproveRule(this.approveRuleForm);
|
if (res.data.code === '200') {
|
this.$message({
|
type: 'success',
|
message: '审批规则修改成功',
|
duration: 2000
|
});
|
this.ifShowApproveRuleDialog = false;
|
this.$emit('refreshApproveRule');
|
} else {
|
this.$message({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
} else {
|
this.$message({
|
type: 'warning',
|
message: '请完善基本信息'
|
});
|
}
|
});
|
}
|
},
|
};
|
</script>
|
|
<style scoped lang="scss">
|
$homeNavLengh: 8;
|
.home-container {
|
height: calc(100vh - 144px);
|
box-sizing: border-box;
|
overflow: hidden;
|
.homeCard {
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
|
.main-card {
|
width: 100%;
|
height: 100%;
|
.cardTop {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
.mainCardBtn {
|
margin: 0;
|
}
|
}
|
.pageBtn {
|
height: 60px;
|
display: flex;
|
align-items: center;
|
justify-content: right;
|
|
.demo-pagination-block + .demo-pagination-block {
|
margin-top: 10px;
|
}
|
.demo-pagination-block .demonstration {
|
margin-bottom: 16px;
|
}
|
}
|
}
|
&:last-of-type {
|
height: calc(100% - 100px);
|
}
|
}
|
.el-row {
|
display: flex;
|
align-items: center;
|
margin-bottom: 20px;
|
&:last-child {
|
margin-bottom: 0;
|
}
|
.grid-content {
|
align-items: center;
|
min-height: 36px;
|
}
|
|
.topInfo {
|
display: flex;
|
align-items: center;
|
font-size: 16px;
|
font-weight: bold;
|
|
& > div {
|
white-space: nowrap;
|
margin-right: 20px;
|
}
|
}
|
}
|
}
|
.stepItem {
|
width: 100%;
|
display: flex;
|
align-items: flex-start;
|
margin-bottom: 30px;
|
margin-left: 30px;
|
padding-bottom: 30px;
|
border-left: 2px solid #ccc;
|
&:first-of-type {
|
margin-top: 30px;
|
}
|
&:last-of-type {
|
margin-bottom: 0;
|
border-left: none;
|
}
|
.stepNum {
|
width: 30px;
|
height: 30px;
|
border-radius: 15px;
|
box-sizing: border-box;
|
color: #333;
|
border: 1px solid #999;
|
line-height: 28px;
|
text-align: center;
|
margin-right: 10px;
|
margin-left: -16px;
|
margin-top: -30px;
|
}
|
.stepCard {
|
width: 100%;
|
margin-top: -30px;
|
|
.box-card {
|
width: 100%;
|
>>>.el-card__header {
|
padding: 10px 15px;
|
}
|
.card-header {
|
width: 100%;
|
display: flex;
|
justify-content: space-between;
|
align-items: center;
|
& > div:first-of-type {
|
margin-right: 80px;
|
font-size: 18px;
|
font-weight: bold;
|
}
|
}
|
}
|
}
|
&:hover .card-header {
|
color: #0098f5;
|
}
|
&:hover .stepNum {
|
border: 2px solid #0098f5;
|
color: #0098f5;
|
}
|
}
|
/deep/.el-date-editor {
|
width: 100%;
|
}
|
</style>
|