@vue-ui-kit/ant 1.1.2 → 1.3.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.
@@ -1,4 +1,4 @@
1
- import { RenderFormParams, RenderOptions, RenderTableParams } from '#/antProxy'
1
+ import { RenderFormParams, RenderOptions, RenderTableParams } from '#/antProxy';
2
2
  import {
3
3
  Button,
4
4
  Dropdown,
@@ -20,13 +20,13 @@ import {
20
20
  Textarea,
21
21
  TimePicker,
22
22
  TreeSelect,
23
- } from 'ant-design-vue'
24
- import { set, isFunction, merge, omit } from 'lodash-es'
25
- import { ButtonProps } from 'ant-design-vue/lib/button'
26
- import { noValue, valued } from '@/utils/is'
27
- import TableInput from '@/renders/TableInput.vue'
28
- import Icon from '@/renders/Icon'
29
- import { computed } from 'vue'
23
+ } from 'ant-design-vue';
24
+ import { set, isFunction, merge, omit } from 'lodash-es';
25
+ import { ButtonProps } from 'ant-design-vue/lib/button';
26
+ import { noValue, valued } from '@/utils/is';
27
+ import TableInput from '@/renders/TableInput.vue';
28
+ import Icon from '@/renders/Icon';
29
+ import { computed } from 'vue';
30
30
 
31
31
  interface BtnOptions extends ButtonProps {
32
32
  content?: string;
@@ -84,7 +84,7 @@ const antDefaultProps = {
84
84
  filterOption: (input: string, option: IOption) =>
85
85
  option.label && option.label.toLowerCase().includes(input.toLowerCase()),
86
86
  },
87
- }
87
+ };
88
88
  const defaultProps: Recordable = {
89
89
  PercentInput: {
90
90
  controls: false,
@@ -93,9 +93,9 @@ const defaultProps: Recordable = {
93
93
  addonAfter: '%',
94
94
  },
95
95
  autoComplete: {
96
- inputProps: {}
97
- }
98
- }
96
+ inputProps: {},
97
+ },
98
+ };
99
99
  const componentsMap = {
100
100
  $input: Input,
101
101
  AInput: Input,
@@ -122,16 +122,16 @@ const componentsMap = {
122
122
  $time: TimePicker,
123
123
  ATimePicker: TimePicker,
124
124
  ATreeSelect: TreeSelect,
125
- }
125
+ };
126
126
  const renderBasic = (name: string) => {
127
- const DynamicComponent = componentsMap[name]
127
+ const DynamicComponent = componentsMap[name];
128
128
  return {
129
- renderItemContent (
129
+ renderItemContent(
130
130
  { props = {}, attrs = {}, events = {}, defaultValue }: RenderOptions,
131
131
  { data, field }: RenderFormParams,
132
132
  ) {
133
133
  if (valued(defaultValue) && valued(field) && noValue(data[field!])) {
134
- data[field!] = defaultValue
134
+ data[field!] = defaultValue;
135
135
  }
136
136
  return field ? (
137
137
  <DynamicComponent
@@ -140,19 +140,19 @@ const renderBasic = (name: string) => {
140
140
  {...attrs}
141
141
  {...merge({}, antDefaultProps[name], props)}
142
142
  onChange={(...arg) => {
143
- events.change?.({ data, field }, ...arg)
143
+ events.change?.({ data, field }, ...arg);
144
144
  }}
145
145
  />
146
146
  ) : (
147
147
  <DynamicComponent is={name} {...props} />
148
- )
148
+ );
149
149
  },
150
- renderDefault (
150
+ renderDefault(
151
151
  { props = antDefaultProps[name] ?? {}, attrs = {}, events = {}, defaultValue }: RenderOptions,
152
152
  { data, row, field }: RenderTableParams,
153
153
  ) {
154
154
  if (valued(defaultValue) && valued(field) && noValue(row[field!])) {
155
- row[field!] = defaultValue
155
+ row[field!] = defaultValue;
156
156
  }
157
157
  return field ? (
158
158
  <DynamicComponent
@@ -161,15 +161,15 @@ const renderBasic = (name: string) => {
161
161
  {...attrs}
162
162
  {...merge({}, antDefaultProps[name], props)}
163
163
  onChange={(...arg) => {
164
- events.change?.({ data, row, field }, ...arg)
164
+ events.change?.({ data, row, field }, ...arg);
165
165
  }}
166
166
  />
167
167
  ) : (
168
168
  <DynamicComponent is={name} {...props} />
169
- )
169
+ );
170
170
  },
171
- }
172
- }
171
+ };
172
+ };
173
173
 
