@ctzy-web-client/plugin-component-vue 1.0.0

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 (138) hide show
  1. package/package.json +43 -0
  2. package/src/advance-select/advance-operation.vue +44 -0
  3. package/src/advance-select/advance-option.vue +115 -0
  4. package/src/advance-select/advance-select.vue +343 -0
  5. package/src/advance-select/events-helpers.js +40 -0
  6. package/src/advance-select/index.js +13 -0
  7. package/src/advance-select/use-advance-option.js +58 -0
  8. package/src/advance-select/use-advance-select.js +142 -0
  9. package/src/application-slot/application-slot.js +70 -0
  10. package/src/application-slot/breadcrumb-item.vue +12 -0
  11. package/src/application-slot/header-tools-item.vue +12 -0
  12. package/src/application-slot/index.js +17 -0
  13. package/src/breadcrumb-select/breadcrumb-select.vue +97 -0
  14. package/src/breadcrumb-select/index.js +6 -0
  15. package/src/components.js +39 -0
  16. package/src/contextmenu/contextmenu-item.vue +13 -0
  17. package/src/contextmenu/contextmenu.vue +56 -0
  18. package/src/contextmenu/index.js +11 -0
  19. package/src/contextmenu/use-contextmenu.js +117 -0
  20. package/src/data-form/data-form-item.vue +49 -0
  21. package/src/data-form/data-form.vue +212 -0
  22. package/src/data-form/dynamic-component.js +24 -0
  23. package/src/data-form/form-components/Blots/AtBlot.js +32 -0
  24. package/src/data-form/form-components/bwa-date-picker.vue +43 -0
  25. package/src/data-form/form-components/bwa-date-time-picker.vue +49 -0
  26. package/src/data-form/form-components/bwa-input-float.vue +41 -0
  27. package/src/data-form/form-components/bwa-input-integer.vue +58 -0
  28. package/src/data-form/form-components/bwa-input.vue +32 -0
  29. package/src/data-form/form-components/bwa-multi-select.vue +27 -0
  30. package/src/data-form/form-components/bwa-rich-text-tinymce.vue +561 -0
  31. package/src/data-form/form-components/bwa-rich-text.vue +395 -0
  32. package/src/data-form/form-components/bwa-select.vue +67 -0
  33. package/src/data-form/form-components/bwa-textarea.vue +28 -0
  34. package/src/data-form/form-components/bwa-upload.vue +145 -0
  35. package/src/data-form/form-components/bwa-user-multi-select.vue +25 -0
  36. package/src/data-form/form-components/bwa-user-select.vue +81 -0
  37. package/src/data-form/index.js +35 -0
  38. package/src/data-table/data-column-view.vue +131 -0
  39. package/src/data-table/data-table-card.vue +81 -0
  40. package/src/data-table/data-table-column.vue +52 -0
  41. package/src/data-table/data-table.vue +426 -0
  42. package/src/data-table/dynamic-component.js +58 -0
  43. package/src/data-table/index.js +13 -0
  44. package/src/data-table/use-datatable-drag.js +156 -0
  45. package/src/datatable-settings/datatable-settings.vue +323 -0
  46. package/src/datatable-settings/index.js +6 -0
  47. package/src/date-range/date-picker.vue +115 -0
  48. package/src/date-range/date-range.vue +202 -0
  49. package/src/date-range/index.js +6 -0
  50. package/src/drag-list/constants.js +1 -0
  51. package/src/drag-list/drag-item.vue +46 -0
  52. package/src/drag-list/drag-list.vue +50 -0
  53. package/src/drag-list/index.js +6 -0
  54. package/src/drag-list/use-drag-list.js +209 -0
  55. package/src/dragable/constants.js +3 -0
  56. package/src/dragable/dragable-item.vue +19 -0
  57. package/src/dragable/dragable-operation.vue +28 -0
  58. package/src/dragable/dragable.vue +26 -0
  59. package/src/dragable/index.js +14 -0
  60. package/src/dragable/use-dragable.js +227 -0
  61. package/src/filter-panel/conditions/condition.js +35 -0
  62. package/src/filter-panel/conditions/date-range-condition.vue +35 -0
  63. package/src/filter-panel/conditions/department-condition/data.json +29537 -0
  64. package/src/filter-panel/conditions/department-condition/department-condition.vue +92 -0
  65. package/src/filter-panel/conditions/department-condition/department-node.vue +52 -0
  66. package/src/filter-panel/conditions/index.js +22 -0
  67. package/src/filter-panel/conditions/input-condition.vue +63 -0
  68. package/src/filter-panel/conditions/multi-user-condition.vue +56 -0
  69. package/src/filter-panel/conditions/multiple-menu-condition.vue +45 -0
  70. package/src/filter-panel/conditions/single-menu-condition.vue +58 -0
  71. package/src/filter-panel/conditions/single-user-condition.vue +56 -0
  72. package/src/filter-panel/filter-panel-item.vue +46 -0
  73. package/src/filter-panel/filter-panel.vue +149 -0
  74. package/src/filter-panel/index.js +17 -0
  75. package/src/filter-panel/use-filter-panel-item.js +59 -0
  76. package/src/filter-panel/use-filter-panel.js +203 -0
  77. package/src/hooks/use-data/index.js +234 -0
  78. package/src/index.js +48 -0
  79. package/src/layout/index.js +6 -0
  80. package/src/layout/layout.vue +74 -0
  81. package/src/make-installer.js +36 -0
  82. package/src/math/Rectangle.js +28 -0
  83. package/src/menu/index.js +6 -0
  84. package/src/menu/menu-item.vue +41 -0
  85. package/src/menu/menu.vue +53 -0
  86. package/src/panel/index.js +6 -0
  87. package/src/panel/panel.vue +42 -0
  88. package/src/panel-tabs/index.js +6 -0
  89. package/src/panel-tabs/panel-tabs.js +92 -0
  90. package/src/pct-filter-panel/index.js +10 -0
  91. package/src/pct-filter-panel/pct-compents/index.js +10 -0
  92. package/src/pct-filter-panel/pct-compents/pct-Input-condition.vue +63 -0
  93. package/src/pct-filter-panel/pct-compents/pct-date-range-condition.vue +60 -0
  94. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition.vue +177 -0
  95. package/src/pct-filter-panel/pct-compents/pct-multiple-menu-condition2.vue +142 -0
  96. package/src/pct-filter-panel/pct-filter-panel-item.vue +46 -0
  97. package/src/pct-filter-panel/pct-filter-panel.vue +201 -0
  98. package/src/pct-filter-panel/use-filter-panel-item.js +61 -0
  99. package/src/pct-filter-panel/use-filter-panel.js +206 -0
  100. package/src/plugins.js +3 -0
  101. package/src/progress/index.js +8 -0
  102. package/src/progress/progress-item.vue +81 -0
  103. package/src/progress/progress.vue +58 -0
  104. package/src/progress/use-progress.js +66 -0
  105. package/src/utils/db.js +8 -0
  106. package/src/utils.js +263 -0
  107. package/src/where-filter-panel/index.js +0 -0
  108. package/src/where-filter-panel/use-where-filter-panel.js +28 -0
  109. package/src/where-filter-panel/where-filter-panel.vue +9 -0
  110. package/style/advance-select.scss +316 -0
  111. package/style/breadcrumb-select.scss +80 -0
  112. package/style/common/var.scss +240 -0
  113. package/style/common.scss +48 -0
  114. package/style/contextmenu.scss +58 -0
  115. package/style/data-form.scss +35 -0
  116. package/style/data-table.scss +81 -0
  117. package/style/datatable-settings.scss +125 -0
  118. package/style/date-range.scss +136 -0
  119. package/style/department-condition.scss +39 -0
  120. package/style/drag-list.scss +68 -0
  121. package/style/dragable.scss +8 -0
  122. package/style/filter-panel.scss +199 -0
  123. package/style/index.scss +22 -0
  124. package/style/input-condition.scss +30 -0
  125. package/style/layout.scss +70 -0
  126. package/style/menu.scss +184 -0
  127. package/style/mixins/_var.scss +21 -0
  128. package/style/mixins/config.scss +4 -0
  129. package/style/mixins/function.scss +62 -0
  130. package/style/mixins/mixins.scss +88 -0
  131. package/style/panel-tabs.scss +60 -0
  132. package/style/panel.scss +110 -0
  133. package/style/pct-filter-panel.scss +306 -0
  134. package/style/progress.scss +122 -0
  135. package/style/rich-text.scss +30 -0
  136. package/style/theme/theme.scss +161 -0
  137. package/style/theme/var.scss +34 -0
  138. package/style/var.scss +21 -0
