From 37e09a8edf9afb70342b68352329ce959f8ebda6 Mon Sep 17 00:00:00 2001
From: qx <1084500556@qq.com>
Date: 星期三, 23 四月 2025 11:11:10 +0800
Subject: [PATCH] qx

---
 src/views/hosp/project/index.vue |  650 +++++++++++++++++++---------------------------------------
 1 files changed, 211 insertions(+), 439 deletions(-)

diff --git a/src/views/hosp/project/index.vue b/src/views/hosp/project/index.vue
index c499b82..0ae2020 100644
--- a/src/views/hosp/project/index.vue
+++ b/src/views/hosp/project/index.vue
@@ -9,8 +9,8 @@
         <div class="scrollable-container">
           <div class="content">
             <el-tree :data="deptOptions" :props="defaultProps" :expand-on-click-node="false"
-              :filter-node-method="filterNode" ref="tree" node-key="id" :default-expanded-keys="treeId"
-              highlight-current @node-click="handleNodeClick" :render-content="renderContent" />
+              :filter-node-method="filterNode" ref="tree1" node-key="id" :default-expanded-keys="treeId"
+              highlight-current @node-click="handleNodeClick" :render-content="renderContent" v-loading="loadings" />
           </div>
         </div>
       </el-col>
@@ -39,12 +39,6 @@
             <el-button :disabled="xiugais" type="primary" icon="el-icon-plus" size="mini" @click="handleUpdate1"
               v-hasPermi="['hosp:project:add']">淇敼</el-button>
           </el-col>
-          <!-- <el-col :span="1.5">
-        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate" v-hasPermi="['hosp:project:edit']">淇敼</el-button>
-      </el-col> -->
-          <!-- <el-col :span="1.5">
-        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['hosp:project:remove']">鍒犻櫎</el-button>
-      </el-col> -->
           <el-col :span="1.5">
             <el-button type="primary" icon="el-icon-download" size="mini" @click="handleExport"
               v-hasPermi="['hosp:project:export']">瀵煎嚭</el-button>
@@ -60,13 +54,11 @@
         </el-row>
 
         <el-table v-if="refreshTable" v-loading="loading" :data="projectList" ref="tableRef" border>
-          <!-- :show-overflow-tooltip="true"  -->
-          <el-table-column label="椤圭洰鍚嶇О" prop="proName" fixed="left" :width="flexColumnWidth('rwdtypeName')" />
+          <el-table-column label="椤圭洰鍚嶇О" prop="proName" fixed="left" :width="flexColumnWidth('proName')" />
           <el-table-column label="浠锋牸(/鍏�)" align="center" prop="proPrice" width="75px"
             :show-overflow-tooltip="true"></el-table-column>
           <el-table-column label="鏁伴噺" align="center" prop="sl" width="65px"
             :show-overflow-tooltip="true"></el-table-column>
-          <!-- <el-table-column label="绉戝鍚嶇О" align="center" prop="deptName" width="110px" :show-overflow-tooltip="true" /> -->
           <el-table-column label="妫�鏌ョ被鍒�" align="center" prop="proCheckType" width="110px"
             :show-overflow-tooltip="true" />
           <el-table-column label="榛樿鍊�" align="center" prop="proDefault" width="110px" :show-overflow-tooltip="true" />
@@ -75,9 +67,6 @@
               <dict-tag :options="dict.type.tj_result_type" :value="scope.row.resultType" />
             </template>
           </el-table-column>
-
-          <!-- <el-table-column label="妫�鏌ユ柟寮�" align="center" prop="proCheckMethod" :show-overflow-tooltip="true"
-            width="110px" /> -->
           <el-table-column label="鍙備笌灏忕粨" align="center" prop="needReport" :show-overflow-tooltip="true" width="75px">
             <template slot-scope="scope">
               <dict-tag :options="dict.type.sys_yes_no" :value="scope.row.needReport" />
@@ -89,6 +78,10 @@
             </template>
           </el-table-column>
           <el-table-column label="椤圭洰鏍囧噯鍊�" align="center" prop="proScope" :show-overflow-tooltip="true" width="90px">
+          </el-table-column>
+          <el-table-column label="Lis椤圭洰鍚嶇О" align="center" prop="lisXmmc" :show-overflow-tooltip="true" width="200px">
+          </el-table-column>
+          <el-table-column label="Lis缂栫爜" align="center" prop="lisXmbm" :show-overflow-tooltip="true" width="90px">
           </el-table-column>
           <el-table-column label="涓村簥鎰忎箟" align="center" prop="proMeaning" width="350px" :show-overflow-tooltip="true" />
           <el-table-column label="澶囨敞" prop="remark" align="center" width="120px" :show-overflow-tooltip="true">
@@ -120,10 +113,8 @@
           <treeselect :disabled="proParent" v-model="form.proParentId" :options="projectOptions"
             :normalizer="normalizer" :show-count="true" placeholder="閫夋嫨涓婚」鍚嶇О" style="width: 260px" @select="obtain" />
         </el-form-item>
-
         <el-form-item label="鏄庣粏椤圭洰" prop="proName">
-          <el-input v-model="form.proName" placeholder="璇疯緭鍏ユ槑缁嗛」鐩�">
-          </el-input>
+          <el-input v-model="form.proName" placeholder="璇疯緭鍏ユ槑缁嗛」鐩�"></el-input>
         </el-form-item>
         <el-form-item label="椤圭洰浠锋牸" prop="proPrice">
           <el-input v-model="form.proPrice" :disabled="isPriceDisabled" placeholder="璇疯緭鍏ラ」鐩环鏍�" />
@@ -146,12 +137,6 @@
               :value="dict.value"></el-option>
           </el-select>
         </el-form-item>
