@ditari/bsui 1.1.40 → 1.1.41

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.
@@ -1,58 +1,393 @@
1
1
  <script setup lang="ts">
2
- import { onActivated, onUnmounted, ref } from "vue";
3
- import { useRoute } from "vue-router";
2
+ import { ref, onDeactivated, onBeforeUnmount } from "vue";
3
+ import { useTable } from "./hooks";
4
4
 
5
- const columns = [
5
+ const { data, loading, config, selectedRowKeys } = useTable();
6
+
7
+ const formState = ref({
8
+ name: "",
9
+ to: "",
10
+ from: ""
11
+ });
12
+
13
+ onBeforeUnmount(() => {
14
+ console.log("onBeforeUnmount");
15
+ });
16
+
17
+ onDeactivated(() => {
18
+ console.log("222");
19
+ });
20
+
21
+ const scheme = [
22
+ {
23
+ type: "a-col",
24
+ props: {
25
+ span: 6
26
+ },
27
+ body: {
28
+ type: "a-form-item",
29
+ props: {
30
+ label: "姓名",
31
+ name: "name"
32
+ },
33
+ body: {
34
+ type: "a-input",
35
+ props: {
36
+ name: "name",
37
+ placeholder: "请输入姓名"
38
+ }
39
+ }
40
+ }
41
+ },
42
+ {
43
+ type: "a-col",
44
+ props: {
45
+ span: 6
46
+ },
47
+ body: {
48
+ type: "a-form-item",
49
+ props: {
50
+ label: "姓名",
51
+ name: "name"
52
+ },
53
+ body: {
54
+ type: "a-input",
55
+ props: {
56
+ name: "name",
57
+ placeholder: "请输入姓名"
58
+ }
59
+ }
60
+ }
61
+ },
62
+ {
63
+ type: "a-col",
64
+ props: {
65
+ span: 6
66
+ },
67
+ body: {
68
+ type: "a-form-item",
69
+ props: {
70
+ label: "姓名",
71
+ name: "name"
72
+ },
73
+ body: {
74
+ type: "a-input",
75
+ props: {
76
+ name: "name",
77
+ placeholder: "请输入姓名"
78
+ }
79
+ }
80
+ }
81
+ },
82
+ {
83
+ type: "a-col",
84
+ props: {
85
+ span: 6
86
+ },
87
+ body: {
88
+ type: "a-form-item",
89
+ props: {
90
+ label: "姓名",
91
+ name: "name"
92
+ },
93
+ body: {
94
+ type: "a-input",
95
+ props: {
96
+ name: "name",
97
+ placeholder: "请输入姓名"
98
+ }
99
+ }
100
+ }
101
+ },
102
+ {
103
+ type: "a-col",
104
+ props: {
105
+ span: 6
106
+ },
107
+ body: {
108
+ type: "a-form-item",
109
+ props: {
110
+ label: "姓名",
111
+ name: "name"
112
+ },
113
+ body: {
114
+ type: "a-input",
115
+ props: {
116
+ name: "name",
117
+ placeholder: "请输入姓名"
118
+ }
119
+ }
120
+ }
121
+ },
122
+ {
123
+ type: "a-col",
124
+ props: {
125
+ span: 6
126
+ },
127
+ body: {
128
+ type: "a-form-item",
129
+ props: {
130
+ label: "姓名",
131
+ name: "name"
132
+ },
133
+ body: {
134
+ type: "a-input",
135
+ props: {
136
+ name: "name",
137
+ placeholder: "请输入姓名"
138
+ }
139
+ }
140
+ }
141
+ },
6
142
  {
7
- title: "商品编码"
143
+ type: "a-col",
144
+ props: {
145
+ span: 6
146
+ },
147
+ body: {
148
+ type: "a-form-item",
149
+ props: {
150
+ label: "姓名",
151
+ name: "name"
152
+ },
153
+ body: {
154
+ type: "a-input",
155
+ props: {
156
+ name: "name",
157
+ placeholder: "请输入姓名"
158
+ }
159
+ }
160
+ }
8
161
  },
9
162
  {
10
- title: "商品名称"
163
+ type: "a-col",
164
+ props: {
165
+ span: 6
166
+ },
167
+ body: {
168
+ type: "a-form-item",
169
+ props: {
170
+ label: "姓名",
171
+ name: "name"
172
+ },
173
+ body: {
174
+ type: "a-input",
175
+ props: {
176
+ name: "name",
177
+ placeholder: "请输入姓名"
178
+ }
179
+ }
180
+ }
11
181
  },
12
182
  {
13
- title: "第一计量单位"
183
+ type: "a-col",
184
+ props: {
185
+ span: 6
186
+ },
187
+ body: {
188
+ type: "a-form-item",
189
+ props: {
190
+ label: "姓名",
191
+ name: "name"
192
+ },
193
+ body: {
194
+ type: "a-input",
195
+ props: {
196
+ name: "name",
197
+ placeholder: "请输入姓名"
198
+ }
199
+ }
200
+ }
14
201
  },
15
202
  {
16
- title: "申报总价"
203
+ type: "a-col",
204
+ props: {
205
+ span: 6
206
+ },
207
+ body: {
208
+ type: "a-form-item",
209
+ props: {
210
+ label: "姓名",
211
+ name: "name"
212
+ },
213
+ body: {
214
+ type: "a-input",
215
+ props: {
216
+ name: "name",
217
+ placeholder: "请输入姓名"
218
+ }
219
+ }
220
+ }
17
221
  },
18
222
  {
19
- title: "毛重"
223
+ type: "a-col",
224
+ props: {
225
+ span: 6
226
+ },
227
+ body: {
228
+ type: "a-form-item",
229
+ props: {
230
+ label: "姓名",
231
+ name: "name"
232
+ },
233
+ body: {
234
+ type: "a-input",
235
+ props: {
236
+ name: "name",
237
+ placeholder: "请输入姓名"
238
+ }
239
+ }
240
+ }
241
+ },
242
+ {
243
+ type: "a-col",
244
+ props: {
245
+ span: 6
246
+ },
247
+ body: {
248
+ type: "a-form-item",
249
+ props: {
250
+ label: "申报日期",
251
+ name: "date"
252
+ },
253
+ body: {
254
+ type: "d-range-picker",
255
+ props: {
256
+ value: formState,
257
+ field: ["to", "from"]
258
+ }
259
+ }
260
+ }
20
261
  }
21
262
  ];
22
- const route = useRoute();
23
- const loading = ref(false);
24
263
 
25
- const formState = ref({
26
- originCountry: ""
27
- });
264
+ const onQuery = () => {
265
+ console.log("22");
266
+ };
28
267
 
29
- onUnmounted(() => {
30
- console.log("onUnmounted");
31
- });
32
- onActivated(() => {
33
- console.log("onActivated");
34
- });
268
+ const queryParams = ref({ from: "", to: "" });
269
+
270
+ setTimeout(() => {
271
+ queryParams.value.from = "2023-02-04";
272
+ queryParams.value.to = "2023-05-06";
273
+ }, 3000);
35
274
  </script>
36
275
  <script lang="ts">
37
276
  export default {
38
- name: "Add"
277
+ name: "TableList"
39
278
  };
40
279
  </script>
41
280
  <template>
42
- <d-show-layout :loading="loading">
43
- <template #footer>
44
- <a-space>
45
- <a-button type="primary" @click="loading = true">暂存</a-button>
46
- {{ loading }}
47
- <a-button type="primary">申报</a-button>
48
- </a-space>
281
+ <d-list-layout>
282
+ <template #form>
283
+ <d-query-form :value="formState" :scheme="scheme" @query="onQuery">
284
+ </d-query-form>
285
+ {{ queryParams }}
286
+ <d-range-picker v-model:value="queryParams" :field="['from', 'to']" />
49
287
  </template>
50
- </d-show-layout>
288
+ <template #table="{ height }">
289
+ <d-table
290
+ v-model:keys="selectedRowKeys"
291
+ row-key="id"
292
+ :loading="loading"
293
+ :expanded-row-keys="['1', '2']"
294
+ :data="data"
295
+ :config="config"
296
+ :height="height"
297
+ @change="
298
+ () => {
299
+ console.log('change');
300
+ }
301
+ "
302
+ >
303
+ <template #action>
304
+ <a-button>ok</a-button>
305
+ </template>
306
+ </d-table>
307
+ </template>
308
+ </d-list-layout>
51
309
  </template>
52
- <style scoped>
53
- .title {
54
- font-size: 18px;
55
- font-weight: bold;
56
- color: #2589ff;
310
+ <style lang="scss">
311
+ @mixin rowEdit {
312
+ //content: "";
313
+ //display: block;
314
+ //position: absolute;
315
+ //top: 0;
316
+ //left: 0;
317
+ //z-index: 1993;
318
+ //transition: all 0.3s ease-in-out; /* 或者使用动画实现 */
319
+ content: "";
320
+ position: absolute;
321
+ //top: 0;
322
+ //left: 0;
323
+ //right: 0;
324
+ //bottom: 0;
325
+ z-index: 1993;
326
+
327
+ // border: 1px solid red;
328
+ //transform: scaleY(0);
329
+ transition: transform 0.3s ease-in-out;
330
+ }
331
+ .row-edit-class {
332
+ position: relative;
333
+
334
+ &:after {
335
+ @include rowEdit;
336
+ //box-shadow: 0 0 0 2px red;
337
+ }
338
+
339
+ //&::before {
340
+ // border-top: 1px solid #ccc;
341
+ // border-bottom: 1px solid #ccc;
342
+ // transform: scaleY(0);
343
+ //}
344
+ //
345
+ //&::after {
346
+ // border-left: 1px solid #ccc;
347
+ // border-right: 1px solid #ccc;
348
+ //}
349
+ }
350
+
351
+ //tr:hover::before,
352
+ //tr:hover::after {
353
+ // transform: scaleY(1) scaleX(1);
354
+ //}
355
+
356
+ .row-class {
357
+ position: relative;
358
+ z-index: 1993;
359
+ //box-shadow: 2px 1px 8px 2px #162157;
360
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
361
+ transform: translate(0px, 1px);
362
+ transition: box-shadow 0.3s, transform 0.3s, font-weight 0.9s;
363
+ td {
364
+ font-weight: bold;
365
+
366
+ &:first-child {
367
+ &::before {
368
+ position: absolute;
369
+ left: 0px;
370
+ top: -2px;
371
+ bottom: -2px;
372
+ content: "";
373
+ width: 4px;
374
+ background: #017ffe;
375
+ transition: width 0.3s, background 0.3s;
376
+ }
377
+ }
378
+ }
379
+ }
380
+ //
381
+ //tr {
382
+ // &:hover {
383
+ // position: relative;
384
+ // z-index: 1993;
385
+ // box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
386
+ // transform: translateZ(10px);
387
+ // transition: box-shadow 0.3s, transform 0.3s;
388
+ // }
389
+ //}
390
+ tr {
391
+ cursor: pointer;
57
392
  }
58
393
  </style>
@@ -1,5 +1,5 @@
1
1
  <script setup lang="ts">
2
- import { ref, onDeactivated } from "vue";
2
+ import { ref, onDeactivated, onBeforeUnmount } from "vue";
3
3
  import { useTable } from "./hooks";
4
4
 
5
5
  const { data, loading, config, selectedRowKeys } = useTable();
@@ -10,6 +10,10 @@ const formState = ref({
10
10
  from: ""
11
11
  });
12
12
 
13
+ onBeforeUnmount(() => {
14
+ console.log("onBeforeUnmount");
15
+ });
16
+
13
17
  onDeactivated(() => {
14
18
  console.log("222");
15
19
  });
@@ -266,7 +270,7 @@ const queryParams = ref({ from: "", to: "" });
266
270
  setTimeout(() => {
267
271
  queryParams.value.from = "2023-02-04";
268
272
  queryParams.value.to = "2023-05-06";
269
- }, 3000);
273
+ }, 200);
270
274
  </script>
