cxc-szcx-uniapp/pages/leave/application.vue

385 lines
9.2 KiB
Vue
Raw Normal View History

2024-09-14 02:26:50 +00:00
<template>
<view :class="{'gray':store.isgray==1}">
<view class="form">
2024-09-24 09:21:34 +00:00
<view class="f-row aic jcb input_box">
<view class="title">
职工姓名
2024-09-14 02:26:50 +00:00
</view>
2024-09-24 09:21:34 +00:00
<input v-model="realname" disabled />
</view>
<view class="f-row aic jcb input_box">
<view class="title">
工作单位
2024-09-14 02:26:50 +00:00
</view>
2024-09-24 09:21:34 +00:00
<input v-model="depart" disabled />
</view>
<view class="f-row aic jcb input_box">
<view class="title">
联系方式
</view>
<input v-model="phone" />
</view>
<view class="f-row aic jcb input_box">
<view class="title">
请假类型
</view>
2024-09-26 04:06:47 +00:00
<tree-select :dataSource="dataSource" v-model="type" dataValue="name" />
2024-09-24 09:21:34 +00:00
</view>
2025-01-07 01:44:59 +00:00
<picker mode="date" fields="day" @change="chooseStart" :value="beginTime" :end="endTime">
2024-09-14 02:26:50 +00:00
<view class="f-row aic jcb box">
<view class="title">
开始时间
</view>
<view class="f-row aic">
2024-09-24 09:21:34 +00:00
<view :class="[{'choose':!beginTime},{'choosed':beginTime}]">
{{beginTime?beginTime:'请选择'}}
2024-09-14 02:26:50 +00:00
</view>
2024-09-24 09:21:34 +00:00
<uni-icons type="bottom" color="#333333"></uni-icons>
2024-09-14 02:26:50 +00:00
</view>
</view>
</picker>
2025-01-06 02:44:29 +00:00
<picker mode="date" fields="day" @change="chooseEnd" :value="endTime" :start="beginTime">
2024-09-14 02:26:50 +00:00
<view class="f-row aic jcb box">
<view class="title">
2024-10-12 00:53:10 +00:00
截止时间
2024-09-14 02:26:50 +00:00
</view>
<view class="f-row aic">
2024-09-24 09:21:34 +00:00
<view :class="[{'choose':!endTime},{'choosed':endTime}]">
{{endTime?endTime:'请选择'}}
2024-09-14 02:26:50 +00:00
</view>
2024-09-24 09:21:34 +00:00
<uni-icons type="bottom" color="#333333"></uni-icons>
2024-09-14 02:26:50 +00:00
</view>
</view>
</picker>
2024-10-12 00:53:10 +00:00
<picker @change="bindType" :value="typeIndex" :range="typeArr" range-key="realname" v-if="ifShow">
<view class="f-row aic jcb box">
<view class="title">
审批领导
</view>
<view class="f-row aic">
<view :class="[{'choose':typeIndex==null},{'choosed':typeIndex!=null}]">
{{typeIndex!=null?typeArr[typeIndex].realname:'请选择'}}
</view>
<uni-icons type="bottom" color="#333333"></uni-icons>
</view>
</view>
</picker>
2024-09-14 02:26:50 +00:00
<view class="f-row aic jcb input_box">
<view class="title">
2024-11-12 08:16:01 +00:00
出发地
2024-09-14 02:26:50 +00:00
</view>
2024-11-12 08:16:01 +00:00
<input v-model="departure" placeholder="请输入" nplaceholder-style="font-size: 28rpx;color: #999999;" />
</view>
<view class="f-row aic jcb input_box">
<view class="title">
目的地
</view>
<input v-model="destination" placeholder="请输入" nplaceholder-style="font-size: 28rpx;color: #999999;" />
2024-09-14 02:26:50 +00:00
</view>
2024-10-14 07:22:41 +00:00
<view class="f-row aic jcb input_box">
<view class="title">
请假事由
</view>
<input v-model="reason" placeholder="请输入" placeholder-style="font-size: 28rpx;color: #999999;" />
</view>
<view class="f-row aic jcb input_box">
<view class="title">
上传附件
</view>
2024-11-12 08:16:01 +00:00
<uni-file-picker @select="select" :image-styles="imageStyles" />
2024-09-14 02:26:50 +00:00
</view>
</view>
2024-10-14 07:22:41 +00:00
2024-09-14 02:26:50 +00:00
<view class="btn f-col aic">
2024-09-24 09:21:34 +00:00
<view @click="qjAdd">
2024-09-14 02:26:50 +00:00
提交
</view>
</view>
</view>
</template>
<script setup>
import {
ref,
getCurrentInstance
} from 'vue';
import {
startMutilProcessApi,
2024-10-12 00:53:10 +00:00
getCategoryItemsApi,
2024-09-19 07:12:58 +00:00
} from '@/api/api.js';
2024-10-12 00:53:10 +00:00
import {
qjAddApi,
2025-02-07 02:26:15 +00:00
queryZwmcAndExaApi,
queryHisDateApi
2024-10-12 00:53:10 +00:00
} from '@/api/pages.js';
2024-09-24 09:21:34 +00:00
import {
2024-12-06 01:00:15 +00:00
queryDepByCode,
queryZbDepByLdhth
2024-09-24 09:21:34 +00:00
} from '@/api/depart.js'
2024-09-14 02:26:50 +00:00
import {
onLoad
} from '@dcloudio/uni-app'
import {
useStore
} from '@/store';
2024-09-24 09:21:34 +00:00
import treeSelect from "@/components/treeSelect/treeSelect.vue"
2024-09-14 02:26:50 +00:00
const store = useStore()
const {
proxy
} = getCurrentInstance()
2024-09-24 09:21:34 +00:00
/**职工姓名*/
const realname = ref(store.userinfo.realname)
/**工作单位*/
const depart = ref('')
2024-12-06 01:00:15 +00:00
/**工作单位*/
const orgCode = ref('')
2024-09-24 09:21:34 +00:00
/**联系方式*/
const phone = ref(store.userinfo.phone)
/**请假类型*/
const type = ref('')
const dataSource = ref([])
/**开始时间*/
const beginTime = ref('')
2024-09-14 02:26:50 +00:00
const chooseStart = (e) => {
2024-09-24 09:21:34 +00:00
beginTime.value = e.detail.value
2024-09-14 02:26:50 +00:00
}
2024-09-24 09:21:34 +00:00
/**结束时间*/
const endTime = ref('')
2024-09-14 02:26:50 +00:00
const chooseEnd = (e) => {
2024-09-24 09:21:34 +00:00
endTime.value = e.detail.value
2024-09-14 02:26:50 +00:00
}
2024-10-12 00:53:10 +00:00
/**审批领导*/
const typeArr = ref([])
const typeIndex = ref(null)
/**判断是否显示审批领导字段*/
const ifShow = ref(true)
/**职位层级*/
const zwcj = ref('')
2024-11-12 08:16:01 +00:00
/**出发地*/
const departure = ref('')
/**目的地*/
const destination = ref('')
2024-09-24 09:21:34 +00:00
/**请假事由*/
const reason = ref('')
2024-10-14 07:22:41 +00:00
/**附件路径*/
const path = ref([])
const baseUrl = import.meta.env.VITE_REQUEST_BASE_URL + '/jeecg-boot/sys/common/upload/'
const imageStyles = {
width: 64,
height: 64,
border: {
color: "#dce7e1",
width: 2,
style: 'dashed',
radius: '2px'
}
}
2024-09-24 09:21:34 +00:00
onLoad(() => {
loadData()
2025-02-07 02:26:15 +00:00
// getTomorrowDate()
2024-09-24 09:21:34 +00:00
})
2024-10-14 07:22:41 +00:00
const select = (e) => {
const tempFilePaths = e.tempFilePaths
for (let i = 0; i < e.tempFilePaths.length; i++) {
2024-12-06 01:00:15 +00:00
let photoPath = '职工请假/' + depart.value + '/' + store.userinfo.realname
2024-10-14 07:22:41 +00:00
uni.uploadFile({
url: baseUrl,
filePath: e.tempFilePaths[i],
name: 'file',
formData: {
appPath: photoPath
},
success: (res) => {
path.value.push(JSON.parse(res.data).message)
}
});
}
}
2024-09-14 02:26:50 +00:00
const qjAdd = () => {
2024-09-24 09:21:34 +00:00
if (!phone.value.trim()) return proxy.$toast('请输入联系方式')
if (!type.value) return proxy.$toast('请选择请假类型')
if (!beginTime.value) return proxy.$toast('请选择开始时间')
if (!endTime.value) return proxy.$toast('请选择结束时间')
2024-10-12 01:14:27 +00:00
if (ifShow.value) {
2024-10-12 00:53:10 +00:00
if (typeIndex.value == null) { //副职、员工需要选择审批领导
return proxy.$toast('请选择审批领导')
}
}
2024-11-12 08:16:01 +00:00
if (!departure.value.trim()) return proxy.$toast('请输入出发地')
if (!destination.value.trim()) return proxy.$toast('请输入目的地')
2024-09-14 02:26:50 +00:00
if (!reason.value.trim()) return proxy.$toast('请输入请假事由')
2025-01-06 02:44:29 +00:00
2024-09-14 02:26:50 +00:00
qjAddApi({
2024-12-06 01:00:15 +00:00
sysOrgCode: orgCode.value,
2024-09-24 09:21:34 +00:00
username: store.userinfo.username,
phone: phone.value,
type: type.value,
begintime: beginTime.value,
endtime: endTime.value,
2024-12-06 01:00:15 +00:00
examineleader: typeArr.value[typeIndex.value] ? typeArr.value[typeIndex.value].username : '',
2024-11-12 08:16:01 +00:00
departure: departure.value,
destination: destination.value,
2024-10-12 00:53:10 +00:00
reason: reason.value,
2024-10-14 07:22:41 +00:00
zwmc: zwcj.value,
path: path.value.toString()
2024-09-14 02:26:50 +00:00
}).then((res) => {
if (res.success) {
startMutilProcess(res.message)
2024-09-26 04:06:47 +00:00
} else {
proxy.$toast(res.message);
2024-09-14 02:26:50 +00:00
}
})
}
2024-10-14 07:22:41 +00:00
2024-09-14 02:26:50 +00:00
const startMutilProcess = (id) => {
startMutilProcessApi({
2024-10-12 00:53:10 +00:00
flowCode: "dev_cxc_qxj",
2024-09-14 02:26:50 +00:00
id,
2024-10-12 00:53:10 +00:00
formUrl: "modules/qxj/modules/CxcQxjBpmModel",
2024-09-24 09:21:34 +00:00
formUrlMobile: "leaveApplication" //对应main.js里全局注册createApp()里的 app.component('leaveApplication',index)
2024-09-14 02:26:50 +00:00
}).then((res) => {
if (res.success) {
proxy.$toast(res.message)
setTimeout(() => {
uni.navigateBack()
}, 2000)
}
}).catch((err) => {
console.log(err);
})
}
2024-09-24 09:21:34 +00:00
const loadData = () => {
2024-09-26 04:06:47 +00:00
getCategoryItemsApi('1838487445813645313').then((res) => { //请假类型
2024-09-14 02:26:50 +00:00
if (res.success) {
2024-09-24 09:21:34 +00:00
dataSource.value = res.result
2024-09-14 02:26:50 +00:00
}
})
2024-09-26 04:06:47 +00:00
2024-12-06 01:00:15 +00:00
queryZbDepByLdhth(store.userinfo.workNo).then((res) => { //获取工作单位
depart.value = res.departName
orgCode.value = res.orgCode
2024-09-24 09:21:34 +00:00
})
2024-09-26 04:06:47 +00:00
2024-10-12 00:53:10 +00:00
queryZwmcAndExaApi(store.userinfo.username).then((res) => { //本人职位及审批领导列表
if (res.success) {
typeArr.value = res.result.list
zwcj.value = res.result.zwmc
2024-12-03 02:52:17 +00:00
if (zwcj.value == '单位专家' || zwcj.value == '基层正职' || zwcj.value == '高级主管') {
2024-10-12 00:53:10 +00:00
ifShow.value = false;
}
} else {
proxy.$toast(res.message);
}
})
2025-02-07 02:26:15 +00:00
queryHisDateApi(store.userinfo.username).then((res) => { // 最新请假结束日期
if (res) {
console.log('--0', res)
getTomorrowDate(res);
} else {
console.log('--1', res)
getTomorrowDate();
}
})
2024-10-12 00:53:10 +00:00
}
const bindType = (e) => {
typeIndex.value = e.detail.value
2024-09-14 02:26:50 +00:00
}
2024-11-12 08:16:01 +00:00
2025-02-07 02:26:15 +00:00
const getTomorrowDate = (e) => {
let tomorrow;
if (e) {
// 将传入的日期字符串转换为Date对象
const dateParts = e.split('-').map(Number);
tomorrow = new Date(dateParts[0], dateParts[1] - 1, dateParts[2]);
} else {
// 如果没有提供日期,则使用当前日期
tomorrow = new Date();
}
// 设置为明天的日期
tomorrow.setDate(tomorrow.getDate() + 1);
// 格式化日期
const year = tomorrow.getFullYear();
const month = (tomorrow.getMonth() + 1).toString().padStart(2, '0');
const day = tomorrow.getDate().toString().padStart(2, '0');
beginTime.value = `${year}-${month}-${day}`;
2024-11-12 08:16:01 +00:00
}
2024-09-14 02:26:50 +00:00
</script>
<style>
page {
background-color: #fff;
}
</style>
<style lang="scss" scoped>
.btn {
border-top: 1px solid #EFEFEF;
height: 120rpx;
justify-content: center;
position: fixed;
bottom: 0;
width: 100vw;
view {
width: 690rpx;
height: 88rpx;
background: #01508B;
border-radius: 16rpx;
font-size: 28rpx;
color: #FFFFFF;
text-align: center;
line-height: 88rpx;
}
}
.input_box {
height: 100rpx;
.title {
font-size: 28rpx;
color: #333333;
}
input {
flex: 1;
height: 100%;
text-align: right;
font-size: 28rpx;
color: #333333;
}
}
.form {
padding: 0 30rpx;
background-color: #fff;
.title {
font-size: 28rpx;
color: #333333;
}
.box {
height: 100rpx;
}
.box:not(:last-child) {
border-bottom: 1px solid #EFEFEF;
}
.choose {
font-size: 28rpx;
color: #999999;
}
.choosed {
font-size: 28rpx;
color: #333333;
}
}
</style>