@94ai/nf-search-form 100.1.9 → 100.1.17

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.
@@ -138,10 +138,9 @@ import {
138
138
  computed,
139
139
  onBeforeMount,
140
140
  getCurrentInstance,
141
- PropType,
142
- onMounted
143
141
  } from 'vue-demi'
144
142
  import { deepClone } from '@94ai/common-utils'
143
+ import { set as cachedSet } from 'idb-keyval'
145
144
 
146
145
  const instance = getCurrentInstance()?.proxy
147
146
 
@@ -157,6 +156,10 @@ const props = withDefaults(defineProps<{
157
156
  noFixedDesc?: string
158
157
  getCheckedLengthDesc?: Function
159
158
  getAllCheckDesc?: Function
159
+ /**
160
+ * 列编辑,是否显示按钮配置表单项显示
161
+ */
162
+ columnEdit?: boolean,
160
163
  }>(), {
161
164
  selectEmptyWarningTips: '请选择至少一个选项',
162
165
  tableColumns: () => [],
@@ -166,7 +169,8 @@ const props = withDefaults(defineProps<{
166
169
  clearDesc: '清除',
167
170
  noFixedDesc: '不固定',
168
171
  getCheckedLengthDesc: (length) => '已选(' + length + ')',
169
- getAllCheckDesc: (length) => '全选(' + length + ')'
172
+ getAllCheckDesc: (length) => '全选(' + length + ')',
173
+ columnEdit: false
170
174
  })
171
175
 
172
176
  // 获取当前缓存中的动态数据列
@@ -182,6 +186,7 @@ const unFixedColumn = ref<Record<string, any>[]>([])
182
186
 
183
187
 
184
188
  onBeforeMount(() => {
189
+ // 混合缓存后数据
185
190
  currentTable.value = deepClone(props.tableColumns.filter(item => !item.destory)).sort((a,b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0) as Record<string, any>[]
186
191
  // 兼容处理
187
192
  currentTable.value.map(i => {
@@ -189,6 +194,7 @@ onBeforeMount(() => {
189
194
  i.attr = {}
190
195
  }
191
196
  })
197
+ // 原始数据
192
198
  const list = props.tableColumns.filter(item => !item.destory)
193
199
  // 可选列表 → 字段区分
194
200
  setFields(list)
@@ -341,7 +347,7 @@ const handleFixed = (v, prop) => {
341
347
  /**
342
348
  * 确定
343
349
  */
344
- const syncTableColumnsToCookies = () => {
350
+ const syncTableColumnsToCookies = async () => {
345
351
  const newTableColumns = [...fixedColumn.value, ...unFixedColumn.value]
346
352
  if (newTableColumns.filter(item => !item.initHidden).length === 0) {
347
353
  // @ts-ignore
@@ -351,20 +357,21 @@ const syncTableColumnsToCookies = () => {
351
357
  })
352
358
  throw new Error(props.selectEmptyWarningTips)
353
359
  }
354
- const columnState = {}
355
- const obj: Record<string, any> = {}
356
- newTableColumns.map((i, index) => {
357
- columnState[i.prop] = {
358
- initHidden: i.initHidden || false,
359
- fixed: i.attr?.fixed || false,
360
- prop: i.prop,
361
- index
360
+ const columnState = {}
361
+ const obj: Record<string, any> = {}
362
+ newTableColumns.map((i, index) => {
363
+ columnState[i.prop] = {
364
+ initHidden: i.initHidden || false,
365
+ fixed: i.attr?.fixed || false,
366
+ prop: i.prop,
367
+ index
368
+ }
369
+ obj[i.prop] = !columnState[i.prop].initHidden
370
+ })
371
+ if (props.columnEdit) {
372
+ await cachedSet(props.storageKey, columnState)
362
373
  }
363
- obj[i.prop] = !columnState[i.prop].initHidden
364
- })
365
- instance?.$cookies?.remove(props.storageKey)
366
- instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
367
- return obj
374
+ return obj
368
375
  }
369
376
 
370
377
  /**
@@ -204,7 +204,6 @@
204
204
  :table-columns="formOptions"
205
205
  :title="moreDialogTitle"
206
206
  :width="moreDialogWidth"
207
- :show-columns="localShowItems"
208
207
  :modal-append-to-body="modalAppendToBody"
209
208
  :modal="modal"
210
209
  :fullscreen="fullscreen"
@@ -245,6 +244,7 @@
245
244
  <slot slot="title" name="columCheckTitle" />
246
245
  <slot slot="footer" name="columCheckFooter" />
247
246
  <column-check-drawer
247
+ :column-edit="columnEdit"
248
248
  :search-placeholder="columnCheckSearchPlaceholder"
249
249
  :fixed-left-desc="columnCheckFixedLeftDesc"
250
250
  :clear-desc="columnCheckClearDesc"
@@ -290,6 +290,12 @@ import { ITabItem } from '@94ai/nf-drawer/lib/types'
290
290
  import {
291
291
  NfTableColumnAttributes
292
292
  } from '@94ai/nf-table/lib/types'
293
+ import { set } from 'vue'
294
+ import {
295
+ del,
296
+ get as cachedGet,
297
+ set as cachedSet
298
+ } from 'idb-keyval'
293
299
 
294
300
 
295
301
  const props = withDefaults(defineProps<{
@@ -611,7 +617,9 @@ const initLocalShow = () => {
611
617
  }
612
618
  return !item.initHidden
613
619
  }).map(item => item.prop!)
614
- props.formOptions._skip = false
620
+ nextTick(() => {
621
+ props.formOptions._skip = false
622
+ })
615
623
  if (result.length) {
616
624
  return result
617
625
  }
@@ -621,12 +629,15 @@ const initLocalShow = () => {
621
629
  * 表单显示的item集合
622
630
  */
623
631
  const localShowItems = ref<string[]>(initLocalShow())
624
- watch(() => localShowItems.value?.length, () => {
632
+ watch(() => localShowItems.value?.length, async () => {
625
633
  emit('update:showItems', localShowItems.value)
634
+ if (Object.keys(nfSearchFormModel.value).length) {
635
+ await refreshNfSearchFormModel(false)
636
+ }
626
637
  }, {
627
638
  immediate: true
628
639
  })
629
- const syncLocalShowColumnToCookies = () => {
640
+ const syncLocalShowColumnToCookies = async () => {
630
641
  if (props.columnEdit) {
631
642
  const columnState = {}
632
643
  props.formOptions.map((i, index) => {
@@ -637,25 +648,29 @@ const syncLocalShowColumnToCookies = () => {
637
648
  index
638
649
  }
639
650
  })
640
- instance?.$cookies?.remove(props.storageKey)
641
- instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1, '/xxxx/xxxx/xxxx')
651
+ await cachedSet(props.storageKey, columnState)
642
652
  }
643
653
  }
644
- const syncCookiesToLocalShowColumn = () => {
654
+
655
+ const syncCookiesToLocalShowColumn = async () => {
645
656
  if (props.columnEdit) {
646
- let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
647
- if (columnState) {
648
- if (typeof columnState === 'string') {
649
- columnState = JSON.parse(columnState)
650
- }
651
- const showColumnItems: string[] = []
652
- for (const key in columnState as NfTableColumnAttributes) {
653
- if (!columnState![key].initHidden) {
654
- showColumnItems.push(columnState![key].prop)
657
+ try {
658
+ let columnState: string | NfTableColumnAttributes | undefined = await cachedGet(props.storageKey)
659
+ if (columnState) {
660
+ if (typeof columnState === 'string') {
661
+ columnState = JSON.parse(columnState)
655
662
  }
663
+ const showColumnItems: string[] = []
664
+ for (const key in columnState as NfTableColumnAttributes) {
665
+ if (!columnState![key].initHidden) {
666
+ showColumnItems.push(columnState![key].prop)
667
+ }
668
+ }
669
+ setLocalShowItems(showColumnItems, true)
656
670
  }
657
- localShowItems.value = showColumnItems
658
- syncShowItemToInitHidden()
671
+ } catch (e) {
672
+ console.log(e)
673
+ await del(props.storageKey)
659
674
  }
660
675
  }
661
676
  }
@@ -669,19 +684,29 @@ const syncShowItemToInitHidden = () => {
669
684
  item.initHidden = true
670
685
  }
671
686
  })
672
- props.formOptions._skip = false
687
+ nextTick(() => {
688
+ props.formOptions._skip = false
689
+ })
673
690
  }
674
- if (props.columnEdit) {
675
- // 同步缓存参数
676
- const cached = instance?.$cookies?.get(props.storageKey)
677
- const cachedPriority = props.priority === 'cached'
678
- if (cachedPriority ? cached : localShowItems.value?.length) {
679
- cachedPriority ? syncCookiesToLocalShowColumn() : syncLocalShowColumnToCookies()
680
- } else if (cachedPriority ? localShowItems.value?.length : cached) {
681
- cachedPriority ? syncLocalShowColumnToCookies() : syncCookiesToLocalShowColumn()
691
+ const initCachedData = async () => {
692
+ if (props.columnEdit) {
693
+ // 同步缓存参数
694
+ try {
695
+ const cached = await cachedGet(props.storageKey)
696
+ const cachedPriority = props.priority === 'cached'
697
+ if (cachedPriority ? cached : localShowItems.value?.length) {
698
+ cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies()
699
+ } else if (cachedPriority ? localShowItems.value?.length : cached) {
700
+ cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn()
701
+ }
702
+ } catch (e) {
703
+ await del(props.storageKey)
704
+ }
682
705
  }
683
706
  }
684
707
 
708
+ initCachedData()
709
+
685
710
  /**
686
711
  * 超过数量显示更多
687
712
  */
@@ -702,36 +727,44 @@ const isShowBtnBoxSlot = computed(() => {
702
727
  * 转换成最终的表单项渲染数据
703
728
  */
704
729
  const renderSearchFormItemOptions = ref<NfSearchFormItemOption[]>([])
705
- const syncCookiesToSearchFormItemOptions = (readCached = true) => {
730
+ const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
706
731
  props.formOptions._skip = true
707
732
  const columns = props.formOptions!.map((item, index) => {
708
733
  item.key = item.key || createUniqueString()
709
- item._index = index
710
- item.__index = index
734
+ item._index = index // 混合缓存后的数据
735
+ item.__index = index // 原始顺序
736
+ set(item, 'initHidden', !!item.initHidden)
737
+ set(item, 'destory', !!item.destory)
711
738
  return item
712
739
  })
713
740
  if (readCached && props.columnEdit) {
714
741
  // 读取缓存 Column 配置
715
- let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
716
- if (columnState) {
717
- if (typeof columnState === 'string') {
718
- columnState = JSON.parse(columnState)
719
- }
720
- for (const key in columnState as NfTableColumnAttributes) {
721
- const state = columnState![key]
722
- columns.every(i => {
723
- if (i.prop === key) {
724
- i.initHidden = state.initHidden
725
- i._index = state.index
726
- return false
727
- }
728
- return true
729
- })
742
+ try {
743
+ let columnState: string | NfTableColumnAttributes | undefined = await cachedGet(props.storageKey)
744
+ props.formOptions._skip = true
745
+ if (columnState) {
746
+ if (typeof columnState === 'string') {
747
+ columnState = JSON.parse(columnState)
748
+ }
749
+ for (const key in columnState as NfTableColumnAttributes) {
750
+ const state = columnState![key]
751
+ columns.every(i => {
752
+ if (i.prop === key) {
753
+ i.initHidden = state.initHidden
754
+ i._index = state.index
755
+ return false
756
+ }
757
+ return true
758
+ })
759
+ }
730
760
  }
761
+ } catch (e) {
762
+ console.log(e)
731
763
  }
732
764
  }
733
- renderSearchFormItemOptions.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
765
+ await nextTick()
734
766
  props.formOptions._skip = false
767
+ renderSearchFormItemOptions.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
735
768
  }
736
769
  syncCookiesToSearchFormItemOptions()
737
770
 
@@ -740,10 +773,7 @@ syncCookiesToSearchFormItemOptions()
740
773
  * @param prop
741
774
  */
742
775
  const itemIsShow = (item: NfSearchFormItemOption) => {
743
- if (!localShowItems.value?.length) {
744
- return !item.initHidden && !item.destory
745
- }
746
- return localShowItems.value.includes(item.prop!) && !item.initHidden && !item.destory
776
+ return !item.initHidden && !item.destory
747
777
  }
748
778
 
749
779
 
@@ -768,6 +798,14 @@ watch(() => {
768
798
  immediate: true
769
799
  })
770
800
 
801
+ const setLocalShowItems = (list, syncToInitHidden = false) => {
802
+ if (JSON.stringify(list.sort()) !== JSON.stringify(localShowItems.value.sort())) {
803
+ localShowItems.value = list
804
+ if (syncToInitHidden) {
805
+ syncShowItemToInitHidden()
806
+ }
807
+ }
808
+ }
771
809
 
772
810
  /**
773
811
  * 初始化formData表单数据
@@ -783,29 +821,43 @@ onBeforeMount(() => {
783
821
  */
784
822
  watch(() => {
785
823
  return props.formOptions
786
- }, () => {
824
+ }, async () => {
787
825
  if (props.formOptions._skip) {
788
826
  return
789
827
  }
790
- syncCookiesToSearchFormItemOptions(false)
828
+ setLocalShowItems(initLocalShow())
829
+ await syncCookiesToSearchFormItemOptions(false)
791
830
  }, {
792
831
  deep: true
793
832
  })
833
+ refreshNfSearchFormModel(false, true)
834
+ })
835
+
836
+
837
+ const refreshNfSearchFormModel = async (outEmit = true, init = false) => {
794
838
  const obj: Record<string, any> = {}
795
- props.formOptions.forEach(v => {
796
- if (v.initValue !== undefined) {
797
- obj[v.prop!] = v.initValue
798
- } else {
799
- obj[v.prop!] = undefined
839
+ props.formOptions.filter(item => !item.destory).forEach(v => {
840
+ if (localShowItems.value.includes(v.prop)) {
841
+ if (init) {
842
+ if (v.initValue !== undefined) {
843
+ obj[v.prop!] = v.initValue
844
+ } else {
845
+ obj[v.prop!] = undefined
846
+ }
847
+ } else {
848
+ obj[v.prop!] = nfSearchFormModel.value[v.prop]
849
+ }
800
850
  }
801
851
  })
802
- for (const key in obj) {
803
- if (!localShowItems.value.includes(key)) {
804
- delete obj[key]
852
+ if (JSON.stringify(nfSearchFormModel.value) !== JSON.stringify(obj)) {
853
+ nfSearchFormModel.value = obj
854
+ if (outEmit) {
855
+ emit('onChange', nfSearchFormModel.value)
856
+ await nextTick()
857
+ emit('itemsChange', localShowItems.value)
805
858
  }
806
859
  }
807
- nfSearchFormModel.value = obj
808
- })
860
+ }
809
861
 
810
862
  const isCollapseChange = async (val: boolean) => {
811
863
  emit('isCollapseChange', val)
@@ -827,15 +879,15 @@ const refreshLabel = () => {
827
879
  const onResize = async (params: Record<string, any> = {}) => {
828
880
  const {
829
881
  width
830
- } = (params?.[0]?.contentRect) || {};
882
+ } = (params?.[0]?.contentRect) || {}
831
883
  if (width && domWidth.value && width === domWidth.value) {
832
- return;
884
+ return
833
885
  }
834
886
  if (domWidth.value) {
835
- await nextTick();
836
- domWidth.value = topDom.value.offsetWidth;
887
+ await nextTick()
888
+ domWidth.value = topDom.value.offsetWidth
837
889
  }
838
- refreshLabel();
890
+ refreshLabel()
839
891
  }
840
892
 
841
893
  const calcColumns = () => {
@@ -862,7 +914,7 @@ onMounted(async () => {
862
914
  calcColumns()
863
915
  await nextTick()
864
916
  observer.value = new ResizeObserver(onResize)
865
- observer.value.observe(topDom.value, { box: "border-box" });
917
+ observer.value.observe(topDom.value, { box: 'border-box' })
866
918
  })
867
919
 
868
920
  onBeforeUnmount(() => {
@@ -910,31 +962,23 @@ const onNfSearchFormExport = () => {
910
962
  * @param prop
911
963
  */
912
964
  const hiddenNfSearchFormItemOptionField = async (prop) => {
913
- const index = localShowItems.value.indexOf(prop)
914
- if (index > -1) {
915
- localShowItems.value.splice(index, 1)
916
- syncShowItemToInitHidden()
917
- syncLocalShowColumnToCookies()
918
- syncCookiesToSearchFormItemOptions()
919
- refreshNfSearchFormModel()
920
- await nextTick()
921
- refreshLabel()
922
- }
923
- }
924
-
925
- /**
926
- * 更新item对应的formData
927
- * @param prop
928
- */
929
- const refreshNfSearchFormModel = async () => {
930
- for (const key in nfSearchFormModel.value) {
931
- if (!localShowItems.value.includes(key)) {
932
- delete nfSearchFormModel.value[key]
965
+ prop.formOptions._skip = true
966
+ prop.formOptions.every(item => {
967
+ if (item.prop === prop) {
968
+ item.initHidden = true
969
+ return false
933
970
  }
934
- }
935
- emit('onChange', nfSearchFormModel.value)
971
+ return true
972
+ })
973
+ nextTick(() => {
974
+ props.formOptions._skip = false
975
+ })
976
+ localShowItems.value = prop.formOptions.filter(item => !item.initHidden).map(item => item.prop)
977
+ await syncLocalShowColumnToCookies()
978
+ await syncCookiesToSearchFormItemOptions()
979
+ await refreshNfSearchFormModel()
936
980
  await nextTick()
937
- emit('itemsChange', localShowItems.value)
981
+ refreshLabel()
938
982
  }
939
983
 
940
984
  const columnCheckConfirmFeedback = (value: Record<string, any>) => {
@@ -945,19 +989,18 @@ const columnCheckConfirmFeedback = (value: Record<string, any>) => {
945
989
  itemsList.push(key)
946
990
  }
947
991
  }
948
- localShowItems.value = itemsList
949
- syncShowItemToInitHidden()
992
+ setLocalShowItems(itemsList, true)
950
993
  }
951
994
  }
952
995
 
953
996
  // 抽屉确定
954
997
  const columnCheckConfirm = async (cb, error) => {
955
998
  try {
956
- const value = columnCheckDrawer.value.syncTableColumnsToCookies()
999
+ const value = await columnCheckDrawer.value.syncTableColumnsToCookies()
957
1000
  columnCheckConfirmFeedback(value)
958
- syncCookiesToLocalShowColumn()
959
- syncCookiesToSearchFormItemOptions()
960
- refreshNfSearchFormModel()
1001
+ await syncCookiesToLocalShowColumn()
1002
+ await syncCookiesToSearchFormItemOptions()
1003
+ await refreshNfSearchFormModel()
961
1004
  await nextTick()
962
1005
  refreshLabel()
963
1006
  cb()
@@ -972,9 +1015,9 @@ const columnCheckConfirm = async (cb, error) => {
972
1015
  */
973
1016
  const nfSearchFormItemOptionFieldsSave = async (value) => {
974
1017
  columnCheckConfirmFeedback(value)
975
- syncCookiesToLocalShowColumn()
976
- syncCookiesToSearchFormItemOptions()
977
- refreshNfSearchFormModel()
1018
+ await syncCookiesToLocalShowColumn()
1019
+ await syncCookiesToSearchFormItemOptions()
1020
+ await refreshNfSearchFormModel()
978
1021
  await nextTick()
979
1022
  refreshLabel()
980
1023
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "100.1.9",
3
+ "version": "100.1.17",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,23 +14,23 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^100.1.9",
18
- "@94ai/nf-action": "^100.1.9",
19
- "@94ai/nf-double-half-year": "^100.1.9",
20
- "@94ai/nf-double-quarter": "^100.1.9",
21
- "@94ai/nf-double-week": "^100.1.9",
22
- "@94ai/nf-double-year": "^100.1.9",
23
- "@94ai/nf-drawer": "^100.1.9",
24
- "@94ai/nf-form": "^100.1.9",
25
- "@94ai/nf-form-item": "^100.1.9",
26
- "@94ai/nf-half-year-picker": "^100.1.9",
27
- "@94ai/nf-message": "^100.1.9",
28
- "@94ai/nf-quarter-picker": "^100.1.9",
29
- "@94ai/nf-select-transfer": "^100.1.9",
30
- "@94ai/nf-theme-chalk": "^100.1.9",
31
- "@94ai/nf-virtual-select": "^100.1.9",
17
+ "@94ai/common-utils": "^100.1.17",
18
+ "@94ai/nf-action": "^100.1.17",
19
+ "@94ai/nf-double-half-year": "^100.1.17",
20
+ "@94ai/nf-double-quarter": "^100.1.17",
21
+ "@94ai/nf-double-week": "^100.1.17",
22
+ "@94ai/nf-double-year": "^100.1.17",
23
+ "@94ai/nf-drawer": "^100.1.17",
24
+ "@94ai/nf-form": "^100.1.17",
25
+ "@94ai/nf-form-item": "^100.1.17",
26
+ "@94ai/nf-half-year-picker": "^100.1.17",
27
+ "@94ai/nf-message": "^100.1.17",
28
+ "@94ai/nf-quarter-picker": "^100.1.17",
29
+ "@94ai/nf-select-transfer": "^100.1.17",
30
+ "@94ai/nf-theme-chalk": "^100.1.17",
31
+ "@94ai/nf-virtual-select": "^100.1.17",
32
+ "idb-keyval": "^6.2.1",
32
33
  "resize-observer-polyfill": "^1.5.1",
33
- "vue-cookies": "^1.8.3",
34
34
  "vue-demi": "^0.14.5",
35
35
  "vuedraggable": "^2.24.3"
36
36
  },
@@ -47,5 +47,5 @@
47
47
  "types": "lib/index.d.ts",
48
48
  "main": "lib/nf-search-form.cjs.js",
49
49
  "module": "lib/nf-search-form.esm-bundler.js",
50
- "gitHead": "39459d15baea73427838a5d69ff485723b3dc9f2"
50
+ "gitHead": "8cbd9254da4ec43f46b29198c0839bf2ba19132d"
51
51
  }
package/package/README.md DELETED
@@ -1,137 +0,0 @@
1
- ##
2
- ## 搜索栏组件
3
-
4
- ### 示例
5
- <ai-search-form :formOptions="searchOption" @onSearch="search">
6
- <template slot="btnBox">
7
- <el-button>新增按钮</el-button>
8
- </template>
9
- </ai-search-form>
10
-
11
- <!-- searchOption: [
12
- {
13
- label: '意见内容',
14
- prop: 'content',
15
- element: 'el-input',
16
- width: '200px'
17
- },
18
- {
19
- label: '数字',
20
- prop: 'content2',
21
- element: 'el-input-number',
22
- width: '200px'
23
- },
24
- {
25
- label: '状态',
26
- prop: 'status',
27
- element: 'el-select',
28
- options: [
29
- { label: '给点意见', value: '1' },
30
- { label: '售后问题', value: '2' }
31
- ]
32
- },
33
- {
34
- label: '提交时间',
35
- prop: 'timeRange',
36
- element: 'el-date-picker'
37
- },
38
- {
39
- label: '固定时间',
40
- prop: 'guding',
41
- element: 'el-time-select',
42
- 'picker-options': {
43
- start: '08:30',
44
- step: '00:10',
45
- end: '18:30'
46
- }
47
- },
48
- {
49
- label: '时间区间',
50
- prop: 'time',
51
- element: 'el-time-select',
52
- type: 'timeRange',
53
- 'picker-options': {
54
- start: '08:30',
55
- step: '00:10',
56
- end: '18:30'
57
- }
58
- },
59
- {
60
- label: '数字区间',
61
- prop: 'number',
62
- element: 'number-range',
63
- initValue: [],
64
- min: 0,
65
- events: {
66
- change(val) {
67
- console.log(val)
68
- }
69
- }
70
- }
71
- ] -->
72
-
73
- ### 字段说明
74
-
75
- ## formOptions 表单配置项
76
- /**
77
- * 表单配置
78
- * 示例:
79
- * [{
80
- * label: '用户名', // label文字
81
- * prop: 'username', // 字段名
82
- * element: 'el-input', // 指定elementui组件
83
- * initValue: '阿黄', // 字段初始值
84
- * placeholder: '请输入用户名', // elementui组件属性
85
- * rules: [{ required: true, message: '必填项', trigger: 'blur' }], // elementui组件属性
86
- * hidden:false, // 显示隐藏
87
- * events: { // elementui组件方法
88
- * input (val) {
89
- * console.log(val)
90
- * },
91
- * ...... // 可添加任意elementui组件支持的方法
92
- * }
93
- * ...... // 可添加任意elementui组件支持的属性
94
- * }]
95
- */
96
-
97
- element 支持组件类型:
98
- 1.el-input
99
- 2.el-input-number
100
- 3.el-select
101
- 4.el-date-picker
102
- 5.el-cascader
103
- 6.el-time-select
104
- 7.el-time-select(固定时间范围,需要type:timeRange)
105
- 8.el-time-picker
106
- 自定义组件
107
- 1.number-range(继承el-number-input属性)
108
-
109
- ## btnItems 提交按钮
110
- 多个用逗号分隔(search, export, reset)
111
-
112
- ## labelWidth 标题宽度
113
-
114
- ## itemWidth 内容宽度
115
-
116
- ## btnModel 搜索按钮模式
117
- flex 左右分布
118
- inline 行内模式
119
-
120
- ### 方法说明
121
- 1.onSearch 点击搜索按钮
122
- 2.onExport 点击导出按钮
123
- 3.onChange 值变化
124
-
125
- ### slot
126
- slot="btnBox" 按钮扩展
127
-
128
- ### 建议说明
129
- ## 组件使用建议
130
- 1.文本输入框 使用el-input
131
- 2.数字输入框 使用el-input-number
132
- 3.单选选择、多项选择、radio选择、checkbox选择、开关切换 使用el-select
133
- 4.日期选择 使用el-date-picker
134
- 5.数字范围选择 使用number-range
135
- 6.级联选择器(如二三级联动) 使用el-cascader
136
- 7.时间选择 使用el-time-select
137
- 8.时间范围选择 使用el-time-select(固定时间范围,需要type:timeRange)