@94ai/nf-search-form 8.3.23 → 10.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.
@@ -269,15 +269,11 @@ const pullAwayColumn = (column) => {
269
269
  }
270
270
  }
271
271
 
272
- const insertColumn = (column, append = false) => {
272
+ const insertColumn = (column) => {
273
273
  const unFixedIndex = unFixedColumn.value.findIndex(item => item.prop === column.prop)
274
274
  const fixedIndex = fixedColumn.value.findIndex(item => item.prop === column.prop)
275
275
  if (unFixedIndex === -1 && fixedIndex === -1) {
276
- if (append) {
277
- (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).push(column)
278
- } else {
279
- (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).unshift(column)
280
- }
276
+ (column.attr.fixed ? fixedColumn.value : unFixedColumn.value).push(column)
281
277
  }
282
278
  }
283
279
 
@@ -340,13 +336,14 @@ const handleCheckAllChange = (v) => {
340
336
  if (item) {
341
337
  item.initHidden = false
342
338
  const cloneItem = deepClone(item)
343
- if (!cloneItem.attr) {
344
- cloneItem.attr = {}
345
- }
346
339
  newColumns.push(cloneItem)
347
340
  }
348
341
  })
349
342
  currentTable.value = newColumns
343
+ if (columnName.value) {
344
+ searchValue = currentTable.value.filter(item => (item.addLabel || item.label).includes(columnName.value))
345
+ setFields(searchValue)
346
+ }
350
347
  currentTable.value.map(item => {
351
348
  if (item.attr.fixed) {
352
349
  fixedColumn.value.push(item)
@@ -364,7 +361,7 @@ const handleCheckAllChange = (v) => {
364
361
  searchValue.map(item => {
365
362
  if (!unChangedColumn.value.includes(item.prop)) {
366
363
  if (v) { // 追加
367
- insertColumn(item, true)
364
+ insertColumn(item)
368
365
  } else {
369
366
  pullAwayColumn(item)
370
367
  }
@@ -377,7 +374,7 @@ const handleCheckAllChange = (v) => {
377
374
  currentTable.value.map(item => {
378
375
  if (!unChangedColumn.value.includes(item.prop)) {
379
376
  if (v) { // 追加
380
- insertColumn(item, true)
377
+ insertColumn(item)
381
378
  } else {
382
379
  pullAwayColumn(item)
383
380
  }
@@ -402,37 +399,12 @@ const handleCheckedChange = (v, prop) => {
402
399
  item.initHidden = !v
403
400
  // 清除列目时,清除固定属性
404
401
  v ? '' : item.attr.fixed = false
405
- v ? insertColumn(item, true) : pullAwayColumn(item)
402
+ v ? insertColumn(item) : pullAwayColumn(item)
406
403
  }
407
404
  })
408
405
  updateCheckStatus()
409
406
  }
410
407
 
411
- /**
412
- * 固定/取消固定
413
- * @param {Boolean} v 是否取消 true:固定; false: 取消固定
414
- * @param {String} prop 当前选中列目的 prop
415
- */
416
- const handleFixed = (v, prop) => {
417
- const columnInfo = currentTable.value.find(item => item.prop === prop)
418
- if (columnInfo) {
419
- columnInfo.attr.fixed = v ? 'left' : false
420
- if (v) { // 固定
421
- const unFixedColumnIndex = unFixedColumn.value.findIndex(unFixedColumnItem => unFixedColumnItem.prop === columnInfo.prop)
422
- if (unFixedColumnIndex > -1) {
423
- unFixedColumn.value.splice(unFixedColumnIndex, 1)
424
- fixedColumn.value.push(columnInfo)
425
- }
426
- } else { // 取消固定
427
- const fixedColumnIndex = fixedColumn.value.findIndex(fixedColumnItem => fixedColumnItem.prop === columnInfo.prop)
428
- if (fixedColumnIndex > -1) {
429
- fixedColumn.value.splice(fixedColumnIndex, 1)
430
- unFixedColumn.value.push(columnInfo)
431
- }
432
- }
433
- }
434
- }
435
-
436
408
  /**
437
409
  * 确定
438
410
  */
@@ -500,4 +472,3 @@ defineExpose({
500
472
  drag,
501
473
  })
502
474
  </script>
503
-
@@ -100,7 +100,7 @@ const emit = defineEmits<{
100
100
 
101
101
  const inputlistens = computed(() => {
102
102
  const list = Object.assign({},
103
- instance?.$listeners || {},
103
+ instance?.$listeners,
104
104
  {
105
105
  change: function() {
106
106
  emit('change', [minNumber.value, maxNumber.value])
@@ -164,8 +164,4 @@ watch(() => {
164
164
  emit('input', [minNumber.value, maxNumber.value])
165
165
  })
166
166
 
167
- const input = () => {
168
- emit('input', [minNumber.value, maxNumber.value])
169
- }
170
-
171
167
  </script>
@@ -62,9 +62,9 @@
62
62
  v-on="bindEvents"
63
63
  :type="itemOptions.type || 'datetimerange'"
64
64
  :clearable="itemOptions.clearable || true"
65
- :start-placeholder="itemOptions.startPlaceholder || '开始日期'"
65
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.startDate')"
66
66
  :range-separator="itemOptions.rangeSeparator || '-'"
67
- :end-placeholder="itemOptions.endPlaceholder || '结束日期'"
67
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.endDate')"
68
68
  :default-time="itemOptions.defaultTime || ['00:00:00', '23:59:59']"
69
69
  :value-format="itemOptions.valueFormat || 'yyyy-MM-dd HH:mm:ss'"
70
70
  @change="handleChange"
@@ -81,9 +81,9 @@
81
81
  v-on="bindEvents"
82
82
  :type="itemOptions.type || 'datetimerange'"
83
83
  :clearable="itemOptions.clearable || true"
84
- :start-placeholder="itemOptions.startPlaceholder || '开始日期'"
84
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.startDate')"
85
85
  :range-separator="itemOptions.rangeSeparator || '-'"
86
- :end-placeholder="itemOptions.endPlaceholder || '结束日期'"
86
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.endDate')"
87
87
  :default-time="itemOptions.defaultTime || ['00:00:00', '23:59:59']"
88
88
  :value-format="itemOptions.valueFormat || 'yyyy-MM-dd HH:mm:ss'"
89
89
  @change="handleChange"
@@ -101,9 +101,9 @@
101
101
  v-on="bindEvents"
102
102
  type="monthrange"
103
103
  :clearable="itemOptions.clearable || true"
104
- :start-placeholder="itemOptions.startPlaceholder || '开始日期'"
104
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.startDate')"
105
105
  :range-separator="itemOptions.rangeSeparator || '-'"
106
- :end-placeholder="itemOptions.endPlaceholder || '结束日期'"
106
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.endDate')"
107
107
  :value-format="itemOptions.valueFormat || 'yyyy-MM'"
108
108
  @change="handleChange"
109
109
  >
@@ -118,9 +118,9 @@
118
118
  v-on="bindEvents"
119
119
  type="monthrange"
120
120
  :clearable="itemOptions.clearable || true"
121
- :start-placeholder="itemOptions.startPlaceholder || '开始日期'"
121
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.startDate')"
122
122
  :range-separator="itemOptions.rangeSeparator || '-'"
123
- :end-placeholder="itemOptions.endPlaceholder || '结束日期'"
123
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.endDate')"
124
124
  :value-format="itemOptions.valueFormat || 'yyyy-MM'"
125
125
  @change="handleChange"
126
126
  >
@@ -134,7 +134,7 @@
134
134
  v-model="currentVal"
135
135
  v-bind="bindProps"
136
136
  v-on="bindEvents"
137
- :placeholder="itemOptions.placeholder || '请选择日期'"
137
+ :placeholder="itemOptions.placeholder || t('nf.common.selectDate')"
138
138
  :type="itemOptions.type"
139
139
  @change="handleChange"
140
140
  >
@@ -147,7 +147,7 @@
147
147
  v-model="currentVal"
148
148
  v-bind="bindProps"
149
149
  v-on="bindEvents"
150
- :placeholder="itemOptions.placeholder || '请选择日期'"
150
+ :placeholder="itemOptions.placeholder || t('nf.common.selectDate')"
151
151
  :type="itemOptions.type"
152
152
  @change="handleChange"
153
153
  >
@@ -160,7 +160,7 @@
160
160
  v-model="currentVal"
161
161
  v-bind="bindProps"
162
162
  v-on="bindEvents"
163
- :placeholder="itemOptions.placeholder || '请选择周'"
163
+ :placeholder="itemOptions.placeholder || t('nf.common.selectWeek')"
164
164
  >
165
165
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
166
166
  <span class="iconfont icon-dao" />
@@ -171,7 +171,7 @@
171
171
  v-model="currentVal"
172
172
  v-bind="bindProps"
173
173
  v-on="bindEvents"
174
- :placeholder="itemOptions.placeholder || '请选择年'"
174
+ :placeholder="itemOptions.placeholder || t('nf.common.selectYear')"
175
175
  >
176
176
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
177
177
  <span class="iconfont icon-dao" />
@@ -182,7 +182,7 @@
182
182
  v-model="currentVal"
183
183
  v-bind="bindProps"
184
184
  v-on="bindEvents"
185
- :placeholder="itemOptions.placeholder || '请选择季度'"
185
+ :placeholder="itemOptions.placeholder || t('nf.common.selectQuarter')"
186
186
  >
187
187
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
188
188
  <span class="iconfont icon-dao" />
@@ -193,7 +193,7 @@
193
193
  v-model="currentVal"
194
194
  v-bind="bindProps"
195
195
  v-on="bindEvents"
196
- :placeholder="itemOptions.placeholder || '请选择半年'"
196
+ :placeholder="itemOptions.placeholder || t('nf.common.selectHalfYear')"
197
197
  >
198
198
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
199
199
  <span class="iconfont icon-dao" />
@@ -204,7 +204,7 @@
204
204
  v-model="currentVal"
205
205
  v-bind="bindProps"
206
206
  v-on="bindEvents"
207
- :placeholder="itemOptions.placeholder || '请选择半年'"
207
+ :placeholder="itemOptions.placeholder || t('nf.common.selectHalfYear')"
208
208
  >
209
209
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
210
210
  <span class="iconfont icon-dao" />
@@ -215,7 +215,7 @@
215
215
  v-model="currentVal"
216
216
  v-bind="bindProps"
217
217
  v-on="bindEvents"
218
- :placeholder="itemOptions.placeholder || '请选择季度'"
218
+ :placeholder="itemOptions.placeholder || t('nf.common.selectQuarter')"
219
219
  >
220
220
  <slot slot="range-separator" :name="itemOptions.rangeSeparator">
221
221
  <span class="iconfont icon-dao" />
@@ -235,7 +235,7 @@
235
235
  v-model="currentVal"
236
236
  v-bind="bindProps"
237
237
  v-on="bindEvents"
238
- :placeholder="itemOptions.placeholder || '请选择时间'"
238
+ :placeholder="itemOptions.placeholder || t('nf.common.selectTime')"
239
239
  @change="handleChange"
240
240
  />
241
241
  <!-- el-time-select (type:range) -->
@@ -244,8 +244,8 @@
244
244
  v-model="currentVal"
245
245
  v-bind="bindProps"
246
246
  v-on="bindEvents"
247
- :start-placeholder="itemOptions.startPlaceholder || '开始时间'"
248
- :end-placeholder="itemOptions.endPlaceholder || '结束时间'"
247
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.startTime')"
248
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.endTime')"
249
249
  @change="handleChange"
250
250
  />
251
251
  <!-- el-time-picker -->
@@ -254,9 +254,9 @@
254
254
  v-model="currentVal"
255
255
  v-bind="bindProps"
256
256
  v-on="bindEvents"
257
- :placeholder="itemOptions.placeholder || '请选择时间'"
258
- :start-placeholder="itemOptions.startPlaceholder || '请选择时间'"
259
- :end-placeholder="itemOptions.endPlaceholder || '请选择时间'"
257
+ :placeholder="itemOptions.placeholder || t('nf.common.selectTime')"
258
+ :start-placeholder="itemOptions.startPlaceholder || t('nf.common.selectTime')"
259
+ :end-placeholder="itemOptions.endPlaceholder || t('nf.common.selectTime')"
260
260
  @change="handleChange"
261
261
  />
262
262
  <!-- 数字区间 -->
@@ -306,7 +306,7 @@ import {
306
306
  getCurrentInstance
307
307
  } from 'vue-demi'
308
308
  import { NfSearchFormItemOption } from '@94ai/nf-search-form/lib/types'
309
- import { createUniqueString } from '@94ai/common-utils'
309
+ import { createUniqueString, useLocale } from '@94ai/common-utils'
310
310
 
311
311
  const emit = defineEmits<{
312
312
  (e: 'input', event: any): void
@@ -341,6 +341,7 @@ const props = withDefaults(defineProps<{
341
341
  })
342
342
 
343
343
  const instance = getCurrentInstance()?.proxy
344
+ const { t } = useLocale()
344
345
 
345
346
  const slotName = computed(() => {
346
347
  return props.itemOptions.slot || ''
@@ -435,7 +436,7 @@ const bindEvents = computed(() => {
435
436
  if (events?.change) {
436
437
  delete events.change
437
438
  }
438
- return events || {}
439
+ return events
439
440
  })
440
441
 
441
442
  const tooltip = computed(() => {