<template>
|
<div class="system-add-menu-container">
|
<el-dialog v-model="ifShowApproveRuleDialog" :title="title" :close-on-click-modal="false">
|
<el-form :model="approveRuleForm" label-width="120px" ref="approveRuleFormRef" :rules="approveRuleFormRules">
|
<el-row>
|
<el-col :span="12" style="margin-bottom: 20px">
|
<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="12" style="margin-bottom: 20px">
|
<el-form-item label="部门名称" prop="depId">
|
<el-cascader :disabled="!disabled" placeholder="请选择部门名称" :options="departmentList" :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" clearable filterable class="input-add" v-model="approveRuleForm.depId"> </el-cascader>
|
</el-form-item>
|
</el-col>
|
<el-col :span="12" style="margin-bottom: 20px">
|
<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="12" style="margin-bottom: 20px" 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%; margin-bottom: 20px" v-show="disabled">
|
<el-button type="primary" :icon="Plus" 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" v-for="i in typeList">
|
<div v-if="i.id === item.approvalType">
|
层级类型:<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<div class="text item" v-for="i in auditTypeList">
|
<div v-if="i.id === item.auditType">
|
审批类型:<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<div class="text item" v-for="i in personTypeList">
|
<div v-if="i.id === item.personType">
|
人员类型:<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<div class="text item" v-for="i in contentTypeList">
|
<div v-if="i.id === item.contentType">
|
内容类型:<span>{{ i.name }}</span>
|
</div>
|
</div>
|
<!-- <div class="text item">-->
|
<!-- 关联RFID:<span>{{ item.rfidId }}</span>-->
|
<!-- </div>-->
|
<div class="text item">
|
审批人:<span>{{
|
item.unitList
|
.map((item) => {
|
return userList.find((i) => i.uid === 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.dataReportType }}</span>-->
|
<!-- </div>-->
|
<div class="text item" v-if="item.contentType == 1">
|
审批项:<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: 12px" 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-row>
|
</el-form>
|
<template #footer>
|
<div v-show="disabled" class="dialog-footer">
|
<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 lang="ts">
|
import { reactive, toRefs, ref } from 'vue';
|
import { ElMessage } from 'element-plus/es';
|
import { approveRuleApi } from '/@/api/specialWorkSystem/approveRule';
|
import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue';
|
import approveLevelDialog from '/@/views/specialWorkSystem/flow/ruleofApp/components/approveLevelDialog.vue';
|
interface dataState {
|
title: string;
|
pointTitle: string;
|
disabled: boolean;
|
ifShowApproveRuleDialog: boolean;
|
inspectPointForm: step;
|
approveRuleForm: {
|
id: number | null;
|
ruleName: number | null;
|
depId: number | null;
|
workType: number | null;
|
workLevel: number | null;
|
stepList: Array<step>;
|
};
|
approveRuleFormRules: {};
|
departmentList: [];
|
userList: [];
|
workTypeList: Array<type>;
|
timeList: Array<type>;
|
typeList: Array<type>;
|
auditTypeList: Array<type>;
|
workLevelList: Array<type>;
|
personTypeList: Array<type>;
|
contentTypeList: Array<type>;
|
}
|
|
interface type {
|
id: number;
|
name: string;
|
}
|
interface step {
|
id: number | null;
|
stepName: null;
|
stepSerial: number | null;
|
type: number | null;
|
continueTime: number | null;
|
continueTimeUnit: number | null;
|
unitList: [];
|
itemList: [];
|
}
|
export default {
|
name: 'approveRuleDialog',
|
components: { approveLevelDialog,Plus },
|
setup(props: any, context: any) {
|
const approveRuleFormRef = ref();
|
const approveLevelDialogRef = ref();
|
const data = reactive<dataState>({
|
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: '分析人' }
|
],
|
auditTypeList: [
|
{ id: 1, name: '并行单审' },
|
{ id: 2, name: '并行会审' },
|
],
|
personTypeList: [
|
{ id: 1, name: '普通人员审批' },
|
{ id: 2, name: '监护人员元审批' },
|
{ id: 3, name: '分析人员审批' }
|
],
|
contentTypeList: [
|
{ id: 1, name: '审批项审批' },
|
{ id: 2, 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: []
|
});
|
|
const openApproveLevelDialog = (type: string, value: {}) => {
|
approveLevelDialogRef.value.showApproveLevelDialog(type, value, data.userList);
|
};
|
|
const achieveApprovalLevel = (value: step, title: string) => {
|
if (title === '新增审批层级') {
|
if (data.approveRuleForm.stepList.length === 0) {
|
value.stepSerial = 1;
|
data.approveRuleForm.stepList.push(value);
|
} else {
|
value.stepSerial = (data.approveRuleForm.stepList[data.approveRuleForm.stepList.length - 1]?.stepSerial as number) + 1;
|
data.approveRuleForm.stepList.push(value);
|
}
|
} else {
|
let result = data.approveRuleForm.stepList.findIndex((item) => item.stepSerial === value.stepSerial);
|
data.approveRuleForm.stepList[result] = JSON.parse(JSON.stringify(value));
|
}
|
};
|
|
const showApproveRuleDialog = (type: string, value: { workType: number }, departmentList: [], userList: [], workTypeList: []) => {
|
data.ifShowApproveRuleDialog = true;
|
data.userList = userList;
|
data.workTypeList = workTypeList;
|
data.departmentList = departmentList;
|
if (type === '新增') {
|
data.disabled = true;
|
data.title = '新增审批规则';
|
data.approveRuleForm = {
|
id: null,
|
ruleName: null,
|
depId: null,
|
workType: null,
|
workLevel: null,
|
stepList: []
|
};
|
} else if (type === '修改') {
|
data.disabled = true;
|
data.title = '修改审批规则';
|
data.approveRuleForm = JSON.parse(JSON.stringify(value));
|
setValue(value.workType);
|
} else {
|
data.disabled = false;
|
data.title = '查看审批规则';
|
setValue(value.workType);
|
data.approveRuleForm = JSON.parse(JSON.stringify(value));
|
}
|
};
|
|
const deleteApproveLevel = (index: number, item: any) => {
|
data.approveRuleForm.stepList.splice(index, 1);
|
};
|
|
const clearValue = () => {
|
if (data.approveRuleForm.workType === 1) {
|
data.approveRuleForm.workLevel = null;
|
data.workLevelList = [
|
{ id: 3, name: '特级动火作业' },
|
{ id: 1, name: '一级动火作业' },
|
{ id: 2, name: '二级动火作业' }
|
];
|
} else if (data.approveRuleForm.workType === 3) {
|
data.approveRuleForm.workLevel = null;
|
data.workLevelList = [
|
{ id: 8, name: '一级吊装作业' },
|
{ id: 9, name: '二级吊装作业' },
|
{ id: 10, name: '三级吊装作业' }
|
];
|
} else if (data.approveRuleForm.workType === 6) {
|
data.approveRuleForm.workLevel = null;
|
data.workLevelList = [
|
{ id: 7, name: '特级高处作业' },
|
{ id: 4, name: '一级高处作业' },
|
{ id: 5, name: '二级高处作业' },
|
{ id: 6, name: '三级高处作业' },
|
];
|
} else if (data.approveRuleForm.workType === 8) {
|
data.approveRuleForm.workLevel = null;
|
data.workLevelList = [
|
{ id: 11, name: '抽盲板作业' },
|
{ id: 12, name: '堵盲板作业' }
|
];
|
} else {
|
data.approveRuleForm.workLevel = null;
|
data.workLevelList = [];
|
}
|
};
|
|
const setValue = (workType: number) => {
|
if (workType === 1) {
|
data.workLevelList = [
|
{ id: 3, name: '特级动火作业' },
|
{ id: 1, name: '一级动火作业' },
|
{ id: 2, name: '二级动火作业' },
|
];
|
} else if (workType === 3) {
|
data.workLevelList = [
|
{ id: 8, name: '一级吊装作业' },
|
{ id: 9, name: '二级吊装作业' },
|
{ id: 10, name: '三级吊装作业' }
|
];
|
} else if (workType === 6) {
|
data.workLevelList = [
|
{ id: 7, name: '四级高处作业' },
|
{ id: 4, name: '一级高处作业' },
|
{ id: 5, name: '二级高处作业' },
|
{ id: 6, name: '三级高处作业' }
|
];
|
} else if (workType === 8) {
|
data.workLevelList = [
|
{ id: 11, name: '抽盲板作业' },
|
{ id: 12, name: '堵盲板作业' }
|
];
|
} else {
|
data.workLevelList = [];
|
}
|
};
|
|
const parseNumber = (type: string, value: number) => {
|
if (type === '时间单位') {
|
return data.timeList.find((item) => item.id === value)?.name;
|
}
|
};
|
|
const submitApproveRule = () => {
|
approveRuleFormRef.value.validate(async (valid: Boolean) => {
|
if (valid) {
|
if (data.title === '新增审批规则') {
|
let res = await approveRuleApi().addApproveRule(data.approveRuleForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '审批规则新增成功',
|
duration: 2000
|
});
|
data.ifShowApproveRuleDialog = false;
|
context.emit('refreshApproveRule');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await approveRuleApi().modApproveRule(data.approveRuleForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '审批规则修改成功',
|
duration: 2000
|
});
|
data.ifShowApproveRuleDialog = false;
|
context.emit('refreshApproveRule');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: '请完善基本信息'
|
});
|
}
|
});
|
};
|
|
return {
|
...toRefs(data),
|
Plus,
|
clearValue,
|
parseNumber,
|
approveLevelDialog,
|
approveRuleFormRef,
|
approveLevelDialogRef,
|
submitApproveRule,
|
achieveApprovalLevel,
|
openApproveLevelDialog,
|
showApproveRuleDialog,
|
deleteApproveLevel
|
};
|
}
|
};
|
</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%;
|
&:deep(.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>
|