From 5832a7f9ca44c5d58d7de0809e93d244be115b14 Mon Sep 17 00:00:00 2001 From: jjLv <1981429112@qq.com> Date: Sat, 16 Nov 2024 14:01:15 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=86=E6=96=99=E5=87=BA=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lease/apply/component/addToolsApply.vue | 58 ++++++++---- .../lease/apply/component/queryToolsApply.vue | 89 ++++++++++++------- 2 files changed, 101 insertions(+), 46 deletions(-) diff --git a/src/views/material/lease/apply/component/addToolsApply.vue b/src/views/material/lease/apply/component/addToolsApply.vue index 10f1c882..153e49f0 100644 --- a/src/views/material/lease/apply/component/addToolsApply.vue +++ b/src/views/material/lease/apply/component/addToolsApply.vue @@ -26,7 +26,7 @@ /> --> - + - + @@ -278,14 +280,14 @@ export default { }, // 表单校验 rules: { - leaseUnitId: [ + unitId: [ { required: true, message: "请选择租赁单位", trigger: "blur", }, ], - leaseProjectId: [ + projectId: [ { required: true, message: "请选择租赁工程", @@ -339,16 +341,18 @@ export default { }, watch: {}, mounted() { + this.projectInfoList(); + this.equipmentType(); if (this.isEdit) { console.log("isEdit", this.isEdit); this.taskId = this.editTaskId; this.id = this.editId; + this.getTaskInfo(); this.equipmentType(); - } else { - this.projectInfoList(); - this.equipmentType(); } + // this.projectInfoList(); + // this.equipmentType(); }, methods: { uniteChange(val) { @@ -358,11 +362,10 @@ export default { } else if (val && val.length == 0) { this.maForm.unitId = ""; } - // this.$set(this.maForm, "leaseProjectId", null); getListProject({ unitId: this.maForm.unitId }).then((response) => { this.projectList = response.data; }); - this.unitTemp = this.unitid; + // this.unitTemp = this.unitid; }, projectChange(val) { if (val && val.length > 0) { @@ -373,8 +376,7 @@ export default { getListUnite({ projectId: this.maForm.projectId }).then((response) => { this.uniteList = response.data; }); - // this.maForm.leaseProjectId = val; - this.projectTemp = this.projectId; + // this.projectTemp = this.projectId; }, /** 租赁单位和工程-下拉选 */ projectInfoList() { @@ -389,8 +391,7 @@ export default { getListUnite({ projectId: null }).then((response) => { this.uniteList = response.data; }); - console.log("maForm", this.maForm.leaseUnitId); - getListProject({ unitId: this.maForm.leaseUnitId }).then((response) => { + getListProject({ unitId: this.maForm.unitId }).then((response) => { this.projectList = response.data; }); } @@ -490,12 +491,36 @@ export default { // this.loading = true; await getApplyInfo(this.id).then((response) => { this.maForm = response.data.leaseApplyInfo; - console.log("this.maForm", this.maForm); + this.maForm.unitId = response.data.leaseApplyInfo.leaseUnitId; + this.maForm.projectId = response.data.leaseApplyInfo.leaseProjectId; + this.unitId = this.treeParentsById(this.uniteList, this.maForm.unitId); + this.projectId = this.treeParentsById( + this.projectList, + this.maForm.projectId + ); this.equipmentList = response.data.leaseApplyDetailsList; // this.loading = false; }); await this.projectInfoList(); }, + + //单位,工程树结构数据获取父 + treeParentsById(list, id) { + for (let i in list) { + if (list[i].id == id) { + //查询到就返回该数组对象的value + return [list[i].id]; + } + if (list[i].children) { + let node = this.treeParentsById(list[i].children, id); + if (node !== undefined) { + //查询到把父节把父节点加到数组前面 + node.unshift(list[i].id); + return node; + } + } + } + }, // 多选框选中数据 handleSelectionChange(selection) { this.ids = selection.map((item) => item.roleId); @@ -505,6 +530,7 @@ export default { /** 保存按钮操作 */ handleSave() { // console.log(this.equipmentList) + console.log("maForm", this.maForm); if (this.equipmentList.length > 0) { this.$refs["maForm"].validate(async (valid) => { if (valid) { @@ -523,6 +549,8 @@ export default { .then(function () {}) .then(() => { if (this.isEdit) { + this.maForm.leaseUnitId = this.maForm.unitId; + this.maForm.leaseProjectId = this.maForm.projectId; console.log("编辑"); this.loading = true; updateApplyInfo({ diff --git a/src/views/material/lease/apply/component/queryToolsApply.vue b/src/views/material/lease/apply/component/queryToolsApply.vue index 74595b5d..35892514 100644 --- a/src/views/material/lease/apply/component/queryToolsApply.vue +++ b/src/views/material/lease/apply/component/queryToolsApply.vue @@ -8,39 +8,33 @@ :inline="true" label-width="120px" > - - + - - + > - - + - - + placeholder="请选择租赁工程" + > { this.maForm = response.data.leaseApplyInfo; + this.maForm.unitId = response.data.leaseApplyInfo.leaseUnitId; + this.maForm.projectId = response.data.leaseApplyInfo.leaseProjectId; + this.unitId = this.treeParentsById(this.uniteList, this.maForm.unitId); + this.projectId = this.treeParentsById( + this.projectList, + this.maForm.projectId + ); this.equipmentList = response.data.leaseApplyDetailsList; this.loading = false; }); }, + //单位,工程树结构数据获取父 + treeParentsById(list, id) { + for (let i in list) { + if (list[i].id == id) { + //查询到就返回该数组对象的value + return [list[i].id]; + } + if (list[i].children) { + let node = this.treeParentsById(list[i].children, id); + if (node !== undefined) { + //查询到把父节把父节点加到数组前面 + node.unshift(list[i].id); + return node; + } + } + } + }, /** 导出按钮操作 */ handleExport() { this.download(