174
174
  const renderBtn = (btnOpt: BtnOptions, params: RenderTableParams) =>
175
175
  btnOpt.dropdowns && btnOpt.dropdowns.length > 0 ? (
@@ -185,7 +185,7 @@ const renderBtn = (btnOpt: BtnOptions, params: RenderTableParams) =>
185
185
  'clickEvt',
186
186
  'dropdowns',
187
187
  ])}
188
- icon={btnOpt.icon ? <Icon icon={btnOpt.icon}/> : null}
188
+ icon={btnOpt.icon ? <Icon icon={btnOpt.icon} /> : null}
189
189
  >
190
190
  {btnOpt.content || (btnOpt?.getContent?.(params) ?? '')}
191
191
  </Button>
@@ -208,21 +208,21 @@ const renderBtn = (btnOpt: BtnOptions, params: RenderTableParams) =>
208
208
  'clickEvt',
209
209
  'dropdowns',
210
210
  ])}
211
- icon={btnOpt.icon ? <Icon icon={btnOpt.icon}/> : null}
211
+ icon={btnOpt.icon ? <Icon icon={btnOpt.icon} /> : null}
212
212
  onClick={() => {
213
213
  if (btnOpt?.clickEvt) {
214
- btnOpt.clickEvt(params)
214
+ btnOpt.clickEvt(params);
215
215
  }
216
216
  }}
217
217
  >
218
218
  {btnOpt.content || (btnOpt?.getContent?.(params) ?? '')}
219
219
  </Button>
