<template>
|
<div class="home-container">
|
<div style="height: 100%;display: flex;flex-direction: column;align-items: stretch;">
|
<el-row class="homeCard">
|
<div class="basic-line">
|
<span>规则名称:</span>
|
<el-input v-model="tableData.params.searchParams.ruleName" class="input-box" placeholder="规则名称"> </el-input>
|
</div>
|
<div class="basic-line">
|
<span>部门:</span>
|
<el-cascader placeholder="部门名称" :options="departmentList" :props="{ emitPath: false, checkStrictly: true, value: 'depId', label: 'depName' }" clearable filterable class="input-box" v-model="tableData.params.searchParams.depId"> </el-cascader>
|
</div>
|
<div class="basic-line">
|
<span>作业类型:</span>
|
<el-select v-model="tableData.params.searchParams.workType" clearable filterable class="input-box" placeholder="作业类型">
|
<el-option v-for="item in workTypeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</div>
|
<div class="basic-line">
|
<span>作业等级:</span>
|
<el-select v-model="tableData.params.searchParams.workLevel" clearable filterable class="input-box" placeholder="作业等级">
|
<el-option v-for="item in workLevelList" :key="item.id" :label="item.name" :value="item.id"></el-option>
|
</el-select>
|
</div>
|
<div style="padding-bottom: 10px">
|
<el-button type="primary" @click="getApproveRule">查询</el-button>
|
<el-button plain @click="reset">重置</el-button>
|
</div>
|
</el-row>
|
<div class="homeCard">
|
<div class="main-card">
|
<el-row class="cardTop">
|
<el-col :span="12" class="mainCardBtn">
|
<el-button type="primary" :icon="Plus" size="default" @click="openApproveRuleDialog('新增', {})">新增</el-button>
|
<el-button type="danger" :icon="Delete" size="default" @click="deleteMoreApproveRule" plain>批量删除</el-button>
|
</el-col>
|
<el-button type="primary" :icon="Refresh" size="default" />
|
</el-row>
|
<el-table ref="multipleTableRef" :data="tableData.approveRuleData" style="width: 100%" height="calc(100% - 100px)" :header-cell-style="{ background: '#fafafa' }" @selection-change="handleSelectionChange">
|
<el-table-column type="selection" width="55" />
|
<el-table-column property="ruleName" label="任务名称" />
|
<el-table-column property="workType" label="作业类型">
|
<template #default="scope">
|
<span>
|
{{ parseNumber(scope.row.workType, '作业类型') }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column property="workLevel" label="作业等级">
|
<template #default="scope">
|
<span>
|
{{ parseNumber(scope.row.workLevel, '作业等级') }}
|
</span>
|
</template>
|
</el-table-column>
|
<el-table-column prop="createUname" label="创建人" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="gmtCreate" label="创建时间" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="modifiedUname" label="最后修改人" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="gmtModified" label="最后修改时间" show-overflow-tooltip></el-table-column>
|
<el-table-column fixed="right" label="操作" align="center" width="300">
|
<template #default="scope">
|
<el-button link type="primary" size="small" :icon="View" @click="openApproveRuleDialog('查看', scope.row)">查看</el-button>
|
<el-button link type="primary" size="small" :icon="Edit" @click="openApproveRuleDialog('修改', scope.row)">修改</el-button>
|
<el-button link type="primary" style="color: red" size="small" :icon="Delete" @click="deleteApproveRule(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
<div class="pageBtn">
|
<el-pagination @size-change="onHandleSizeChange" @current-change="onHandleCurrentChange" :pager-count="5" :page-sizes="[10, 20, 30]" v-model:current-page="tableData.params.pageIndex" background v-model:page-size="tableData.params.pageSize" layout="total, sizes, prev, pager, next, jumper" :total="tableData.total" class="page-position"> </el-pagination>
|
</div>
|
</div>
|
</div>
|
</div>
|
<approve-rule-dialog ref="approveRuleDialogRef" @refreshApproveRule="getApproveRule"></approve-rule-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
import { toRefs, reactive, ref, onMounted } from 'vue';
|
import { Edit, View, Plus, Delete, Refresh, Search, Download } from '@element-plus/icons-vue';
|
import { ElTable, ElMessage, ElMessageBox } from 'element-plus';
|
import approveRuleDialog from '/@/views/specialWorkSystem/flow/ruleofApp/components/approveRuleDialog.vue';
|
import { departmentApi } from '/@/api/systemManage/department';
|
import { approveRuleApi } from '/@/api/specialWorkSystem/approveRule/index';
|
import { userApi } from '/@/api/systemManage/user';
|
|
interface stateType {
|
tableData: {
|
approveRuleData: [];
|
total: number;
|
loading: boolean;
|
params: {
|
pageIndex: number | null;
|
pageSize: number | null;
|
searchParams: {
|
ruleName: string | null;
|
depId: number | null;
|
workType: number | null;
|
workLevel: number | null;
|
};
|
};
|
};
|
workTypeList: Array<type>;
|
departmentList: [];
|
userList: [];
|
workLevelList: Array<type>;
|
deleteList: { ids: Array<deleteType> };
|
timeType: Array<type>;
|
}
|
interface deleteType {
|
ruleId: number;
|
}
|
|
interface type {
|
id: number;
|
name: string;
|
}
|
|
export default {
|
name: 'index',
|
components: { approveRuleDialog },
|
setup() {
|
const approveRuleDialogRef = ref();
|
const state = reactive<stateType>({
|
tableData: {
|
approveRuleData: [],
|
total: 0,
|
loading: false,
|
params: {
|
pageIndex: 1,
|
pageSize: 10,
|
searchParams: {
|
ruleName: null,
|
depId: null,
|
workType: null,
|
workLevel: null
|
}
|
}
|
},
|
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: '盲板抽堵作业' },
|
{ id: 9, name: '打开作业' }
|
],
|
workLevelList: [
|
{ id: 3, name: '特级动火作业' },
|
{ id: 1, name: '一级动火作业' },
|
{ id: 2, name: '二级动火作业' },
|
{ id: 7, name: '四级高处作业' },
|
{ id: 4, name: '一级高处作业' },
|
{ id: 5, name: '二级高处作业' },
|
{ id: 6, name: '三级高处作业' },
|
{ id: 8, name: '一级吊装作业' },
|
{ id: 9, name: '二级吊装作业' },
|
{ id: 10, name: '三级吊装作业' },
|
{ id: 11, name: '抽盲板作业' },
|
{ id: 12, name: '堵盲板作业' }
|
],
|
departmentList: [],
|
userList: [],
|
deleteList: { ids: [] },
|
timeType: [
|
{ id: 1, name: '分' },
|
{ id: 2, name: '小时' },
|
{ id: 3, name: '日' },
|
{ id: 4, name: '月' },
|
{ id: 5, name: '年' }
|
]
|
});
|
|
//获取巡检任务数据
|
const getApproveRule = async () => {
|
let res = await approveRuleApi().getApproveRuleList(state.tableData.params);
|
if (res.data.code === '200') {
|
state.tableData.approveRuleData = res.data.data;
|
state.tableData.total = res.data.total;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
//获取部门
|
const getDepartmentData = async () => {
|
let res = await departmentApi().getDepartmentList();
|
if (res.data.code === '200') {
|
state.departmentList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
//获取用户列表
|
const getUserData = async () => {
|
let res = await userApi().getAllUser();
|
if (res.data.code === '200') {
|
state.userList = res.data.data;
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
};
|
|
// 删除
|
const deleteApproveRule = (row: any) => {
|
ElMessageBox.confirm(`此操作将永久删除该审批规则,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await approveRuleApi().deleteApproveRule({ ids: [row.id] });
|
state.deleteList.ids = [];
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await getApproveRule();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch(() => {});
|
};
|
|
// 批量删除
|
const deleteMoreApproveRule = (row: any) => {
|
ElMessageBox.confirm(`此操作将永久删除这些审批规则,是否继续?`, '提示', {
|
confirmButtonText: '确认',
|
cancelButtonText: '取消',
|
type: 'warning'
|
})
|
.then(async () => {
|
let res = await approveRuleApi().deleteApproveRule(state.deleteList);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
duration: 2000,
|
message: '删除成功'
|
});
|
await getApproveRule();
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
})
|
.catch(() => {});
|
};
|
|
const openApproveRuleDialog = (type: string, value: {}) => {
|
approveRuleDialogRef.value.showApproveRuleDialog(type, value, state.departmentList, state.userList, state.workTypeList);
|
};
|
|
const parseNumber = (value: number, type: string) => {
|
if (type === '作业类型') {
|
return state.workTypeList.find((item) => item.id === value)?.name;
|
} else if (type === '作业等级') {
|
return state.workLevelList.find((item) => item.id == value)?.name;
|
} else {
|
}
|
};
|
|
const handleSelectionChange = (val: Array<deleteType>) => {
|
state.deleteList.ids = val.map((item) => {
|
return item.ruleId;
|
}) as [];
|
};
|
|
// 分页改变
|
const onHandleSizeChange = (val: number) => {
|
state.tableData.params.pageSize = val;
|
getApproveRule();
|
};
|
// 分页改变
|
const onHandleCurrentChange = (val: number) => {
|
state.tableData.params.pageIndex = val;
|
getApproveRule();
|
};
|
|
const reset = () => {
|
state.tableData.params = {
|
pageIndex: 1,
|
pageSize: 10,
|
searchParams: {
|
ruleName: null,
|
depId: null,
|
workType: null,
|
workLevel: null
|
}
|
};
|
};
|
|
// 页面加载时
|
onMounted(() => {
|
getApproveRule();
|
getDepartmentData();
|
getUserData();
|
});
|
|
return {
|
View,
|
Edit,
|
Delete,
|
Refresh,
|
Plus,
|
reset,
|
parseNumber,
|
deleteApproveRule,
|
getApproveRule,
|
deleteMoreApproveRule,
|
handleSelectionChange,
|
onHandleSizeChange,
|
onHandleCurrentChange,
|
approveRuleDialogRef,
|
openApproveRuleDialog,
|
...toRefs(state)
|
};
|
}
|
};
|
</script>
|
|
<style scoped lang="scss">
|
$homeNavLengh: 8;
|
.home-container {
|
height: calc(100vh - 144px);
|
box-sizing: border-box;
|
overflow: hidden;
|
position: relative;
|
.homeCard {
|
width: 100%;
|
padding: 20px;
|
box-sizing: border-box;
|
background: #fff;
|
border-radius: 4px;
|
flex: 0 auto;
|
|
.main-card {
|
width: 100%;
|
height: 100%;
|
.cardTop {
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
margin-bottom: 20px;
|
.mainCardBtn {
|
margin: 0;
|
}
|
}
|
.pageBtn {
|
position: absolute;
|
width: 100%;
|
z-index: 99;
|
bottom: 0;
|
right: 0;
|
height: 60px;
|
border-radius: 0 0 4px 4px;
|
padding-right: 20px;
|
background: #fff;
|
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 {
|
flex: 1;
|
}
|
}
|
.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-textarea.is-disabled .el-textarea__inner) {
|
background-color: var(--el-card-bg-color);
|
color: var(--el-input-text-color, var(--el-text-color-regular));
|
}
|
:deep(.el-input.is-disabled .el-input__inner) {
|
color: var(--el-input-text-color, var(--el-text-color-regular));
|
}
|
:deep(.el-input.is-disabled .el-input__wrapper) {
|
background-color: var(--el-card-bg-color);
|
}
|
</style>
|