update 巡检单设置

This commit is contained in:
lb 2024-02-22 16:11:30 +08:00
parent ef354732b4
commit 9ad83f84fa
5 changed files with 160 additions and 202 deletions

View File

@ -84,12 +84,12 @@ export default {
btnName: '修改', btnName: '修改',
} }
: undefined, : undefined,
this.$auth.hasPermi('equipment:check-setting:update') // this.$auth.hasPermi('equipment:check-setting:update')
? { // ? {
type: 'detail', // type: 'detail',
btnName: '查看详情', // btnName: '',
} // }
: undefined, // : undefined,
this.$auth.hasPermi('equipment:check-setting:delete') this.$auth.hasPermi('equipment:check-setting:delete')
? { ? {
type: 'delete', type: 'delete',
@ -175,51 +175,6 @@ export default {
// color: 'warning', // color: 'warning',
// }, // },
], ],
rows: [
[
{
input: true,
label: '配置名称',
prop: 'name',
rules: [
{ required: true, message: '配置名称不能为空', trigger: 'blur' },
],
},
{
input: true,
label: '配置编码',
prop: 'code',
url: '/base/equipment-check-config/getCode',
rules: [
{ required: true, message: '配置编码不能为空', trigger: 'blur' },
],
},
],
[
{
select: true,
label: '设备名称',
prop: 'equipmentId',
url: '/base/core-equipment/listAll',
bind: {
filterable: true,
clearable: true,
},
rules: [
{
required: true,
message: '设备名称不能为空',
trigger: 'change',
},
],
},
{
input: true,
label: '设备编码', // TODO:
prop: 'equipmentCode',
},
],
],
// //
open: false, open: false,
// //
@ -227,6 +182,7 @@ export default {
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
name: null, name: null,
status: 0,
}, },
// //
form: {}, form: {},
@ -314,26 +270,18 @@ export default {
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
// this.reset();
this.open = true; this.open = true;
this.title = '添加巡检设置'; this.title = '添加巡检设置';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.add.init(); this.$refs.add.init();
}) });
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
// this.reset();
// const id = row.id;
// this.info({ id }).then((response) => {
// this.form = response.data;
// this.open = true;
// this.title = '';
// });
this.open = true; this.open = true;
this.title = '修改巡检设置'; this.title = '修改巡检设置';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.add.init(row.id); this.$refs.add.init(row);
}); });
}, },
/** 提交按钮 */ /** 提交按钮 */
@ -397,11 +345,11 @@ export default {
this.$refs.addOrUpdate.init(id, true); this.$refs.addOrUpdate.init(id, true);
}); });
}, },
handleAddDetail({ id }) { handleAddDetail(row) {
this.addOrUpdateVisible = true; this.addOrUpdateVisible = true;
this.addOrEditTitle = '添加巡检'; this.addOrEditTitle = '添加内容';
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(id); this.$refs.addOrUpdate.init(row);
}); });
}, },
/** 导出按钮操作 */ /** 导出按钮操作 */

View File

