update 巡检单设置
This commit is contained in:
parent
95a4b336f8
commit
ef354732b4
@ -122,9 +122,14 @@ export default {
|
||||
filter: parseTime,
|
||||
},
|
||||
{
|
||||
width: 144,
|
||||
prop: 'confirmTimeLimit',
|
||||
label: '确认时限',
|
||||
showOverflowtooltip: true,
|
||||
filter: (val) =>
|
||||
val != null && val > 24
|
||||
? `${(val - (val % 24)) / 24}天${val % 24}小时`
|
||||
: `${val}小时`,
|
||||
},
|
||||
{ prop: 'groupClass', label: '班次', showOverflowtooltip: true },
|
||||
{ prop: 'creator', label: '创建人', showOverflowtooltip: true },
|
||||
@ -282,10 +287,9 @@ export default {
|
||||
},
|
||||
/** 取消按钮 */
|
||||
cancel() {
|
||||
this.$refs.add.formClear();
|
||||
this.$refs.add.reset();
|
||||
this.open = false;
|
||||
this.title = '';
|
||||
// this.reset();
|
||||
},
|
||||
/** 表单重置 */
|
||||
reset() {
|
||||
@ -315,7 +319,7 @@ export default {
|
||||
this.title = '添加巡检设置';
|
||||
this.$nextTick(() => {
|
||||
this.$refs.add.init();
|
||||
});
|
||||
})
|
||||
},
|
||||
/** 修改按钮操作 */
|
||||
handleUpdate(row) {
|
||||
|
@ -7,63 +7,81 @@
|
||||
-->
|
||||
<template>
|
||||
<el-form
|
||||
ref="form"
|
||||
:model="dataForm"
|
||||
:rules="dataRule"
|
||||
ref="dataForm"
|
||||
@keyup.enter.native="dataFormSubmit()"
|
||||
label-width="80px">
|
||||
label-width="128px"
|
||||
v-loading="formLoading"
|
||||
label-position="top">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="配置名称" prop="name">
|
||||
<el-input v-model="dataForm.name" placeholder="请输入配置名称" />
|
||||
<el-col>
|
||||
<el-form-item label="巡检单名称" prop="name">
|
||||
<el-input v-model="dataForm.name" placeholder="请输入巡检单名称" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="配置编码" prop="code">
|
||||
<el-input v-model="dataForm.code" placeholder="请输入配置编码" />
|
||||
<el-col>
|
||||
<el-form-item label="巡检单编码" prop="code">
|
||||
<el-input v-model="dataForm.code" placeholder="请输入巡检单编码" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-col>
|
||||
<el-form-item
|
||||
label="设备大类"
|
||||
prop="equipmentCategory"
|
||||
:rules="[
|
||||
{ required: true, message: '请选择设备大类', trigger: 'blur' },
|
||||
]">
|
||||
label="部门"
|
||||
prop="departmentId"
|
||||
:rules="[{ required: true, message: '请选择部门', trigger: 'blur' }]">
|
||||
<el-select
|
||||
v-model="dataForm.equipmentCategory"
|
||||
:placeholder="`请选择设备大类`"
|
||||
@change="handleEqTypeChange">
|
||||
v-model="dataForm.departmentId"
|
||||
:placeholder="`请选择部门`">
|
||||
<el-option
|
||||
v-for="opt in equipmentTypeOptions"
|
||||
v-for="opt in departmentOptions"
|
||||
:key="opt.value"
|
||||
:label="opt.label"
|
||||
:value="opt.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</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-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
|
||||
v-model="dataForm.equipmentId"
|
||||
v-model="dataForm.groupClass"
|
||||
filterable
|
||||
clearable
|
||||
multiple
|
||||
style="width: 100%"
|
||||
placeholder="请选择设备名称"
|
||||
@change="setCode">
|
||||
placeholder="请选择班次">
|
||||
<el-option
|
||||
v-for="d in equipmentOptions"
|
||||
v-for="d in groupOptions"
|
||||
:key="d.value"
|
||||
:label="d.label"
|
||||
:value="d.value" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="设备编码" prop="equipmentCode">
|
||||
<el-input
|
||||
v-model="dataForm.equipmentCode"
|
||||
disabled
|
||||
placeholder="请输入设备编码" />
|
||||
<el-col>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="dataForm.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
@ -71,89 +89,127 @@
|
||||
</template>
|
||||
|
||||
<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 {
|
||||
mixins: [basicAdd],
|
||||
data() {
|
||||
return {
|
||||
urlOptions: {
|
||||
isGetCode: true,
|
||||
codeURL: getCode,
|
||||
createURL: createCheckConfig,
|
||||
updateURL: updateCheckConfig,
|
||||
infoURL: getEqCheck,
|
||||
},
|
||||
formLoading: false,
|
||||
dataForm: {
|
||||
id: undefined,
|
||||
code: undefined,
|
||||
name: undefined,
|
||||
equipmentId: undefined,
|
||||
equipmentCode: undefined,
|
||||
equipmentCategory: undefined,
|
||||
id: null,
|
||||
code: null,
|
||||
name: null,
|
||||
departmentId: null,
|
||||
planCheckTime: null,
|
||||
confirmTimeLimit: null,
|
||||
groupClass: null,
|
||||
remark: null,
|
||||
// special: true,
|
||||
},
|
||||
eqList: [],
|
||||
dataRule: {
|
||||
equipmentId: [
|
||||
{ required: true, message: '设备不能为空', trigger: 'blur' },
|
||||
confirmTimeLimit: [
|
||||
{ required: true, message: '确认时限不能为空', trigger: 'blur' },
|
||||
],
|
||||
code: [
|
||||
{ required: true, message: '配置编码不能为空', trigger: 'blur' },
|
||||
{ required: true, message: '巡检单编码不能为空', trigger: 'blur' },
|
||||
],
|
||||
name: [
|
||||
{ required: true, message: '配置名称不能为空', trigger: 'blur' },
|
||||
{ required: true, message: '巡检单名称不能为空', trigger: 'blur' },
|
||||
],
|
||||
planCheckTime: [
|
||||
{ required: true, message: '计划巡检时间不能为空', trigger: 'blur' },
|
||||
],
|
||||
},
|
||||
equipmentOptions: [],
|
||||
equipmentTypeOptions: [
|
||||
{ label: '安全设备', value: 1 },
|
||||
{ label: '消防设备', value: 2 },
|
||||
{ label: '特种设备', value: 3 },
|
||||
],
|
||||
groupOptions: [],
|
||||
departmentOptions: [],
|
||||
};
|
||||
},
|
||||
mounted() {
|
||||
this.getDict();
|
||||
this.initOptions();
|
||||
},
|
||||
methods: {
|
||||
async getDict() {
|
||||
// 设备列表
|
||||
const res = await getEquipmentAll();
|
||||
this.eqList = res.data;
|
||||
this.$nextTick(() => {
|
||||
this.handleEqTypeChange();
|
||||
});
|
||||
reset() {
|
||||
this.dataForm = {
|
||||
id: null,
|
||||
code: null,
|
||||
name: null,
|
||||
departmentId: null,
|
||||
planCheckTime: null,
|
||||
confirmTimeLimit: null,
|
||||
groupClass: null,
|
||||
remark: null,
|
||||
// special: true,
|
||||
};
|
||||
},
|
||||
setCode() {
|
||||
const chooseM = this.eqList.filter((item) => {
|
||||
return item.id === this.dataForm.equipmentId;
|
||||
});
|
||||
this.dataForm.equipmentCode = chooseM[0].code;
|
||||
},
|
||||
// handlers
|
||||
handleEqTypeChange(type) {
|
||||
this.dataForm.equipmentId = null;
|
||||
this.dataForm.equipmentCode = null;
|
||||
if (type) {
|
||||
this.equipmentOptions = this.eqList
|
||||
.filter((item) => item.special)
|
||||
.filter((item) => item.specialType === type)
|
||||
.map((item) => ({ label: item.name, value: item.id }));
|
||||
} else
|
||||
this.equipmentOptions = this.eqList
|
||||
.filter((item) => item.special)
|
||||
.map((item) => ({
|
||||
|
||||
async initOptions() {
|
||||
this.formLoading = true;
|
||||
const urls = [
|
||||
'/base/core-department/listAll',
|
||||
'/base/group-classes/listAll',
|
||||
'/base/equipment-check-order/getCode',
|
||||
];
|
||||
try {
|
||||
const [dpt, grp, code] = await Promise.all(
|
||||
urls.map((url) => this.$axios(url))
|
||||
);
|
||||
if (dpt.code == 0) {
|
||||
this.departmentOptions = dpt.data.map((item) => ({
|
||||
label: item.name,
|
||||
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 ? '更新成功' : '创建成功');
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user