@a2simcode/ui 0.0.222 → 0.0.224

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.
@@ -0,0 +1,378 @@
1
+ <template>
2
+ <div class="demo-form-view-table">
3
+ <j-form ref="formRef" :schema="schema" :config="formConfig" />
4
+ <div style="margin-top: 16px; text-align: right">
5
+ <j-button type="primary" label="加载模拟数据" @click="handleLoadMock" />
6
+ <j-button style="margin-left: 8px" label="获取数据" @click="handleGetFormData" />
7
+ </div>
8
+ <div style="margin-top: 16px">
9
+ <pre class="demo-form-view-table__pre">{{ JSON.stringify(formData, null, 2) }}</pre>
10
+ </div>
11
+ </div>
12
+ </template>
13
+
14
+ <script setup lang="ts">
15
+ import { onMounted, reactive, ref } from 'vue'
16
+
17
+ const formRef = ref<any>()
18
+ const formData = ref<Record<string, any>>({})
19
+
20
+ const formConfig = reactive({
21
+ labelWidth: 100,
22
+ labelPosition: 'right',
23
+ size: 'default',
24
+ gutter: 16,
25
+ span: 24,
26
+ })
27
+
28
+ const createId = () => Math.random().toString(36).slice(2, 10)
29
+
30
+ const dataViewOptions = [
31
+ { label: '用户列表视图', value: 'userView' },
32
+ { label: '订单列表视图', value: 'orderView' },
33
+ ]
34
+
35
+ const paramsOptionsMap: Record<string, { label: string; value: string }[]> = {
36
+ userView: [
37
+ { label: '关键字', value: 'keyword' },
38
+ { label: '状态', value: 'status' },
39
+ ],
40
+ orderView: [
41
+ { label: '订单号', value: 'orderNo' },
42
+ { label: '客户名称', value: 'customerName' },
43
+ ],
44
+ }
45
+
46
+ const componentOptions = [
47
+ { label: '输入框', value: 'j-input' },
48
+ { label: '选择器', value: 'j-select' },
49
+ { label: '日期', value: 'j-date' },
50
+ ]
51
+
52
+ const mockData = () => ({
53
+ dataCode: 'userView',
54
+ paramsSetting: [
55
+ { paramId: 'keyword', compId: 'j-input', dValue: '' },
56
+ { paramId: 'status', compId: 'j-select', dValue: 'enabled' },
57
+ ],
58
+ columns: [
59
+ {
60
+ id: createId(),
61
+ name: 'name',
62
+ width: 160,
63
+ align: 'left',
64
+ fixed: 'none',
65
+ hide: false,
66
+ type: 'text',
67
+ dataType: 'options',
68
+ },
69
+ {
70
+ id: createId(),
71
+ name: 'status',
72
+ width: 120,
73
+ align: 'center',
74
+ fixed: 'none',
75
+ hide: false,
76
+ type: 'j-tag',
77
+ dataType: 'options',
78
+ },
79
+ ],
80
+ isPage: true,
81
+ display: true,
82
+ })
83
+
84
+ const schema = [
85
+ {
86
+ type: 'j-collapse',
87
+ config: {
88
+ label: '视图列表配置',
89
+ field: 'viewTableConfig',
90
+ },
91
+ children: [
92
+ {
93
+ config: {
94
+ label: '数据选项',
95
+ active: true,
96
+ },
97
+ children: [
98
+ {
99
+ type: 'j-select',
100
+ config: {
101
+ label: '数据视图',
102
+ field: 'dataCode',
103
+ options: dataViewOptions,
104
+ },
105
+ },
106
+ {
107
+ type: 'j-input-cards',
108
+ config: {
109
+ label: '参数设置',
110
+ field: 'paramsSetting',
111
+ editConfig: {
112
+ isAddBtn: true,
113
+ isRemoveBtn: true,
114
+ addBtnText: '添加参数',
115
+ },
116
+ },
117
+ children: [
118
+ {
119
+ type: 'j-select',
120
+ config: {
121
+ label: '参数',
122
+ field: 'paramId',
123
+ },
124
+ getCompConfig: ({ formData: currentFormData }: any) => ({
125
+ options: paramsOptionsMap[currentFormData?.dataCode] || [],
126
+ }),
127
+ },
128
+ {
129
+ type: 'j-select',
130
+ config: {
131
+ label: '组件',
132
+ field: 'compId',
133
+ options: componentOptions,
134
+ },
135
+ },
136
+ {
137
+ type: 'j-input',
138
+ config: {
139
+ label: '默认值',
140
+ field: 'dValue',
141
+ },
142
+ },
143
+ ],
144
+ },
145
+ ],
146
+ },
147
+ {
148
+ config: {
149
+ label: '列表设置',
150
+ },
151
+ children: [
152
+ {
153
+ type: 'j-layer-form',
154
+ config: {
155
+ label: '列表设置',
156
+ type: 'primary',
157
+ layerLabel: '列表设置',
158
+ layerWidth: 1000,
159
+ layerHeight: 800,
160
+ },
161
+ children: [
162
+ {
163
+ type: 'j-table',
164
+ config: {
165
+ label: '字段列表',
166
+ field: 'columns',
167
+ heightMode: 'auto',
168
+ maxHeight: 520,
169
+ editConfig: {
170
+ isAddBtn: true,
171
+ isRemoveBtn: true,
172
+ addBtnText: '添加字段',
173
+ },
174
+ addRow: (tableData: Record<string, any>[]) => {
175
+ tableData.push({
176
+ id: createId(),
177
+ name: '',
178
+ width: 120,
179
+ align: 'left',
180
+ fixed: 'none',
181
+ hide: false,
182
+ type: 'text',
183
+ dataType: 'options',
184
+ })
185
+ },
186
+ },
187
+ children: [
188
+ {
189
+ type: 'span',
190
+ config: {
191
+ label: 'ID',
192
+ field: 'id',
193
+ width: 120,
194
+ },
195
+ },
196
+ {
197
+ type: 'j-input',
198
+ config: {
199
+ label: '字段名',
200
+ field: 'name',
201
+ minWidth: 160,
202
+ },
203
+ },
204
+ {
205
+ type: 'j-number',
206
+ config: {
207
+ label: '宽度',
208
+ field: 'width',
209
+ min: 100,
210
+ width: 110,
211
+ },
212
+ },
213
+ {
214
+ type: 'j-select',
215
+ config: {
216
+ label: '对齐方式',
217
+ field: 'align',
218
+ width: 110,
219
+ options: [
220
+ { label: '左对齐', value: 'left' },
221
+ { label: '居中', value: 'center' },
222
+ { label: '右对齐', value: 'right' },
223
+ ],
224
+ },
225
+ },
226
+ {
227
+ type: 'j-select',
228
+ config: {
229
+ label: '固定',
230
+ field: 'fixed',
231
+ width: 110,
232
+ options: [
233
+ { label: '左固定', value: 'left' },
234
+ { label: '右固定', value: 'right' },
235
+ { label: '不固定', value: 'none' },
236
+ ],
237
+ },
238
+ },
239
+ {
240
+ type: 'j-switch',
241
+ config: {
242
+ label: '隐藏',
243
+ field: 'hide',
244
+ width: 80,
245
+ activeValue: true,
246
+ inactiveValue: false,
247
+ },
248
+ },
249
+ {
250
+ type: 'j-layer-form',
251
+ config: {
252
+ label: '设置',
253
+ field: 'more',
254
+ width: 90,
255
+ align: 'center',
256
+ buttonLabel: '设置',
257
+ layerLabel: '字段设置',
258
+ layerWidth: 560,
259
+ layerHeight: 260,
260
+ formConfig: {
261
+ labelWidth: 80,
262
+ labelPosition: 'right',
263
+ size: 'default',
264
+ gutter: 16,
265
+ span: 12,
266
+ },
267
+ },
268
+ children: [
269
+ {
270
+ id: 'type',
271
+ type: 'j-select',
272
+ config: {
273
+ label: '类型',
274
+ options: [
275
+ { label: '文本', value: 'text' },
276
+ { label: '标签', value: 'j-tag' },
277
+ { label: '开关', value: 'j-switch' },
278
+ { label: '评分', value: 'j-rate' },
279
+ { label: '滑块', value: 'j-slider' },
280
+ { label: '图标', value: 'j-icon' },
281
+ ],
282
+ },
283
+ },
284
+ {
285
+ id: 'dataType',
286
+ type: 'j-select',
287
+ config: {
288
+ label: '数据类型',
289
+ options: [
290
+ { label: '静态', value: 'options' },
291
+ { label: '字典', value: 'dataItem' },
292
+ { label: '视图', value: 'dataView' },
293
+ { label: '日期', value: 'date' },
294
+ { label: '日期时间', value: 'dateTime' },
295
+ { label: '人员', value: 'user' },
296
+ { label: '部门', value: 'department' },
297
+ { label: '公司', value: 'company' },
298
+ ],
299
+ },
300
+ },
301
+ ],
302
+ },
303
+ ],
304
+ },
305
+ ],
306
+ },
307
+ ],
308
+ },
309
+ {
310
+ config: {
311
+ label: '更多属性',
312
+ },
313
+ children: [
314
+ {
315
+ type: 'j-switch',
316
+ config: {
317
+ label: '分页设置',
318
+ field: 'isPage',
319
+ activeValue: true,
320
+ inactiveValue: false,
321
+ },
322
+ },
323
+ ],
324
+ },
325
+ {
326
+ config: {
327
+ label: '状态属性',
328
+ },
329
+ children: [
330
+ {
331
+ type: 'j-switch',
332
+ config: {
333
+ label: '可见',
334
+ field: 'display',
335
+ activeValue: true,
336
+ inactiveValue: false,
337
+ },
338
+ },
339
+ ],
340
+ },
341
+ ],
342
+ },
343
+ ]
344
+
345
+ const syncFormData = () => {
346
+ formData.value = formRef.value?.getFormData?.() || {}
347
+ }
348
+
349
+ const handleLoadMock = () => {
350
+ formRef.value?.setFormData?.(mockData())
351
+ syncFormData()
352
+ }
353
+
354
+ const handleGetFormData = () => {
355
+ syncFormData()
356
+ }
357
+
358
+ onMounted(() => {
359
+ handleLoadMock()
360
+ })
361
+ </script>
362
+
363
+ <style scoped>
364
+ .demo-form-view-table {
365
+ border: 1px solid var(--el-border-color-lighter);
366
+ padding: 16px;
367
+ border-radius: 4px;
368
+ }
369
+
370
+ .demo-form-view-table__pre {
371
+ margin: 0;
372
+ padding: 12px;
373
+ background: #f7f8fa;
374
+ border-radius: 4px;
375
+ overflow: auto;
376
+ max-height: 240px;
377
+ }
378
+ </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@a2simcode/ui",
3
- "version": "0.0.222",
3
+ "version": "0.0.224",
4
4
  "description": "A Vue 3 UI Component Library",
5
5
  "type": "module",
6
6
  "main": "./dist/simcode-ui.umd.js",