@@ -0,0 +1,323 @@
1
+ <template>
2
+ <ElTooltip
3
+ v-model:visible="value"
4
+ v-bind="attrs"
5
+ effect="light"
6
+ :show-arrow="false"
7
+ trigger="click"
8
+ :popper-class="ns.b()"
9
+ :gpu-acceleration="false"
10
+ placement="bottom"
11
+ append-to=".bwa-application"
12
+ >
13
+ <span>
14
+ <slot> </slot>
15
+ </span>
16
+ <template #content>
17
+ <div :class="ns.e('content')">
18
+ <div :class="ns.e('header')">
19
+ 表头设置
20
+
21
+ <span :class="ns.e('tools')">
22
+ <span
23
+ v-if="isShowResetColumn"
24
+ :class="[ns.e('tools-item'), ns.e('refresh')]"
25
+ @click="resetColumns"
26
+ >
27
+ <ElTooltip content="恢复默认" append-to=".bwa-application">
28
+ <ElIcon>
29
+ <RefreshRight />
30
+ </ElIcon>
31
+ </ElTooltip>
32
+ </span>
33
+
34
+ <span
35
+ :class="[ns.e('tools-item'), ns.e('close')]"
36
+ @click="value = false"
37
+ >
38
+ <ElTooltip content="关闭" append-to=".bwa-application">
39
+ <ElIcon>
40
+ <Close />
41
+ </ElIcon>
42
+ </ElTooltip>
43
+ </span>
44
+ </span>
45
+ </div>
46
+
47
+ <!-- <div :class="ns.e('search')">
48
+ <ElInput
49
+ v-model="search"
50
+ :clearable="true"
51
+ prefix-icon="Search"
52
+ placeholder="请输入关键词搜索"
53
+ />
54
+ </div> -->
55
+
56
+ <ElScrollbar max-height="500px">
57
+ <div :class="ns.e('main')">
58
+ <div v-if="displaySearchedColumns.length" :class="ns.b('section')">
59
+ <div :class="ns.be('section', 'header')">显示字段</div>
60
+ <BwaDraglist
61
+ :data="displaySearchedColumns"
62
+ labelAttr="title"
63
+ idAttr="attrName"
64
+ @sort-change="handleSortChange"
65
+ >
66
+ <template #default="{ item }">
67
+ <div :class="ns.be('section', 'content')">
68
+ <div :class="ns.e('field-item')">
69
+ <span>
70
+ {{ item.title }}
71
+ </span>
72
+ <ElSwitch
73
+ v-model="item.visible"
74
+ size="small"
75
+ :disabled="item.settings.disabled"
76
+ @mousedown.stop
77
+ />
78
+ </div>
79
+ </div>
80
+ </template>
81
+ </BwaDraglist>
82
+ <!-- <div
83
+ v-show="!displaySearchedColumns.length"
84
+ :class="ns.be('section', 'empty')"
85
+ >
86
+ 暂无字段
87
+ </div> -->
88
+ </div>
89
+
90
+ <div v-if="hiddenSearchedColumns.length" :class="ns.b('section')">
91
+ <div :class="ns.be('section', 'header')">未显示字段</div>
92
+
93
+ <div :class="ns.be('section', 'content')">
94
+ <div
95
+ v-for="column in hiddenSearchedColumns"
96
+ :key="column.attrName"
97
+ :class="ns.e('field-item')"
98
+ >
99
+ <span>
100
+ {{ column.title }}
101
+ </span>
102
+ <ElSwitch
103
+ v-model="column.visible"
104
+ size="small"
105
+ :disabled="column.settings.disabled"
106
+ />
107
+ </div>
108
+ </div>
109
+
110
+ <!-- <div
111
+ v-show="!hiddenSearchedColumns.length"
112
+ :class="ns.be('section', 'empty')"
113
+ >
114
+ 暂无字段
115
+ </div> -->
116
+ </div>
117
+ </div>
118
+ </ElScrollbar>
119
+ </div>
120
+ </template>
121
+ </ElTooltip>
122
+ </template>
123
+
124
+ <script setup>
125
+ import { ElIcon, ElScrollbar, ElSwitch, ElTooltip } from 'element-plus';
126
+ import {
127
+ useNamespace,
128
+ useValue,
129
+ useService,
130
+ useEventDispatcher,
131
+ } from 'web-base-client-vue';
132
+ import {
133
+ computed,
134
+ getCurrentScope,
135
+ onScopeDispose,
136
+ ref,
137
+ unref,
138
+ useAttrs,
139
+ withCtx,
140
+ } from 'vue';
141
+ import BwaDraglist from '../drag-list';
142
+ import { map } from 'rxjs';
143
+ import { dataModelDB } from '../utils/db';
144
+
145
+ defineOptions({ name: 'BwaDataTableSetting' });
146
+
147
+ const props = defineProps({
148
+ dataTable: {
149
+ type: Object,
150
+ required: true,
151
+ },
152
+ });
153
+
154
+ const attrs = useAttrs();
155
+
156
+ const ns = useNamespace('datatable-settings');
157
+
158
+ const value = ref(false);
159
+
160
+ const appName = useValue('AppName');
161
+ const userService = useService('UserService');
162
+
163
+ const userID = computed(() => unref(userService)?.userInfo?.id || '');
164
+
165
+ const isShowResetColumn = computed(
166
+ () => !props.dataTable.isDefaultColumnSort()
167
+ );
168
+
169
+ const key = computed(
170
+ () => `${unref(appName)}_${props.dataTable.name}_settings`
171
+ );
172
+
173
+ const search = ref('');
174
+
175
+ const columns = computed(() =>
176
+ props.dataTable
177
+ .getColumns()
178
+ .filter((column) => column.settings.visible)
179
+ .filter((column) => column.settings.visible)
180
+ );
181
+
182
+ const initColumns = async () => {
183
+ let persistentColumnInfos = [];
184
+
185
+ const result = await dataModelDB.tableHeaderSettings
186
+ .where('[app+tableName+userID]')
187
+ .equals([unref(appName), props.dataTable.name, unref(userID)])
188
+ .toArray();
189
+
190
+ if (result.length) {
191
+ persistentColumnInfos = result[0]?.columnInfo ?? [];
192
+ }
193
+
194
+ if (persistentColumnInfos.some((item) => typeof item === 'string')) {
195
+ persistentColumnInfos = persistentColumnInfos.map((columnInfo) => {
196
+ return typeof columnInfo === 'object'
197
+ ? columnInfo
198
+ : { name: columnInfo, visible: true };
199
+ });
200
+ }
201
+
202
+ const _dataTable = props.dataTable;
203
+ let dataTableColumns = _dataTable
204
+ .getColumns()
205
+ .slice()
206
+ .filter((item) => item.settings.visible);
207
+
208
+ persistentColumnInfos = persistentColumnInfos.filter(
209
+ (item) =>
210
+ dataTableColumns.findIndex((column) => column.name === item.name) !== -1
211
+ );
212
+
213
+ if (!persistentColumnInfos) {
214
+ return dataTableColumns;
215
+ }
216
+
217
+ let sortedColumns = persistentColumnInfos
218
+ .map((columnInfo) =>
219
+ dataTableColumns.find((column) => column.name === columnInfo.name)
220
+ )
221
+ .filter(Boolean);
222
+
223
+ dataTableColumns = sortedColumns.concat(
224
+ dataTableColumns.filter(
225
+ (column) => !sortedColumns.find((col) => column.name === col.name)
226
+ )
227
+ );
228
+
229
+ for (const column of dataTableColumns) {
230
+ const persistentItem = persistentColumnInfos.find(
231
+ (item) => item.name === column.name
232
+ );
233
+ column.visible = persistentItem?.visible ?? column.visible;
234
+ }
235
+
236
+ props.dataTable.setDisplayColumns(
237
+ dataTableColumns.filter((column) => column.visible)
238
+ );
239
+
240
+ return dataTableColumns;
241
+ };
242
+
243
+ const resetColumns = () => {
244
+ const _dataTable = props.dataTable;
245
+
246
+ _dataTable.resetColumnSort();
247
+ };
248
+
249
+ const allSearchedColumns = computed(() => {
250
+ const _search = unref(search);
251
+ return unref(columns).filter((column) => column.title.indexOf(_search) > -1);
252
+ });
253
+
254
+ const hiddenSearchedColumns = computed(() =>
255
+ unref(allSearchedColumns).filter((item) => !item.visible)
256
+ );
257
+
258
+ const displaySearchedColumns = computed(() => {
259
+ const _search = unref(search);
260
+ return props.dataTable
261
+ .getDisplayColumns()
262
+ .filter((column) => column.settings.visible)
263
+ .filter((column) => column.title.indexOf(_search) > -1);
264
+ });
265
+
266
+ const handleSortChange = (sort) => {
267
+ const _columns = unref(columns);
268
+ const displayColumns = sort
269
+ .map(
270
+ (attrName) =>
271
+ _columns.find((column) => column.attrName === attrName) ?? null
272
+ )
273
+ .filter(Boolean);
274
+
275
+ props.dataTable.setDisplayColumns(displayColumns);
276
+ };
277
+
278
+ const scope = getCurrentScope();
279
+
280
+ const handleInitCompleted = async () => {
281
+ const dataTableColumns = await initColumns();
282
+
283
+ const subscription = props.dataTable
284
+ .getDisplayColumnsSubject()
285
+ .pipe(
286
+ map((displayColumns) => {
287
+ const hiddenColumns = dataTableColumns.filter(
288
+ (column) =>
289
+ !displayColumns.find(
290
+ (displayColumn) => displayColumn.attrName === column.attrName
291
+ )
292
+ );
293
+
294
+ return [...displayColumns, ...hiddenColumns].map((column) => ({
295
+ name: column.name,
296
+ visible: column.visible,
297
+ }));
298
+ })
299
+ )
300
+ .subscribe({
301
+ next: (columnInfo) => {
302
+ dataModelDB.tableHeaderSettings.put({
303
+ app: unref(appName),
304
+ tableName: props.dataTable.name,
305
+ userID: unref(userID),
306
+ columnInfo: columnInfo,
307
+ });
308
+ },
309
+ });
310
+
311
+ scope.run(() => {
312
+ onScopeDispose(() => {
313
+ subscription.unsubscribe();
314
+ });
315
+ });
316
+ };
317
+
318
+ if (!props.dataTable.inited) {
319
+ useEventDispatcher(props.dataTable, 'init-completed', handleInitCompleted);
320
+ } else {
321
+ handleInitCompleted();
322
+ }
323
+ </script>
@@ -0,0 +1,6 @@
1
+ import { withInstall } from 'element-plus/es/utils/vue/install';
2
+ import DataTableSettings from './datatable-settings.vue';
3
+
4
+ export const BwaDataTableSetting = withInstall(DataTableSettings);
5
+
6
+ export default BwaDataTableSetting;
@@ -0,0 +1,115 @@
1
+ <template>
2
+ <ElTooltip
3
+ trigger="click"
4
+ pure
5
+ teleported
6
+ effect="light"
7
+ role="dialog"
8
+ :transition="`el-zoom-in-top`"
9
+ :fallback-placements="['bottom', 'top', 'right', 'left']"
10
+ :gpu-acceleration="false"
11
+ :show-arrow="false"
12
+ :stop-popper-mouse-event="false"
13
+ v-model:visible="visible"
14
+ :hide-after="0"
15
+ :popper-class="ns.b()"
16
+ persistent
17
+ append-to=".bwa-application"
18
+ >
19
+ <template #default>
20
+ <slot :visible="visible"> </slot>
21
+ </template>
22
+ <template #content>
23
+ <ElPanelDatePicker type="date" :parsed-value="parsedValue" @pick="onPick" :teleported="false">
24
+ <template #sidebar>
25
+ <div :class="ns.e('sidebar')">
26
+ <ElButton size="small" @click="onClear">清空</ElButton>
27
+ </div>
28
+ </template>
29
+ </ElPanelDatePicker>
30
+ </template>
31
+ </ElTooltip>
32
+ </template>
33
+
34
+ <script setup>
35
+ import { ROOT_PICKER_INJECTION_KEY } from 'element-plus/es/components/date-picker/src/constants';
36
+ import ElPanelDatePicker from 'element-plus/es/components/date-picker/src/date-picker-com/panel-date-pick';
37
+ import {
38
+ formatter,
39
+ parseDate,
40
+ valueEquals,
41
+ } from 'element-plus/es/components/time-picker/src/utils';
42
+ import { useLocale } from 'element-plus/es/hooks/index';
43
+ import { computed, provide, ref, watch } from 'vue';
44
+ import { useNamespace } from 'web-base-client-vue';
45
+
46
+ defineOptions({ name: 'BwaDatePicker' });
47
+ const props = defineProps({
48
+ modelValue: {
49
+ type: [String, Date, Array],
50
+ },
51
+ visible: {
52
+ type: Boolean,
53
+ },
54
+ format: {
55
+ type: String,
56
+ default: 'YYYY-MM-DD',
57
+ },
58
+ shortcuts: {
59
+ type: Array,
60
+ default: () => [],
61
+ },
62
+ });
63
+ const emit = defineEmits(['update:modelValue', 'update:visible']);
64
+
65
+ const ns = useNamespace('datepicker');
66
+
67
+ const { lang } = useLocale();
68
+
69
+ const visible = ref(false);
70
+
71
+ watch(visible, () => {
72
+ emit('update:visible', visible.value);
73
+ });
74
+
75
+ provide('EP_PICKER_BASE', {
76
+ props,
77
+ });
78
+ provide(ROOT_PICKER_INJECTION_KEY, {
79
+ slots: {},
80
+ pickerNs: null,
81
+ });
82
+
83
+ const parsedValue = computed(() => {
84
+ return parseDate(props.modelValue, props.format, lang);
85
+ });
86
+
87
+ const emitInput = (input) => {
88
+ if (valueEquals(props.modelValue, input)) {
89
+ return;
90
+ }
91
+ let formatted;
92
+ if (Array.isArray(input)) {
93
+ formatted = input.map((item) => formatter(item, props.format, lang.value));
94
+ } else {
95
+ formatted = formatter(input, props.format, lang.value);
96
+ }
97
+ emit('update:modelValue', formatted);
98
+ };
99
+
100
+ const onPick = (date) => {
101
+ let result;
102
+ if (Array.isArray(date)) {
103
+ result = date.map((_) => _.toDate());
104
+ } else {
105
+ result = date ? date.toDate() : date;
106
+ }
107
+ emitInput(result);
108
+ visible.value = false;
109
+ };
110
+
111
+ const onClear = () => {
112
+ emit('update:modelValue', '');
113
+ visible.value = false;
114
+ };
115
+ </script>
@@ -0,0 +1,202 @@
1
+ <template>
2
+ <ElTooltip
3
+ v-model:visible="pickerVisivle"
4
+ pure
5
+ teleported
6
+ effect="light"
7
+ role="dialog"
8
+ :transition="`el-zoom-in-top`"
9
+ :fallback-placements="['bottom', 'top', 'right', 'left']"
10
+ :gpu-acceleration="false"
11
+ :show-arrow="false"
12
+ :stop-popper-mouse-event="false"
13
+ :hide-after="0"
14
+ persistent
15
+ trigger="click"
16
+ append-to=".bwa-application"
17
+ >
18
+ <template #default>
19
+ <slot name="pct-default" :formatStartTime="formatStartTime" :formatEndTime="formatEndTime">
20
+ <div :class="[ns.b(), ns.is('active', pickerVisivle)]">
21
+ <slot name="label">
22
+ <span v-if="column" :class="ns.e('label')">{{ column.title }}</span>
23
+ </slot>
24
+
25
+ <span :class="[ns.e('time'), ns.is('empty', !formatStartTime)]">
26
+ <span :class="ns.e('content')">
27
+ {{ formatStartTime ? formatStartTime : '开始日期' }}
28
+ </span>
29
+ <ElIcon :class="ns.e('caret')">
30
+ <CaretBottom />
31
+ </ElIcon>
32
+ </span>
33
+
34
+ <span :class="[ns.e('time'), ns.is('empty', !formatEndTime)]">
35
+ <span :class="ns.e('content')">
36
+ {{ formatEndTime ? formatEndTime : '结束日期' }}
37
+ </span>
38
+ <ElIcon :class="ns.e('caret')">
39
+ <CaretBottom />
40
+ </ElIcon>
41
+ </span>
42
+ </div>
43
+ </slot>
44
+ </template>
45
+
46
+ <template #content>
47
+ <PanelDateRange
48
+ :parsed-value="parsedValue"
49
+ type="daterange"
50
+ :visible="pickerVisivle"
51
+ @pick="onPick"
52
+ :teleported="false"
53
+ />
54
+ </template>
55
+ </ElTooltip>
56
+ </template>
57
+
58
+ <script setup>
59
+ import { computed, watch, inject, ref, provide, useSlots, unref } from 'vue';
60
+ import {
61
+ useNamespace,
62
+ filterPanelItemKey,
63
+ useGlobalConfig,
64
+ } from 'web-base-client-vue';
65
+ import { dayjs } from 'element-plus';
66
+ import PanelDateRange from 'element-plus/es/components/date-picker/src/date-picker-com/panel-date-range';
67
+ import { timePickerDefaultProps } from 'element-plus/es/components/time-picker/src/common/props';
68
+ import { ROOT_PICKER_INJECTION_KEY } from 'element-plus/es/components/date-picker/src/constants';
69
+ import { useNamespace as useElementPlusNamesplace } from 'element-plus/es/hooks/index';
70
+ import {
71
+ formatter,
72
+ parseDate,
73
+ valueEquals,
74
+ } from 'element-plus/es/components/time-picker/src/utils';
75
+
76
+ defineOptions({ name: 'BwaDateRange' });
77
+
78
+ const props = defineProps({
79
+ ...timePickerDefaultProps,
80
+ modelValue: {
81
+ type: null,
82
+ required: true,
83
+ },
84
+ });
85
+
86
+ const ns = useNamespace('daterange');
87
+
88
+ const pickerVisivle = ref(false);
89
+
90
+ const filterPanelItem = inject(filterPanelItemKey);
91
+ const column = computed(() => filterPanelItem?.column ?? null);
92
+
93
+ const emit = defineEmits(['update:modelValue']);
94
+
95
+ const slots = useSlots();
96
+
97
+ const locale = useGlobalConfig('locale', 'ZH');
98
+ const lang = computed(() => unref(locale).name);
99
+
100
+ provide(ROOT_PICKER_INJECTION_KEY, {
101
+ slots,
102
+ pickerNs: useElementPlusNamesplace('picker-panel'),
103
+ });
104
+ provide('EP_PICKER_BASE', {
105
+ props,
106
+ });
107
+
108
+ watch(
109
+ computed(() => props.modelValue),
110
+ () => {
111
+ if (
112
+ !props.modelValue ||
113
+ Array.isArray(props.modelValue) ||
114
+ typeof props.modelValue !== 'object'
115
+ ) {
116
+ emit('update:modelValue', { start: '', end: '' });
117
+ }
118
+ },
119
+ { immediate: true }
120
+ );
121
+
122
+ const formatShowTime = (date) => {
123
+ return date ? dayjs(date).format('YYYY-MM-DD') : '';
124
+ };
125
+
126
+ /** @type {import('vue').ComputedRef<string>} */
127
+ const startTime = computed(() => {
128
+ if (!props.modelValue?.start) {
129
+ return '';
130
+ }
131
+
132
+ return dayjs(props.modelValue.start)
133
+ .set('hour', 0)
134
+ .set('minute', 0)
135
+ .set('second', 0)
136
+ .format('YYYY-MM-DD HH:mm:ss');
137
+ });
138
+ /** @type {import('vue').ComputedRef<string>} */
139
+ const endTime = computed(() => {
140
+ if (!props.modelValue?.end) {
141
+ return '';
142
+ }
143
+
144
+ return dayjs(props.modelValue.end)
145
+ .set('hour', 23)
146
+ .set('minute', 59)
147
+ .set('second', 59)
148
+ .format('YYYY-MM-DD HH:mm:ss');
149
+ });
150
+
151
+ const formatStartTime = computed(() => formatShowTime(unref(startTime)));
152
+ const formatEndTime = computed(() => formatShowTime(unref(endTime)));
153
+
154
+ const dateRangeValue = computed(() => [unref(startTime), unref(endTime)]);
155
+
156
+ const valueIsEmpty = computed(() => {
157
+ const value = unref(dateRangeValue);
158
+ return !value || (Array.isArray(value) && !value.filter(Boolean).length);
159
+ });
160
+
161
+ const parsedValue = computed(() => {
162
+ const { valueFormat } = props;
163
+ const value = unref(dateRangeValue);
164
+
165
+ if (!unref(valueIsEmpty)) {
166
+ return value.map((d) => parseDate(d, valueFormat, unref(lang)));
167
+ }
168
+
169
+ return [];
170
+ });
171
+
172
+ const emitInput = (input) => {
173
+ if (!valueEquals(unref(dateRangeValue), input)) {
174
+ const formatted = input.map((item) =>
175
+ formatter(item, props.valueFormat, unref(lang))
176
+ );
177
+
178
+ emit('update:modelValue', {
179
+ start: formatted[0]
180
+ ? dayjs(formatted[0])
181
+ .set('hour', 0)
182
+ .set('minute', 0)
183
+ .set('second', 0)
184
+ .format('YYYY-MM-DD HH:mm:ss')
185
+ : '',
186
+ end: formatted[1]
187
+ ? dayjs(formatted[1])
188
+ .set('hour', 23)
189
+ .set('minute', 59)
190
+ .set('second', 59)
191
+ .format('YYYY-MM-DD HH:mm:ss')
192
+ : '',
193
+ });
194
+ }
195
+ };
196
+
197
+ const onPick = (date, visible = false) => {
198
+ pickerVisivle.value = visible;
199
+
200
+ emitInput(date.map((item) => item.toDate()));
201
+ };
202
+ </script>
@@ -0,0 +1,6 @@
1
+ import { withInstall } from 'element-plus/es/utils/vue/install';
2
+ import DateRange from './date-range.vue';
3
+
4
+ export const BwaDateRange = withInstall(DateRange);
5
+
6
+ export default BwaDateRange;
@@ -0,0 +1 @@
1
+ export const dragListContextKey = 'DRAG_LIST_CONTEXT_KEY';
@@ -0,0 +1,46 @@
1
+ <template>
2
+ <div :class="ns.b()" draggable-context-id="" @mousedown="handleMousedown">
3
+ <i :class="[ns.e('drag-icon'), 'ptp-icon', 'ptp-buzhou-yidong']"></i>
4
+ <span :class="ns.e('content')">
5
+ <slot></slot>
6
+ </span>
7
+ </div>
8
+ </template>
9
+
10
+ <script setup>
11
+ import { getCurrentInstance, inject, onBeforeUnmount, onMounted } from 'vue';
12
+ import { useNamespace } from 'web-base-client-vue';
13
+ import { dragListContextKey } from './constants';
14
+
15
+ const ns = useNamespace('dragitem');
16
+
17
+ defineOptions({ name: 'BwaDragItem' });
18
+
19
+ const dragListContext = inject(dragListContextKey);
20
+
21
+ const id = dragListContext.nextID();
22
+
23
+ const instance = getCurrentInstance();
24
+
25
+ /**
26
+ * @param {MouseEvent} event
27
+ */
28
+ const handleMousedown = (event) => {
29
+ if (event.button !== 0) {
30
+ return;
31
+ }
32
+ dragListContext.startDrag(instance.proxy);
33
+ };
34
+
35
+ onMounted(() => {
36
+ dragListContext.handleItemCreate(id, instance.proxy);
37
+ });
38
+
39
+ onBeforeUnmount(() => {
40
+ dragListContext.handleItemDestroy(id, instance.proxy);
41
+ });
42
+
43
+ defineExpose({
44
+ id,
45
+ });
46
+ </script>