271
275
  <script lang="ts">
272
276
  export default {
@@ -20,7 +20,7 @@ export const useTable = () => {
20
20
  columns,
21
21
  // bordered: true,
22
22
  pagination,
23
-
23
+ selection: "M",
24
24
  clickSelectedClassName: "ant-table-row-selected",
25
25
  onPageChange,
26
26
  dbClick: (record: any) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditari/bsui",
3
- "version": "1.1.40",
3
+ "version": "1.1.41",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -1,4 +1,4 @@
1
- import { defineComponent, ref, watchEffect } from "vue";
1
+ import { defineComponent, ref, watch } from "vue";
2
2
  import type { PropType } from "vue";
3
3
  import { RangePicker } from "ant-design-vue";
4
4
 
@@ -43,27 +43,27 @@ export default defineComponent({
43
43
  emit("update:value", internalModel.value);
44
44
  };
45
45
 
46
- watchEffect(() => {
47
- const value: any = props.value;
48
- props.field.forEach((key, index) => {
49
- if (value[key] === "") {
50
- dates.value && (dates.value[index] = "");
51
- } else {
52
- dates.value && (dates.value[index] = value[key]);
53
- }
54
- });
46
+ //循环字段
47
+ // eslint-disable-next-line vue/no-setup-props-destructure
48
+ const watchExpressions = props.field.map((key) => () => {
49
+ return props.value?.[key];
55
50
  });
56
51
 
57
- watchEffect(() => {
58
- const value: any = props.value;
59
- props.field.forEach((key, index) => {
60
- if (value[key] === "") {
61
- dates.value && (dates.value[index] = "");
62
- } else {
63
- dates.value && (dates.value[index] = value[key]);
64
- }
52
+ const watchHandler = (newValues: any) => {
53
+ // 判断是否被置空只有这两个字段同时为空,才是表明被置空
54
+ const isClear = props.field.every((key, index) => {
55
+ return newValues[index] === "" || newValues[index] === undefined;
65
56
  });
66
- });
57
+ if (isClear) {
58
+ dates.value = [];
59
+ } else {
60
+ props.field.forEach((key, index) => {
61
+ dates.value && (dates.value[index] = newValues[index]);
62
+ });
63
+ }
64
+ };
65
+ //监听多个字段变化
66
+ watch(watchExpressions, watchHandler);
67
67
 
68
68
  return () => (
69
69
  <div>
@@ -3,7 +3,7 @@
3
3
  * 根据字典名字及对应的value替换成中文或者人能看懂的文字
4
4
  * @author 余春林
5
5
  */
6
- import { defineComponent, ref, watchEffect } from "vue";
6
+ import { defineComponent, ref, watch } from "vue";
7
7
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
8
8
  // @ts-ignore
9
9
  // import DicWorker from "./replace.worker?worker&inline";
@@ -45,12 +45,18 @@ export default defineComponent({
45
45
  // // 赋值给下拉选择数据变量
46
46
  // dicValueTxt.value = e.data;
47
47
  // };
48
- watchEffect(() => {
49
- const value = props.value;
50
- const name = props.name;
51
- dicValueTxt.value = getDicTextByValue(name, value);
52
- // workerInstance.postMessage({ list: JSON.stringify(list), name, value });
53
- });
48
+
49
+ watch(
50
+ () => props.value,
51
+ (val: any) => {
52
+ const value = val;
53
+ const name = props.name;
54
+ dicValueTxt.value = getDicTextByValue(name, value);
55
+ },
56
+ {
57
+ immediate: true
58
+ }
59
+ );
54
60
 
55
61
  return () => <>{dicValueTxt.value}</>;
56
62
  }
@@ -8,8 +8,7 @@ import {
8
8
  onUnmounted,
9
9
  WatchStopHandle,
10
10
  inject,
11
- nextTick,
12
- watchEffect
11
+ nextTick
13
12
  } from "vue";
14
13
  import { useElementSize, useResizeObserver } from "@vueuse/core";
15
14
  import { useSettingsStore } from "@ditari/store";
@@ -81,22 +80,24 @@ function useWatch() {
81
80
 
82
81
  // 监听表单高度变化
83
82
  // 然后再获取表格高度
83
+ // 在表格高度动态变化的时候会被监听到
84
84
  const formRef = ref(null);
85
85
  const { height: formHeight } = useElementSize(formRef);
86
86
  watch(
87
87
  () => formHeight.value,
88
88
  () => {
89
- calcHeight();
90
- },
91
- { immediate: true }
89
+ nextTick(() => {
90
+ calcHeight();
91
+ });
92
+ }
92
93
  );
93
94
 
94
- watchEffect(() => {
95
+ const { stop } = useResizeObserver(document.body, () => {
95
96
  calcHeight();
96
97
  });
97
98
 
98
- useResizeObserver(document.body, () => {
99
- calcHeight();
99
+ onUnmounted(() => {
100
+ stop();
100
101
  });
101
102
 
102
103
  // 动态计算高度
package/src/menu/Menu.tsx CHANGED
@@ -1,4 +1,4 @@
1
- import { defineComponent, h, inject, resolveComponent, watchEffect } from "vue";
1
+ import { defineComponent, h, inject, resolveComponent, watch } from "vue";
2
2
  import { useRouter, useRoute } from "vue-router";
3
3
 
4
4
  import { storeToRefs } from "pinia";
@@ -18,19 +18,36 @@ export default defineComponent({
18
18
  const settingsStore = useSettingsStore();
19
19
  const { getCollapsed } = storeToRefs(settingsStore) as any;
20
20
 
21
- watchEffect(() => {
22
- if (getCollapsed.value) {
23
- // 如果菜单是收缩的状态,则不匹配激活的菜单
24
- // 否则 在切换标签的时候,收缩菜单会自动激活悬浮的动作
25
- return;
21
+ // watchEffect(() => {
22
+ // if (getCollapsed.value) {
23
+ // // 如果菜单是收缩的状态,则不匹配激活的菜单
24
+ // // 否则 在切换标签的时候,收缩菜单会自动激活悬浮的动作
25
+ // return;
26
+ // }
27
+ // // 会被触发两次
28
+ // // 当前激活的url
29
+ // const activatedUrl =
30
+ // selectedMenuKeys.value.length > 0 ? selectedMenuKeys.value[0] : "";
31
+ // const parentUrls = getParentUrls(list.value, activatedUrl);
32
+ // openMenusKeys.value = parentUrls || [];
33
+ // });
34
+
35
+ watch(
36
+ () => selectedMenuKeys.value,
37
+ (newValue: any) => {
38
+ if (getCollapsed.value) {
39
+ // 如果菜单是收缩的状态,则不匹配激活的菜单
40
+ // 否则 在切换标签的时候,收缩菜单会自动激活悬浮的动作
41
+ return;
42
+ }
43
+ const activatedUrl = newValue.length > 0 ? newValue[0] : "";
44
+ const parentUrls = getParentUrls(list.value, activatedUrl);
45
+ openMenusKeys.value = parentUrls || [];
46
+ },
47
+ {
48
+ deep: true
26
49
  }
27
- // 会被触发两次
28
- // 当前激活的url
29
- const activatedUrl =
30
- selectedMenuKeys.value.length > 0 ? selectedMenuKeys.value[0] : "";
31
- const parentUrls = getParentUrls(list.value, activatedUrl);
32
- openMenusKeys.value = parentUrls || [];
33
- });
50
+ );
34
51
 
35
52
  function getParentUrls(menus: any, url: any) {
36
53
  for (let i = 0; i < menus.length; i++) {
@@ -2,6 +2,8 @@ import {
2
2
  computed,
3
3
  defineComponent,
4
4
  nextTick,
5
+ onBeforeUnmount,
6
+ onDeactivated,
5
7
  PropType,
6
8
  reactive,
7
9
  ref,
@@ -184,6 +186,8 @@ const DXTable = defineComponent({
184
186
  // });
185
187
  // }
186
188
  // });
189
+
190
+ let playTimeout: any = null;
187
191
  watch(
188
192
  () => props.height,
189
193
  (val) => {
@@ -193,7 +197,7 @@ const DXTable = defineComponent({
193
197
  playHeight(props.height);
194
198
  } else {
195
199
  // 必须在组件挂载成功后 执行计算高度 否则无法正确获取元素的高度
196
- setTimeout(() => {
200
+ playTimeout = setTimeout(() => {
197
201
  playHeight(props.height);
198
202
  // 如果表格头有很多列的情况下,获取到的头部高度不对,需要延迟执行获取高度方法
199
203
  }, 100);
@@ -202,6 +206,14 @@ const DXTable = defineComponent({
202
206
  }
203
207
  }
204
208
  );
209
+
210
+ onBeforeUnmount(() => {
211
+ playTimeout && clearTimeout(playTimeout);
212
+ });
213
+ onDeactivated(() => {
214
+ playTimeout && clearTimeout(playTimeout);
215
+ });
216
+
205
217
  // 监听分页组件
206
218
  const onPageChange = (page: number, size: number) => {
207
219
  onChange ? onChange({ page: page === 0 ? 1 : page, size }) : null;
@@ -311,6 +323,9 @@ const DXTable = defineComponent({
311
323
  } else {
312
324
  rowSelection.value = undefined;
313
325
  }
326
+ },
327
+ {
328
+ immediate: true
314
329
  }
315
330
  );
316
331