From a339dd3e4ca4a3746ef7eef9a475ecd7288697ca Mon Sep 17 00:00:00 2001 From: xy <271556543@qq.com> Date: Wed, 24 Jul 2024 17:52:31 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/createDialog.js | 19 +- src/views/assets/handle.vue | 3 + src/views/assets/handleSign.vue | 1144 +++++++++++++++++++++++++ src/views/lease/component/addLet.vue | 14 +- src/views/lease/component/payList.vue | 177 ++++ src/views/lease/detailLease.vue | 537 ++++++++++++ src/views/lease/detailLet.vue | 8 +- src/views/lease/index.vue | 8 +- src/views/lease/sign.vue | 912 +++++++++++++++----- 9 files changed, 2588 insertions(+), 234 deletions(-) create mode 100644 src/views/assets/handleSign.vue create mode 100644 src/views/lease/component/payList.vue create mode 100644 src/views/lease/detailLease.vue diff --git a/src/utils/createDialog.js b/src/utils/createDialog.js index 4c86d1d..a3d5097 100644 --- a/src/utils/createDialog.js +++ b/src/utils/createDialog.js @@ -144,11 +144,12 @@ export class CreateDialog { "padding-right": "12px", }, props: { - model: that.form, - labelWidth: "100px", + model: this.options.disabled ? that.originalForm : that.form, + labelWidth: this.options.labelWidth || "100px", rules: that.rules, - labelPosition: "top", - size: "small", + labelPosition: this.options.labelPosition || "top", + size: this.options.size || "small", + disabled: this.options.disabled }, }, (() => { @@ -189,7 +190,7 @@ export class CreateDialog { ...addPropsMap.get(i.edit_input), ...this.extraProps(i), placeholder: i.help, - value: that.form[i.field], + value: this.options.disabled ? that.originalForm[i.field] : that.form[i.field], readonly: that.type === "show", //disabled: that.type === 'show', }, @@ -256,6 +257,9 @@ export class CreateDialog { ]), h("i", { class: "el-icon-close", + style: { + "display": this.options.disabled ? "none" : "inline" + }, on: { ["click"]: () => this.fileRemoveHandler( @@ -346,6 +350,7 @@ export class CreateDialog { { props: { size: "mini", + disabled: this.options.disabled }, on: { click: () => (that.dialogVisible = false), @@ -360,6 +365,7 @@ export class CreateDialog { type: "warning", plain: true, size: "mini", + disabled: this.options.disabled }, on: { click: () => that.init(), @@ -373,6 +379,7 @@ export class CreateDialog { props: { type: "primary", size: "mini", + disabled: this.options.disabled }, on: { click: that.submit, @@ -391,6 +398,7 @@ export class CreateDialog { props: { type: "warning", plain: true, + disabled: this.options.disabled }, on: { click: () => that.init(), @@ -403,6 +411,7 @@ export class CreateDialog { { props: { type: "primary", + disabled: this.options.disabled }, on: { click: that.submit, diff --git a/src/views/assets/handle.vue b/src/views/assets/handle.vue index 2a9a908..3e0f4f9 100644 --- a/src/views/assets/handle.vue +++ b/src/views/assets/handle.vue @@ -261,6 +261,9 @@ " @loaded="adjustAlignment" > + +import { save, show, index, destroy, imports } from "@/api/system/baseForm"; +import { CreateDialog } from "@/utils/createDialog"; +import { deepCopy } from "@/utils"; +import { resolveFormInfo } from "@/utils/createTable"; +export default { + components: {}, + props: { + tableName: String, + }, + render(h) { + const _this = this; + let dialog = new CreateDialog( + this, + [ + { + show: true, + key: "qiandingnianyue", + label: "签订年月", + render: h("el-date-picker", { + style: { width: "100%" }, + props: { + type: "month", + placeholder: "请选择签订年月", + value: _this.form.qiandingnianyue, + format: "yyyy-MM", + valueFormat: "yyyy-MM", + }, + on: { + ["input"]: (e) => { + _this.form.qiandingnianyue = e; + _this.form = Object.assign({}, _this.form); + }, + }, + }), + }, + ], + {}, + false + ); + + return ( +
+ +
+ { + this.$router.go(-1); + }, + }} + > +

+ {(() => { + let title = new Map([ + ["add", "签订合同"], + ["editor", "修改合同"], + ["change", "合同变更"], + ]); + return title.get(this.type); + })()} +

+
+ + {/* 资产信息 */} +
+
+

资产信息

+ +
+ + +
+
+ + { + row._relation_id + ? row._relation_id + : row.hasOwnProperty("land_id") + ? "house_" + row.id + : "land_" + row.id; + }} + list={this.nowAssets} + height="300" + isHandlerKey={false} + is-page={false} + table-item={[ + { + prop: "name", + label: "地块名称", + width: 0, + fixed: "left", + align: "left", + }, + { + prop: "zuoluo", + label: "坐落", + width: 0, + align: "left", + }, + { + prop: "shijimianji", + label: "实际面积(m²)", + width: 0, + align: "center", + }, + { + prop: "_chuzumianji", + label: "出租面积(m²)", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "operate", + label: "操作", + width: 160, + customFn: (row) => { + return ( +
+ +
+ ); + }, + }, + ]} + >
+
+ + {/* 租金收取计划 */} +
+
+

