فهرست منبع

转换数据缓存读取时机修改

cfort 2 سال پیش
والد
کامیت
4fddc972cd
2فایلهای تغییر یافته به همراه536 افزوده شده و 539 حذف شده
  1. 408 412
      src/business/platform/org/selector/index.vue
  2. 128 127
      src/utils/remote.js

+ 408 - 412
src/business/platform/org/selector/index.vue

@@ -1,29 +1,29 @@
 <template>
-  <div>
-    <ibps-selector
-      :items="items"
-      :multiple="multiple"
-      :placeholder="placeholder"
-      :readonly="readonly"
-      :readonly-text="readonlyText"
-      :disabled="disabled"
-      :disabled-icon="disabledIcon"
-      :show-placeholder="showPlaceholder"
-      @click="handleSelectorClick"
-      @remove="handleSelectorRemove"
-    />
-    <org-compose-selector-dialog
-      ref="composeSelectorDialog"
-      :visible="selectorVisible"
-      :form-data="formData"
-      :type="type"
-      :value="selectorValue"
-      :filter="filter"
-      :multiple="multiple"
-      @close="visible=>selectorVisible=visible"
-      @action-event="handleSelectorActionEvent"
-    />
-  </div>
+    <div>
+        <ibps-selector
+            :items="items"
+            :multiple="multiple"
+            :placeholder="placeholder"
+            :readonly="readonly"
+            :readonly-text="readonlyText"
+            :disabled="disabled"
+            :disabled-icon="disabledIcon"
+            :show-placeholder="showPlaceholder"
+            @click="handleSelectorClick"
+            @remove="handleSelectorRemove"
+        />
+        <org-compose-selector-dialog
+            ref="composeSelectorDialog"
+            :visible="selectorVisible"
+            :form-data="formData"
+            :type="type"
+            :value="selectorValue"
+            :filter="filter"
+            :multiple="multiple"
+            @close="visible=>selectorVisible=visible"
+            @action-event="handleSelectorActionEvent"
+        />
+    </div>
 </template>
 <script>
 import { transfer as transferEmployee, get as getEmployee } from '@/api/platform/org/employee'
