Files
ipms-sjy/yudao-ui-admin-vue3/src/views/bpm/oa/leave/create.vue

59 lines
1.7 KiB
Vue
Raw Normal View History

2023-01-21 20:25:45 +08:00
<template>
2023-01-21 21:30:17 +08:00
<ContentWrap>
<!-- 对话框(添加 / 修改) -->
<Form :schema="allSchemas.formSchema" :rules="rules" ref="formRef" />
<!-- 按钮保存 -->
<XButton
type="primary"
:title="t('action.save')"
:loading="actionLoading"
@click="submitForm"
/>
</ContentWrap>
2023-01-21 20:25:45 +08:00
</template>
<script setup lang="ts">
2023-01-21 21:30:17 +08:00
import { FormExpose } from '@/components/Form'
2023-02-01 15:18:59 +08:00
// import XEUtils from 'xe-utils'
2023-01-21 21:30:17 +08:00
// 业务相关的 import
import * as LeaveApi from '@/api/bpm/leave'
import { rules, allSchemas } from './leave.data'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const router = useRouter() // 路由
2023-01-21 20:25:45 +08:00
// 表单参数
2023-01-21 21:30:17 +08:00
const actionLoading = ref(false) // 按钮 Loading
const formRef = ref<FormExpose>() // 表单 Ref
2023-01-21 20:25:45 +08:00
2023-01-21 21:30:17 +08:00
// 提交按钮
const submitForm = async () => {
const elForm = unref(formRef)?.getElFormRef()
if (!elForm) return
elForm.validate(async (valid) => {
if (!valid) {
return
}
try {
// 设置提交中
actionLoading.value = true
const data = unref(formRef)?.formModel as LeaveApi.LeaveVO
2023-02-01 15:18:59 +08:00
// data.startTime = XEUtils.toDateString(data.startTime, 'yyyy-MM-dd HH:mm:ss')
// data.endTime = XEUtils.toDateString(data.endTime, 'yyyy-MM-dd HH:mm:ss')
data.startTime = Date.parse(new Date(data.startTime).toString())
data.endTime = Date.parse(new Date(data.endTime).toString())
2023-01-21 20:25:45 +08:00
// 添加的提交
2023-01-21 21:30:17 +08:00
await LeaveApi.createLeaveApi(data)
message.success(t('common.createSuccess'))
// 关闭窗口
2023-02-01 14:16:32 +08:00
router.push({
path: '/bpm/oa/leave'
2023-01-21 20:25:45 +08:00
})
2023-01-21 21:30:17 +08:00
} finally {
actionLoading.value = false
2023-01-21 20:25:45 +08:00
}
})
}
</script>