servicePlanModal.vue
1.43 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
<template>
<div>
<BasicModal
v-bind="$attrs"
width="30rem"
:title="getTitle"
@register="register"
@cancel="handleCancel"
@ok="handleOk"
destroyOnClose
>
<div>
<BasicForm @register="registerForm" />
</div>
</BasicModal>
</div>
</template>
<script setup lang="ts">
import {computed, ref, unref} from "vue";
import {useI18n} from "/@/hooks/web/useI18n";
import {useForm} from "/@/components/Form";
import {schemas} from "../index";
import {useModalInner} from "/@/components/Modal";
const { t } = useI18n();
const isUpdate = ref<Boolean>(false);
const recordInfo = ref<any>({});
const emit = defineEmits(['handleReload', 'register']);
const getTitle = computed(() =>
!unref(isUpdate)
? t('inspection.servicePlan.createPlanText')
: t('inspection.servicePlan.editPlanText')
);
const [registerForm, { getFieldsValue, setFieldsValue, validate, updateSchema }] = useForm({
labelWidth: 140,
schemas,
actionColOptions: {
span: 14,
},
showActionButtonGroup: false,
});
const [register, { closeModal, setModalProps }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false, loading: true });
isUpdate.value = data?.isUpdate;
recordInfo.value = data?.record;
if (data?.record) {
setFieldsValue(data?.record);
}
setModalProps({ loading: false });
});
const handleCancel = () => {
closeModal();
};
const handleOk = async () => {
}
</script>