@jetlinks-web/components 2.0.2 → 2.0.3

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 (237) hide show
  1. package/es/AMap/Map.js +124 -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 +121 -0
  10. package/es/CheckButton/index.js +2 -0
  11. package/es/ConfigProvider/context.js +12 -0
  12. package/es/ConfigProvider/index.js +31 -0
  13. package/es/Echarts/Echarts.js +47 -0
  14. package/es/Echarts/index.js +2 -0
  15. package/es/Ellipsis/Ellipsis.js +189 -0
  16. package/es/Ellipsis/index.js +2 -0
  17. package/es/Empty/Empty.js +56 -0
  18. package/es/Empty/image.js +2 -0
  19. package/es/Empty/index.js +2 -0
  20. package/es/FullPage/FullPage.js +31 -0
  21. package/es/FullPage/index.js +2 -0
  22. package/es/Icon/icon.js +42 -0
  23. package/{src/Icon/index.ts → es/Icon/index.js} +2 -3
  24. package/es/MonacoEditor/Monaco.js +238 -0
  25. package/es/MonacoEditor/index.js +2 -0
  26. package/es/PermissionButton/index.js +117 -0
  27. package/es/ProLayout/Basic/BasicLayout.js +259 -0
  28. package/es/ProLayout/Basic/Header.js +97 -0
  29. package/es/ProLayout/PageContainer/index.js +324 -0
  30. package/es/ProLayout/PageContainer/typings.js +1 -0
  31. package/es/ProLayout/RouteContext.js +22 -0
  32. package/es/ProLayout/SiderMenu/BaseMenu.js +285 -0
  33. package/es/ProLayout/SiderMenu/SiderMenu.js +278 -0
  34. package/es/ProLayout/SiderMenu/index.js +2 -0
  35. package/es/ProLayout/SiderMenu/typings.js +1 -0
  36. package/es/ProLayout/TopHeader/index.js +163 -0
  37. package/es/ProLayout/defaultSettings.js +66 -0
  38. package/{src/ProLayout/index.ts → es/ProLayout/index.js} +4 -6
  39. package/{src → es}/ProLayout/style/default.less +4 -4
  40. package/es/ProLayout/style/index.js +1 -0
  41. package/es/ProLayout/typings.js +1 -0
  42. package/es/ProLayout/util.js +61 -0
  43. package/es/ProTable/index.js +411 -0
  44. package/es/ProTable/proTableTypes.js +11 -0
  45. package/es/ProTable/style/index.css +65 -0
  46. package/es/ProTable/style/index.js +1 -0
  47. package/es/Scrollbar/Bar.js +114 -0
  48. package/es/Scrollbar/Scrollbar.js +212 -0
  49. package/es/Scrollbar/Thumb.js +189 -0
  50. package/es/Scrollbar/constants.js +1 -0
  51. package/es/Scrollbar/index.js +2 -0
  52. package/es/Scrollbar/scrollbarProps.js +100 -0
  53. package/es/Scrollbar/thumbProps.js +10 -0
  54. package/es/Scrollbar/util.js +30 -0
  55. package/es/Search/Advanced/History.js +183 -0
  56. package/es/Search/Advanced/SaveHistory.js +153 -0
  57. package/es/Search/Advanced/index.js +520 -0
  58. package/es/Search/Item.js +497 -0
  59. package/es/Search/Search.js +249 -0
  60. package/es/Search/hooks/index.js +1 -0
  61. package/es/Search/hooks/useSearchItems.js +40 -0
  62. package/es/Search/index.js +4 -0
  63. package/es/Search/setting.js +91 -0
  64. package/es/Search/style/Item.less +33 -0
  65. package/es/Search/style/Search.less +179 -0
  66. package/es/Search/style/index.js +2 -0
  67. package/es/Search/typing.js +1 -0
  68. package/es/Search/util.js +234 -0
  69. package/es/ValueItem/ValueItem.js +233 -0
  70. package/es/ValueItem/index.js +2 -0
  71. package/es/ValueItem/util.js +16 -0
  72. package/es/index.js +24 -0
  73. package/es/style/index.js +3 -0
  74. package/es/style/variable.css +0 -0
  75. package/{src → es}/style/variable.less +0 -2
  76. package/es/style.js +3 -0
  77. package/lib/AMap/Map.js +124 -0
  78. package/lib/AMap/index.js +9 -0
  79. package/lib/AMap/util.js +62 -0
  80. package/lib/BadgeStatus/Badge.js +54 -0
  81. package/lib/BadgeStatus/color.js +27 -0
  82. package/lib/BadgeStatus/index.js +22 -0
  83. package/lib/CardSelect/CardSelect.js +123 -0
  84. package/lib/CardSelect/index.js +9 -0
  85. package/lib/CheckButton/CheckButton.js +121 -0
  86. package/lib/CheckButton/index.js +9 -0
  87. package/lib/ConfigProvider/context.js +19 -0
  88. package/lib/ConfigProvider/index.js +37 -0
  89. package/lib/Echarts/Echarts.js +47 -0
  90. package/lib/Echarts/index.js +9 -0
  91. package/lib/Ellipsis/Ellipsis.js +189 -0
  92. package/lib/Ellipsis/index.js +9 -0
  93. package/lib/Empty/Empty.js +56 -0
  94. package/lib/Empty/image.js +8 -0
  95. package/lib/Empty/index.js +9 -0
  96. package/lib/FullPage/FullPage.js +31 -0
  97. package/lib/FullPage/index.js +9 -0
  98. package/lib/Icon/icon.js +52 -0
  99. package/lib/Icon/index.js +9 -0
  100. package/lib/MonacoEditor/Monaco.js +238 -0
  101. package/lib/MonacoEditor/index.js +9 -0
  102. package/lib/PermissionButton/index.js +124 -0
  103. package/lib/ProLayout/Basic/BasicLayout.js +268 -0
  104. package/lib/ProLayout/Basic/BasicLayout.less +66 -0
  105. package/lib/ProLayout/Basic/Header.js +103 -0
  106. package/lib/ProLayout/Basic/Header.less +8 -0
  107. package/lib/ProLayout/PageContainer/index.js +327 -0
  108. package/lib/ProLayout/PageContainer/index.less +103 -0
  109. package/lib/ProLayout/PageContainer/typings.js +5 -0
  110. package/lib/ProLayout/RouteContext.js +28 -0
  111. package/lib/ProLayout/SiderMenu/BaseMenu.js +290 -0
  112. package/lib/ProLayout/SiderMenu/SiderMenu.js +287 -0
  113. package/lib/ProLayout/SiderMenu/index.js +20 -0
  114. package/lib/ProLayout/SiderMenu/index.less +212 -0
  115. package/lib/ProLayout/SiderMenu/typings.js +5 -0
  116. package/lib/ProLayout/TopHeader/index.js +168 -0
  117. package/lib/ProLayout/TopHeader/index.less +174 -0
  118. package/lib/ProLayout/defaultSettings.js +72 -0
  119. package/lib/ProLayout/index.js +16 -0
  120. package/lib/ProLayout/style/default.less +4 -0
  121. package/lib/ProLayout/style/index.js +3 -0
  122. package/lib/ProLayout/style/style.less +7 -0
  123. package/lib/ProLayout/typings.js +5 -0
  124. package/lib/ProLayout/util.js +72 -0
  125. package/lib/ProTable/index.js +417 -0
  126. package/lib/ProTable/proTableTypes.js +17 -0
  127. package/lib/ProTable/style/index.css +65 -0
  128. package/lib/ProTable/style/index.js +3 -0
  129. package/lib/ProTable/style/index.less +92 -0
  130. package/lib/Scrollbar/Bar.js +114 -0
  131. package/lib/Scrollbar/Scrollbar.js +212 -0
  132. package/lib/Scrollbar/Thumb.js +189 -0
  133. package/lib/Scrollbar/constants.js +7 -0
  134. package/lib/Scrollbar/index.js +9 -0
  135. package/{src/Scrollbar/scrollbar.ts → lib/Scrollbar/scrollbarProps.js} +106 -108
  136. package/lib/Scrollbar/thumbProps.js +16 -0
  137. package/lib/Scrollbar/util.js +37 -0
  138. package/lib/Search/Advanced/History.js +183 -0
  139. package/lib/Search/Advanced/SaveHistory.js +153 -0
  140. package/lib/Search/Advanced/index.js +520 -0
  141. package/lib/Search/Item.js +497 -0
  142. package/lib/Search/Search.js +249 -0
  143. package/lib/Search/hooks/index.js +16 -0
  144. package/lib/Search/hooks/useSearchItems.js +47 -0
  145. package/lib/Search/index.js +16 -0
  146. package/lib/Search/setting.js +97 -0
  147. package/lib/Search/style/Item.less +33 -0
  148. package/lib/Search/style/Search.less +179 -0
  149. package/lib/Search/style/index.js +4 -0
  150. package/lib/Search/typing.js +5 -0
  151. package/lib/Search/util.js +241 -0
  152. package/lib/ValueItem/ValueItem.js +233 -0
  153. package/lib/ValueItem/index.js +9 -0
  154. package/lib/ValueItem/util.js +22 -0
  155. package/lib/index.js +158 -0
  156. package/lib/style/components.less +1 -0
  157. package/lib/style/index.js +4 -0
  158. package/lib/style/variable.css +0 -0
  159. package/lib/style/variable.less +2 -0
  160. package/lib/style.js +5 -0
  161. package/package.json +122 -13
  162. package/index.ts +0 -64
  163. package/src/AMap/Map.vue +0 -110
  164. package/src/AMap/index.ts +0 -1
  165. package/src/AMap/util.ts +0 -56
  166. package/src/BadgeStatus/Badge.vue +0 -41
  167. package/src/BadgeStatus/color.ts +0 -25
  168. package/src/BadgeStatus/index.ts +0 -4
  169. package/src/CardSelect/CardSelect.vue +0 -136
  170. package/src/CardSelect/index.ts +0 -3
  171. package/src/CheckButton/CheckButton.vue +0 -146
  172. package/src/CheckButton/index.md +0 -27
  173. package/src/CheckButton/index.ts +0 -3
  174. package/src/ConfigProvider/context.ts +0 -17
  175. package/src/ConfigProvider/index.tsx +0 -42
  176. package/src/Echarts/Echarts.vue +0 -43
  177. package/src/Echarts/index.ts +0 -3
  178. package/src/Ellipsis/Ellipsis.vue +0 -182
  179. package/src/Ellipsis/index.ts +0 -3
  180. package/src/Empty/Empty.vue +0 -43
  181. package/src/Empty/image.ts +0 -3
  182. package/src/Empty/index.ts +0 -2
  183. package/src/FullPage/FullPage.vue +0 -30
  184. package/src/FullPage/index.ts +0 -3
  185. package/src/Icon/icon.tsx +0 -40
  186. package/src/MonacoEditor/Monaco.vue +0 -242
  187. package/src/MonacoEditor/index.md +0 -26
  188. package/src/MonacoEditor/index.ts +0 -2
  189. package/src/PermissionButton/index.tsx +0 -110
  190. package/src/ProLayout/Basic/BasicLayout.tsx +0 -392
  191. package/src/ProLayout/Basic/Header.tsx +0 -115
  192. package/src/ProLayout/PageContainer/index.tsx +0 -441
  193. package/src/ProLayout/PageContainer/typings.ts +0 -56
  194. package/src/ProLayout/RouteContext.ts +0 -87
  195. package/src/ProLayout/SiderMenu/BaseMenu.tsx +0 -296
  196. package/src/ProLayout/SiderMenu/SiderMenu.tsx +0 -320
  197. package/src/ProLayout/SiderMenu/index.ts +0 -2
  198. package/src/ProLayout/SiderMenu/typings.ts +0 -49
  199. package/src/ProLayout/TopHeader/index.tsx +0 -210
  200. package/src/ProLayout/defaultSettings.ts +0 -106
  201. package/src/ProLayout/style/index.ts +0 -1
  202. package/src/ProLayout/typings.ts +0 -87
  203. package/src/ProLayout/util.ts +0 -64
  204. package/src/ProTable/index.md +0 -53
  205. package/src/ProTable/index.tsx +0 -551
  206. package/src/ProTable/proTableTypes.ts +0 -70
  207. package/src/ProTable/style/index.ts +0 -1
  208. package/src/Scrollbar/Bar.vue +0 -75
  209. package/src/Scrollbar/Scrollbar.vue +0 -260
  210. package/src/Scrollbar/Thumb.vue +0 -163
  211. package/src/Scrollbar/constants.ts +0 -10
  212. package/src/Scrollbar/index.ts +0 -4
  213. package/src/Scrollbar/thumb.ts +0 -16
  214. package/src/Scrollbar/util.ts +0 -38
  215. package/src/Search/Advanced/History.vue +0 -140
  216. package/src/Search/Advanced/SaveHistory.vue +0 -108
  217. package/src/Search/Advanced/index.vue +0 -435
  218. package/src/Search/Item.vue +0 -525
  219. package/src/Search/Search.vue +0 -398
  220. package/src/Search/hooks/index.ts +0 -1
  221. package/src/Search/hooks/useSearchItems.ts +0 -68
  222. package/src/Search/index.md +0 -57
  223. package/src/Search/index.ts +0 -5
  224. package/src/Search/setting.ts +0 -55
  225. package/src/Search/typing.ts +0 -76
  226. package/src/Search/util.ts +0 -263
  227. package/src/ValueItem/ValueItem.vue +0 -192
  228. package/src/ValueItem/index.ts +0 -3
  229. package/src/ValueItem/util.ts +0 -16
  230. package/src/style/index.ts +0 -3
  231. /package/{src → es}/ProLayout/Basic/BasicLayout.less +0 -0
  232. /package/{src → es}/ProLayout/Basic/Header.less +0 -0
  233. /package/{src → es}/ProLayout/PageContainer/index.less +0 -0
  234. /package/{src → es}/ProLayout/SiderMenu/index.less +0 -0
  235. /package/{src → es}/ProLayout/TopHeader/index.less +0 -0
  236. /package/{src → es}/ProLayout/style/style.less +0 -0
  237. /package/{src → es}/ProTable/style/index.less +0 -0
@@ -1,525 +0,0 @@
1
- <template>
2
- <div class="JSearch-item">
3
- <template v-if="!onlyValue">
4
- <div v-if="expand" class="JSearch-item--type">
5
- <Select
6
- v-if="index !== 1 && index !== 4"
7
- v-model:value="termsModel.type"
8
- :options="typeOptions"
9
- style="width: 100%"
10
- @change="valueChange"
11
- />
12
- <span v-else>
13
- {{ index === 1 ? '第一组' : '第二组' }}
14
- </span>
15
- </div>
16
- <Select
17
- v-model:value="termsModel.column"
18
- placeholder="请选择"
19
- class="JSearch-item--column"
20
- :options="columnOptions"
21
- @change="columnChange"
22
- />
23
- <Select
24
- v-model:value="termsModel.termType"
25
- placeholder="请选择"
26
- class="JSearch-item--termType"
27
- :options="termTypeOptions.option"
28
- @change="termTypeChange"
29
- />
30
- </template>
31
- <template v-else>
32
- <div
33
- class="JSearch-item--label"
34
- :style="{ minWidth: `${labelWidth}px` }"
35
- >
36
- {{
37
- columnOptions.length ? columnOptions[index - 1]?.label : ''
38
- }}
39
- </div>
40
- </template>
41
- <div class="JSearch-item--value">
42
- <FormItem no-style>
43
- <Input
44
- v-if="component === componentType.input"
45
- v-model:value="termsModel.value"
46
- allow-clear
47
- v-bind="cProps"
48
- style="width: 100%"
49
- @change="valueChange"
50
- />
51
- <Select
52
- v-else-if="component === componentType.select"
53
- v-model:value="termsModel.value"
54
- allow-clear
55
- show-search
56
- :mode="isBtw ? 'multiple' : 'combobox'"
57
- v-bind="cProps"
58
- style="width: 100%; min-width: 80px"
59
- :loading="optionLoading"
60
- :options="options"
61
- :filter-option="
62
- (v, option) => filterSelectNode(v, option, 'label')
63
- "
64
- @change="valueChange"
65
- />
66
- <InputNumber
67
- v-else-if="component === componentType.inputNumber"
68
- v-model:value="termsModel.value"
69
- allow-clear
70
- v-bind="cProps"
71
- style="width: 100%"
72
- @change="valueChange"
73
- />
74
- <InputPassword
75
- v-else-if="component === componentType.password"
76
- v-model:value="termsModel.value"
77
- allow-clear
78
- v-bind="cProps"
79
- style="width: 100%"
80
- @change="valueChange"
81
- />
82
- <TimePicker
83
- v-else-if="component === componentType.time"
84
- v-model:value="termsModel.value"
85
- allow-clear
86
- value-format="HH:mm:ss"
87
- style="width: 100%"
88
- v-bind="cProps"
89
- @change="valueChange"
90
- />
91
- <TimeRangePicker
92
- v-else-if="component === componentType.timeRange"
93
- v-model:value="termsModel.value"
94
- allow-clear
95
- value-format="HH:mm:ss"
96
- style="width: 100%"
97
- v-bind="cProps"
98
- @change="valueChange"
99
- />
100
- <DatePicker
101
- v-else-if="component === componentType.date"
102
- v-model:value="termsModel.value"
103
- allow-clear
104
- show-time
105
- value-format="YYYY-MM-DD HH:mm:ss"
106
- style="width: 100%"
107
- v-bind="cProps"
108
- @change="valueChange"
109
- />
110
- <RangePicker
111
- v-else-if="component === componentType.rangePicker"
112
- v-model:value="termsModel.value"
113
- allow-clear
114
- show-time
115
- value-format="YYYY-MM-DD HH:mm:ss"
116
- style="width: 100%"
117
- v-bind="cProps"
118
- @change="valueChange"
119
- />
120
- <TreeSelect
121
- v-else-if="component === componentType.treeSelect"
122
- v-model:value="termsModel.value"
123
- allow-clear
124
- show-search
125
- style="width: 100%"
126
- :height="350"
127
- :field-names="{ label: 'name', value: 'id' }"
128
- :multiple="isBtw"
129
- :filter-tree-node="
130
- (v, option) => filterTreeSelectNode(v, option)
131
- "
132
- v-bind="cProps"
133
- :tree-data="options"
134
- @change="valueChange"
135
- />
136
- <component
137
- :is="componentName"
138
- v-else-if="
139
- component === componentType.component && componentName
140
- "
141
- v-bind="cProps"
142
- v-model:value="termsModel.value"
143
- @change="valueChange"
144
- />
145
- </FormItem>
146
- </div>
147
- </div>
148
- </template>
149
-
150
- <script setup lang="ts" name="SearchItem">
151
- import { typeOptions, termType, componentType, optionsMapKey } from './setting';
152
- import type { PropType } from 'vue';
153
- import { ref, reactive, nextTick, watch, computed, inject } from 'vue';
154
- import type { SearchItemData, SearchProps } from './typing';
155
- import { cloneDeep, debounce, isArray, isFunction, omit } from 'lodash-es';
156
- import {
157
- filterTreeSelectNode,
158
- filterSelectNode,
159
- getTermTypeFn,
160
- getTermOptions,
161
- getTermTypes,
162
- } from './util';
163
- import {
164
- TreeSelect,
165
- Select,
166
- Input,
167
- InputNumber,
168
- DatePicker,
169
- TimePicker,
170
- InputPassword,
171
- RangePicker,
172
- TimeRangePicker,
173
- FormItem
174
- } from 'ant-design-vue'
175
- import { isPromise } from '@jetlinks-web/utils';
176
-
177
- type ItemType = SearchProps['type'];
178
-
179
- type UrlParam = {
180
- q: string | null;
181
- target: string | null;
182
- };
183
-
184
- interface Emit {
185
- (e: 'change', data: SearchItemData): void;
186
- }
187
-
188
- const props = defineProps({
189
- columns: {
190
- type: Array as PropType<SearchProps[]>,
191
- default: () => [],
192
- required: true,
193
- },
194
- index: {
195
- type: Number,
196
- default: 1,
197
- },
198
- expand: {
199
- type: Boolean,
200
- default: false,
201
- },
202
- termsItem: {
203
- type: Object as PropType<SearchItemData>,
204
- default: () => ({}),
205
- },
206
- componentProps: {
207
- type: Object,
208
- default: () => ({}),
209
- },
210
- onlyValue: {
211
- type: Boolean,
212
- default: false,
213
- },
214
- reset: {
215
- type: Number,
216
- default: 1,
217
- },
218
- labelWidth: {
219
- type: Number,
220
- default: 40,
221
- },
222
- });
223
-
224
- type optionItemType = { label: string; value: any };
225
-
226
- const emit = defineEmits<Emit>();
227
-
228
- const termsModel = reactive<SearchItemData>({
229
- type: props.termsItem?.type || 'or',
230
- value: props.termsItem?.value || '',
231
- termType: props.termsItem?.termType || 'like',
232
- column: props.termsItem?.column || undefined,
233
- });
234
-
235
- const isBtw = computed(() => {
236
- return ['in', 'nin'].includes(termsModel.termType);
237
- });
238
-
239
- const component = ref(componentType.input);
240
- const componentName = ref();
241
- const cProps = ref({});
242
-
243
- const options = ref<any[]>([]);
244
-
245
- const columnOptions = ref<optionItemType[]>([]);
246
- const columnOptionMap = inject(optionsMapKey, new Map());
247
-
248
- const termTypeOptions = reactive({option: termType});
249
-
250
- const optionLoading = ref(false);
251
-
252
- /**
253
- * 根据类型切换默termType值
254
- * @param type {}
255
- * @param column {}
256
- * @param options {}
257
- * @param defaultTermType {}
258
- */
259
- const getTermType = (
260
- type?: ItemType,
261
- column?: string,
262
- options?: string[],
263
- defaultTermType?: string,
264
- termFilter?: string[],
265
- ) => {
266
- termTypeOptions.option = options?.length
267
- ? getTermTypes(options)
268
- : getTermOptions(type, column);
269
- if (termFilter?.length) {
270
- termTypeOptions.option = termTypeOptions.option.filter(
271
- (item) => !termFilter.includes(item.value),
272
- );
273
- }
274
- return defaultTermType || options?.length
275
- ? termTypeOptions.option[0].value
276
- : getTermTypeFn(type, column);
277
- };
278
-
279
- /**
280
- * 根据类型返回组件
281
- * @param type
282
- */
283
- const getComponent = (type?: ItemType) => {
284
- switch (type) {
285
- case 'select':
286
- component.value = componentType.select;
287
- break;
288
- case 'treeSelect':
289
- component.value = componentType.treeSelect;
290
- break;
291
- case 'date':
292
- component.value = componentType.date;
293
- break;
294
- case 'time':
295
- component.value = componentType.time;
296
- break;
297
- case 'number':
298
- component.value = componentType.inputNumber;
299
- break;
300
- case 'timeRange':
301
- component.value = componentType.timeRange;
302
- break;
303
- case 'rangePicker':
304
- component.value = componentType.rangePicker;
305
- break;
306
- case 'component':
307
- component.value = componentType.component;
308
- break;
309
- default:
310
- component.value = componentType.input;
311
- break;
312
- }
313
- };
314
-
315
- const removeOptionByKey = (options: any[]): any[] => {
316
- return options.map((item) => {
317
- if (item.children) {
318
- item.children = removeOptionByKey(item.children);
319
- }
320
- return omit(item, ['key']);
321
- });
322
- };
323
-
324
- const handleItemOptions = debounce((option?: any[] | Function) => {
325
- options.value = [];
326
- if (isArray(option)) {
327
- options.value = option;
328
- } else if (isFunction(option)) {
329
- optionLoading.value = true;
330
- const fn = option();
331
- if (isPromise(fn)) {
332
- (fn as Promise<any>)
333
- .then((res: any[]) => {
334
- optionLoading.value = false;
335
- options.value = removeOptionByKey(res);
336
- })
337
- .catch((_: any) => {
338
- optionLoading.value = false;
339
- });
340
- } else {
341
- optionLoading.value = false;
342
- options.value = removeOptionByKey(fn || []);
343
- }
344
- }
345
- }, 100);
346
-
347
- const initModel = () => {
348
- termsModel.type = 'or';
349
- termsModel.column = undefined;
350
- termsModel.value = undefined;
351
- termsModel.termType = undefined;
352
- termTypeOptions.option = termType;
353
- };
354
- const columnChange = (
355
- value: string,
356
- isChange: boolean,
357
- changeValue: boolean = true,
358
- ) => {
359
- const item = columnOptionMap.value?.get(value);
360
-
361
- if (!item) {
362
- initModel();
363
- return;
364
- }
365
- cProps.value = item.componentProps;
366
- optionLoading.value = false;
367
- // 设置value为undefined
368
- termsModel.column = value;
369
- getComponent(item.type); // 处理Item的组件类型
370
- componentName.value = item.components;
371
-
372
- // 处理options 以及 request
373
-
374
- if ('options' in item) {
375
- handleItemOptions(item.options);
376
- }
377
-
378
- const termsTypeValue = getTermType(
379
- item.type,
380
- value,
381
- item.termOptions,
382
- item.defaultTermType,
383
- item.termFilter,
384
- );
385
-
386
- if (changeValue) {
387
- termsModel.value = undefined;
388
- termsModel.termType = termsTypeValue;
389
- }
390
-
391
- if (isChange) {
392
- valueChange();
393
- }
394
- };
395
-
396
- const handleItem = () => {
397
- columnOptions.value = [];
398
- if (!props.columns.length) return;
399
- columnOptions.value = props.columns.map((item) => {
400
- // 对columns进行Map处理以及值处理
401
- return {
402
- label: item.title,
403
- value: item.column,
404
- };
405
- });
406
- console.log(props.onlyValue);
407
- if (!props.onlyValue) {
408
- // 获取第一个值
409
- const sortColumn = cloneDeep(props.columns);
410
- sortColumn?.sort((a, b) => a.sortIndex! - b.sortIndex!);
411
-
412
- const _index =
413
- props.index > sortColumn.length
414
- ? sortColumn.length - 1
415
- : props.index;
416
-
417
- if (props.index <= sortColumn.length) {
418
- const _itemColumn = sortColumn[_index - 1];
419
- columnChange(_itemColumn.column as string, false);
420
- } else {
421
- columnChange(null, false);
422
- }
423
- } else {
424
- columnChange(props.columns[props.index - 1]?.column as string, false);
425
- }
426
- };
427
-
428
- const termTypeChange = (v) => {
429
- const isOldValueMultiple = ['in', 'nin'].includes(
430
- props.termsItem?.termType,
431
- );
432
- const isValueMultiple = ['in', 'nin'].includes(v);
433
-
434
- if (isOldValueMultiple !== isValueMultiple) {
435
- termsModel.value = isValueMultiple ? [] : undefined;
436
- }
437
- valueChange();
438
- };
439
-
440
- const valueChange = () => {
441
- emit('change', {
442
- type: props.onlyValue ? 'and' : termsModel.type || 'or',
443
- value: termsModel.value,
444
- termType: termsModel.termType || 'like',
445
- column: termsModel.column,
446
- });
447
- };
448
-
449
- const reset = () => {
450
- termsModel.value = undefined;
451
- };
452
-
453
- watch(
454
- () => props.columns,
455
- () => {
456
- console.log(props.columns);
457
- if (props.columns) {
458
- handleItem();
459
- }
460
- },
461
- {immediate: true, deep: true},
462
- );
463
-
464
- watch(
465
- () => props.termsItem,
466
- (val, oldVal) => {
467
- if (val?.column) {
468
- nextTick(() => {
469
- Object.keys(props.termsItem).forEach((key) => {
470
- termsModel[key] = props.termsItem[key];
471
- if (key === 'column' && val?.column !== oldVal?.column) {
472
- columnChange(
473
- props.termsItem.column as string,
474
- false,
475
- false,
476
- );
477
- }
478
- });
479
- });
480
- } else {
481
- handleItem();
482
- }
483
- },
484
- {immediate: true, deep: true},
485
- );
486
- </script>
487
-
488
- <style scoped lang="less">
489
- .JSearch-item {
490
- display: flex;
491
- gap: 16px;
492
- align-items: center;
493
-
494
- .JSearch-item--type {
495
- width: 90px;
496
- min-width: 0;
497
-
498
- > span {
499
- line-height: 34px;
500
- font-weight: bold;
501
- }
502
- }
503
-
504
- .JSearch-item--column {
505
- width: 130px;
506
- min-width: 0;
507
- }
508
-
509
- .JSearch-item--termType {
510
- width: 110px;
511
- min-width: 0;
512
- }
513
-
514
- .JSearch-item--label {
515
- min-width: 40px;
516
- }
517
-
518
- .JSearch-item--value {
519
- display: flex;
520
- width: 0;
521
- flex-grow: 1;
522
- }
523
- }
524
-
525
- </style>