Commit ed9df492 authored by 裴文涛's avatar 裴文涛

解决修改窗口数据覆盖Bug

parent a69eeefe
...@@ -51,9 +51,7 @@ function search() { ...@@ -51,9 +51,7 @@ function search() {
} }
} }
const revise = (row) => { // 修改按钮单击事件 const revise = (row) => { // 修改按钮单击事件
console.log('row的值:',row) dependentSub.value = row
dependentSub.value = data.value[row]
// console.log('dependentSub的值:', dependentSub.value)
reviseWindowOpen.value = true reviseWindowOpen.value = true
} }
const bind = (row) => { // 绑定按钮单击事件 const bind = (row) => { // 绑定按钮单击事件
...@@ -62,7 +60,6 @@ const bind = (row) => { // 绑定按钮单击事件 ...@@ -62,7 +60,6 @@ const bind = (row) => { // 绑定按钮单击事件
} }
const cancelRevise = ()=>{ const cancelRevise = ()=>{
reviseWindowOpen.value = false reviseWindowOpen.value = false
reset()
getData() getData()
} }
const confirmRevise = val => { // 修改弹窗确认按钮事件 const confirmRevise = val => { // 修改弹窗确认按钮事件
...@@ -138,7 +135,6 @@ function getData() { ...@@ -138,7 +135,6 @@ function getData() {
getWeatherMagData().then(res => { getWeatherMagData().then(res => {
data.value = res.data data.value = res.data
dataBackup.value = [...data.value]; dataBackup.value = [...data.value];
console.log('获取到的所有数据',data.value)
}) })
} }
function handleAddWinOpenClose(){ function handleAddWinOpenClose(){
...@@ -198,26 +194,7 @@ function getOrganizationStructure() { ...@@ -198,26 +194,7 @@ function getOrganizationStructure() {
ElMessage.error('接口异常,获取数据失败.') ElMessage.error('接口异常,获取数据失败.')
}) })
} // 获取组织结构 } // 获取组织结构
function reset(){
dependentSub.value = {
allowPagingId:"",
temperature:"",
wind:"",
illumination:"",
diffPercentage:"",
timeoutMin:"",
tempRegulation:"",
sort:"",
customizeName:"",
supplyName:"",
customizeId:"",
isFixed:"",
isAuto:"",
supplyId:"",
operateTime:"",
updateNullFields:''
}
}
function resetSearch(){ function resetSearch(){
isAutoSearchKey.value = '' isAutoSearchKey.value = ''
supplySearchKey.value = '' supplySearchKey.value = ''
...@@ -254,7 +231,7 @@ function resetSearch(){ ...@@ -254,7 +231,7 @@ function resetSearch(){
border border
style="width: 100%" style="width: 100%"
height="720px" height="720px"
:default-sort="{ prop: 'operateTime', order: 'descending' }"
:header-cell-class-name="tableHeaderClass" :header-cell-class-name="tableHeaderClass"
:row-class-name="tableBodyClass"> :row-class-name="tableBodyClass">
<el-table-column prop="allowPagingId" label="编号" align="center" width="60"/> <el-table-column prop="allowPagingId" label="编号" align="center" width="60"/>
...@@ -273,7 +250,7 @@ function resetSearch(){ ...@@ -273,7 +250,7 @@ function resetSearch(){
<el-table-column label="操作" fixed="right" width="200"> <el-table-column label="操作" fixed="right" width="200">
<template #default="scope"> <template #default="scope">
<div class="table-operate-column"> <div class="table-operate-column">
<el-button link @click="revise(scope.$index)" type="primary">修改</el-button> <el-button link @click="revise(scope.row)" type="primary">修改</el-button>
<el-button link @click="bind(scope.row)" type="primary">绑定换热站</el-button> <el-button link @click="bind(scope.row)" type="primary">绑定换热站</el-button>
</div> </div>
</template> </template>
......
...@@ -94,7 +94,7 @@ const rules = reactive({ ...@@ -94,7 +94,7 @@ const rules = reactive({
{ pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "风速必须是1-11位实数", trigger: "blur" } { pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "风速必须是1-11位实数", trigger: "blur" }
], ],
illumination: [ illumination: [
{ pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "光照必须是1-11位实数", trigger: "blur" } { pattern: /^(\d{1,2})?$/, "message": "光照必须是1-2位实数", trigger: "blur" }
], ],
sort: [ sort: [
{ pattern: /^(\d{1,11})$/, "message": "排序必须是1-11位正整数", trigger: "blur" } { pattern: /^(\d{1,11})$/, "message": "排序必须是1-11位正整数", trigger: "blur" }
...@@ -155,7 +155,7 @@ const rules = reactive({ ...@@ -155,7 +155,7 @@ const rules = reactive({
<el-col :span="8" class="content-col-label">光照:</el-col> <el-col :span="8" class="content-col-label">光照:</el-col>
<el-col :span="16" class="content-col-value"> <el-col :span="16" class="content-col-value">
<el-form-item prop="illumination" style="padding: 0;margin: 0;"> <el-form-item prop="illumination" style="padding: 0;margin: 0;">
<el-input :input-style="inputStyle" maxlength="11" v-model="addData.illumination" <el-input :input-style="inputStyle" maxlength="2" v-model="addData.illumination"
style="width: 510px" /> style="width: 510px" />
</el-form-item> </el-form-item>
</el-col> </el-col>
......
...@@ -68,6 +68,9 @@ function onSubmit() { ...@@ -68,6 +68,9 @@ function onSubmit() {
updateNullFields: '' updateNullFields: ''
}) })
}) })
bindData.value.isAuto = bindData.value.isAuto === '自动模式' ? true : false;
bindData.value.isFixed = bindData.value.isFixed === '固定模式' ? true : false;
bindData.value.updateNullFields = ""
emit('onConfirm', bindData.value) emit('onConfirm', bindData.value)
}else { }else {
ElMessage.error('请选择供热站') ElMessage.error('请选择供热站')
...@@ -110,6 +113,7 @@ async function getTransfer(supplyId, isAvailable = true) { ...@@ -110,6 +113,7 @@ async function getTransfer(supplyId, isAvailable = true) {
function onOpen() { function onOpen() {
bindData.value.transfers = []
loadingInstance = ElLoading.service({target: '#bind-dialog'}) loadingInstance = ElLoading.service({target: '#bind-dialog'})
selectedTransfer.value.length = 0 // 清空已选择的换热站 selectedTransfer.value.length = 0 // 清空已选择的换热站
transferData.value.length = 0 // 清空显示的换热站 transferData.value.length = 0 // 清空显示的换热站
......
...@@ -24,22 +24,22 @@ const emit = defineEmits({ ...@@ -24,22 +24,22 @@ const emit = defineEmits({
} }
}) })
const reviseData = ref({ const reviseData = ref({
allowPagingId:"", allowPagingId: "",
temperature:"", temperature: "",
wind:"", wind: "",
illumination:"", illumination: "",
diffPercentage:"", diffPercentage: "",
timeoutMin:"", timeoutMin: "",
tempRegulation:"", tempRegulation: "",
sort:"", sort: "",
customizeName:"", customizeName: "",
supplyName:"", supplyName: "",
customizeId:"", customizeId: "",
isFixed:"", isFixed: "",
isAuto:"", isAuto: "",
supplyId:"", supplyId: "",
operateTime:"", operateTime: "",
updateNullFields:'' updateNullFields: ''
}) })
const formRef = ref() const formRef = ref()
...@@ -53,7 +53,7 @@ const rules = reactive({ ...@@ -53,7 +53,7 @@ const rules = reactive({
{pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "风速必须是1-11位实数", trigger: "blur"} {pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "风速必须是1-11位实数", trigger: "blur"}
], ],
illumination: [ illumination: [
{pattern: /^(\d{1,11})(\.[0-9]{1,4})?$/, "message": "光照必须是1-11位实数", trigger: "blur"} {pattern: /^(\d{1,2})?$/, "message": "光照必须是1-11位实数", trigger: "blur"}
], ],
sort: [ sort: [
{pattern: /^(\d{1,11})$/, "message": "排序必须是1-11位正整数", trigger: "blur"} {pattern: /^(\d{1,11})$/, "message": "排序必须是1-11位正整数", trigger: "blur"}
...@@ -67,10 +67,7 @@ const rules = reactive({ ...@@ -67,10 +67,7 @@ const rules = reactive({
] ]
}); });
watchEffect(() => { watchEffect(() => {
// reviseData.value = {...props.data}
// props.data.transfers = []
reviseData.value = props.data // 深拷贝数据 reviseData.value = props.data // 深拷贝数据
// console.log('>>>>>>>>>>>',props.data)
}) })
const inputStyle = { const inputStyle = {
color: 'black', color: 'black',
...@@ -89,20 +86,20 @@ const switchingisAuto = computed({ ...@@ -89,20 +86,20 @@ const switchingisAuto = computed({
} }
}) // 可写计算属性,手动、自动模式切换 }) // 可写计算属性,手动、自动模式切换
function onOpen() { function onOpen() {
// console.log('点击弹窗:',reviseData.value) reviseData.value.updateNullFields = ""
// console.log('props的值:', props.data)
formRef.value.resetFields()
} }
async function handleConfirm() { function handleConfirm() {
if (reviseData.value.hasOwnProperty('supplyId')) { reviseData.value.transfers = []
if (reviseData.value.supplyId) { formRef.value.validate(async valid => {
getTransferInterface({ if (valid) {
if (reviseData.value.supplyId !== undefined && reviseData.value.supplyId !== '') {
const result = await getTransferInterface({
customizeId: reviseData.value.customizeId, customizeId: reviseData.value.customizeId,
supplyId: reviseData.value.supplyId supplyId: reviseData.value.supplyId
}).then(result => { })
for (let item of result.data) { for (let item of result.data) {
if(item.selected.toLowerCase() === 'true'){ if (item.selected.toLowerCase() === 'true') {
reviseData.value.transfers.push( reviseData.value.transfers.push(
{ {
customizeId: reviseData.value.customizeId, customizeId: reviseData.value.customizeId,
...@@ -112,42 +109,21 @@ async function handleConfirm() { ...@@ -112,42 +109,21 @@ async function handleConfirm() {
) )
} }
} }
formRef.value.validate(valid => { } else {
if (valid) { delete reviseData.value.supplyId
}
reviseData.value.isAuto = reviseData.value.isAuto === '自动模式' ? true : false;
reviseData.value.isFixed = reviseData.value.isFixed === '固定模式' ? true : false;
console.log('修改数据', reviseData.value)
emit('onConfirm', reviseData.value) emit('onConfirm', reviseData.value)
reset()
} }
}) })
})
}
}
} }
function onClose(){
function onClose() {
emit('onCancel') emit('onCancel')
reset()
} }
function reset(){
reviseData.value = {
allowPagingId:"",
temperature:"",
wind:"",
illumination:"",
diffPercentage:"",
timeoutMin:"",
tempRegulation:"",
sort:"",
customizeName:"",
supplyName:"",
customizeId:"",
isFixed:"",
isAuto:"",
supplyId:"",
operateTime:"",
updateNullFields:''
}
}
</script> </script>
<template> <template>
...@@ -192,7 +168,7 @@ function reset(){ ...@@ -192,7 +168,7 @@ function reset(){
<el-col :span="8" class="content-col-label">光照:</el-col> <el-col :span="8" class="content-col-label">光照:</el-col>
<el-col :span="16" class="content-col-value"> <el-col :span="16" class="content-col-value">
<el-form-item prop="illumination" style="padding: 0;margin: 0;"> <el-form-item prop="illumination" style="padding: 0;margin: 0;">
<el-input :input-style="inputStyle" maxlength="11" v-model="reviseData.illumination" <el-input :input-style="inputStyle" maxlength="2" v-model="reviseData.illumination"
style="width: 510px"/> style="width: 510px"/>
</el-form-item> </el-form-item>
</el-col> </el-col>
......
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