feat: 添加离职申请表
This commit is contained in:
parent
714ab23cd6
commit
84e447527a
|
|
@ -1,15 +1,18 @@
|
|||
<template>
|
||||
<el-container>
|
||||
<el-main class="nopadding">
|
||||
<el-form label-width="80px" :model="formData" style="padding: 20px;">
|
||||
<el-form-item label="员工信息" required>
|
||||
{{ formData.employee_name }}({{ formData.belong_dept_name }} - {{ formData.post_name }})
|
||||
</el-form-item>
|
||||
<el-form-item label="离职日期" required>
|
||||
<el-date-picker
|
||||
v-model="formData.resign_date"
|
||||
v-model="formData.end_date"
|
||||
type="date"
|
||||
placeholder="预计离职日期"
|
||||
style="width: 100%;"
|
||||
:readonly="mode === 'show'"
|
||||
value-format="YYYY-MM-DD"
|
||||
:readonly="localMode === 'show'"
|
||||
></el-date-picker>
|
||||
</el-form-item>
|
||||
<el-form-item label="离职原因" required>
|
||||
|
|
@ -18,58 +21,109 @@
|
|||
:rows="4"
|
||||
v-model="formData.reason"
|
||||
placeholder="请输入离职原因"
|
||||
:readonly="mode === 'show'"
|
||||
:readonly="localMode === 'show'"
|
||||
></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
</el-form>
|
||||
<el-footer>
|
||||
<ticketd_b
|
||||
:workflow_key="'resignation'"
|
||||
:title="formData.employee_name + '的离职申请'"
|
||||
:workflow_key="'wf_resignation'"
|
||||
:title="ticketTitle"
|
||||
:t_id="formData.id"
|
||||
:ticket_="formData.ticket_"
|
||||
@success="()=>{$emit('success')}"
|
||||
@success="$emit('success', localMode)"
|
||||
:submit_b_func="submit_b_func"
|
||||
ref="ticketd_b"
|
||||
></ticketd_b>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-footer>
|
||||
</el-main>
|
||||
<el-aside width="20%" v-if="formData.ticket_">
|
||||
<ticketd :ticket_="formData.ticket_" @success="$emit('success')"></ticketd>
|
||||
</el-aside>
|
||||
</el-container>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, defineProps } from 'vue'
|
||||
|
||||
<script>
|
||||
import ticketd_b from "@/views/wf/ticketd_b.vue";
|
||||
import ticketd from '@/views/wf/ticketd.vue'
|
||||
import API from '@/api'
|
||||
import TOOL from "@/utils/tool.js";
|
||||
|
||||
const props = defineProps({
|
||||
mode: { type: String, default: 'show' },
|
||||
t_id: { type: String, default: "" },
|
||||
});
|
||||
const formData = ref({});
|
||||
const mode = ref(props.mode);
|
||||
onMounted(async () =>{
|
||||
if(props.t_id){
|
||||
getTid();
|
||||
}else{
|
||||
let res = await API.hrm.employee.read.req();
|
||||
formData.value.employee_name = res.name;
|
||||
formData.value.belong_dept_name = res.belong_dept_name;
|
||||
formData.value.post_name = res.post_name;
|
||||
formData.value.employee = res.id;
|
||||
export default {
|
||||
name: 'ResignationForm',
|
||||
components: {
|
||||
ticketd_b,
|
||||
ticketd
|
||||
},
|
||||
props: {
|
||||
mode: {
|
||||
type: String,
|
||||
default: 'show'
|
||||
},
|
||||
t_id: {
|
||||
type: String,
|
||||
default: ""
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
formData: {
|
||||
employee_name: ""
|
||||
},
|
||||
localMode: this.mode,
|
||||
ticketTitle: "离职申请"
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
mode(newVal) {
|
||||
this.localMode = newVal;
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.t_id) {
|
||||
this.getTid();
|
||||
} else {
|
||||
this.initFormData();
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
async initFormData() {
|
||||
try {
|
||||
let res = await this.$API.hrm.employee.read.req();
|
||||
this.formData.employee_name = res.name;
|
||||
this.formData.belong_dept_name = res.belong_dept_name;
|
||||
this.formData.post_name = res.post_name;
|
||||
this.formData.employee = res.id;
|
||||
this.localMode = "add";
|
||||
} catch (error) {
|
||||
console.error('初始化表单数据失败:', error);
|
||||
}
|
||||
},
|
||||
async getTid() {
|
||||
try {
|
||||
let res = await this.$API.hrm.resignation.item.req(this.t_id);
|
||||
this.formData = res;
|
||||
if (res.ticket_ && res.ticket_.state_.type == 1 && res.create_by == this.$TOOL.data.get("USER_INFO").id) {
|
||||
this.localMode = "edit";
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取离职数据失败:', error);
|
||||
}
|
||||
},
|
||||
async submit_b_func() {
|
||||
if (this.localMode == "add") {
|
||||
try {
|
||||
let res = await this.$API.hrm.resignation.create.req(this.formData);
|
||||
this.ticketTitle = this.formData.employee_name + "的离职申请";
|
||||
this.formData.id = res.id;
|
||||
return res.id;
|
||||
} catch (error) {
|
||||
console.error('提交离职申请失败:', error);
|
||||
throw error;
|
||||
}
|
||||
} else if (this.localMode == "edit") {
|
||||
this.$message.error("不支持编辑");
|
||||
throw new Error("不支持编辑");
|
||||
}
|
||||
})
|
||||
const getTid = async () => {
|
||||
let res = await API.hrm.resignation.item.req(props.t_id);
|
||||
formData.value = res;
|
||||
if(res.ticket_.state_.type == 1 && res.create_by == TOOL.data.get("USER_INFO").id ) {
|
||||
mode.value = "edit";
|
||||
}else{
|
||||
mode.value = "show";
|
||||
}
|
||||
};
|
||||
const submit_b_func = async ()=>{
|
||||
if (mode.value == "add") {
|
||||
await API.hrm.resignation.create.req(formData.value);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
<el-footer>
|
||||
<el-button @click="$emit('closed')" style="margin-right: 4px">取消</el-button>
|
||||
<ticketd_b
|
||||
:workflow_key="'mroombooking.create'"
|
||||
:workflow_key="'booking'"
|
||||
:title="form.title+'-会议室预定'"
|
||||
:t_id="form.id"
|
||||
:ticket_="form.ticket_"
|
||||
|
|
|
|||
Loading…
Reference in New Issue