@ -379,10 +379,7 @@ export default {
this.handleQuery(); this.handleQuery();
}, },
/** 新增按钮操作 */ /** 新增按钮操作 */
handleAdd() { handleAdd() {
// this.reset();
// this.open = true;
// this.title = '';
this.addOrUpdateVisible = true; this.addOrUpdateVisible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.addOrUpdate.init(); this.$refs.addOrUpdate.init();

View File

@ -1,8 +1,8 @@
<!-- <!--
* @Author: zwq * @Author: zwq
* @Date: 2021-11-18 14:16:25 * @Date: 2021-11-18 14:16:25
* @LastEditors: DY * @LastEditors: lb
* @LastEditTime: 2023-12-01 11:02:43 * @LastEditTime: 2024-02-22 11:02:43
* @Description: * @Description:
--> -->
<template> <template>
@ -24,7 +24,7 @@
@keyup.enter.native="dataFormSubmit()" @keyup.enter.native="dataFormSubmit()"
label-position="top"> label-position="top">
<el-row :gutter="20"> <el-row :gutter="20">
<el-col :span="8"> <!-- <el-col :span="8">
<el-form-item label="设备大类" prop="equipmentCategory"> <el-form-item label="设备大类" prop="equipmentCategory">
<span> <span>
{{ {{
@ -34,21 +34,20 @@
}} }}
</span> </span>
</el-form-item> </el-form-item>
</el-col> </el-col> -->
<el-col :span="8"> <el-col :span="8">
<el-form-item label="设备名称" prop="equipmentName"> <el-form-item label="巡检单名称" prop="name">
{{ dataForm.equipmentName }} {{ dataForm.name }}
<!-- <el-input v-model="dataForm.equipmentName" disabled clearable placeholder="请输入设备名称" /> -->
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-form-item label="设备编码" prop="equipmentCode"> <el-form-item label="部门" prop="department">
{{ dataForm.equipmentCode }} {{ dataForm.department }}
<!-- <el-input </el-form-item>
v-model="dataForm.equipmentCode" </el-col>
clearable <el-col :span="8">
disabled <el-form-item label="巡检时间" prop="planCheckTime">
placeholder="请输入设备编码" /> --> {{ dataForm.planCheckTime | parseTime }}
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -87,8 +86,8 @@
@clickBtn="handleClick" /> @clickBtn="handleClick" />
</base-table> </base-table>
<pagination <pagination
v-show="listQuery.total > 0" v-show="checkDetList.total > 0"
:total="listQuery.total" :total="checkDetList.total"
:page.sync="listQuery.pageNo" :page.sync="listQuery.pageNo"
:limit.sync="listQuery.pageSize" :limit.sync="listQuery.pageSize"
:page-sizes="[5, 10, 15]" :page-sizes="[5, 10, 15]"
@ -103,20 +102,17 @@
<attr-add <attr-add
v-if="addOrUpdateVisible" v-if="addOrUpdateVisible"
ref="addOrUpdate" ref="addOrUpdate"
:config-id="dataForm.id" :orderId="dataForm.id"
@closed="addOrUpdateVisible = false"
@refreshDataList="getList" /> @refreshDataList="getList" />
</el-drawer> </el-drawer>
</template> </template>
<script> <script>
import {
getEqCheck,
getCheckDetPage,
deleteCheckDet,
} from '@/api/equipment/base/inspection/settings';
import SmallTitle from './SmallTitle'; import SmallTitle from './SmallTitle';
import attrAdd from './attr-add'; import attrAdd from './attr-add';
import { DICT_TYPE, getDictDatas } from '@/utils/dict'; import { DICT_TYPE, getDictDatas } from '@/utils/dict';
import { parseTime } from '../../core/mixins/code-filter';
const tableBtn = [ const tableBtn = [
{ {
@ -129,50 +125,35 @@ const tableBtn = [
}, },
]; ];
const tableProps = [ const tableProps = [
{
prop: 'equipmentName',
label: '设备名称',
},
{ {
prop: 'program', prop: 'program',
label: '巡检项目', label: '检查项目',
},
{
prop: 'content',
label: '巡检内容',
},
{
prop: 'code',
label: '巡检内容编码',
},
{
prop: 'description',
label: '备注',
}, },
]; ];
export default { export default {
components: { SmallTitle, attrAdd }, components: { SmallTitle, attrAdd },
filters: {
parseTime,
},
data() { data() {
return { return {
tableBtn, tableBtn,
tableProps, tableProps,
addOrUpdateVisible: false, addOrUpdateVisible: false,
urlOptions: {
infoURL: getEqCheck,
},
listQuery: { listQuery: {
pageSize: 10, pageSize: 10,
pageNo: 1, pageNo: 1,
total: 0,
}, },
dataForm: { dataForm: {
id: undefined, id: undefined,
code: undefined, name: undefined,
name: '', department: undefined,
materialType: undefined, planCheckTime: undefined,
productType: undefined,
area: undefined,
specifications: undefined,
processTime: 0,
remark: undefined,
unit: undefined,
}, },
checkDetList: [], checkDetList: [],
visible: false, visible: false,
@ -204,7 +185,7 @@ export default {
methods: { methods: {
initData() { initData() {
this.checkDetList.splice(0); this.checkDetList.splice(0);
this.listQuery.total = 0; this.checkDetList.total = 0;
}, },
handleClick(raw) { handleClick(raw) {
if (raw.type === 'delete') { if (raw.type === 'delete') {
@ -231,39 +212,35 @@ export default {
}) })
.catch(() => {}); .catch(() => {});
} else { } else {
this.addNew(raw.data.id); console.log('handle click....', raw);
this.addNew(raw.data);
} }
}, },
getList() { async getList() {
// //
getCheckDetPage({ const res = await this.$axios({
...this.listQuery, url: '/base/equipment-check-order-det/page',
configId: this.dataForm.id, params: { ...this.listQuery, orderId: this.dataForm.id },
}).then((response) => {
this.checkDetList = response.data.list;
this.listQuery.total = response.data.total;
}); });
if (res.code == 0) {
this.checkDetList = res.data.list;
this.checkDetList.total = res.data.total;
}
}, },
init(id, isdetail) { init(row, isdetail) {
this.initData(); this.initData();
this.isdetail = isdetail || false; this.isdetail = isdetail || false;
this.dataForm.id = id || undefined; this.dataForm.id = row.id;
this.visible = true; this.visible = true;
this.$nextTick(() => { this.$nextTick(() => {
this.$refs['dataForm'].resetFields(); this.$refs['dataForm'].resetFields();
if (this.dataForm.id) { if (this.dataForm.id) {
//
this.urlOptions.infoURL(id).then((response) => {
this.dataForm = response.data;
});
// //
Object.keys(this.dataForm).forEach((key) => {
this.dataForm[key] = row[key];
});
this.getList(); this.getList();
} else {
if (this.urlOptions.isGetCode) {
this.getCode();
}
} }
}); });
}, },

View File

@ -75,7 +75,7 @@
v-for="d in groupOptions" v-for="d in groupOptions"
:key="d.value" :key="d.value"
:label="d.label" :label="d.label"
:value="d.value" /> :value="d.label" />
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>
@ -185,6 +185,9 @@ export default {
if (res.code == 0) { if (res.code == 0) {
Object.keys(this.dataForm).forEach((key) => { Object.keys(this.dataForm).forEach((key) => {
this.dataForm[key] = res.data[key]; this.dataForm[key] = res.data[key];
if (key == 'groupClass') {
this.dataForm.groupClass = res.data.groupClass.split(',')
}
}); });
} }
}, },
@ -203,6 +206,7 @@ export default {
data: { data: {
...this.dataForm, ...this.dataForm,
special: true, special: true,
status: 0,
groupClass: this.dataForm.groupClass.join(','), groupClass: this.dataForm.groupClass.join(','),
}, },
}); });

View File

@ -4,6 +4,7 @@
:width="'30%'" :width="'30%'"
:append-to-body="true" :append-to-body="true"
:close-on-click-modal="false" :close-on-click-modal="false"
@closed="$emit('closed')"
class="dialog"> class="dialog">
<template #title> <template #title>
<slot name="title"> <slot name="title">
@ -17,18 +18,33 @@
ref="dataForm" ref="dataForm"
:model="dataForm" :model="dataForm"
:rules="dataRule" :rules="dataRule"
label-width="60px" label-width="90px"
v-loading="formLoading"
@keyup.enter.native="dataFormSubmit()"> @keyup.enter.native="dataFormSubmit()">
<el-form-item label="巡检" prop="checkId"> <el-form-item label="设备名称" prop="equipmentId">
<el-select v-model="dataForm.checkId" filterable placeholder="请选择巡检" style="width: 100%"> <el-select
<el-option v-for="dict in checkList" :key="dict.id" :label="dict.content" v-model="dataForm.equipmentId"
:value="dict.id" /> filterable
clearable
placeholder="请选择设备名称"
style="width: 100%">
<el-option
v-for="dict in equipmentOptions"
:key="dict.value"
:label="dict.label"
:value="dict.value" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="description"> <el-form-item label="巡检项目" prop="program">
<el-input <el-input
v-model="dataForm.description" v-model="dataForm.program"
placeholder="请输入备注" placeholder="请输入巡检项目"
clearable />
</el-form-item>
<el-form-item label="巡检结果" prop="checkResult">
<el-input
v-model="dataForm.checkResult"
placeholder="请输入巡检结果"
clearable /> clearable />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -41,80 +57,96 @@
</template> </template>
<script> <script>
import { getCheckDet, createCheckDet, updateCheckDet, getcheckList } from "@/api/equipment/base/inspection/settings";
export default { export default {
props: { props: ['orderId'],
configId: {
type: String,
default: '',
},
},
data() { data() {
return { return {
visible: false, visible: false,
dataForm: { dataForm: {
id: undefined, id: null,
checkId: undefined, equipmentId: null,
configId: undefined, program: null,
description: '' checkResult: null,
}, },
checkList: [], formLoading: false,
equipmentOptions: [],
dataRule: { dataRule: {
checkId: [{ required: true, message: '巡检不能为空', trigger: 'blur' }], equipmentId: [
{ required: true, message: '设备不能为空', trigger: 'blur' },
],
program: [
{ required: true, message: '巡检项目不能为空', trigger: 'blur' },
],
checkResult: [
{ required: true, message: '巡检结果不能为空', trigger: 'blur' },
],
}, },
}; };
}, },
mounted() { mounted() {
this.getDict() this.initOptions();
}, },
methods: { methods: {
async getDict() { async initOptions() {
const res = await getcheckList() this.formLoading = true;
this.checkList = res.data const urls = [
}, '/base/core-equipment/page?pageNo=1&pageSize=100&special=true',
init(id) { ];
this.dataForm.id = id || ''; try {
this.visible = true; const [eq] = await Promise.all(urls.map((url) => this.$axios(url)));
this.$nextTick(() => { if (eq.code == 0) {
this.$refs['dataForm'].resetFields(); this.equipmentOptions = eq.data.list.map((item) => ({
if (this.dataForm.id) { label: item.name,
getCheckDet(this.dataForm.id).then((res) => { value: item.id,
// const { name, value } = res.data; }));
// this.dataForm.name = name;
// this.dataForm.value = value;
this.dataForm = res.data
});
} }
}); this.formLoading = false;
} catch (err) {
this.formLoading = false;
console.error(err);
}
},
init(row) {
this.visible = true;
if (row?.id) {
this.$nextTick(() => {
this.$refs['dataForm'].resetFields();
this.formLoading = true;
this.$axios({
url: '/base/equipment-check-order-det/get?id=' + row.id,
}).then((res) => {
Object.keys(this.dataForm).forEach((key) => {
this.dataForm[key] = res.data[key];
});
this.formLoading = false;
});
});
}
}, },
// //
dataFormSubmit() { async dataFormSubmit() {
this.$refs['dataForm'].validate((valid) => { let valid = false;
if (valid) { try {
// valid = await this.$refs['dataForm'].validate();
if (this.dataForm.id) { } catch (err) {}
updateCheckDet({ if (!valid) return;
...this.dataForm,
configId: this.configId const res = await this.$axios({
}).then((response) => { url:
this.$modal.msgSuccess('修改成功'); 'base/equipment-check-order-det' +
this.visible = false; (this.dataForm.id ? '/update' : '/create'),
this.$emit('refreshDataList'); method: this.dataForm.id ? 'put' : 'post',
}); data: {
return; ...this.dataForm,
} orderId: this.orderId,
// },
createCheckDet({
...this.dataForm,
configId: this.configId,
}).then((response) => {
this.$modal.msgSuccess('新增成功');
this.visible = false;
this.$emit('refreshDataList');
});
}
}); });
if (res.code == 0) {
this.$modal.msgSuccess(this.dataForm.id ? '修改成功' : '新增成功');
this.$emit('refreshDataList');
this.visible = false;
}
}, },
}, },
}; };