af-mobile-client-vue3 1.0.70 → 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.
@@ -1,78 +1,96 @@
1
- <script setup lang="ts">
2
- import {
3
- Tabs as VanTabs,
4
- Tab as VanTab,
5
- Row as VanRow,
6
- Button as VanButton
7
- } from 'vant'
8
- import { defineProps, watchEffect, onBeforeMount, ref, onMounted, watch, defineEmits } from 'vue'
9
- import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
10
- import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
11
- import { useRouter } from 'vue-router'
12
- import {getConfigByName, query} from '@af-mobile-client-vue3/services/api/common'
13
-
14
- const props = withDefaults(defineProps<{
15
- configName?: string
16
- serviceName?: string,
17
- groupFormData?: object,
18
- showSubmit: boolean
19
- }>(), {
20
- configName: '',
21
- serviceName: undefined,
22
- groupFormData: {},
23
- showSubmit: true
24
- })
25
- const emit = defineEmits(['submit'])
26
- const router = useRouter()
27
- const groupItems = ref([])
28
- const formData = ref({})
29
- function initComponents () {
30
- getConfigByName(props.configName, (result) => {
31
- groupItems.value = result.groups
32
- formData.value = props.groupFormData
33
- result.groups.forEach((group) => {
34
- if(!formData.value[group.groupName]){
35
- formData.value[group.groupName] = {}
36
- }
37
- })
38
- }, props.serviceName)
39
- }
40
- watch(()=>props.groupFormData, (val)=>{
41
- formData.value = {...formData.value, ...props.groupFormData}
42
- })
43
- onBeforeMount(()=>{
44
- initComponents()
45
- })
46
- const xFormListRef = ref([])
47
- const submit = async () => {
48
- for (const res of xFormListRef.value) {
49
- await res.validate()
50
- formData.value[res.formGroupName] = res.form
51
- }
52
- emit('submit', formData)
53
- }
54
- </script>
55
-
56
- <template>
57
- <div id="x-form-group">
58
- <VanTabs v-model:active="active" scrollspy sticky>
59
- <VanTab v-for="(item, index) in groupItems" :title="item.describe" :key="item.groupName+index" >
60
- <div class="x-form-group-item">
61
- <XForm :group-form-items="item" :form-data="formData[item.groupName]" ref="xFormListRef" :form-name="item.groupName" :service-name="props.serviceName"/>
62
- </div>
63
- </VanTab>
64
- </VanTabs>
65
- <VanButton round block type="primary" @click="submit" v-if="showSubmit">
66
- 提交
67
- </VanButton>
68
- </div>
69
- </template>
70
- <style scoped lang="less">
71
- #x-form-group{
72
- background-color: rgb(247,248,250);
73
- padding-bottom: 10px;
74
- .x-form-group-item{
75
- margin:20px 0;
76
- }
77
- }
78
- </style>
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>