diff --git a/src/api/dms/shutReason.js b/src/api/dms/shutReason.js
index 60fe4d4..a9074de 100644
--- a/src/api/dms/shutReason.js
+++ b/src/api/dms/shutReason.js
@@ -42,3 +42,13 @@ export function delShutReason(shutReasonId) {
method: 'delete'
})
}
+
+
+// 不分页查询所有停机原因信息列表
+export function selectDmsBaseShutReasonList(query) {
+ return request({
+ url: '/dms/shutReason/selectDmsBaseShutReasonList',
+ method: 'get',
+ params: query
+ })
+}
\ No newline at end of file
diff --git a/src/views/dms/shutDownRecord/index.vue b/src/views/dms/shutDownRecord/index.vue
index 1da741b..b5e4ba3 100644
--- a/src/views/dms/shutDownRecord/index.vue
+++ b/src/views/dms/shutDownRecord/index.vue
@@ -9,27 +9,16 @@
-
-
-
-
-
+
+
-
+ v-for="item in shutReasonList"
+ :key="item.shutReasonId"
+ :label="item.shutReason"
+ :value="item.shutReasonId" />
-
+
@@ -117,15 +106,10 @@
-
-
- v-for="(item, index) in ledgerList"
- :key="index"
- :value="item.ledgerList"
- v-if="scope.row.deviceId == item.deviceId"
- >
- {{ item.deviceId }}
-
+
+ {{ row.deviceName }}
+ {{ ledgerMap[row.deviceId].deviceName || ledgerMap[row.deviceId].deviceCode }}
+ {{ row.deviceId }}
@@ -141,18 +125,7 @@
-
-
-
- {{ item.shutTypeName }}
-
-
-
+
@@ -169,13 +142,13 @@
-
-
-
-
-
-
-
+ 修改
-
+
@@ -211,19 +184,16 @@
-
-
+
+
-
+ v-for="item in shutReasonList"
+ :key="item.shutReasonId"
+ :label="item.shutReason"
+ :value="item.shutReasonId"
+ />
-
-
-
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("修改成功");
diff --git a/src/views/dms/shutReason/index.vue b/src/views/dms/shutReason/index.vue
index 3a8241c..8cb185d 100644
--- a/src/views/dms/shutReason/index.vue
+++ b/src/views/dms/shutReason/index.vue
@@ -182,7 +182,7 @@
-
+
@@ -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(() => {
diff --git a/src/views/dms/shutType/index.vue b/src/views/dms/shutType/index.vue
index 07c5e5c..2445b89 100644
--- a/src/views/dms/shutType/index.vue
+++ b/src/views/dms/shutType/index.vue
@@ -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(() => {