From 67000bf11ea45f2f29177e203e91d42f524faa59 Mon Sep 17 00:00:00 2001
From: zhangherong <571457620@qq.com>
Date: 星期一, 31 三月 2025 16:33:48 +0800
Subject: [PATCH] art: 设备管理-保养标准-编辑功能

---
 src/views/eam/equipment/modules/LxSearchEquipmentSelect.vue |  183 +++++++++++++++------------------------------
 1 files changed, 63 insertions(+), 120 deletions(-)

diff --git a/src/views/eam/equipment/modules/LxSearchEquipmentSelect.vue b/src/views/eam/equipment/modules/LxSearchEquipmentSelect.vue
index 4ec5444..8a4df54 100644
--- a/src/views/eam/equipment/modules/LxSearchEquipmentSelect.vue
+++ b/src/views/eam/equipment/modules/LxSearchEquipmentSelect.vue
@@ -13,148 +13,110 @@
     @change="handleAsyncChange"
     allowClear
     :notFoundContent="loading ? undefined : null"
-    :mode="mode"
+    mode="default"
   >
     <template #suffixIcon>
       <a-icon type="search" />
     </template>
-    <a-spin v-if="loading" slot="notFoundContent" size="small"/>
+    <a-spin v-if="loading" slot="notFoundContent" size="small" />
     <a-select-option v-for="d in options" :key="d.value" :value="d.value">{{ d.text }}</a-select-option>
   </a-select>
 
 </template>
 
 <script>
