af-mobile-client-vue3 1.0.74 → 1.0.76
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.
- package/package.json +108 -108
- package/src/components/core/XSelect/index.vue +2 -0
- package/src/components/data/XBadge/index.vue +87 -85
- package/src/components/data/XCellList/XCellList.md +275 -275
- package/src/components/data/XCellList/index.vue +5 -0
- package/src/components/data/XCellListFilter/index.vue +3 -3
- package/src/components/data/XFormGroup/index.vue +1 -1
- package/src/components/data/XFormItem/index.vue +181 -24
- package/src/router/routes.ts +1 -1
- package/src/utils/dictUtil.ts +52 -51
- package/src/views/component/XCellListView/index.vue +35 -26
- package/src/views/component/XFormGroupView/index.vue +4 -1
- package/tsconfig.json +43 -43
- package/src/views/component/test/index.vue +0 -52
|
@@ -100,6 +100,12 @@ const showPicker = ref(false)
|
|
|
100
100
|
const showDatePicker = ref(false)
|
|
101
101
|
const showTimePicker = ref(false)
|
|
102
102
|
const showArea = ref(false)
|
|
103
|
+
const errorMessage = ref('')
|
|
104
|
+
const formInputDefaultValue = ref('')
|
|
105
|
+
const queryInputDefaultValue = ref('')
|
|
106
|
+
const formSelectDefaultValue = ref([])
|
|
107
|
+
const querySelectDefaultValue = ref([])
|
|
108
|
+
// eslint-disable-next-line ts/no-use-before-define
|
|
103
109
|
const currUser = computed(() => userState.f.resources.id)
|
|
104
110
|
// 是否展示当前项
|
|
105
111
|
const showItem = ref(true)
|
|
@@ -133,7 +139,7 @@ const localValue = computed({
|
|
|
133
139
|
// if (props.modelValue !== undefined) {
|
|
134
140
|
// return props.modelValue
|
|
135
141
|
// }
|
|
136
|
-
switch (
|
|
142
|
+
switch (attr.type) {
|
|
137
143
|
case 'switch':
|
|
138
144
|
return props.modelValue !== undefined ? props.modelValue : false
|
|
139
145
|
case 'checkbox':
|
|
@@ -143,7 +149,14 @@ const localValue = computed({
|
|
|
143
149
|
case 'datePicker':
|
|
144
150
|
case 'timePicker':
|
|
145
151
|
case 'select':
|
|
146
|
-
|
|
152
|
+
if (mode === '查询') {
|
|
153
|
+
// console.log(querySelectDefaultValue.value)
|
|
154
|
+
return props.modelValue !== undefined ? props.modelValue : querySelectDefaultValue.value
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
// console.log(formSelectDefaultValue.value)
|
|
158
|
+
return props.modelValue !== undefined ? props.modelValue : formSelectDefaultValue.value
|
|
159
|
+
}
|
|
147
160
|
case 'radio':
|
|
148
161
|
case 'rate':
|
|
149
162
|
case 'slider':
|
|
@@ -152,7 +165,10 @@ const localValue = computed({
|
|
|
152
165
|
case 'calendar':
|
|
153
166
|
case 'textarea':
|
|
154
167
|
case 'input':
|
|
155
|
-
|
|
168
|
+
if (mode === '查询')
|
|
169
|
+
return props.modelValue !== undefined ? props.modelValue : queryInputDefaultValue.value
|
|
170
|
+
else
|
|
171
|
+
return props.modelValue !== undefined ? props.modelValue : formInputDefaultValue.value
|
|
156
172
|
case 'stepper':
|
|
157
173
|
return props.modelValue !== undefined ? props.modelValue : 1
|
|
158
174
|
case 'rangePicker':
|
|
@@ -172,6 +188,126 @@ const localValue = computed({
|
|
|
172
188
|
},
|
|
173
189
|
})
|
|
174
190
|
|
|
191
|
+
// 表单校验的类型校验
|
|
192
|
+
function formTypeCheck(attr, value) {
|
|
193
|
+
switch (attr.rule.type) {
|
|
194
|
+
case 'string':
|
|
195
|
+
if (value.length === 0) {
|
|
196
|
+
errorMessage.value = `${attr.name}必须为有效的字符串`
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
break
|
|
200
|
+
case 'number':
|
|
201
|
+
if (!/^[+-]?(\d+(\.\d*)?|\.\d+)$/.test(value)) {
|
|
202
|
+
errorMessage.value = `${attr.name}必须为数字`
|
|
203
|
+
return
|
|
204
|
+
}
|
|
205
|
+
break
|
|
206
|
+
case 'boolean':
|
|
207
|
+
case 'array':
|
|
208
|
+
case 'regexp':
|
|
209
|
+
if (value) {
|
|
210
|
+
errorMessage.value = ''
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
break
|
|
214
|
+
case 'integer':
|
|
215
|
+
if (!/^-?\d+$/.test(value)) {
|
|
216
|
+
errorMessage.value = `${attr.name}必须为整数`
|
|
217
|
+
return
|
|
218
|
+
}
|
|
219
|
+
break
|
|
220
|
+
case 'float':
|
|
221
|
+
if (!/^-?\d+\.\d+$/.test(value)) {
|
|
222
|
+
errorMessage.value = `${attr.name}必须为小数`
|
|
223
|
+
return
|
|
224
|
+
}
|
|
225
|
+
break
|
|
226
|
+
case 'email':
|
|
227
|
+
if (!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value)) {
|
|
228
|
+
errorMessage.value = `请输入正确的邮箱地址`
|
|
229
|
+
return
|
|
230
|
+
}
|
|
231
|
+
break
|
|
232
|
+
case 'idNumber':
|
|
233
|
+
if (!/^(^\d{15}$|^\d{17}([0-9]|X)$)$/.test(value)) {
|
|
234
|
+
errorMessage.value = `请输入正确的身份证号码`
|
|
235
|
+
return
|
|
236
|
+
}
|
|
237
|
+
break
|
|
238
|
+
case 'userPhone':
|
|
239
|
+
if (!/^1[3-9]\d{9}$/.test(value)) {
|
|
240
|
+
errorMessage.value = `请输入正确的手机号码`
|
|
241
|
+
return
|
|
242
|
+
}
|
|
243
|
+
break
|
|
244
|
+
case 'landlineNumber':
|
|
245
|
+
if (!/^(0\d{2,3}-\d{7,8})$|^(0\d{2,3}\d{7,8})$|^$0\d{2,3}$\s?\d{7,8}$/.test(value)) {
|
|
246
|
+
errorMessage.value = `请输入正确的座机号码`
|
|
247
|
+
return
|
|
248
|
+
}
|
|
249
|
+
break
|
|
250
|
+
case 'greaterThanZero':
|
|
251
|
+
if (!/^(?:[1-9]\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(value)) {
|
|
252
|
+
errorMessage.value = `请输入一个大于0的数字`
|
|
253
|
+
return
|
|
254
|
+
}
|
|
255
|
+
break
|
|
256
|
+
case 'greaterThanOrEqualZero':
|
|
257
|
+
if (!/^(?:\d+|\d*\.\d+)$/.test(value)) {
|
|
258
|
+
errorMessage.value = `请输入一个大于等于0的数字`
|
|
259
|
+
return
|
|
260
|
+
}
|
|
261
|
+
break
|
|
262
|
+
case 'stringLength':
|
|
263
|
+
if (!(value.length >= attr.rule.minLen && value.length < attr.rule.maxLen)) {
|
|
264
|
+
errorMessage.value = `长度必须在${attr.rule.minLen}~${attr.rule.maxLen}之间`
|
|
265
|
+
return
|
|
266
|
+
}
|
|
267
|
+
break
|
|
268
|
+
case 'customJs':
|
|
269
|
+
// eslint-disable-next-line no-case-declarations
|
|
270
|
+
const funcStr = attr.rule.customValidatorFunc
|
|
271
|
+
// 输入的数据是否符合条件
|
|
272
|
+
// eslint-disable-next-line no-case-declarations
|
|
273
|
+
const status = ref(true)
|
|
274
|
+
// 提取函数体部分
|
|
275
|
+
// eslint-disable-next-line no-case-declarations
|
|
276
|
+
const funcBodyMatch = funcStr.match(/function\s*\(.*?\)\s*{([\s\S]*)}/)
|
|
277
|
+
if (!funcBodyMatch)
|
|
278
|
+
throw new Error('自定义校验函数不合法')
|
|
279
|
+
// eslint-disable-next-line no-case-declarations
|
|
280
|
+
const funcBody = funcBodyMatch[1].trim() // 提取函数体
|
|
281
|
+
// 使用 new Function 创建函数
|
|
282
|
+
// eslint-disable-next-line no-new-func,no-case-declarations
|
|
283
|
+
const customValidatorFunc = new Function('rule', 'value', 'callback', 'form', 'attr', 'util', funcBody)
|
|
284
|
+
// 定义 callback 函数
|
|
285
|
+
// eslint-disable-next-line no-case-declarations
|
|
286
|
+
const callback = (error) => {
|
|
287
|
+
if (error) {
|
|
288
|
+
errorMessage.value = `${error}`
|
|
289
|
+
status.value = false // 表示有错误发生
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
// 调用自定义校验函数
|
|
293
|
+
customValidatorFunc(
|
|
294
|
+
attr.rule,
|
|
295
|
+
value,
|
|
296
|
+
callback,
|
|
297
|
+
form,
|
|
298
|
+
attr,
|
|
299
|
+
{}, // util 对象(可以根据需要传递)
|
|
300
|
+
)
|
|
301
|
+
if (!status.value)
|
|
302
|
+
return
|
|
303
|
+
break
|
|
304
|
+
default:
|
|
305
|
+
errorMessage.value = ''
|
|
306
|
+
break
|
|
307
|
+
}
|
|
308
|
+
errorMessage.value = ''
|
|
309
|
+
}
|
|
310
|
+
|
|
175
311
|
onBeforeMount(() => {
|
|
176
312
|
init()
|
|
177
313
|
showFormItemFunc()
|
|
@@ -246,6 +382,26 @@ function init() {
|
|
|
246
382
|
initRadioValue()
|
|
247
383
|
}
|
|
248
384
|
}
|
|
385
|
+
if (attr.type === 'radio' || attr.type === 'rate' || attr.type === 'slider' || attr.type === 'area' || attr.type === 'citySelect' || attr.type === 'calendar' || attr.type === 'textarea' || attr.type === 'input') {
|
|
386
|
+
if (attr.formDefault)
|
|
387
|
+
formInputDefaultValue.value = attr.formDefault
|
|
388
|
+
if (attr.queryFormDefault)
|
|
389
|
+
queryInputDefaultValue.value = attr.queryFormDefault
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
if (attr.type === 'checkbox' || attr.type === 'uploader' || attr.type === 'file' || attr.type === 'image' || attr.type === 'datePicker' || attr.type === 'timePicker' || attr.type === 'select') {
|
|
393
|
+
if (attr.formDefault) {
|
|
394
|
+
if (attr.type === 'checkbox')
|
|
395
|
+
formSelectDefaultValue.value = attr.formDefault
|
|
396
|
+
else
|
|
397
|
+
formSelectDefaultValue.value.push(attr.formDefault)
|
|
398
|
+
}
|
|
399
|
+
if (attr.queryFormDefault) {
|
|
400
|
+
// console.log(querySelectDefaultValue.value)
|
|
401
|
+
querySelectDefaultValue.value.push(attr.queryFormDefault)
|
|
402
|
+
// querySelectDefaultValue.value = attr.queryFormDefault
|
|
403
|
+
}
|
|
404
|
+
}
|
|
249
405
|
}
|
|
250
406
|
|
|
251
407
|
function getDataCallback(res) {
|
|
@@ -361,7 +517,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
361
517
|
v-if="attr.type === 'switch' && showItem"
|
|
362
518
|
name="switch"
|
|
363
519
|
:label="labelData"
|
|
364
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
520
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
365
521
|
>
|
|
366
522
|
<template #input>
|
|
367
523
|
<VanSwitch v-model="localValue" />
|
|
@@ -386,7 +542,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
386
542
|
v-if="attr.showMode === 'checkbox' && mode !== '查询'"
|
|
387
543
|
name="checkboxGroup"
|
|
388
544
|
:label="labelData"
|
|
389
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
545
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
390
546
|
>
|
|
391
547
|
<template #input>
|
|
392
548
|
<van-checkbox-group v-model="localValue as any[]" direction="horizontal" shape="square" :disabled="readonly">
|
|
@@ -400,7 +556,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
400
556
|
v-if="attr.showMode === 'checkbox' && mode === '查询'"
|
|
401
557
|
name="checkboxGroup"
|
|
402
558
|
:label="labelData"
|
|
403
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
559
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
404
560
|
>
|
|
405
561
|
<template #input>
|
|
406
562
|
<XGridDropOption
|
|
@@ -420,7 +576,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
420
576
|
:placeholder="placeholder"
|
|
421
577
|
:columns="option"
|
|
422
578
|
:option="attr.option ? attr.option : columnsField"
|
|
423
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
579
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
424
580
|
/>
|
|
425
581
|
</template>
|
|
426
582
|
|
|
@@ -430,7 +586,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
430
586
|
name="radio"
|
|
431
587
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
432
588
|
:label="labelData"
|
|
433
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
589
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
434
590
|
>
|
|
435
591
|
<template #input>
|
|
436
592
|
<VanRadioGroup v-model="localValue" direction="horizontal" :disabled="readonly">
|
|
@@ -447,7 +603,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
447
603
|
name="radio"
|
|
448
604
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
449
605
|
:label="labelData"
|
|
450
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
606
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
451
607
|
>
|
|
452
608
|
<template #input>
|
|
453
609
|
<XGridDropOption
|
|
@@ -464,7 +620,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
464
620
|
name="stepper"
|
|
465
621
|
:label="labelData"
|
|
466
622
|
:readonly="readonly"
|
|
467
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
623
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
468
624
|
>
|
|
469
625
|
<template #input>
|
|
470
626
|
<VanStepper v-model="(localValue as string)" />
|
|
@@ -477,7 +633,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
477
633
|
name="rate"
|
|
478
634
|
:label="labelData"
|
|
479
635
|
:readonly="readonly"
|
|
480
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
636
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
481
637
|
>
|
|
482
638
|
<template #input>
|
|
483
639
|
<VanRate v-model="(localValue as number)" />
|
|
@@ -490,7 +646,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
490
646
|
name="slider"
|
|
491
647
|
:label="labelData"
|
|
492
648
|
:readonly="readonly"
|
|
493
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
649
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
494
650
|
>
|
|
495
651
|
<template #input>
|
|
496
652
|
<VanSlider v-model="(localValue as number)" />
|
|
@@ -502,7 +658,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
502
658
|
v-if="(attr.type === 'image' || attr.type === 'file') && showItem"
|
|
503
659
|
name="uploader"
|
|
504
660
|
:label="labelData"
|
|
505
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
661
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
506
662
|
>
|
|
507
663
|
<template #input>
|
|
508
664
|
<!-- <van-uploader v-model="localValue" /> -->
|
|
@@ -524,7 +680,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
524
680
|
:label="labelData"
|
|
525
681
|
:readonly="readonly"
|
|
526
682
|
is-link
|
|
527
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
683
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
528
684
|
@click="showPicker = true"
|
|
529
685
|
/>
|
|
530
686
|
<VanPopup v-model:show="showPicker" round position="bottom" teleport="body">
|
|
@@ -550,7 +706,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
550
706
|
name="rangePicker"
|
|
551
707
|
:label="labelData"
|
|
552
708
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
553
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
709
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
554
710
|
@click="calendarShow = true"
|
|
555
711
|
/>
|
|
556
712
|
<VanCalendar
|
|
@@ -571,7 +727,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
571
727
|
readonly
|
|
572
728
|
:is-link="true"
|
|
573
729
|
:placeholder="placeholder"
|
|
574
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
730
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
575
731
|
@click="readonly ? null : showDatePicker = true"
|
|
576
732
|
/>
|
|
577
733
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body">
|
|
@@ -596,7 +752,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
596
752
|
readonly
|
|
597
753
|
:is-link="true"
|
|
598
754
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
599
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
755
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
600
756
|
@click="showDatePicker = true"
|
|
601
757
|
/>
|
|
602
758
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body">
|
|
@@ -622,7 +778,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
622
778
|
readonly
|
|
623
779
|
:placeholder="attr.placeholder"
|
|
624
780
|
:label="labelData"
|
|
625
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
781
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
626
782
|
@click="showTimePicker = true"
|
|
627
783
|
/>
|
|
628
784
|
<VanPopup v-model:show="showTimePicker" position="bottom" teleport="body">
|
|
@@ -647,7 +803,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
647
803
|
is-link
|
|
648
804
|
readonly
|
|
649
805
|
:label="labelData"
|
|
650
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
806
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
651
807
|
@click="readonly ? null : showArea = true"
|
|
652
808
|
/>
|
|
653
809
|
<VanPopup v-model:show="showArea" position="bottom" teleport="body">
|
|
@@ -668,7 +824,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
668
824
|
:placeholder="placeholder"
|
|
669
825
|
:columns="option"
|
|
670
826
|
:option="attr.option ? attr.option : columnsField"
|
|
671
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
827
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
672
828
|
/>
|
|
673
829
|
|
|
674
830
|
<!-- 文本区域 -->
|
|
@@ -684,7 +840,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
684
840
|
:placeholder="attr.placeholder ? attr.placeholder : `请输入${attr.name}`"
|
|
685
841
|
show-word-limit
|
|
686
842
|
label-align="top"
|
|
687
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
843
|
+
:rules="[{ required: attr.rule.required === 'true', message: `请填写${attr.name}` }]"
|
|
688
844
|
/>
|
|
689
845
|
|
|
690
846
|
<!-- 文本输入框 -->
|
|
@@ -692,14 +848,15 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
692
848
|
v-if="attr.type === 'input' && showItem"
|
|
693
849
|
v-model="(localValue as string)"
|
|
694
850
|
:label="labelData"
|
|
695
|
-
:required="attr.required"
|
|
851
|
+
:required="attr.rule.required"
|
|
696
852
|
:type="attr.type"
|
|
697
853
|
:readonly="readonly"
|
|
698
854
|
:disabled="attr.disabled"
|
|
699
855
|
:placeholder="placeholder"
|
|
700
|
-
:error-message="
|
|
856
|
+
:error-message="errorMessage"
|
|
701
857
|
:clearable="attr.clearable"
|
|
702
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
858
|
+
:rules="[{ required: attr.rule.required === 'true', message: `请填写${attr.name}` }]"
|
|
859
|
+
@blur="() => formTypeCheck(attr, localValue as string)"
|
|
703
860
|
/>
|
|
704
861
|
</div>
|
|
705
862
|
</template>
|
package/src/router/routes.ts
CHANGED
package/src/utils/dictUtil.ts
CHANGED
|
@@ -1,51 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 字典工具
|
|
3
|
-
*/
|
|
4
|
-
import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* 获取字典
|
|
8
|
-
* @param configName 配置名
|
|
9
|
-
* @param callback 获取到字典的回调
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* 字典工具
|
|
3
|
+
*/
|
|
4
|
+
import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 获取字典
|
|
8
|
+
* @param configName 配置名
|
|
9
|
+
* @param callback 获取到字典的回调
|
|
10
|
+
* @param serviceName 服务名
|
|
11
|
+
*/
|
|
12
|
+
export function getDict(configName: string, callback: Function, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
13
|
+
getConfigByName(configName, (result) => {
|
|
14
|
+
if (result != null && result.value) {
|
|
15
|
+
callback(result.value)
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
console.warn(`dict [${configName}] not found`)
|
|
19
|
+
callback(null)
|
|
20
|
+
}
|
|
21
|
+
}, serviceName)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function getDictItemByValue(configName: string, serviceName: string, value: string, callback: Function) {
|
|
25
|
+
getDict(configName, (result) => {
|
|
26
|
+
if (result != null) {
|
|
27
|
+
for (const item of result) {
|
|
28
|
+
if (item.value.toString() === value) {
|
|
29
|
+
callback(item)
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
console.warn(`dict [${configName}] 's value [${value}] not found`)
|
|
34
|
+
}
|
|
35
|
+
callback(null)
|
|
36
|
+
}, serviceName)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function getDictItemByLabel(configName: string, serviceName: string, label: string, callback: Function) {
|
|
40
|
+
getDict(configName, (result) => {
|
|
41
|
+
if (result != null) {
|
|
42
|
+
for (const item of result) {
|
|
43
|
+
if (item.label.toString() === label) {
|
|
44
|
+
callback(item)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
console.warn(`dict [${configName}] 's label [${label}] not found`)
|
|
49
|
+
}
|
|
50
|
+
callback(null)
|
|
51
|
+
}, serviceName)
|
|
52
|
+
}
|
|
@@ -10,11 +10,19 @@ const emit = defineEmits(['deleteRow'])
|
|
|
10
10
|
const router = useRouter()
|
|
11
11
|
// 获取默认值
|
|
12
12
|
const idKey = ref('o_id')
|
|
13
|
-
|
|
14
|
-
//
|
|
15
|
-
const configName = ref('
|
|
13
|
+
|
|
14
|
+
// 简易crud表单测试
|
|
15
|
+
const configName = ref('crud_oper_log_manage')
|
|
16
16
|
const serviceName = ref('af-system')
|
|
17
17
|
|
|
18
|
+
// 资源权限测试
|
|
19
|
+
// const configName = ref('crud_sources_test')
|
|
20
|
+
// const serviceName = ref('af-system')
|
|
21
|
+
|
|
22
|
+
// 实际业务测试
|
|
23
|
+
// const configName = ref('orderCarOutMobileCRUD')
|
|
24
|
+
// const serviceName = ref('af-gaslink')
|
|
25
|
+
|
|
18
26
|
// 跳转到详情页面
|
|
19
27
|
// function toDetail(item) {
|
|
20
28
|
// router.push({
|
|
@@ -48,30 +56,30 @@ function toDetail(item) {
|
|
|
48
56
|
}
|
|
49
57
|
|
|
50
58
|
// 新增功能
|
|
51
|
-
function addOption(totalCount) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
}
|
|
59
|
+
// function addOption(totalCount) {
|
|
60
|
+
// router.push({
|
|
61
|
+
// name: 'XFormView',
|
|
62
|
+
// params: { id: totalCount, openid: totalCount },
|
|
63
|
+
// query: {
|
|
64
|
+
// configName: configName.value,
|
|
65
|
+
// serviceName: serviceName.value,
|
|
66
|
+
// mode: '新增',
|
|
67
|
+
// },
|
|
68
|
+
// })
|
|
69
|
+
// }
|
|
62
70
|
|
|
63
71
|
// 修改功能
|
|
64
|
-
function updateRow(result) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
72
|
+
// function updateRow(result) {
|
|
73
|
+
// router.push({
|
|
74
|
+
// name: 'XFormView',
|
|
75
|
+
// params: { id: result.o_id, openid: result.o_id },
|
|
76
|
+
// query: {
|
|
77
|
+
// configName: configName.value,
|
|
78
|
+
// serviceName: serviceName.value,
|
|
79
|
+
// mode: '修改',
|
|
80
|
+
// },
|
|
81
|
+
// })
|
|
82
|
+
// }
|
|
75
83
|
|
|
76
84
|
// 删除功能
|
|
77
85
|
function deleteRow(result) {
|
|
@@ -84,7 +92,8 @@ function deleteRow(result) {
|
|
|
84
92
|
<template #layout_content>
|
|
85
93
|
<XCellList
|
|
86
94
|
:config-name="configName"
|
|
87
|
-
:
|
|
95
|
+
:service-name="serviceName"
|
|
96
|
+
:fix-query-form="{ o_f_oper_name: 'edu_test' }"
|
|
88
97
|
:id-key="idKey"
|
|
89
98
|
@to-detail="toDetail"
|
|
90
99
|
@delete-row="deleteRow"
|
|
@@ -6,6 +6,9 @@ import { showDialog } from 'vant'
|
|
|
6
6
|
// import {runLogic} from "@af-mobile-client-vue3/services/api/common";
|
|
7
7
|
|
|
8
8
|
// 纯表单
|
|
9
|
+
// const configName = ref("form_check_test")
|
|
10
|
+
// const serviceName = ref("af-system")
|
|
11
|
+
|
|
9
12
|
// const configName = ref("计划下发Form")
|
|
10
13
|
// const serviceName = ref("af-linepatrol")
|
|
11
14
|
|
|
@@ -44,7 +47,7 @@ function submit(_result) {
|
|
|
44
47
|
:config-name="configName"
|
|
45
48
|
:service-name="serviceName"
|
|
46
49
|
:group-form-data="formData"
|
|
47
|
-
mode="
|
|
50
|
+
mode="新增"
|
|
48
51
|
@submit="submit"
|
|
49
52
|
/>
|
|
50
53
|
</template>
|