@neatui/nuxt 0.1.0 → 1.0.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 (85) hide show
  1. package/BUILD.md +128 -0
  2. package/IMPORT_GUIDE.md +142 -0
  3. package/README.md +98 -1
  4. package/SSR_COMPATIBILITY.md +201 -0
  5. package/USAGE.md +291 -0
  6. package/nuxt.config.example.ts +37 -0
  7. package/package.json +34 -11
  8. package/src/components/basic/IDraggable.vue +87 -65
  9. package/src/components/basic/IFollowView.vue +32 -23
  10. package/src/components/basic/IRouterView.vue +38 -23
  11. package/src/components/basic/IScrollView.vue +11 -7
  12. package/src/components/basic/Icon.vue +17 -17
  13. package/src/components/basic/LayerView/Layer.vue +33 -106
  14. package/src/components/basic/follow.ts +133 -0
  15. package/src/components/display/Calendar.vue +14 -14
  16. package/src/components/display/CalendarReg.vue +14 -14
  17. package/src/components/display/Image.vue +8 -8
  18. package/src/components/display/PhotoEditor.vue +36 -36
  19. package/src/components/display/PhotoViewer.vue +8 -8
  20. package/src/components/display/Tree.vue +6 -6
  21. package/src/components/display/TreeView.vue +4 -4
  22. package/src/components/display/index.ts +2 -2
  23. package/src/components/form/Cascader.vue +19 -19
  24. package/src/components/form/Checkbox.vue +64 -0
  25. package/src/components/form/DatePicker.vue +6 -7
  26. package/src/components/form/DateRangePicker@v3.vue +4 -4
  27. package/src/components/form/DateRangeView@v3.vue +18 -19
  28. package/src/components/form/DateView.vue +14 -14
  29. package/src/components/form/DateView@v2.vue +14 -14
  30. package/src/components/form/DateView@v3.vue +331 -318
  31. package/src/components/form/ImgUpload.vue +7 -7
  32. package/src/components/form/Input@v3.vue +11 -11
  33. package/src/components/form/MoreSelect@v3.vue +87 -17
  34. package/src/components/form/MoreSelectList.vue +8 -8
  35. package/src/components/form/MoreSelectPanel@v3.vue +3 -3
  36. package/src/components/form/MoreSelectPicker.vue +7 -7
  37. package/src/components/form/MoreSelectTags.vue +8 -8
  38. package/src/components/form/PageMoreSelect.vue +14 -14
  39. package/src/components/form/PageSelect.vue +16 -16
  40. package/src/components/form/SearchMoreSelect.vue +12 -12
  41. package/src/components/form/SearchSelect@v3.vue +3 -3
  42. package/src/components/form/Select@v3.vue +229 -23
  43. package/src/components/form/SelectList.vue +8 -8
  44. package/src/components/form/SelectPicker.vue +6 -6
  45. package/src/components/form/SelectTags.vue +7 -7
  46. package/src/components/form/SelectTree/SelectTree@v1.vue +5 -5
  47. package/src/components/form/Switch.vue +38 -103
  48. package/src/components/form/TextArea.vue +18 -18
  49. package/src/components/form/Textarea@v2.vue +275 -0
  50. package/src/components/form/TimeView.vue +14 -14
  51. package/src/components/form/Upload.vue +806 -297
  52. package/src/components/form/date.ts +321 -0
  53. package/src/components/form/index.ts +7 -5
  54. package/src/components/form/number.ts +3 -0
  55. package/src/components/form/type.ts +224 -0
  56. package/src/components/icon/OrderIcon.vue +113 -0
  57. package/src/components/loader/FormLoader/FormLoader@v2.vue +193 -195
  58. package/src/components/loader/FormLoader/FormLoader@v3.vue.backup +372 -291
  59. package/src/components/loader/FormLoader/FormRender@v3.vue.backup +4 -0
  60. package/src/components/loader/FormLoader/NodeLoader.vue +85 -0
  61. package/src/components/loader/FormLoader@v1/FormLoader.vue +1 -1
  62. package/src/components/loader/FormLoader@v1/FormRender.vue +49 -24
  63. package/src/components/loader/LayerLoader/LayerLoader.vue +318 -0
  64. package/src/components/loader/LayerLoader/index.ts +2 -0
  65. package/src/components/loader/LayerLoader/style.scss +77 -0
  66. package/src/components/loader/LimitLoader/LimitLoader@v3.vue +39 -28
  67. package/src/components/loader/MoveLoader/MoveLoader.vue +628 -0
  68. package/src/components/loader/MoveLoader/index.ts +2 -0
  69. package/src/components/loader/MoveLoader/style.scss +77 -0
  70. package/src/components/loader/TableLoader/TableLoader.vue +227 -195
  71. package/src/components/loader/TableLoader/TableRender.vue +141 -0
  72. package/src/components/loader/TableLoader/index.ts +47 -0
  73. package/src/components/loader/index.ts +3 -2
  74. package/src/components/tools/Pagination@a.vue +17 -18
  75. package/src/components/tools/Pagination@b.vue +16 -16
  76. package/src/index.ts +2 -1
  77. package/src/module.ts +169 -0
  78. package/src/runtime/types.d.ts +36 -0
  79. package/src/store/{myui.ts → frame.ts} +4 -4
  80. package/src/utils/theme.ts +14 -0
  81. package/tsconfig.json +1 -1
  82. package/src/components/loader/FormLoader/index.ts +0 -2
  83. package/src/components/loader/LimitLoader/LimitLoader.vue.backup +0 -131
  84. package/src/components/loader/LimitLoader/LimitLoader@v2.vue.backup +0 -174
  85. package/src/components/loader/TableLoader/TableColView.vue +0 -115
