lyh
2025-04-09 53c269711fcb59f48fd2acd7e825bebfd31d09e5
src/views/eam/equipment/modules/MaintenanceEquipmentSelect.vue
@@ -19,7 +19,8 @@
      <a-icon type="search" />
    </template>
    <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-option v-for="d in options" :key="d.equipmentId" :value="d.equipmentId">{{ d.equipmentText }}
    </a-select-option>
  </a-select>
</template>
@@ -43,6 +44,11 @@
      default: 20,
      required: false
    },
    maintenanceCategory: {
      type: String,
      default: '',
      required: false
    }
  },
  data() {
    this.loadData = debounce(this.loadData, 800)//消抖
@@ -62,7 +68,9 @@
      immediate: true,
      handler(val) {
        if (!val) {
          this.initDictData();
          this.selectedValue = undefined;
          this.selectedAsyncValue = undefined;
          this.initDictData()
        } else {
          this.initSelectValue()
        }
@@ -71,18 +79,22 @@
  },
  methods: {
    initSelectValue() {
      if(!this.selectedAsyncValue || !this.selectedAsyncValue.key || this.selectedAsyncValue.key!=this.value){
        console.log("这才请求后台")
        getAction(`/eam/maintenanceStandard/listByUser`, { id: this.value }).then(res=>{
          if(res.success){
            if(res.result && res.result.length > 0){
      if (!this.selectedAsyncValue || !this.selectedAsyncValue.key || this.selectedAsyncValue.key != this.value || !this.maintenanceCategory) {
        console.log('这才请求后台')
        getAction(`/eam/maintenanceStandard/listByUser`, {
          id: this.value,
          maintenanceCategory: this.maintenanceCategory
        }).then(res => {
          if (res.success) {
            if (res.result && res.result.length > 0) {
              let obj = {
                key : this.value,
                key: this.value,
                label: res.result[0].text
              }
              this.selectedAsyncValue = {...obj};
              this.selectedAsyncValue = { ...obj }
              this.$emit('autocompleteForm', res.result[0])
            }
            this.options = res.result;
            this.options = res.result
          }
        })
      }
@@ -93,8 +105,14 @@
      const currentLoad = this.lastLoad
      this.options = []
      this.loading = true
      console.log('ssfs', this.selectedAsyncValue)
      console.log('ASGasgsgas', this.maintenanceCategory)
      // 字典code格式:table,text,code
      getAction(`/eam/maintenanceStandard/listByUser`, { keyword: value, pageSize: this.pageSize }).then(res => {
      getAction(`/eam/maintenanceStandard/listByUser`, {
        keyword: value,
        maintenanceCategory: this.maintenanceCategory,
        pageSize: this.pageSize
      }).then(res => {
        this.loading = false
        if (res.success) {
          if (currentLoad != this.lastLoad) {
@@ -111,8 +129,13 @@
    },
    initDictData() {
      //异步一开始也加载一点数据
      console.log('fasfasgasgasgfasg')
      this.loading = true
      getAction(`/eam/maintenanceStandard/listByUser`, { pageSize: this.pageSize, keyword: '' }).then(res => {
      getAction(`/eam/maintenanceStandard/listByUser`, {
        pageSize: this.pageSize,
        keyword: '',
        maintenanceCategory: this.maintenanceCategory
      }).then(res => {
        this.loading = false
        if (res.success) {
          this.options = [...res.result]
@@ -125,17 +148,20 @@
      return option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0
    },
    handleAsyncChange(selectedObj) {
      console.log('selectedObj', selectedObj)
      //update-begin-author:scott date:20201222 for:【搜索】搜索查询组件,删除条件,默认下拉还是上次的缓存数据,不好 JT-191
      if (selectedObj) {
        this.selectedAsyncValue = selectedObj
        //update-begin---author:wangshuai ---date:20221115  for:[issues/4213]JSearchSelectTag改造支持多选------------
        this.selectedValue = selectedObj.key
        this.$emit('autocompleteForm', this.options.find(item => item.equipmentId === selectedObj.key))
        //update-end---author:wangshuai ---date:20221115  for:[issues/4213]JSearchSelectTag改造支持多选------------
      } else {
        this.selectedAsyncValue = null
        this.selectedAsyncValue = undefined
        this.selectedValue = null
        this.options = null
        this.options = []
        this.loadData('')
        this.$emit('autocompleteForm', {})
      }
      this.callback()
      //update-end-author:scott date:20201222 for:【搜索】搜索查询组件,删除条件,默认下拉还是上次的缓存数据,不好 JT-191