fit2cloud-ui-plus 0.0.1-beta.16 → 0.0.1-beta.19

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.
Files changed (83) hide show
  1. package/lib/fit2cloud-ui-plus.es.js +1057 -242
  2. package/lib/fit2cloud-ui-plus.umd.js +1 -1
  3. package/package.json +2 -2
  4. package/src/components/filter-bar/FuFilter.vue +3 -2
  5. package/src/components/filter-bar/FuFilterBar.vue +5 -5
  6. package/src/components/filter-bar/FuFilterInput.vue +4 -1
  7. package/src/components/filter-bar/filter-components/FuFilterDate.vue +17 -13
  8. package/src/components/filter-bar/filter-components/FuFilterDateTime.vue +4 -4
  9. package/src/components/filter-bar/filter-components/FuFilterSelect.vue +5 -4
  10. package/src/components/read-write-switch/FuSelectRwSwitch.vue +23 -10
  11. package/src/components/search-bar/FuComplexSearch.vue +66 -132
  12. package/src/components/search-bar/FuQuickSearch.vue +21 -51
  13. package/src/components/search-bar/FuSearchBar.vue +120 -125
  14. package/src/components/search-bar/FuSearchBarButton.vue +15 -14
  15. package/src/components/search-bar/FuSearchContions.vue +26 -15
  16. package/src/components/search-bar/complex-components/FuComplexDate.vue +8 -7
  17. package/src/components/search-bar/complex-components/FuComplexDateTime.vue +23 -17
  18. package/src/components/search-bar/complex-components/FuComplexInput.vue +10 -3
  19. package/src/components/search-bar/complex-components/FuComplexSelect.vue +17 -10
  20. package/src/components/search-bar/index.ts +20 -0
  21. package/src/components/search-bar/types.ts +1 -1
  22. package/src/hooks/index.ts +0 -1
  23. package/src/hooks/use-global-config/index.ts +26 -8
  24. package/src/hooks/use-locale/index.ts +1 -1
  25. package/src/hooks/use-size/index.ts +11 -5
  26. package/src/index.ts +5 -2
  27. package/src/styles/common/function.scss +14 -4
  28. package/src/styles/common/mixins.scss +9 -4
  29. package/src/styles/common/variables.scss +33 -11
  30. package/src/styles/components/filter-bar.scss +9 -10
  31. package/src/styles/components/search-bar.scss +27 -71
  32. package/src/styles/components/table.scss +5 -5
  33. package/src/styles/index.scss +2 -0
  34. package/src/styles/var.scss +8 -0
  35. package/types/examples/pages/search/attributes.d.ts +57 -0
  36. package/types/examples/pages/search/demo/BaseSearchbar.vue.d.ts +66 -0
  37. package/types/examples/pages/search/demo/ComplexComponentsDemo.vue.d.ts +60 -0
  38. package/types/examples/pages/search/demo/ComplexSearchDemo.vue.d.ts +84 -0
  39. package/types/examples/pages/search/demo/CustomComponentsDemo.vue.d.ts +50 -0
  40. package/types/examples/pages/search/demo/EchoConditionsDemo.vue.d.ts +52 -0
  41. package/types/examples/pages/search/demo/QuickSearchDemo.vue.d.ts +18 -0
  42. package/types/examples/pages/search/demo/SearchBarButtonDemo.vue.d.ts +54 -0
  43. package/types/examples/pages/search/index.vue.d.ts +150 -0
  44. package/types/examples/pages/search-bar/attributes.d.ts +63 -0
  45. package/types/examples/pages/search-bar/demo/BaseSearchbar.vue.d.ts +31 -0
  46. package/types/examples/pages/search-bar/demo/ComplexSearchDemo.vue.d.ts +40 -0
  47. package/types/examples/pages/search-bar/demo/EchoConditionsDemo.vue.d.ts +32 -0
  48. package/types/examples/pages/search-bar/demo/QuickSearchDemo.vue.d.ts +7 -0
  49. package/types/examples/pages/search-bar/demo/SearchBarButtonDemo.vue.d.ts +32 -0
  50. package/types/examples/pages/search-bar/index.vue.d.ts +2 -0
  51. package/types/examples/pages/table/demo/TablePagination.vue.d.ts +1 -1
  52. package/types/src/components/filter-bar/FuFilter.vue.d.ts +3 -0
  53. package/types/src/components/filter-bar/FuFilterBar.vue.d.ts +12 -1
  54. package/types/src/components/filter-bar/FuFilterInput.vue.d.ts +17 -0
  55. package/types/src/components/filter-bar/index.d.ts +2 -2
  56. package/types/src/components/read-write-switch/FuSelectRwSwitch.vue.d.ts +11 -1
  57. package/types/src/components/search-bar/FuComplexSearch.vue.d.ts +22 -0
  58. package/types/src/components/search-bar/FuQuickSearch.vue.d.ts +29 -0
  59. package/types/src/components/search-bar/FuSearchBar.vue.d.ts +58 -0
  60. package/types/src/components/search-bar/FuSearchBarButton.vue.d.ts +14 -0
  61. package/types/src/components/search-bar/FuSearchContions.vue.d.ts +26 -0
  62. package/types/src/components/search-bar/complex-components/FuComplexDate.vue.d.ts +36 -0
  63. package/types/src/components/search-bar/complex-components/FuComplexDateTime.vue.d.ts +36 -0
  64. package/types/src/components/search-bar/complex-components/FuComplexInput.vue.d.ts +26 -0
  65. package/types/src/components/search-bar/complex-components/FuComplexSelect.vue.d.ts +50 -0
  66. package/types/src/components/search-bar/complex-components/index.d.ts +0 -0
  67. package/types/src/components/search-bar/complex-components/mixins.d.ts +6 -0
  68. package/types/src/components/search-bar/index.d.ts +2 -0
  69. package/types/src/components/search-bar/types.d.ts +17 -0
  70. package/types/src/hooks/use-global-config/index.d.ts +9 -1
  71. package/types/src/hooks/use-size/index.d.ts +5 -1
  72. package/types/src/index.d.ts +2 -1
  73. package/src/components/read-write-switch/index.d.ts +0 -2
  74. package/src/components/read-write-switch/types.d.ts +0 -4
  75. package/src/components/search-bar/complex-components/index.js +0 -16
  76. package/src/components/search-bar/complex-components/mixins.js +0 -26
  77. package/src/components/search-bar/index.js +0 -16
  78. package/src/components/table/index.d.ts +0 -2
  79. package/src/components/table/table-column-select/utils.d.ts +0 -8
  80. package/src/components/table/types.d.ts +0 -2
  81. package/src/hooks/use-global-config/index.d.ts +0 -1
  82. package/src/hooks/use-locale/index.d.ts +0 -14
  83. package/src/hooks/use-size/index.d.ts +0 -5
