update 巡检单设置

This commit is contained in:
lb 2024-02-22 11:21:59 +08:00
parent 95a4b336f8
commit ef354732b4
2 changed files with 153 additions and 93 deletions

View File

@ -122,9 +122,14 @@ export default {
filter: parseTime, filter: parseTime,
}, },
{ {
width: 144,
prop: 'confirmTimeLimit', prop: 'confirmTimeLimit',
label: '确认时限', label: '确认时限',
showOverflowtooltip: true, showOverflowtooltip: true,
filter: (val) =>
val != null && val > 24
? `${(val - (val % 24)) / 24}${val % 24}小时`
: `${val}小时`,
}, },
{ prop: 'groupClass', label: '班次', showOverflowtooltip: true }, { prop: 'groupClass', label: '班次', showOverflowtooltip: true },
{ prop: 'creator', label: '创建人', showOverflowtooltip: true }, { prop: 'creator', label: '创建人', showOverflowtooltip: true },
@ -282,10 +287,9 @@ export default {
}, },
/** 取消按钮 */ /** 取消按钮 */
cancel() { cancel() {
this.$refs.add.formClear(); this.$refs.add.reset();
this.open = false; this.open = false;
this.title = ''; this.title = '';
// this.reset();
}, },
/** 表单重置 */ /** 表单重置 */
reset() { reset() {
@ -315,7 +319,7 @@ export default {
this.title = '添加巡检设置'; this.title = '添加巡检设置';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.add.init(); this.$refs.add.init();
}); })
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {

View File

@ -7,63 +7,81 @@
--> -->
<template> <template>
<el-form <el-form
ref="form"
:model="dataForm" :model="dataForm"
:rules="dataRule" :rules="dataRule"
ref="dataForm"
@keyup.enter.native="dataFormSubmit()" @keyup.enter.native="dataFormSubmit()"
label-width="80px"> label-width="128px"
v-loading="formLoading"
label-position="top">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="12"> <el-col>
<el-form-item label="配置名称" prop="name"> <el-form-item label="巡检单名称" prop="name">
<el-input v-model="dataForm.name" placeholder="请输入配置名称" /> <el-input v-model="dataForm.name" placeholder="请输入巡检单名称" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col>
<el-form-item label="配置编码" prop="code"> <el-form-item label="巡检单编码" prop="code">
<el-input v-model="dataForm.code" placeholder="请输入配置编码" /> <el-input v-model="dataForm.code" placeholder="请输入巡检单编码" />
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col>
<el-form-item <el-form-item
label="设备大类" label="部门"
prop="equipmentCategory" prop="departmentId"
:rules="[ :rules="[{ required: true, message: '请选择部门', trigger: 'blur' }]">
{ required: true, message: '请选择设备大类', trigger: 'blur' },
]">
<el-select <el-select
v-model="dataForm.equipmentCategory" v-model="dataForm.departmentId"
:placeholder="`请选择设备大类`" :placeholder="`请选择部门`">
@change="handleEqTypeChange">
<el-option <el-option
v-for="opt in equipmentTypeOptions" v-for="opt in departmentOptions"
:key="opt.value" :key="opt.value"
:label="opt.label" :label="opt.label"
:value="opt.value" /> :value="opt.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col>
<el-form-item label="计划巡检时间" prop="planCheckTime">
<el-date-picker
v-model="dataForm.planCheckTime"
type="datetime"
:placeholder="`请选择计划巡检时间`"
value-format="timestamp" />
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="设备名称" prop="equipmentId"> <el-form-item label="确认时限 (时)" prop="confirmTimeLimit">
<el-input
v-model="dataForm.confirmTimeLimit"
:placeholder="`请输入确认时限`" />
<!-- <el-date-picker
v-model="dataForm.confirmTimeLimit"
type="datetime"
:placeholder="`请选择确认时限`"
value-format="timestamp" /> -->
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="班次" prop="groupClass">
<el-select <el-select
v-model="dataForm.equipmentId" v-model="dataForm.groupClass"
filterable filterable
clearable
multiple
style="width: 100%" style="width: 100%"
placeholder="请选择设备名称" placeholder="请选择班次">
@change="setCode">
<el-option <el-option
v-for="d in equipmentOptions" v-for="d in groupOptions"
:key="d.value" :key="d.value"
:label="d.label" :label="d.label"
:value="d.value" /> :value="d.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12"> <el-col>
<el-form-item label="设备编码" prop="equipmentCode"> <el-form-item label="备注" prop="remark">
<el-input <el-input v-model="dataForm.remark" placeholder="请输入备注" />
v-model="dataForm.equipmentCode"
disabled
placeholder="请输入设备编码" />
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -71,89 +89,127 @@
</template> </template>
<script> <script>
import basicAdd from '../../core/mixins/basic-add';
import {
getEqCheck,
getCode,
createCheckConfig,
updateCheckConfig,
} from '@/api/equipment/base/inspection/settings';
import { getEquipmentAll } from '@/api/base/equipment';
export default { export default {
mixins: [basicAdd],
data() { data() {
return { return {
urlOptions: { formLoading: false,
isGetCode: true,
codeURL: getCode,
createURL: createCheckConfig,
updateURL: updateCheckConfig,
infoURL: getEqCheck,
},
dataForm: { dataForm: {
id: undefined, id: null,
code: undefined, code: null,
name: undefined, name: null,
equipmentId: undefined, departmentId: null,
equipmentCode: undefined, planCheckTime: null,
equipmentCategory: undefined, confirmTimeLimit: null,
groupClass: null,
remark: null,
// special: true,
}, },
eqList: [],
dataRule: { dataRule: {
equipmentId: [ confirmTimeLimit: [
{ required: true, message: '设备不能为空', trigger: 'blur' }, { required: true, message: '确认时限不能为空', trigger: 'blur' },
], ],
code: [ code: [
{ required: true, message: '配置编码不能为空', trigger: 'blur' }, { required: true, message: '巡检单编码不能为空', trigger: 'blur' },
], ],
name: [ name: [
{ required: true, message: '配置名称不能为空', trigger: 'blur' }, { required: true, message: '巡检单名称不能为空', trigger: 'blur' },
],
planCheckTime: [
{ required: true, message: '计划巡检时间不能为空', trigger: 'blur' },
], ],
}, },
equipmentOptions: [], equipmentOptions: [],
equipmentTypeOptions: [ groupOptions: [],
{ label: '安全设备', value: 1 }, departmentOptions: [],
{ label: '消防设备', value: 2 },
{ label: '特种设备', value: 3 },
],
}; };
}, },
mounted() { mounted() {
this.getDict(); this.initOptions();
}, },
methods: { methods: {
async getDict() { reset() {
// this.dataForm = {
const res = await getEquipmentAll(); id: null,
this.eqList = res.data; code: null,
this.$nextTick(() => { name: null,
this.handleEqTypeChange(); departmentId: null,
}); planCheckTime: null,
confirmTimeLimit: null,
groupClass: null,
remark: null,
// special: true,
};
}, },
setCode() {
const chooseM = this.eqList.filter((item) => { async initOptions() {
return item.id === this.dataForm.equipmentId; this.formLoading = true;
}); const urls = [
this.dataForm.equipmentCode = chooseM[0].code; '/base/core-department/listAll',
}, '/base/group-classes/listAll',
// handlers '/base/equipment-check-order/getCode',
handleEqTypeChange(type) { ];
this.dataForm.equipmentId = null; try {
this.dataForm.equipmentCode = null; const [dpt, grp, code] = await Promise.all(
if (type) { urls.map((url) => this.$axios(url))
this.equipmentOptions = this.eqList );
.filter((item) => item.special) if (dpt.code == 0) {
.filter((item) => item.specialType === type) this.departmentOptions = dpt.data.map((item) => ({
.map((item) => ({ label: item.name, value: item.id }));
} else
this.equipmentOptions = this.eqList
.filter((item) => item.special)
.map((item) => ({
label: item.name, label: item.name,
value: item.id, value: item.id,
})); }));
// this.$emit('update', this.form) }
if (grp.code == 0) {
this.groupOptions = grp.data.map((item) => ({
label: item.name,
value: item.id,
}));
}
if (code.code == 0) {
this.dataForm.code = code.data;
}
this.formLoading = false;
} catch (err) {
this.formLoading = false;
console.error(err);
}
},
async init(row) {
if (!row || !row.id) {
this.dataForm.planCheckTime = new Date().setHours(8, 0, 0, 0);
return;
}
const res = await this.$axios({
url: '/base/equipment-check-order/get?id=' + row.id,
});
if (res.code == 0) {
Object.keys(this.dataForm).forEach((key) => {
this.dataForm[key] = res.data[key];
});
}
},
async dataFormSubmit() {
let valid = false;
try {
valid = await this.$refs.form.validate();
} catch (err) {}
if (!valid) return;
const res = await this.$axios({
url:
'/base/equipment-check-order' +
(this.dataForm.id ? '/update' : '/create'),
method: this.dataForm.id ? 'put' : 'post',
data: {
...this.dataForm,
special: true,
groupClass: this.dataForm.groupClass.join(','),
},
});
if (res.code == 0) {
this.$emit('refreshDataList');
this.$message.success(this.dataForm.id ? '更新成功' : '创建成功');
}
}, },
}, },
}; };