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

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 (38) hide show
  1. package/lib/fit2cloud-ui-plus.es.js +27 -28
  2. package/lib/fit2cloud-ui-plus.umd.js +1 -1
  3. package/package.json +2 -2
  4. package/src/components/filter-bar/FuFilter.vue +37 -29
  5. package/src/components/filter-bar/FuFilterBar.vue +25 -16
  6. package/src/components/filter-bar/FuFilterInput.vue +45 -0
  7. package/src/components/filter-bar/index.ts +4 -4
  8. package/src/components/read-write-switch/index.d.ts +2 -0
  9. package/src/components/read-write-switch/types.d.ts +4 -0
  10. package/src/components/search-bar/FuComplexSearch.vue +170 -0
  11. package/src/components/search-bar/FuQuickSearch.vue +94 -0
  12. package/src/components/search-bar/FuSearchBar.vue +158 -0
  13. package/src/components/search-bar/FuSearchBarButton.vue +22 -0
  14. package/src/components/search-bar/FuSearchContions.vue +29 -0
  15. package/src/components/search-bar/complex-components/FuComplexDate.vue +69 -0
  16. package/src/components/search-bar/complex-components/FuComplexDateTime.vue +68 -0
  17. package/src/components/search-bar/complex-components/FuComplexInput.vue +50 -0
  18. package/src/components/search-bar/complex-components/FuComplexSelect.vue +86 -0
  19. package/src/components/search-bar/complex-components/index.js +16 -0
  20. package/src/components/search-bar/complex-components/mixins.js +26 -0
  21. package/src/components/search-bar/index.js +16 -0
  22. package/src/components/search-bar/types.ts +23 -0
  23. package/src/components/table/FuTable.vue +3 -3
  24. package/src/components/table/index.d.ts +2 -0
  25. package/src/components/table/table-column-select/utils.d.ts +8 -0
  26. package/src/components/table/types.d.ts +2 -0
  27. package/src/components/tabs/FuTabs.vue +4 -3
  28. package/src/hooks/use-global-config/index.d.ts +1 -0
  29. package/src/hooks/use-locale/index.d.ts +14 -0
  30. package/src/hooks/use-size/index.d.ts +5 -0
  31. package/src/styles/common/variables.scss +5 -0
  32. package/src/styles/components/filter-bar.scss +6 -3
  33. package/src/styles/components/search-bar.scss +285 -0
  34. package/src/styles/components/table.scss +2 -1
  35. package/types/examples/pages/table/demo/TablePagination.vue.d.ts +1 -1
  36. package/src/.DS_Store +0 -0
  37. package/src/components/.DS_Store +0 -0
  38. package/src/components/filter-bar/FuSearchInput.vue +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fit2cloud-ui-plus",
3
- "version": "0.0.1-beta.13",
3
+ "version": "0.0.1-beta.16",
4
4
  "private": false,
5
5
  "main": "./lib/fit2cloud-ui-plus.es.js",