租金收取计划

+ + +
+ +
+ { + this.leasePlans.map((leasePlan, index) => ( + +
+

租金收取计划{index+1}

+ + +
+ +
+ + + + + +
+
+ )) + } +
+ { /* { + return ( + + ); + }, + }, + { + prop: "yingshou", + label: "应收", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "shijidaozhang", + label: "实际到账", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "weidaoweiyuanyin", + label: "未到位原因", + width: 180, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "shijidaozhangriqi", + label: "实际到账日期", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "operate", + label: "操作", + minWidth: 120, + customFn: (row, { $index }) => { + return ( +
+ +
+ ); + }, + }, + ]} + >
*/ } +
+ + {dialog.render()} +
+ + (this.landDialog = val), + }} + > +
+
+ + +
+ { + this.$nextTick(() => { + 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) + }) + }) + }, + ["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, + shijimianji: row.shijimianji, + _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: "leases_to_assets", + id: temp._relation_id + },false) + } + } + }, + }} + > +
+
+ + (this.houseDialog = val), + }} + > +
+
+ + +
+ { + this.$nextTick(() => { + 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) + }) + }) + }, + ["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, + shijimianji: row.shijimianji, + _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: "leases_to_assets", + id: temp._relation_id + },false) + } + } + }, + }} + > +
+
+
+ ); + }, + data() { + return { + nowAssets: [], + houseDialog: false, + landDialog: false, + leasePlans: [], + landSelect: { + table_name: "lands", + keyword: "", + }, + houseSelect: { + table_name: "houses", + keyword: "", + }, + + columns: 1, + row: {}, + formInfo: [], + id: "", + type: "add", + form: {}, + originalForm: {}, + rules: {}, + file: {}, + }; + }, + methods: { + index, + setRow(row) { + this.row = row; + }, + init() { + for (let key in this.form) { + if (this.form[key] instanceof Array) { + this.form[key] = []; + } else { + this.form[key] = ""; + } + } + this.$refs["elForm"].clearValidate(); + }, + setType(type = "add") { + let types = ["add", "editor", "change"]; + if (types.includes(type)) { + this.type = type; + } else { + console.warn("Unknown type: " + type); + } + }, + setId(id) { + if (typeof id == "number") { + this.id = id; + } else { + console.error("error typeof id: " + typeof id); + } + }, + + async getDetail() { + const res = await show({ id: this.id, table_name: "leases" }); + this.$integrateData(this.form, res); + + this.formInfo.forEach((i) => { + if (i.edit_input === "file") { + } + if (i.edit_input === "files") { + this.file[i.field] = res[`${i.field}_upload_details`]; + } + }); + this.form = Object.assign({}, this.form); + this.leasePlans = res.id_lease_plans_lease_id_relation; + this.originalForm = deepCopy(res); + if (this.type !== 'add') { + this.originalForm?.id_leases_to_assets_lease_id_relation?.forEach( + (item) => { + if (item.land_id) { + let land = this.originalForm.land?.find( + (land) => land.id === item.land_id + ); + if (land) { + this.nowAssets.push({ + id: land.id, + name: land.name, + zuoluo: land.zuoluo, + zichanweizhi: land.zichanweizhi, + shijimianji: land.shijimianji, + _chuzumianji: item.chuzumianji, + _relation_id: item.id, + }); + } + } else { + let house = this.originalForm.houses?.find( + (house) => house.id === item.house_id + ); + if (house) { + this.nowAssets.push({ + id: house.id, + name: house.name, + zuoluo: house.zuoluo, + zichanweizhi: house.zichanweizhi, + shijimianji: house.shijimianji, + _chuzumianji: item.chuzumianji, + _relation_id: item.id, + _TAG_: "house", + land_id: house.land_id + }); + } + } + } + ) + } + }, + + submit() { + if (this.type === "add") { + if (this.form.hasOwnProperty("id")) { + delete this.form.id; + } + } + if (this.type === "editor") { + Object.defineProperty(this.form, "id", { + value: this.id, + enumerable: true, + configurable: true, + writable: true, + }); + } + + this.form.let_id = this.$route.params.letId; + save(Object.assign(this.form, { table_name: "leases" })).then((res) => { + if (this.type !== 'add') { + Promise.all([ + ...this.originalForm.id_leases_to_assets_lease_id_relation?.map(i => destroy({ + id: i.id, + table_name: "leases_to_assets" + },false)), + ...this.originalForm.id_lease_plans_lease_id_relation?.map(i => destroy({ + id: i.id, + table_name: "lease_plans" + },false)) + ]) + } + let leaseToAssetsData = this.nowAssets.map(item => ({ + id: item._relation_id, + land_id: !item.hasOwnProperty("land_id") ? item.id : "", + house_id: item.hasOwnProperty("land_id") ? item.id : "", + chuzumianji: item._chuzumianji, + lease_id: res.id + })); + if (leaseToAssetsData && leaseToAssetsData.length > 0) { + imports( + { + table_name: "leases_to_assets", + data: leaseToAssetsData, + }, + false + ); + } + let leasePlansData = this.leasePlans.map((item) => ({ + ...item, + lease_id: res.id, + })); + if (leasePlansData && leasePlansData.length > 0) { + imports({ + table_name: "lease_plans", + data: leasePlansData, + }); + } + //变更保存日志 + if (this.type === "change") { + let content = ""; + for (let key in this.originalForm) { + if (this.form[key] && this.originalForm[key] !== this.form[key]) { + content += `${key}由${this.originalForm[key]}变更为${this.form[key]}\n`; + } + } + save( + { + table_name: "lease_logs", + content, + lease_id: this.id, + }, + false + ); + } + this.$Message.success({ + content: `${this.type === "add" ? "新增" : "编辑"}成功`, + }); + this.$emit("refresh"); + this.$router.push("/lease"); + }); + }, + }, + computed: { + + }, + watch: { + formInfo: { + handler: function (newVal) { + this.form = {}; + this.rules = {}; + this.file = {}; + newVal.forEach((i) => { + if (i.field) { + this.form[i.field] = ""; + if ( + i.validation instanceof Array && + i.validation.length > 0 && + !!i.validation.find((i) => i === "required") + ) { + this.rules[i.field] = [ + { required: true, message: `请填写${i.name}` }, + ]; + } + if (i.edit_input === "files") { + this.form[i.field] = []; + } + if (i.edit_input === "files" || i.edit_input === "file") { + this.file[i.field] = []; + } + if (i.edit_input === "checkbox") { + this.form[i.field] = []; + } + if (i._relations) { + this.form[i._relations?.link_with_name] = []; + } + } + }); + }, + //immediate: true, + }, + dialogVisible(val) { + if (val) { + if (this.type === "editor" || this.type === "change") { + this.$nextTick(() => this.getDetail()); + } + } else { + this.id = ""; + this.type = ""; + this.init(); + this.$refs["elForm"].clearValidate(); + delete this.form.id; + for (let key in this.file) { + this.file[key] = []; + } + this.$refs["landLinkTable"].clearSelection(); + this.$refs["houseLinkTable"].clearSelection(); + } + }, + }, + created() { + this.id = this.$route.query.leaseId; + this.type = this.$route.query.type; + resolveFormInfo(15).then((res) => { + this.formInfo = res; + + if (this.type === "editor" || this.type === "change") { + this.$nextTick(() => this.getDetail()); + } else { + show({ id: this.$route.params.letId, table_name: "lets" }).then(letDetail => { + letDetail?.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, + shijimianji: land.shijimianji, + _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, + shijimianji: house.shijimianji, + _chuzumianji: item.chuzumianji||0, + _relation_id: item.id, + land_id: house.land_id, + }); + } + } + }) + }) + } + }); + }, + mounted() {}, + beforeDestroy() { + this.id = ""; + this.type = ""; + this.init(); + this.$refs["elForm"].clearValidate(); + delete this.form.id; + for (let key in this.file) { + this.file[key] = []; + } + }, +}; + + + + diff --git a/src/views/lease/component/addLet.vue b/src/views/lease/component/addLet.vue index 18e5af1..49ae5a7 100644 --- a/src/views/lease/component/addLet.vue +++ b/src/views/lease/component/addLet.vue @@ -84,10 +84,10 @@ export default { "align": "left" }, { - "prop": "dengjimianji", - "label": "登记面积(m²)", + "prop": "shijimianji", + "label": "实际面积(m²)", "width": 0, - "align": "center" + "align": "right" }, { "prop": "_chuzumianji", @@ -350,7 +350,7 @@ export default { name: row.name, zuoluo: row.zuoluo, zichanweizhi: row.zichanweizhi, - dengjimianji: row.dengjimianji, + shijimianji: row.shijimianji, _chuzumianji: 0, _relation_id: "", }) @@ -530,7 +530,7 @@ export default { name: row.name, zuoluo: row.zuoluo, zichanweizhi: row.zichanweizhi, - dengjimianji: row.dengjimianji, + shijimianji: row.shijimianji, _chuzumianji: 0, _relation_id: "", land_id: row.land_id @@ -643,7 +643,7 @@ export default { name: land.name, zuoluo: land.zuoluo, zichanweizhi: land.zichanweizhi, - dengjimianji: land.dengjimianji, + shijimianji: land.shijimianji, _chuzumianji: item.chuzumianji||0, _relation_id: item.id, }); @@ -656,7 +656,7 @@ export default { name: house.name, zuoluo: house.zuoluo, zichanweizhi: house.zichanweizhi, - dengjimianji: house.dengjimianji, + shijimianji: house.shijimianji, _chuzumianji: item.chuzumianji||0, _relation_id: item.id, land_id: house.land_id, diff --git a/src/views/lease/component/payList.vue b/src/views/lease/component/payList.vue new file mode 100644 index 0000000..5f6f344 --- /dev/null +++ b/src/views/lease/component/payList.vue @@ -0,0 +1,177 @@ + + + + + diff --git a/src/views/lease/detailLease.vue b/src/views/lease/detailLease.vue new file mode 100644 index 0000000..e87b3c8 --- /dev/null +++ b/src/views/lease/detailLease.vue @@ -0,0 +1,537 @@ + + + + + diff --git a/src/views/lease/detailLet.vue b/src/views/lease/detailLet.vue index 8ad90f8..d72f862 100644 --- a/src/views/lease/detailLet.vue +++ b/src/views/lease/detailLet.vue @@ -138,16 +138,16 @@ export default { "width": 0, "align": "left", customFn: row => { - return ({ row.land_id ? row.lands.name : row.house.name }) + return ({ row.land_id ? row.lands.zuoluo : row.house.zuoluo }) } }, { - "prop": "dengjimianji", - "label": "登记面积(m²)", + "prop": "shijimianji", + "label": "实际面积(m²)", "width": 0, "align": "center", customFn: row => { - return ({ row.land_id ? row.lands.dengjimianji : row.house.dengjimianji }) + return ({ row.land_id ? row.lands.shijimianji : row.house.shijimianji }) } }, { diff --git a/src/views/lease/index.vue b/src/views/lease/index.vue index fffe0ce..c9a6564 100644 --- a/src/views/lease/index.vue +++ b/src/views/lease/index.vue @@ -247,6 +247,7 @@ :req-opt="select" :destroy-req-opt="select" :table-item="table" + :btn-to-more="true" @detail=" (row) => { $router.push({ @@ -263,7 +264,7 @@ > @@ -302,13 +304,15 @@ import add from "./component/addLease.vue"; import LxHeader from "@/components/LxHeader/index.vue"; import headerContent from "@/components/LxHeader/XyContent.vue"; import addPay from "@/views/lease/component/addPay.vue"; +import payList from "@/views/lease/component/payList.vue" export default { name: 'tableList', components: { LxHeader, add, headerContent, - addPay + addPay, + payList }, mixins: [authMixin], provide: { diff --git a/src/views/lease/sign.vue b/src/views/lease/sign.vue index e0f9462..9b86d67 100644 --- a/src/views/lease/sign.vue +++ b/src/views/lease/sign.vue @@ -38,115 +38,280 @@ export default { {}, false ); + let oldDialog = new CreateDialog( + this, + [ + { + show: true, + key: "qiandingnianyue", + label: "签订年月", + render: h("el-date-picker", { + style: { width: "100%" }, + props: { + type: "month", + placeholder: "请选择签订年月", + value: _this.originalForm.qiandingnianyue, + format: "yyyy-MM", + valueFormat: "yyyy-MM", + } + }), + }, + ], + { + disabled: true + }, + false + ); return (
- -
- { - this.$router.go(-1); - }, - }} - > -

- {(() => { - let title = new Map([ - ["add", "签订合同"], - ["editor", "修改合同"], - ["change", "合同变更"], - ]); - return title.get(this.type); - })()} -

-
+
(this.isShowOldData = true), + }} + > + + 展开原数据 +
+ + {this.type === "change" ? ( + + + +
+ { + this.$router.go(-1); + }, + }} + > +