-        <!-- <el-form-item label="绌鸿吂" prop="isEat">
-          <el-select v-model="form.isEat" placeholder="璇烽�夋嫨鏄惁绌鸿吂" style="width: 200px">
-            <el-option v-for="dict in dict.type.sys_yes_no" :key="dict.value" :label="dict.label"
-              :value="dict.value"></el-option>
-          </el-select>
-        </el-form-item> -->
         <el-form-item label="鎬у埆" prop="proSex">
           <el-select v-model="form.proSex" placeholder="璇烽�夋嫨浣撴浜烘�у埆" style="width: 200px" clearable>
             <el-option v-for="dict in dict.type.sys_user_sex" :key="dict.value" :label="dict.label"
@@ -161,7 +146,6 @@
         <el-form-item label="椤圭洰绫诲瀷" prop="proType">
           <el-input v-model="form.proType" placeholder="璇疯緭鍏ラ」鐩被鍨�" />
         </el-form-item>
-
         <el-form-item label="绉戝鍚嶇О" prop="deptId">
           <el-select v-model="form.deptId" placeholder="璇烽�夋嫨绉戝鍚嶇О" @change="changeType" filterable style="width: 260px">
             <el-option v-for="item in parentNameList" :key="item.deptId" :label="item.deptName" :value="item.deptId" />
@@ -209,7 +193,6 @@
               :value="dict.value"></el-option>
           </el-select>
         </el-form-item>
-
         <el-form-item label="缁撴灉绫诲瀷" prop="resultType">
           <el-select v-model="form.resultType" placeholder="璇烽�夋嫨缁撴灉绫诲瀷" style="width: 200px" filterable clearable>
             <el-option v-for="dict in dict.type.tj_result_type" :key="dict.value" :label="dict.label"
@@ -220,13 +203,10 @@
           <span slot="label" style="display: inline-block; border-bottom: 2px solid blue" @click="getDetailed">
             his椤圭洰鍚嶇О
           </span>
-
-          <el-input v-model="form.hisXmmc" placeholder="his椤圭洰鍚嶇О" style="width: 200px">
-          </el-input>
+          <el-input v-model="form.hisXmmc" placeholder="his椤圭洰鍚嶇О" style="width: 200px"></el-input>
         </el-form-item>
         <el-form-item label="his椤圭洰鍚嶇О" prop="hisXmmc" v-if="key == 'N'">
-          <el-input v-model="form.hisXmmc" placeholder="璇疯緭鍏ユ槑缁嗛」鐩�" style="width: 260px">
-          </el-input>
+          <el-input v-model="form.hisXmmc" placeholder="璇疯緭鍏ユ槑缁嗛」鐩�" style="width: 260px"></el-input>
         </el-form-item>
         <el-form-item label="his缂栫爜" prop="hisXmbm">
           <el-input v-model="form.hisXmbm" placeholder="璇疯緭鍏is缂栫爜" style="width: 260px" />
@@ -238,11 +218,8 @@
           <span slot="label" style="display: inline-block; border-bottom: 2px solid blue" @click="handleQuerys">
             LIS椤圭洰
           </span>
-
-          <el-input v-model="form.lisXmmc" placeholder="璇疯緭鍏IS椤圭洰" style="width: 200px">
-          </el-input>
+          <el-input v-model="form.lisXmmc" placeholder="璇疯緭鍏IS椤圭洰" style="width: 200px"></el-input>
         </el-form-item>
-
         <el-form-item label="LIS缂栫爜" prop="lisXmbm">
           <el-input v-model="form.lisXmbm" placeholder="璇疯緭鍏is缂栫爜" style="width: 260px" />
         </el-form-item>
@@ -250,7 +227,13 @@
           <el-input v-model="form.proRemark" placeholder="璇疯緭鍏ュ娉�" style="width: 200px" />
         </el-form-item>
         <el-form-item label="鎺掑簭" prop="xh">
-          <el-input v-model="form.xh" placeholder="璇疯緭鍏ュ娉�" style="width: 200px" />
+          <el-input v-model="form.xh" placeholder="璇疯緭鍏ユ帓搴�" style="width: 200px" />
+        </el-form-item>
+        <el-form-item label="鏄惁鍙備笌寮傚父" prop="sfcyyc">
+          <el-select v-model="form.sfcyyc" placeholder="璇烽�夋嫨鏄惁鍙備笌寮傚父" style="width: 260px">
+            <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>
       <el-button style="margin-left: 40px" type="primary" plain size="mini" icon="el-icon-plus"
@@ -262,15 +245,12 @@
           <template slot-scope="scope">
             <el-select filterable v-model="scope.row.makings" placeholder="璇烽�夋嫨鏀惰垂椤圭洰" @change="getSelectValue">
               <el-option v-for="(item, index) in consumableList" :key="index" :label="item.makings"
-                :value="item.makings">
-              </el-option>
+                :value="item.makings"></el-option>
             </el-select>
           </template>
         </el-table-column>
-        <el-table-column label="瑙勬牸" align="center" prop="specifications">
-        </el-table-column>
-        <el-table-column label="浠锋牸" align="center" prop="price">
-        </el-table-column>
+        <el-table-column label="瑙勬牸" align="center" prop="specifications"></el-table-column>
+        <el-table-column label="浠锋牸" align="center" prop="price"></el-table-column>
         <el-table-column label="鎿嶄綔" align="center" fixed="right" class-name="small-padding fixed-width">
           <template slot-scope="scope">
             <el-button size="mini" type="text" icon="el-icon-delete" @click.native.prevent="Delete(scope.$index)"
@@ -328,7 +308,6 @@
     <el-dialog title="鏀惰垂椤圭洰" :visible.sync="dialogTableVisible" width="80%" :close-on-click-modal="false">
       <div class="app-container">
         <el-row :gutter="24">
-          <!--閮ㄩ棬鏁版嵁-->
           <el-col :span="6" :xs="24">
             <div style="height: 560px; overflow-y: scroll">
               <div class="head-container">
@@ -364,7 +343,6 @@
               <el-table-column label="椤圭洰缂栫爜" align="center" prop="xmbm" />
               <el-table-column label="椤圭洰鍚嶇О" align="center" prop="xmmc" />
               <el-table-column label="鎷奸煶鐮�" align="center" prop="pym" />
