mirror of
https://gitee.com/js-yhsec/energy_storage.git
synced 2026-05-27 18:59:26 +08:00
```
refactor(EditCom, device, station): 优化逻辑处理和错误提示 - 在 `EditCom.vue` 中,修改了 `workModeIdSelect` 监听器的条件判断,确保只有在旧值存在且新旧值不同时才清空 `policy_id`。 - 判断调用 `getRoleIdList` 方法。 - 在多个异步方法(如 `userConfirm`, `roleConfirm`, `stationConfirm`, `deviceConfirm`)中统一了成功与失败的消息提示,并移除了原有的错误日志打印。 - 场站管理对状态和策略id进行修改。 - 对 `station.vue` 进行了格式调整,改进了 `forEach` 循环内的逻辑处理。 ```
This commit is contained in:
@@ -176,9 +176,9 @@ export default {
|
|||||||
computed: {},
|
computed: {},
|
||||||
watch: {
|
watch: {
|
||||||
workModeIdSelect: {
|
workModeIdSelect: {
|
||||||
async handler(n,o) {
|
async handler(n, o) {
|
||||||
if(n !== o){
|
if (o && n !== o) {
|
||||||
this.detailInfos[0].ruleForm.policy_id=''
|
this.detailInfos[0].ruleForm.policy_id = ''
|
||||||
}
|
}
|
||||||
switch (n) {
|
switch (n) {
|
||||||
case '1':
|
case '1':
|
||||||
@@ -235,6 +235,7 @@ export default {
|
|||||||
this.detailInfos = stationOptions
|
this.detailInfos = stationOptions
|
||||||
this.formRules = stationFormRules
|
this.formRules = stationFormRules
|
||||||
this.workModeIdSelect = this.detailInfos[0].ruleForm['work_mode']
|
this.workModeIdSelect = this.detailInfos[0].ruleForm['work_mode']
|
||||||
|
console.log(stationOptions)
|
||||||
|
|
||||||
break
|
break
|
||||||
case 'device':
|
case 'device':
|
||||||
@@ -264,7 +265,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
|
if(this.type == 'user'||this.type == 'role'){
|
||||||
this.getRoleIdList()
|
this.getRoleIdList()
|
||||||
|
|
||||||
|
}
|
||||||
},
|
},
|
||||||
unmounted() {
|
unmounted() {
|
||||||
console.log('modal')
|
console.log('modal')
|
||||||
@@ -275,10 +279,8 @@ export default {
|
|||||||
try {
|
try {
|
||||||
const res = await getReq('/queryPolicyByType', { type })
|
const res = await getReq('/queryPolicyByType', { type })
|
||||||
if (res.errcode == 0) {
|
if (res.errcode == 0) {
|
||||||
list = res.data
|
list = res.data.map((item) => {
|
||||||
.map((item) => {
|
return { label: item.name, value: item.policy_id }
|
||||||
|
|
||||||
return {label:item.name,value:item.policy_id }
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -386,14 +388,16 @@ export default {
|
|||||||
|
|
||||||
const res = await postReq(menuApi[this.action], paramsDate)
|
const res = await postReq(menuApi[this.action], paramsDate)
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
|
this.$message.success('操作成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.handleback()
|
this.handleback()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
throw res
|
throw res
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error, 'userConfirm')
|
this.$message.error('操作失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async roleConfirm() {
|
async roleConfirm() {
|
||||||
@@ -429,14 +433,16 @@ export default {
|
|||||||
|
|
||||||
const res = await postReq(menuApi[this.action], paramsDate)
|
const res = await postReq(menuApi[this.action], paramsDate)
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
|
this.$message.success('操作成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.handleback()
|
this.handleback()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
throw res
|
throw res
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error, 'roleConfirm')
|
this.$message.error('操作失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
// 定义筛选树形数据的函数
|
// 定义筛选树形数据的函数
|
||||||
@@ -507,22 +513,27 @@ export default {
|
|||||||
edit: '/updateStation'
|
edit: '/updateStation'
|
||||||
}
|
}
|
||||||
const paramsDate = {
|
const paramsDate = {
|
||||||
...this.form
|
...this.form,
|
||||||
|
status:Number(this.form.status),
|
||||||
|
work_mode:this.workModeIdSelect
|
||||||
}
|
}
|
||||||
if (this.action == 'edit') {
|
if (this.action == 'edit') {
|
||||||
paramsDate.station_id = this.record.station_id
|
paramsDate.station_id = this.record.station_id
|
||||||
}
|
}
|
||||||
|
|
||||||
const res = await postReq(menuApi[this.action], paramsDate)
|
const res = await postReq(menuApi[this.action], paramsDate)
|
||||||
|
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
|
this.$message.success('操作成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.handleback()
|
this.handleback()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
throw res
|
throw res
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error, 'stationConfirm')
|
this.$message.error('操作失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async deviceConfirm() {
|
async deviceConfirm() {
|
||||||
@@ -544,7 +555,7 @@ export default {
|
|||||||
|
|
||||||
const res = await postReq(menuApi[this.action], paramsDate)
|
const res = await postReq(menuApi[this.action], paramsDate)
|
||||||
if (res.errcode === 0) {
|
if (res.errcode === 0) {
|
||||||
this.$message.success('添加成功')
|
this.$message.success('操作成功')
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.handleback()
|
this.handleback()
|
||||||
}, 1000)
|
}, 1000)
|
||||||
@@ -552,7 +563,7 @@ export default {
|
|||||||
throw res
|
throw res
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$message.error('添加失败')
|
this.$message.error('操作失败')
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async serviceApiConfirm() {
|
async serviceApiConfirm() {
|
||||||
|
|||||||
@@ -154,7 +154,6 @@ export default {
|
|||||||
this.getRuleFormInfo()
|
this.getRuleFormInfo()
|
||||||
} else if (type == 'edit' || type == 'read') {
|
} else if (type == 'edit' || type == 'read') {
|
||||||
await this.getRuleFormInfo(record)
|
await this.getRuleFormInfo(record)
|
||||||
|
|
||||||
this.formModal = true
|
this.formModal = true
|
||||||
this.formState = record
|
this.formState = record
|
||||||
} else if (type == 'del') {
|
} else if (type == 'del') {
|
||||||
|
|||||||
@@ -18,7 +18,9 @@
|
|||||||
<span>{{}}</span>
|
<span>{{}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #work_mode="record">
|
<template #work_mode="record">
|
||||||
<span>{{ workModeList.find((item) => record.work_mode == item.value)?.label || '' }}</span>
|
<span>{{
|
||||||
|
workModeList.find((item) => record.work_mode == item.value)?.label || ''
|
||||||
|
}}</span>
|
||||||
</template>
|
</template>
|
||||||
<template #policy_id="record">
|
<template #policy_id="record">
|
||||||
<span>{{ policyList.find((item) => record.policy_id == item.value)?.label || '' }}</span>
|
<span>{{ policyList.find((item) => record.policy_id == item.value)?.label || '' }}</span>
|
||||||
@@ -28,7 +30,13 @@
|
|||||||
</template>
|
</template>
|
||||||
</ComTable>
|
</ComTable>
|
||||||
</div>
|
</div>
|
||||||
<a-modal v-model:open="formModal" width="750px" style="top: 80px" :footer="null" :destroy-on-close="true">
|
<a-modal
|
||||||
|
v-model:open="formModal"
|
||||||
|
width="750px"
|
||||||
|
style="top: 80px"
|
||||||
|
:footer="null"
|
||||||
|
:destroy-on-close="true"
|
||||||
|
>
|
||||||
<!-- action:edit add -->
|
<!-- action:edit add -->
|
||||||
<EditCom
|
<EditCom
|
||||||
ref="EditCom"
|
ref="EditCom"
|
||||||
@@ -62,7 +70,7 @@ export default {
|
|||||||
props: {},
|
props: {},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
tableData:[],
|
tableData: [],
|
||||||
tableOption: {
|
tableOption: {
|
||||||
select: false
|
select: false
|
||||||
},
|
},
|
||||||
@@ -238,20 +246,18 @@ export default {
|
|||||||
stationOptions.forEach((e, index) => {
|
stationOptions.forEach((e, index) => {
|
||||||
e.list.forEach((i) => {
|
e.list.forEach((i) => {
|
||||||
if (i.key == 'work_mode') {
|
if (i.key == 'work_mode') {
|
||||||
switch (row[i.key]) {
|
if (row[i.key] == 1 || row[i.key] == 5) {
|
||||||
case '1':
|
|
||||||
case '5':
|
|
||||||
e.ruleForm[i.key] =row[i.key]
|
|
||||||
e.ruleForm['policy_id'] = row ? row['policy_id'] : ''
|
|
||||||
stationOptions[0].list[stationOptions[0].list.length - 1].type = 'select'
|
stationOptions[0].list[stationOptions[0].list.length - 1].type = 'select'
|
||||||
break
|
e.ruleForm[i.key] = row[i.key]
|
||||||
default:
|
e.ruleForm['policy_id'] = row ? row['policy_id'] : ''
|
||||||
e.ruleForm[i.key] =row[i.key]
|
} else {
|
||||||
|
e.ruleForm[i.key] = row[i.key]
|
||||||
|
|
||||||
stationOptions[0].list[stationOptions[0].list.length - 1].type = 'unshow'
|
stationOptions[0].list[stationOptions[0].list.length - 1].type = 'unshow'
|
||||||
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
|
} else if (i.key == 'status') {
|
||||||
|
e.ruleForm.status = row ? Boolean(Number(row.status)) : ''
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
e.ruleForm[i.key] = row ? row[i.key] : ''
|
e.ruleForm[i.key] = row ? row[i.key] : ''
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user