@ditari/bsui 1.1.40 → 1.1.42

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,383 @@
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-table
282
+ v-model:keys="selectedRowKeys"
283
+ row-key="id"
284
+ :loading="loading"
285
+ :expanded-row-keys="['1', '2']"
286
+ :data="data"
287
+ :config="config"
288
+ :height="400"
289
+ @change="
290
+ () => {
291
+ console.log('change');
292
+ }
293
+ "
294
+ >
295
+ <template #action>
296
+ <a-button>ok</a-button>
49
297
  </template>
50
- </d-show-layout>
298
+ </d-table>
51
299
  </template>
52
- <style scoped>
53
- .title {
54
- font-size: 18px;
55
- font-weight: bold;
56
- color: #2589ff;
300
+ <style lang="scss">
301
+ @mixin rowEdit {
302
+ //content: "";
303
+ //display: block;
304
+ //position: absolute;
305
+ //top: 0;
306
+ //left: 0;
307
+ //z-index: 1993;
308
+ //transition: all 0.3s ease-in-out; /* 或者使用动画实现 */
309
+ content: "";
310
+ position: absolute;
311
+ //top: 0;
312
+ //left: 0;
313
+ //right: 0;
314
+ //bottom: 0;
315
+ z-index: 1993;
316
+
317
+ // border: 1px solid red;
318
+ //transform: scaleY(0);
319
+ transition: transform 0.3s ease-in-out;
320
+ }
321
+ .row-edit-class {
322
+ position: relative;
323
+
324
+ &:after {
325
+ @include rowEdit;
326
+ //box-shadow: 0 0 0 2px red;
327
+ }
328
+
329
+ //&::before {
330
+ // border-top: 1px solid #ccc;
331
+ // border-bottom: 1px solid #ccc;
332
+ // transform: scaleY(0);
333
+ //}
334
+ //
335
+ //&::after {
336
+ // border-left: 1px solid #ccc;
337
+ // border-right: 1px solid #ccc;
338
+ //}
339
+ }
340
+
341
+ //tr:hover::before,
342
+ //tr:hover::after {
343
+ // transform: scaleY(1) scaleX(1);
344
+ //}
345
+
346
+ .row-class {
347
+ position: relative;
348
+ z-index: 1993;
349
+ //box-shadow: 2px 1px 8px 2px #162157;
350
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
351
+ transform: translate(0px, 1px);
352
+ transition: box-shadow 0.3s, transform 0.3s, font-weight 0.9s;
353
+ td {
354
+ font-weight: bold;
355
+
356
+ &:first-child {
357
+ &::before {
358
+ position: absolute;
359
+ left: 0px;
360
+ top: -2px;
361
+ bottom: -2px;
362
+ content: "";
363
+ width: 4px;
364
+ background: #017ffe;
365
+ transition: width 0.3s, background 0.3s;
366
+ }
367
+ }
368
+ }
369
+ }
370
+ //
371
+ //tr {
372
+ // &:hover {
373
+ // position: relative;
374
+ // z-index: 1993;
375
+ // box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
376
+ // transform: translateZ(10px);
377
+ // transition: box-shadow 0.3s, transform 0.3s;
378
+ // }
379
+ //}
380
+ tr {
381
+ cursor: pointer;
57
382
  }
58
383
  </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.42",
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++) {