-              <!-- <el-table-column label="浜旂瑪鐮�" align="center" prop="wbm"  /> -->
               <el-table-column label="鍙傝�冨崟浠�" align="center" prop="ckdj" />
               <el-table-column label="涓�绾ф渶楂橀檺浠�" align="center" prop="yjzgxj" />
               <el-table-column label="浜岀骇鏈�楂橀檺浠�" align="center" prop="ejzgxj" />
@@ -398,6 +376,8 @@
 </template>
 
 <script>
+import debounce from 'lodash/debounce';
+import cnchar from 'cnchar';
 import Packagese from "@/components/Packagese";
 import {
   getProject,
@@ -445,19 +425,18 @@
   data() {
     let checkPhoneNum = (rule, value, callback) => {
       let patter = new RegExp(/^1\s*[3456789]\s*(\d\s*){9}$/);
-      if (value == "" && value == undefined && !value) {
-        return callback("");
-      } else if (value != undefined && value != "") {
+      if (value == "" || value == undefined || !value) {
         return callback();
       } else if (!patter.test(value)) {
-        return callback("");
+        return callback(new Error("璇疯緭鍏ユ湁鏁堢殑鎵嬫満鍙�"));
+      } else {
+        return callback();
       }
     };
     return {
       xiugais: true,
       xiugaiList: [],
-      // 閮ㄩ棬鏍戦�夐」
-      deptOptions: undefined,
+      deptOptions: [],
       dialogTableVisible: false,
       isPriceDisabled: false,
       sfxmList: [],
@@ -468,43 +447,40 @@
       },
       xmmc: "",
       chargeId: [],
+      dictTypesy: [
+        {
+          value:"0",
+          label:"鏄�"
+        },
+        {
+          value:"1",
+          label:"鍚�"
+        }
+      ],
       List: false,
-      // 閮ㄩ棬鍚嶇О
       deptName: "",
       deptOption: [],
       ChangeList: [],
-      // 閬僵灞�
       loading: true,
+      loadings: false,
       key: "",
-      // 閫変腑鏁扮粍
       ids: [],
-      // 闈炲崟涓鐢�
       single: true,
-      // 闈炲涓鐢�
       multiple: true,
-      // 鏄剧ず鎼滅储鏉′欢
       showSearch: true,
-      // 鎬绘潯鏁�
       total: 0,
       treeId: ["532"],
       ListId: [],
       noclick: false,
-      // 浣撴鑰楁潗琛ㄦ牸鏁版嵁
       consumableList: [],
       tjStandardList: [],
-      // 琛ㄦ牸鏍戞暟鎹�
       deptList: [],
       parentNameList: [],
       sfxmId: null,
-      // 浣撴椤圭洰琛ㄦ牸鏁版嵁
       projectList: [],
-      // 鑿滃崟鏍戦�夐」
       projectOptions: [],
-      // 寮瑰嚭灞傛爣棰�
       title: "",
-      // 鏄惁鏄剧ず寮瑰嚭灞�
       open: false,
-      // 鏄惁灞曞紑锛岄粯璁ゅ叏閮ㄦ姌鍙�
       isExpandAll: false,
       showPrise: false,
       showRentPrise: false,
@@ -515,12 +491,8 @@
       proParent: false,
       id: "",
       isSubmitting: false,
-      // 閲嶆柊娓叉煋琛ㄦ牸鐘舵��
       refreshTable: true,
-      // 鏌ヨ鍙傛暟
       queryParams: {
-        // pageNum: 1,
-        // pageSize: 10,
         proName: null,
         proEngName: null,
         checkType: null,
@@ -539,7 +511,6 @@
         pageSize: 10,
         id: null,
       },
-      // 琛ㄥ崟鍙傛暟
       form: {
         proParentId: "",
         deptId: "",
@@ -549,7 +520,7 @@
         sfzhfy: "Y",
         hisdj: "",
         sl: "",
-        xh:"0",
+        xh: "0",
         proStatus: "0",
         proName: "",
         proPrice: "",
@@ -559,9 +530,9 @@
         proMetering: "",
         proScope: "",
         proSex: "2",
-        resultType: "", // 鍒濆鍊�
+        resultType: "",
+        sfcyyc: "0",
       },
-      // 琛ㄥ崟鏍¢獙
       rules: {
         createTime: [
           { required: true, validator: checkPhoneNum, trigger: "blur" },
@@ -573,36 +544,29 @@
           { required: true, validator: checkPhoneNum, trigger: "blur" },
         ],
         proName: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
+          { required: true, message: "椤圭洰鍚嶇О涓嶈兘涓虹┖", trigger: "blur" },
         ],
         proPrice: [
-          { required: true, validator: checkPhoneNum, trigger: "blur" },
+          { required: true, message: "椤圭洰浠锋牸涓嶈兘涓虹┖", trigger: "blur" },
         ],
-        deptId: [{ required: true, validator: checkPhoneNum, trigger: "blur" }],
-        // proStandard: [
-        //   { required: true, message: "椤圭洰鏍囧噯鍊间笉鑳戒负绌�", trigger: "blur" },
-        // ],
+        deptId: [
+          { required: true, message: "绉戝鍚嶇О涓嶈兘涓虹┖", trigger: "change" },
+        ],
       },
+      pinyinCache: new Map(),
     };
   },
   watch: {
-    // 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲
     deptName(val) {
-      this.$refs.tree.filter(val);
+      this.debounceFilter(val);
     },
-    treeId(newVal, oldVal) {
+    treeId(newVal) {
       if (newVal && newVal.length > 0) {
         this.$nextTick(() => {
-          // Find the last ID in the treeId array
-          const lastId = newVal[newVal.length - 1] || "532"; // Default to 100 if undefined
-          // Search for the node in deptOptions
+          const lastId = newVal[newVal.length - 1] || "532";
           const node = this.findNodeById(this.deptOptions, lastId);
-
           if (node) {
-            // Set the current key for the tree
-            this.$refs.tree.setCurrentKey(lastId);
-
-            // Simulate clicking on the node
+            this.$refs.tree1.setCurrentKey(lastId);
             const nodeElement = document.querySelector(`.el-tree-node[data-key="${lastId}"] .el-tree-node__content`);
             if (nodeElement) {
               nodeElement.click();
@@ -611,52 +575,105 @@
         });
       }
     },
-    // 鏍规嵁鍚嶇О绛涢�夐儴闂ㄦ爲
     xmmc(val) {
       this.$refs.tree.filter(val);
     },
-    chargeId(newVal, oldVal) {
+    chargeId(newVal) {
       if (newVal) {
         this.$nextTick(() => {
-          // document.getElementById("changtree").click();;
           document
             .querySelector(
               "#changtree .el-tree-node__children .el-tree-node.is-focusable .el-tree-node__content"
             )
-            .click();
+            ?.click();
         });
       }
     },
   },
-
   created() {
     this.getConsumables();
     this.getDeptList();
-    this.getDeptTree();
-
+    this.getDeptTree().then(() => {
+      this.precomputePinyin();
+    });
   },
   mounted() {
-    this.getDeptTree();
+    this.getDeptTree().then(() => {
+      this.precomputePinyin();
+    });
   },
   methods: {
+    debounceFilter: debounce(function (val) {
+      this.$refs.tree1.filter(val);
+    }, 300),
+    precomputePinyin() {
+      const traverse = (nodes) => {
+        nodes.forEach(node => {
+          if (node.label) {
+            const lowerSpell = cnchar.spell(node.label, 'low', 'array').join(''); // 瀹屾暣灏忓啓鎷奸煶
+            const upperSpell = cnchar.spell(node.label, 'up', 'array').join('');  // 瀹屾暣澶у啓鎷奸煶
+            const shortPinyin = node.label
+              .split('')
+              .map(char => cnchar.spell(char, 'array')[0]?.[0]?.toLowerCase() || char) // 鎷奸煶棣栧瓧姣�
+              .join('');
+            this.pinyinCache.set(node.id, {
+              lowerSpell,
+              upperSpell,
+              shortPinyin, // 缂撳瓨鎷奸煶绠�鍐�
+              label: node.label
+            });
+          }
+          if (node.children) traverse(node.children);
+        });
+      };
+      traverse(this.deptOptions);
+    },
+    filterNode(value, data) {
+      if (!value) return true; // 濡傛灉鎼滅储鍊间负绌猴紝杩斿洖鎵�鏈夎妭鐐�
+      const cached = this.pinyinCache.get(data.id);
+      if (!cached) return false; // 濡傛灉娌℃湁缂撳瓨鏁版嵁锛屼笉鏄剧ず璇ヨ妭鐐�
+      const searchLower = value.toLowerCase(); // 灏嗘悳绱㈣瘝杞负灏忓啓
+      return (
+        cached.label.includes(value) ||           // 鐩存帴鍖归厤姹夊瓧
+        cached.shortPinyin.includes(searchLower) || // 鍖归厤鎷奸煶绠�鍐�
+        cached.lowerSpell.includes(searchLower)   // 鍖归厤瀹屾暣鎷奸煶
+      );
+    },
+    filterNode2(value, data) {
+      if (!value) return true;
+      return data.xmmc.includes(value);
+    },
+    findNodeById(nodes, id) {
+      for (let node of nodes) {
+        if (node.id === id) return node;
+        if (node.children) {
+          let result = this.findNodeById(node.children, id);
+          if (result) return result;
+        }
+      }
+      return null;
+    },
+    renderContent(h, { node, data }) {
+      return h(
+        "span",
+        {
+          style: {
+            color: data.status === "1" ? "red" : "inherit",
+            fontSize: "14px",
+          },
+        },
+        data.label
+      );
+    },
     handleQuerys() {
       this.$refs.aaa.open = true;
       this.$refs.aaa.getAllList();
       this.$refs.aaa.title = "鏁版嵁瀛楀吀";
     },
     handleChanges(param1) {
-      // if(this.form.pacCode == "涓嶈"){
-      //   this.form.cusIdcard = param1[0].xh;
-      // }else{
-      //   this.form.cusIdcard = param1[0].pacCode;
-      // }
-
       this.form.lisXmbm = param1[0].pacCode;
       this.form.lisXmmc = param1[0].pacName;
     },
-    //鏄惁鏄剧ず閫変腑鐨勫��
-    display(value) { },
-    /** 鏌ヨ浣撴椤圭洰鍒楄〃 */
     getList() {
       this.loading = true;
       let data = {
@@ -667,12 +684,9 @@
       };
       getAllChildListById(data).then((response) => {
         this.projectList = response.data.list;
-        console.log("杩涙潵浜嗗垪琛ㄥ苟涓旇幏鍙栧埌浜嗗��", this.projectList);
-
         this.loading = false;
       });
     },
-    /** 鏌ヨ浣撴鑰楁潗鍒楄〃 */
     getConsumables() {
       this.loading = true;
       listConsumables(this.queryParams).then((response) => {
@@ -680,20 +694,16 @@
         this.loading = false;
       });
     },
-
-    /** 鏂板鎸夐挳鎿嶄綔 */
     handleAdd(row) {
       this.form.hisXmbm = "";
       this.form.hisXmmc = "";
       this.form.hisdj = "";
-      // this.reset();
       this.loading = true;
       this.proParent = false;
       this.form.proPrice = 0.0;
       this.form.proName = "";
       this.form.proId = null;
       this.form.resultType = "1";
-      //  ProjectTree
       getlist().then((response) => {
         if (response.code == 200) {
           this.loading = false;
@@ -702,71 +712,47 @@
           project.children = this.handleTree(response.data.list, "proId");
           this.key = response.data.key;
           this.projectOptions.push(project);
+          // this.open = true;
           if (row.proId) {
-            for (var i = 0; i < project.children.length; i++) {
-              if (project.children[i].proId === row.proId) {
-                this.form.proParentId = row.proId;
-                break;
-              } else {
-                this.form.proParentId = 0;
-              }
-            }
-
+            this.form.proParentId = row.proId || 0;
             this.open = true;
           } else if (this.treeDate.id) {
-            for (var i = 0; i < project.children.length; i++) {
-              if (project.children[i].proId === this.treeDate.id) {
-                this.form.proParentId = this.treeDate.id;
-                break;
-              } else {
-                this.form.proParentId = 0;
-              }
+            if (this.treeDate.qf == "0") {
+              this.form.proParentId = "0"
+              this.form.deptId = this.treeDate.id
+            } else {
+              this.form.proParentId = this.treeDate.id;
+              this.projectOptions.forEach((item) => {
+                item.children.forEach((item1) => {
+                  if (this.form.proParentId == item1.proId) {
+                    this.form.deptId = item1.deptId;
+                  }
+                });
+              });
             }
 
-            this.projectOptions.forEach((item) => {
-              item.children.forEach((item1) => {
-                if (this.form.proParentId == item1.proId) {
-                  this.form.deptId = item1.deptId;
-                }
-              });
-            });
+
             this.open = true;
           } else {
+            this.form.proParentId = "0"
             this.open = true;
           }
         }
       });
-
       this.title = "浣撴椤圭洰淇℃伅缁存姢";
-      if (this.queryParams.deptId) {
-        this.form.deptId = this.queryParams.deptId;
-      } else {
-        this.form.deptId = null;
-      }
-      // this.form.proId = this.queryParams.proId;
+      this.form.deptId = this.queryParams.deptId || null;
       this.form.proCheckMethod = "N";
-
-      if ((this.key = "Y")) {
+      if (this.key === "Y") {
         gettreeList().then((response) => {
           this.deptOptionstree = response.data;
         });
       }
     },
-
-    // 鎵撳紑input寮规
     getDetailed() {
       this.querycharge.xmmc = "";
       this.querycharge.pym = "";
-      if (this.selectList) {
-        if (this.selectList.proName === "涓荤被鐩�") {
-          this.dialogTableVisible = false;
-        } else {
-          this.dialogTableVisible = true;
-          this.$nextTick(() => {
-            this.chargeId.push(this.deptOptionstree[0].id);
-          });
-          this.getlistSfxm();
-        }
+      if (this.selectList?.proName === "涓荤被鐩�") {
+        this.dialogTableVisible = false;
       } else if (this.form.proParentId) {
         if (this.form.proParentId != 0) {
           this.dialogTableVisible = true;
@@ -774,7 +760,7 @@
             this.chargeId.push(this.deptOptionstree[0].id);
           });
           this.getlistSfxm();
-        } else if (this.form.proParentId == 0) {
+        } else {
           this.dialogTableVisible = false;
         }
       } else {
@@ -784,11 +770,8 @@
     changeType() {
       this.$forceUpdate();
     },
-
     obtain(vals) {
-      if (this.projectOptions) {
-        this.selectList = vals;
-      }
+      this.selectList = vals;
       if (this.selectList.proName === "涓荤被鐩�") {
         this.showPrise = true;
         this.showRentPrise = false;
@@ -803,51 +786,39 @@
       this.List = true;
       listSfxm(this.querycharge).then((response) => {
         this.sfxmList = response.rows;
-
         response.rows.forEach((item, index) => {
-          item.newID =
-            (this.querycharge.pageNum - 1) * this.querycharge.pageSize +
-            index +
-            1;
+          item.newID = (this.querycharge.pageNum - 1) * this.querycharge.pageSize + index + 1;
         });
         this.total = response.total;
         this.loading = false;
       });
     },
-
     Synchronizationfees() {
       tbhisproprice().then((response) => {
         this.$modal.msgSuccess("鎵归噺鍚屾璐圭敤鎴愬姛");
       });
     },
-    // input寮规鎼滅储
     handlecharge() {
       this.querycharge.pageNum = 1;
       this.List = true;
       this.getlistSfxm();
     },
-
     handleNodecharge(data) {
       this.queryParam.id = data.id;
-
       this.List = false;
       this.getListByXmId();
     },
-
     getListByXmId() {
       this.loading = true;
       getListByXmId(this.queryParam).then((response) => {
         this.sfxmList = response.data.date;
         response.data.date.forEach((item, index) => {
-          item.newID =
-            (this.queryParam.page - 1) * this.queryParam.pageSize + index + 1;
+          item.newID = (this.queryParam.page - 1) * this.queryParam.pageSize + index + 1;
         });
         this.total = response.data.total;
         this.loading = false;
       });
     },
-
-    /** 杞崲鑿滃崟鏁版嵁缁撴瀯 */
     normalizer(node) {
       if (node.children && !node.children.length) {
         delete node.children;
@@ -858,84 +829,32 @@
         children: node.children,
       };
     },
-    // // 鏌ヨ浣撴椤圭洰鍒楄〃(鏍戝舰缁撴瀯)
     getData() {
-      /** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
       getAllChildListById().then((response) => {
         this.projectOptions = [];
         const project = { proId: 0, proName: "涓荤被鐩�", children: [] };
         project.children = this.handleTree(response.data.list, "proId");
         this.key = response.data.key;
-        // if (this.key == "Y") {
-        //   this.key = response.data.key
-        // } else if (response.data.key == "N") {
-        //   this.key = response.data.key
-        // }
         this.projectOptions.push(project);
       });
     },
-    /** 鏌ヨ閮ㄩ棬鍒楄〃 */
     getDeptList() {
       listDept(this.queryParams).then((response) => {
         this.parentNameList = response.data;
         this.deptList = this.handleTree(response.data, "proId");
       });
     },
-    /** 鏌ヨ閮ㄩ棬涓嬫媺鏍戠粨鏋� */
     getDeptTree() {
-
-      deptTree111().then((response) => {
+      return deptTree111().then((response) => {
         this.deptOptions = response.data;
         this.treeId.push(this.treeDate.id);
-        console.log(this.treeId)
       });
-
     },
-    findNodeById(nodes, id) {
-      for (let node of nodes) {
-        if (node.id === id) {
-          return node;
-        }
-        if (node.children) {
-          let result = this.findNodeById(node.children, id);
-          if (result) return result;
-        }
-      }
-      return null;
-    },
-    renderContent(h, { node, data }) {
-      return h(
-        "span",
-        {
-          style: {
-            color: data.status === "1" ? "red" : "inherit", // 鍔ㄦ�佽缃鑹�
-            fontSize: "14px",
-          },
-        },
-        data.label // 鏄剧ず鑺傜偣鐨� label
-      );
-    },
-
-    // 绛涢�夎妭鐐�
-    filterNode2(value, data) {
-      if (!value) return true;
-      return data.xmmc.indexOf(value) !== -1;
-    },
-    // 绛涢�夎妭鐐�
-    filterNode(value, data) {
-      if (!value) return true;
-      return data.label.indexOf(value) !== -1;
-    },
-    // 鑺傜偣鍗曞嚮浜嬩欢
     handleNodeClick(date) {
 
-      console.log("璋冪敤浜唄andleNodeClick ", date.id, this.id)
       this.treeDate = date;
-      if (date.qf == "0") {
-        this.xiugais = true;
-      } else {
-        this.xiugais = false;
-      }
+      this.xiugaiList ={}
+      this.xiugais = date.qf === "0";
       let proId = date.id;
       getInfoByProId(proId).then((response) => {
         this.xiugaiList = response.data;
@@ -944,36 +863,18 @@
       this.queryParams.proId = date.id;
       let data = {
         proId: this.queryParams.proId,
-        proName: this.queryParams.proNamez,
+        proName: this.queryParams.proName,
       };
       this.loading = true;
       getAllChildListById(data).then((response) => {
         if (response.code == 200) {
-          if (response.data.list.length >= 1) {
-            this.projectList = this.handleTree(response.data.list, "proId");
-            this.ListId.push(this.projectList[0].proId);
-            this.key = response.data.key;
-          } else {
-            this.projectList = [];
-          }
-
-          // if (this.key == "Y") {
-          //   this.key = response.data.key
-          // } else if (response.data.key == "N") {
-          //   this.key = response.data.key
-          // }
+          this.projectList = response.data.list.length >= 1 ? this.handleTree(response.data.list, "proId") : [];
+          this.ListId = this.projectList.length ? [this.projectList[0].proId] : [];
+          this.key = response.data.key;
           this.loading = false;
         }
       });
     },
-    selectSingleRow({ row, rowIndex }) {
-      if (rowIndex === 1) {
-        return "warning-row";
-      }
-      return "";
-    },
-
-    /** 灞曞紑/鎶樺彔鎿嶄綔 */
     toggleExpandAll() {
       this.refreshTable = false;
       this.isExpandAll = !this.isExpandAll;
@@ -981,24 +882,22 @@
         this.refreshTable = true;
       });
     },
-    // 鍙栨秷鎸夐挳
     cancel() {
-      // this.$tab.refreshPage();
       this.open = false;
       this.queryParam.id = this.id;
-      let data = {
-        proId: this.queryParams.proId,
-      };
-      getAllChildListById(data).then((response) => {
-
+      let data = { proId: this.queryParams.proId };
+      getAllChildListById(data).then(() => {
         this.loading = false;
       });
+      this.deptName = "";
+      // 鎵嬪姩璋冪敤杩囨护鏂规硶锛堥渶绛夊緟 DOM 鏇存柊锛�
+      this.$nextTick(() => {
+        this.$refs.tree1.filter(this.deptName);
+      });
     },
-
     handleClose() {
       this.cancel();
     },
-    // 琛ㄥ崟閲嶇疆
     reset() {
       this.form = {
         proParentId: null,
@@ -1006,7 +905,7 @@
         proEngName: null,
         proPrice: "0.00",
         proRemark: null,
-        xh:"0",
+        xh: "0",
         createBy: null,
         createTime: null,
         updateBy: null,
@@ -1027,55 +926,37 @@
       };
       this.resetForm("form");
     },
-    /** 鎼滅储鎸夐挳鎿嶄綔 */
     handleQuery() {
-      // this.queryParams.pageNum = 1;
       this.getList();
     },
-    /** 閲嶇疆鎸夐挳鎿嶄綔 */
     resetQuery() {
       this.resetForm("queryForm");
       this.queryParams.proId = undefined;
-      this.$refs.tree.setCurrentKey(null);
+      this.$refs.tree1.setCurrentKey(null);
       this.handleQuery();
     },
-
     flexColumnWidth(column) {
-      if (!column) {
-        return;
-      }
-      let maxlength = 160; //鍦ㄦ澶勮缃粯璁ゅ搴�
-      if (column == "rwdtypeName") {
-        //鍦ㄦ澶勪负浜嗕繚璇佽〃澶翠笉鎹㈣锛屽彲浠ユ牴鎹〃澶村悕绉伴暱搴﹁缃粯璁ゅ搴�
-        // column1 灏辨槸瀵瑰簲琛ㄦ牸涓殑prop灞炴�у�硷紝姣斿涓婇潰鐨� rwdtypeName
-        maxlength = 160;
-      }
+      if (!column) return;
+      let maxlength = 160;
+      if (column === "proName") maxlength = 160;
       for (let i = 0; i < this.projectList.length; i++) {
         if (this.projectList[i][column]) {
           let now_temp = this.projectList[i][column] + "";
           let flexWidth = 0;
           for (const char of now_temp) {
             if ((char >= "A" && char <= "Z") || (char >= "a" && char <= "z")) {
-              //鑻辨枃瀛楁瘝 8 鍍忕礌
               flexWidth += 8;
             } else if (char >= "\u4e00" && char <= "\u9fa5") {
-              //涓枃鏂囧瓧 15 鍍忕礌
               flexWidth += 15;
             } else {
-              //鍏朵粬瀛楃 10 鍍忕礌
               flexWidth += 10;
             }
           }
-          if (flexWidth > maxlength) {
-            maxlength = flexWidth;
-          }
+          if (flexWidth > maxlength) maxlength = flexWidth;
         }
       }
-      //el-table涓� cell 鏈夊乏鍙崇殑 padding 涓� 10 鍍忕礌
       return maxlength + 20 + "px";
     },
-
-    // 澶氶�夋閫変腑鏁版嵁
     handleSelectionChange(selection) {
       this.ChangeList = selection;
       this.ids = selection.map((item) => item.id);
@@ -1083,87 +964,51 @@
       this.multiple = !selection.length;
       if (selection.length > 1) {
         let del_row = selection.shift();
-        this.$refs.tb.toggleRowSelection(del_row, false); //璁剧疆杩欎竴琛屽彇娑堥�変腑
+        this.$refs.tb.toggleRowSelection(del_row, false);
       }
     },
-
-    // 鏂板琛�
     addmembers() {
       if (this.form.proName) {
         if (!this.form.consumablesList) {
           this.form.consumablesList = [];
-          this.form.consumablesList.push({
-            // id: parseInt(length),
-            id: "",
-            makings: "",
-            specifications: "",
-            price: "",
-            Selection,
-          });
-        } else {
-          this.form.consumablesList.push({
-            // id: parseInt(length),
-            id: "",
-            makings: "",
-            specifications: "",
-            price: "",
-            Selection,
-          });
         }
+        this.form.consumablesList.push({
+          id: "",
+          makings: "",
+          specifications: "",
+          price: "",
+        });
         if (!this.form.tjStandardList) {
           this.form.tjStandardList = [];
-          this.form.tjStandardList.push({
-            stanId: "",
-            tjSex: "",
-            tjType: "",
-            tjStandardGtValue: "",
-            tjStandardLtValue: "",
-            company: "",
-            Selection,
-          });
-        } else {
-          this.form.tjStandardList.push({
-            stanId: "",
-            tjSex: "",
-            tjType: "",
-            tjStandardGtValue: "",
-            tjStandardLtValue: "",
-            company: "",
-            Selection,
-          });
         }
+        this.form.tjStandardList.push({
+          stanId: "",
+          tjSex: "",
+          tjType: "",
+          tjStandardGtValue: "",
+          tjStandardLtValue: "",
+          company: "",
+        });
       } else {
         Message.warning("璇峰厛濉啓椤圭洰鍚嶇О");
       }
       this.$forceUpdate();
     },
-    // 鍒犻櫎琛�
     Delete(index) {
-      if (this.form.consumablesList.length == 0) {
-        this.$alert("璇峰厛閫夋嫨瑕佸垹闄ょ殑鏁版嵁", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-      } else {
+      if (this.form.consumablesList.length) {
         this.form.consumablesList.splice(index, 1);
       }
-      if (this.form.tjStandardList.length == 0) {
-        this.$alert("璇峰厛閫夋嫨瑕佸垹闄ょ殑鏁版嵁", "鎻愮ず", {
-          confirmButtonText: "纭畾",
-        });
-      } else {
+      if (this.form.tjStandardList.length) {
         this.form.tjStandardList.splice(index, 1);
       }
     },
     handleUpdate1() {
+      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;
-      // if(){
-      //   this.proParent = true
-      // }
       getlist().then((response) => {
         if (response.code == 200) {
           this.loading = false;
@@ -1172,71 +1017,31 @@
           project.children = this.handleTree(response.data.list, "proId");
           this.key = response.data.key;
           this.projectOptions.push(project);
+          console.log( this.projectOptions,11111)
         }
       });
       this.open = true;
-
     },
-    /** 淇敼鎸夐挳鎿嶄綔 */
     handleUpdate(row) {
-      console.log('璋冪敤浜唄andleUpdate');
-
       this.reset();
       this.getData();
-      // this.form = row;
       const proId = row.proId || this.ids;
       this.proParent = false;
       this.isPriceDisabled = false;
       getProject(proId).then((response) => {
         this.form = response.data;
-        if (this.form.proParentId === "0") {
-          this.showPrise = true;
-          this.showRentPrise = false;
-        } else {
-          this.showPrise = false;
-          this.showRentPrise = true;
-        }
-        // this.form.deptId = Number(this.form.deptId);
-        if (this.form.proStandard === 0) {
-          this.showPrise = true;
-          this.showRentPrise = false;
-        } else {
-          this.showPrise = false;
-          this.showRentPrise = true;
-        }
+        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 != null) {
+        if (this.form.tjStandardList) {
           this.form.tjStandardList.forEach((item) => {
-            if (item.tjSex === 0 || item.tjSex === "鐢�") {
-              item.tjSex = "鐢�";
-            } else if (item.tjSex === 1 || item.tjSex === "濂�") {
-              item.tjSex = "濂�";
-            } else {
-              item.tjSex = null;
-            }
-            if (item.tjType === 0) {
-              item.tjType = "濠村効";
-            }
-            if (item.tjType === 1) {
-              item.tjType = "骞煎効";
-            }
-            if (item.tjType === 2) {
-              item.tjType = "鍎跨";
-            }
-            if (item.tjType === 3) {
-              item.tjType = "灏戝勾";
-            }
-            if (item.tjType === 4) {
-              item.tjType = "闈掑勾";
-            }
-            if (item.tjType === 5) {
-              item.tjType = "涓勾";
-            }
-            if (item.tjType === 6) {
-              item.tjType = "鑰佸勾";
-            }
+            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) => {
@@ -1253,10 +1058,6 @@
         this.title = "浣撴椤圭洰淇℃伅缁存姢";
       });
     },
-    changeValue(value) {
-      // this.form.deptName = value;
-      this.form.deptId = value;
-    },
     getSelectValue(val) {
       this.form.consumablesList.forEach((formitem) => {
         if (formitem.makings === val) {
@@ -1270,40 +1071,20 @@
         }
       });
     },
-
-    // sex(sval) {
-    //   if (this.form.tjStandardList) {
-    //     this.form.tjStandardList.forEach((sitem) => {
-    //       if (sitem.tjSex === "鐢�") {
-    //         sitem.tjSex = 0;
-    //       } else {
-    //         sitem.tjSex = 1;
-    //       }
-    //     });
-    //   }
-    // },
-
-    /** 鎻愪氦鎸夐挳 */
     submitForm() {
       this.noclick = true;
-      this.$refs["form"].validate(valid => {
+      this.$refs["form"].validate((valid) => {
         if (valid) {
           const isUpdate = this.form.proId != null;
-
-          // 澶勭悊鎬у埆鍜屽勾榫勭粍鐨勮浆鎹�
           if (this.form.tjStandardList) {
-            this.form.tjStandardList.forEach(item => {
+            this.form.tjStandardList.forEach((item) => {
               item.tjSex = item.tjSex === "鐢�" || item.tjSex === "0" ? "0" : (item.tjSex === "濂�" || item.tjSex === "1" ? "1" : null);
               item.tjType = {
                 "濠村効": 0, "骞煎効": 1, "鍎跨": 2, "灏戝勾": 3, "闈掑勾": 4, "涓勾": 5, "鑰佸勾": 6
               }[item.tjType] || null;
             });
           }
-
-          // 璁剧疆 lisXmbm
           this.form.lisXmbm = this.form.lisXmbm;
-
-          // 鏍规嵁 key 鍊奸�夋嫨涓嶅悓鐨勬搷浣滄祦绋�
           if (this.key === "N") {
             this.processSubmission(isUpdate, false);
           } else if (this.key === "Y") {
@@ -1312,42 +1093,44 @@
           }
         }
       });
+      this.deptName = "";
+      // 鎵嬪姩璋冪敤杩囨护鏂规硶锛堥渶绛夊緟 DOM 鏇存柊锛�
+      this.$nextTick(() => {
+        this.$refs.tree1.filter(this.deptName);
+      });
     },
-
     processSubmission(isUpdate, isY) {
       if (isUpdate) {
-        updateProject(this.form).then(response => {
+        updateProject(this.form).then((response) => {
           this.$modal.msgSuccess("淇敼鎴愬姛");
           this.handleSuccess(isY);
         });
       } else {
-        // 鏂板閫昏緫
         if (this.form.proParentId === 0) {
           this.form.tjStandardList = null;
         } else {
           this.form.consumablesList = null;
         }
-
-        if (this.form.deptId === null || this.form.proParentId === null) {
+        if (!this.form.deptId || this.form.proParentId == null) {
           this.$message.error("璇峰~鍐欑埗椤瑰悕绉版垨绉戝鍚嶇О");
           this.open = true;
         } else {
-          addProject(this.form).then(response => {
+          addProject(this.form).then((response) => {
             this.$modal.msgSuccess("鏂板鎴愬姛");
             this.handleSuccess(isY);
           });
         }
       }
     },
-
     handleSuccess(isY) {
       this.cancel();
       this.getList();
       if (this.proParent || isY) {
-        this.getDeptTree();
+        this.getDeptTree().then(() => {
+          this.precomputePinyin();
+        });
       }
     },
-    // 鏀惰垂椤圭洰纭
     submit() {
       this.ChangeList.forEach((item) => {
         this.form.proPrice = item.ckdj;
@@ -1358,13 +1141,11 @@
       });
       this.dialogTableVisible = false;
     },
-    /** 鍒犻櫎鎸夐挳鎿嶄綔 */
     handleDelete(row) {
       const proIds = row.proId || this.ids;
       this.$modal
         .confirm('鏄惁纭鍒犻櫎浣撴椤圭洰缂栧彿涓�"' + proIds + '"鐨勬暟鎹」锛�')
-        .then(function () {
-          // return delProject(proIds);
+        .then(() => {
           return delProject(proIds).then((response) => {
             if (response.msg === "璇ラ」鐩鍦ㄤ娇鐢ㄦ殏鏃朵笉鑳藉垹闄�") {
               Message.warning(response.msg);
@@ -1378,38 +1159,29 @@
         })
         .catch(() => { });
     },
-    /** 瀵煎嚭鎸夐挳鎿嶄綔 */
     handleExport() {
       this.download(
         "hosp/project/export",
-        {
-          ...this.queryParams,
-        },
+        { ...this.queryParams },
         `project_${new Date().getTime()}.xlsx`
       );
     },
   },
 };
 </script>
+
 <style scoped>
 .scrollable-container {
   width: 200px;
-  /* 璁剧疆瀹瑰櫒鐨勫搴� */
   height: 629px;
-  /* 璁剧疆瀹瑰櫒鐨勯珮搴� */
   overflow: auto;
-  /* 鍏佽鍐呭婧㈠嚭鏃舵樉绀烘粴鍔ㄦ潯 */
   border: 1px solid #ccc;
-  /* 鍙�夛細娣诲姞杈规浠ユ洿濂藉湴鏄剧ず瀹瑰櫒 */
   position: relative;
-  /* 鍙�夛細浣垮鍣ㄥ唴鐨勭粷瀵瑰畾浣嶅厓绱犺兘澶熸纭樉绀� */
 }
 
 .content {
   width: 1000px;
-  /* 璁剧疆鍐呭鐨勫搴︼紝浠ヨЕ鍙戞按骞虫粴鍔ㄦ潯 */
   height: 1000px;
-  /* 璁剧疆鍐呭鐨勯珮搴︼紝浠ヨЕ鍙戝瀭鐩存粴鍔ㄦ潯 */
 }
 
 .el-table__header-wrapper .el-checkbox {
@@ -1453,4 +1225,4 @@
 .el-scrollbar__wrap {
   overflow-x: hidden;
 }
-</style>
+</style>
\ No newline at end of file

--
Gitblit v1.8.0