factory_mp/pages/hrm/empneed_form.vue

194 lines
6.5 KiB
Vue

<!-- 离职申请 -->
<template>
<view class="container">
<scroll-view scroll-y style="padding-bottom: 180rpx;background-color: #fff;">
<uni-forms v-model="form" label-width="150rpx" ref="customForm" :rules="customRules">
<ticketd :ticket_="form.ticket_"></ticketd>
<uni-forms-item label="部门">
<uni-easyinput v-model="form.belong_dept_name" placeholder="请输入岗位" :disabled="true" v-if="mode!='show'"/>
<span v-else>{{form.belong_dept_name}}</span>
</uni-forms-item>
<uni-forms-item label="员工信息">
<span>{{form.employee_name}}</span>
</uni-forms-item>
<uni-forms-item label="需求岗位">
<uni-easyinput v-model="form.post_name" placeholder="请输入需求岗位" :disabled="true" v-if="mode!='show'"/>
<span v-else>{{form.post_name}}</span>
</uni-forms-item>
<uni-forms-item label="需求人数" required>
<uni-number-box v-model="form.count_need" :min="0" v-if="mode!='show'"></uni-number-box>
<span v-else>{{form.count_need}}</span>
</uni-forms-item>
<uni-forms-item label="工资报酬" required>
<uni-number-box v-model="form.salary" :min="0" v-if="mode!='show'"></uni-number-box>
<span v-else>{{form.salary}}</span>
</uni-forms-item>
<uni-forms-item label="性别要求" required>
<uni-data-checkbox
v-model="form.gender"
:localdata="genderList"
v-if="mode!='show'"/>
<span v-else>{{ getLabel(genderList, form.gender) }}</span>
</uni-forms-item>
<uni-forms-item label="学历要求" required>
<uni-data-select
v-if="mode!='show'"
v-model="form.education"
:localdata="educationList"
:disabled="mode=='show'"
@change="educationChange"
></uni-data-select>
<span v-else>{{getLabel(educationList,form.education) }}</span>
</uni-forms-item>
<uni-forms-item label="到岗日期" required>
<uni-datetime-picker type="date" :clear-icon="false" v-model="form.arrival_date" v-if="mode!='show'"/>
<span v-else>{{form.arrival_date}}</span>
</uni-forms-item>
<uni-forms-item label="申请理由" required>
<uni-data-checkbox v-model="form.reason" :localdata="reasonList" placeholder="请选择申请描述" v-if="mode!='show'"></uni-data-checkbox>
<span v-else>{{getLabel(reasonList,form.reason)}}</span>
</uni-forms-item>
<uni-forms-item label="职责描述" required>
<uni-easyinput v-model="form.duty" placeholder="请输入职责描述" v-if="mode!='show'"/>
<span v-else>{{form.duty}}</span>
</uni-forms-item>
<uni-forms-item label="相关专业及技能要求">
<textarea placeholder-style="color:#efefef" v-model="form.professional_requirement" placeholder="相关专业及技能要求" v-if="mode!='show'" style="width:100%; border: 2upx solid #e5e5e5;padding: 10upx;"/>
<span v-else>{{form.professional_requirement}}</span>
</uni-forms-item>
</uni-forms>
</scroll-view>
<view class="footer_fixed">
<button v-if="mode=='edit'" size="mini" @click="handleDel" :loading="saveLoading" :disabled="saveLoading" type="warn">
删除
</button>
<button v-if="mode!='show'" size="mini" @click="handleSave" :loading="saveLoading" :disabled="saveLoading" type="primary">
提交审批
</button>
<ticketd_b :workflow_key="'wf_empneed'" v-if="form.ticket_ && mode == 'show'" :t_id="form.id" :ticket_="form.ticket_"
:ticket_data="ticket_data" @success="()=>{uni.navigateBack()}" ref="ticketd_b"></ticketd_b>
</view>
</view>
</template>
<script>
import ticketd_b from "../wf/ticketd_b.vue"
import ticketd from "../wf/ticketd.vue"
import {actStateEnum} from "@/utils/enum.js"
export default {
components: { ticketd_b, ticketd },
data(){
return{
saveLoading: false,
mode:"show",
t_id: null,
form:{
count_need: 0, // 👈 默认 0
salary: 0,
},
ticket_data:{},
userInfo:{},
type:0,
genderList: [
{text: '男',value: 1},
{text: '女',value: 2},
{text: '不限',value: 0},
],
educationList: [
{ value: 0, text: '不限' },
{ value: 1, text: '高中/中专' },
{ value: 2, text: '大专' },
{ value: 3, text: '本科' },
{ value: 4, text: '硕士及以上' }
],
reasonList:[
{ value: 0, text: '新增人员' },
{ value: 1, text: '高中该岗原人员离职或辞职或辞退需补充' },
{ value: 2, text: '其他原因' },
],
header:"",
customRules: {
count_need: {
rules: [{
required: true,
errorMessage: '不能为空'
}]
}
},
}
},
async onLoad(options) {
let that = this;
that.mode = options.mode?options.mode:'show';
that.t_id = options.t_id?options.t_id:null;
if(that.t_id) {
const res = await that.$api.empneedItem(that.t_id);
this.form = res
await this.fillNames()
if(that.form.ticket_.state_.type == 1 && that.form.create_by == uni.getStorageSync("userInfo").id ) {
that.mode = "edit";
}else{
that.mode = "show";
}
}
else{
that.getEmployee();
}
},
methods:{
async fillNames(){
const employee = await this.$api.employeeInfo()
this.form.employee_name = employee.name
this.form.belong_dept_name = employee.belong_dept_name
this.form.post_name = employee.post_name
},
async getEmployee(){
let res = await this.$api.employeeInfo();
this.form.employee_name = res.name;
this.form.dept_need = res.belong_dept;
this.form.post_need = res.post;
this.form.belong_dept_name = res.belong_dept_name;
this.form.post_name = res.post_name;
this.form.employee = res.id;
this.mode = "add";
},
async handleDel(){
let that = this;
await that.$api.empneedDelete(that.form.id)
uni.navigateBack()
},
async handleSave(){
let that = this;
that.$refs.customForm.validate().then(res => {
}).catch(err => {
console.log('err', err);
})
await that.$api.empneedCreate(that.form)
uni.navigateBack()
},
getLabel(list, value) {
if (!list || value === undefined || value === null) return ''
const item = list.find(i => String(i.value) === String(value))
return item ? item.text : ''
},
educationChange(val) {
const item = this.educationList.find(i => i.value === val)
this.form.education_name = item ? item.text : ''
},
}
}
</script>
<style scoped>
.uni-data-checklist .checklist-group .checklist-box{
margin: 10px 0!important;
}
.flex_file_picker>.uni-file-picker__files{
flex-direction: row;
}
.flex_file_picker{
width: 90px;
flex: none;
}
</style>