af-mobile-client-vue3 1.0.75 → 1.0.77
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 +4 -0
- package/src/components/data/XCellListFilter/index.vue +2 -1
- package/src/components/data/XFormGroup/index.vue +1 -1
- package/src/components/data/XFormItem/index.vue +182 -25
- 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':
|
|
@@ -151,8 +164,12 @@ const localValue = computed({
|
|
|
151
164
|
case 'citySelect':
|
|
152
165
|
case 'calendar':
|
|
153
166
|
case 'textarea':
|
|
167
|
+
case 'intervalPicker':
|
|
154
168
|
case 'input':
|
|
155
|
-
|
|
169
|
+
if (mode === '查询')
|
|
170
|
+
return props.modelValue !== undefined ? props.modelValue : queryInputDefaultValue.value
|
|
171
|
+
else
|
|
172
|
+
return props.modelValue !== undefined ? props.modelValue : formInputDefaultValue.value
|
|
156
173
|
case 'stepper':
|
|
157
174
|
return props.modelValue !== undefined ? props.modelValue : 1
|
|
158
175
|
case 'rangePicker':
|
|
@@ -172,6 +189,126 @@ const localValue = computed({
|
|
|
172
189
|
},
|
|
173
190
|
})
|
|
174
191
|
|
|
192
|
+
// 表单校验的类型校验
|
|
193
|
+
function formTypeCheck(attr, value) {
|
|
194
|
+
switch (attr.rule.type) {
|
|
195
|
+
case 'string':
|
|
196
|
+
if (value.length === 0) {
|
|
197
|
+
errorMessage.value = `${attr.name}必须为有效的字符串`
|
|
198
|
+
return
|
|
199
|
+
}
|
|
200
|
+
break
|
|
201
|
+
case 'number':
|
|
202
|
+
if (!/^[+-]?(\d+(\.\d*)?|\.\d+)$/.test(value)) {
|
|
203
|
+
errorMessage.value = `${attr.name}必须为数字`
|
|
204
|
+
return
|
|
205
|
+
}
|
|
206
|
+
break
|
|
207
|
+
case 'boolean':
|
|
208
|
+
case 'array':
|
|
209
|
+
case 'regexp':
|
|
210
|
+
if (value) {
|
|
211
|
+
errorMessage.value = ''
|
|
212
|
+
return
|
|
213
|
+
}
|
|
214
|
+
break
|
|
215
|
+
case 'integer':
|
|
216
|
+
if (!/^-?\d+$/.test(value)) {
|
|
217
|
+
errorMessage.value = `${attr.name}必须为整数`
|
|
218
|
+
return
|
|
219
|
+
}
|
|
220
|
+
break
|
|
221
|
+
case 'float':
|
|
222
|
+
if (!/^-?\d+\.\d+$/.test(value)) {
|
|
223
|
+
errorMessage.value = `${attr.name}必须为小数`
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
break
|
|
227
|
+
case 'email':
|
|
228
|
+
if (!/^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/.test(value)) {
|
|
229
|
+
errorMessage.value = `请输入正确的邮箱地址`
|
|
230
|
+
return
|
|
231
|
+
}
|
|
232
|
+
break
|
|
233
|
+
case 'idNumber':
|
|
234
|
+
if (!/^(^\d{15}$|^\d{17}([0-9]|X)$)$/.test(value)) {
|
|
235
|
+
errorMessage.value = `请输入正确的身份证号码`
|
|
236
|
+
return
|
|
237
|
+
}
|
|
238
|
+
break
|
|
239
|
+
case 'userPhone':
|
|
240
|
+
if (!/^1[3-9]\d{9}$/.test(value)) {
|
|
241
|
+
errorMessage.value = `请输入正确的手机号码`
|
|
242
|
+
return
|
|
243
|
+
}
|
|
244
|
+
break
|
|
245
|
+
case 'landlineNumber':
|
|
246
|
+
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)) {
|
|
247
|
+
errorMessage.value = `请输入正确的座机号码`
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
break
|
|
251
|
+
case 'greaterThanZero':
|
|
252
|
+
if (!/^(?:[1-9]\d*(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(value)) {
|
|
253
|
+
errorMessage.value = `请输入一个大于0的数字`
|
|
254
|
+
return
|
|
255
|
+
}
|
|
256
|
+
break
|
|
257
|
+
case 'greaterThanOrEqualZero':
|
|
258
|
+
if (!/^(?:\d+|\d*\.\d+)$/.test(value)) {
|
|
259
|
+
errorMessage.value = `请输入一个大于等于0的数字`
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
break
|
|
263
|
+
case 'stringLength':
|
|
264
|
+
if (!(value.length >= attr.rule.minLen && value.length < attr.rule.maxLen)) {
|
|
265
|
+
errorMessage.value = `长度必须在${attr.rule.minLen}~${attr.rule.maxLen}之间`
|
|
266
|
+
return
|
|
267
|
+
}
|
|
268
|
+
break
|
|
269
|
+
case 'customJs':
|
|
270
|
+
// eslint-disable-next-line no-case-declarations
|
|
271
|
+
const funcStr = attr.rule.customValidatorFunc
|
|
272
|
+
// 输入的数据是否符合条件
|
|
273
|
+
// eslint-disable-next-line no-case-declarations
|
|
274
|
+
const status = ref(true)
|
|
275
|
+
// 提取函数体部分
|
|
276
|
+
// eslint-disable-next-line no-case-declarations
|
|
277
|
+
const funcBodyMatch = funcStr.match(/function\s*\(.*?\)\s*{([\s\S]*)}/)
|
|
278
|
+
if (!funcBodyMatch)
|
|
279
|
+
throw new Error('自定义校验函数不合法')
|
|
280
|
+
// eslint-disable-next-line no-case-declarations
|
|
281
|
+
const funcBody = funcBodyMatch[1].trim() // 提取函数体
|
|
282
|
+
// 使用 new Function 创建函数
|
|
283
|
+
// eslint-disable-next-line no-new-func,no-case-declarations
|
|
284
|
+
const customValidatorFunc = new Function('rule', 'value', 'callback', 'form', 'attr', 'util', funcBody)
|
|
285
|
+
// 定义 callback 函数
|
|
286
|
+
// eslint-disable-next-line no-case-declarations
|
|
287
|
+
const callback = (error) => {
|
|
288
|
+
if (error) {
|
|
289
|
+
errorMessage.value = `${error}`
|
|
290
|
+
status.value = false // 表示有错误发生
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
// 调用自定义校验函数
|
|
294
|
+
customValidatorFunc(
|
|
295
|
+
attr.rule,
|
|
296
|
+
value,
|
|
297
|
+
callback,
|
|
298
|
+
form,
|
|
299
|
+
attr,
|
|
300
|
+
{}, // util 对象(可以根据需要传递)
|
|
301
|
+
)
|
|
302
|
+
if (!status.value)
|
|
303
|
+
return
|
|
304
|
+
break
|
|
305
|
+
default:
|
|
306
|
+
errorMessage.value = ''
|
|
307
|
+
break
|
|
308
|
+
}
|
|
309
|
+
errorMessage.value = ''
|
|
310
|
+
}
|
|
311
|
+
|
|
175
312
|
onBeforeMount(() => {
|
|
176
313
|
init()
|
|
177
314
|
showFormItemFunc()
|
|
@@ -246,6 +383,26 @@ function init() {
|
|
|
246
383
|
initRadioValue()
|
|
247
384
|
}
|
|
248
385
|
}
|
|
386
|
+
if (attr.type === 'radio' || attr.type === 'rate' || attr.type === 'slider' || attr.type === 'area' || attr.type === 'citySelect' || attr.type === 'calendar' || attr.type === 'textarea' || attr.type === 'intervalPicker' || attr.type === 'input') {
|
|
387
|
+
if (attr.formDefault)
|
|
388
|
+
formInputDefaultValue.value = attr.formDefault
|
|
389
|
+
if (attr.queryFormDefault)
|
|
390
|
+
queryInputDefaultValue.value = attr.queryFormDefault
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if (attr.type === 'checkbox' || attr.type === 'uploader' || attr.type === 'file' || attr.type === 'image' || attr.type === 'datePicker' || attr.type === 'timePicker' || attr.type === 'select') {
|
|
394
|
+
if (attr.formDefault) {
|
|
395
|
+
if (attr.type === 'checkbox')
|
|
396
|
+
formSelectDefaultValue.value = attr.formDefault
|
|
397
|
+
else
|
|
398
|
+
formSelectDefaultValue.value.push(attr.formDefault)
|
|
399
|
+
}
|
|
400
|
+
if (attr.queryFormDefault) {
|
|
401
|
+
// console.log(querySelectDefaultValue.value)
|
|
402
|
+
querySelectDefaultValue.value.push(attr.queryFormDefault)
|
|
403
|
+
// querySelectDefaultValue.value = attr.queryFormDefault
|
|
404
|
+
}
|
|
405
|
+
}
|
|
249
406
|
}
|
|
250
407
|
|
|
251
408
|
function getDataCallback(res) {
|
|
@@ -361,7 +518,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
361
518
|
v-if="attr.type === 'switch' && showItem"
|
|
362
519
|
name="switch"
|
|
363
520
|
:label="labelData"
|
|
364
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
521
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
365
522
|
>
|
|
366
523
|
<template #input>
|
|
367
524
|
<VanSwitch v-model="localValue" />
|
|
@@ -386,7 +543,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
386
543
|
v-if="attr.showMode === 'checkbox' && mode !== '查询'"
|
|
387
544
|
name="checkboxGroup"
|
|
388
545
|
:label="labelData"
|
|
389
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
546
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
390
547
|
>
|
|
391
548
|
<template #input>
|
|
392
549
|
<van-checkbox-group v-model="localValue as any[]" direction="horizontal" shape="square" :disabled="readonly">
|
|
@@ -400,7 +557,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
400
557
|
v-if="attr.showMode === 'checkbox' && mode === '查询'"
|
|
401
558
|
name="checkboxGroup"
|
|
402
559
|
:label="labelData"
|
|
403
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
560
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
404
561
|
>
|
|
405
562
|
<template #input>
|
|
406
563
|
<XGridDropOption
|
|
@@ -420,7 +577,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
420
577
|
:placeholder="placeholder"
|
|
421
578
|
:columns="option"
|
|
422
579
|
:option="attr.option ? attr.option : columnsField"
|
|
423
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
580
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
424
581
|
/>
|
|
425
582
|
</template>
|
|
426
583
|
|
|
@@ -430,7 +587,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
430
587
|
name="radio"
|
|
431
588
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
432
589
|
:label="labelData"
|
|
433
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
590
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
434
591
|
>
|
|
435
592
|
<template #input>
|
|
436
593
|
<VanRadioGroup v-model="localValue" direction="horizontal" :disabled="readonly">
|
|
@@ -447,7 +604,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
447
604
|
name="radio"
|
|
448
605
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
449
606
|
:label="labelData"
|
|
450
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
607
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
451
608
|
>
|
|
452
609
|
<template #input>
|
|
453
610
|
<XGridDropOption
|
|
@@ -464,7 +621,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
464
621
|
name="stepper"
|
|
465
622
|
:label="labelData"
|
|
466
623
|
:readonly="readonly"
|
|
467
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
624
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
468
625
|
>
|
|
469
626
|
<template #input>
|
|
470
627
|
<VanStepper v-model="(localValue as string)" />
|
|
@@ -477,7 +634,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
477
634
|
name="rate"
|
|
478
635
|
:label="labelData"
|
|
479
636
|
:readonly="readonly"
|
|
480
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
637
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
481
638
|
>
|
|
482
639
|
<template #input>
|
|
483
640
|
<VanRate v-model="(localValue as number)" />
|
|
@@ -490,7 +647,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
490
647
|
name="slider"
|
|
491
648
|
:label="labelData"
|
|
492
649
|
:readonly="readonly"
|
|
493
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
650
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
494
651
|
>
|
|
495
652
|
<template #input>
|
|
496
653
|
<VanSlider v-model="(localValue as number)" />
|
|
@@ -502,7 +659,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
502
659
|
v-if="(attr.type === 'image' || attr.type === 'file') && showItem"
|
|
503
660
|
name="uploader"
|
|
504
661
|
:label="labelData"
|
|
505
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
662
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
506
663
|
>
|
|
507
664
|
<template #input>
|
|
508
665
|
<!-- <van-uploader v-model="localValue" /> -->
|
|
@@ -524,7 +681,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
524
681
|
:label="labelData"
|
|
525
682
|
:readonly="readonly"
|
|
526
683
|
is-link
|
|
527
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
684
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
528
685
|
@click="showPicker = true"
|
|
529
686
|
/>
|
|
530
687
|
<VanPopup v-model:show="showPicker" round position="bottom" teleport="body">
|
|
@@ -550,7 +707,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
550
707
|
name="rangePicker"
|
|
551
708
|
:label="labelData"
|
|
552
709
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
553
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
710
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
554
711
|
@click="calendarShow = true"
|
|
555
712
|
/>
|
|
556
713
|
<VanCalendar
|
|
@@ -571,7 +728,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
571
728
|
readonly
|
|
572
729
|
:is-link="true"
|
|
573
730
|
:placeholder="placeholder"
|
|
574
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
731
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
575
732
|
@click="readonly ? null : showDatePicker = true"
|
|
576
733
|
/>
|
|
577
734
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body">
|
|
@@ -596,7 +753,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
596
753
|
readonly
|
|
597
754
|
:is-link="true"
|
|
598
755
|
:placeholder="attr.placeholder ? attr.placeholder : `请选择${attr.name}`"
|
|
599
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
756
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
600
757
|
@click="showDatePicker = true"
|
|
601
758
|
/>
|
|
602
759
|
<VanPopup v-model:show="showDatePicker" position="bottom" teleport="body">
|
|
@@ -622,7 +779,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
622
779
|
readonly
|
|
623
780
|
:placeholder="attr.placeholder"
|
|
624
781
|
:label="labelData"
|
|
625
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
782
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
626
783
|
@click="showTimePicker = true"
|
|
627
784
|
/>
|
|
628
785
|
<VanPopup v-model:show="showTimePicker" position="bottom" teleport="body">
|
|
@@ -647,7 +804,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
647
804
|
is-link
|
|
648
805
|
readonly
|
|
649
806
|
:label="labelData"
|
|
650
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
807
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
651
808
|
@click="readonly ? null : showArea = true"
|
|
652
809
|
/>
|
|
653
810
|
<VanPopup v-model:show="showArea" position="bottom" teleport="body">
|
|
@@ -668,7 +825,7 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
668
825
|
:placeholder="placeholder"
|
|
669
826
|
:columns="option"
|
|
670
827
|
:option="attr.option ? attr.option : columnsField"
|
|
671
|
-
:rules="[{ required: attr.rule.required === 'true', message: '
|
|
828
|
+
:rules="[{ required: attr.rule.required === 'true', message: '请选择' }]"
|
|
672
829
|
/>
|
|
673
830
|
|
|
674
831
|
<!-- 文本区域 -->
|
|
@@ -684,22 +841,22 @@ watch(() => form, (_oldVal, _newVal) => {
|
|
|
684
841
|
:placeholder="attr.placeholder ? attr.placeholder : `请输入${attr.name}`"
|
|
685
842
|
show-word-limit
|
|
686
843
|
label-align="top"
|
|
687
|
-
:rules="[{ required: attr.rule.required === 'true', message:
|
|
844
|
+
:rules="[{ required: attr.rule.required === 'true', message: `请填写${attr.name}` }]"
|
|
688
845
|
/>
|
|
689
846
|
|
|
690
847
|
<!-- 文本输入框 -->
|
|
691
848
|
<VanField
|
|
692
|
-
v-if="attr.type === 'input' && showItem"
|
|
849
|
+
v-if="(attr.type === 'input' || attr.type === 'intervalPicker') && showItem"
|
|
693
850
|
v-model="(localValue as string)"
|
|
694
851
|
:label="labelData"
|
|
695
|
-
:required="attr.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('lngChargeAuditMobileCRUD')
|
|
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>
|