@@ -40,411 +40,407 @@ import OrgComposeSelectorDialog from './dialog'
 import { TRANSFER_DATA } from '@/constant'
 
 export default {
-  components: {
-    IbpsSelector,
-    OrgComposeSelectorDialog
-  },
-  inject: {
-    elForm: {
-      default: ''
-    },
-    elFormItem: {
-      default: ''
-    }
-  },
-  mixins: [emitter],
-  props: {
-    type: {
-      type: String,
-      default: 'employee'
-    },
-    value: {
-      type: [String, Number, Array, Object]
-    },
-    // 存储类型 :
-    // ①、id:只存储id 字符串,
-    // ②、json: json字符串,
-    // ③、 array:存储数组数据(完整数据,包含key和value)。
-    // ④、 bind:绑定ID,需要回调和返回
-    store: {
-      type: String,
-      default: 'id',
-      validator: function(value) {
-        return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
-      }
-    },
-    storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
-      type: String,
-      default: ','
-    },
-    multiple: { // 是否多选
-      type: Boolean,
-      default: false
-    },
-    placeholder: { // 输入框占位文本
-      type: String,
-      default: '请选择'
-    },
-    labelKey: {
-      type: String,
-      default: 'name'
-    },
-    valueKey: {
-      type: String,
-      default: 'id'
-    },
-    disabled: { // 禁用
-      type: Boolean,
-      default: false
-    },
-    disabledIcon: { // 禁用有图标
-      type: Boolean,
-      default: false
-    },
-    readonly: {
-      type: Boolean,
-      default: false
-    },
-    filter: {
-      type: Array,
-      default: () => []
-    },
-    readonlyText: {
-      type: String,
-      default: 'original'
-    },
-    showPlaceholder: { // 是否显示占位符
-      type: Boolean,
-      default: false
-    },
-    formData: Object
-  },
-  data() {
-    return {
-      selectorVisible: false,
-      selectorValue: this.multiple ? [] : {},
-      cacheData: {},
-      bindIdValue: ''
-    }
-  },
-  computed: {
-    items() {
-      if (this.$utils.isEmpty(this.selectorValue)) return []
-      if (this.multiple) {
-        return this.selectorValue.map(data => {
-          return data[this.labelKey] || ''
-        })
-      } else {
-        return [this.selectorValue[this.labelKey] || '']
-      }
-    }
-  },
-  watch: {
-    value: {
-      handler(val, oldVal) {
-        this.initData()
-        if (!valueEquals(val, oldVal)) {
-          this.dispatch('ElFormItem', 'el.form.change', val)
+    components: {
+        IbpsSelector,
+        OrgComposeSelectorDialog
+    },
+    inject: {
+        elForm: {
+            default: ''
+        },
+        elFormItem: {
+            default: ''
         }
-      },
-      immediate: true
-    }
-  },
-  methods: {
-    /**
-     * 初始化数据
-     */
-    initData() {
-      const data = this.getArrayValue(this.value)
-      this.selectorValue = this.multiple ? [] : {}
-      if (this.$utils.isEmpty(data)) {
-        return
-      }
-      data.forEach(v => {
-        if (this.cacheData[v]) {
-          this.setSelectorValue(v)
-        } else {
-          this.getDataInfo(v)
-        }
-      })
-    },
-    setCacheData() {
-      if (this.$utils.isEmpty(this.selectorValue)) return
-      const data = this.multiple ? this.selectorValue : [this.selectorValue]
-      data.forEach(v => {
-        this.cacheData[v[this.valueKey]] = v
-      })
     },
-    setSelectorValue(v) {
-      if (this.multiple) {
-        this.selectorValue.push(this.cacheData[v])
-      } else {
-        this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
-      }
-    },
-    /**
-     * 获得数组数据
-     */
-    getArrayValue(value, bindId) {
-      if (this.$utils.isEmpty(value)) {
-        return []
-      }
-      if (this.store === 'json') { // json
-        return this.parseJsonData(value)
-      } else if (this.store === 'id') { // id
-        // 可能是json数据
-        if (this.$utils.isJSON(value)) {
-          return this.parseJsonData(value)
-        } else {
-          return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
-        }
-      } else if (this.store === 'bind') { // 绑定bind
-        if (this.$utils.isJSON(value)) {
-          return this.parseJsonData(value)
-        } else {
-          return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
+    mixins: [emitter],
+    props: {
+        type: {
+            type: String,
+            default: 'employee'
+        },
+        value: {
+            type: [String, Number, Array, Object]
+        },
+        // 存储类型 :
+        // ①、id:只存储id 字符串,
+        // ②、json: json字符串,
+        // ③、 array:存储数组数据(完整数据,包含key和value)。
+        // ④、 bind:绑定ID,需要回调和返回
+        store: {
+            type: String,
+            default: 'id',
+            validator: function (value) {
+                return ['id', 'json', 'array', 'arrayId', 'bind'].indexOf(value) !== -1
+            }
+        },
+        storeSeparator: { // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        multiple: { // 是否多选
+            type: Boolean,
+            default: false
+        },
+        placeholder: { // 输入框占位文本
+            type: String,
+            default: '请选择'
+        },
+        labelKey: {
+            type: String,
+            default: 'name'
+        },
+        valueKey: {
+            type: String,
+            default: 'id'
+        },
+        disabled: { // 禁用
+            type: Boolean,
+            default: false
+        },
+        disabledIcon: { // 禁用有图标
+            type: Boolean,
+            default: false
+        },
+        readonly: {
+            type: Boolean,
+            default: false
+        },
+        filter: {
+            type: Array,
+            default: () => []
+        },
+        readonlyText: {
+            type: String,
+            default: 'original'
+        },
+        showPlaceholder: { // 是否显示占位符
+            type: Boolean,
+            default: false
+        },
+        formData: Object
+    },
+    data () {
+        return {
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            cacheData: {},
+            bindIdValue: ''
         }
-      } else { // array
-        return value.map((d) => {
-          return d[this.valueKey]
-        })
-      }
     },
-    parseJsonData(value) {
-      try {
-        const data = this.$utils.parseData(value)
-        const result = []
-        if (Array.isArray(data)) {
-          data.forEach(d => {
-            this.cacheData[d[this.valueKey]] = d
-            const node = d[this.valueKey]
-            if (node) result.push(node)
-          })
-        } else {
-          this.cacheData[data[this.valueKey]] = data
-          result.push(data[this.valueKey])
+    computed: {
+        items () {
+            if (this.$utils.isEmpty(this.selectorValue)) return []
+            if (this.multiple) {
+                return this.selectorValue.map(data => {
+                    return data[this.labelKey] || ''
+                })
+            } else {
+                return [this.selectorValue[this.labelKey] || '']
+            }
         }
-        return result
-      } catch (error) {
-        console.warn(error)
-        return []
-      }
     },
-    getStoreValue(value) {
-      const res = []
-      if (this.store === 'json') { // json
-        if (this.$utils.isEmpty(value)) {
-          return ''
-        }
-        if (this.multiple) {
-          value.forEach(v => {
-            const o = {}
-            o[this.valueKey] = v[this.valueKey]
-            o[this.labelKey] = v[this.labelKey]
-            res.push(o)
-          })
-          return JSON.stringify(res)
-        } else {
-          const o = {}
-          o[this.valueKey] = value[this.valueKey]
-          o[this.labelKey] = value[this.labelKey]
-          return JSON.stringify(o)
+    watch: {
+        value: {
+            handler (val, oldVal) {
+                this.initData()
+                if (!valueEquals(val, oldVal)) {
+                    this.dispatch('ElFormItem', 'el.form.change', val)
+                }
+            },
+            immediate: true
         }
-      } else if (this.store === 'id') { // id
-        if (this.$utils.isEmpty(value)) {
-          return ''
-        }
-        if (this.multiple) {
-          value.forEach(v => {
-            res.push(v[this.valueKey])
-          })
-        } else {
-          res.push(value[this.valueKey])
-        }
-        return res.join(this.storeSeparator)
-      } else if (this.store === 'bind') { // 绑定bind
-        const bindIdValue = []
-        value.forEach(v => {
-          bindIdValue.push(v[this.valueKey])
-        })
-        this.bindIdValue = bindIdValue.join(this.storeSeparator)
-
-        return this.bindIdValue
-      } else { // 数组 array
-        return value || []
-      }
     },
-    getValue() {
-      return this.getStoreValue(this.selectorValue)
-    },
-    getDataInfo(id) {
-      const type = this.type
-      if (TRANSFER_DATA === 'transfer') {
-        this.getTransferData(type, id)
-      } else {
-        this.getRemoteData(type, id)
-      }
-    },
-    setRemoteData(data) {
-      if (this.$utils.isNotEmpty(data)) {
-        this.cacheData[data[this.valueKey]] = data
-        this.setSelectorValue(data[this.valueKey])
-      }
-    },
-    getTransferData(type, id) {
-      remoteTransRequest(type + 'id', id).then(idset => {
-        const ids = Array.from(idset)
-        remoteRequest(type + 'ids', ids, () => {
-          return this.getRemoteTransFunc(type, ids)
-        }).then(response => {
-          const responseData = response.data
-          const data = responseData[id]
-          data[this.valueKey] = id
-          this.setRemoteData(data)
-        }).catch(() => {
-        })
-      })
-    },
-
-    getRemoteTransFunc(type, ids) {
-      return new Promise((resolve, reject) => {
-        switch (type) {
-          case 'employee':// 员工
-          case 'user':
-            transferEmployee({
-              'ids': ids
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+    methods: {
+        /**
+         * 初始化数据
+         */
+        initData () {
+            const data = this.getArrayValue(this.value)
+            this.selectorValue = this.multiple ? [] : {}
+            if (this.$utils.isEmpty(data)) {
+                return
+            }
+            data.forEach(v => {
+                if (this.cacheData[v]) {
+                    this.setSelectorValue(v)
+                } else {
+                    this.getDataInfo(v)
+                }
             })
-            break
-
-          case 'org':// 组织
-            transferOrg({
-              'ids': ids
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
-            })
-            break
-          case 'position':// 岗位
-            transferPosition({
-              'ids': ids
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+        },
+        setCacheData () {
+            if (this.$utils.isEmpty(this.selectorValue)) return
+            const data = this.multiple ? this.selectorValue : [this.selectorValue]
+            data.forEach(v => {
+                this.cacheData[v[this.valueKey]] = v
             })
-            break
-          case 'role':// 角色
-            transferRole({
-              'ids': ids
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
-            })
-            break
-          default:
-            break
-        }
-      })
-    },
+        },
+        setSelectorValue (v) {
+            if (this.multiple) {
+                this.selectorValue.push(this.cacheData[v])
+            } else {
+                this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
+            }
+        },
+        /**
+         * 获得数组数据
+         */
+        getArrayValue (value, bindId) {
+            if (this.$utils.isEmpty(value)) {
+                return []
+            }
+            if (this.store === 'json') { // json
+                return this.parseJsonData(value)
+            } else if (this.store === 'id') { // id
+                // 可能是json数据
+                if (this.$utils.isJSON(value)) {
+                    return this.parseJsonData(value)
+                } else {
+                    return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
+                }
+            } else if (this.store === 'bind') { // 绑定bind
+                if (this.$utils.isJSON(value)) {
+                    return this.parseJsonData(value)
+                } else {
+                    return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
+                }
+            } else { // array
+                return value.map((d) => {
+                    return d[this.valueKey]
+                })
+            }
+        },
+        parseJsonData (value) {
+            try {
+                const data = this.$utils.parseData(value)
+                const result = []
+                if (Array.isArray(data)) {
+                    data.forEach(d => {
+                        this.cacheData[d[this.valueKey]] = d
+                        const node = d[this.valueKey]
+                        if (node) result.push(node)
+                    })
+                } else {
+                    this.cacheData[data[this.valueKey]] = data
+                    result.push(data[this.valueKey])
+                }
+                return result
+            } catch (error) {
+                console.warn(error)
+                return []
+            }
+        },
+        getStoreValue (value) {
+            const res = []
+            if (this.store === 'json') { // json
+                if (this.$utils.isEmpty(value)) {
+                    return ''
+                }
+                if (this.multiple) {
+                    value.forEach(v => {
+                        const o = {}
+                        o[this.valueKey] = v[this.valueKey]
+                        o[this.labelKey] = v[this.labelKey]
+                        res.push(o)
+                    })
+                    return JSON.stringify(res)
+                } else {
+                    const o = {}
+                    o[this.valueKey] = value[this.valueKey]
+                    o[this.labelKey] = value[this.labelKey]
+                    return JSON.stringify(o)
+                }
+            } else if (this.store === 'id') { // id
+                if (this.$utils.isEmpty(value)) {
+                    return ''
+                }
+                if (this.multiple) {
+                    value.forEach(v => {
+                        res.push(v[this.valueKey])
+                    })
+                } else {
+                    res.push(value[this.valueKey])
+                }
+                return res.join(this.storeSeparator)
+            } else if (this.store === 'bind') { // 绑定bind
+                const bindIdValue = []
+                value.forEach(v => {
+                    bindIdValue.push(v[this.valueKey])
+                })
+                this.bindIdValue = bindIdValue.join(this.storeSeparator)
 
-    getRemoteData(type, id) {
-      remoteRequest(type + 'id', id, () => {
-        return this.getRemoteByIdFunc(type, id)
-      }).then(response => {
-        const data = response.data
-        this.setRemoteData(data)
-      }).catch(() => {
-      })
-    },
-    getRemoteByIdFunc(type, id) {
-      return new Promise((resolve, reject) => {
-        switch (type) {
-          case 'employee':// 员工
-          case 'user':
-            getEmployee({
-              employeeId: id
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+                return this.bindIdValue
+            } else { // 数组 array
+                return value || []
+            }
+        },
+        getValue () {
+            return this.getStoreValue(this.selectorValue)
+        },
+        getDataInfo (id) {
+            const type = this.type
+            if (TRANSFER_DATA === 'transfer') {
+                this.getTransferData(type, id)
+            } else {
+                this.getRemoteData(type, id)
+            }
+        },
+        setRemoteData (data) {
+            if (this.$utils.isNotEmpty(data)) {
+                this.cacheData[data[this.valueKey]] = data
+                this.setSelectorValue(data[this.valueKey])
+            }
+        },
+        getTransferData (type, id) {
+            remoteTransRequest(type + 'id', id).then(idset => {
+                const ids = Array.from(idset)
+                remoteRequest(type + 'ids', ids, () => {
+                    return this.getRemoteTransFunc(type, ids)
+                }).then(response => {
+                    const responseData = response.data
+                    const data = responseData[id]
+                    data[this.valueKey] = id
+                    this.setRemoteData(data)
+                }).catch(() => {
+                })
             })
-            break
+        },
+        getRemoteTransFunc (type, ids) {
+            return new Promise((resolve, reject) => {
+                switch (type) {
+                    case 'employee':// 员工
+                    case 'user':
+                        transferEmployee({
+                            'ids': ids
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
 
-          case 'org':// 组织
-            getOrg({
-              orgId: id
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+                    case 'org':// 组织
+                        transferOrg({
+                            'ids': ids
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    case 'position':// 岗位
+                        transferPosition({
+                            'ids': ids
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    case 'role':// 角色
+                        transferRole({
+                            'ids': ids
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    default:
+                        break
+                }
             })
-            break
-          case 'position':// 岗位
-            getPosition({
-              positionId: id
+        },
+        getRemoteData (type, id) {
+            remoteRequest(type + 'id', id, () => {
+                return this.getRemoteByIdFunc(type, id)
             }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+                const data = response.data
+                this.setRemoteData(data)
+            }).catch(() => {
             })
-            break
-          case 'role':// 角色
-            getRole({
-              roleId: id
-            }).then(response => {
-              resolve(response)
-            }).catch((error) => {
-              reject(error)
+        },
+        getRemoteByIdFunc (type, id) {
+            return new Promise((resolve, reject) => {
+                switch (type) {
+                    case 'employee':// 员工
+                    case 'user':
+                        getEmployee({
+                            employeeId: id
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+
+                    case 'org':// 组织
+                        getOrg({
+                            orgId: id
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    case 'position':// 岗位
+                        getPosition({
+                            positionId: id
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    case 'role':// 角色
+                        getRole({
+                            roleId: id
+                        }).then(response => {
+                            resolve(response)
+                        }).catch((error) => {
+                            reject(error)
+                        })
+                        break
+                    default:
+                        break
+                }
             })
-            break
-          default:
-            break
+        },
+        // ===================事件处理=========
+        handleSelectorClick () {
+            this.selectorVisible = true
+            this.initData()
+        },
+        handleSelectorRemove (index) {
+            if (this.multiple) {
+                this.selectorValue.splice(index, 1)
+            } else {
+                this.selectorValue = {}
+            }
+            this.handleInput()
+        },
+        handleSelectorActionEvent (buttonKey, data, type) {
+            let val
+            switch (buttonKey) {
+                case 'confirm':// 确定
+                    this.selectorVisible = false
+                    this.selectorValue = data
+                    this.setCacheData() // 设置缓存数据
+                    this.handleInput()
+                    val = this.getValue()
+                    this.emitChangeLinkData(val, type)
+                    break
+            }
+        },
+        handleInput () {
+            const value = this.getValue()
+            this.$emit('input', value)
+        },
+        emitChangeLinkData (val, type) {
+            if (!valueEquals(this.value, val)) {
+                this.$emit('change-link-data', val, this.selectorValue, type)
+            }
         }
-      })
-    },
-    // ===================事件处理=========
-
-    handleSelectorClick() {
-      this.selectorVisible = true
-      this.initData()
-    },
-    handleSelectorRemove(index) {
-      if (this.multiple) {
-        this.selectorValue.splice(index, 1)
-      } else {
-        this.selectorValue = {}
-      }
-      this.handleInput()
-    },
-
-    handleSelectorActionEvent(buttonKey, data, type) {
-      let val
-      switch (buttonKey) {
-        case 'confirm':// 确定
-          this.selectorVisible = false
-          this.selectorValue = data
-          this.setCacheData() // 设置缓存数据
-          this.handleInput()
-          val = this.getValue()
-          this.emitChangeLinkData(val, type)
-          break
-      }
-    },
-    handleInput() {
-      const value = this.getValue()
-      this.$emit('input', value)
-    },
-    emitChangeLinkData(val, type) {
-      if (!valueEquals(this.value, val)) {
-        this.$emit('change-link-data', val, this.selectorValue, type)
-      }
     }
-  }
 }
 </script>

+ 128 - 127
src/utils/remote.js

@@ -9,74 +9,74 @@ const cacheTime = new Map()
  * @param repeatRequest 是否重复请求
  * @returns {Promise<any>|Promise<T | never>}
  */
-export function remoteRequest(prefix, params, remoteFunc, repeatRequest = true, requestTime = 2000) {
-  if (params == null) {
-    return new Promise((resolve) => {
-      resolve([])
-    })
-  }
-
-  const timeKey = prefix + '#' + JSON.stringify(params)
-  let time = ''
-  if (repeatRequest) {
-    const curTime = new Date().getTime()
-    time = cacheTime.get(timeKey)
-    if (time == null) {
-      cacheTime.set(timeKey, curTime)
-      time = curTime
+export function remoteRequest (prefix, params, remoteFunc, repeatRequest = true, requestTime = 2000) {
+    if (params == null) {
+        return new Promise((resolve) => {
+            resolve([])
+        })
     }
 
-    if (curTime - requestTime >= time) { // 2秒内的请求都重新请求
-      // 清除缓存换个请求
-      cacheTime.clear()
-      cacheTime.set(timeKey, curTime)
-      time = curTime
+    const timeKey = prefix + '#' + JSON.stringify(params)
+    let time = ''
+    if (repeatRequest) {
+        const curTime = new Date().getTime()
+        time = cacheTime.get(timeKey)
+        if (time == null) {
+            cacheTime.set(timeKey, curTime)
+            time = curTime
+        }
+
+        if (curTime - requestTime >= time) { // 2秒内的请求都重新请求
+            // 清除缓存换个请求
+            cacheTime.clear()
+            cacheTime.set(timeKey, curTime)
+            time = curTime
+        }
     }
-  }
-
-  const key = timeKey + '#' + time
 
-  // 远程获取
-  let item = cache.get(key)
-  if (item == null || item.error === true) {
-    // 还没加载过
-    if (item == null) {
-      item = { loading: true, callbacks: [] }
-      cache.set(key, item)
+    const key = timeKey + '#' + time
+
+    // 远程获取
+    let item = cache.get(key)
+    if (item == null || item.error === true) {
+        // 还没加载过
+        if (item == null) {
+            item = { loading: true, callbacks: [] }
+            cache.set(key, item)
+        }
+
+        item.loading = true
+        item.error = false
+
+        // 远程加载
+        return remoteFunc().then((data) => {
+            // prop mapping
+            item.data = data
+            // 之前注册过的callback全部触发
+            for (const callback of item.callbacks) {
+                callback(item.data)
+            }
+            item.loading = false
+            item.callbacks = []
+            return data
+        }).catch(() => {
+            item.loading = false
+            item.error = true
+        })
+    } else if (item.loading === true) {
+        // 正在加载中,注册callback,等加载完了之后,再统一触发,就只需要向服务器请求一次数据模版
+        return new Promise((resolve) => {
+            const callback = (data) => {
+                resolve(data)
+            }
+            item.callbacks.push(callback)
+        })
+    } else {
+        //  从缓存拿
+        return new Promise((resolve) => {
+            resolve(item.data)
+        })
     }
-
-    item.loading = true
-    item.error = false
-
-    // 远程加载
-    return remoteFunc().then((data) => {
-      // prop mapping
-      item.data = data
-      // 之前注册过的callback全部触发
-      for (const callback of item.callbacks) {
-        callback(item.data)
-      }
-      item.loading = false
-      item.callbacks = []
-      return data
-    }).catch(() => {
-      item.loading = false
-      item.error = true
-    })
-  } else if (item.loading === true) {
-    // 正在加载中,注册callback,等加载完了之后,再统一触发,就只需要向服务器请求一次数据模版
-    return new Promise((resolve) => {
-      const callback = (data) => {
-        resolve(data)
-      }
-      item.callbacks.push(callback)
-    })
-  } else {
-    //  从缓存拿
-    return new Promise((resolve) => {
-      resolve(item.data)
-    })
-  }
 }
 
 const cacheTrans = new Map()
@@ -89,71 +89,72 @@ const cacheTransTime = new Map()
  * @param id 参数配置
  * @returns {Promise<any>|Promise<T | never>}
  */
-export function remoteTransRequest(prefix, id) {
-  const curTime = new Date().getTime()
-  const timeOut = 200
-  let time = cacheTransTime.get(prefix)
-  if (time == null) {
-    cacheTransTime.set(prefix, curTime)
-    time = curTime
-  }
-  if (curTime - timeOut >= time) { // 2秒内的请求都重新请求
-    // 清除缓存换个请求
-    cacheTransTime.clear()
-    cacheTransTime.set(prefix, curTime)
-    time = curTime
-  }
-
-  const key = prefix + '#' + time
-  // 汇总接口
-  let item = cacheTrans.get(key)
-
-  let idVal = id
-  if (Object.prototype.toString.call(id) === '[object Object]') {
-    idVal = JSON.stringify(id)
-  }
-
-  if (item == null || item.error === true) {
-    // 还没加载过
-    if (item == null) {
-      item = { loading: true, ids: new Set(), callbacks: [] }
-      cacheTrans.set(key, item)
+export function remoteTransRequest (prefix, id) {
+    const curTime = new Date().getTime()
+    const timeOut = 200
+    let time = cacheTransTime.get(prefix)
+    if (time == null) {
+        cacheTransTime.set(prefix, curTime)
+        time = curTime
     }
-    item.loading = true
-    item.ids = item.ids.add(idVal)
-
-    const remoteFunc = (ids) => {
-      return new Promise((resolve) => {
-        setTimeout(() => {
-          resolve(ids)
-        }, 100)
-      })
+    if (curTime - timeOut >= time) { // 2秒内的请求都重新请求
+        // 清除缓存换个请求
+        cacheTransTime.clear()
+        cacheTransTime.set(prefix, curTime)
+        time = curTime
     }
 
-    return remoteFunc(item.ids).then((ids) => {
-      item.ids = ids
-      // 之前注册过的callback全部触发
-      for (const callback of item.callbacks) {
-        callback(ids)
-      }
-      item.loading = false
-      item.callbacks = []
-
-      return ids
-    })
-  } else if (item.loading === true) {
-    // 正在加载中,注册callback,等加载完了之后,再统一触发,就只需要向服务器请求一次数据模版
-    return new Promise((resolve) => {
-      const callback = (ids) => {
-        item.ids = ids.add(idVal)
-        resolve(item.ids)
-      }
-      item.callbacks.push(callback)
-    })
-  } else {
-    //  从缓存拿
-    return new Promise((resolve) => {
-      resolve(item.ids)
-    })
-  }
+    const key = prefix + '#' + time
+    // 汇总接口
+    let item = cacheTrans.get(key)
+
+    let idVal = id
+    if (Object.prototype.toString.call(id) === '[object Object]') {
+        idVal = JSON.stringify(id)
+    }
+
+    // 20230814调整缓存判断机制,若缓存中的值与当前id不匹配,则不走缓存
+    if (item == null || item.error === true || (item.loading === false && !item.ids.has(idVal))) {
+        // 还没加载过
+        if (item == null) {
+            item = { loading: true, ids: new Set(), callbacks: [] }
+            cacheTrans.set(key, item)
+        }
+        item.loading = true
+        item.ids = item.ids.add(idVal)
+
+        const remoteFunc = (ids) => {
+            return new Promise((resolve) => {
+                setTimeout(() => {
+                    resolve(ids)
+                }, 100)
+            })
+        }
+
+        return remoteFunc(item.ids).then((ids) => {
+            item.ids = ids
+            // 之前注册过的callback全部触发
+            for (const callback of item.callbacks) {
+                callback(ids)
+            }
+            item.loading = false
+            item.callbacks = []
+
+            return ids
+        })
+    } else if (item.loading === true) {
+        // 正在加载中,注册callback,等加载完了之后,再统一触发,就只需要向服务器请求一次数据模版
+        return new Promise((resolve) => {
+            const callback = (ids) => {
+                item.ids = ids.add(idVal)
+                resolve(item.ids)
+            }
+            item.callbacks.push(callback)
+        })
+    } else {
+        //  从缓存拿
+        return new Promise((resolve) => {
+            resolve(item.ids)
+        })
+    }
 }