-import { ajaxGetDictItems,getDictItemsFromCache } from '@/api/api'
-import debounce from 'lodash/debounce';
+import debounce from 'lodash/debounce'
 import { getAction } from '@/api/manage'
 
 export default {
   name: 'LxSearchEquipmentSelect',
-  props:{
+  props: {
     disabled: Boolean,
     value: [String, Number],
-    dictOptions: Array,
-    placeholder:{
-      type:String,
-      default:"璇烽�夋嫨",
-      required:false
+    placeholder: {
+      type: String,
+      default: '璇烽�夋嫨',
+      required: false
     },
-    pageSize:{
+    pageSize: {
       type: Number,
       default: 20,
       required: false
     },
-    mode:{
-      type: String,
-      default: '',
-    },
   },
-  data(){
-    this.loadData = debounce(this.loadData, 800);//娑堟姈
-    this.lastLoad = 0;
+  data() {
+    this.loadData = debounce(this.loadData, 800)//娑堟姈
+    this.lastLoad = 0
     return {
-      loading:false,
-      selectedValue:[],
-      selectedAsyncValue:[],
-      options: [],
+      loading: false,
+      selectedValue: undefined,
+      selectedAsyncValue: undefined,
+      options: []
     }
   },
-  created(){
-    this.initDictData();
+  created() {
+    // this.initDictData()
   },
-  watch:{
-    "value":{
-      immediate:true,
-      handler(val){
-        if(!val){
-          if(val==0){
-            this.initSelectValue()
-          }else{
-            this.selectedValue=[]
-            this.selectedAsyncValue=[]
-          }
-        }else{
+  watch: {
+    'value': {
+      immediate: true,
+      handler(val) {
+        if (!val) {
+          this.initDictData();
+        } else {
           this.initSelectValue()
         }
       }
-    },
+    }
   },
-  methods:{
-    initSelectValue(){
+  methods: {
+    initSelectValue() {
       if(!this.selectedAsyncValue || !this.selectedAsyncValue.key || this.selectedAsyncValue.key!=this.value){
         console.log("杩欐墠璇锋眰鍚庡彴")
-        //update-begin-author:taoyan date:20220112 for: 鏂规硶initSelectValue 鏍规嵁涓嬫媺妗嗗疄闄呭�兼煡璇笅鎷夋鐨勬樉绀虹殑鏂囨湰 鍥犲悗鍙版帴鍙e彧澶勭悊3涓弬鏁帮紝鎵�浠ュ皢杩囨护鏉′欢鍘绘帀
-        // TODO 闅愭偅 鏌ヨ鏁堢巼闂 杩樻槸搴旇鍦ㄥ悗鍙颁綔绛涢��
-        let itemDictStr = this.dict
-        let arr = itemDictStr.split(',')
-        if(arr && arr.length==4){
-          // 鍒犻櫎鏈�鍚庝竴涓厓绱�
-          arr.pop();
-          itemDictStr = arr.join(',')
-        }
-        //update-end-author:taoyan date:20220112 for: 鏂规硶initSelectValue 鏍规嵁涓嬫媺妗嗗疄闄呭�兼煡璇笅鎷夋鐨勬樉绀虹殑鏂囨湰 鍥犲悗鍙版帴鍙e彧澶勭悊3涓弬鏁帮紝鎵�浠ュ皢杩囨护鏉′欢鍘绘帀
-        getAction(`/eam/equipment/asyncLoadEquipment`,{key:this.value}).then(res=>{
+        getAction(`/eam/equipment/asyncLoadEquipment`, { id: this.value }).then(res=>{
           if(res.success){
-            //update-begin---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�------------
-            //鍒ゆ柇鏄惁澶氶��
-            if(this.mode === 'multiple'){
-              if(res.result && res.result.length>0){
-                let itemArray = [];
-                let valueArray = this.value.split(",")
-                for (let i = 0; i < res.result.length; i++) {
-                  itemArray.push({
-                    key:valueArray[i],
-                    label:res.result[i]
-                  })
-                }
-                this.selectedAsyncValue = itemArray
-              }else{
-                this.selectedAsyncValue = []
-                this.selectedValue = []
-              }
-            }else{
+            if(res.result && res.result.length > 0){
               let obj = {
-                key:this.value,
-                label:res.result
+                key : this.value,
+                label: res.result[0].text
               }
-              this.selectedAsyncValue = {...obj}
+              this.selectedAsyncValue = {...obj};
             }
-            //update-end---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�--------------
+            this.options = res.result;
           }
         })
       }
     },
-    loadData(value){
-      console.log("鏁版嵁鍔犺浇",value)
-      this.lastLoad +=1
+    loadData(value) {
+      console.log('鏁版嵁鍔犺浇', value)
+      this.lastLoad += 1
       const currentLoad = this.lastLoad
       this.options = []
-      this.loading=true
+      this.loading = true
       // 瀛楀吀code鏍煎紡锛歵able,text,code
-      getAction(`/eam/equipment/asyncLoadEquipment`,{keyword:value, pageSize: this.pageSize}).then(res=>{
-        this.loading=false
-        if(res.success){
-          if(currentLoad!=this.lastLoad){
+      getAction(`/eam/equipment/asyncLoadEquipment`, { keyword: value, pageSize: this.pageSize }).then(res => {
+        this.loading = false
+        if (res.success) {
+          if (currentLoad != this.lastLoad) {
             return
           }
           this.options = res.result
-          console.log("鎴戞槸绗竴涓�",res)
-        }else{
+          console.log('鎴戞槸绗竴涓�', res)
+        } else {
           this.$message.warning(res.message)
         }
 
       })
 
     },
-    initDictData(){
+    initDictData() {
       //寮傛涓�寮�濮嬩篃鍔犺浇涓�鐐规暟鎹�
-      this.loading=true
-      getAction(`/eam/equipment/asyncLoadEquipment`,{pageSize: this.pageSize, keyword:''}).then(res=>{
-        this.loading=false
-        if(res.success){
-          this.options = res.result
-        }else{
+      this.loading = true
+      getAction(`/eam/equipment/asyncLoadEquipment`, { pageSize: this.pageSize, keyword: '' }).then(res => {
+        this.loading = false
+        if (res.success) {
+          this.options = [...res.result]
+        } else {
           this.$message.warning(res.message)
         }
       })
@@ -162,53 +124,34 @@
     filterOption(input, option) {
       return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
     },
-    handleChange (selectedValue) {
-      console.log("selectedValue",selectedValue)
-      this.selectedValue = selectedValue
-      this.callback()
-    },
-    handleAsyncChange(selectedObj){
+    handleAsyncChange(selectedObj) {
       //update-begin-author:scott date:20201222 for:銆愭悳绱€�戞悳绱㈡煡璇㈢粍浠讹紝鍒犻櫎鏉′欢锛岄粯璁や笅鎷夎繕鏄笂娆$殑缂撳瓨鏁版嵁锛屼笉濂� JT-191
-      if(selectedObj){
+      if (selectedObj) {
         this.selectedAsyncValue = selectedObj
         //update-begin---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�------------
-        if(this.mode ==='multiple'){
-          let keyArray = []
-          for (let i = 0; i < selectedObj.length; i++) {
-            keyArray.push(selectedObj[i].key)
-          }
-          this.selectedValue = keyArray
-        }else{
-          this.selectedValue = selectedObj.key
-        }
+        this.selectedValue = selectedObj.key
         //update-end---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�------------
-      }else{
+      } else {
         this.selectedAsyncValue = null
         this.selectedValue = null
         this.options = null
-        this.loadData("")
+        this.loadData('')
       }
       this.callback()
       //update-end-author:scott date:20201222 for:銆愭悳绱€�戞悳绱㈡煡璇㈢粍浠讹紝鍒犻櫎鏉′欢锛岄粯璁や笅鎷夎繕鏄笂娆$殑缂撳瓨鏁版嵁锛屼笉濂� JT-191
     },
-    callback(){
-      //update-begin---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�------------
-      if(this.mode === 'multiple'){
-        this.$emit('change',  this.selectedValue.join(","));
-      }else{
-        this.$emit('change', this.selectedValue);
-      }
-      //update-end---author:wangshuai ---date:20221115  for锛歔issues/4213]JSearchSelectTag鏀归�犳敮鎸佸閫�------------
+    callback() {
+      this.$emit('change', this.selectedValue)
     },
-    getParentContainer(node){
-      if(typeof this.getPopupContainer === 'function'){
+    getParentContainer(node) {
+      if (typeof this.getPopupContainer === 'function') {
         return this.getPopupContainer(node)
-      } else if(!this.popContainer){
+      } else if (!this.popContainer) {
         return node.parentNode
-      }else{
+      } else {
         return document.querySelector(this.popContainer)
       }
-    },
+    }
 
   },
   model: {

--
Gitblit v1.9.3