Commit 7d73c86f authored by 裴文涛's avatar 裴文涛

绑定换热站功能调整

parent ca388f4f
...@@ -36,7 +36,9 @@ const bindData = ref({}) // 要绑定的数据 ...@@ -36,7 +36,9 @@ const bindData = ref({}) // 要绑定的数据
const supplyData = ref([]) // 供热站数据 const supplyData = ref([]) // 供热站数据
const transferData = ref([]) // 换热站数据 const transferData = ref([]) // 换热站数据
const selectedTransfer = ref([]) // 被本气象干预方案选中的换热站 const selectedTransfer = ref([]) // 被本气象干预方案选中的换热站
const isSaveOper = ref(false)
let optional = '' // 可以选换热站的供热站 let optional = '' // 可以选换热站的供热站
let originSupply = '' // 原先绑定的供热站
let loadingInstance = null let loadingInstance = null
const inputStyle = { const inputStyle = {
color: 'black', color: 'black',
...@@ -68,6 +70,7 @@ function onSubmit() { ...@@ -68,6 +70,7 @@ function onSubmit() {
updateNullFields: '' updateNullFields: ''
}) })
}) })
bindData.value.isAuto = bindData.value.isAuto === '自动模式' ? true : false; bindData.value.isAuto = bindData.value.isAuto === '自动模式' ? true : false;
bindData.value.isFixed = bindData.value.isFixed === '固定模式' ? true : false; bindData.value.isFixed = bindData.value.isFixed === '固定模式' ? true : false;
bindData.value.updateNullFields = "" bindData.value.updateNullFields = ""
...@@ -93,25 +96,32 @@ async function getTransfer(supplyId, isAvailable = true) { ...@@ -93,25 +96,32 @@ async function getTransfer(supplyId, isAvailable = true) {
*/ */
const result = await getTransferInterface(param) const result = await getTransferInterface(param)
transferData.value = result.data transferData.value = result.data
if(isAvailable){ // if(isAvailable){
// 每次需要为换热站推入数据时,清空已有的数据 // // 每次需要为换热站推入数据时,清空已有的数据
selectedTransfer.value.length = 0 // selectedTransfer.value.length = 0
} // }
for (const item of transferData.value) { for (const item of transferData.value) {
if (!isAvailable) { if (!isAvailable) {
item.selected = item.selected.toLowerCase() === 'true' ? true : false item.selected = item.selected.toLowerCase() === 'true' ? true : false
item.enabled = false item.enabled = false
if (item.selected) { if (item.selected) {
if(optional !== originSupply && bindData.value.supplyId === originSupply){
continue
}
selectedTransfer.value.push(item.transferId) selectedTransfer.value.push(item.transferId)
} }
} else { } else {
item.selected = item.selected.toLowerCase() === 'true' ? true : false item.selected = item.selected.toLowerCase() === 'true' ? true : false
item.enabled = item.enabled.toLowerCase() === 'true' ? true : false item.enabled = item.enabled.toLowerCase() === 'true' ? true : false
if (item.selected) { if (item.selected) {
if(optional !== originSupply && bindData.value.supplyId === originSupply){
continue
}
selectedTransfer.value.push(item.transferId) selectedTransfer.value.push(item.transferId)
} }
} }
} }
selectedTransfer.value = [...unique(selectedTransfer.value)]
loadingInstance.close() loadingInstance.close()
} }
...@@ -124,6 +134,7 @@ function onOpen() { ...@@ -124,6 +134,7 @@ function onOpen() {
if (bindData.value.hasOwnProperty('supplyId')) { if (bindData.value.hasOwnProperty('supplyId')) {
if (bindData.value.supplyId) { if (bindData.value.supplyId) {
optional = bindData.value.supplyId optional = bindData.value.supplyId
originSupply = bindData.value.supplyId
getTransfer(bindData.value.supplyId) getTransfer(bindData.value.supplyId)
} }
} }
...@@ -139,10 +150,13 @@ function selectChange(val) { ...@@ -139,10 +150,13 @@ function selectChange(val) {
loadingInstance = ElLoading.service({target: '#bind-dialog'}) loadingInstance = ElLoading.service({target: '#bind-dialog'})
if (selectedTransfer.value.length === 0) { if (selectedTransfer.value.length === 0) {
getTransfer(val) getTransfer(val)
isSaveOper.value = false
} else if (bindData.value.supplyId === optional) { } else if (bindData.value.supplyId === optional) {
getTransfer(val) getTransfer(val)
isSaveOper.value = false
} else { } else {
getTransfer(val, false) getTransfer(val, false)
isSaveOper.value = true
} }
loadingInstance.close() loadingInstance.close()
} }
...@@ -152,8 +166,16 @@ function selectChange(val) { ...@@ -152,8 +166,16 @@ function selectChange(val) {
* @param val * @param val
*/ */
function checkboxChange(val) { function checkboxChange(val) {
optional = bindData.value.supplyId
// console.log('checkboxChange====>>>===>>>', val) // console.log('checkboxChange====>>>===>>>', val)
} }
/**
* 过滤器,用于过滤掉重复的换热站ID
*/
function unique(arr){
return new Set(arr)
}
</script> </script>
<template> <template>
<el-dialog <el-dialog
...@@ -207,7 +229,7 @@ function checkboxChange(val) { ...@@ -207,7 +229,7 @@ function checkboxChange(val) {
</template> </template>
<template #footer> <template #footer>
<div class="dialog-footer"> <div class="dialog-footer">
<el-button type="primary" @click="onSubmit">保存</el-button> <el-button type="primary" :disabled="isSaveOper" @click="onSubmit">保存</el-button>
<el-button type="primary" @click="emit('onCancel')">关闭</el-button> <el-button type="primary" @click="emit('onCancel')">关闭</el-button>
</div> </div>
</template> </template>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment