@jetlinks-web/components 2.0.2 → 2.0.4-1

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 (245) hide show
  1. package/es/AMap/Map.js +125 -0
  2. package/es/AMap/index.js +2 -0
  3. package/es/AMap/util.js +56 -0
  4. package/es/BadgeStatus/Badge.js +54 -0
  5. package/es/BadgeStatus/color.js +21 -0
  6. package/es/BadgeStatus/index.js +3 -0
  7. package/es/CardSelect/CardSelect.js +123 -0
  8. package/es/CardSelect/index.js +2 -0
  9. package/es/CheckButton/CheckButton.js +120 -0
  10. package/es/CheckButton/index.js +2 -0
  11. package/es/CheckButton/style/index.css +37 -0
  12. package/es/CheckButton/style/index.less +40 -0
  13. package/es/ConfigProvider/context.js +12 -0
  14. package/es/ConfigProvider/index.js +31 -0
  15. package/es/Echarts/Echarts.js +47 -0
  16. package/es/Echarts/index.js +2 -0
  17. package/es/Ellipsis/Ellipsis.js +184 -0
  18. package/es/Ellipsis/index.js +2 -0
  19. package/es/Ellipsis/style/index.css +17 -0
  20. package/es/Ellipsis/style/index.less +20 -0
  21. package/es/Empty/Empty.js +56 -0
  22. package/es/Empty/image.js +2 -0
  23. package/es/Empty/index.js +2 -0
  24. package/es/FullPage/FullPage.js +31 -0
  25. package/es/FullPage/index.js +2 -0
  26. package/es/Icon/icon.js +42 -0
  27. package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
  28. package/es/MonacoEditor/Monaco.js +238 -0
  29. package/es/MonacoEditor/index.js +2 -0
  30. package/es/PermissionButton/index.js +117 -0
  31. package/es/ProLayout/Basic/BasicLayout.js +259 -0
  32. package/es/ProLayout/Basic/Header.js +97 -0
  33. package/es/ProLayout/PageContainer/index.js +324 -0
  34. package/es/ProLayout/PageContainer/typings.js +1 -0
  35. package/es/ProLayout/RouteContext.js +22 -0
  36. package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
  37. package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
  38. package/es/ProLayout/SiderMenu/index.js +2 -0
  39. package/es/ProLayout/SiderMenu/typings.js +1 -0
  40. package/es/ProLayout/TopHeader/index.js +163 -0
  41. package/es/ProLayout/defaultSettings.js +66 -0
  42. package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
  43. package/{src → es}/ProLayout/style/default.less +1 -1
  44. package/es/ProLayout/style/index.js +1 -0
  45. package/es/ProLayout/typings.js +1 -0
  46. package/es/ProLayout/util.js +61 -0
  47. package/es/ProTable/index.js +411 -0
  48. package/es/ProTable/proTableTypes.js +11 -0
  49. package/es/ProTable/style/index.css +65 -0
  50. package/es/ProTable/style/index.js +1 -0
  51. package/{src → es}/ProTable/style/index.less +92 -92
  52. package/es/Scrollbar/Bar.js +114 -0
  53. package/es/Scrollbar/Scrollbar.js +212 -0
  54. package/es/Scrollbar/Thumb.js +189 -0
  55. package/es/Scrollbar/constants.js +1 -0
  56. package/es/Scrollbar/index.js +2 -0
  57. package/es/Scrollbar/scrollbarProps.js +100 -0
  58. package/es/Scrollbar/thumbProps.js +10 -0
  59. package/es/Scrollbar/util.js +30 -0
  60. package/es/Search/Advanced/History.js +183 -0
  61. package/es/Search/Advanced/SaveHistory.js +153 -0
  62. package/es/Search/Advanced/index.js +520 -0
  63. package/es/Search/Item.js +497 -0
  64. package/es/Search/Search.js +249 -0
  65. package/es/Search/hooks/index.js +1 -0
  66. package/es/Search/hooks/useSearchItems.js +40 -0
  67. package/es/Search/index.js +4 -0
  68. package/es/Search/setting.js +91 -0
  69. package/es/Search/style/Item.less +33 -0
  70. package/es/Search/style/Search.less +179 -0
  71. package/es/Search/style/index.js +2 -0
  72. package/es/Search/typing.js +1 -0
  73. package/es/Search/util.js +234 -0
  74. package/es/ValueItem/ValueItem.js +233 -0
  75. package/es/ValueItem/index.js +2 -0
  76. package/es/ValueItem/util.js +16 -0
  77. package/es/index.js +24 -0
  78. package/es/style/index.js +3 -0
  79. package/es/style/variable.css +0 -0
  80. package/{src → es}/style/variable.less +2 -4
  81. package/es/style.js +5 -0
  82. package/lib/AMap/Map.js +125 -0
  83. package/lib/AMap/index.js +9 -0
  84. package/lib/AMap/util.js +62 -0
  85. package/lib/BadgeStatus/Badge.js +54 -0
  86. package/lib/BadgeStatus/color.js +27 -0
  87. package/lib/BadgeStatus/index.js +22 -0
  88. package/lib/CardSelect/CardSelect.js +123 -0
  89. package/lib/CardSelect/index.js +9 -0
  90. package/lib/CheckButton/CheckButton.js +120 -0
  91. package/lib/CheckButton/index.js +9 -0
  92. package/lib/CheckButton/style/index.css +37 -0
  93. package/lib/CheckButton/style/index.less +40 -0
  94. package/lib/ConfigProvider/context.js +19 -0
  95. package/lib/ConfigProvider/index.js +37 -0
  96. package/lib/Echarts/Echarts.js +47 -0
  97. package/lib/Echarts/index.js +9 -0
  98. package/lib/Ellipsis/Ellipsis.js +184 -0
  99. package/lib/Ellipsis/index.js +9 -0
  100. package/lib/Ellipsis/style/index.css +17 -0
  101. package/lib/Ellipsis/style/index.less +20 -0
  102. package/lib/Empty/Empty.js +56 -0
  103. package/lib/Empty/image.js +8 -0
  104. package/lib/Empty/index.js +9 -0
  105. package/lib/FullPage/FullPage.js +31 -0
  106. package/lib/FullPage/index.js +9 -0
  107. package/lib/Icon/icon.js +52 -0
  108. package/lib/Icon/index.js +9 -0
  109. package/lib/MonacoEditor/Monaco.js +238 -0
  110. package/lib/MonacoEditor/index.js +9 -0
  111. package/lib/PermissionButton/index.js +124 -0
  112. package/lib/ProLayout/Basic/BasicLayout.js +268 -0
  113. package/lib/ProLayout/Basic/BasicLayout.less +66 -0
  114. package/lib/ProLayout/Basic/Header.js +103 -0
  115. package/lib/ProLayout/Basic/Header.less +8 -0
  116. package/lib/ProLayout/PageContainer/index.js +327 -0
  117. package/lib/ProLayout/PageContainer/index.less +103 -0
  118. package/lib/ProLayout/PageContainer/typings.js +5 -0
  119. package/lib/ProLayout/RouteContext.js +28 -0
  120. package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
  121. package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
  122. package/lib/ProLayout/SiderMenu/index.js +20 -0
  123. package/lib/ProLayout/SiderMenu/index.less +212 -0
  124. package/lib/ProLayout/SiderMenu/typings.js +5 -0
  125. package/lib/ProLayout/TopHeader/index.js +168 -0
  126. package/lib/ProLayout/TopHeader/index.less +174 -0
  127. package/lib/ProLayout/defaultSettings.js +72 -0
  128. package/lib/ProLayout/index.js +16 -0
  129. package/lib/ProLayout/style/default.less +4 -0
  130. package/lib/ProLayout/style/index.js +3 -0
  131. package/lib/ProLayout/style/style.less +7 -0
  132. package/lib/ProLayout/typings.js +5 -0
  133. package/lib/ProLayout/util.js +72 -0
  134. package/lib/ProTable/index.js +417 -0
  135. package/lib/ProTable/proTableTypes.js +17 -0
  136. package/lib/ProTable/style/index.css +65 -0
  137. package/lib/ProTable/style/index.js +3 -0
  138. package/lib/ProTable/style/index.less +92 -0
  139. package/lib/Scrollbar/Bar.js +114 -0
  140. package/lib/Scrollbar/Scrollbar.js +212 -0
  141. package/lib/Scrollbar/Thumb.js +189 -0
  142. package/lib/Scrollbar/constants.js +7 -0
  143. package/lib/Scrollbar/index.js +9 -0
  144. package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
  145. package/lib/Scrollbar/thumbProps.js +16 -0
  146. package/lib/Scrollbar/util.js +37 -0
  147. package/lib/Search/Advanced/History.js +183 -0
  148. package/lib/Search/Advanced/SaveHistory.js +153 -0
  149. package/lib/Search/Advanced/index.js +520 -0
  150. package/lib/Search/Item.js +497 -0
  151. package/lib/Search/Search.js +249 -0
  152. package/lib/Search/hooks/index.js +16 -0
  153. package/lib/Search/hooks/useSearchItems.js +47 -0
  154. package/lib/Search/index.js +16 -0
  155. package/lib/Search/setting.js +97 -0
  156. package/lib/Search/style/Item.less +33 -0
  157. package/lib/Search/style/Search.less +179 -0
  158. package/lib/Search/style/index.js +4 -0
  159. package/lib/Search/typing.js +5 -0
  160. package/lib/Search/util.js +241 -0
  161. package/lib/ValueItem/ValueItem.js +233 -0
  162. package/lib/ValueItem/index.js +9 -0
  163. package/lib/ValueItem/util.js +22 -0
  164. package/lib/index.js +158 -0
  165. package/lib/style/components.less +3 -0
  166. package/lib/style/index.js +4 -0
  167. package/lib/style/variable.css +0 -0
  168. package/lib/style/variable.less +2 -0
  169. package/lib/style.js +7 -0
  170. package/package.json +123 -13
  171. package/index.ts +0 -64
  172. package/src/AMap/Map.vue +0 -110
  173. package/src/AMap/index.ts +0 -1
  174. package/src/AMap/util.ts +0 -56
  175. package/src/BadgeStatus/Badge.vue +0 -41
  176. package/src/BadgeStatus/color.ts +0 -25
  177. package/src/BadgeStatus/index.ts +0 -4
  178. package/src/CardSelect/CardSelect.vue +0 -136
  179. package/src/CardSelect/index.ts +0 -3
  180. package/src/CheckButton/CheckButton.vue +0 -146
  181. package/src/CheckButton/index.md +0 -27
  182. package/src/CheckButton/index.ts +0 -3
  183. package/src/ConfigProvider/context.ts +0 -17
  184. package/src/ConfigProvider/index.tsx +0 -42
  185. package/src/Echarts/Echarts.vue +0 -43
  186. package/src/Echarts/index.ts +0 -3
  187. package/src/Ellipsis/Ellipsis.vue +0 -182
  188. package/src/Ellipsis/index.ts +0 -3
  189. package/src/Empty/Empty.vue +0 -43
  190. package/src/Empty/image.ts +0 -3
  191. package/src/Empty/index.ts +0 -2
  192. package/src/FullPage/FullPage.vue +0 -30
  193. package/src/FullPage/index.ts +0 -3
  194. package/src/Icon/icon.tsx +0 -40
  195. package/src/MonacoEditor/Monaco.vue +0 -242
  196. package/src/MonacoEditor/index.md +0 -26
  197. package/src/MonacoEditor/index.ts +0 -2
  198. package/src/PermissionButton/index.tsx +0 -110
  199. package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
  200. package/src/ProLayout/Basic/Header.tsx +0 -115
  201. package/src/ProLayout/PageContainer/index.tsx +0 -441
  202. package/src/ProLayout/PageContainer/typings.ts +0 -56
  203. package/src/ProLayout/RouteContext.ts +0 -87
  204. package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
  205. package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
  206. package/src/ProLayout/SiderMenu/index.ts +0 -2
  207. package/src/ProLayout/SiderMenu/typings.ts +0 -49
  208. package/src/ProLayout/TopHeader/index.tsx +0 -210
  209. package/src/ProLayout/defaultSettings.ts +0 -106
  210. package/src/ProLayout/style/index.ts +0 -1
  211. package/src/ProLayout/typings.ts +0 -87
  212. package/src/ProLayout/util.ts +0 -64
  213. package/src/ProTable/index.md +0 -53
  214. package/src/ProTable/index.tsx +0 -551
  215. package/src/ProTable/proTableTypes.ts +0 -70
  216. package/src/ProTable/style/index.ts +0 -1
  217. package/src/Scrollbar/Bar.vue +0 -75
  218. package/src/Scrollbar/Scrollbar.vue +0 -260
  219. package/src/Scrollbar/Thumb.vue +0 -163
  220. package/src/Scrollbar/constants.ts +0 -10
  221. package/src/Scrollbar/index.ts +0 -4
  222. package/src/Scrollbar/thumb.ts +0 -16
  223. package/src/Scrollbar/util.ts +0 -38
  224. package/src/Search/Advanced/History.vue +0 -140
  225. package/src/Search/Advanced/SaveHistory.vue +0 -108
  226. package/src/Search/Advanced/index.vue +0 -435
  227. package/src/Search/Item.vue +0 -525
  228. package/src/Search/Search.vue +0 -398
  229. package/src/Search/hooks/index.ts +0 -1
  230. package/src/Search/hooks/useSearchItems.ts +0 -68
  231. package/src/Search/index.md +0 -57
  232. package/src/Search/index.ts +0 -5
  233. package/src/Search/setting.ts +0 -55
  234. package/src/Search/typing.ts +0 -76
  235. package/src/Search/util.ts +0 -263
  236. package/src/ValueItem/ValueItem.vue +0 -192
  237. package/src/ValueItem/index.ts +0 -3
  238. package/src/ValueItem/util.ts +0 -16
  239. package/src/style/index.ts +0 -3
  240. /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
  241. /package/{src → es}/ProLayout/Basic/Header.less +0 -0
  242. /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
  243. /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
  244. /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
  245. /package/{src → es}/ProLayout/style/style.less +0 -0
@@ -1,108 +0,0 @@
1
- <template>
2
- <Popover
3
- v-model:visible="visible"
4
- title="搜索名称"
5
- trigger="click"
6
- placement="bottom"
7
- @visibleChange="visibleChange"
8
- >
9
- <template #content>
10
- <div v-if="visible" style="width: 240px">
11
- <Form ref="formRef" :model="modelRef">
12
- <FormItem
13
- name="name"
14
- :rules="[
15
- { required: true, message: '请输入名称' },
16
- { max: 64, message: '最多64个字符' },
17
- ]"
18
- >
19
- <Textarea
20
- v-model:value="modelRef.name"
21
- :rows="3"
22
- :maxlength="200"
23
- />
24
- </FormItem>
25
- </Form>
26
- <Button
27
- :loading="saveHistoryLoading"
28
- type="primary"
29
- class="save-btn"
30
- style="width: 100%"
31
- @click="saveHistory"
32
- >
33
- 保存
34
- </Button>
35
- </div>
36
- </template>
37
- <Button ghost type="primary"> 保存</Button>
38
- </Popover>
39
- </template>
40
-
41
- <script setup lang="ts">
42
- import type { Terms } from '../typing';
43
- import type { PropType } from 'vue';
44
- import { ref, reactive } from 'vue';
45
- import { Form, Button, FormItem, Popover, Textarea, message } from 'ant-design-vue'
46
- import { isFunction } from 'lodash-es';
47
-
48
- const props = defineProps({
49
- terms: {
50
- type: Object as PropType<Terms>,
51
- default: () => ({}),
52
- },
53
- target: {
54
- type: String,
55
- default: '',
56
- required: true,
57
- },
58
- request: {
59
- type: Function as PropType<(data: any, target: string) => Promise<any>>,
60
- default: null,
61
- },
62
- });
63
-
64
- const saveHistoryLoading = ref(false);
65
-
66
- const visible = ref(false);
67
-
68
- const formRef = ref();
69
-
70
- const modelRef = reactive({
71
- name: undefined,
72
- });
73
-
74
- const visibleChange = (e: boolean) => {
75
- visible.value = e;
76
- if (!e) {
77
- setTimeout(() => {
78
- modelRef.name = undefined;
79
- }, 100);
80
- }
81
- };
82
-
83
- /**
84
- * 保存当前查询条件
85
- */
86
- const saveHistory = async () => {
87
- // 获取当前查询条件并转化为字符串
88
- const formData = await formRef.value.validate();
89
- if (formData && props.request && isFunction(props.request)) {
90
- formData.content = JSON.stringify(props.terms);
91
- saveHistoryLoading.value = true;
92
- const resp = await props.request(formData, props.target);
93
- saveHistoryLoading.value = false;
94
- if (resp.success || resp.status === 200 || resp.code === 200) {
95
- message.success('操作成功');
96
- visibleChange(false);
97
- } else {
98
- message.error('操作失败');
99
- }
100
- }
101
- };
102
- </script>
103
-
104
- <style scoped lang="less">
105
- .save-btn {
106
- width: 100%;
107
- }
108
- </style>
@@ -1,435 +0,0 @@
1
- <template>
2
- <Form :model="termsData" @finish="searchSubmit">
3
- <div
4
- ref="searchRef"
5
- :class="['JSearch-warp', 'senior', props.class]"
6
- :style="style"
7
- >
8
- <!-- 高级模式 -->
9
- <div
10
- v-if="props.type === 'advanced'"
11
- ref="searchRefContentRef"
12
- :class="[
13
- 'JSearch-content',
14
- expand || compatible ? 'senior-expand' : 'pack-up',
15
- screenSize ? 'big' : 'small',
16
- ]"
17
- >
18
- <div
19
- :class="[
20
- 'JSearch-items',
21
- expand ? 'items-expand' : '',
22
- layout,
23
- ]"
24
- >
25
- <div class="left">
26
- <div class="left-items">
27
- <SearchItem
28
- :expand="expand"
29
- :index="1"
30
- :columns="searchItems"
31
- :terms-item="termsData.terms[0].terms[0]"
32
- :reset="resetNumber"
33
- @change="(v) => itemValueChange(v, 1)"
34
- />
35
- <SearchItem
36
- v-if="expand"
37
- :expand="expand"
38
- :index="2"
39
- :columns="searchItems"
40
- :terms-item="termsData.terms[0].terms[1]"
41
- :reset="resetNumber"
42
- @change="(v) => itemValueChange(v, 2)"
43
- />
44
- <SearchItem
45
- v-if="expand"
46
- :expand="expand"
47
- :index="3"
48
- :columns="searchItems"
49
- :terms-item="termsData.terms[0].terms[2]"
50
- :reset="resetNumber"
51
- @change="(v) => itemValueChange(v, 3)"
52
- />
53
- </div>
54
- </div>
55
- <div v-if="expand" class="center">
56
- <Select
57
- v-model:value="termsData.terms[1].type"
58
- class="center-select"
59
- style="width: 100px"
60
- :options="typeOptions"
61
- />
62
- </div>
63
- <div v-if="expand" class="right">
64
- <div class="right-items">
65
- <SearchItem
66
- v-for="item in [4, 5, 6]"
67
- :key="`search_item_${item}`"
68
- :expand="expand"
69
- :index="item"
70
- :columns="searchItems"
71
- :terms-item="termsData.terms[1].terms[item - 4]"
72
- :reset="resetNumber"
73
- @change="(v) => itemValueChange(v, item)"
74
- />
75
- </div>
76
- </div>
77
- </div>
78
- <div
79
- :class="[
80
- 'JSearch-footer',
81
- expand || compatible ? 'expand' : '',
82
- ]"
83
- >
84
- <div class="JSearch-footer--btns">
85
- <Button type="stroke" @click="reset"> 重置</Button>
86
- <SaveHistory
87
- :terms="termsData"
88
- :target="target"
89
- :request="request"
90
- />
91
- <History
92
- :target="target"
93
- :request="historyRequest"
94
- :delete-request="deleteRequest"
95
- :delete-key="deleteKey"
96
- @click="searchSubmit"
97
- @itemClick="historyItemClick"
98
- />
99
- </div>
100
- <Button
101
- type="link"
102
- class="more-btn"
103
- @click="expandChange"
104
- >
105
- <span class="more-text"> 更多筛选 </span>
106
- <AIcon
107
- type="DoubleRightOutlined"
108
- :class="[
109
- 'more-icon',
110
- expand ? 'more-up' : 'more-down',
111
- ]"
112
- />
113
- </Button>
114
- </div>
115
- </div>
116
- <!-- 简单模式 -->
117
- <div v-else class="JSearch-content single big pack-up">
118
- <div class="JSearch-items">
119
- <div class="left">
120
- <SearchItem
121
- :expand="false"
122
- :index="1"
123
- :columns="searchItems"
124
- :terms-item="termsData.terms[0].terms[0]"
125
- :reset="resetNumber"
126
- @change="(v) => itemValueChange(v, 1)"
127
- />
128
- </div>
129
- </div>
130
- <div class="JSearch-footer">
131
- <div class="JSearch-footer--btns">
132
- <FormItemRest>
133
- <Button type="stroke" @click="reset">
134
- 重置
135
- </Button>
136
- <Button html-type="submit" type="primary">
137
- 搜索
138
- </Button>
139
- </FormItemRest>
140
- </div>
141
- </div>
142
- </div>
143
- </div>
144
- </Form>
145
- </template>
146
-
147
- <script setup lang="ts">
148
- import SearchItem from '../Item.vue';
149
- import { optionsMapKey, typeOptions } from '../setting';
150
- import { useElementSize } from '@vueuse/core';
151
- import { useRouteQuery } from '@vueuse/router';
152
- import { PropType, ref, reactive, watch, provide } from 'vue';
153
- import SaveHistory from './SaveHistory.vue';
154
- import History from './History.vue';
155
- import type {
156
- SearchItemData,
157
- SearchProps,
158
- Terms,
159
- JColumnsProps,
160
- } from '../typing';
161
- import {
162
- compatibleOldTerms,
163
- getTermTypeFn,
164
- handleQData,
165
- hasExpand,
166
- termsParamsFormat,
167
- } from '../util';
168
- import { Select, Button, Form, FormItemRest } from 'ant-design-vue'
169
- import { AIcon } from '../../../'
170
- import { cloneDeep } from 'lodash-es';
171
-
172
- type UrlParam = {
173
- q: string | null;
174
- target: string | null;
175
- };
176
-
177
- interface Emit {
178
- (e: 'search', data: Terms): void;
179
- }
180
-
181
- const props = defineProps({
182
- columns: {
183
- type: Array as PropType<JColumnsProps[]>,
184
- default: () => [],
185
- required: true,
186
- },
187
- type: {
188
- type: String,
189
- default: 'advanced',
190
- },
191
- target: {
192
- type: String,
193
- default: '',
194
- required: true,
195
- },
196
- class: {
197
- type: String,
198
- default: '',
199
- },
200
- request: {
201
- type: Function as PropType<(data: any, target: string) => Promise<any>>,
202
- default: undefined,
203
- },
204
- historyRequest: {
205
- type: Function as PropType<(target: string) => Promise<any>>,
206
- default: undefined,
207
- },
208
- deleteRequest: {
209
- type: Function as PropType<
210
- (target: string, id: string) => Promise<any>
211
- >,
212
- default: null,
213
- },
214
- deleteKey: {
215
- type: String,
216
- default: 'key',
217
- },
218
- routerMode: {
219
- type: String,
220
- default: 'hash',
221
- },
222
- style: {
223
- type: [String, Object],
224
- default: undefined,
225
- },
226
- });
227
-
228
- const searchRef = ref(null);
229
- const searchRefContentRef = ref(null);
230
- const {width} = useElementSize(searchRef);
231
-
232
- const q = useRouteQuery('q');
233
- const target = useRouteQuery('target');
234
- const hasOnceSearch = ref(false);
235
-
236
- // 是否展开更多筛选
237
- const expand = ref(false);
238
-
239
- // 组件方向
240
- const layout = ref('horizontal');
241
- const compatible = ref(false);
242
- // 当前组件宽度 true 大于1000
243
- const screenSize = ref(true);
244
- const resetNumber = ref(1);
245
-
246
- const searchItems = ref<SearchProps[]>([]); // 当前查询条件
247
-
248
- const termsData = reactive<Terms>({
249
- terms: [
250
- {terms: [null, null, null]},
251
- {terms: [null, null, null], type: 'and'},
252
- ],
253
- });
254
-
255
- const columnOptionMap = ref(new Map());
256
-
257
- provide(optionsMapKey, columnOptionMap);
258
-
259
- const emit = defineEmits<Emit>();
260
-
261
- const expandChange = () => {
262
- expand.value = !expand.value;
263
- if (!expand.value) {
264
- // 收起
265
- const firstItem = termsData.terms[0].terms[0];
266
- termsData.terms = [
267
- {terms: [firstItem, null, null]},
268
- {type: 'or', terms: [null, null, null]},
269
- ];
270
- }
271
- };
272
-
273
- const itemValueChange = (value: SearchItemData, index: number) => {
274
- if (index < 4) {
275
- // 第一组数据
276
- termsData.terms[0].terms[index - 1] = value;
277
- } else {
278
- // 第二组数据
279
- termsData.terms[1].terms[index - 4] = value;
280
- }
281
- };
282
-
283
- const addUrlParams = () => {
284
- q.value = encodeURI(JSON.stringify(termsData));
285
- target.value = props.target;
286
- };
287
-
288
- const submitData = () => {
289
- emit('search', termsParamsFormat(termsData, columnOptionMap.value));
290
- };
291
-
292
- /**
293
- * 提交
294
- */
295
- const searchSubmit = () => {
296
- submitData();
297
- if (props.type === 'advanced') {
298
- addUrlParams();
299
- }
300
- };
301
-
302
- /**
303
- * 重置查询
304
- */
305
- const reset = () => {
306
- termsData.terms = [
307
- {terms: [null, null, null]},
308
- {terms: [null, null, null], type: 'and'},
309
- ];
310
- expand.value = false;
311
- if (props.type === 'advanced') {
312
- q.value = null;
313
- target.value = null;
314
- }
315
- resetNumber.value += 1;
316
- emit('search', {terms: []});
317
- };
318
-
319
- watch(
320
- width,
321
- (value) => {
322
- if (value < 1000) {
323
- layout.value = 'vertical';
324
- screenSize.value = false;
325
- compatible.value = value < 760;
326
- } else {
327
- layout.value = 'horizontal';
328
- screenSize.value = true;
329
- compatible.value = false;
330
- }
331
- },
332
- {immediate: true},
333
- );
334
-
335
- const historyItemClick = (content: string) => {
336
- try {
337
- termsData.terms = handleQData(compatibleOldTerms(content))?.terms || [];
338
- expand.value = hasExpand(termsData.terms);
339
- searchSubmit();
340
- } catch (e) {
341
- console.warn(`Search组件中handleUrlParams处理JSON时异常:【${e}】`);
342
- }
343
- };
344
-
345
- /**
346
- * 处理URL中的查询参数
347
- * @param _params
348
- */
349
- const handleUrlParams = (_params: UrlParam) => {
350
- // URL中的target和props的一致,则还原查询参数
351
- if (props.target && _params.target === props.target && _params.q) {
352
- const qStr = decodeURI(_params.q);
353
- termsData.terms = handleQData(compatibleOldTerms(qStr))?.terms || [];
354
- expand.value = hasExpand(termsData.terms);
355
- emit('search', termsParamsFormat(termsData, columnOptionMap.value));
356
- }
357
- };
358
-
359
- /**
360
- * 处理每项的key为Item组件所需要的key
361
- */
362
- const handleItems = () => {
363
- searchItems.value = [];
364
- columnOptionMap.value.clear();
365
- props.columns!.forEach((item, index) => {
366
- const _item = cloneDeep(item);
367
- if (_item.search && Object.keys(_item.search).length) {
368
- columnOptionMap.value.set(
369
- // _item.search?.rename || _item.dataIndex,
370
- _item.dataIndex,
371
- _item.search,
372
- );
373
-
374
- // 默认值
375
- const {search} = _item;
376
- let defaultTerms = null;
377
- // 包含defaultValue 或者 defaultOnceValue
378
- if (search.defaultValue !== undefined || search.defaultOnceValue) {
379
- const _value = search.defaultValue || search.defaultOnceValue;
380
- defaultTerms = {
381
- type: 'and',
382
- value: _value,
383
- termType:
384
- search.defaultTermType || getTermTypeFn(search.type),
385
- column: _item.dataIndex,
386
- };
387
- }
388
-
389
- if (
390
- search.defaultValue !== undefined ||
391
- search.defaultOnceValue !== undefined
392
- ) {
393
- hasOnceSearch.value = true;
394
- }
395
- searchItems.value.push({
396
- ..._item.search,
397
- sortIndex: _item.search.first ? 0 : index + 1,
398
- title: _item.title as any,
399
- // column: _item.search?.rename || _item.dataIndex,
400
- column: _item.dataIndex,
401
- });
402
- if (defaultTerms) {
403
- itemValueChange(defaultTerms, search.first ? 1 : index + 1);
404
- }
405
- }
406
- });
407
-
408
- submitData();
409
-
410
- handleUrlParams({q: q.value, target: target.value});
411
- };
412
-
413
- watch(
414
- () => props.columns,
415
- () => {
416
- termsData.terms = [
417
- {terms: [null, null, null]},
418
- {terms: [null, null, null], type: 'and'},
419
- ];
420
- expand.value = false;
421
- if (props.type === 'advanced') {
422
- q.value = null;
423
- target.value = null;
424
- }
425
- handleItems();
426
- },
427
- {
428
- deep: true,
429
- },
430
- );
431
-
432
- handleItems();
433
- </script>
434
-
435
- <style scoped lang="less"></style>