|
|
|
|
@ -57,48 +57,14 @@ export default {
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<xy-table list={
|
|
|
|
|
this.distinct([
|
|
|
|
|
...this.selectedLands,
|
|
|
|
|
...this.selectedHouses,
|
|
|
|
|
...(() => {
|
|
|
|
|
let temp = [];
|
|
|
|
|
this.originalForm?.id_lets_to_assets_let_id_relation?.forEach(item => {
|
|
|
|
|
if (item.land_id) {
|
|
|
|
|
let land = this.originalForm.land?.find(land => land.id === item.land_id);
|
|
|
|
|
if (land) {
|
|
|
|
|
temp.push({
|
|
|
|
|
id: land.id,
|
|
|
|
|
name: land.name,
|
|
|
|
|
zuoluo: land.zuoluo,
|
|
|
|
|
zichanweizhi: land.zichanweizhi,
|
|
|
|
|
dengjimianji: land.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
_TAG_: "land"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let house = this.originalForm.house?.find(house => house.id === item.house_id);
|
|
|
|
|
if (house) {
|
|
|
|
|
temp.push({
|
|
|
|
|
id: house.id,
|
|
|
|
|
name: house.name,
|
|
|
|
|
zuoluo: house.zuoluo,
|
|
|
|
|
zichanweizhi: house.zichanweizhi,
|
|
|
|
|
dengjimianji: house.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
_TAG_: "house"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
|
})()
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
<xy-table
|
|
|
|
|
row-key={
|
|
|
|
|
row => {
|
|
|
|
|
row._relation_id ? row._relation_id : (row.hasOwnProperty('land_id') ? 'house_' + row.id : 'land_' + row.id)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ref="assetsTable"
|
|
|
|
|
list={this.nowAssets}
|
|
|
|
|
height="300"
|
|
|
|
|
isHandlerKey={false}
|
|
|
|
|
is-page={false}
|
|
|
|
|
@ -153,19 +119,19 @@ export default {
|
|
|
|
|
['click']: _ => {
|
|
|
|
|
this.$confirm("确定删除?").then(_ => {
|
|
|
|
|
if (row.hasOwnProperty("land_id")) {
|
|
|
|
|
this.$refs["houseLinkTable"]?.toggleRowSelection(row,false)
|
|
|
|
|
++this.houseSelectTemp;
|
|
|
|
|
this.$refs["houseLinkTable"]?.toggleRowSelection(
|
|
|
|
|
this.$refs["houseLinkTable"].getListData().find(i => i.id === row.id)
|
|
|
|
|
,false)
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
this.$refs["landLinkTable"]?.toggleRowSelection(row,false)
|
|
|
|
|
++this.landSelectTemp;
|
|
|
|
|
this.$refs["landLinkTable"]?.toggleRowSelection(
|
|
|
|
|
this.$refs["landLinkTable"].getListData().find(i => i.id === row.id)
|
|
|
|
|
,false)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (row._relation_id) {
|
|
|
|
|
destroy({ table_name: "lets_to_assets", id: row._relation_id },false).then(_ => {
|
|
|
|
|
let index = this.originalForm.id_lets_to_assets_let_id_relation?.findIndex(item => item.id === row._relation_id);
|
|
|
|
|
this.originalForm.id_lets_to_assets_let_id_relation?.splice(index, 1);
|
|
|
|
|
++this.landSelectTemp;
|
|
|
|
|
++this.houseSelectTemp;
|
|
|
|
|
this.nowAssets.splice(this.nowAssets.findIndex(j => j._relation_id === row._relation_id),1)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
@ -375,13 +341,33 @@ export default {
|
|
|
|
|
on={{
|
|
|
|
|
['loaded']: _ => {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs['landLinkTable'].getListData()?.filter(item => this.originalForm.id_lets_to_assets_let_id_relation?.find(j => j.land_id === item.id))?.forEach(item => {
|
|
|
|
|
this.$refs['landLinkTable'].getListData()?.filter(item => this.nowAssets?.find(j => j.id === item.id && !j.hasOwnProperty('land_id')))?.forEach(item => {
|
|
|
|
|
this.$refs['landLinkTable'].toggleRowSelection(item, true)
|
|
|
|
|
})
|
|
|
|
|
++this.landSelectTemp;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
['select']: _ => ++this.landSelectTemp
|
|
|
|
|
['select']: (selection, row) => {
|
|
|
|
|
if (selection.find(i => i.id === row.id)) {
|
|
|
|
|
this.nowAssets.push({
|
|
|
|
|
id: row.id,
|
|
|
|
|
name: row.name,
|
|
|
|
|
zuoluo: row.zuoluo,
|
|
|
|
|
zichanweizhi: row.zichanweizhi,
|
|
|
|
|
dengjimianji: row.dengjimianji,
|
|
|
|
|
_chuzumianji: 0,
|
|
|
|
|
_relation_id: "",
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
let index = this.nowAssets.findIndex(i => i.id === row.id && !i.hasOwnProperty('land_id') )
|
|
|
|
|
let temp = this.nowAssets.splice(index, 1)
|
|
|
|
|
if (temp._relation_id) {
|
|
|
|
|
destroy({
|
|
|
|
|
table_name: "lets_to_assets",
|
|
|
|
|
id: temp._relation_id
|
|
|
|
|
},false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
></xy-table>
|
|
|
|
|
</div>
|
|
|
|
|
@ -532,13 +518,34 @@ export default {
|
|
|
|
|
on={{
|
|
|
|
|
['loaded']: _ => {
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs['houseLinkTable'].getListData()?.filter(item => this.originalForm.id_lets_to_assets_let_id_relation?.find(j => j.house_id === item.id))?.forEach(item => {
|
|
|
|
|
this.$refs['houseLinkTable'].getListData()?.filter(item => this.nowAssets?.find(j => j.id === item.id && j.hasOwnProperty('land_id')))?.forEach(item => {
|
|
|
|
|
this.$refs['houseLinkTable'].toggleRowSelection(item, true)
|
|
|
|
|
})
|
|
|
|
|
++this.houseSelectTemp;
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
['select']: _ => ++this.houseSelectTemp
|
|
|
|
|
['select']: (selection, row) => {
|
|
|
|
|
if (selection.find(i => i.id === row.id)) {
|
|
|
|
|
this.nowAssets.push({
|
|
|
|
|
id: row.id,
|
|
|
|
|
name: row.name,
|
|
|
|
|
zuoluo: row.zuoluo,
|
|
|
|
|
zichanweizhi: row.zichanweizhi,
|
|
|
|
|
dengjimianji: row.dengjimianji,
|
|
|
|
|
_chuzumianji: 0,
|
|
|
|
|
_relation_id: "",
|
|
|
|
|
land_id: row.land_id
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
let index = this.nowAssets.findIndex(i => i.id === row.id && i.hasOwnProperty('land_id') )
|
|
|
|
|
let temp = this.nowAssets.splice(index, 1)
|
|
|
|
|
if (temp._relation_id) {
|
|
|
|
|
destroy({
|
|
|
|
|
table_name: "lets_to_assets",
|
|
|
|
|
id: temp._relation_id
|
|
|
|
|
},false)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
></xy-table>
|
|
|
|
|
</div>
|
|
|
|
|
@ -549,10 +556,9 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
nowAssets: [],
|
|
|
|
|
houseDialog: false,
|
|
|
|
|
houseSelectTemp: 0,
|
|
|
|
|
landDialog: false,
|
|
|
|
|
landSelectTemp: 0,
|
|
|
|
|
leasePlans: [],
|
|
|
|
|
landSelect: {
|
|
|
|
|
table_name: "lands",
|
|
|
|
|
@ -575,21 +581,6 @@ export default {
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
distinct (arr, key="id") {
|
|
|
|
|
let newobj = {};
|
|
|
|
|
arr = arr.reduce((preVal, curVal) => {
|
|
|
|
|
if (!newobj[curVal[key]]) {
|
|
|
|
|
newobj[curVal[key]] = preVal.push(curVal)
|
|
|
|
|
} else {
|
|
|
|
|
let findVal = preVal.find(item => item[key] === curVal[key]);
|
|
|
|
|
findVal._chuzumianji = newobj[curVal[key]]["_chuzumianji"] || curVal["_chuzumianji"];
|
|
|
|
|
findVal._chuzumianji = newobj[curVal[key]]["_relation_id"] || curVal["_relation_id"];
|
|
|
|
|
findVal._TAG_ = newobj[curVal[key]]["_TAG_"] || curVal["_TAG_"];
|
|
|
|
|
}
|
|
|
|
|
return preVal
|
|
|
|
|
}, []);
|
|
|
|
|
return arr;
|
|
|
|
|
},
|
|
|
|
|
index,
|
|
|
|
|
setRow (row) {
|
|
|
|
|
this.row = row
|
|
|
|
|
@ -634,6 +625,36 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
this.form = Object.assign({}, this.form);
|
|
|
|
|
this.originalForm = deepCopy(res);
|
|
|
|
|
this.originalForm?.lets_to_assets?.forEach(item => {
|
|
|
|
|
if (item.land_id) {
|
|
|
|
|
let land = item.lands;
|
|
|
|
|
if (land) {
|
|
|
|
|
this.nowAssets.push({
|
|
|
|
|
id: land.id,
|
|
|
|
|
name: land.name,
|
|
|
|
|
zuoluo: land.zuoluo,
|
|
|
|
|
zichanweizhi: land.zichanweizhi,
|
|
|
|
|
dengjimianji: land.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji||0,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let house = item.house;
|
|
|
|
|
if (house) {
|
|
|
|
|
this.nowAssets.push({
|
|
|
|
|
id: house.id,
|
|
|
|
|
name: house.name,
|
|
|
|
|
zuoluo: house.zuoluo,
|
|
|
|
|
zichanweizhi: house.zichanweizhi,
|
|
|
|
|
dengjimianji: house.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji||0,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
land_id: house.land_id,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
submit() {
|
|
|
|
|
@ -651,7 +672,6 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.form.let_id = this.$route.params.letId;
|
|
|
|
|
// this.form.id_leases_to_assets_lease_id_relation = [];
|
|
|
|
|
// this.selectedHouses?.forEach(i => {
|
|
|
|
|
// this.form.id_leases_to_assets_lease_id_relation.push({
|
|
|
|
|
@ -669,48 +689,14 @@ export default {
|
|
|
|
|
// })
|
|
|
|
|
// this.form.id_lease_plans_lease_id_relation = this.leasePlans;
|
|
|
|
|
save(Object.assign(this.form, { table_name: 'lets' })).then(res => {
|
|
|
|
|
let leaseToAssetsData = this.distinct([
|
|
|
|
|
...this.selectedLands.map(i => ({...i,_TAG_: "land"})),
|
|
|
|
|
...this.selectedHouses.map(i => ({...i,_TAG_: "house"})),
|
|
|
|
|
...(() => {
|
|
|
|
|
let temp = [];
|
|
|
|
|
this.originalForm?.id_lets_to_assets_let_id_relation?.forEach(item => {
|
|
|
|
|
if (item.land_id) {
|
|
|
|
|
let land = this.originalForm.land?.find(land => land.id === item.land_id);
|
|
|
|
|
if (land) {
|
|
|
|
|
temp.push({
|
|
|
|
|
id: land.id,
|
|
|
|
|
name: land.name,
|
|
|
|
|
zuoluo: land.zuoluo,
|
|
|
|
|
zichanweizhi: land.zichanweizhi,
|
|
|
|
|
dengjimianji: land.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
_TAG_: "land"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
let house = this.originalForm.house?.find(house => house.id === item.house_id);
|
|
|
|
|
if (house) {
|
|
|
|
|
temp.push({
|
|
|
|
|
id: house.id,
|
|
|
|
|
name: house.name,
|
|
|
|
|
zuoluo: house.zuoluo,
|
|
|
|
|
zichanweizhi: house.zichanweizhi,
|
|
|
|
|
dengjimianji: house.dengjimianji,
|
|
|
|
|
_chuzumianji: item.chuzumianji,
|
|
|
|
|
_relation_id: item.id,
|
|
|
|
|
_TAG_: "house"
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
return temp;
|
|
|
|
|
})()
|
|
|
|
|
]).map(item => ({
|
|
|
|
|
Promise.all(this.originalForm.id_lets_to_assets_let_id_relation.map(i => destroy({
|
|
|
|
|
id: i.id,
|
|
|
|
|
table_name: "lets_to_assets"
|
|
|
|
|
},false)))
|
|
|
|
|
let leaseToAssetsData = this.nowAssets.map(item => ({
|
|
|
|
|
id: item._relation_id,
|
|
|
|
|
land_id: item._TAG_ === "land" ? item.id : "",
|
|
|
|
|
house_id: item._TAG_ === "house"? item.id : "",
|
|
|
|
|
land_id: !item.hasOwnProperty("land_id") ? item.id : "",
|
|
|
|
|
house_id: item.hasOwnProperty("land_id") ? item.id : "",
|
|
|
|
|
chuzumianji: item._chuzumianji,
|
|
|
|
|
let_id: res.id
|
|
|
|
|
}));
|
|
|
|
|
@ -729,14 +715,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
selectedLands () {
|
|
|
|
|
let temp = this.landSelectTemp;
|
|
|
|
|
return this.$refs['landLinkTable']?.getSelection() || [];
|
|
|
|
|
},
|
|
|
|
|
selectedHouses () {
|
|
|
|
|
let temp = this.houseSelectTemp;
|
|
|
|
|
return this.$refs['houseLinkTable']?.getSelection() || [];
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
formInfo: {
|
|
|
|
|
|