feat(dms): 更新停机记录页面功能

- 将停机原因从输入框改为下拉选择,并绑定到 shutReasonId 字段
- 移除停机类型查询条件,改为后端自动赋值不显示
- 注释掉停机时间范围查询条件
- 优化设备名称显示逻辑,支持通过 ledgerMap 映射显示
- 恢复表格中的编辑按钮显示权限
- 调整表单标签宽度从 80px 到 120px
- 修改表单项将停机类型改为停机原因选择
- 替换 API 导入从 shutType 到 shutReason 的 selectDmsBaseShutReasonList
- 添加 ledgerMap 数据结构用于设备信息映射
- 更新查询参数中的 shutType 和 shutReason 为 shutReasonId
- 添加停机原因必填校验规则
- 实现停机原因选择变化时的联动处理
- 优化设备列表转为 Map 结构提高查找效率
- 在提交表单时将选择的原因名称写回描述字段
- 更新停机原因页面移除设备名称表单项
- 添加停机原因必填校验
- 优化停机原因和停机类型删除逻辑,防止删除主键为 1 的记录
- 新增不分页查询停机原因列表的 API 接口
master
zangch@mesnac.com 6 days ago
parent 16c08f5e25
commit 0e72b858cc

@ -42,3 +42,13 @@ export function delShutReason(shutReasonId) {
method: 'delete'
})
}
// 不分页查询所有停机原因信息列表
export function selectDmsBaseShutReasonList(query) {
return request({
url: '/dms/shutReason/selectDmsBaseShutReasonList',
method: 'get',
params: query
})
}

