123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- <template>
- <xn-form-container
- :title="formData.id ? '编辑停车费配置' : '增加停车费配置'"
- :width="700"
- v-model:open="open"
- :destroy-on-close="true"
- @close="onClose"
- >
- <a-form ref="formRef" :model="formData" :rules="formRules" :wrapper-col="wrapperCol" :label-col="labelCol">
- <a-form-item label="预约类型:" name="appointmentType">
- <a-radio-group button-style="solid" v-model:value="formData.appointmentType">
- <a-radio-button v-for="appointmentItem in appointmentClassifyOptions" :key="appointmentItem.value" :value="appointmentItem.value" >
- {{ appointmentItem.label }}
- </a-radio-button>
- </a-radio-group>
- </a-form-item>
- <a-form-item label="免费停留时长(分钟):" name="freeParkTime">
- <a-input-number v-model:value="formData.freeParkTime" :min="0" style="width: 100%;" placeholder="请输入免费停留时长" allow-clear />
- </a-form-item>
- <a-form-item label="超出费用(元/小时):" name="exceedAmount">
- <a-input-number v-model:value="formData.exceedAmount" :min="0" style="width: 100%;" placeholder="请输入超出每小时费用" allow-clear />
- </a-form-item>
- <a-form-item label="支付后停留时长(分钟):" name="payAfterParkTime">
- <a-input-number v-model:value="formData.payAfterParkTime" :min="0" style="width: 100%;" placeholder="请输入支付后停留时长" allow-clear />
- </a-form-item>
- </a-form>
- <template #footer>
- <a-button style="margin-right: 8px" @click="onClose">关闭</a-button>
- <a-button type="primary" @click="onSubmit" :loading="submitLoading">保存</a-button>
- </template>
- </xn-form-container>
- </template>
- <script setup name="bizParkConfigForm">
- import { cloneDeep } from 'lodash-es'
- import { required } from '@/utils/formRules'
- import bizParkConfigApi from '@/api/biz/bizParkConfigApi'
- import tool from '@/utils/tool'
- // 抽屉状态
- const open = ref(false)
- const emit = defineEmits({ successful: null })
- const formRef = ref()
- // 表单数据
- const formData = ref({})
- const submitLoading = ref(false)
- //设置表单样式
- const labelCol = ref({ span: 6})
- const wrapperCol = ref({ span: 16})
- // 预约分类
- const appointmentClassifyOptions = tool.dictList('appointment_classify')
- // 打开抽屉
- const onOpen = (record) => {
- open.value = true
- if (record) {
- let recordData = cloneDeep(record)
- formData.value = Object.assign({}, recordData)
- }
- }
- // 关闭抽屉
- const onClose = () => {
- formRef.value.resetFields()
- formData.value = {}
- open.value = false
- }
- // 默认要校验的
- const formRules = {
- appointmentType: [required('请选择预约类型')],
- freeParkTime: [required('请输入免费停留时长')],
- exceedAmount: [required('请输入超出每小时费用')],
- payAfterParkTime: [required('请输入支付后停留时长')],
- }
- // 验证并提交数据
- const onSubmit = () => {
- formRef.value
- .validate()
- .then(() => {
- submitLoading.value = true
- const formDataParam = cloneDeep(formData.value)
- bizParkConfigApi
- .bizParkConfigSubmitForm(formDataParam, formDataParam.id)
- .then(() => {
- onClose()
- emit('successful')
- })
- .finally(() => {
- submitLoading.value = false
- })
- })
- .catch(() => {})
- }
- // 抛出函数
- defineExpose({
- onOpen
- })
- </script>
|