@94ai/nf-search-form 8.3.23 → 9.0.0

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.
@@ -29,8 +29,8 @@
29
29
  :down-icon="downIcon"
30
30
  :show-btn="showBtn"
31
31
  :is-collapse="isCollapse"
32
- :expand-btn-tooltip-desc="expandBtnTooltipDesc"
33
- :shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
32
+ :expand-btn-tooltip-desc="localeText.expandBtnTooltipDesc"
33
+ :shrink-btn-tooltip-desc="localeText.shrinkBtnTooltipDesc"
34
34
  @isCollapseChange="isCollapseChange"
35
35
  >
36
36
  <template
@@ -105,7 +105,7 @@
105
105
  onNfSearchFormSearch(true);
106
106
  onNfSearchFormClick(item);
107
107
  }"
108
- >{{ resolveValue(item.name || queryBtnText, nfSearchFormModel) }}
108
+ >{{ resolveValue(item.name || localeText.queryBtnText, nfSearchFormModel) }}
109
109
  </nf-button>
110
110
  <nf-button
111
111
  v-else-if="item.btnType?.includes('export')"
@@ -123,7 +123,7 @@
123
123
  onNfSearchFormExport();
124
124
  onNfSearchFormClick(item);
125
125
  }"
126
- >{{ resolveValue(item.name || exportBtnText, nfSearchFormModel) }}
126
+ >{{ resolveValue(item.name || localeText.exportBtnText, nfSearchFormModel) }}
127
127
  </nf-button>
128
128
  <nf-button
129
129
  v-else-if="item.btnType?.includes('reset')"
@@ -138,7 +138,7 @@
138
138
  :disabled="resolveValue(resetBtnDisabled, nfSearchFormModel)"
139
139
  :class="(resolveValue(resetBtnClass, nfSearchFormModel) || '') + ' nf-btn-reset'"
140
140
  @click="resetNfSearchFormModel"
141
- >{{ resolveValue(item.name || resetBtnText, nfSearchFormModel) }}
141
+ >{{ resolveValue(item.name || localeText.resetBtnText, nfSearchFormModel) }}
142
142
  </nf-button>
143
143
  <nf-button
144
144
  v-else-if="btnIsShow(item)"
@@ -169,7 +169,7 @@
169
169
  v-if="columnEdit"
170
170
  @click="configNfSearchItemVisibleDialog = true"
171
171
  >
172
- <el-tooltip :content="moreDialogTitle" placement="top">
172
+ <el-tooltip :content="localeText.moreDialogTitle" placement="top">
173
173
  <span class="icon-wrap"><i class="iconfont icon-shaixuan1 nf-fs12"></i></span>
174
174
  </el-tooltip>
175
175
  </nf-button>
@@ -193,7 +193,7 @@
193
193
  :disabled="resolveValue(queryBtnDisabled, nfSearchFormModel)"
194
194
  :class="(resolveValue(queryBtnClass, nfSearchFormModel) || '') + ' nf-btn-search'"
195
195
  @click="onNfSearchFormSearch(true)"
196
- >{{ resolveValue(queryBtnText, nfSearchFormModel) }}
196
+ >{{ resolveValue(localeText.queryBtnText, nfSearchFormModel) }}
197
197
  </nf-button>
198
198
  <nf-button
199
199
  v-else-if="item.btnType?.includes('export')"
@@ -208,7 +208,7 @@
208
208
  :disabled="resolveValue(exportBtnDisabled, nfSearchFormModel)"
209
209
  :class="(resolveValue(exportBtnClass, nfSearchFormModel) || '') + ' nf-btn-export'"
210
210
  @click="onNfSearchFormExport"
211
- >{{ resolveValue(exportBtnText, nfSearchFormModel) }}
211
+ >{{ resolveValue(localeText.exportBtnText, nfSearchFormModel) }}
212
212
  </nf-button>
213
213
  <nf-button
214
214
  v-else-if="item.btnType?.includes('reset')"
