bpm:增加 OA 请假的创建

pull/2/head
YunaiV 2023-01-21 21:30:17 +08:00
parent fb06bc8357
commit 3e4d388e70
3 changed files with 66 additions and 89 deletions

View File

@ -27,7 +27,7 @@ public class BpmOALeaveBaseVO {
@ApiModelProperty(value = "请假类型", required = true, example = "1", notes = "参见 bpm_oa_type 枚举") @ApiModelProperty(value = "请假类型", required = true, example = "1", notes = "参见 bpm_oa_type 枚举")
private Integer type; private Integer type;
@ApiModelProperty(value = "原因", required = true, example = "阅读芋道源码") @ApiModelProperty(value = "原因", example = "阅读芋道源码")
private String reason; private String reason;
} }

View File

@ -1,89 +1,56 @@
<template> <template>
<div class="app-container"> <ContentWrap>
<el-form ref="createForm" :model="form" :rules="rules" label-width="80px"> <!-- 对话框(添加 / 修改) -->
<el-form-item label="开始时间" prop="startTime"> <Form :schema="allSchemas.formSchema" :rules="rules" ref="formRef" />
<el-date-picker clearable v-model="form.startTime" type="date" placeholder="选择开始时间" /> <!-- 按钮保存 -->
</el-form-item> <XButton
<el-form-item label="结束时间" prop="endTime"> type="primary"
<el-date-picker clearable v-model="form.endTime" type="date" placeholder="选择结束时间" /> :title="t('action.save')"
</el-form-item> :loading="actionLoading"
<el-form-item label="请假类型" prop="type"> @click="submitForm"
<el-select v-model="form.type" placeholder="请选择"> />
<el-option </ContentWrap>
v-for="dict in typeDictData"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
/>
</el-select>
</el-form-item>
<el-form-item label="原因" prop="reason">
<el-input
style="width: 650px"
type="textarea"
:rows="3"
v-model="form.reason"
placeholder="请输入原因"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="submitForm(createForm)"> </el-button>
</el-form-item>
</el-form>
</div>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive } from 'vue' import { ref } from 'vue'
import { import { FormExpose } from '@/components/Form'
ElInput, import XEUtils from 'xe-utils'
ElSelect,
ElOption, // import
ElForm, import * as LeaveApi from '@/api/bpm/leave'
ElFormItem, import { rules, allSchemas } from './leave.data'
ElMessage,
ElDatePicker const { t } = useI18n() //
} from 'element-plus' const message = useMessage() //
import type { FormInstance } from 'element-plus' const router = useRouter() //
import { createLeaveApi } from '@/api/bpm/leave'
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
import { useRouter } from 'vue-router'
const { push } = useRouter()
const createForm = ref()
// //
const form = ref({ const actionLoading = ref(false) // Loading
startTime: undefined, const formRef = ref<FormExpose>() // Ref
endTime: undefined,
type: undefined,
reason: undefined
})
//
const rules = reactive({
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
type: [{ required: true, message: '请假类型不能为空', trigger: 'change' }],
reason: [{ required: true, message: '请假原因不能为空', trigger: 'change' }]
})
const typeDictData = getDictOptions(DICT_TYPE.BPM_OA_LEAVE_TYPE)
const submitForm = async (formEl: FormInstance | undefined) => { //
if (!formEl) return const submitForm = async () => {
await formEl.validate((valid, fields) => { const elForm = unref(formRef)?.getElFormRef()
if (valid) { if (!elForm) return
console.log(form.value, 'submit!') elForm.validate(async (valid) => {
form.value.startTime = Date.parse(form.value.startTime) if (!valid) {
form.value.endTime = Date.parse(form.value.endTime) return
}
try {
//
actionLoading.value = true
const data = unref(formRef)?.formModel as LeaveApi.LeaveVO
data.startTime = XEUtils.toDateString(data.startTime, 'yyyy-MM-dd HH:mm:ss')
data.endTime = XEUtils.toDateString(data.endTime, 'yyyy-MM-dd HH:mm:ss')
// //
createLeaveApi(form.value).then((response) => { await LeaveApi.createLeaveApi(data)
console.log(response, 'response') message.success(t('common.createSuccess'))
ElMessage({ //
type: 'success', await router.push({
message: '发起成功' path: '/oa/leave/create'
})
push('/bpm/oa/leave')
}) })
} else { } finally {
console.log('error submit!', fields) actionLoading.value = false
} }
}) })
} }

View File

@ -1,14 +1,12 @@
import { reactive } from 'vue'
import { DICT_TYPE } from '@/utils/dict'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas' import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
// 国际化
const { t } = useI18n() const { t } = useI18n() // 国际化
// 表单校验 // 表单校验
export const rules = reactive({ export const rules = reactive({
startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }], startTime: [{ required: true, message: '开始时间不能为空', trigger: 'blur' }],
endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }], endTime: [{ required: true, message: '结束时间不能为空', trigger: 'blur' }],
type: [{ required: true, message: '请假类型不能为空', trigger: 'change' }], type: [{ required: true, message: '请假类型不能为空', trigger: 'change' }]
reason: [{ required: true, message: '请假原因不能为空', trigger: 'change' }]
}) })
// crudSchemas // crudSchemas
@ -24,7 +22,8 @@ const crudSchemas = reactive<VxeCrudSchema>({
field: 'result', field: 'result',
dictType: DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT, dictType: DICT_TYPE.BPM_PROCESS_INSTANCE_RESULT,
dictClass: 'number', dictClass: 'number',
isSearch: true isSearch: true,
isForm: false
}, },
{ {
title: t('common.startTimeText'), title: t('common.startTimeText'),
@ -35,6 +34,9 @@ const crudSchemas = reactive<VxeCrudSchema>({
}, },
detail: { detail: {
dateFormat: 'YYYY-MM-DD' dateFormat: 'YYYY-MM-DD'
},
form: {
component: 'DatePicker'
} }
}, },
{ {
@ -46,11 +48,14 @@ const crudSchemas = reactive<VxeCrudSchema>({
}, },
detail: { detail: {
dateFormat: 'YYYY-MM-DD' dateFormat: 'YYYY-MM-DD'
},
form: {
component: 'DatePicker'
} }
}, },
{ {
title: '请假类型', title: '请假类型',
field: 'result', field: 'type',
dictType: DICT_TYPE.BPM_OA_LEAVE_TYPE, dictType: DICT_TYPE.BPM_OA_LEAVE_TYPE,
dictClass: 'number', dictClass: 'number',
isSearch: true isSearch: true
@ -58,7 +63,11 @@ const crudSchemas = reactive<VxeCrudSchema>({
{ {
title: '原因', title: '原因',
field: 'reason', field: 'reason',
isSearch: true isSearch: true,
componentProps: {
type: 'textarea',
rows: 4
}
}, },
{ {
title: '申请时间', title: '申请时间',
@ -73,7 +82,8 @@ const crudSchemas = reactive<VxeCrudSchema>({
itemRender: { itemRender: {
name: 'XDataTimePicker' name: 'XDataTimePicker'
} }
} },
isForm: false
} }
] ]
}) })