From 0f2591c87d2ba7b8d7fa2475fcf4deb8599eeec5 Mon Sep 17 00:00:00 2001 From: lkk <364857242@qq.com> Date: 星期三, 30 七月 2025 14:49:32 +0800 Subject: [PATCH] 1 --- src/views/hosp/project/index.vue | 305 +++++++++++++++++++++++++++++++++++++++----------- 1 files changed, 234 insertions(+), 71 deletions(-) diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue index 31c8c32..ed09752 100644 --- a/src/views/hosp/project/index.vue +++ b/src/views/hosp/project/index.vue @@ -1,5 +1,5 @@ <template> - <div class="app-container"> + <div class="app-container" v-loading="pageLoading"> <el-row :gutter="20"> <el-col :span="4" :xs="24"> <div class="head-container"> @@ -12,7 +12,7 @@ style="margin-bottom: 15px" /> </div> - <div class="scrollable-container"> + <div class="scrollable-container" v-loading="loadings"> <div class="content"> <el-tree :data="deptOptions" @@ -25,7 +25,6 @@ highlight-current @node-click="handleNodeClick" :render-content="renderContent" - v-loading="loadings" /> </div> </div> @@ -87,6 +86,7 @@ icon="el-icon-plus" size="mini" @click="handleUpdate1" + :loading="updateLoading" v-hasPermi="['hosp:project:add']" >淇敼</el-button > @@ -128,6 +128,7 @@ <el-table v-if="refreshTable" v-loading="loading" + style="width: 100%" :data="projectList" ref="tableRef" height="580" @@ -308,6 +309,7 @@ width="1200px" append-to-body :before-close="handleClose" + v-loading="loading" :close-on-click-modal="false" > <el-form @@ -469,9 +471,9 @@ ></el-option> </el-select> </el-form-item> - <el-form-item label="鏍锋湰绫诲瀷" prop="specimenType"> + <el-form-item label="鏍锋湰绫诲瀷" prop="yb"> <el-select - v-model="form.specimenType" + v-model="form.yb" placeholder="璇烽�夋嫨鏍锋湰绫诲瀷" style="width: 200px" filterable @@ -630,6 +632,20 @@ > <el-option v-for="dict in dictTypesy" + :key="dict.value" + :label="dict.label" + :value="dict.value" + ></el-option> + </el-select> + </el-form-item> + <el-form-item label="鏄惁澶栭��" prop="proDelivery"> + <el-select + v-model="form.proDelivery" + placeholder="璇烽�夋嫨鏄惁澶栭��" + style="width: 200px" + > + <el-option + v-for="dict in wsTypesy" :key="dict.value" :label="dict.label" :value="dict.value" @@ -1002,10 +1018,11 @@ }; return { xiugais: true, - xiugaiList: [], + xiugaiList: null, // 鏀逛负 null锛屼究浜庡垽鏂槸鍚﹀凡鍔犺浇 deptOptions: [], dialogTableVisible: false, isPriceDisabled: false, + pageLoading: true, sfxmList: [], deptOptionstree: [], defaultPropstree: { @@ -1022,6 +1039,16 @@ label: "鍚�", }, ], + wsTypesy: [ + { + value: "1", + label: "鏄�", + }, + { + value: "0", + label: "鍚�", + }, + ], xmmc: "", chargeId: [], List: false, @@ -1030,6 +1057,8 @@ ChangeList: [], loading: true, loadings: false, + addLoading: false, + updateLoading: false, key: "", ids: [], single: true, @@ -1133,6 +1162,8 @@ this.$nextTick(() => { const lastId = newVal[newVal.length - 1] || "532"; const node = this.findNodeById(this.deptOptions, lastId); + this.queryParams.proId = lastId; + this.getList(); if (node) { this.$refs.tree1.setCurrentKey(lastId); const nodeElement = document.querySelector( @@ -1161,16 +1192,18 @@ }, }, created() { - this.getConsumables(); - this.getDeptList(); + // this.getConsumables(); + // this.getDeptList(); // this.getDeptTree().then(() => { // this.precomputePinyin(); // }); }, mounted() { - this.getDeptTree().then(() => { - this.precomputePinyin(); - }); + // this.getDeptTree().then(() => { + // this.precomputePinyin(); + // }); + // this.precomputePinyin(); + this.loadPage(); }, methods: { debounceFilter: debounce(function (val) { @@ -1193,6 +1226,58 @@ }; traverse(this.deptOptions); }, + + async loadPage() { + this.pageLoading = true; + try { + await Promise.all([ + this.getDeptTree(), // 鑾峰彇宸︿晶鏍� + //this.getList(), 鑾峰彇鍙充晶琛ㄦ牸 + ]); + } catch (error) { + console.error("鍔犺浇椤甸潰鍑洪敊", error); + } finally { + this.pageLoading = false; // 涓や釜閮藉姞杞藉畬鍐嶅叧闂� loading + } + }, + + async getDeptTree() { + this.loadings = true; + try { + const response = await deptTree111(); + this.deptOptions = response.data; + + // 淇濊瘉 treeId 鏄暟缁勬牸寮� + this.treeId = []; + + if (this.treeDate?.id) { + this.treeId.push(this.treeDate.id); + } else { + this.treeId.push("532"); + } + } catch (error) { + console.error("鍔犺浇閮ㄩ棬鏍戝け璐ワ細", error); + } finally { + this.loadings = false; // loading 鐘舵�佺粨鏉� + } + }, + + async getList() { + this.loading = true; + let data = { + proName: this.queryParams.proName, + checkType: this.queryParams.checkType, + deptId: this.queryParams.deptId, + proId: this.queryParams.proId, + }; + try { + const res = await getAllChildListById(data); // 鏇挎崲鎴愪綘瀹為檯鐨勬帴鍙� + this.projectList = res.data.list; + } finally { + this.loading = false; + } + }, + filterNode(value, data) { if (!value) return true; const cached = this.pinyinCache.get(data.id); @@ -1461,17 +1546,25 @@ this.deptList = this.handleTree(response.data, "proId"); }); }, - getDeptTree() { - return deptTree111().then((response) => { - this.deptOptions = response.data; - this.treeId = []; - if (this.treeDate.id) { - this.treeId.push(this.treeDate.id); - } else { - this.treeId.push("532"); - } - }); - }, + /* getDeptTree() { + this.loadings = true; + return deptTree111() + .then((response) => { + this.deptOptions = response.data; + this.treeId = []; + if (this.treeDate.id) { + this.treeId.push(this.treeDate.id); + } else { + this.treeId.push("532"); + } + }) + .catch((err) => { + console.error("鍔犺浇閮ㄩ棬鏍戝け璐ワ細", err); + }) + .finally(() => { + this.loadings = false; // 鏃犺鎴愬姛鎴栧け璐ワ紝缁撴潫鍔犺浇 + }); + }, */ handleNodeClick(date) { this.treeDate = date; this.xiugaiList = {}; @@ -1629,23 +1722,39 @@ } }, handleUpdate1() { + // this.updateLoading = true; this.form = {}; - this.form = this.xiugaiList; - this.form.proStatus = this.form.proStatus.toString(); - this.form.sfcyyc = this.form.sfcyyc.toString(); this.proParent = true; this.isPriceDisabled = true; - getlist().then((response) => { - if (response.code == 200) { + + // 鍏堝姞杞界瀹ゅ垪琛ㄦ暟鎹紝鍐嶈缃〃鍗曟暟鎹� + Promise.all([ + listDept(this.queryParams), + getlist() + ]).then(([deptResponse, listResponse]) => { + // 鍏堣缃瀹ゅ垪琛� + this.parentNameList = deptResponse.data; + + // 鍐嶈缃〃鍗曟暟鎹� + this.form = this.xiugaiList; + this.form.proStatus = this.form.proStatus.toString(); + this.form.sfcyyc = this.form.sfcyyc.toString(); + + // 澶勭悊椤圭洰閫夐」 + if (listResponse.code == 200) { this.loading = false; this.projectOptions = []; const project = { proId: 0, proName: "涓荤被鐩�", children: [] }; - project.children = this.handleTree(response.data.list, "proId"); - this.key = response.data.key; + project.children = this.handleTree(listResponse.data.list, "proId"); + this.key = listResponse.data.key; this.projectOptions.push(project); } - }); - this.open = true; + + this.open = true; + }).catch((error) => { + console.error("鍔犺浇鏁版嵁澶辫触:", error); + this.$message.error("鍔犺浇鏁版嵁澶辫触"); + }) }, handleUpdate(row) { this.reset(); @@ -1653,47 +1762,79 @@ const proId = row.proId || this.ids; this.proParent = false; this.isPriceDisabled = false; - getProject(proId).then((response) => { - this.form = response.data; - this.showPrise = this.form.proParentId === "0"; - this.showRentPrise = !this.showPrise; - this.form.proStatus = this.form.proStatus.toString(); - this.form.sfcyyc = this.form.sfcyyc.toString(); - this.form.consumablesList = response.data.consumablesList; - this.form.tjStandardList = response.data.tjStandardList; - if (this.form.tjStandardList) { - this.form.tjStandardList.forEach((item) => { - item.tjSex = - item.tjSex === "0" || item.tjSex === "鐢�" - ? "鐢�" - : item.tjSex === "1" || item.tjSex === "濂�" - ? "濂�" - : null; - item.tjType = - { - 0: "濠村効", - 1: "骞煎効", - 2: "鍎跨", - 3: "灏戝勾", - 4: "闈掑勾", - 5: "涓勾", - 6: "鑰佸勾", - }[item.tjType] || item.tjType; - }); - } - getlist().then((response) => { - if (response.code == 200) { - this.loading = false; - this.projectOptions = []; - const project = { proId: 0, proName: "涓荤被鐩�", children: [] }; - project.children = this.handleTree(response.data.list, "proId"); - this.key = response.data.key; - this.projectOptions.push(project); + listDept(this.queryParams).then((response) => { + this.parentNameList = response.data; + // this.deptList = this.handleTree(response.data, "proId"); + getProject(proId).then((response) => { + this.form = response.data; + this.form.deptId = response.data.deptId; + this.showPrise = this.form.proParentId === "0"; + this.showRentPrise = !this.showPrise; + this.form.proStatus = this.form.proStatus.toString(); + this.form.sfcyyc = this.form.sfcyyc.toString(); + this.form.consumablesList = response.data.consumablesList; + this.form.tjStandardList = response.data.tjStandardList; + if (this.form.tjStandardList) { + this.form.tjStandardList.forEach((item) => { + item.tjSex = + item.tjSex === "0" || item.tjSex === "鐢�" + ? "鐢�" + : item.tjSex === "1" || item.tjSex === "濂�" + ? "濂�" + : null; + item.tjType = + { + 0: "濠村効", + 1: "骞煎効", + 2: "鍎跨", + 3: "灏戝勾", + 4: "闈掑勾", + 5: "涓勾", + 6: "鑰佸勾", + }[item.tjType] || item.tjType; + }); } + getlist().then((response) => { + if (response.code == 200) { + // this.loading = false; + this.projectOptions = []; + const project = { proId: 0, proName: "涓荤被鐩�", children: [] }; + project.children = this.handleTree(response.data.list, "proId"); + this.key = response.data.key; + this.projectOptions.push(project); + } + }); + // this.loadPage(); + this.open = true; + this.title = "浣撴椤圭洰淇℃伅缁存姢"; }); - this.open = true; - this.title = "浣撴椤圭洰淇℃伅缁存姢"; }); + }, + // 鍒锋柊褰撳墠閫変腑椤圭洰鐨勬暟鎹� + async refreshCurrentProjectData() { + if (this.id) { + try { + const response = await getInfoByProId(this.id); + this.xiugaiList = response.data; + console.log("鍒锋柊椤圭洰鏁版嵁鎴愬姛:", this.xiugaiList); + return response.data; + } catch (error) { + console.error("鍒锋柊椤圭洰鏁版嵁澶辫触:", error); + this.$message.error("鍒锋柊椤圭洰鏁版嵁澶辫触"); + this.xiugaiList = null; // 鍒锋柊澶辫触鏃堕噸缃负 null + return null; + } + } + return null; + }, + // 璋冭瘯鏂规硶锛氭鏌ュ綋鍓嶆暟鎹姸鎬� + debugDataState() { + console.log("=== 鏁版嵁鐘舵�佽皟璇� ==="); + console.log("褰撳墠ID:", this.id); + console.log("xiugaiList:", this.xiugaiList); + console.log("form:", this.form); + console.log("treeDate:", this.treeDate); + console.log("=================="); }, getSelectValue(val) { this.form.consumablesList.forEach((formitem) => { @@ -1710,6 +1851,7 @@ }, submitForm() { this.noclick = true; + this.pageLoading = true; this.$refs["form"].validate((valid) => { if (valid) { const isUpdate = this.form.proId != null; @@ -1736,9 +1878,13 @@ this.form.lisXmbm = this.form.lisXmbm; if (this.key === "N") { this.processSubmission(isUpdate, false); + this.open = false; + // this.pageLoading = false; } else if (this.key === "Y") { this.form.sfxmId = this.sfxmId; this.processSubmission(isUpdate, true); + this.open = false; + // this.pageLoading = false; } } }); @@ -1771,15 +1917,32 @@ } } }, - handleSuccess(isY) { + /* handleSuccess(isY) { this.cancel(); - this.getList(); + // this.getList(); if (this.proParent || isY) { this.getDeptTree().then(() => { this.precomputePinyin(); }); } console.log(this.treeId); + }, */ + async handleSuccess(isY) { + this.cancel(); + + if (this.proParent || isY) { + // 绛夊緟宸︿晶鏍戝姞杞藉拰鎷奸煶澶勭悊 + await this.getDeptTree(); + this.precomputePinyin(); + } + + // 绛夊緟鍙充晶琛ㄦ牸鍒锋柊 + await this.getList(); + + // 绔嬪嵆鍒锋柊褰撳墠椤圭洰鏁版嵁锛岀‘淇濇暟鎹槸鏈�鏂扮殑 + await this.refreshCurrentProjectData(); + + this.pageLoading = false; // 鉁� 缁熶竴鍔犺浇鐘舵�佹帶鍒� }, submit() { this.ChangeList.forEach((item) => { -- Gitblit v1.8.0