From ead85633109bcb3cc8d8b3c6804c280dd6ee1e5d Mon Sep 17 00:00:00 2001
From: WXL <wl_5969728@163.com>
Date: 星期二, 06 一月 2026 11:38:51 +0800
Subject: [PATCH] 省人民维护

---
 src/views/project/components/orgselect/index.vue |  205 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 133 insertions(+), 72 deletions(-)

diff --git a/src/views/project/components/orgselect/index.vue b/src/views/project/components/orgselect/index.vue
index cc71e07..7471f43 100644
--- a/src/views/project/components/orgselect/index.vue
+++ b/src/views/project/components/orgselect/index.vue
@@ -1,5 +1,5 @@
 <template>
-  <div>
+  <div class="selectclass">
     <el-select
       v-model="myValue"
       :loading="isLoading"
@@ -14,16 +14,17 @@
       @focus="focusEvents.func"
       @change="change"
       @blur="changeBlur"
+      @visible-change="handleVisibleChange"
       value-key="organizationid"
       allow-create
       reserve-keyword
-      :placeholder="placeholder ? placeholder : '璇疯緭鍏ユ満鏋勫悕绉�'"
+      :placeholder="placeholder ? placeholder : '璇烽�夋嫨'"
       class="full-block"
       ref="selecter"
     >
       <el-option
-        v-for="(spec, index) in dataList"
-        :key="index"
+        v-for="(spec, index) in displayList"
+        :key="spec.organizationid"
         :label="spec.organizationname"
         :value="spec.organizationid"
       >
@@ -33,7 +34,7 @@
 </template>
 
 <script>
