From 8b740834e85ad265a25998bcdd8ad1291a0dd67e Mon Sep 17 00:00:00 2001 From: mk <2403457699@qq.com> Date: Mon, 14 Aug 2023 13:36:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B1=85=E6=B0=91=E4=BF=A1=E6=81=AF=E5=88=86?= =?UTF-8?q?=E9=A1=B5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/modules/base/resi.vue | 119 ++++++++++---------------------- 1 file changed, 38 insertions(+), 81 deletions(-) diff --git a/src/views/modules/base/resi.vue b/src/views/modules/base/resi.vue index 9a3266dc5..c1aa72d11 100644 --- a/src/views/modules/base/resi.vue +++ b/src/views/modules/base/resi.vue @@ -12,7 +12,7 @@ 查询 + @click="handleSearchFrom('search')">查询 @@ -596,6 +597,8 @@ export default { }, queryConditions: [], + + searchForm:{} }; }, @@ -643,7 +646,7 @@ export default { categoryKey: "resi_info", }, }); - this.getQueryConditions(); + // this.getQueryConditions(); }, methods: { @@ -683,83 +686,35 @@ export default { }, }); }, - handleSearchFrom () { - let obj = this.$refs.myResiSearch.form; - let categoryArr = this.$refs.myResiSearch.form.categoryKey; - let agencyId = this.$refs.myResiSearch.form.agencyId; - if ( - typeof obj.categoryKey == "object" && - obj.categoryKey.length != 0 - ) { - obj.categoryKey = obj.categoryKey.join(","); - } else { - obj.categoryKey = ""; - } - if (typeof obj.agencyId == "object" && obj.agencyId.length != 0) { - // obj.agencyId = obj.agencyId.join(","); - obj.agencyId = obj.agencyId[obj.agencyId.length - 1] - } else { - obj.agencyId = ""; - } - obj.level = this.$refs.myResiSearch.level ? this.$refs.myResiSearch.level : '' - this.currentPage = 1; - this.getTableData(obj); - - let conditions = this.queryConditions - .filter((item) => obj[item.humpName]) - .map((item) => { - let queryType = "equal"; - const { humpName } = item; - if ( - humpName == "name" || - humpName == "mobile" || - humpName == "idNum" - ) { - queryType = "like"; - } - return { - ...item, - queryType, - columnValue: [obj[item.humpName]], - }; - }); - if (obj.birthdayStart || obj.birthdayEnd) { - conditions.push({ - queryType: "daterange", - columnValue: [ - obj.birthdayStart || "", - obj.birthdayEnd || "", - ], - columnName: "BIRTHDAY", - label: "出生日期", - tableName: "resident_base_info", - }); - } - if (obj.ageStart || obj.ageEnd) { - let ageStart = obj.ageStart || 0; - let ageEnd = obj.ageEnd || 200; - let currentYear = new Date().getFullYear(); - let dateStart = dateFormat( - new Date(new Date().setFullYear(currentYear - ageStart)), - "yyyy-MM-dd" - ); - let dateEnd = dateFormat( - new Date(new Date().setFullYear(currentYear - ageEnd)), - "yyyy-MM-dd" - ); - conditions.push({ - queryType: "daterange", - columnValue: [dateEnd, dateStart], - columnName: "BIRTHDAY", - label: "出生日期", - tableName: "resident_base_info", - }); - } - this.conditions = conditions; - console.log(obj, this.conditions); + handleSearchFrom (type) { + // 使用解构赋值获取需要的属性 + const { categoryKey, agencyId, level } = this.$refs.myResiSearch.form; + // 深复制对象 + let _obj = JSON.parse(JSON.stringify(this.$refs.myResiSearch.form)); + + // 处理 categoryKey + if (Array.isArray(categoryKey) && categoryKey.length) { + _obj.categoryKey = categoryKey.join(","); + } else { + _obj.categoryKey = ""; + } + + // 处理 agencyId + if (Array.isArray(agencyId) && agencyId.length) { + _obj.agencyId = agencyId[agencyId.length - 1]; + } else { + _obj.agencyId = ""; + } - this.$refs.myResiSearch.form.categoryKey = categoryArr; - this.$refs.myResiSearch.form.agencyId = agencyId; + _obj.level = level || ''; // 使用逻辑或操作符简化代码 + if(type){ + this.currentPage = 1 + } + this.getTableData(_obj); + this.searchForm = _obj; + // 还原form的值 + this.$refs.myResiSearch.form.categoryKey = categoryKey; + this.$refs.myResiSearch.form.agencyId = agencyId; }, // 是否可以选中 checkSelectable (row, index) { @@ -809,6 +764,7 @@ export default { }, async diyExport () { await this.getExportList(); + console.log(this.$refs['']); }, computedWidth (label, type) { let wd = ""; @@ -908,8 +864,8 @@ export default { resetSearchForm () { for (const n in this.$refs.myResiSearch.form) { this.$refs.myResiSearch.form[n] = ""; - } + this.currentPage = 1 this.$refs.myResiSearch.level = '' this.getTableData(); }, @@ -1447,12 +1403,13 @@ export default { }, async getTableData (obj) { + console.log(this.currentPage); let params = { pageNo: this.currentPage, pageSize: this.pageSize, ...obj, }; - + this.tableLoading = true; const { data } = await this.$http.post( "/actual/base/residentBaseInfo/page",