合同变更-原数据

- {/* 资产信息 */} -
-
-

资产信息

+ (this.isShowOldData = false) }} + > + 收起 + +
-
- - -
-
+ {/* 资产信息 */} +
+
+

资产信息

+
- { - row._relation_id - ? row._relation_id - : row.hasOwnProperty("land_id") - ? "house_" + row.id - : "land_" + row.id; - }} - list={this.nowAssets} + { + row._relation_id + ? row._relation_id + : row.hasOwnProperty("land_id") + ? "house_" + row.id + : "land_" + row.id; + }} + list={this.oldNowAssets} + height="300" + isHandlerKey={false} + is-page={false} + table-item={[ + { + prop: "name", + label: "地块名称", + width: 0, + fixed: "left", + align: "left", + }, + { + prop: "zuoluo", + label: "坐落", + width: 0, + align: "left", + }, + { + prop: "shijimianji", + label: "实际面积(m²)", + width: 0, + align: "center", + }, + { + prop: "_chuzumianji", + label: "出租面积(m²)", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + ]} + > +
+ + {/* 租金收取计划 */} +
+
+

+ 租金收取计划 +

+
+ +
+ {this.oldLeasePlans.map((leasePlan, index) => ( + +
+

+ 租金收取计划{index + 1} +

+
+ +
+ + + + + + + + +
+
+ ))} +
+ {/* { + return ( + + ); + }, }, { - prop: "dengjimianji", - label: "登记面积(m²)", - width: 0, - align: "center", + prop: "yingshou", + label: "应收", + width: 160, + customFn: (row) => { + return ( + + ); + }, }, { - prop: "_chuzumianji", - label: "出租面积(m²)", + prop: "shijidaozhang", + label: "实际到账", width: 160, customFn: (row) => { return ( ); }, }, { - prop: "operate", - label: "操作", + prop: "weidaoweiyuanyin", + label: "未到位原因", + width: 180, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "shijidaozhangriqi", + label: "实际到账日期", width: 160, customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "operate", + label: "操作", + minWidth: 120, + customFn: (row, { $index }) => { return (
+ >
*/} +
- {/* 租金收取计划 */} -
-
-

租金收取计划

+ {oldDialog.render()} + + + + ) : ( + "" + )} + + +
+ { + this.$router.go(-1); + }, + }} + > +

