<template>
|
<div class="system-add-menu-container">
|
<el-dialog :title="title" v-model="isShowInspectionTaskDialog" append-to-body :close-on-click-modal="false" width="50%">
|
<el-divider></el-divider>
|
<div class="inspectionTask-form">
|
<el-form
|
:model="inspectionTaskForm"
|
:rules="inspectionTaskFormRules"
|
ref="productionDeviceFormRef"
|
size="default"
|
label-width="120px"
|
>
|
<el-row :gutter="35">
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="任务名称" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入任务名称"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="任务类型" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入任务类型"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="检查频次" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入检查频次"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="周期开始时间" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入周期开始时间"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="有效时间" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入有效时间"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="提前通知时间" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入提前通知时间"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="巡检部门" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入巡检部门"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12" class="mb20">
|
<el-form-item label="巡检班组" prop="produceDeviceName">
|
<el-input
|
class="input-length"
|
v-model.trim="inspectionTaskForm.produceDeviceName"
|
placeholder="请输入巡检班组"
|
clearable
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</el-form>
|
</div>
|
|
<div class="inspectionTask-point">
|
<el-tabs class="active" v-model="activeName">
|
<el-tab-pane label="检查项信息" name="inspectionPoint">
|
<div class="filter-container">
|
<el-button size="default" type="success" @click="onOpenDialogRef('新增', '')">
|
<el-icon>
|
<ele-FolderAdd />
|
</el-icon>
|
新增排查任务
|
</el-button>
|
</div>
|
|
<el-table :data="inspectionPointData" border fit highlight-current-row style="width: 100%">
|
<el-table-column type="index" label="序号" width="60" />
|
<el-table-column prop="produceDeviceName" label="生产装置名称" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="depName" label="所属部门" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="riskLevel" label="风险等级" show-overflow-tooltip></el-table-column>
|
<el-table-column prop="location" label="区域位置" show-overflow-tooltip></el-table-column>
|
<el-table-column label="操作" width="150">
|
<template #default="scope">
|
<el-button size="small" text type="primary" @click="onOpenDialogRef('修改', scope.row)">修改</el-button>
|
<el-button size="small" text type="danger" @click="onDelProductionDevice(scope.row)">删除</el-button>
|
</template>
|
</el-table-column>
|
</el-table>
|
</el-tab-pane>
|
</el-tabs>
|
</div>
|
|
<template #footer>
|
<span class="dialog-footer">
|
<el-button @click="isShowInspectionTaskDialog = !isShowInspectionTaskDialog" size="default">取 消</el-button>
|
<el-button type="primary" @click="submitProductionDevice" v-throttle size="default">确 实</el-button>
|
</span>
|
</template>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script lang="ts">
|
interface stateType {
|
isShowInspectionTaskDialog: Boolean;
|
inspectionTaskForm: {
|
produceDeviceName: string;
|
depId: number | null;
|
riskLevel: number | null;
|
location: string;
|
};
|
title: string;
|
activeName: string;
|
departmentList: [];
|
inspectionPointData: [];
|
levelList: Array<levelListState>;
|
inspectionTaskFormRules: {};
|
}
|
interface levelListState {}
|
import { reactive, toRefs, ref } from 'vue';
|
import { productionDeviceApi } from '/@/api/doublePreventSystem/productionDevice';
|
import { ElMessage } from 'element-plus';
|
export default {
|
name: 'inspectionTaskDialog',
|
setup(props: any, context: any) {
|
const productionDeviceFormRef = ref();
|
const state = reactive<stateType>({
|
title: '',
|
activeName: 'inspectionPoint',
|
inspectionPointData: [],
|
departmentList: [],
|
isShowInspectionTaskDialog: false,
|
levelList: [
|
{ id: 1, name: '低风险' },
|
{ id: 2, name: '一般风险' },
|
{ id: 3, name: '较大风险' },
|
{ id: 4, name: '重大风险' }
|
],
|
inspectionTaskForm: {
|
produceDeviceName: '',
|
depId: null,
|
riskLevel: null,
|
location: ''
|
},
|
inspectionTaskFormRules: {
|
produceDeviceName: [{ required: true, message: '请填写生产装置名称', trigger: 'blur' }],
|
depId: [{ required: true, message: '请选择部门', trigger: 'change' }],
|
riskLevel: [{ required: true, message: '请选择风险等级', trigger: 'change' }],
|
location: [{ required: true, message: '请填写区域位置', trigger: 'blur' }]
|
}
|
});
|
|
//打开模态框
|
const openProductionDeviceDialog = (type: string, value: object, department: []) => {
|
state.isShowInspectionTaskDialog = true;
|
state.departmentList = department;
|
setTimeout(() => {
|
productionDeviceFormRef.value.clearValidate();
|
});
|
if (type === '新增') {
|
state.title = '新增生产装置';
|
state.inspectionTaskForm = {
|
produceDeviceName: '',
|
depId: null,
|
riskLevel: null,
|
location: ''
|
};
|
} else {
|
state.title = '修改生产装置';
|
state.inspectionTaskForm = JSON.parse(JSON.stringify(value));
|
}
|
};
|
|
//新增修改提交
|
const submitProductionDevice = async () => {
|
productionDeviceFormRef.value.validate(async (valid: Boolean) => {
|
if (valid) {
|
if (state.title === '新增生产装置') {
|
let res = await productionDeviceApi().addProductionDevice(state.inspectionTaskForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '生产装置新增成功',
|
duration: 2000
|
});
|
state.isShowInspectionTaskDialog = false;
|
context.emit('refreshProductionDevice');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
} else {
|
let res = await productionDeviceApi().modProductionDevice(state.productionDeviceForm);
|
if (res.data.code === '200') {
|
ElMessage({
|
type: 'success',
|
message: '生产装置修改成功',
|
duration: 2000
|
});
|
state.isShowInspectionTaskDialog = false;
|
context.emit('refreshProductionDevice');
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: res.data.msg
|
});
|
}
|
}
|
} else {
|
ElMessage({
|
type: 'warning',
|
message: '请完善基本信息'
|
});
|
}
|
});
|
};
|
|
return {
|
...toRefs(state),
|
productionDeviceFormRef,
|
submitProductionDevice,
|
openProductionDeviceDialog
|
};
|
}
|
};
|
</script>
|
|
<style scoped>
|
::v-deep.el-divider--horizontal {
|
margin-top: 0px !important;
|
}
|
|
::v-deep.el-dialog__body {
|
padding-top: 10px !important;
|
}
|
.filter-container {
|
padding: 10px 0px;
|
}
|
</style>
|