220
- )
220
+ );
221
221
  const renders = {
222
222
  ...Object.fromEntries(Object.keys(componentsMap).map((name) => [name, renderBasic(name)])),
223
223
  //简单按钮
224
224
  $button: {
225
- renderItemContent (
225
+ renderItemContent(
226
226
  { props = {}, events = {} }: RenderOptions,
227
227
  { data, field }: RenderFormParams,
228
228
  defaultHandler: {
@@ -232,19 +232,19 @@ const renders = {
232
232
  return (
233
233
  <Button
234
234
  {...omit(props, ['content'])}
235
- icon={props.icon ? <Icon icon={props.icon}/> : null}
235
+ icon={props.icon ? <Icon icon={props.icon} /> : null}
236
236
  onClick={() => {
237
- events.click?.({ data, field })
237
+ events.click?.({ data, field });
238
238
  if (props.htmlType === 'reset' && defaultHandler?.reset) {
239
- defaultHandler.reset({ data, field })
239
+ defaultHandler.reset({ data, field });
240
240
  }
241
241
  }}
242
242
  >
243
243
  {props.content}
244
244
  </Button>
245
- )
245
+ );
246
246
  },
247
- renderDefault (
247
+ renderDefault(
248
248
  { props = {}, events = {} }: RenderOptions,
249
249
  { row, field }: RenderTableParams,
250
250
  defaultHandler: {
@@ -254,25 +254,25 @@ const renders = {
254
254
  return (
255
255
  <Button
256
256
  {...omit(props, ['content'])}
257
- icon={props.icon ? <Icon icon={props.icon}/> : null}
257
+ icon={props.icon ? <Icon icon={props.icon} /> : null}
258
258
  onClick={() => {
259
- events.click?.({ row, field })
259
+ events.click?.({ row, field });
260
260
  if (props.htmlType === 'reset' && defaultHandler?.reset) {
261
- defaultHandler.reset({ row, field })
261
+ defaultHandler.reset({ row, field });
262
262
  }
263
263
  if (props.htmlType === 'pick' && defaultHandler?.pick) {
264
- defaultHandler.pick({ row, field })
264
+ defaultHandler.pick({ row, field });
265
265
  }
266
266
  }}
267
267
  >
268
268
  {props.content}
269
269
  </Button>
270
- )
270
+ );
271
271
  },
272
272
  },
273
273
  // 简单按钮组
274
274
  $buttons: {
275
- renderItemContent (
275
+ renderItemContent(
276
276
  { props = {}, children = [] }: RenderOptions,
277
277
  { data, field }: RenderFormParams,
278
278
  defaultHandler: {
@@ -284,11 +284,11 @@ const renders = {
284
284
  {children.map((m) => (
285
285
  <Button
286
286
  {...omit(Object.assign(props, m.props), ['content'])}
287
- icon={m.props.icon ? <Icon icon={m.props.icon}/> : null}
287
+ icon={m.props.icon ? <Icon icon={m.props.icon} /> : null}
288
288
  onClick={() => {
289
- m.events?.click?.({ data, field })
289
+ m.events?.click?.({ data, field });
290
290
  if (m.props.htmlType === 'reset' && defaultHandler?.reset) {
291
- defaultHandler.reset({ data, field })
291
+ defaultHandler.reset({ data, field });
292
292
  }
293
293
  }}
294
294
  >
@@ -296,9 +296,9 @@ const renders = {
296
296
  </Button>
297
297
  ))}
298
298
  </span>
299
- )
299
+ );
300
300
  },
301
- renderDefault (
301
+ renderDefault(
302
302
  { props = {}, children = [] }: RenderOptions,
303
303
  { data, row, field }: RenderTableParams,
304
304
  ) {
@@ -307,67 +307,73 @@ const renders = {
307
307
  {children.map((m) => (
308
308
  <Button
309
309
  {...omit(Object.assign(props, m.props), ['content'])}
310
- icon={m.props.icon ? <Icon icon={m.props.icon}/> : null}
310
+ icon={m.props.icon ? <Icon icon={m.props.icon} /> : null}
311
311
  onClick={() => {
312
- m.events?.click?.({ data, row, field })
312
+ m.events?.click?.({ data, row, field });
313
313
  }}
314
314
  >
315
315
  {m.props.content}
316
316
  </Button>
317
317
  ))}
318
318
  </span>
319
- )
319
+ );
320
320
  },
321
321
  },
322
322
  ButtonTree: {
323
- renderDefault ({ children = [], props = {} as Recordable }, params: RenderTableParams) {
323
+ renderDefault({ children = [], props = {} as Recordable }, params: RenderTableParams) {
324
324
  return (
325
325
  <span class={props.noGap ? 'align-no-gap-box' : 'align-gap-box'}>
326
326
  {(children as BtnOptions[]).map((item) => renderBtn(item, params)) ?? []}
327
327
  </span>
328
- )
328
+ );
329
329
  },
330
330
  },
331
331
  $radio: {
332
- renderItemContent ({ props = {}, options }: RenderOptions, { data, field }: RenderFormParams) {
332
+ renderItemContent({ props = {}, options }: RenderOptions, { data, field }: RenderFormParams) {
333
333
  return valued(field) ? (
334
334
  <RadioGroup
335
335
  v-model:value={data[field!]}
336
336
  {...props}
337
337
  options={props.options ?? options ?? []}
338
338
  />
339
- ) : null
339
+ ) : null;
340
340
  },
341
- renderDefault ({ props = {}, options }: RenderOptions, { row, field }: RenderTableParams) {
341
+ renderDefault({ props = {}, options }: RenderOptions, { row, field }: RenderTableParams) {
342
342
  return valued(field) ? (
343
343
  <RadioGroup
344
344
  v-model:value={row[field!]}
345
345
  {...props}
346
346
  options={props.options ?? options ?? []}
347
347
  />
348
- ) : null
348
+ ) : null;
349
349
  },
350
350
  },
351
351
  $autoComplete: {
352
- renderItemContent ({ props = {}, events = {} }: RenderOptions, {
353
- data,
354
- field
355
- }: RenderFormParams) {
356
- return (valued(field) ?
357
- <AutoComplete v-model:value={data[field!]} {...props}
358
- onChange={(...arg) => {
359
- events.change?.({ data, field }, ...arg)
360
- }}>
352
+ renderItemContent(
353
+ { props = {}, events = {} }: RenderOptions,
354
+ { data, field }: RenderFormParams,
355
+ ) {
356
+ return valued(field) ? (
357
+ <AutoComplete
358
+ v-model:value={data[field!]}
359
+ {...props}
360
+ onChange={(...arg) => {
361
+ events.change?.({ data, field }, ...arg);
362
+ }}
363
+ >
361
364
  {{
362
- default: () =>
363
- <a-input {...(Object.assign({}, defaultProps.autoComplete.inputProps, props.inputProps ?? {}))}/>
365
+ default: () => (
366
+ <a-input
367
+ {...Object.assign({}, defaultProps.autoComplete.inputProps, props.inputProps ?? {})}
368
+ />
369
+ ),
364
370
  }}
365
-
366
- </AutoComplete> : null)
367
- }
371
+ </AutoComplete>
372
+ ) : null;
373
+ },
368
374
  },
369
375
  $switch: {
370
- renderItemContent (
376
+ renderItemContent(
371
377
  { props = {}, events = {} }: RenderOptions,
372
378
  { data, field }: RenderFormParams,
373
379
  ) {
@@ -376,14 +382,14 @@ const renders = {
376
382
  v-model:checked={data[field!]}
377
383
  {...props}
378
384
  onChange={(...arg) => {
379
- events.change?.({ data, field }, ...arg)
385
+ events.change?.({ data, field }, ...arg);
380
386
  }}
381
387
  />
382
- ) : null
388
+ ) : null;
383
389
  },
384
390
  },
385
391
  $checkbox: {
386
- renderItemContent (
392
+ renderItemContent(
387
393
  { props = {}, options, events = {} }: RenderOptions,
388
394
  { data, field }: RenderFormParams,
389
395
  ) {
@@ -393,40 +399,40 @@ const renders = {
393
399
  {...props}
394
400
  options={props.options ?? options ?? []}
395
401
  onChange={(...arg) => {
396
- events.change?.({ data, field }, ...arg)
402
+ events.change?.({ data, field }, ...arg);
397
403
  }}
398
404
  />
399
- ) : null
405
+ ) : null;
400
406
  },
401
- renderDefault ({ props = {}, options }: RenderOptions, { row, field }: RenderTableParams) {
407
+ renderDefault({ props = {}, options }: RenderOptions, { row, field }: RenderTableParams) {
402
408
  return valued(field) ? (
403
409
  <CheckboxGroup
404
410
  v-model:value={row[field!]}
405
411
  {...props}
406
412
  options={props.options ?? options ?? []}
407
413
  />
408
- ) : null
414
+ ) : null;
409
415
  },
410
416
  },
411
417
  $paragraph: {
412
- renderDefault ({ props = {} }: RenderOptions, { row, field }: RenderTableParams) {
418
+ renderDefault({ props = {} }: RenderOptions, { row, field }: RenderTableParams) {
413
419
  const defaultProps = {
414
420
  ellipsis: {
415
421
  expandable: true,
416
422
  rows: 3,
417
423
  },
418
- }
419
- const content = props.getContent?.({ row, field }) ?? (valued(field) ? row[field!] : '')
424
+ };
425
+ const content = props.getContent?.({ row, field }) ?? (valued(field) ? row[field!] : '');
420
426
  return valued(field) ? (
421
427
  <TypographyParagraph
422
428
  {...merge({}, defaultProps, omit(props, ['content', 'getContent']))}
423
429
  content={content}
424
430
  />
425
- ) : null
431
+ ) : null;
426
432
  },
427
433
  },
428
434
  $tableInput: {
429
- renderItemContent (
435
+ renderItemContent(
430
436
  { props = {}, handleTrigger }: RenderOptions,
431
437
  { data, field }: RenderFormParams,
432
438
  ) {
@@ -435,28 +441,28 @@ const renders = {
435
441
  v-model={data[field!]}
436
442
  onTrigger={() => {
437
443
  if (handleTrigger && isFunction(handleTrigger)) {
438
- handleTrigger(props.cusFields ?? field)
444
+ handleTrigger(props.cusFields ?? field);
439
445
  }
440
446
  }}
441
447
  editColumns={props.editColumns ?? []}
442
448
  tableConfig={props.tableConfig ?? {}}
443
449
  />
444
- ) : null
450
+ ) : null;
445
451
  },
446
452
  },
447
453
  PercentInput: {
448
- renderItemContent (
454
+ renderItemContent(
449
455
  { props = {}, attrs = {} }: RenderOptions,
450
456
  { data, field }: RenderFormParams,
451
457
  ) {
452
- const rate = props.parse ? 100 : 1
458
+ const rate = props.parse ? 100 : 1;
453
459
  if (valued(field)) {
454
460
  const percentage = computed({
455
461
  get: () => (data[field!] ?? 0) * rate,
456
462
  set: (val) => {
457
- data[field!] = (val ?? 0) / rate
463
+ data[field!] = (val ?? 0) / rate;
458
464
  },
459
- })
465
+ });
460
466
  return (
461
467
  <div class="flex items-center">
462
468
  {props.info ? <span class="pr-4">{props.info}</span> : null}
@@ -467,20 +473,20 @@ const renders = {
467
473
  {...merge({}, defaultProps.PercentInput, omit(props, ['info']))}
468
474
  />
469
475
  </div>
470
- )
476
+ );
471
477
  } else {
472
- return null
478
+ return null;
473
479
  }
474
480
  },
475
- renderDefault ({ props = {}, attrs = {} }: RenderOptions, { row, field }: RenderTableParams) {
476
- const rate = props.parse ? 100 : 1
481
+ renderDefault({ props = {}, attrs = {} }: RenderOptions, { row, field }: RenderTableParams) {
482
+ const rate = props.parse ? 100 : 1;
477
483
  if (valued(field)) {
478
484
  const percentage = computed({
479
485
  get: () => (row[field!] ?? 0) * rate,
480
486
  set: (val) => {
481
- set(row, field!, (val ?? 0) / rate)
487
+ set(row, field!, (val ?? 0) / rate);
482
488
  },
483
- })
489
+ });
484
490
  return [
485
491
  props.info ? <span class="pr-4">{props.info}</span> : null,
486
492
  <a-input-number
@@ -489,21 +495,21 @@ const renders = {
489
495
  v-model:value={percentage.value}
490
496
  {...merge({}, defaultProps.PercentInput, omit(props, ['info']))}
491
497
  />,
492
- ]
498
+ ];
493
499
  } else {
494
- return null
500
+ return null;
495
501
  }
496
502
  },
497
503
  },
498
504
  TreeSelect: {
499
- renderItemContent ({ props = {} }: RenderOptions, { data, field }: RenderFormParams) {
500
- return valued(field) ? <TreeSelect v-model:value={data[field!]} {...props} /> : null
505
+ renderItemContent({ props = {} }: RenderOptions, { data, field }: RenderFormParams) {
506
+ return valued(field) ? <TreeSelect v-model:value={data[field!]} {...props} /> : null;
501
507
  },
502
- renderDefault ({ props = {} }: RenderOptions, { row, field }: RenderTableParams) {
503
- return valued(field) ? <TreeSelect v-model:value={row[field!]} {...props} /> : null
508
+ renderDefault({ props = {} }: RenderOptions, { row, field }: RenderTableParams) {
509
+ return valued(field) ? <TreeSelect v-model:value={row[field!]} {...props} /> : null;
504
510
  },
505
511
  },
506
- }
512
+ };
507
513
  export const addRender = (
508
514
  name: string,
509
515
  {
@@ -523,14 +529,14 @@ export const addRender = (
523
529
  },
524
530
  ) => {
525
531
  if (renders.hasOwnProperty(name)) {
526
- console.warn(`render ${name} already exists`)
532
+ console.warn(`render ${name} already exists`);
527
533
  }
528
534
  renders[name] = {
529
535
  renderItemContent,
530
536
  renderDefault,
531
- }
532
- }
537
+ };
538
+ };
533
539
  export default {
534
540
  renders,
535
541
  addRender,
536
- }
542
+ };
@@ -11,6 +11,20 @@
11
11
  width: 100%;
12
12
  }
13
13
 
14
+ .cursor-pointer {
15
+ cursor: pointer;
16
+ }
17
+
18
+ .py-4x {
19
+ padding-top: 4px;
20
+ padding-bottom: 4px;
21
+ }
22
+
23
+ .px-2x {
24
+ padding-left: 2px;
25
+ padding-right: 2px;
26
+ }
27
+
14
28
  .h-0 {
15
29
  height: 0;
16
30
  }
@@ -90,6 +104,18 @@
90
104
  .ant-form-item {
91
105
  margin-bottom: 0;
92
106
 
107
+ &.p-required {
108
+ .ant-form-item-label > label:before {
109
+ display: inline-block;
110
+ margin-inline-end: 4px;
111
+ color: #ff4d4f;
112
+ font-size: 14px;
113
+ font-family: SimSun, sans-serif;
114
+ line-height: 1;
115
+ content: '*';
116
+ }
117
+ }
118
+
93
119
  .ant-form-item-label {
94
120
  display: flex;
95
121
  align-items: start;
@@ -165,6 +191,12 @@
165
191
  }
166
192
  }
167
193
  }
194
+
195
+ .ant-pagination-options {
196
+ .ant-select {
197
+ width: 100px;
198
+ }
199
+ }
168
200
  }
169
201
 
170
202
  //endregion