@@ -6,7 +6,7 @@
6
6
  <el-popover popper-class="fu-filter-component-popover" :show-arrow="false" placement="bottom-start"
7
7
  trigger="click" width="240">
8
8
  <el-select v-model="selection" v-bind="$attrs" :multiple="multiple" @change="change" :teleported="false"
9
- :size="size" :placeholder="t('fu.search_bar.please_select')">
9
+ :size="configSize" :placeholder="t('fu.search_bar.please_select')">
10
10
  <el-option value="" v-if="useSelectAll && multiple">
11
11
  <div @click="selectAll">{{ t('fu.filter_bar.select_all') }}</div>
12
12
  </el-option>
@@ -30,10 +30,9 @@ import { ref, provide, computed, PropType, Ref, inject } from "vue";
30
30
  import FuFilterOption from "./FuFilterOption.vue";
31
31
  import { FilterCondition, OptionProps, ReferenceContext, referenceKey, selectKey } from "../types";
32
32
 
33
- import { useLocale } from "@/hooks"
33
+ import {useLocale, useSize} from "@/hooks"
34
34
  import { validateSize } from "@/tools/size";
35
35
  defineOptions({ name: "FuFilterSelect" });
36
- const { t } = useLocale()
37
36
 
38
37
  const props = defineProps({
39
38
  size: {
@@ -65,7 +64,7 @@ const props = defineProps({
65
64
  const emit = defineEmits(["change"])
66
65
 
67
66
  const selection: Ref<Array<string | number> | string | number> = ref(props.multiple ? [] : '')
68
-
67
+ const configSize = useSize()
69
68
  const showOptions = computed(() => {
70
69
  return props.options.filter((o, i) => {
71
70
  let show = props.showLimit < 0 ? true : i < props.showLimit
@@ -88,6 +87,8 @@ const valueLabel = computed(() => {
88
87
  return getValueLabel(selection.value);
89
88
  })
90
89
 
90
+ const { t } = useLocale()
91
+
91
92
  function change(v: string) {
92
93
  if (v.includes("")) {
93
94
  selection.value = props.options.map(o => o.value)
@@ -7,9 +7,9 @@
7
7
  </template>
8
8
  <template #default="{ read }">
9
9
  <el-select v-model="data" v-bind="$attrs" @input="input" @blur="blur(read, $event)"
10
- @change="change(read, $event)">
10
+ @change="change(read, $event)">
11
11
  <slot>
12
- <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value" />
12
+ <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"/>
13
13
  </slot>
14
14
  </el-select>
15
15
  </template>
@@ -17,15 +17,22 @@
17
17
  </template>
18
18
 
19
19
  <script setup lang="ts">
20
- import { ref, watch, PropType } from "vue";
21
- import { OptionProps } from "./types";
22
- defineOptions({ name: "FuSelectRwSwitch" });
20
+ import FuReadWriteSwitch from "./FuReadWriteSwitch.vue";
21
+ import {watch, ref, PropType} from "vue";
22
+ import {OptionProps} from "./types";
23
+
24
+ defineOptions({name: "FuSelectRwSwitch"});
25
+
23
26
  const props = defineProps({
24
27
  modelValue: [String, Number],
25
28
  options: {
26
29
  type: Array as PropType<OptionProps[]>,
27
30
  default: []
28
31
  },
32
+ blurTime: {
33
+ type: Number,
34
+ default: 150
35
+ },
29
36
  writeTrigger: {
30
37
  type: String,
31
38
  default: "onClick",
@@ -34,22 +41,28 @@ const props = defineProps({
34
41
  }
35
42
  }
36
43
  })
37
- const emit = defineEmits(["input", "blur", "change"])
44
+ const emit = defineEmits(["input", "blur", "change", "update:modelValue"])
38
45
  const data = ref(props.modelValue)
39
46
 
40
47
  watch(() => props.modelValue, (v) => {
41
48
  data.value = v
42
49
  })
50
+
43
51
  function input(e: Event) {
44
52
  emit("input", data.value, e)
45
53
  }
54
+
46
55
  function blur(read: Function, e: Event) {
47
- setTimeout(() => {
48
- read()
49
- }, 100)
50
- emit("blur", data.value, e)
56
+ if (props.blurTime > 0) {
57
+ setTimeout(() => {
58
+ read()
59
+ }, props.blurTime)
60
+ emit("blur", e)
61
+ }
51
62
  }
63
+
52
64
  function change(read: Function, e: Event) {
65
+ emit("update:modelValue", data.value, e)
53
66
  emit("change", data.value, e)
54
67
  read()
55
68
  }
@@ -1,170 +1,104 @@
1
1
  <template>
2
- <div class="fu-complex-search">
3
- <el-popover
4
- trigger="manual"
5
- v-model="active"
6
- :visible-arrow="false"
7
- @hide="closePopover"
8
- popper-class="fu-complex-components">
9
-
2
+ <el-popover :visible="active" :show-arrow="false" @hide="hide" width="auto" popper-class="fu-complex-components">
3
+ <div class="fu-complex-components">
10
4
  <div class="fu-complex-components__body">
11
- <slot></slot>
5
+ <slot>
6
+ <component v-for="c in components" :is="c.component" v-bind="c" :size="configSize"/>
7
+ </slot>
12
8
  </div>
13
9
  <div class="fu-complex-components__footer">
14
- <el-button @click="active=false" :size="size">{{ t('fu.search_bar.cancel') }}</el-button>
15
- <el-button type="primary" @click="ok" :size="size">{{ t('fu.search_bar.ok') }}</el-button>
10
+ <el-button @click="close" :size="configSize">{{ t('fu.search_bar.cancel') }}</el-button>
11
+ <el-button type="primary" @click="ok" :size="configSize">{{ t('fu.search_bar.ok') }}</el-button>
16
12
  </div>
17
-
18
- <fu-search-bar-button
19
- slot="reference"
20
- icon="el-icon-arrow-right"
21
- @click="toggle"
22
- :size="size"
23
- :class="['fu-complex-search__trigger',{'is-active':active}]"
24
- :tooltip="t('fu.search_bar.adv_search')"/>
25
- </el-popover>
26
- </div>
13
+ </div>
14
+ <template #reference>
15
+ <el-button circle icon="ArrowRightBold" @click="toggle" :size="configSize" v-show="showComplex"
16
+ :class="['fu-complex-components-trigger', {'is-active':active}]"/>
17
+ </template>
18
+ </el-popover>
27
19
  </template>
28
20
 
29
21
  <script setup lang="ts">
30
- import {ref, computed} from "vue";
31
- import {useLocale} from "@/hooks"
22
+ import {ref, inject, computed, PropType} from "vue";
23
+ import {useLocale, useSize} from "@/hooks"
32
24
  import {validateSize} from "@/tools/size";
33
- import FuSearchBarButton from "@/components/search-bar/FuSearchBarButton";
25
+ import {ComplexCondition, referenceKey} from "./types";
34
26
 
35
27
  defineOptions({name: "FuComplexSearch"});
36
28
 
37
- defineProps({
29
+ const props = defineProps({
38
30
  size: {
39
31
  type: String,
40
32
  validator: validateSize
41
33
  },
42
- resultCount: Number,
43
- quickPlaceholder: String,
44
- components: Array
34
+ components: Array as PropType<any[]>,
45
35
  })
46
36
 
47
- const emit = defineEmits(["exec"])
37
+ const emit = defineEmits(["close", "change"])
38
+
39
+ const active = ref(false)
40
+ const references = inject(referenceKey)
48
41
 
49
- const quick = ref("")
50
- const conditions = ref([])
42
+ const configSize = useSize()
51
43
 
52
- const filterRef = ref()
44
+ const showComplex = computed(() => {
45
+ return references ? references.value.length > 0 : false
46
+ })
53
47
 
54
48
  const {t} = useLocale()
55
49
 
56
- function open() {
57
- filterRef.value?.open()
50
+ function hide() {
51
+ emit("close")
58
52
  }
59
53
 
60
- function change() {
61
- emit("exec", conditionObj.value)
54
+ function toggle() {
55
+ active.value = !active.value
56
+ if (active.value) {
57
+ references?.value.forEach(r => r.init())
58
+ }
62
59
  }
63
60
 
64
- function filter(c: any) {
65
- conditions.value = c
66
- emit("exec", conditionObj.value)
61
+ function close() {
62
+ active.value = false
67
63
  }
68
64
 
69
- function setConditions(conditionObj: any) {
70
- filterRef.value?.setConditions(conditionObj)
65
+ function ok() {
66
+ close()
67
+ exec()
71
68
  }
72
69
 
73
- const conditionObj = computed(() => {
74
- let obj: any = {quick: quick.value}
75
- conditions.value.forEach((c: any) => {
76
- obj[c.field] = c
70
+ function exec() {
71
+ let conditions: any = [];
72
+ references?.value.forEach(r => {
73
+ let condition = r.getCondition()
74
+ if (condition && condition.value !== undefined) {
75
+ conditions.push(condition)
76
+ }
77
77
  })
78
- return obj
79
- });
80
-
81
- defineExpose({
82
- setConditions
83
- })
84
- </script>
85
-
86
- <script>
87
- import FuSearchBarButton from "@/components/search-bar/FuSearchBarButton";
88
- import Locale from "@/mixins/locale";
89
- import ConfigSize from "@/mixins/config-size";
78
+ emit("change", conditions)
79
+ }
90
80
 
91
- export default {
92
- name: "FuComplexSearch",
93
- components: {FuSearchBarButton},
94
- mixins: [Locale, ConfigSize],
95
- props: {
96
- components: Array,
97
- },
98
- data() {
99
- return {
100
- active: false,
101
- }
102
- },
103
- methods: {
104
- closePopover() {
105
- this.$emit("close")
106
- },
107
- toggle() {
108
- this.active = !this.active
109
- this.refs.forEach(r => {
110
- if (r.init) {
111
- r.init()
112
- } else {
113
- console.warn("init undefined", r)
114
- }
115
- })
116
- },
117
- close() {
118
- this.active = false
119
- },
120
- ok() {
121
- this.active = false
122
- let conditions = [];
123
- this.refs.forEach(r => {
124
- let condition
125
- if (r.getCondition) {
126
- condition = r.getCondition()
127
- } else {
128
- console.warn("getCondition undefined", r)
129
- }
130
- if (condition && condition.value !== undefined) {
131
- conditions.push(condition)
81
+ function setConditions(conditionObj: any): ComplexCondition[] {
82
+ let result: ComplexCondition[] = []
83
+ if (conditionObj) {
84
+ Object.keys(conditionObj).forEach(key => {
85
+ let c = conditionObj[key]
86
+ references?.value.forEach(r => {
87
+ if (r.field === key) {
88
+ r.init(c.value)
89
+ const condition = r.getCondition()
90
+ if (condition) {
91
+ result.push(condition)
92
+ }
132
93
  }
133
94
  })
134
- this.$emit("change", conditions)
135
- },
136
- createConditions(conditions) {
137
- let result = []
138
- if (conditions) {
139
- Object.keys(conditions).forEach(key => {
140
- let c = conditions[key]
141
- this.refs.forEach(r => {
142
- if (r.field === key) {
143
- result.push(r.createCondition(c.value, c.operator))
144
- }
145
- })
146
- })
147
- }
148
- return result
149
- }
150
- },
151
- computed: {
152
- refs() {
153
- let refs = [];
154
- if (this.$slots?.default) {
155
- // 使用slot
156
- this.$slots.default.forEach(component => {
157
- refs.push(component.componentInstance)
158
- })
159
- } else {
160
- // 使用components
161
- let $refs = this.$refs
162
- this.components.forEach(c => {
163
- refs.push($refs[c.field][0])
164
- })
165
- }
166
- return refs
167
- }
95
+ })
168
96
  }
97
+ return result
169
98
  }
99
+
100
+ defineExpose({
101
+ setConditions,
102
+ close
103
+ })
170
104
  </script>
@@ -1,8 +1,10 @@
1
1
  <template>
2
- <div :class="['fu-quick-search', 'fu-quick-search--' + size]">
3
- <i class="el-icon-search" v-if="useIcon"/>
2
+ <div :class="['fu-quick-search', 'fu-quick-search--' + configSize]">
3
+ <el-icon v-if="useIcon">
4
+ <Search/>
5
+ </el-icon>
4
6
  <label>
5
- <input :placeholder="placeholder" v-model="quick" @input="input" @blur="blur" @keydown="keydown"/>
7
+ <input :placeholder="placeholder" v-model="value" @blur="blur" @focus="focus" @keydown="keydown"/>
6
8
  </label>
7
9
  </div>
8
10
  </template>
@@ -11,8 +13,9 @@
11
13
  <script setup lang="ts">
12
14
  import {computed, ref, watch} from "vue";
13
15
  import {validateSize} from "@/tools/size";
16
+ import {useSize} from "@/hooks";
14
17
 
15
- defineOptions({name: "FuFilterSelect"});
18
+ defineOptions({name: "FuQuickSearch"});
16
19
 
17
20
  const props = defineProps({
18
21
  size: {
@@ -27,12 +30,11 @@ const props = defineProps({
27
30
  }
28
31
  })
29
32
 
30
- const quick = ref<string>("")
33
+ const focused = ref(false)
31
34
 
32
- const emit = defineEmits<{
33
- (e: "update:modelValue", value: string): void
34
- (e: "change", value: string, event: Event): void
35
- }>()
35
+ const emit = defineEmits(["update:modelValue", "change"])
36
+
37
+ const configSize = useSize()
36
38
 
37
39
  const value = computed({
38
40
  get: () => props.modelValue,
@@ -41,54 +43,22 @@ const value = computed({
41
43
  }
42
44
  })
43
45
 
46
+ function focus() {
47
+ focused.value = true
48
+ }
49
+
44
50
  function blur(e: Event) {
45
- emit("change", quick.value, e)
51
+ if (focused.value) {
52
+ emit("change", value.value, e)
53
+ }
54
+ focused.value = false
46
55
  }
47
56
 
48
57
  function keydown(e: KeyboardEvent) {
49
58
  const {code} = e
50
59
  if (code === "Enter") {
51
- emit("change", quick.value, e)
52
- }
53
- }
54
- </script>
55
-
56
- <script>
57
- import ConfigSize from "@/mixins/config-size";
58
-
59
- export default {
60
- name: "FuQuickSearch",
61
- mixins: [ConfigSize],
62
- props: {
63
- value: String,
64
- placeholder: String,
65
- useIcon: {
66
- type: Boolean,
67
- default: true
68
- }
69
- },
70
- data() {
71
- return {
72
- quick: ""
73
- }
74
- },
75
- watch: {
76
- value(v) {
77
- this.quick = v
78
- }
79
- },
80
- methods: {
81
- input(e) {
82
- this.$emit("input", this.quick, e)
83
- },
84
- blur(e) {
85
- this.$emit("change", this.quick, e)
86
- },
87
- keydown(e) {
88
- if (e.keyCode === 13) {
89
- this.$emit("change", this.quick, e)
90
- }
91
- }
60
+ focused.value = false
61
+ emit("change", value.value, e)
92
62
  }
93
63
  }
94
64
  </script>