@@ -223,7 +223,7 @@
223
223
  :disabled="resolveValue(resetBtnDisabled, nfSearchFormModel)"
224
224
  :class="(resolveValue(resetBtnClass, nfSearchFormModel) || '') + ' nf-btn-reset'"
225
225
  @click="resetNfSearchFormModel"
226
- >{{ resolveValue(resetBtnText, nfSearchFormModel) }}
226
+ >{{ resolveValue(localeText.resetBtnText, nfSearchFormModel) }}
227
227
  </nf-button>
228
228
  <nf-button
229
229
  v-else-if="btnIsShow(item)"
@@ -252,17 +252,17 @@
252
252
  @click="configNfSearchItemVisibleDialog = true"
253
253
  :class="(checkBtnClass || '') + ' nf-btn-check'"
254
254
  >
255
- <el-tooltip :content="moreDialogTitle" placement="top" v-if="columnEdit">
255
+ <el-tooltip :content="localeText.moreDialogTitle" placement="top" v-if="columnEdit">
256
256
  <span class="icon-wrap"><i class="iconfont icon-shaixuan1 nf-fs12"></i></span>
257
257
  </el-tooltip>
258
258
  </nf-button>
259
259
  <slot v-if="isShowBtnBoxSlot && reverseBtnSlot" name="btnBox" />
260
260
  </div>
261
261
  <column-check-dialog
262
- :title="moreDialogTitle"
263
- :cancel-text="columnCheckCancelButtonText"
264
- :confirm-text="columnCheckConfirmButtonText"
265
- :basic-field-desc="columnCheckBasicFieldDesc"
262
+ :title="localeText.moreDialogTitle"
263
+ :cancel-text="localeText.columnCheckCancelButtonText"
264
+ :confirm-text="localeText.columnCheckConfirmButtonText"
265
+ :basic-field-desc="localeText.columnCheckBasicFieldDesc"
266
266
 
267
267
  ref="columnCheckDialog"
268
268
  v-if="columnEdit && configNfSearchItemVisibleDialog && checkMode === 'dialog'"
@@ -293,9 +293,9 @@
293
293
  <slot slot="footer" name="dialogFooter"></slot>
294
294
  </column-check-dialog>
295
295
  <nf-drawer
296
- :title="moreDialogTitle"
297
- :cancel-button-text="columnCheckCancelButtonText"
298
- :confirm-button-text="columnCheckConfirmButtonText"
296
+ :title="localeText.moreDialogTitle"
297
+ :cancel-button-text="localeText.columnCheckCancelButtonText"
298
+ :confirm-button-text="localeText.columnCheckConfirmButtonText"
299
299
 
300
300
  ref="columnCheckNfDrawer"
301
301
  size="680px"
@@ -311,14 +311,14 @@
311
311
  <slot slot="title" name="columCheckTitle" />
312
312
  <slot slot="footer" name="columCheckFooter" />
313
313
  <column-check-drawer
314
- :basic-field-desc="columnCheckBasicFieldDesc"
315
- :search-placeholder="columnCheckSearchPlaceholder"
316
- :fixed-left-desc="columnCheckFixedLeftDesc"
317
- :clear-desc="columnCheckClearDesc"
318
- :no-fixed-desc="columnCheckNoFixedDesc"
319
- :select-empty-warning-tips="selectEmptyWarningTips"
320
- :get-checked-length-desc="columnCheckGetCheckedLengthDesc"
321
- :get-all-check-desc="columnCheckGetAllCheckDesc"
314
+ :basic-field-desc="localeText.columnCheckBasicFieldDesc"
315
+ :search-placeholder="localeText.columnCheckSearchPlaceholder"
316
+ :fixed-left-desc="localeText.columnCheckFixedLeftDesc"
317
+ :clear-desc="localeText.columnCheckClearDesc"
318
+ :no-fixed-desc="localeText.columnCheckNoFixedDesc"
319
+ :select-empty-warning-tips="localeText.selectEmptyWarningTips"
320
+ :get-checked-length-desc="localeText.columnCheckGetCheckedLengthDesc"
321
+ :get-all-check-desc="localeText.columnCheckGetAllCheckDesc"
322
322
 
