From 8022f7036945b75f82f2dfc43055623f81ed98f6 Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期五, 23 五月 2025 22:42:56 +0800
Subject: [PATCH] yxh

---
 src/views/project/components/orgselect/index.vue |  117 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 71 insertions(+), 46 deletions(-)

diff --git a/src/views/project/components/orgselect/index.vue b/src/views/project/components/orgselect/index.vue
index cc71e07..be20106 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"
@@ -17,7 +17,7 @@
       value-key="organizationid"
       allow-create
       reserve-keyword
-      :placeholder="placeholder ? placeholder : '璇疯緭鍏ユ満鏋勫悕绉�'"
+      :placeholder="placeholder ? placeholder : '璇烽�夋嫨'"
       class="full-block"
       ref="selecter"
     >
@@ -33,7 +33,7 @@
 </template>
 
 <script>
-import { listOrganization,listReportname } from "@/api/project/organization";
+import { listOrganization, listReportname } from "@/api/project/organization";
 
 export default {
   name: "OrgSelecter",
@@ -41,66 +41,73 @@
   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: [],
+      // dataList: [],
       tempList: [],
       myValue: this.multiple ? [] : "",
       focusEvents: {
         func: () => {},
-        loaded: false,
-      },
+        loaded: false
+      }
     };
   },
   mounted() {
@@ -120,40 +127,52 @@
     }
   },
   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.dataList.push(...arr);
+        if (this.isAll) {
+          let all = {
+            organizationid: "",
+            organizationname: "鍏ㄩ儴"
+          };
+          this.dataList.unshift(all);
+        }
+        this.tempList = this.dataList.map(item => item);
+        this.focusEvents.loaded = true;
+        this.isLoading = false;
+        return;
+      }
 
       listOrganization(searchData)
-        .then((response) => {
+        .then(response => {
           this.dataList.push(...response.rows);
           if (this.isAll) {
             let all = {
               organizationid: "",
-              organizationname: "鍏ㄩ儴",
+              organizationname: "鍏ㄩ儴"
             };
             this.dataList.unshift(all);
           }
-          this.tempList = this.dataList.map(item=>item);
+          this.tempList = this.dataList.map(item => item);
           this.focusEvents.loaded = true;
         })
-        .catch((error) => {
+        .catch(error => {
           // 鏆傛棤澶勭悊
         })
         .finally(() => {
@@ -163,10 +182,10 @@
 
     getOptionByValue(key) {
       let outValue = null;
-      this.dataList.forEach((e) => {
-          if (e.organizationid == key) {
-            outValue = e;
-          }
+      this.dataList.forEach(e => {
+        if (e.organizationid == key) {
+          outValue = e;
+        }
       });
 
       return outValue;
@@ -175,7 +194,7 @@
     filterMethod(val) {
       this.myValue = val;
       if (val) {
-        this.dataList = this.tempList.filter((item) => {
+        this.dataList = this.tempList.filter(item => {
           if (
             (item.PYM &&
               !!~item.PYM.toUpperCase().indexOf(val.toUpperCase())) ||
@@ -190,7 +209,7 @@
           }
         });
       } else {
-        this.dataList = this.tempList.map(item=>item);
+        this.dataList = this.tempList.map(item => item);
       }
     },
     focus() {
@@ -211,20 +230,20 @@
     defaultInit(defaultItem, defaultItemName) {
       if (defaultItem && defaultItemName) {
         let list = this.dataList.filter(
-          (r) =>
+          r =>
             r.organizationid == defaultItem &&
             r.organizationname == defaultItemName
         );
         if (list.length == 0) {
           let data = {
             organizationname: defaultItemName,
-            organizationid: defaultItem,
+            organizationid: defaultItem
           };
           this.dataList.push(data);
         }
       }
-      this.tempList = this.dataList.map(item=>item);
-    },
+      this.tempList = this.dataList.map(item => item);
+    }
   },
   computed: {},
   watch: {
@@ -235,9 +254,15 @@
     myValue(newVal) {
       this.$emit("input", newVal);
       this.$emit("change", newVal);
-    },
-  },
+    }
+  }
 };
 </script>
 
-<style></style>
+<style lang="scss" scoped>
+::v-deep.selectclass .el-select {
+  display: inline-block;
+  position: relative;
+  width: 90%;
+}
+</style>

--
Gitblit v1.9.3