@xuekl/cli-components 1.8.0 → 1.9.146

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/XklFormInfo.vue CHANGED
@@ -1,12 +1,13 @@
1
1
  <template>
2
- <el-form class="xkl-form-info" :class="{ 'force-align-left': opts.forceAlignLeft }" ref="XklFormInfoRef" :model="form"
3
- :label-width="opts.labelWidth">
2
+ <el-form class="xkl-form-info" :class="{ 'force-align-left': opts.forceAlignLeft }" ref="XklFormInfoRef"
3
+ :model="form" :label-width="opts.labelWidth">
4
4
  <el-row>
5
5
  <template v-for="item in formList" :key="item.prop">
6
6
  <el-col :span="item.span" v-if="item.show()">
7
- <el-form-item :label="item.label + ':'" :label-width="item.labelWidth">
8
- <span v-if="item.type === 'dict-select'">{{ dictLabel(item.config.dict, form[item.prop]) }}</span>
9
- <span v-else-if="item.type">{{ form[item.reflect] || form[item.prop] }}</span>
7
+ <el-form-item :label="item.label ? item.label + ':' : ''" :label-width="item.labelWidth">
8
+ <span v-if="item.type === 'dict-select'">{{ dictLabel(item.config.dict, form[item.prop])
9
+ }}</span>
10
+ <span v-else-if="item.type">{{ reflect(form[item.reflect]) || form[item.prop] }}</span>
10
11
  <slot v-else :name="item.prop"></slot>
11
12
  </el-form-item>
12
13
  </el-col>
@@ -25,7 +26,8 @@ import http from "@/utils/httpRequest"
25
26
  import { baseConf } from './index'
26
27
  import { setUpperFirst } from '@xuekl/cli-utils'
27
28
  import { FormItem } from '@xuekl/cli-base/type.d'
28
- import { ref, computed } from 'vue'
29
+ import { ref, computed, onBeforeMount } from 'vue'
30
+ import DictStore from "@/utils/DictStore";
29
31
 
30
32
  const props = defineProps(['form'])
31
33
  const XklFormRef = ref(null)
@@ -33,7 +35,6 @@ const { form } = props
33
35
  const formList: FormItem[] = []
34
36
  const opts = form._opts || {}
35
37
 
36
-
37
38
  // 获取符合mode的字段