@@ -19,8 +19,8 @@
19
19
  <div
20
20
  ui-flex="col cm"
21
21
  class="r-ss b-solid bk-none b-xs"
22
- :class="`${item.isToday ? 'bk-main-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
23
- state.selected && state.selected === item.date ? 'active bg-main-ls co-fore' : 'hover-bg-weak'
22
+ :class="`${item.isToday ? 'bk-main-o-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
23
+ state.selected && state.selected === item.date ? 'active bg-main-o-ls co-fore' : 'hover-bg-weak'
24
24
  }`"
25
25
  >
26
26
  <span>{{ item.day }}</span>
@@ -108,40 +108,40 @@
108
108
  // 提示文案
109
109
  tips: {
110
110
  type: String,
111
- default: ''
111
+ default: '',
112
112
  },
113
113
  // 提示文案
114
114
  placeholder: {
115
115
  type: String,
116
- default: ''
116
+ default: '',
117
117
  },
118
118
  // 格式
119
119
  format: {
120
120
  type: String,
121
- default: ''
121
+ default: '',
122
122
  },
123
123
  // 值
124
124
  value: {
125
125
  type: [String, Number],
126
- default: ''
126
+ default: '',
127
127
  },
128
128
  // 值
129
129
  modelValue: { type: [String, Number], default: '' },
130
130
  // 节假日
131
131
  holiday: {
132
132
  type: Object,
133
- default: () => ({})
133
+ default: () => ({}),
134
134
  },
135
135
  // 校验规则
136
136
  rules: {
137
137
  type: Array,
138
- default: () => []
138
+ default: () => [],
139
139
  },
140
140
  // 是否是示校验图标
141
141
  verify: {
142
142
  type: Boolean,
143
- default: false
144
- }
143
+ default: false,
144
+ },
145
145
  });
146
146
 
147
147
  // 内部数据
@@ -186,7 +186,7 @@
186
186
  calendar.unshift({
187
187
  date: `${last_y}-${last_m}-${prevdays}`,
188
188
  day: prevdays,
189
- isLastMonth: 1
189
+ isLastMonth: 1,
190
190
  });
191
191
  prevdays = prevdays - 1;
192
192
  }
@@ -197,7 +197,7 @@
197
197
  day: _i,
198
198
  isToday: curr_y === y && curr_m === m && curr_d === i,
199
199
  isHoliday: props.holiday[`${y}-${m}-${_i}`]?.name ? 1 : 0,
200
- holiday: props.holiday[`${y}-${m}-${_i}`]?.name
200
+ holiday: props.holiday[`${y}-${m}-${_i}`]?.name,
201
201
  });
202
202
  }
203
203
  for (let i = 1; calendar.length < 42; i++) {
@@ -205,14 +205,14 @@
205
205
  calendar.push({
206
206
  date: `${next_y}-${next_m}-${_i}`,
207
207
  day: _i,
208
- isNextMonth: 1
208
+ isNextMonth: 1,
209
209
  });
210
210
  }
211
211
  return { days: calendar, y, m, d };
212
212
  }),
213
213
  value: computed(() => {
214
214
  return props.format ? idate(state.selected || props.value).format(props.format) : state.selected || props.value;
215
- })
215
+ }),
216
216
  });
217
217
  const { curr = {} }: any = toRefs(state);
218
218
 
@@ -19,8 +19,8 @@
19
19
  <div
20
20
  ui-flex="col cm"
21
21
  class="r-ss b-solid bk-none b-xs"
22
- :class="`${item.isToday ? 'bk-main-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
23
- state.selected && state.selected === item.date ? 'active bg-main-ls co-fore' : 'hover-bg-weak'
22
+ :class="`${item.isToday ? 'bk-main-o-ls' : item.isLastMonth || item.isNextMonth ? 'co-note' : item.isHoliday ? 'co-risk' : ''} ${
23
+ state.selected && state.selected === item.date ? 'active bg-main-o-ls co-fore' : 'hover-bg-weak'
24
24
  }`"
25
25
  >
26
26
  <span>{{ item.day }}</span>
@@ -108,40 +108,40 @@
108
108
  // 提示文案
109
109
  tips: {
110
110
  type: String,
111
- default: ''
111
+ default: '',
112
112
  },
113
113
  // 提示文案
114
114
  placeholder: {
115
115
  type: String,
116
- default: ''
116
+ default: '',
117
117
  },
118
118
  // 格式
119
119
  format: {
120
120
  type: String,
121
- default: ''
121
+ default: '',
122
122
  },
123
123
  // 值
124
124
  value: {
125
125
  type: [String, Number],
126
- default: ''
126
+ default: '',
127
127
  },
128
128
  // 值
129
129
  modelValue: { type: [String, Number], default: '' },
130
130
  // 节假日
131
131
  holiday: {
132
132
  type: Object,
133
- default: () => ({})
133
+ default: () => ({}),
134
134
  },
135
135
  // 校验规则
136
136
  rules: {
137
137
  type: Array,
138
- default: () => []
138
+ default: () => [],
139
139
  },
140
140
  // 是否是示校验图标
141
141
  verify: {
142
142
  type: Boolean,
143
- default: false
144
- }
143
+ default: false,
144
+ },
145
145
  });
146
146
 
147
147
  // 内部数据
@@ -186,7 +186,7 @@
186
186
  calendar.unshift({
187
187
  date: `${last_y}-${last_m}-${prevdays}`,
188
188
  day: prevdays,
189
- isLastMonth: 1
189
+ isLastMonth: 1,
190
190
  });
191
191
  prevdays = prevdays - 1;
192
192
  }
@@ -197,7 +197,7 @@
197
197
  day: _i,
198
198
  isToday: curr_y === y && curr_m === m && curr_d === i,
199
199
  isHoliday: props.holiday[`${y}-${m}-${_i}`]?.name ? 1 : 0,
200
- holiday: props.holiday[`${y}-${m}-${_i}`]?.name
200
+ holiday: props.holiday[`${y}-${m}-${_i}`]?.name,
201
201
  });
202
202
  }
203
203
  for (let i = 1; calendar.length < 42; i++) {
@@ -205,14 +205,14 @@
205
205
  calendar.push({
206
206
  date: `${next_y}-${next_m}-${_i}`,
207
207
  day: _i,
208
- isNextMonth: 1
208
+ isNextMonth: 1,
209
209
  });
210
210
  }
211
211
  return { days: calendar, y, m, d };
212
212
  }),
213
213
  value: computed(() => {
214
214
  return props.format ? idate(state.selected || props.value).format(props.format) : state.selected || props.value;
215
- })
215
+ }),
216
216
  });
217
217
  const { curr = {} }: any = toRefs(state);
218
218
 
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div>
3
- <div :class="`mc-img b-solid bk-case b-xs ${imgClass}`" :style="imgStyle">
3
+ <div :class="`mc-img ${imgClass}`" :style="imgStyle">
4
4
  <img :src="src[srcName]" :style="`object-fit: ${fit}`" @click.stop="showPreview" />
5
5
  <div v-if="tools" class="mc-img-tools">
6
6
  <slot name="tools">
@@ -19,33 +19,33 @@
19
19
 
20
20
  const props: any = defineProps({
21
21
  tools: { type: Boolean, default: true },
22
- srcName: { type: String, default: 'imgUrl' },
22
+ srcName: { type: String, default: 'url' },
23
23
  theme: { type: String, default: '@a' },
24
24
  co: { type: String, default: 'note' },
25
25
  imgClass: { type: String, default: '' },
26
26
  imgStyle: { type: String, default: '' },
27
27
  src: {
28
28
  type: Object,
29
- default: () => ({})
29
+ default: () => ({}),
30
30
  },
31
31
  files: {
32
32
  type: Array as () => any[],
33
- default: () => []
33
+ default: () => [],
34
34
  },
35
35
  // 图片如何适应容器框,同原生object-fit
36
36
  fit: {
37
37
  type: String,
38
- default: 'contain'
38
+ default: 'contain',
39
39
  },
40
40
  // 是否开启图片预览放大
41
41
  preview: {
42
42
  type: Boolean,
43
- default: true
43
+ default: true,
44
44
  },
45
45
  initialSlide: {
46
46
  type: Number,
47
- default: 0
48
- }
47
+ default: 0,
48
+ },
49
49
  });
50
50
 
51
51
  const emit = defineEmits(['delImg']);
@@ -3,7 +3,7 @@
3
3
  <div class="mt-mm" ui-note="@b risk">抠图和压缩处理需要较长时间,期间请耐心等待不要关闭本窗口或进行操作,本功能需要付费,请尽量珍惜每一次处理避免不必要的浪费~</div>
4
4
  <div v-if="state.img" class="photo-editor-viewer bg-weak my-mm" ui-flex="row">
5
5
  <div class="mr-mm" style="flex: 1">
6
- <vue-cropper ref="cropperRef" :img="state.img" :autoCrop="state.autoCrop" @realTime="realTime"></vue-cropper>
6
+ <vue-cropper ref="cropperRef" :img="state.img" :auto-crop="state.autoCrop" @real-time="realTime" />
7
7
  </div>
8
8
  <div style="flex: 1" class="photo-editor-transparent">
9
9
  <img :src="state.previews || ''" />
@@ -32,14 +32,14 @@
32
32
  import { VueCropper } from 'vue-cropper/next';
33
33
  import Compressor from 'compressorjs';
34
34
  import { LayerById } from '../basic';
35
- import axios from 'axios';
35
+ // import axios from 'axios';
36
36
  import 'vue-cropper/next/dist/index.css';
37
37
 
38
38
  const props: any = defineProps({
39
39
  layerId: {
40
40
  type: String,
41
- default: 'PhotoEditor'
42
- }
41
+ default: 'PhotoEditor',
42
+ },
43
43
  });
44
44
 
45
45
  const state = reactive({
@@ -47,7 +47,7 @@
47
47
  // outputType: 'jepg', // 裁剪生成图片格式
48
48
  autoCrop: true,
49
49
  previews: null, //base格式
50
- cropLoad: 0
50
+ cropLoad: 0,
51
51
  });
52
52
 
53
53
  const emit = defineEmits(['fileChange']);
@@ -63,7 +63,7 @@
63
63
  success: resolve,
64
64
  maxWidth: 1000,
65
65
  maxHeight: 700,
66
- error: reject
66
+ error: reject,
67
67
  });
68
68
  });
69
69
  const _file = blobToFile(blob);
@@ -91,36 +91,36 @@
91
91
  if (!state.cropLoad) {
92
92
  state.cropLoad = 1;
93
93
 
94
- const formData = {
95
- image_file_b64: state.previews,
96
- image_url: '',
97
- size: 'preview',
98
- type: 'auto',
99
- type_level: '1',
100
- format: 'auto',
101
- roi: '0% 0% 100% 100%',
102
- crop: false,
103
- crop_margin: '0',
104
- scale: 'original',
105
- position: 'original',
106
- channels: 'rgba',
107
- add_shadow: false,
108
- semitransparency: true,
109
- bg_color: '',
110
- bg_image_url: ''
111
- };
112
- const res: any = await axios.post(
113
- 'https://api.remove.bg/v1.0/removebg',
114
- { ...formData },
115
- { responseType: 'arraybuffer', headers: { 'X-Api-Key': 'kg4jrcKZd6Gjdx5CmBYmksuN' } }
116
- );
117
- if (res.status === 200) {
118
- const blob = new Blob([res.data], { type: 'image/png' });
119
- blobToDataURI(blob, (data: any) => {
120
- state.previews = data;
121
- state.cropLoad = 0;
122
- });
123
- }
94
+ // const formData = {
95
+ // image_file_b64: state.previews,
96
+ // image_url: '',
97
+ // size: 'preview',
98
+ // type: 'auto',
99
+ // type_level: '1',
100
+ // format: 'auto',
101
+ // roi: '0% 0% 100% 100%',
102
+ // crop: false,
103
+ // crop_margin: '0',
104
+ // scale: 'original',
105
+ // position: 'original',
106
+ // channels: 'rgba',
107
+ // add_shadow: false,
108
+ // semitransparency: true,
109
+ // bg_color: '',
110
+ // bg_image_url: '',
111
+ // };
112
+ // const res: any = await axios.post(
113
+ // 'https://api.remove.bg/v1.0/removebg',
114
+ // { ...formData },
115
+ // { responseType: 'arraybuffer', headers: { 'X-Api-Key': 'kg4jrcKZd6Gjdx5CmBYmksuN' } },
116
+ // );
117
+ // if (res.status === 200) {
118
+ // const blob = new Blob([res.data], { type: 'image/png' });
119
+ // blobToDataURI(blob, (data: any) => {
120
+ // state.previews = data;
121
+ // state.cropLoad = 0;
122
+ // });
123
+ // }
124
124
  }
125
125
  };
126
126
 
@@ -5,14 +5,14 @@
5
5
  :initialSlide="initialSlide"
6
6
  :spaceBetween="30"
7
7
  :keyboard="{
8
- enabled: true
8
+ enabled: true,
9
9
  }"
10
10
  :pagination="{
11
- clickable: true
11
+ clickable: true,
12
12
  }"
13
13
  :navigation="true"
14
14
  :modules="[Keyboard, Pagination, Navigation]"
15
- class="mySwiper"
15
+ class="full"
16
16
  >
17
17
  <SwiperSlide v-for="item in files" :key="item.id" class="ac" ui-flex="col cm">
18
18
  <img :src="item[srcName]" class="vc" />
@@ -32,19 +32,19 @@
32
32
  const props: any = defineProps({
33
33
  srcName: {
34
34
  type: String,
35
- default: 'imgUrl'
35
+ default: 'url',
36
36
  },
37
37
  id: {
38
38
  type: String,
39
- default: 'PhotoViewer'
39
+ default: 'PhotoViewer',
40
40
  },
41
41
  initialSlide: {
42
42
  type: Number,
43
- default: 0
43
+ default: 0,
44
44
  },
45
45
  files: {
46
46
  type: Array as () => any[],
47
- default: () => []
48
- }
47
+ default: () => [],
48
+ },
49
49
  });
50
50
  </script>
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <ul :class="`${root ? '' : 'nl-ms'}`">
3
3
  <li v-if="root" class="pr">
4
- <div ui-form="@a sz: co:risk type:none :block" class="full-w">
4
+ <div ui-form="@a sz: co:risk type:none :block" class="w-full">
5
5
  <div style="left: 0.75em" :ui-form-tips="state.error.ontips">{{ state.error.tips }}</div>
6
6
  </div>
7
7
  </li>
@@ -156,7 +156,7 @@
156
156
  line: false,
157
157
  interacted: false,
158
158
  rules: () => [],
159
- block: false
159
+ block: false,
160
160
  });
161
161
 
162
162
  /*
@@ -227,7 +227,7 @@
227
227
  error: {},
228
228
  // 用户是否交互
229
229
  interacted: false,
230
- tree: [] as Array<Record<string, any>>
230
+ tree: [] as Array<Record<string, any>>,
231
231
  });
232
232
 
233
233
  watch(
@@ -247,7 +247,7 @@
247
247
  return n;
248
248
  });
249
249
  },
250
- { deep: true, immediate: true }
250
+ { deep: true, immediate: true },
251
251
  );
252
252
 
253
253
  // 获取节点勾选状态
@@ -300,7 +300,7 @@
300
300
  change(state.selected);
301
301
  }
302
302
  },
303
- { deep: true, immediate: true }
303
+ { deep: true, immediate: true },
304
304
  );
305
305
 
306
306
  // 校验
@@ -359,7 +359,7 @@
359
359
  state.error = { tips: props.tips, ontips: props.tips ? 'show' : '', verify: '', co: '' };
360
360
  }
361
361
  },
362
- { deep: true, immediate: true }
362
+ { deep: true, immediate: true },
363
363
  );
364
364
  </script>
365
365
  <style lang="scss" scoped>
@@ -92,11 +92,11 @@
92
92
  suffix: () => [],
93
93
  active: () => ({ class: 'co-main' }),
94
94
  optional: 'all',
95
- multiple: false
95
+ multiple: false,
96
96
  });
97
97
 
98
98
  const state: any = reactive({
99
- value: ''
99
+ value: '',
100
100
  });
101
101
  watch(
102
102
  () => props.modelValue,
@@ -105,7 +105,7 @@
105
105
  state.value = value;
106
106
  }
107
107
  },
108
- { deep: true, immediate: true }
108
+ { deep: true, immediate: true },
109
109
  );
110
110
  watch(
111
111
  () => state.value,
@@ -114,7 +114,7 @@
114
114
  emits('update:modelValue', value);
115
115
  }
116
116
  },
117
- { deep: true, immediate: true }
117
+ { deep: true, immediate: true },
118
118
  );
119
119
 
120
120
  // 事件处理
@@ -3,6 +3,6 @@ import Tree from './Tree.vue';
3
3
  import Calendar from './Calendar.vue';
4
4
  import PhotoEditor from './PhotoEditor.vue';
5
5
  import TreeView from './TreeView.vue';
6
- import ChartView from './ChartView.vue';
6
+ // import ChartView from './ChartView.vue';
7
7
 
8
- export { Image, Tree, Calendar, PhotoEditor, TreeView, ChartView };
8
+ export { Image, Tree, Calendar, PhotoEditor, TreeView };
@@ -101,49 +101,49 @@
101
101
  // 提示文案
102
102
  tips: {
103
103
  type: String,
104
- default: ''
104
+ default: '',
105
105
  },
106
106
  placeholder: {
107
107
  type: String,
108
- default: ''
108
+ default: '',
109
109
  },
110
110
  options: {
111
111
  type: Array as () => any[],
112
- default: () => []
112
+ default: () => [],
113
113
  },
114
114
  ui: {
115
115
  type: Object,
116
- default: () => ({ sz: 'm' })
116
+ default: () => ({ sz: 'm' }),
117
117
  },
118
118
  modelValue: {
119
119
  type: [String, Number, Array as () => any[]],
120
- default: ''
120
+ default: '',
121
121
  },
122
122
  tools: {
123
123
  type: Boolean,
124
- default: true
124
+ default: true,
125
125
  },
126
126
  spare: {
127
127
  type: String,
128
- default: '当前没有可选项'
128
+ default: '当前没有可选项',
129
129
  },
130
130
  multiple: {
131
131
  type: Boolean,
132
- default: false
132
+ default: false,
133
133
  },
134
134
  // 单选时生效,当为true时选中任何一级节点都生效
135
135
  changeOnSelect: {
136
136
  type: Boolean,
137
- default: false
137
+ default: false,
138
138
  },
139
139
  readonly: {
140
140
  type: Boolean,
141
- default: false
141
+ default: false,
142
142
  },
143
143
  disabled: {
144
144
  type: Boolean,
145
- default: false
146
- }
145
+ default: false,
146
+ },
147
147
  });
148
148
 
149
149
  const emit = defineEmits(['update:modelValue']);
@@ -156,7 +156,7 @@
156
156
  flatOpts: [], // 拉平的数据
157
157
  selectd: { label: '', value: '' },
158
158
  transSelected: { label: '', value: [] }, // 单选选中节点 - 单选过渡节点(记录选中的级联节点)
159
- checkAll: false //全选
159
+ checkAll: false, //全选
160
160
  });
161
161
 
162
162
  // modelValue与input组件的v-model绑定属性重复,会造成覆盖问题。需要删掉
@@ -372,7 +372,7 @@
372
372
  } else {
373
373
  state.selectd = {
374
374
  label: '',
375
- value: props.multiple ? [] : ''
375
+ value: props.multiple ? [] : '',
376
376
  };
377
377
  handleCheck(true);
378
378
  }
@@ -382,7 +382,7 @@
382
382
  const remove = () => {
383
383
  state.selectd = {
384
384
  label: '',
385
- value: props.multiple ? [] : ''
385
+ value: props.multiple ? [] : '',
386
386
  };
387
387
  if (props.multiple) {
388
388
  handleCheck(true);
@@ -390,7 +390,7 @@
390
390
  } else {
391
391
  state.transSelected = {
392
392
  label: '',
393
- value: []
393
+ value: [],
394
394
  };
395
395
  }
396
396
  ifollow.value.cancel();
@@ -405,7 +405,7 @@
405
405
  () => {
406
406
  init();
407
407
  },
408
- { deep: true }
408
+ { deep: true },
409
409
  );
410
410
 
411
411
  watch(
@@ -423,13 +423,13 @@
423
423
  emit('update:modelValue', state.selectd.value);
424
424
  }
425
425
  },
426
- { deep: true }
426
+ { deep: true },
427
427
  );
428
428
 
429
429
  defineExpose({
430
430
  select,
431
431
  remove,
432
- cancel
432
+ cancel,
433
433
  });
434
434
  </script>
435
435
  . .
@@ -0,0 +1,64 @@
1
+ <template>
2
+ <form class="m-sm-sub">
3
+ <label v-for="(item, idx) in state.lists" :key="idx" :ui-form="`${theme} type:checkbox${item.disabled ? ' disabled' : ''}`">
4
+ <input v-model="item.__checked" type="checkbox" :disabled="item.disabled" />
5
+ <slot>
6
+ <span>{{ item.label }}</span>
7
+ </slot>
8
+ </label>
9
+ </form>
10
+ </template>
11
+ <script setup lang="ts">
12
+ import { reactive, watch } from 'vue';
13
+
14
+ // 定义类型
15
+ interface OptionsTypes {
16
+ label: string;
17
+ value: any;
18
+ disabled?: boolean;
19
+ }
20
+ interface Props {
21
+ modelValue: any[];
22
+ options: OptionsTypes[];
23
+ theme?: string;
24
+ }
25
+ // 外部入参
26
+ const props = withDefaults(defineProps<Props>(), {
27
+ theme: '@a',
28
+ modelValue: () => [],
29
+ options: () => [],
30
+ });
31
+
32
+ // 定义事件
33
+ const emits = defineEmits(['update:modelValue']);
34
+
35
+ // 内部数据
36
+ const state: any = reactive({
37
+ lists: [],
38
+ });
39
+
40
+ // 监听数据
41
+ watch(
42
+ [() => props.options, () => props.modelValue],
43
+ ([options, value]) => {
44
+ const lists = options?.map((item) => ({ ...item, __checked: value?.includes(item.value) }));
45
+ // 只有在内容变化时才更新
46
+ if (JSON.stringify(state.lists) !== JSON.stringify(lists)) {
47
+ state.lists = lists;
48
+ }
49
+ },
50
+ {
51
+ immediate: true,
52
+ },
53
+ );
54
+ watch(
55
+ () => state.lists,
56
+ (val) => {
57
+ const value = val.filter((item: any) => item.__checked).map((item: any) => item.value);
58
+ emits('update:modelValue', value);
59
+ },
60
+ {
61
+ deep: true,
62
+ },
63
+ );
64
+ </script>