Browse Source

绑定房屋

shibei_master
mk 2 years ago
parent
commit
fba45c7f7a
  1. 92
      src/views/modules/base/microGrid/microGridHouse.vue

92
src/views/modules/base/microGrid/microGridHouse.vue

@ -40,28 +40,31 @@
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<!-- multiple collapse-tags -->
<el-select v-model.trim="BUILD_ID" placeholder="楼号" size="small" clearable <el-select v-model.trim="BUILD_ID" placeholder="楼号" size="small" clearable
style="width: 150px;" class="resi-cell-select " :disabled="changeVDisabled" style="width: 150px;" class="resi-cell-select " :disabled="changeVDisabled"
@clear="handleClearBuild" multiple collapse-tags @change="handleChangeB" @clear="handleClearBuild" @change="handleChangeB"
popper-class="vSelsect" ref="buildS"> popper-class="vSelsect" ref="buildS">
<el-option v-for="(item, index) in optionsB" :key="index" :label="item.label" <el-option v-for="(item, index) in optionsB" :key="index" :label="item.label"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<el-select v-model.trim="UNIT_ID" multiple collapse-tags :disabled="changeBDisabled" <!-- multiple collapse-tags -->
<el-select v-model.trim="UNIT_ID" :disabled="changeBDisabled"
placeholder="单元" size="small" clearable style="width: 150px;" class="resi-cell-select " placeholder="单元" size="small" clearable style="width: 150px;" class="resi-cell-select "
@clear="handleClearDan" @change="handleChangeD" popper-class="vSelsect"> @clear="handleClearDan" @change="handleChangeD" popper-class="vSelsect">
<el-option v-for="(item, index) in optionsD " :key="index" :label="item.label" <el-option v-for="(item, index) in optionsD " :key="index" :label="item.label"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<el-select v-model.trim="HOME_ID" multiple collapse-tags :disabled="changeDDisabled" <el-select v-model.trim="HOME_ID" :disabled="changeDDisabled"
placeholder="房号" size="small" clearable style="width: 150px;" class="resi-cell-select " placeholder="房号" size="small" multiple collapse-tags clearable style="width: 150px;" class="resi-cell-select "
popper-class="vSelsect" @clear="handleClearHouse" @change="handleChangeH"> popper-class="vSelsect" @clear="handleClearHouse" @change="handleChangeH">
<el-option v-for="(item, index) in optionsH" :key="index" :label="item.label" <el-option v-for="(item, index) in optionsH" :key="index" :label="item.label"
:value="item.value"> :value="item.value">
</el-option> </el-option>
</el-select> </el-select>
<el-button type="primary" style="margin-left: 10px;" size="small" @click="handelClickCheck">选取</el-button>
</div> </div>
</div> </div>
<section> <section>
@ -198,7 +201,7 @@ export default {
getUniList() { getUniList() {
this.$http this.$http
.post('/gov/org/icbuildingunit/unitoption', { .post('/gov/org/icbuildingunit/unitoption', {
buildingId: this.BUILD_ID.join(',') buildingId: this.BUILD_ID
}) })
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
@ -215,7 +218,7 @@ export default {
}, },
getHouseList() { getHouseList() {
this.$http this.$http
.post('/gov/org/ichouse/houseoption', { unitId: this.UNIT_ID.join(',') }) .post('/gov/org/ichouse/houseoption', { unitId: this.UNIT_ID })
.then(({ data: res }) => { .then(({ data: res }) => {
if (res.code !== 0) { if (res.code !== 0) {
return this.$message.error(res.msg) return this.$message.error(res.msg)
@ -236,61 +239,69 @@ export default {
this.getBuildList() this.getBuildList()
}, },
handleChangeB(val) { handleChangeB(val) {
const selected = val.filter(item => !this.prevSelectedOptionsB.includes(item)); // const selected = val.filter(item => !this.prevSelectedOptionsB.includes(item));
const unselected = this.prevSelectedOptionsB.filter(item => !val.includes(item)); // const unselected = this.prevSelectedOptionsB.filter(item => !val.includes(item));
console.log(unselected); // console.log(unselected);
if (unselected.length > 0) { // if (unselected.length > 0) {
this.selArr = this.selArr.filter(item => item.id !== unselected[0]) // this.selArr = this.selArr.filter(item => item.id !== unselected[0])
} else { // } else {
this.getMicroGridHouseName(selected[selected.length - 1], 'building') // this.getMicroGridHouseName(selected[selected.length - 1], 'building')
} // }
this.prevSelectedOptionsB = [...val]; // this.prevSelectedOptionsB = [...val];
// //
this.UNIT_ID = '' this.UNIT_ID = ''
this.HOME_ID = '' this.HOME_ID = ''
this.getUniList() this.getUniList()
}, },
handleChangeD(val) { handleChangeD(val) {
const selected = val.filter(item => !this.prevSelectedOptionsD.includes(item)); // const selected = val.filter(item => !this.prevSelectedOptionsD.includes(item));
const unselected = this.prevSelectedOptionsD.filter(item => !val.includes(item)); // const unselected = this.prevSelectedOptionsD.filter(item => !val.includes(item));
if (unselected.length > 0) { // if (unselected.length > 0) {
this.selArr = this.selArr.filter(item => item.id !== unselected[0]) // this.selArr = this.selArr.filter(item => item.id !== unselected[0])
} else { // } else {
this.getMicroGridHouseName(selected[selected.length - 1], 'unit') // this.getMicroGridHouseName(selected[selected.length - 1], 'unit')
} // }
this.prevSelectedOptionsD = [...val]; // this.prevSelectedOptionsD = [...val];
this.HOME_ID = '' this.HOME_ID = ''
this.getHouseList() this.getHouseList()
}, },
handleChangeH(val) { handleChangeH(val) {
const selected = val.filter(item => !this.prevSelectedOptionsH.includes(item)); // const selected = val.filter(item => !this.prevSelectedOptionsH.includes(item));
const unselected = this.prevSelectedOptionsH.filter(item => !val.includes(item)); // const unselected = this.prevSelectedOptionsH.filter(item => !val.includes(item));
if (unselected.length > 0) { // if (unselected.length > 0) {
this.selArr = this.selArr.filter(item => item.id !== unselected[0]) // this.selArr = this.selArr.filter(item => item.id !== unselected[0])
} else { // } else {
this.getMicroGridHouseName(selected[selected.length - 1], 'house') // this.getMicroGridHouseName(selected[selected.length - 1], 'house')
} // }
this.prevSelectedOptionsH = [...val]; // this.prevSelectedOptionsH = [...val];
}, },
handleClearVillage() { handleClearVillage() {
this.BUILD_ID = '' this.BUILD_ID = ''
this.HOME_ID = '' this.HOME_ID = ''
}, },
handelClickCheck(){
if(this.HOME_ID.length > 0){
for(let i in this.HOME_ID){
this.getMicroGridHouseName(this.HOME_ID[i],'house')
}
}else if(this.UNIT_ID){
this.getMicroGridHouseName(this.UNIT_ID,'unit')
}else if(this.BUILD_ID){
this.getMicroGridHouseName(this.BUILD_ID,'building')
}
},
handleClearBuild() { handleClearBuild() {
this.BUILD_ID = '' this.BUILD_ID = ''
this.UNIT_ID = '' this.UNIT_ID = ''
this.HOME_ID = '' this.HOME_ID = ''
this.selArr = []
}, },
handleClearDan() { handleClearDan() {
this.UNIT_ID = '' this.UNIT_ID = ''
this.HOME_ID = '' this.HOME_ID = ''
this.selArr = this.selArr.filter(item => item.level !== 'unit' || item.level !== 'house') || []
}, },
handleClearHouse() { handleClearHouse() {
this.selArr = this.selArr.filter(item => item.level !== 'house') || []
}, },
handleSizeChange(val) { handleSizeChange(val) {
this.pageSize = val this.pageSize = val
@ -330,13 +341,6 @@ export default {
this.tableLoading = false this.tableLoading = false
}, },
handelClickDel(val) { handelClickDel(val) {
if (val.level === "building") {
this.BUILD_ID = this.BUILD_ID.filter(item => item !== val.id);
} else if (val.level === "unit") {
this.UNIT_ID = this.UNIT_ID.filter(item => item !== val.id);
} else if (val.level === "house") {
this.HOME_ID = this.HOME_ID.filter(item => item !== val.id);
}
this.selArr = this.selArr.filter(item => item.id !== val.id); this.selArr = this.selArr.filter(item => item.id !== val.id);
}, },
handleClose() { handleClose() {
@ -357,9 +361,9 @@ export default {
}, },
async handelSave() { async handelSave() {
let parm = { let parm = {
houseIds: this.HOME_ID ? this.HOME_ID.join(',') : '', houseIds: this.selArr.filter(item=>item.level == 'house').map(item=>item.id).join(',') || '',
unitIds: this.UNIT_ID ? this.UNIT_ID.join(',') : '', unitIds: this.selArr.filter(item=>item.level == 'unit').map(item=>item.id).join(',') || '',
buildingIds: this.BUILD_ID ? this.BUILD_ID.join(',') : '', buildingIds: this.selArr.filter(item=>item.level == 'building').map(item=>item.id).join(',')|| '' ,
microGridId: this.microGridId microGridId: this.microGridId
} }
let url = '/gov/org/house/addMicroGridHouse' let url = '/gov/org/house/addMicroGridHouse'

Loading…
Cancel
Save