diff --git a/src/store/modules/user.js b/src/store/modules/user.js index 8923977..183a083 100644 --- a/src/store/modules/user.js +++ b/src/store/modules/user.js @@ -7,6 +7,8 @@ const user = { token: getToken(), name: '', avatar: '', + userId:'', + userName: '', roles: [], permissions: [] }, @@ -29,7 +31,15 @@ const user = { }, SET_USERINFO: (state, value) => { state.userInfo = value - } + }, + SET_USERID: (state, value) => { + state.userId = value + }, + SET_USERID: (state, value) => { + state.userName = value + }, + + }, actions: { @@ -65,6 +75,8 @@ const user = { if (data.roles && data.roles.length > 0) { // 验证返回的roles是否是一个非空数组 commit('SET_ROLES', data.roles) + commit('SET_USERID', data.user.id), + commit('SET_USERNAME', data.user.username) commit('SET_PERMISSIONS', data.permissions) } else { commit('SET_ROLES', ['ROLE_DEFAULT']) diff --git a/src/views/andonManagement/humanComputerInteraction/index.vue b/src/views/andonManagement/humanComputerInteraction/index.vue index 7bc8813..baea2f8 100644 --- a/src/views/andonManagement/humanComputerInteraction/index.vue +++ b/src/views/andonManagement/humanComputerInteraction/index.vue @@ -115,8 +115,7 @@ - + @@ -207,6 +206,8 @@ import { getAndonAreaParentDictList,//区域一 getAndonAreaChildDictList,//区域二 } from '@/api/andonManagement/policeRecord/index.js'; +import { getInfo } from '@/api/system/login' +import store from '@/store'; export default { data() { const rules = { @@ -260,9 +261,16 @@ export default { ], alarmCode: '', ids: '', + + // 移动到 data 中的用户信息 + userId: '', + userName: '' } }, + + created() { + this.getLeftList() getAndonAlarmTypeDictList().then(res => { if (res.code == 200) { @@ -278,11 +286,22 @@ export default { }) } }) + getInfo().then(res => { + if (res.code == 200) { + console.log(res, '获取用户信息'); + this.userId = res.data.user.userId + this.userName = res.data.user.nickName + } + }) }, + mounted() { }, + methods: { + + getLeftList() { this.loading = true; listAndonAlarmRecord(this.queryParams).then(res => { @@ -293,6 +312,7 @@ export default { } }) }, + handleRowClick(row, column, event) { this.ids = row.id console.log(this.ids, '获取的id'); @@ -306,12 +326,15 @@ export default { } }) }, + handleQuery() { this.queryVisible = true }, + handleAdd() { this.open = true }, + handleAreaChange(label) { console.log('区域选择变化:', label); this.changeValue = label; @@ -330,28 +353,14 @@ export default { } }); }, + resetFormAdd() { this.formAdd = {} if (this.$refs.formAdd) { this.$refs.formAdd.resetFields(); } }, - // handleAddSubmit() { - // this.$refs.formAdd.validate((valid) => { - // if (valid) { - // console.log(this.formAdd, '新增的数据'); - // addAndonAlarmRecord(this.formAdd).then(res => { - // if (res.code == 200) { - // this.msgSuccess("新增成功"); - // this.open = false; - // this.getLeftList(); - // } - // }); - // } else { - // return false; - // } - // }); - // }, + handleClose() { this.timeData = [ new Date(), @@ -359,6 +368,7 @@ export default { ] this.queryVisible = false }, + handleTimeSubmit() { let params = { pageNum: this.queryParams.pageNum, @@ -378,19 +388,26 @@ export default { handleAreaExpandChange(val) { console.log(val[0], '区域选择变化'); }, + handleAlarmTypeChange(value) { + // 修复: 原代码中使用了未定义的 alarmTypeDataList + // 这里暂时移除这部分逻辑,因为没有看到 alarmTypeDataList 的定义 + /* const selectedType = this.alarmTypeDataList.find(item => item.label === value); if (selectedType) { this.$set(this.form, 'responseTime', selectedType.responseTime); } else { this.$set(this.form, 'responseTime', undefined); } + */ }, + // 取消按钮 cancel() { this.open = false; this.reset(); }, + // 提交按钮 submitForm: function () { this.$refs["form"].validate((valid) => { @@ -439,8 +456,15 @@ export default { } }); }, + //响应 handleResponse() { + let data = { + ...this.form, + userId: String(this.userId), + userName: this.userName + } + if (this.ids == '' || this.ids == null || this.ids == undefined) { this.$message({ message: '请选择报警信息', @@ -448,6 +472,7 @@ export default { }); return false; } + if (this.form.status == '已处理') { this.$message({ message: '此报警已处理', @@ -455,19 +480,21 @@ export default { }); return } - if(this.form.status == '已响应'){ + + if (this.form.status == '已响应') { this.$message({ message: '此报警已响应', type: 'warning' }); return } + this.$confirm('确定要响应此报警吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - getAndonAlarmRecordProcessList(this.form).then(res => { + getAndonAlarmRecordProcessList(data).then(res => { if (res.code == 200) { this.$message({ type: 'success', @@ -485,8 +512,15 @@ export default { }); }); }, + //处理完毕 hanleCompleted() { + let data = { + ...this.form, + userId: String(this.userId), + userName: this.userName + } + if (this.ids == '' || this.ids == null || this.ids == undefined) { this.$message({ message: '请选择报警信息', @@ -494,6 +528,7 @@ export default { }); return false; } + if (this.form.handleResult == '' || this.form.handleResult == null) { this.$message({ message: '请填写处理结果', @@ -501,12 +536,13 @@ export default { }); return } + this.$confirm('确定要处理完毕此报警吗?', '提示', { confirmButtonText: '确定', cancelButtonText: '取消', type: 'warning' }).then(() => { - addAndonAlarmRecordProcess(this.form).then(res => { + addAndonAlarmRecordProcess(data).then(res => { if (res.code == 200) { this.$message({ type: 'success', @@ -524,35 +560,7 @@ export default { }); }); }, - // hanleReportToSuperiors() { - // if (this.ids == '' || this.ids == null || this.ids == undefined) { - // this.$message({ - // message: '请选择报警信息', - // type: 'warning' - // }); - // return false; - // } - // this.$confirm('确定报告上级此报警吗?', '提示', { - // confirmButtonText: '确定', - // cancelButtonText: '取消', - // type: 'warning' - // }).then(() => { - // addAndonAlarmRecordReport(this.form).then(res => { - // if (res.code == 200) { - // this.$message({ - // type: 'success', - // message: '已报告!' - // }); - // } - // }) - // }).catch(() => { - // this.$message({ - // type: 'info', - // message: '已取消' - // }); - // }); - // }, formatDate(date) { if (!date) return ''; const year = date.getFullYear(); diff --git a/src/views/andonManagement/policeRecord/index.vue b/src/views/andonManagement/policeRecord/index.vue index ae66ea8..6f2609b 100644 --- a/src/views/andonManagement/policeRecord/index.vue +++ b/src/views/andonManagement/policeRecord/index.vue @@ -36,7 +36,8 @@ - + @@ -486,6 +487,7 @@ export default { let data = { ...this.form, + }; if (this.form.alarmType) {