+ {(() => { + let title = new Map([ + ["add", "签订合同"], + ["editor", "修改合同"], + ["change", "合同变更-变更数据"], + ]); + return title.get(this.type); + })()} +

+
- -
+ {/* 资产信息 */} +
+
+

资产信息

- + + +
+
+ + { + row._relation_id + ? row._relation_id + : row.hasOwnProperty("land_id") + ? "house_" + row.id + : "land_" + row.id; + }} + list={this.nowAssets} + height="300" + isHandlerKey={false} + is-page={false} + table-item={[ + { + prop: "name", + label: "地块名称", + width: 0, + fixed: "left", + align: "left", + }, + { + prop: "zuoluo", + label: "坐落", + width: 0, + align: "left", + }, + { + prop: "shijimianji", + label: "实际面积(m²)", + width: 0, + align: "center", + }, + { + prop: "_chuzumianji", + label: "出租面积(m²)", + width: 160, + customFn: (row) => { + return ( + + ); + }, + }, + { + prop: "operate", + label: "操作", + width: 160, + customFn: (row) => { + return ( +
+ +
+ ); + }, + }, + ]} + >
+
+ + {/* 租金收取计划 */} +
+
+

租金收取计划

+ + +
+ +
+ {this.leasePlans.map((leasePlan, index) => ( + +
+

租金收取计划{index + 1}

+ + +
+ +
+ + + + + + + + +
+
+ ))} +
+ {/* -
+ > */} +
- {dialog.render()} -
+ {dialog.render()} +
+ + { this.$nextTick(() => { - 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.$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 + ); + }); + }); }, ["select"]: (selection, row) => { - if (selection.find(i => i.id === row.id)) { + 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, + shijimianji: row.shijimianji, _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) + 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: "leases_to_assets", - id: temp._relation_id - },false) + destroy( + { + table_name: "leases_to_assets", + id: temp._relation_id, + }, + false + ); } } }, @@ -684,7 +1100,7 @@ export default { prop: "dengjimianji", label: "登记面积(m²)", width: 0, - align: "center", + align: "right", }, { prop: "shijimianji", @@ -728,31 +1144,46 @@ export default { on={{ ["loaded"]: (_) => { this.$nextTick(() => { - 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.$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 + ); + }); + }); }, ["select"]: (selection, row) => { - if (selection.find(i => i.id === row.id)) { + 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, + shijimianji: row.shijimianji, _chuzumianji: 0, _relation_id: "", - land_id: row.land_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) + 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: "leases_to_assets", - id: temp._relation_id - },false) + destroy( + { + table_name: "leases_to_assets", + id: temp._relation_id, + }, + false + ); } } }, @@ -765,10 +1196,13 @@ export default { }, data() { return { + isShowOldData: true, nowAssets: [], + oldNowAssets: [], houseDialog: false, landDialog: false, leasePlans: [], + oldLeasePlans: [], landSelect: { table_name: "lands", keyword: "", @@ -833,8 +1267,12 @@ export default { }); this.form = Object.assign({}, this.form); this.leasePlans = res.id_lease_plans_lease_id_relation; + if (this.type === 'change') { + this.oldLeasePlans = deepCopy(this.leasePlans) + } this.originalForm = deepCopy(res); - if (this.type !== 'add') { + + if (this.type !== "add") { this.originalForm?.id_leases_to_assets_lease_id_relation?.forEach( (item) => { if (item.land_id) { @@ -847,7 +1285,7 @@ export default { name: land.name, zuoluo: land.zuoluo, zichanweizhi: land.zichanweizhi, - dengjimianji: land.dengjimianji, + shijimianji: land.shijimianji, _chuzumianji: item.chuzumianji, _relation_id: item.id, }); @@ -862,16 +1300,20 @@ export default { name: house.name, zuoluo: house.zuoluo, zichanweizhi: house.zichanweizhi, - dengjimianji: house.dengjimianji, + shijimianji: house.shijimianji, _chuzumianji: item.chuzumianji, _relation_id: item.id, _TAG_: "house", - land_id: house.land_id + land_id: house.land_id, }); } } } - ) + ); + + if (this.type === 'change') { + this.oldNowAssets = deepCopy(this.nowAssets) + } } }, @@ -881,7 +1323,7 @@ export default { delete this.form.id; } } - if (this.type === "editor") { + if (this.type === "editor" || this.type === "change") { Object.defineProperty(this.form, "id", { value: this.id, enumerable: true, @@ -892,24 +1334,35 @@ export default { this.form.let_id = this.$route.params.letId; save(Object.assign(this.form, { table_name: "leases" })).then((res) => { - if (this.type !== 'add') { + if (this.type !== "add") { Promise.all([ - ...this.originalForm.id_leases_to_assets_lease_id_relation?.map(i => destroy({ - id: i.id, - table_name: "leases_to_assets" - },false)), - ...this.originalForm.id_lease_plans_lease_id_relation?.map(i => destroy({ - id: i.id, - table_name: "lease_plans" - },false)) - ]) + ...this.originalForm.id_leases_to_assets_lease_id_relation?.map( + (i) => + destroy( + { + id: i.id, + table_name: "leases_to_assets", + }, + false + ) + ), + ...this.originalForm.id_lease_plans_lease_id_relation?.map((i) => + destroy( + { + id: i.id, + table_name: "lease_plans", + }, + false + ) + ), + ]); } - let leaseToAssetsData = this.nowAssets.map(item => ({ + let leaseToAssetsData = this.nowAssets.map((item) => ({ id: item._relation_id, land_id: !item.hasOwnProperty("land_id") ? item.id : "", house_id: item.hasOwnProperty("land_id") ? item.id : "", chuzumianji: item._chuzumianji, - lease_id: res.id + lease_id: res.id, })); if (leaseToAssetsData && leaseToAssetsData.length > 0) { imports( @@ -932,17 +1385,20 @@ export default { } //变更保存日志 if (this.type === "change") { - let content = ""; - for (let key in this.originalForm) { - if (this.form[key] && this.originalForm[key] !== this.form[key]) { - content += `${key}由${this.originalForm[key]}变更为${this.form[key]}\n`; + let logData = deepCopy(this.originalForm) + delete logData.id; + for (let key in logData) { + if (/_relation/g.test(key)) { + logData[key].forEach(item => { + delete item.id; + }) } } save( { - table_name: "lease_logs", - content, - lease_id: this.id, + ...logData, + table_name: "leases_histories", + biangengshijian: this.$moment().format("YYYY-MM-DD HH:mm:ss") }, false ); @@ -955,9 +1411,7 @@ export default { }); }, }, - computed: { - - }, + computed: {}, watch: { formInfo: { handler: function (newVal) { @@ -1021,38 +1475,40 @@ export default { if (this.type === "editor" || this.type === "change") { this.$nextTick(() => this.getDetail()); } else { - show({ id: this.$route.params.letId, table_name: "lets" }).then(letDetail => { - letDetail?.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, - }); + show({ id: this.$route.params.letId, table_name: "lets" }).then( + (letDetail) => { + letDetail?.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, + shijimianji: land.shijimianji, + _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, + shijimianji: house.shijimianji, + _chuzumianji: item.chuzumianji || 0, + _relation_id: item.id, + land_id: house.land_id, + }); + } } - } - }) - }) + }); + } + ); } }); }, @@ -1076,6 +1532,10 @@ export default { }