6
6
  "files": [
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "dependencies": {
26
26
  "@element-plus/icons-vue": "^1.1.4",
27
- "element-plus": "^2.2.2",
27
+ "element-plus": "^2.2.13",
28
28
  "github-markdown-css": "^5.1.0",
29
29
  "prism-theme-vars": "^0.2.3",
30
30
  "prismjs": "^1.28.0",
@@ -1,44 +1,46 @@
1
1
  <template>
2
- <div class="fu-filter" ref="filterRef">
3
- <div class="fu-filter__result">{{ count }} <span style="opacity: 0.6">{{ t('fu.filter_bar.results') }}</span></div>
4
- <div class="fu-filter__split" />
2
+ <div class="fu-filter" ref="filterRef" v-show="show">
3
+ <div class="fu-filter__result">{{ count }} <span style="opacity: 0.6">{{ t('fu.filter_bar.results') }}</span>
4
+ </div>
5
+ <div class="fu-filter__split"/>
5
6
 
6
7
  <div class="fu-filter__scroll" @mousedown="left" @mouseup="mouseup" v-if="scroll">
7
8
  <el-icon>
8
- <ArrowLeftBold />
9
+ <ArrowLeftBold/>
9
10
  </el-icon>
10
11
  </div>
11
12
 
12
- <fu-filter-conditions :conditions="conditions" @change="change" ref="conditionsRef" />
13
+ <fu-filter-conditions :conditions="conditions" @change="change" ref="conditionsRef"/>
13
14
 
14
15
  <div class="fu-filter__scroll" @mousedown="right" @mouseup="mouseup" v-if="scroll">
15
16
  <el-icon>
16
- <ArrowRightBold />
17
+ <ArrowRightBold/>
17
18
  </el-icon>
18
19
  </div>
19
20
 
20
21
  <div class="fu-filter__clear fu-scale-click" @click="clear" v-if="conditions.length > 0">
21
22
  <el-icon>
22
- <Delete />
23
+ <Delete/>
23
24
  </el-icon>
24
25
  {{ t('fu.filter_bar.clear') }}
25
26
  </div>
26
-
27
- <el-drawer :size="drawerWidth" custom-class="fu-filter__drawer" :title="t('fu.filter_bar.drawer_title')"
28
- v-model="drawer" @open="initComponents">
29
- <div class="drawer-body">
30
- <slot>
31
- <component v-for="(c, i) in components" :key="i" :is="c.component" v-bind="c" :ref="c.field" v-on="c" :size="size"/>
32
- </slot>
33
- </div>
34
- <div class="drawer-footer">
35
- <slot name="footer">
36
- <el-button :size="size" @click="drawer = false">{{ t('fu.filter_bar.cancel') }}</el-button>
37
- <el-button :size="size" type="primary" @click="filter">{{ t('fu.filter_bar.search') }}</el-button>
38
- </slot>
39
- </div>
40
- </el-drawer>
41
27
  </div>
28
+
29
+ <el-drawer :size="drawerWidth" custom-class="fu-filter__drawer" :title="t('fu.filter_bar.drawer_title')"
30
+ v-model="drawer" @open="initComponents">
31
+ <div class="drawer-body">
32
+ <slot>
33
+ <component v-for="(c, i) in components" :key="i" :is="c.component" v-bind="c" :ref="c.field" v-on="c"
34
+ :size="size"/>
35
+ </slot>
36
+ </div>
37
+ <div class="drawer-footer">
38
+ <slot name="footer">
39
+ <el-button :size="size" @click="drawer = false">{{ t('fu.filter_bar.cancel') }}</el-button>
40
+ <el-button :size="size" type="primary" @click="filter">{{ t('fu.filter_bar.search') }}</el-button>
41
+ </slot>
42
+ </div>
43
+ </el-drawer>
42
44
  </template>
43
45
 
44
46
  <script setup lang="ts">
@@ -52,16 +54,17 @@ import {
52
54
  ComponentPublicInstance
53
55
  } from "vue";
54
56
  import FuFilterConditions from "./FuFilterConditions.vue";
55
- import { useLocale } from "@/hooks"
56
- import { validateSize } from "@/tools/size";
57
- import { FilterCondition, ReferenceContext, referenceKey } from "@/components/filter-bar/types";
58
- defineOptions({ name: "FuFilter" });
59
- const { t } = useLocale()
57
+ import {useLocale} from "@/hooks"
58
+ import {validateSize} from "@/tools/size";
59
+ import {FilterCondition, ReferenceContext, referenceKey} from "@/components/filter-bar/types";
60
+
61
+ defineOptions({name: "FuFilter"});
62
+ const {t} = useLocale()
60
63
 
61
64
  const filterRef = ref<HTMLElement | null>(null)
62
65
  const conditionsRef = ref<ComponentPublicInstance | null>(null)
63
66
 
64
- defineProps({
67
+ const props = defineProps({
65
68
  size: {
66
69
  type: String,
67
70
  validator: validateSize
@@ -74,7 +77,8 @@ defineProps({
74
77
  drawerWidth: {
75
78
  type: [Number, String],
76
79
  default: "680px"
77
- }
80
+ },
81
+ showEmpty: Boolean
78
82
  })
79
83
 
80
84
  const emit = defineEmits(["filter"])
@@ -167,6 +171,10 @@ const scrollWidth = computed(() => {
167
171
  return el === null ? 0 : el.getBoundingClientRect().width - 210
168
172
  })
169
173
 
174
+ const show = computed(() => {
175
+ return (conditions.value.length > 0 && props.showEmpty === false) || props.showEmpty
176
+ })
177
+
170
178
  provide(referenceKey, references)
171
179
 
172
180
  onMounted(() => {
@@ -5,19 +5,19 @@
5
5
  <slot name="tl"></slot>
6
6
  </div>
7
7
  <div class="top_right">
8
- <slot name="tr">
9
- <fu-search-input :size="size" v-model="quick" :placeholder="quickPlaceholder" @change="change" />
10
- <el-button @click="open" icon="Filter" :size="size">{{ t('fu.filter_bar.filter') }}
11
- <span v-if="conditions.length > 0">({{ conditions.length }})</span>
12
- </el-button>
8
+ <slot name="tr" :condition="conditionObj">
9
+ <fu-filter-input :size="size" v-model="quick" :placeholder="quickPlaceholder" @change="change"/>
13
10
  </slot>
11
+ <el-button class="fu-filter-button" @click="open" icon="Filter" :size="size">{{ t('fu.filter_bar.filter') }}
12
+ <span v-if="conditions.length > 0">({{ conditions.length }})</span>
13
+ </el-button>
14
14
 
15
15
  <slot name="buttons"></slot>
16
-
17
16
  </div>
18
17
  </div>
19
18
  <div class="fu-filter-bar__bottom">
20
- <fu-filter ref="filterRef" @filter="filter" :count="resultCount" :components="components" :size="size">
19
+ <fu-filter ref="filterRef" @filter="filter" :count="resultCount" :components="components" :size="size"
20
+ :show-empty="showEmpty">
21
21
  <slot></slot>
22
22
  </fu-filter>
23
23
  </div>
@@ -25,13 +25,14 @@
25
25
  </template>
26
26
 
27
27
  <script setup lang="ts">
28
- import { ref, computed } from "vue";
29
- import { useLocale } from "@/hooks"
30
- import { validateSize } from "@/tools/size";
31
- import FuSearchInput from "@/components/filter-bar/FuSearchInput.vue";
28
+ import {ref, computed} from "vue";
29
+ import {useLocale} from "@/hooks"
30
+ import {validateSize} from "@/tools/size";
31
+ import FuFilterInput from "@/components/filter-bar/FuFilterInput.vue";
32
32
  import FuFilter from "@/components/filter-bar/FuFilter.vue";
33
- defineOptions({ name: "FuFilterBar" });
34
- const { t } = useLocale()
33
+
34
+ defineOptions({name: "FuFilterBar"});
35
+ const {t} = useLocale()
35
36
  defineProps({
36
37
  size: {
37
38
  type: String,
@@ -39,7 +40,11 @@ defineProps({
39
40
  },
40
41
  resultCount: Number,
41
42
  quickPlaceholder: String,
42
- components: Array
43
+ components: Array,
44
+ showEmpty: {
45
+ type: Boolean,
46
+ default: false
47
+ }
43
48
  })
44
49
 
45
50
  const emit = defineEmits(["exec"])
@@ -67,7 +72,10 @@ function setConditions(conditionObj: any) {
67
72
  }
68
73
 
69
74
  const conditionObj = computed(() => {
70
- let obj: any = { quick: quick.value }
75
+ let obj: any = {}
76
+ if (quick.value) {
77
+ obj.quick = quick.value
78
+ }
71
79
  conditions.value.forEach((c: any) => {
72
80
  obj[c.field] = c
73
81
  })
@@ -75,6 +83,7 @@ const conditionObj = computed(() => {
75
83
  });
76
84
 
77
85
  defineExpose({
78
- setConditions
86
+ setConditions,
87
+ open
79
88
  })
80
89
  </script>
@@ -0,0 +1,45 @@
1
+ <template>
2
+ <el-input class="fu-filter-input" prefix-icon="Search" v-model="quick" @input="input" @blur="blur" @keydown="keydown"
3
+ @clear="clear" v-bind="$attrs" clearable :size="size"/>
4
+ </template>
5
+
6
+ <script setup lang="ts">
7
+ import {ref, watch} from "vue";
8
+ import {validateSize} from "@/tools/size";
9
+
10
+ defineOptions({name: "FuFilterInput"});
11
+
12
+ const props = defineProps({
13
+ size: {
14
+ type: String,
15
+ validator: validateSize
16
+ },
17
+ modelValue: String,
18
+ })
19
+ const emit = defineEmits(["update:modelValue", "change"])
20
+ const quick = ref("")
21
+
22
+ watch(() => props.modelValue, (val: any) => {
23
+ quick.value = val
24
+ })
25
+
26
+ function input(e: Event) {
27
+ emit("update:modelValue", quick.value, e)
28
+ }
29
+
30
+ function blur(e: Event) {
31
+ emit("change", quick.value, e)
32
+ }
33
+
34
+ function clear() {
35
+ emit("update:modelValue", quick.value)
36
+ emit("change", quick.value)
37
+ }
38
+
39
+ function keydown(e: Event) {
40
+ const event = e as KeyboardEvent
41
+ if (event.key === "Enter") {
42
+ emit("change", quick.value, e)
43
+ }
44
+ }
45
+ </script>
@@ -1,4 +1,4 @@
1
- import FuSearchInput from "./FuSearchInput.vue";
1
+ import FuFilterInput from "./FuFilterInput.vue";
2
2
  import FuFilterBar from "./FuFilterBar.vue";
3
3
  import FuFilter from "./FuFilter.vue";
4
4
  import FuFilterSelect from "./filter-components/FuFilterSelect.vue";
@@ -6,13 +6,13 @@ import FuFilterDate from "./filter-components/FuFilterDate.vue";
6
6
  import FuFilterDateTime from "./filter-components/FuFilterDateTime.vue";
7
7
  import type { App } from "vue";
8
8
 
9
- FuSearchInput.install = (app: App): void => {
9
+ FuFilterBar.install = (app: App): void => {
10
10
  app.component(FuFilterBar.name, FuFilterBar);
11
11
  app.component(FuFilter.name, FuFilter);
12
- app.component(FuSearchInput.name, FuSearchInput);
12
+ app.component(FuFilterInput.name, FuFilterInput);
13
13
  app.component(FuFilterSelect.name, FuFilterSelect);
14
14
  app.component(FuFilterDate.name, FuFilterDate);
15
15
  app.component(FuFilterDateTime.name, FuFilterDateTime);
16
16
  };
17
17
 
18
- export default FuSearchInput;
18
+ export default FuFilterBar;
@@ -0,0 +1,2 @@
1
+ import FuReadWriteSwitch from "./FuReadWriteSwitch.vue";
2
+ export default FuReadWriteSwitch;
@@ -0,0 +1,4 @@
1
+ export interface OptionProps {
2
+ label: string;
3
+ value: string | number;
4
+ }
@@ -0,0 +1,170 @@
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
+
10
+ <div class="fu-complex-components__body">
11
+ <slot></slot>
12
+ </div>
13
+ <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>
16
+ </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>
27
+ </template>
28
+
29
+ <script setup lang="ts">
30
+ import {ref, computed} from "vue";
31
+ import {useLocale} from "@/hooks"
32
+ import {validateSize} from "@/tools/size";
33
+ import FuSearchBarButton from "@/components/search-bar/FuSearchBarButton";
34
+
35
+ defineOptions({name: "FuComplexSearch"});
36
+
37
+ defineProps({
38
+ size: {
39
+ type: String,
40
+ validator: validateSize
41
+ },
42
+ resultCount: Number,
43
+ quickPlaceholder: String,
44
+ components: Array
45
+ })
46
+
47
+ const emit = defineEmits(["exec"])
48
+
49
+ const quick = ref("")
50
+ const conditions = ref([])
51
+
52
+ const filterRef = ref()
53
+
54
+ const {t} = useLocale()
55
+
56
+ function open() {
57
+ filterRef.value?.open()
58
+ }
59
+
60
+ function change() {
61
+ emit("exec", conditionObj.value)
62
+ }
63
+
64
+ function filter(c: any) {
65
+ conditions.value = c
66
+ emit("exec", conditionObj.value)
67
+ }
68
+
69
+ function setConditions(conditionObj: any) {
70
+ filterRef.value?.setConditions(conditionObj)
71
+ }
72
+
73
+ const conditionObj = computed(() => {
74
+ let obj: any = {quick: quick.value}
75
+ conditions.value.forEach((c: any) => {
76
+ obj[c.field] = c
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";
90
+
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)
132
+ }
133
+ })
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
+ }
168
+ }
169
+ }
170
+ </script>
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div :class="['fu-quick-search', 'fu-quick-search--' + size]">
3
+ <i class="el-icon-search" v-if="useIcon"/>
4
+ <label>
5
+ <input :placeholder="placeholder" v-model="quick" @input="input" @blur="blur" @keydown="keydown"/>
6
+ </label>
7
+ </div>
8
+ </template>
9
+
10
+
11
+ <script setup lang="ts">
12
+ import {computed, ref, watch} from "vue";
13
+ import {validateSize} from "@/tools/size";
14
+
15
+ defineOptions({name: "FuFilterSelect"});
16
+
17
+ const props = defineProps({
18
+ size: {
19
+ type: String,
20
+ validator: validateSize
21
+ },
22
+ modelValue: String,
23
+ placeholder: String,
24
+ useIcon: {
25
+ type: Boolean,
26
+ default: true
27
+ }
28
+ })
29
+
30
+ const quick = ref<string>("")
31
+
32
+ const emit = defineEmits<{
33
+ (e: "update:modelValue", value: string): void
34
+ (e: "change", value: string, event: Event): void
35
+ }>()
36
+
37
+ const value = computed({
38
+ get: () => props.modelValue,
39
+ set: (val) => {
40
+ emit("update:modelValue", val as string)
41
+ }
42
+ })
43
+
44
+ function blur(e: Event) {
45
+ emit("change", quick.value, e)
46
+ }
47
+
48
+ function keydown(e: KeyboardEvent) {
49
+ const {code} = e
50
+ 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
+ }
92
+ }
93
+ }
94
+ </script>