38
39
  Object.keys(form).forEach(prop => {
39
40
  if (form['get' + setUpperFirst(prop)]) {
@@ -64,26 +65,42 @@ Object.keys(form).forEach(prop => {
64
65
  const dictTypes = formList.map(item => item.config?.dict).filter(res => !!res)
65
66
  const dictStore = ref({})
66
67
 
67
- dictTypes.forEach((dict: string) => {
68
- http({
69
- url: http.adornUrl(`${baseConf.dict_api_url}${dict}`),
70
- method: 'get',
71
- params: http.adornParams({})
72
- }).then(({ data }) => {
73
- dictStore.value[dict] = data.data
74
- })
68
+
69
+ onBeforeMount(async () => {
70
+ for (let dict of dictTypes) {
71
+ dictStore.value[dict] = await DictStore.getDict(dict)
72
+ }
75
73
  })
76
74
 
75
+
77
76
  const dictLabel = computed(() => {
78
- return function (dict: string, val: string | number) {
77
+ return function (dict: string, propValue: any) {
79
78
  if (dictStore.value[dict]) {
80
- const item = dictStore.value[dict].find(res => res.dictValue == val) || {}
81
- return item.dictLabel
79
+ if (Array.isArray(propValue)) {
80
+ const items = dictStore.value[dict].filter(res => propValue.includes(res.dictValue))
81
+ const labels = items.map(it => it.dictLabel)
82
+ return labels.join(',')
83
+ } else {
84
+ const item = dictStore.value[dict].find(res => res.dictValue == propValue) || {}
85
+ return item.dictLabel
86
+ }
87
+
82
88
  }
83
89
  return ''
84
90
  }
85
91
  })
86
92
 
93
+ const reflect = computed(() => {
94
+ return function (value) {
95
+ if (Array.isArray(value)) {
96
+ return value.join(',')
97
+ } else {
98
+ return value
99
+ }
100
+ }
101
+ })
102
+
103
+
87
104
 
88
105
  </script>
89
106
  <style lang="scss" scoped>
package/XklLink.vue CHANGED
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <real-el-link v-if="isAuth(auth)" @click.prevent="btnClick">
2
+ <real-el-link v-if="doAuth(auth)" :underline="false" @click.prevent.stop="btnClick">
3
3
  <slot></slot>
4
4
  </real-el-link>
5
5
  </template>
@@ -10,25 +10,105 @@ export default {
10
10
  </script>
11
11
  <script setup lang="ts">
12
12
  import { ElLink as RealElLink } from 'element-plus'
13
- import { componentGlobal } from '@xuekl/cli-base/global'
13
+ import { Loading } from "@element-plus/icons-vue";
14
14
  import { isAuth } from '@/utils'
15
- const props = defineProps(['auth'])
16
- const emit = defineEmits(['click', 'async'])
15
+ import { ref, useAttrs } from 'vue'
16
+ import { ElMessageBox } from 'element-plus'
17
+ import { useRoute } from 'vue-router'
18
+ const startLoading = window.startLoading
19
+ const finishLoading = window.finishLoading
20
+ const props = defineProps(['auth', 'prevent', 'openType', 'name', 'mask'])
21
+ const route: any = useRoute()
17
22
 
18
- const { auth } = props
19
- let preventClick = false
23
+ const { auth, name } = props
24
+ const mask = typeof props.mask === 'undefined' ? true : props.mask
25
+
26
+ const doAuth = (auth) => {
27
+ if (name) {
28
+ return isAuth(route?.name + ':' + name)
29
+ } else {
30
+ return isAuth(auth)
31
+ }
32
+ }
33
+
34
+
35
+ const attrs: any = useAttrs()
36
+ const preventClick = ref(false)
20
37
 
21
38
  const btnClick = () => {
22
- emit('click')
23
- if (componentGlobal.enableSubmit) {
24
- preventClick = false
25
- componentGlobal.enableSubmit = false
39
+ if (attrs.click) {
40
+ attrs.onClick()
41
+ if (props.openType) {
42
+ window[props.openType] && window[props.openType]()
43
+ }
44
+ }
45
+ if (attrs.onAsync) {
46
+ if (!preventClick.value) {
47
+ preventClick.value = true
48
+ if (props.openType !== 'preventLoading' && startLoading) {
49
+ startLoading()
50
+ }
51
+ attrs.onAsync(() => {
52
+ setTimeout(() => {
53
+ preventClick.value = false;
54
+ if (finishLoading) {
55
+ finishLoading()
56
+ }
57
+ if (props.openType) {
58
+ window[props.openType] && window[props.openType]()
59
+ }
60
+ }, 200)
61
+ })
62
+ }
26
63
  }
27
- if (!preventClick) {
28
- preventClick = true
29
- emit('async', () => {
30
- setTimeout(() => preventClick = false, 200)
31
- })
64
+
65
+ if (attrs.onConfirm) {
66
+ if (props.prevent === false) {
67
+ attrs.onConfirm()
68
+ if (props.openType) {
69
+ window[props.openType] && window[props.openType]()
70
+ }
71
+ } else {
72
+ ElMessageBox.confirm(
73
+ '当前内容可能存在修改,确认继续?',
74
+ '提示',
75
+ {
76
+ confirmButtonText: '确认',
77
+ cancelButtonText: '取消',
78
+ type: 'warning',
79
+ }
80
+ ).then(() => {
81
+ attrs.onConfirm()
82
+ if (props.openType) {
83
+ window[props.openType] && window[props.openType]()
84
+ }
85
+ }).catch(() => {
86
+ })
87
+ }
88
+ } else {
89
+ if (props.openType) {
90
+ window[props.openType] && window[props.openType]()
91
+ }
92
+ }
93
+ }
94
+ </script>
95
+
96
+ <style lang="scss" scoped>
97
+ .loading-mask {
98
+ position: absolute;
99
+ left: 0;
100
+ top: 0;
101
+ bottom: 0;
102
+ right: 0;
103
+ background-color: rgba(0, 0, 0, 0.6);
104
+ z-index: 1003;
105
+ display: flex;
106
+ align-items: center;
107
+ justify-content: center;
108
+
109
+ .is-loading {
110
+ font-size: 40px;
111
+ color: #fff;
32
112
  }
33
113
  }
34
- </script>
114
+ </style>
package/XklSelect.vue CHANGED
@@ -1,6 +1,29 @@
1
1
  <template>
2
- <el-select v-model="selectData" style="width: 100%;" @change="changeHandle">
3
- <el-option v-for="item in dataList" :key="item.id" :label="item.label" :value="item.value"></el-option>
2
+ <div v-if="fakeRender && (!selectData || (selectData && !selectData.length))" class="fake-render el-input__wrapper"
3
+ :class="{ 'el-select__wrapper is-disabled': disabled || readonly }" @click="updateRender">
4
+ <span class="fs-14">{{ $attrs.placeholder
5
+ }}</span>
6
+ </div>
7
+ <el-select v-else ref="XklSelectRef" :automatic-dropdown="true" v-model="selectData"
8
+ :class="{ 'readony-input': readonly }" style="width: 100%;" @visible-change="visibleChange"
9
+ @change="changeHandle" :filterable="initFilterable" :disabled="disabled || readonly"
10
+ :filter-method="filterMethod" :allow-create="allowCreate" :multiple-limit="multipleLimit" @focus="onClick()">
11
+ <!-- <template v-if="createAtFirst && filterVal" #header>
12
+ <div class="el-select-dropdown__item" @click="headerClick()">
13
+ <OptionComponent v-if="config && config.customOption" :item="creatingItem" />
14
+ </div>
15
+ </template> -->
16
+ <el-option v-if="config && config.all && dataList.length" key="all" :label="config.allLabel || 'ALL'"
17
+ value="ALL"></el-option>
18
+ <el-option v-if="createAtFirst && filterVal" :label="creatingItem.label" :value="creatingItem.value"
19
+ @click="creatingItemClick()">
20
+ <OptionComponent v-if="config && config.customOption" :item="creatingItem" />
21
+ </el-option>
22
+ <el-option v-for="item in dataList" :key="item.value.toString()" :label="item.label" :value="item.value">
23
+ <!-- <span v-if="item.tag">{{ item.tag }}</span> -->
24
+ <OptionComponent v-if="config && config.customOption" :item="item" />
25
+ <span v-else>{{ item.label }}</span>
26
+ </el-option>
4
27
  </el-select>
5
28
  </template>
6
29
  <script lang="ts">
@@ -9,40 +32,233 @@ export default {
9
32
  }
10
33
  </script>
11
34
  <script setup lang="ts">
12
- import { onBeforeMount, ref, Ref, watch, computed } from 'vue'
35
+ import { onBeforeMount, ref, Ref, watch, computed, shallowRef, onBeforeUnmount } from 'vue'
13
36
  import { SelectItem } from '@xuekl/cli-base/type.d'
37
+ import { selectConf } from './index'
14
38
  import http from "@/utils/httpRequest"
15
- const props = defineProps(['config', 'list', 'modelValue'])
16
- const emit = defineEmits(['update:label', 'loaded', 'update:modelValue', 'itemChange'])
17
- const { config, list } = props
39
+ import useApp from '@/store/app'
40
+ import { toPromise } from '@xuekl/cli-utils'
41
+ import { pinyin } from 'pinyin-pro'
42
+ import { nextTick } from 'vue'
43
+ interface OptionItem extends SelectItem {
44
+ tag?: string
45
+ pinyinStartStr?: string
46
+ pinyinStr?: string
47
+ abbreviation?: string
48
+ pinyin?: string
49
+ isChecked?: boolean
50
+ isSpecial?: boolean
51
+ }
52
+ const props = defineProps(['config', 'list', 'modelValue', 'filterable', 'readonly', 'disabled', 'cache', 'allowCreate', 'multipleLimit', 'createAtFirst', 'fake', 'displaySelectedDataFirst'])
53
+ const emit = defineEmits(['update:label', 'click', 'loaded', 'update:modelValue', 'itemChange', 'visibleChange'])
54
+ const { config, list, filterable, readonly, cache, allowCreate, multipleLimit, createAtFirst, fake, displaySelectedDataFirst } = props
55
+ const appStore = useApp()
56
+
57
+ const dataCahe = cache !== false
58
+
59
+ const dataList: Ref<OptionItem[]> = ref([])
60
+
61
+ const initFilterable = ref(false)
62
+
63
+ const isDisplaySelectedDataFirst = displaySelectedDataFirst !== false
64
+
65
+ const isFake = typeof fake === 'undefined' ? true : fake
66
+ const fakeRender = ref(isFake)
67
+ const XklSelectRef: any = ref(null)
68
+
69
+ const updateRender = () => {
70
+ fakeRender.value = false
71
+ nextTick(() => {
72
+ XklSelectRef.value.focus()
73
+ })
74
+ }
75
+ initFilterable.value = filterable || selectConf?.filterable
76
+
77
+ const disabled = computed(() => props.disabled)
78
+
79
+ const OptionComponent = config?.customOption
80
+
81
+ let sourceData: OptionItem[] = []
82
+ let filterSourceData: OptionItem[] = []
83
+
84
+
85
+ const creatingItem: Ref<OptionItem> = ref({
86
+ label: '',
87
+ value: '',
88
+ isChecked: false,
89
+ isSpecial: false,
90
+ __created: true
91
+ })
92
+
93
+ const createdItems: Ref<OptionItem[]> = ref([])
94
+
95
+ const creatingItemClick = () => {
96
+ if (selectData.value.length >= multipleLimit) {
97
+ return
98
+ }
99
+ // if (selectData.value.includes(creatingItem.value.value)) {
100
+ // return
101
+ // }
102
+ creatingItem.value.isChecked = !creatingItem.value.isChecked
103
+ if (creatingItem.value.isChecked) {
104
+ createdItems.value.push({ ...creatingItem.value })
105
+ } else {
106
+ createdItems.value = createdItems.value.filter(item => item.value !== creatingItem.value.value)
107
+ }
108
+ }
109
+
110
+ // 允许创建到第一条时候
111
+ if (allowCreate && createAtFirst) {
112
+ watch(() => creatingItem.value.isSpecial, (val) => {
113
+ const item = createdItems.value.find(inner => inner.value == creatingItem.value.value)
114
+ if (item) {
115
+ item.isSpecial = val
116
+ }
117
+ })
118
+ }
18
119
 
19
- const dataList: Ref<SelectItem[]> = ref([])
120
+
121
+
122
+ const filterVal = ref('')
20
123
 
21
124
  const selectData = computed({
22
125
  get() {
23
- return dataList.value.length ? props.modelValue : ''
126
+ if (Array.isArray(props.modelValue)) {
127
+ return (!dataList.value.length && !allowCreate) ? [] : props.modelValue
128
+ }
129
+ return (!dataList.value.length && !allowCreate) ? '' : props.modelValue
24
130
  },
25
131
  set(val) {
132
+
26
133
  emit('update:modelValue', val)
27
134
  }
28
135
  })
29
136
 
30
- const changeHandle = (val: string | number | string[] | number[]) => {
137
+ const filterMethod = (val: any) => {
138
+ if (createAtFirst) {
139
+ filterVal.value = val
140
+ creatingItem.value.value = val
141
+ creatingItem.value.label = val
142
+ creatingItem.value.isChecked = selectData.value.includes(creatingItem.value.value)
143
+ const createdItem = createdItems.value.find(item => item.value == val)
144
+ if (createdItem) {
145
+ creatingItem.value.isSpecial = createdItem.isSpecial
146
+ } else {
147
+ creatingItem.value.isSpecial = false
148
+ }
149
+ }
150
+
151
+ if (val) {
152
+ val = val.trim()
153
+ const filterKeys = config.filterKeys || []
154
+ dataList.value = filterSourceData.filter(res => {
155
+ if (filterKeys.length) {
156
+ for (let k of filterKeys) {
157
+ if (res[k] && res[k].toString().includes(val)) {
158
+ return true
159
+ }
160
+ }
161
+ } else {
162
+ if (config?.smartFilter) {
163
+ const startMatch = val.toUpperCase()
164
+ const endMatch1 = res.value.toString().toUpperCase()
165
+ const endMatch2 = res.label.toString().toUpperCase()
166
+ const endMatch3 = res.pinyinStartStr!.toString().toUpperCase()
167
+ const endMatch4 = res.pinyinStr!.toString().toUpperCase()
168
+ const endMatch5 = res.abbreviation!.toString().toUpperCase()
169
+ const endMatch6 = res.pinyin!.toString().toUpperCase()
170
+ return endMatch1.includes(startMatch) || endMatch2.includes(startMatch)
171
+ || endMatch3.includes(startMatch) || endMatch4.includes(startMatch)
172
+ || endMatch5.includes(startMatch) || endMatch6.includes(startMatch);
173
+ } else {
174
+ return res.value.toString().includes(val) || res.label.includes(val);
175
+ }
176
+ }
177
+ })
178
+ } else {
179
+ dataList.value = filterSourceData
180
+ }
181
+ }
182
+
183
+ const onClick = () => {
184
+ emit('click')
185
+ }
186
+
187
+ const valChangeHandle = (val: string | number | string[] | number[]) => {
31
188
  if (Array.isArray(val)) {
32
- const values = val.map(res => res.value)
33
- const labels = val.map(res => res.label)
34
- const items = dataList.value.filter(res => values.includes(res.value))
189
+ const values: any = val
190
+ const items: OptionItem[] = []
191
+ for (let v of values) {
192
+ const item = filterSourceData.find(inner => inner.value == v)
193
+ if (item) {
194
+ items.push(item)
195
+ } else {
196
+ if (allowCreate) {
197
+ const createdItem = createdItems.value.find(inner => inner.value == v)
198
+ if (createdItem) {
199
+ items.push(createdItem)
200
+ } else {
201
+ items.push({
202
+ label: v,
203
+ value: v,
204
+ } as OptionItem)
205
+ }
206
+ }
207
+ }
208
+ }
209
+ const labels = items.map(res => res.label)
35
210
  if (items) {
36
211
  emit('update:label', labels)
37
212
  emit('itemChange', items)
38
213
  }
39
214
  } else {
40
- const item = dataList.value.find(res => res.value === val)
41
- if (item) {
42
- emit('update:label', item.label)
43
- emit('itemChange', item)
215
+ if (!val) {
216
+ emit('update:label', "")
217
+ emit('itemChange', null)
218
+ } else {
219
+ const item = dataList.value.find(res => res.value === val)
220
+ if (item) {
221
+ emit('update:label', item.label)
222
+ emit('itemChange', item)
223
+ } else {
224
+ if (val == 'ALL') {
225
+ emit('update:label', config.allLabel || val)
226
+ emit('itemChange', {
227
+ label: config.allLabel || val,
228
+ value: val
229
+ })
230
+ } else if (allowCreate) {
231
+ emit('update:label', val)
232
+ emit('itemChange', {
233
+ label: val,
234
+ value: val
235
+ })
236
+ }
237
+ }
238
+ }
239
+ }
240
+ }
241
+
242
+ const visibleChange = (visible: boolean) => {
243
+ if (isDisplaySelectedDataFirst) {
244
+ if (visible) {
245
+ const valueTarget = config?.valueTarget
246
+ dataList.value = dataList.value.sort((a) => {
247
+ return selectData.value && (Array.isArray(selectData.value) ? selectData.value.includes(a[valueTarget]) : selectData.value === a[valueTarget]) ? -1 : 1
248
+ })
44
249
  }
45
250
  }
251
+ emit('visibleChange', visible)
252
+ }
253
+
254
+ const changeHandle = (val: string | number | string[] | number[]) => {
255
+ if (allowCreate && createAtFirst) {
256
+ // 在自动创建时,第一条的点击事件是晚于change事件的,目前的使用场景是要早于change事件
257
+ setTimeout(() => { valChangeHandle(val) }, 0)
258
+ } else {
259
+ valChangeHandle(val)
260
+ }
261
+
46
262
  }
47
263
 
48
264
  const handleData = (data) => {
@@ -56,6 +272,7 @@ const handleData = (data) => {
56
272
  }
57
273
 
58
274
  if (data) {
275
+
59
276
  data.forEach(inner => {
60
277
  inner.value = inner[config?.valueTarget || 'value']
61
278
  if (!split) {
@@ -63,47 +280,156 @@ const handleData = (data) => {
63
280
  } else {
64
281
  inner.label = labels.map(label => inner[label]).join(split)
65
282
  }
283
+ if (config?.smartFilter) {
284
+ inner.pinyinStr = pinyin(inner.label, { toneType: 'none', type: 'array' }).join('')
285
+ inner.pinyinStartStr = pinyin(inner.label, { pattern: 'first', toneType: 'none', type: 'array' }).join('')
286
+ }
66
287
  })
67
288
  }
68
289
 
69
290
  return data || []
70
291
  }
71
292
 
293
+ let listWatcher: Function
294
+
72
295
  if (typeof list === 'function') {
73
- watch(list, (val: SelectItem[]) => {
296
+ listWatcher = watch(list, (val: OptionItem[]) => {
74
297
  dataList.value = val
75
298
  })
76
299
  }
77
300
 
301
+ const checkExist = () => {
302
+ // return
303
+ if (!allowCreate) {
304
+ if (Array.isArray(selectData.value)) {
305
+ const exist = dataList.value.some(item => selectData.value.includes(item.value))
306
+ if (!exist) {
307
+ selectData.value = []
308
+ }
309
+ } else {
310
+ const exist = dataList.value.some(item => item.value === selectData.value)
311
+ if (!exist && selectData.value !== 'ALL') {
312
+ selectData.value = ""
313
+ }
314
+ }
315
+ }
316
+ }
317
+
78
318
  onBeforeMount(() => {
319
+
79
320
  if (list) {
80
321
  if (typeof list === 'function') {
81
322
  return false
82
323
  }
83
- dataList.value = handleData(list)
324
+ sourceData = list
325
+ dataList.value = handleData(sourceData)
326
+ filterSourceData = handleData(sourceData)
327
+ // checkExist()
84
328
  } else {
85
329
  if (!config) { return }
86
330
  let doParams
87
331
  if (typeof config.params === 'function') {
88
332
  doParams = config.params
89
333
  } else {
90
- doParams = () => config.params
334
+ doParams = () => config.params || {}
335
+ }
336
+
337
+ const params = doParams()
338
+
339
+ const paramsStr = JSON.stringify(params)
340
+ //先读取缓存中的数据
341
+ if (appStore.urlSelectData[config.url + paramsStr]) {
342
+ sourceData = appStore.urlSelectData[config.url + paramsStr]
343
+ dataList.value = handleData(sourceData)
344
+ filterSourceData = handleData(sourceData)
345
+ // 如果缓存中没有数据,可能是以为接口已经发出数据未返回,需要等待
346
+ if (!dataList.value.length) {
347
+ toPromise(() => appStore.urlSelectData[config.url + paramsStr]).then((vals) => {
348
+ sourceData = vals
349
+ dataList.value = handleData(sourceData)
350
+ filterSourceData = handleData(sourceData)
351
+ emit('loaded', dataList.value, (vals) => {
352
+ sourceData = vals
353
+ dataList.value = handleData(sourceData)
354
+ filterSourceData = handleData(sourceData)
355
+ // appStore.urlSelectData[config.url] = JSON.parse(JSON.stringify(dataList.value))
356
+ })
357
+ })
358
+ } else {
359
+ // 如果有数据则直接完成load
360
+ emit('loaded', dataList.value, (vals) => {
361
+ sourceData = vals
362
+ dataList.value = handleData(sourceData)
363
+ filterSourceData = handleData(sourceData)
364
+ // appStore.urlSelectData[config.url] = JSON.parse(JSON.stringify(dataList.value))
365
+ })
366
+ }
367
+
368
+ if (dataList.value.length) {
369
+ checkExist()
370
+ }
371
+ } else {
372
+ // 缓存中不存在再调用接口 并且开始在缓存中打标记,以防止一个页面有相同接口时会调用多次
373
+ appStore.urlSelectData[config.url + paramsStr] = []
374
+ http({
375
+ url: http.adornUrl(config.url),
376
+ method: 'get',
377
+ params: http.adornParams(params)
378
+ }).then(({ data }) => {
379
+ sourceData = data.data
380
+ dataList.value = handleData(sourceData)
381
+ filterSourceData = handleData(sourceData)
382
+ appStore.urlSelectData[config.url + paramsStr] = sourceData
383
+ emit('loaded', dataList.value, (vals) => {
384
+ sourceData = vals
385
+ dataList.value = handleData(sourceData)
386
+ filterSourceData = handleData(sourceData)
387
+ // appStore.urlSelectData[config.url + paramsStr] = sourceData
388
+ })
389
+ checkExist()
390
+ }).catch(() => {
391
+ appStore.urlSelectData[config.url + paramsStr] = undefined
392
+ })
91
393
  }
92
- http({
93
- url: http.adornUrl(config.url),
94
- method: 'get',
95
- params: http.adornParams(doParams())
96
- }).then(({ data }) => {
97
- dataList.value = handleData(data.data)
98
- emit('loaded', dataList.value)
99
- })
100
394
  }
101
395
  })
396
+
397
+ onBeforeUnmount(() => {
398
+ if (listWatcher) {
399
+ listWatcher(); // 调用返回函数来移除 watch 监听
400
+ }
401
+ dataList.value = []
402
+ sourceData = []
403
+ filterSourceData = []
404
+ if (!dataCahe && config) {
405
+ Object.keys(appStore.urlSelectData).forEach(key => {
406
+ if (key.includes(config.url)) {
407
+ appStore.urlSelectData[key] = undefined
408
+ }
409
+ })
410
+ }
411
+ });
102
412
  </script>
103
413
  <style lang="scss">
104
414
  .readony-input {
105
- .el-input__inner {
106
- cursor: not-allowed;
415
+ .is-disabled .el-input__wrapper {
416
+ background-color: #fff !important;
417
+
418
+ .el-input__inner {
419
+ color: #606266;
420
+ -webkit-text-fill-color: #606266;
421
+ }
107
422
  }
108
423
  }
424
+
425
+ .fake-render {
426
+ width: 100%;
427
+ justify-content: flex-start;
428
+ color: #a8abb2;
429
+ height: 32px;
430
+ }
431
+
432
+ .el-select__wrapper.is-disabled {
433
+ border: 1px solid #dcdfe6;
434
+ }
109
435
  </style>