af-mobile-client-vue3 1.0.69 → 1.0.71
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/.cursorrules +61 -0
- package/package.json +1 -1
- package/src/components/core/XGridDropOption/index.vue +151 -132
- package/src/components/core/XMultiSelect/index.vue +183 -185
- package/src/components/core/XSelect/index.vue +122 -123
- package/src/components/data/XCellList/index.vue +116 -57
- package/src/components/data/XCellListFilter/index.vue +240 -230
- package/src/components/data/XForm/index.vue +153 -147
- package/src/components/data/XFormGroup/index.vue +96 -75
- package/src/components/data/XFormItem/index.vue +638 -579
- package/src/components/data/XReportForm/index.vue +19 -0
- package/src/components/data/XSignature/index.vue +285 -0
- package/src/router/routes.ts +12 -0
- package/src/utils/authority-utils.ts +0 -1
- package/src/utils/runEvalFunction.ts +13 -0
- package/src/views/component/XCellListView/index.vue +96 -57
- package/src/views/component/XFormGroupView/index.vue +54 -0
- package/src/views/component/XFormView/index.vue +170 -58
- package/src/views/component/XReportFormView/index.vue +2 -284
- package/src/views/component/XSignatureView/index.vue +50 -0
- package/src/views/component/index.vue +9 -1
- package/vite.config.ts +1 -1
|
@@ -1,147 +1,153 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
Button as VanButton,
|
|
4
|
-
CellGroup as VanCellGroup,
|
|
5
|
-
Form as VanForm,
|
|
6
|
-
} from 'vant'
|
|
7
|
-
import type { FormInstance } from 'vant'
|
|
8
|
-
import {computed,
|
|
9
|
-
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
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
|
-
const
|
|
38
|
-
|
|
39
|
-
const
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
</
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Button as VanButton,
|
|
4
|
+
CellGroup as VanCellGroup,
|
|
5
|
+
Form as VanForm,
|
|
6
|
+
} from 'vant'
|
|
7
|
+
import type { FormInstance } from 'vant'
|
|
8
|
+
import { computed, defineEmits, defineProps, onBeforeMount, reactive, ref, watch } from 'vue'
|
|
9
|
+
import XFormItem from '@af-mobile-client-vue3/components/data/XFormItem/index.vue'
|
|
10
|
+
|
|
11
|
+
interface FormItem {
|
|
12
|
+
addOrEdit: string
|
|
13
|
+
isOnlyAddOrEdit?: boolean
|
|
14
|
+
type?: string
|
|
15
|
+
model?: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface GroupFormItems {
|
|
19
|
+
btnName?: string
|
|
20
|
+
formJson: any[] // 根据实际类型调整
|
|
21
|
+
}
|
|
22
|
+
const props = withDefaults(defineProps<{
|
|
23
|
+
groupFormItems?: GroupFormItems
|
|
24
|
+
serviceName?: string
|
|
25
|
+
formData?: object
|
|
26
|
+
formName?: string
|
|
27
|
+
mode?: string
|
|
28
|
+
submitButton?: boolean
|
|
29
|
+
}>(), {
|
|
30
|
+
groupFormItems: null,
|
|
31
|
+
serviceName: undefined,
|
|
32
|
+
formData: null,
|
|
33
|
+
formName: 'default',
|
|
34
|
+
mode: '查询',
|
|
35
|
+
submitButton: true,
|
|
36
|
+
})
|
|
37
|
+
const emits = defineEmits(['onSubmit'])
|
|
38
|
+
const formRef = ref<FormInstance>()
|
|
39
|
+
const myFormItems = ref<FormItem[]>([])
|
|
40
|
+
const rules = reactive({})
|
|
41
|
+
const form = ref({})
|
|
42
|
+
const formGroupName = ref(null)
|
|
43
|
+
const myServiceName = ref('')
|
|
44
|
+
const loaded = ref(false)
|
|
45
|
+
let myGetDataParams = reactive({})
|
|
46
|
+
const realJsonData = computed(() => {
|
|
47
|
+
return myFormItems.value.filter((item) => {
|
|
48
|
+
return item.addOrEdit !== 'no'
|
|
49
|
+
})
|
|
50
|
+
})
|
|
51
|
+
onBeforeMount(() => {
|
|
52
|
+
init({ formItems: props.groupFormItems, serviceName: props.serviceName, formData: props.formData, formName: props.formName })
|
|
53
|
+
})
|
|
54
|
+
function init(params) {
|
|
55
|
+
const {
|
|
56
|
+
formItems,
|
|
57
|
+
serviceName,
|
|
58
|
+
getDataParams = {},
|
|
59
|
+
formData = null,
|
|
60
|
+
formName = 'default',
|
|
61
|
+
} = params
|
|
62
|
+
loaded.value = false
|
|
63
|
+
myFormItems.value = JSON.parse(JSON.stringify(formItems.formJson)) as FormItem[]
|
|
64
|
+
myServiceName.value = serviceName
|
|
65
|
+
formGroupName.value = formName
|
|
66
|
+
for (let i = 0; i < realJsonData.value.length; i++) {
|
|
67
|
+
const item = realJsonData.value[i]
|
|
68
|
+
setFormProps(form, item)
|
|
69
|
+
}
|
|
70
|
+
if (formData)
|
|
71
|
+
form.value = formData
|
|
72
|
+
|
|
73
|
+
myGetDataParams = getDataParams
|
|
74
|
+
loaded.value = true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function setFormProps(form, item) {
|
|
78
|
+
form.value[item.model] = undefined
|
|
79
|
+
if (item.rule) {
|
|
80
|
+
rules[item.model] = []
|
|
81
|
+
let defaultValue
|
|
82
|
+
let message
|
|
83
|
+
switch (item.rule.type) {
|
|
84
|
+
case 'number':
|
|
85
|
+
message = '数字'
|
|
86
|
+
defaultValue = 0
|
|
87
|
+
break
|
|
88
|
+
case 'integer':
|
|
89
|
+
message = '整数'
|
|
90
|
+
defaultValue = 0
|
|
91
|
+
break
|
|
92
|
+
case 'float':
|
|
93
|
+
message = '小数'
|
|
94
|
+
defaultValue = 0.0
|
|
95
|
+
break
|
|
96
|
+
case 'string':
|
|
97
|
+
message = '字符串'
|
|
98
|
+
defaultValue = ''
|
|
99
|
+
break
|
|
100
|
+
}
|
|
101
|
+
rules[item.model].push({
|
|
102
|
+
type: item.rule.type,
|
|
103
|
+
message: `${item.name}必须为${message}`,
|
|
104
|
+
transform: (value) => {
|
|
105
|
+
if (value && value.length !== 0)
|
|
106
|
+
return Number(value)
|
|
107
|
+
else
|
|
108
|
+
return defaultValue
|
|
109
|
+
},
|
|
110
|
+
trigger: 'blur',
|
|
111
|
+
})
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function onSubmit() {
|
|
116
|
+
emits('onSubmit', form.value)
|
|
117
|
+
}
|
|
118
|
+
async function validate() {
|
|
119
|
+
await formRef.value?.validate()
|
|
120
|
+
}
|
|
121
|
+
watch(() => props.formData, (_val) => {
|
|
122
|
+
form.value = props.formData
|
|
123
|
+
})
|
|
124
|
+
defineExpose({ init, form, formGroupName, validate })
|
|
125
|
+
</script>
|
|
126
|
+
|
|
127
|
+
<template>
|
|
128
|
+
<VanForm ref="formRef" @submit="onSubmit">
|
|
129
|
+
<VanCellGroup inset>
|
|
130
|
+
<XFormItem
|
|
131
|
+
v-for="(item, index) in realJsonData"
|
|
132
|
+
:key="index"
|
|
133
|
+
v-model="form[item.model]"
|
|
134
|
+
:mode="props.mode"
|
|
135
|
+
:form="form"
|
|
136
|
+
:attr="item"
|
|
137
|
+
:rules="rules"
|
|
138
|
+
:service-name="myServiceName"
|
|
139
|
+
:get-data-params="myGetDataParams"
|
|
140
|
+
/>
|
|
141
|
+
</VanCellGroup>
|
|
142
|
+
<div v-if="props.submitButton" style="margin: 16px;">
|
|
143
|
+
<VanButton round block type="primary" native-type="submit">
|
|
144
|
+
{{ props.groupFormItems.btnName ? props.groupFormItems.btnName : '提交' }}
|
|
145
|
+
</VanButton>
|
|
146
|
+
<slot />
|
|
147
|
+
</div>
|
|
148
|
+
</VanForm>
|
|
149
|
+
</template>
|
|
150
|
+
|
|
151
|
+
<style scoped>
|
|
152
|
+
|
|
153
|
+
</style>
|
|
@@ -1,75 +1,96 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
Tab as VanTab,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
function initComponents
|
|
28
|
-
getConfigByName(props.configName, (result) => {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import {
|
|
3
|
+
Button as VanButton,
|
|
4
|
+
Tab as VanTab,
|
|
5
|
+
Tabs as VanTabs,
|
|
6
|
+
} from 'vant'
|
|
7
|
+
import { defineEmits, defineProps, onBeforeMount, ref, watch } from 'vue'
|
|
8
|
+
import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
|
|
9
|
+
import { getConfigByName } from '@af-mobile-client-vue3/services/api/common'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{
|
|
12
|
+
configName?: string
|
|
13
|
+
serviceName?: string
|
|
14
|
+
groupFormData?: object
|
|
15
|
+
mode?: string
|
|
16
|
+
}>(), {
|
|
17
|
+
configName: '',
|
|
18
|
+
serviceName: undefined,
|
|
19
|
+
groupFormData: () => ({}),
|
|
20
|
+
mode: '查询',
|
|
21
|
+
})
|
|
22
|
+
const emit = defineEmits(['submit'])
|
|
23
|
+
const groupItems = ref([])
|
|
24
|
+
const formData = ref({})
|
|
25
|
+
const submitGroup = ref(false)
|
|
26
|
+
const submitSimple = ref(false)
|
|
27
|
+
function initComponents() {
|
|
28
|
+
getConfigByName(props.configName, (result) => {
|
|
29
|
+
formData.value = props.groupFormData
|
|
30
|
+
if (result.groups) {
|
|
31
|
+
submitGroup.value = true
|
|
32
|
+
groupItems.value = result.groups
|
|
33
|
+
result.groups.forEach((group) => {
|
|
34
|
+
if (!formData.value[group.groupName])
|
|
35
|
+
formData.value[group.groupName] = {}
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
submitSimple.value = result.showSubmitBtn
|
|
40
|
+
groupItems.value = [{ ...result }]
|
|
41
|
+
}
|
|
42
|
+
}, props.serviceName)
|
|
43
|
+
}
|
|
44
|
+
watch(() => props.groupFormData, (_val) => {
|
|
45
|
+
formData.value = { ...formData.value, ...props.groupFormData }
|
|
46
|
+
})
|
|
47
|
+
onBeforeMount(() => {
|
|
48
|
+
initComponents()
|
|
49
|
+
})
|
|
50
|
+
const xFormListRef = ref([])
|
|
51
|
+
async function submit() {
|
|
52
|
+
for (const res of xFormListRef.value) {
|
|
53
|
+
await res.validate()
|
|
54
|
+
formData.value[res.formGroupName] = res.form
|
|
55
|
+
}
|
|
56
|
+
emit('submit', formData)
|
|
57
|
+
}
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<div id="x-form-group">
|
|
62
|
+
<VanTabs scrollspy sticky>
|
|
63
|
+
<VanTab
|
|
64
|
+
v-for="(item, index) in groupItems"
|
|
65
|
+
:key="item.groupName ? (item.groupName + index) : index"
|
|
66
|
+
:title="item.describe ? item.describe : null "
|
|
67
|
+
>
|
|
68
|
+
<div class="x-form-group-item">
|
|
69
|
+
<XForm
|
|
70
|
+
ref="xFormListRef"
|
|
71
|
+
:mode="props.mode"
|
|
72
|
+
:group-form-items="item"
|
|
73
|
+
:form-data="item.groupName ? formData[item.groupName] : formData"
|
|
74
|
+
:form-name="item.groupName"
|
|
75
|
+
:service-name="props.serviceName"
|
|
76
|
+
:submit-button="submitSimple"
|
|
77
|
+
@on-submit="submit"
|
|
78
|
+
/>
|
|
79
|
+
</div>
|
|
80
|
+
</VanTab>
|
|
81
|
+
</VanTabs>
|
|
82
|
+
<VanButton v-if="submitGroup" round block type="primary" @click="submit">
|
|
83
|
+
提交
|
|
84
|
+
</VanButton>
|
|
85
|
+
</div>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
<style scoped lang="less">
|
|
89
|
+
#x-form-group{
|
|
90
|
+
background-color: rgb(247,248,250);
|
|
91
|
+
padding-bottom: 10px;
|
|
92
|
+
.x-form-group-item{
|
|
93
|
+
margin:20px 0;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
</style>
|