-import { listOrganization,listReportname } from "@/api/project/organization";
+import { listOrganization, listReportname } from "@/api/project/organization";
 
 export default {
   name: "OrgSelecter",
@@ -41,66 +42,75 @@
   props: {
     //Select鍩虹灞炴��
     value: {
-      type: [String, Array],
+      type: [String, Array]
+    },
+    //鑾峰彇鍒楄〃
+    dataList: {
+      type: Array,
+      default: function() {
+        return [];
+      }
     },
     disabled: {
       type: Boolean,
-      default: false,
+      default: false
     },
     clearable: {
       type: Boolean,
-      default: false,
+      default: false
     },
     filterable: {
       type: Boolean,
-      default: true,
+      default: true
     },
     multiple: {
       type: Boolean,
-      default: false,
+      default: false
     },
     multipleLimit: {
       type: Number,
-      default: 0,
+      default: 0
     },
     defaultFirstOption: {
       type: Boolean,
-      default: true,
+      default: true
     },
     size: {
       type: String,
-      default: "small",
+      default: "small"
     },
     placeholder: {
       type: String,
-      default: "",
+      default: ""
     },
     //涓氬姟灞炴��
     lazyLoad: {
       type: Boolean,
-      default: false,
+      default: false
     },
     isAll: {
       type: Boolean,
-      default: false,
+      default: false
     },
     //鏈烘瀯绫诲瀷
     orgType: {
       type: String,
-      default: "",
-    },
+      default: ""
+    }
   },
   data() {
     return {
-      pageData: { pageNum:1,pageSize:100 },
+      pageData: { pageNum: 1, pageSize: 100 },
       isLoading: false,
-      dataList: [],
-      tempList: [],
+      // 涓変釜鐙珛鐨勬暟鎹簮锛岄伩鍏嶇浉浜掓薄鏌�
+      originalList: [], // 瀹屾暣鐨勫師濮嬫暟鎹簮
+      tempList: [],     // 涓棿缂撳瓨鏁版嵁
+      displayList: [],  // 鐢ㄤ簬娓叉煋鏄剧ず鐨勫垪琛�
       myValue: this.multiple ? [] : "",
       focusEvents: {
         func: () => {},
-        loaded: false,
-      },
+        loaded: false
+      }
     };
   },
   mounted() {
@@ -120,79 +130,100 @@
     }
   },
   methods: {
-
     renderSelecter() {
       this.pageData.PageSize = 100;
-      this.dataList = [];
       this.myValue = this.value;
-
       this.getdataList();
     },
 
     //鑾峰彇鏁版嵁
     getdataList() {
       this.isLoading = true;
-      let searchData={
-          organizationtype:this.orgType,//浼犲叆鐨勭被鍨�
-          pageNum:1,
-          pageSize:100000
-      };//鎼滅储鏉′欢
+      let searchData = {
+        organizationtype: this.orgType, //浼犲叆鐨勭被鍨�
+        pageNum: 1,
+        pageSize: 100000
+      }; //鎼滅储鏉′欢
 
-      let userType={"userType":"1"};
+      let userType = { userType: "1" };
+      if (this.orgType == 4) {
+        let arr = this.$store.state.user.organization;
+        this.originalList.push(...arr);
+        if (this.isAll) {
+          let all = {
+            organizationid: "",
+            organizationname: "鍏ㄩ儴"
+          };
+          this.originalList.unshift(all);
+        }
+        // 鍒濆鍖栦笁涓垪琛ㄤ负鐩稿悓鏁版嵁
+        this.tempList = [...this.originalList];
+        this.displayList = [...this.originalList];
+        this.focusEvents.loaded = true;
+        this.isLoading = false;
+        return;
+      }
 
       listOrganization(searchData)
-        .then((response) => {
-          this.dataList.push(...response.rows);
+        .then(response => {
+          this.originalList.push(...response.rows);
           if (this.isAll) {
             let all = {
               organizationid: "",
-              organizationname: "鍏ㄩ儴",
+              organizationname: "鍏ㄩ儴"
             };
-            this.dataList.unshift(all);
+            this.originalList.unshift(all);
           }
-          this.tempList = this.dataList.map(item=>item);
+          // 鍒濆鍖栦笁涓垪琛ㄤ负鐩稿悓鏁版嵁
+          this.tempList = [...this.originalList];
+          this.displayList = [...this.originalList];
           this.focusEvents.loaded = true;
         })
-        .catch((error) => {
-          // 鏆傛棤澶勭悊
+        .catch(error => {
+          console.error("鑾峰彇鏈烘瀯鍒楄〃澶辫触:", error);
         })
         .finally(() => {
           this.isLoading = false;
         });
     },
 
-    getOptionByValue(key) {
-      let outValue = null;
-      this.dataList.forEach((e) => {
-          if (e.organizationid == key) {
-            outValue = e;
-          }
-      });
-
-      return outValue;
-    },
-
+    /**
+     * 鑷畾涔夌瓫閫夋柟娉� - 淇鎼滅储鏃犳晥闂
+     * @param {string} val - 鎼滅储鍏抽敭璇�
+     */
     filterMethod(val) {
-      this.myValue = val;
       if (val) {
-        this.dataList = this.tempList.filter((item) => {
-          if (
-            (item.PYM &&
-              !!~item.PYM.toUpperCase().indexOf(val.toUpperCase())) ||
-            (item.WBM &&
-              !!~item.WBM.toUpperCase().indexOf(val.toUpperCase())) ||
+        // 瀵逛复鏃跺垪琛ㄨ繘琛岀瓫閫夛紝涓嶄慨鏀瑰師濮嬫暟鎹�
+        this.displayList = this.tempList.filter(item => {
+          return (
+            (item.PYM && item.PYM.toUpperCase().includes(val.toUpperCase())) ||
+            (item.WBM && item.WBM.toUpperCase().includes(val.toUpperCase())) ||
             (item.organizationname &&
-              !!~item.organizationname.toUpperCase().indexOf(val.toUpperCase()))
-          ) {
-            return true;
-          } else {
-            return false;
-          }
+             item.organizationname.toUpperCase().includes(val.toUpperCase()))
+          );
         });
       } else {
-        this.dataList = this.tempList.map(item=>item);
+        // 鎼滅储璇嶄负绌烘椂鏄剧ず瀹屾暣鍒楄〃
+        this.displayList = [...this.tempList];
       }
     },
+
+    /**
+     * 澶勭悊涓嬫媺妗嗘樉绀�/闅愯棌浜嬩欢 - 淇鏁版嵁鎭㈠闂
+     * @param {boolean} visible - 鏄惁鍙
+     */
+    handleVisibleChange(visible) {
+      if (!visible) {
+        // 涓嬫媺妗嗗叧闂椂閲嶇疆鏄剧ず鍒楄〃涓哄畬鏁存暟鎹�
+        this.displayList = [...this.originalList];
+        this.tempList = [...this.originalList];
+      }
+    },
+
+    getOptionByValue(key) {
+      return this.originalList.find(item => item.organizationid == key) || null;
+    },
+
     focus() {
       this.$refs.selecter.focus();
     },
@@ -208,23 +239,25 @@
         this.$emit("change", data);
       });
     },
+
     defaultInit(defaultItem, defaultItemName) {
       if (defaultItem && defaultItemName) {
-        let list = this.dataList.filter(
-          (r) =>
+        let list = this.originalList.filter(
+          r =>
             r.organizationid == defaultItem &&
             r.organizationname == defaultItemName
         );
         if (list.length == 0) {
           let data = {
             organizationname: defaultItemName,
-            organizationid: defaultItem,
+            organizationid: defaultItem
           };
-          this.dataList.push(data);
+          this.originalList.push(data);
+          this.tempList = [...this.originalList];
+          this.displayList = [...this.originalList];
         }
       }
-      this.tempList = this.dataList.map(item=>item);
-    },
+    }
   },
   computed: {},
   watch: {
@@ -236,8 +269,36 @@
       this.$emit("input", newVal);
       this.$emit("change", newVal);
     },
-  },
+    // 鐩戝惉props涓殑dataList鍙樺寲
+    dataList: {
+      handler(newList) {
+        if (newList && newList.length > 0) {
+          this.originalList = [...newList];
+          this.tempList = [...newList];
+          this.displayList = [...newList];
+        }
+      },
+      immediate: true,
+      deep: true
+    }
+  }
 };
 </script>
 
-<style></style>
+<style lang="scss" scoped>
+::v-deep.selectclass .el-select {
+  display: inline-block;
+  position: relative;
+  width: 90%;
+}
+
+// 浼樺寲鎼滅储妗嗘牱寮�
+::v-deep.selectclass .el-select__input {
+  min-width: 80px;
+}
+
+// 纭繚閫夐」鍒楄〃姝e父鏄剧ず
+::v-deep.selectclass .el-select-dropdown {
+  z-index: 9999 !important;
+}
+</style>

--
Gitblit v1.9.3