6 changed files with 345 additions and 39 deletions
Split View
Diff Options
-
10src/api/clue/index.ts
-
88src/enums/customerEnum.ts
-
28src/views/clue/components/data.ts
-
94src/views/clue/customer/data.ts
-
100src/views/clue/customer/index.vue
-
64src/views/clue/customer/modal.vue
@ -0,0 +1,64 @@ |
|||
<template> |
|||
<BasicModal v-bind="$attrs" @ok="handleOk" @register="registerModal"> |
|||
<BasicForm @register="registerForm" /> |
|||
</BasicModal> |
|||
</template> |
|||
|
|||
<script setup lang="ts"> |
|||
import { ref } from 'vue' |
|||
import { appointmentFormSchema } from './data' |
|||
import { useMessage } from '/@/hooks/web/useMessage' |
|||
import { BasicForm, useForm } from '/@/components/Form' |
|||
import { BasicModal, useModalInner } from '/@/components/Modal' |
|||
import { createAppointment, editAppointment } from '/@/api/clue' |
|||
import { formatToDateTime } from '/@/utils/dateUtil' |
|||
|
|||
const [registerForm, { resetFields, setFieldsValue, validate }] = useForm({ |
|||
labelWidth: 100, |
|||
schemas: appointmentFormSchema, |
|||
baseColProps: { span: 22 }, |
|||
showActionButtonGroup: false, |
|||
}) |
|||
|
|||
const id = ref<string>('') |
|||
const datingClueId = ref<string>('') |
|||
const ifUpdate = ref<boolean>(false) |
|||
const [registerModal, { setModalProps }] = useModalInner(async (data) => { |
|||
const { record } = data |
|||
await resetFields() |
|||
id.value = record?.id |
|||
datingClueId.value = record?.datingClueId |
|||
ifUpdate.value = !!id.value |
|||
setModalProps({ |
|||
minHeight: 50, |
|||
title: `预约到店`, |
|||
confirmLoading: false, |
|||
}) |
|||
if (!!ifUpdate.value) { |
|||
await setFieldsValue({ ...record }) |
|||
} |
|||
}) |
|||
|
|||
const { createMessage } = useMessage() |
|||
const emits = defineEmits(['success']) |
|||
async function handleOk() { |
|||
try { |
|||
const values = await validate() |
|||
setModalProps({ confirmLoading: true }) |
|||
const { appointmentTime } = values |
|||
values.appointmentTime = formatToDateTime(appointmentTime) |
|||
if(id.value){ |
|||
values.id = id.value |
|||
await editAppointment(values) |
|||
createMessage.success(`编辑成功!`) |
|||
} else { |
|||
values.datingClueId = datingClueId.value |
|||
await createAppointment(values) |
|||
createMessage.success(`新增成功!`) |
|||
} |
|||
emits('success') |
|||
} finally { |
|||
setModalProps({ confirmLoading: false }) |
|||
} |
|||
} |
|||
</script> |
|||
Write
Preview
Loading…
Cancel
Save