323
323
  ref="columnCheckDrawer"
324
324
  :storage-key="cStorageKey"
@@ -343,7 +343,7 @@ import SearchFormItem from './nf-search-form-item.vue'
343
343
  import ColumnCheckDialog from './nf-column-check-dialog.vue'
344
344
  import ColumnCheckDrawer from './nf-column-check-drawer.vue'
345
345
  import ResizeObserver from 'resize-observer-polyfill'
346
- import { NfSearchFormItemOption } from './types'
346
+ import { IBtnItems, NfSearchFormItemOption } from './types'
347
347
  import {
348
348
  ref,
349
349
  computed,
@@ -364,7 +364,8 @@ import {
364
364
  createUniqueString,
365
365
  validate as useValidate,
366
366
  mapDispose,
367
- resolveValue
367
+ resolveValue,
368
+ useLocale
368
369
  } from '@94ai/common-utils'
369
370
  import {
370
371
  throttle
@@ -373,23 +374,6 @@ import { useRoute } from 'vue-router/composables'
373
374
  import { ELEMENT_LABEL_TYPE_DEFAULT_VALUE, EXCHANGE_KEY_TYPE } from '@94ai/common-constants'
374
375
  import { ITabItem } from '@94ai/nf-drawer/lib/types'
375
376
 
376
- interface IBtnItems {
377
- btnType?: 'search' | 'export' | 'reset'
378
- name?: string,
379
- type?: string,
380
- icon?: string,
381
- plain?: boolean,
382
- size?: string,
383
- round?: boolean,
384
- circle?: boolean,
385
- loading?: boolean,
386
- disabled?: boolean,
387
- class?: string,
388
- validate?: boolean,
389
- onClick?: (formData: Record<string, any>) => void,
390
- show?: boolean | ((formData: Record<string, any>) => boolean),
391
- [key: string]: any,
392
- }
393
377
 
394
378
  const props = withDefaults(defineProps<{
395
379
  viewIdentity?: string,
@@ -646,23 +630,7 @@ const props = withDefaults(defineProps<{
646
630
  beforeClose: undefined,
647
631
  center: false,
648
632
  destroyOnClose: false,
649
- expandBtnTooltipDesc: '展开',
650
- shrinkBtnTooltipDesc: '收起',
651
- exportBtnText: '导出',
652
- resetBtnText: '重置',
653
- queryBtnText: '查询',
654
- selectEmptyWarningTips: '请选择至少一个选项',
655
- columnCheckCancelButtonText: '取消',
656
- columnCheckConfirmButtonText: '确定',
657
- moreDialogTitle: '设置显示查询框',
658
- columnDisplayBtnText: '添加筛选条件',
659
- columnCheckSearchPlaceholder: '搜索',
660
- columnCheckFixedLeftDesc: '固定在左侧',
661
- columnCheckClearDesc: '清除',
662
- columnCheckNoFixedDesc: '不固定',
663
- columnCheckBasicFieldDesc: '基础字段',
664
- columnCheckGetCheckedLengthDesc: (length) => (length) => '已选(' + length + ')',
665
- columnCheckGetAllCheckDesc: (length) => (length) => '全选(' + length + ')'
633
+ columnDisplayBtnText: '添加筛选条件'
666
634
  })
667
635
 
668
636
  const emit = defineEmits<{
@@ -709,6 +677,27 @@ const emit = defineEmits<{
709
677
  }>()
710
678
  const routeName = computed(() => useRoute().name)
711
679
  const instance = getCurrentInstance()?.proxy
680
+
681
+ // 文案:显式传入的 prop 优先,否则取内置语言包(跟随 vue-i18n 语言或 locale.use 指定的语言)
682
+ const { t } = useLocale()
683
+ const localeText = computed(() => ({
684
+ expandBtnTooltipDesc: props.expandBtnTooltipDesc || t('nf.common.expand'),
685
+ shrinkBtnTooltipDesc: props.shrinkBtnTooltipDesc || t('nf.common.collapse'),
686
+ exportBtnText: props.exportBtnText || t('nf.searchForm.export'),
687
+ resetBtnText: props.resetBtnText || t('nf.searchForm.reset'),
688
+ queryBtnText: props.queryBtnText || t('nf.searchForm.query'),
689
+ selectEmptyWarningTips: props.selectEmptyWarningTips || t('nf.table.selectEmptyWarning'),
690
+ columnCheckCancelButtonText: props.columnCheckCancelButtonText || t('nf.common.cancel'),
691
+ columnCheckConfirmButtonText: props.columnCheckConfirmButtonText || t('nf.common.confirm'),
692
+ moreDialogTitle: props.moreDialogTitle || t('nf.searchForm.moreDialogTitle'),
693
+ columnCheckSearchPlaceholder: props.columnCheckSearchPlaceholder || t('nf.table.searchPlaceholder'),
694
+ columnCheckFixedLeftDesc: props.columnCheckFixedLeftDesc || t('nf.table.fixedLeft'),
695
+ columnCheckClearDesc: props.columnCheckClearDesc || t('nf.table.clear'),
696
+ columnCheckNoFixedDesc: props.columnCheckNoFixedDesc || t('nf.table.noFixed'),
697
+ columnCheckBasicFieldDesc: props.columnCheckBasicFieldDesc || t('nf.table.basicField'),
698
+ columnCheckGetCheckedLengthDesc: props.columnCheckGetCheckedLengthDesc || ((length) => t('nf.table.checkedLength', { length })),
699
+ columnCheckGetAllCheckDesc: props.columnCheckGetAllCheckDesc || ((length) => t('nf.table.allCheck', { length }))
700
+ }))
712
701
  const defaultButtonSlot = ref()
713
702
  const nfSearchFormRef = ref()
714
703
  const columnCheckNfDrawer = ref()
@@ -746,48 +735,48 @@ const processedColumns = computed(() => {
746
735
  })
747
736
 
748
737
  const checkViewIdentityChange = async () => {
749
- const userId = (window as any).userId
750
- const viewField = (window as any).viewField
751
- if (props.viewIdentity && userId && viewField) {
752
- let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value)
753
- if (!viewIdentity) {
754
- viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value)
755
- }
756
- if (!viewIdentity) {
757
- await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField)
758
- } else {
759
- const newViewIdentity = viewField.find(item => item.viewIdentity === props.viewIdentity)
760
- const oldViewIdentity = viewIdentity.find(item => item.viewIdentity === props.viewIdentity)
761
- if ((newViewIdentity && !oldViewIdentity) || (!newViewIdentity && oldViewIdentity)) {
762
- await clearColumnEditCached()
763
- await clearDragCached()
764
- } else if (newViewIdentity && oldViewIdentity) {
765
- let change = false
766
- newViewIdentity.fieldList.every(item => {
767
- if (!oldViewIdentity.fieldList.includes(item)) {
768
- change = true
769
- return
770
- }
771
- return true
772
- })
773
- if (!change) {
774
- oldViewIdentity.fieldList.every(item => {
775
- if (!newViewIdentity.fieldList.includes(item)) {
776
- change = true
777
- return
778
- }
779
- return true
780
- })
781
- }
782
- if (change) {
783
- await clearColumnEditCached()
784
- await clearDragCached()
785
- oldViewIdentity.fieldList = newViewIdentity.fieldList
786
- await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity)
787
- }
788
- }
789
- }
790
- }
738
+ // const userId = (window as any).userId
739
+ // const viewField = (window as any).viewField
740
+ // if (props.viewIdentity && userId && viewField) {
741
+ // let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value)
742
+ // if (!viewIdentity) {
743
+ // viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value)
744
+ // }
745
+ // if (!viewIdentity) {
746
+ // await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField)
747
+ // } else {
748
+ // const newViewIdentity = viewField.find(item => item.viewIdentity === props.viewIdentity)
749
+ // const oldViewIdentity = viewIdentity.find(item => item.viewIdentity === props.viewIdentity)
750
+ // if ((newViewIdentity && !oldViewIdentity) || (!newViewIdentity && oldViewIdentity)) {
751
+ // await clearColumnEditCached()
752
+ // await clearDragCached()
753
+ // } else if (newViewIdentity && oldViewIdentity) {
754
+ // let change = false
755
+ // newViewIdentity.fieldList.every(item => {
756
+ // if (!oldViewIdentity.fieldList.includes(item)) {
757
+ // change = true
758
+ // return
759
+ // }
760
+ // return true
761
+ // })
762
+ // if (!change) {
763
+ // oldViewIdentity.fieldList.every(item => {
764
+ // if (!newViewIdentity.fieldList.includes(item)) {
765
+ // change = true
766
+ // return
767
+ // }
768
+ // return true
769
+ // })
770
+ // }
771
+ // if (change) {
772
+ // await clearColumnEditCached()
773
+ // await clearDragCached()
774
+ // oldViewIdentity.fieldList = newViewIdentity.fieldList
775
+ // await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity)
776
+ // }
777
+ // }
778
+ // }
779
+ // }
791
780
  }
792
781
 
793
782
  /**
@@ -1061,17 +1050,28 @@ const handleColumnsInitHideAndSort = async(columns: any[]) => {
1061
1050
  if (typeof columnState === 'string') {
1062
1051
  columnState = JSON.parse(columnState)
1063
1052
  }
1053
+ let maxIndex = 0
1064
1054
  for (const key in columnState as NfTableColumnAttributes) {
1065
1055
  const state = columnState![key]
1066
1056
  columns.every(i => {
1067
1057
  if (i.prop === key) {
1068
1058
  i.initHidden = state.initHidden
1069
1059
  i._index = state.index
1060
+ if (maxIndex < state.index) {
1061
+ maxIndex = state.index
1062
+ }
1070
1063
  return false
1071
1064
  }
1072
1065
  return true
1073
1066
  })
1074
1067
  }
1068
+ const columnStateKeys = Object.keys(columnState)
1069
+ columns.forEach(item => {
1070
+ if (!columnStateKeys.includes(item.prop)) {
1071
+ maxIndex++
1072
+ item._index = maxIndex
1073
+ }
1074
+ })
1075
1075
  }
1076
1076
  } catch (e) {
1077
1077
  console.log(e)
@@ -3,7 +3,7 @@
3
3
  <el-time-select
4
4
  v-model="startTime"
5
5
  v-bind="inputAttrStart"
6
- :placeholder="startPlaceholder"
6
+ :placeholder="startPlaceholder || t('nf.common.startTime')"
7
7
  class="nf-time-range-el-time-select"
8
8
  v-on="inputlistens"
9
9
  />
@@ -11,7 +11,7 @@
11
11
  <el-time-select
12
12
  v-model="endTime"
13
13
  v-bind="inputAttrEnd"
14
- :placeholder="endPlaceholder"
14
+ :placeholder="endPlaceholder || t('nf.common.endTime')"
15
15
  class="nf-time-range-el-time-select"
16
16
  v-on="inputlistens"
17
17
  />
@@ -35,15 +35,15 @@ import {
35
35
  ref,
36
36
  watch
37
37
  } from 'vue-demi'
38
+ import { useLocale } from '@94ai/common-utils'
38
39
 
40
+ const { t } = useLocale()
39
41
  const props = withDefaults(defineProps<{
40
42
  value?: string[],
41
- endPlaceholder: string
42
- startPlaceholder: string
43
+ endPlaceholder?: string
44
+ startPlaceholder?: string
43
45
  }>(), {
44
- value: () => [],
45
- endPlaceholder: '结束时间',
46
- startPlaceholder: '开始时间'
46
+ value: () => []
47
47
  })
48
48
 
49
49
  const emit = defineEmits<{
package/package/types.ts CHANGED
@@ -1,3 +1,21 @@
1
+ export interface IBtnItems {
2
+ btnType?: 'search' | 'export' | 'reset'
3
+ name?: string,
4
+ type?: string,
5
+ icon?: string,
6
+ plain?: boolean,
7
+ size?: string,
8
+ round?: boolean,
9
+ circle?: boolean,
10
+ loading?: boolean,
11
+ disabled?: boolean,
12
+ class?: string,
13
+ validate?: boolean,
14
+ onClick?: (formData: Record<string, any>) => void,
15
+ show?: boolean | ((formData: Record<string, any>) => boolean),
16
+ [key: string]: any,
17
+ }
18
+
1
19
  interface IExchangeKey {
2
20
  type: number,
3
21
  value?: any
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "8.3.23",
3
+ "version": "9.0.0",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -11,26 +11,26 @@
11
11
  },
12
12
  "repository": {
13
13
  "type": "git",
14
- "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
14
+ "url": "http://gitlab.94ai.pro/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-constants": "^8.3.23",
18
- "@94ai/common-utils": "^8.3.23",
19
- "@94ai/nf-button": "^8.3.23",
20
- "@94ai/nf-double-half-year": "^8.3.23",
21
- "@94ai/nf-double-quarter": "^8.3.23",
22
- "@94ai/nf-double-week": "^8.3.23",
23
- "@94ai/nf-double-year": "^8.3.23",
24
- "@94ai/nf-drawer": "^8.3.23",
25
- "@94ai/nf-form": "^8.3.23",
26
- "@94ai/nf-form-item": "^8.3.23",
27
- "@94ai/nf-half-year-picker": "^8.3.23",
28
- "@94ai/nf-lazy-select": "^8.3.23",
29
- "@94ai/nf-message": "^8.3.23",
30
- "@94ai/nf-quarter-picker": "^8.3.23",
31
- "@94ai/nf-theme-chalk": "^8.3.23",
32
- "@94ai/nf-transfer-select": "^8.3.23",
33
- "@94ai/nf-virtual-select": "^8.3.23",
17
+ "@94ai/common-constants": "^9.0.0",
18
+ "@94ai/common-utils": "^9.0.0",
19
+ "@94ai/nf-button": "^9.0.0",
20
+ "@94ai/nf-double-half-year": "^9.0.0",
21
+ "@94ai/nf-double-quarter": "^9.0.0",
22
+ "@94ai/nf-double-week": "^9.0.0",
23
+ "@94ai/nf-double-year": "^9.0.0",
24
+ "@94ai/nf-drawer": "^9.0.0",
25
+ "@94ai/nf-form": "^9.0.0",
26
+ "@94ai/nf-form-item": "^9.0.0",
27
+ "@94ai/nf-half-year-picker": "^9.0.0",
28
+ "@94ai/nf-lazy-select": "^9.0.0",
29
+ "@94ai/nf-message": "^9.0.0",
30
+ "@94ai/nf-quarter-picker": "^9.0.0",
31
+ "@94ai/nf-theme-chalk": "^9.0.0",
32
+ "@94ai/nf-transfer-select": "^9.0.0",
33
+ "@94ai/nf-virtual-select": "^9.0.0",
34
34
  "idb-keyval": "^6.2.1",
35
35
  "resize-observer-polyfill": "^1.5.1",
36
36
  "vue-demi": "^0.14.5",
@@ -50,5 +50,5 @@
50
50
  "types": "lib/index.d.ts",
51
51
  "main": "lib/nf-search-form.cjs.js",
52
52
  "module": "lib/nf-search-form.esm-bundler.js",
53
- "gitHead": "74e871c7972dc4576480bee02b1dc61a3eafc6ba"
53
+ "gitHead": "afe3016f0e42dfb7fedf6cbbe400ec08bf4b8662"
54
54
  }