index.vue
1.75 KB
1
2
3
4
5
6
7
8
9
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
52
53
54
55
56
57
58
59
60
61
62
<template>
<BasicModal
v-bind="$attrs"
width="55rem"
@register="register"
:title="getTitle"
@ok="handleSubmit"
>
<BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" />
</BasicModal>
</template>
<script lang="ts">
import { defineComponent, ref, computed, unref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicForm, useForm } from '/@/components/Form';
import { formSchema } from './config';
export default defineComponent({
name: 'DetailTemplate',
components: {
BasicModal,
BasicForm,
},
emits: ['success', 'register', 'getAllFields'],
setup(_, { emit }) {
// const getValueData: any = ref({});
const isUpdate = ref(true);
const [registerForm, { getFieldsValue, resetFields }] = useForm({
labelWidth: 120,
schemas: formSchema,
});
const getTitle = computed(() => (!unref(isUpdate) ? '新增详情模板' : '编辑详情模板'));
const [register, { closeModal }] = useModalInner((data) => {
isUpdate.value = !!data?.isUpdate;
});
const resetDataFunc = () => {
resetFields();
};
const handleSubmit = () => {
const values = getFieldsValue();
emit('getAllFields', values);
// let getV = {};
// getAllFields(getV);
closeModal();
};
// function getAllFields(getV) {
// const values = getFieldsValue();
// getValueData.value = values;
// getV = getValueData.value;
// return getV;
// }
return {
resetDataFunc,
// getAllFields,
registerForm,
handleSubmit,
register,
getTitle,
};
},
});
</script>