@ -9,27 +9,16 @@
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item label="停机原因" prop="shutReason">
<el-input
v-model="queryParams.shutReason"
placeholder="请输入停机原因"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="停机类型" prop="shutTypeId" >
<el-select v-model="queryParams.shutTypeId"
placeholder="请输入设备类型"
>
<el-form-item label="停机原因" prop="shutReasonId">
<el-select v-model="queryParams.shutReasonId" placeholder="请选择停机原因" clearable @change="handleQuery">
<el-option
v-for="item in shutTypeList"
:key="item.shutTypeId"
:label="item.shutTypeName"
:value="item.shutTypeId" />
v-for="item in shutReasonList"
:key="item.shutReasonId"
:label="item.shutReason"
:value="item.shutReasonId" />
</el-select>
</el-form-item>
<el-form-item label="停机时间" prop="shutBeginTime">
<!-- <el-form-item label="停机时间" prop="shutBeginTime">
<el-date-picker clearable
v-model="queryParams.shutBeginTime"
type="datetime"
@ -45,7 +34,7 @@
value-format="yyyy-MM-dd HH:mm:ss"
placeholder="请选择停机结束时间">
</el-date-picker>
</el-form-item>
</el-form-item> -->
<!-- <el-form-item label="停机时长" prop="shutTime">-->
<!-- <el-input-->
<!-- v-model="queryParams.shutTime"-->
@ -117,15 +106,10 @@
<el-table-column type="selection" width="55" align="center" />
<!-- <el-table-column label="主键标识;scada上报的记录" align="center" prop="recordShutDownId" />-->
<el-table-column label="设备" align="center" prop="deviceName" >
<template slot-scope="scope">
<span>
v-for="(item, index) in ledgerList"
:key="index"
:value="item.ledgerList"
v-if="scope.row.deviceId == item.deviceId"
>
{{ item.deviceId }}
</span>
<template slot-scope="{ row }">
<span v-if="row.deviceName">{{ row.deviceName }}</span>
<span v-else-if="ledgerMap[row.deviceId]">{{ ledgerMap[row.deviceId].deviceName || ledgerMap[row.deviceId].deviceCode }}</span>
<span v-else>{{ row.deviceId }}</span>
</template>
</el-table-column>
<!-- <el-table-column label="设备名称" align="center" prop="deviceId" >-->
@ -141,18 +125,7 @@
<!-- </template>-->
<!-- </el-table-column>-->
<!-- <el-table-column label="停机类型ID关联dm_base_shut_type的shut_type_id" align="center" prop="shutType" />-->
<el-table-column label="停机类型" align="center" prop="shutType" >
<template slot-scope="scope">
<span
v-for="(item, index) in shutTypeList"
:key="index"
:value="item.shutTypeList"
v-if="scope.row.shutType == item.shutTypeId"
>
{{ item.shutTypeName }}
</span>
</template>
</el-table-column>
<!-- 停机类型后端自动赋值前端不展示选择 -->
<el-table-column label="停机原因" align="center" prop="shutReason" />
<el-table-column label="停机开始时间" align="center" prop="shutBeginTime" width="200">
<template slot-scope="scope">
@ -169,13 +142,13 @@
<el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<!-- <el-button-->
<!-- size="mini"-->
<!-- type="text"-->
<!-- icon="el-icon-edit"-->
<!-- @click="handleUpdate(scope.row)"-->
<!-- v-hasPermi="['dms:shutDown:edit']"-->
<!-- >修改</el-button>-->
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['dms:shutDown:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
@ -197,7 +170,7 @@
<!-- 添加或修改停机记录对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form ref="form" :model="form" :rules="rules" label-width="120px">
<!-- <el-form-item label="设备ID关联dms_base_device_ledger的device_id" prop="deviceId">-->
<!-- <el-input v-model="form.deviceId" placeholder="请输入设备ID关联dms_base_device_ledger的device_id" />-->
<!-- </el-form-item>-->
@ -211,19 +184,16 @@
</el-option>
</el-select>
</el-form-item>
<el-form-item label="停机类型" prop="shutType" >
<el-select v-model="form.shutType" placeholder="请选择停机类型">
<el-form-item label="停机原因" prop="shutReasonId">
<el-select v-model="form.shutReasonId" placeholder="请选择停机原因" @change="onReasonChange">
<el-option
v-for="item in shutTypeList"
:key="item.shutTypeId"
:label="item.shutTypeName"
:value="item.shutTypeId">
</el-option>
v-for="item in shutReasonList"
:key="item.shutReasonId"
:label="item.shutReason"
:value="item.shutReasonId"
/>
</el-select>
</el-form-item>
<el-form-item label="停机原因" prop="shutReason">
<el-input v-model="form.shutReason" placeholder="请输入停机原因" />
</el-form-item>
<el-form-item label="停机开始时间" prop="shutBeginTime">
<el-date-picker clearable
v-model="form.shutBeginTime"
@ -260,7 +230,7 @@
<script>
import { listShutDown, getShutDown, delShutDown, addShutDown, updateShutDown } from "@/api/dms/shutDown";
import { listShutType } from '@/api/dms/shutType'
import { selectDmsBaseShutReasonList } from '@/api/dms/shutReason'
import { getDeviceLedgerList } from '@/api/base/deviceLedger'
export default {
@ -268,7 +238,8 @@ export default {
data() {
return {
ledgerList:[],
shutTypeList:[],
ledgerMap:{},
shutReasonList:[],
//
loading: true,
//
@ -292,8 +263,7 @@ export default {
pageNum: 1,
pageSize: 10,
deviceId: null,
shutType: null,
shutReason: null,
shutReasonId: null,
shutBeginTime: null,
shutEndTime: null,
shutTime: null,
@ -303,31 +273,38 @@ export default {
form: {},
//
rules: {
isFlag: [
{ required: true, message: "是否标识1-是2-否不能为空", trigger: "blur" }
],
shutReasonId: [
{ required: true, message: "请选择停机原因", trigger: "change" }
]
}
};
},
created() {
this.getList();
this.getDevice();
this.getShutType();
this.getShutReason();
},
methods: {
/** 查询停机类型信息列表 */
getShutType() {
listShutType(this.queryParams).then(response => {
console.log(response)
this.shutTypeList = response.rows;
/** 停机原因列表 */
getShutReason() {
selectDmsBaseShutReasonList({}).then(res => {
this.shutReasonList = res.rows || res.data || [];
});
},
onReasonChange(val) {
const found = this.shutReasonList.find(r => r.shutReasonId === val);
this.form.shutReason = found ? found.shutReasonName : null;
},
//
getDevice(){
getDeviceLedgerList({}).then(response => {
// console.log(response)
this.ledgerList = response.data;
this.ledgerMap = Array.isArray(response.data)
? response.data.reduce((acc, cur) => {
acc[cur.deviceId] = cur;
return acc;
}, {})
: {};
})
},
/** 查询停机记录列表 */
@ -349,7 +326,7 @@ export default {
this.form = {
recordShutDownId: null,
deviceId: null,
shutType: null,
shutReasonId: null,
shutReason: null,
shutBeginTime: null,
shutEndTime: null,
@ -399,6 +376,11 @@ export default {
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
// 便使
if (this.form.shutReasonId && !this.form.shutReason) {
const found = this.shutReasonList.find(r => r.shutReasonId === this.form.shutReasonId);
this.form.shutReason = found ? found.shutReasonName : this.form.shutReason;
}
if (this.form.recordShutDownId != null) {
updateShutDown(this.form).then(response => {
this.$modal.msgSuccess("修改成功");

@ -182,7 +182,7 @@
<!-- <el-form-item label="设备ID关联dms_base_device_ledger的device_id" prop="deviceId">-->
<!-- <el-input v-model="form.deviceId" placeholder="请输入设备ID关联dms_base_device_ledger的device_id" />-->
<!-- </el-form-item>-->
<el-form-item label="设备名称" prop="deviceId" >
<!-- <el-form-item label="设备名称" prop="deviceId" >
<el-select v-model="form.deviceId" placeholder="请输入设备类型">
<el-option
v-for="item in ledgerList"
@ -191,7 +191,7 @@
:value="item.deviceId">
</el-option>
</el-select>
</el-form-item>
</el-form-item>-->
<!-- <el-form-item label="停机类型,关联dms_base_shut_type的shut_type_id" prop="shutTypeId">-->
<!-- <el-input v-model="form.shutTypeId" placeholder="请输入停机类型,关联dms_base_shut_type的shut_type_id" />-->
<!-- </el-form-item>-->
@ -276,6 +276,9 @@ export default {
reasonCode: [
{ required: true, message: "部位名称不能为空", trigger: "blur" }
],
shutReason: [
{ required: true, message: "停机原因不能为空", trigger: "blur" }
],
}
};
},
@ -383,8 +386,13 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const shutReasonIds = row.shutReasonId || this.ids;
// R001
const shutReasonIds = row && row.shutReasonId ? [row.shutReasonId] : this.ids;
const idsArray = Array.isArray(shutReasonIds) ? shutReasonIds : [shutReasonIds];
// 1 R001
if (idsArray.includes(1) || idsArray.includes('1')) {
this.$modal.msgWarning('主键为 1 的原因不允许删除');
return;
}
if (row && row.reasonCode === 'R001') {
this.$modal.msgWarning('原因编号 R001 不允许删除');
return;
@ -398,7 +406,7 @@ export default {
return;
}
}
const reasonCode = row.reasonCode || this.ids;
const reasonCode = row && row.reasonCode ? row.reasonCode : this.ids;
this.$modal.confirm('是否确认删除停机原因信息编号为"' + reasonCode + '"的数据项?').then(function() {
return delShutReason(shutReasonIds);
}).then(() => {

@ -272,8 +272,14 @@ export default {
},
/** 删除按钮操作 */
handleDelete(row) {
const shutTypeIds = row.shutTypeId || this.ids;
const typeCodes = row.typeCode || this.typeCode;
const shutTypeIds = row && row.shutTypeId ? [row.shutTypeId] : this.ids;
// 1
const idsArray = Array.isArray(shutTypeIds) ? shutTypeIds : [shutTypeIds];
if (idsArray.includes(1) || idsArray.includes('1')) {
this.$modal.msgWarning('主键为 1 的类型不允许删除');
return;
}
const typeCodes = row && row.typeCode ? row.typeCode : this.typeCode;
this.$modal.confirm('是否确认删除类型编号为"' + typeCodes + '"的数据项?').then(function() {
return delShutType(shutTypeIds);
}).then(() => {

Loading…
Cancel
Save