123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618 |
- <template>
- <view class="content">
- <view class="" v-if="value==0">
- <view class='wrap'>
- <view class="c-row">
- <view class="title">请假类型</view>
- <view class="con-list">
- <view @click='show=true'>{{detailData.leaveType}} ></view>
- <u-picker :range="leaveTypeList" range-key="leaveType" @confirm='ltCheck($event)' v-model="show"
- mode="selector">
- </u-picker>
- </view>
- </view>
- <view class="c-row">
- <view class="title">开始时间</view>
- <view class="con-list">
- <view @click='show1=true'>{{detailData.startDate}} ></view>
- <u-picker v-model="show1" mode="time" @confirm='dateChange($event)' :params="params">
- </u-picker>
- </view>
- </view>
- <view class="c-row">
- <view class="title">结束时间</view>
- <view class="con-list">
- <view @click='show2=true'>{{detailData.endDate}} ></view>
- <u-picker v-model="show2" mode="time" @confirm='dateChange1($event)' :params="params">
- </u-picker>
- </view>
- </view>
- <view class="c-row">
- <view class="title">时长</view>
- <view class="con-list">
- <input v-model='detailData.leaveDuration' placeholder="请输入时长"></input>
- </view>
- </view>
- <view class="c-row">
- <view class="left">请假事由</view>
- </view>
- <view style='position:relative;' class="wrap no-boder">
- <u-input class='textarea' v-model="detailData.reasonForLeave" :type="type" :border="border"
- :height="height" :auto-height="autoHeight" maxlength="100" />
- <view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
- {{detailData.reasonForLeave.length}}/100个字
- </view>
- </view>
- <view style='margin:5px 0;'>
- <u-button type="primary" class="submit" hover-class="none" @click="submit">提交</u-button>
- </view>
- </view>
- </view>
- <view class="" v-else>
- <view class='wrap' v-for="(item, index) in tableData" :key="index">
- <view class="wenzi audit1" v-if="item.approveStatus == '待人事审核'">待人事审核
- </view>
- <view class="wenzi audit1" v-if="item.approveStatus == '待主管审核'">待主管审核
- </view>
- <view class="wenzi audit1" v-if="item.approveStatus == '待决策人审核'">待决策人审核
- </view>
- <view class="wenzi audit2" v-if="item.status == '已通过'">已通过</view>
- <view class="wenzi audit3" v-if="item.status == '未通过'">未通过</view>
- <view class="c-row">
- <view class="title">请假类型 : {{item.leaveType}}</view>
- </view>
- <view class="c-row">
- <view class="title">请假事由 : {{item.reasonForLeave}}</view>
- </view>
- <view class="c-row">
- <view class="title">开始时间 : {{item.startDate}}</view>
- </view>
- <view class="c-row">
- <view class="title">结束时间 : {{item.endDate}}</view>
- </view>
- </view>
- <view v-show="isLoadMore">
- <uni-load-more :status="loadStatus"></uni-load-more>
- </view>
- <view class="bottom-btn">
- <view>
- <view style='width:100%;' class='flex flex-space-between'>
- <view @click='clocksubmit' style='width:50%;text-align:center;'>
- <image v-if='value==0' class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/qingjia-check.png"></image>
- <image v-else class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/qingjia.png"></image>
- <view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
- </view>
- <view @click='clockRecord' style='width:50%;text-align:center;'>
- <image v-if='value==1' class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/jilu-check.png"></image>
- <image v-else class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/jilu.png"></image>
- <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
- </view>
- </view>
- </view>
- <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
- </view>
- </view>
- <u-toast ref="uToast" />
- <view class="bottom-btn">
- <view>
- <view style='width:100%;' class='flex flex-space-between'>
- <view @click='clocksubmit' style='width:50%;text-align:center;'>
- <image v-if='value==0' class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/qingjia-check.png"></image>
- <image v-else class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/qingjia.png"></image>
- <view :style='{"color":value==0?"#22C572":"#000"}'>请假</view>
- </view>
- <view @click='clockRecord' style='width:50%;text-align:center;'>
- <image v-if='value==1' class="u-page__item__slot-icon"
- src="../../static/img/oa_office/leave/jilu-check.png"></image>
- <image v-else class="u-page__item__slot-icon" src="../../static/img/oa_office/leave/jilu.png">
- </image>
- <view :style='{"color":value==1?"#22C572":"#000"}'>记录</view>
- </view>
- </view>
- </view>
- <!-- <u-button type="primary" class="submit" hover-class="none" @click="clockRecord">记录</u-button> -->
- </view>
- </view>
- </template>
- <script>
- import dRili from '@/components/d-rili/d-rili.vue';
- export default {
- components: {
- dRili
- },
- data() {
- return {
- isLoadMore: false, //是否加载中
- loadStatus: 'loading', //加载样式:more-加载前样式,loading-加载中样式,nomore-没有数据样式
- pageSize: 10,
- currentPage: 1,
- show: false,
- show1: false,
- show2: false,
- isFreeTime: true,
- detailData: {
- leaveType: '选择请假类型',
- reasonForLeave: "",
- startDate: '',
- endDate: '选择结束时间',
- leaveDuration: '',
- },
- params: {
- year: true,
- month: true,
- day: true,
- hour: true,
- minute: true,
- },
- value: 0,
- type: 'textarea',
- border: true,
- height: 150,
- autoHeight: true,
- // endDate1:"",
- // startDate1: "",
- leaveTypeList: [{
- leaveType: "事假"
- },
- {
- leaveType: "病假"
- },
- ],
- startDate:"",
- endDate:"",
- beginTime:"",
- endTime:"",
- days:"",
- hours:"",
- date:"",
- stWorkTime:"",
- enWrokTime:"",
- freeTimeMon:"",
- freeTimeAft:"",
- freeTime:"",
- }
- },
- onReachBottom() { //上拉触底函数
- if (!this.isLoadMore) { //此处判断,上锁,防止重复请求
- this.isLoadMore = true
- this.currentPage += 1
- this.getList()
- }
- },
- onLoad(options) {
- let h
- let m
- let s
- let _day = new Date();
- _day.setTime(_day.getTime());
- if (_day.getHours() < 10) {
- h = "0" + _day.getHours()
- } else {
- h = _day.getHours()
- }
- if (_day.getMinutes() < 10) {
- m = "0" + _day.getMinutes()
- } else {
- m = _day.getMinutes()
- }
- this.detailData.startDate = _day.getFullYear() + "-" + (_day.getMonth() + 1) + "-" + _day.getDate() +
- " " + h + ":" + m;
- },
- onShow() {
- this.getList()
- },
- methods: {
- getList() {
- this.$api.doRequest('get', '/leaveInfo/selectLeaveInfo', {
- pageSize: this.pageSize,
- currentPage: this.currentPage,
- pcFlag: 0,
- compId: uni.getStorageSync('pcUserInfo').compId,
- commonId: uni.getStorageSync('pcUserInfo').userId,
- }).then(res => {
- // if (res.data.code == 200) {
- // this.tableData = res.data.data.records
- // }
- if (res.data.code == 200) {
- if (res.data.data.records.length > 0) {
- this.isLoadMore = false
- this.loadStatus = 'loading'
- } else {
- this.isLoadMore = true
- this.loadStatus = 'nomore'
- }
- if (this.currentPage == 1) {
- this.tableData = res.data.data.records
- } else {
- this.tableData = this.tableData.concat(res.data.data.records)
- }
- }
- })
- },
- calculate() {
- const query = uni.createSelectorQuery().in(this);
- query.selectAll('.left')
- console.log(query)
- },
- ltCheck(e) {
- this.detailData.leaveType = this.leaveTypeList[e].leaveType
- if (this.detailData.leaveType == "事假") {
- this.detailData.leaveTypeKey = "1"
- } else {
- this.detailData.leaveTypeKey = "3"
- }
- },
- /**
- * 计算请假时长
- * beginTime 开始时间
- * endTime 结束时间
- * stWorkTime 上班时间
- * enWrokTime 下班时间
- * isFreeTime 是否要去除午休工作时长
- * freeTimeMon 午休开始时间
- * freeTimeAft 午休结束时间
- *
- */
- dateChange(e) {
- this.detailData.startDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
- },
- diffDay(earlyDate,lastDate){
- return (Date.parse(lastDate) - Date.parse(earlyDate))/1000/60/60/24 +1;
- },
- dateChange1(e) {
- this.detailData.endDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
- var days;
- var hours;
- var date;
- var freeTimeAft =13 ;
- var freeTimeMon = 12;
- var stWorkTime = 8;
- var enWrokTime = 17;
- var isFreeTime = true;
- var freeTime = freeTimeAft - freeTimeMon;
- var beginTime = (this.detailData.startDate).replace(/-/g, '/');
- var beginArr = beginTime.split(" ");
- var beginMonth = parseInt(beginArr[0].split("/")[1]);
- var beginDay = parseInt(beginArr[0].split("/")[2]);
- var beginHours = parseInt(beginArr[1].split(":")[0]);
- var beginMin = parseInt(beginArr[1].split(":")[1]);
- var beginHoursMin = beginHours + beginMin / 60;
- var endTime = (this.detailData.endDate).replace(/-/g, '/');
- var endArr = endTime.split(" ");
- var endMonth = parseInt(endArr[0].split("/")[1]);
- var endDay = parseInt(endArr[0].split("/")[2]);
- var endHours = parseInt(endArr[1].split(":")[0]);
- var endMin = parseInt(endArr[1].split(":")[1]);
- var endHoursMin = endHours + endMin / 60;
- //如果beginHoursMin时间小于上班时间都算上班时间
- if (beginHoursMin <= stWorkTime) {
- beginHoursMin = stWorkTime;
- }
- //如果endHoursMin时间大于上班时间都算下班时间
- if (endHoursMin >= enWrokTime) {
- endHoursMin = enWrokTime;
- }
- //如果开始时间在freeTimeMon和freeTimeAft之间都算freeTimeAft
- if (isFreeTime == true) {
- if (beginHoursMin >= freeTimeMon && beginHoursMin <= freeTimeAft) {
- beginHoursMin = freeTimeAft;
- }
- }
- //如果结束时间在freeTimeMon和freeTimeAft之间都算freeTimeMon
- if (isFreeTime == true) {
- if (endHoursMin >= freeTimeMon && endHoursMin <= freeTimeAft) {
- endHoursMin = freeTimeMon;
- }
- }
- //获取结束时间-开始时间的天数
- var daysBetween = this.diffDay(beginTime.substring(0, 10), endTime.substring(0, 10));
- if (daysBetween > 0) {
- var hour = enWrokTime - stWorkTime - freeTime;
- if (daysBetween == 1) {
- //同一天
- if(beginHoursMin < freeTimeMon && endHoursMin > freeTimeAft){
- hours = (endHoursMin) - (beginHoursMin) - freeTime;
- }else{
- hours = endHoursMin - beginHoursMin;
- }
- } else if (daysBetween == 2) {
- //跨一天
- //第一天的时长
- hours = enWrokTime - beginHoursMin;
- //是否有午休
- if (beginHoursMin <= freeTimeMon)
- hours = hours - freeTime;
- //第二天的时长
- hours += endHoursMin - stWorkTime;
- //是否有午休
- if (endHoursMin >= freeTimeAft)
- hours = hours - freeTime;
- } else {
- //跨两天以上
- //第一天的时长
- hours = enWrokTime - beginHoursMin;
- //是否有午休
- if (beginHoursMin <= freeTimeMon)
- hours = hours - freeTime;
- //中间时长
- hours += (daysBetween - 2) * (hour);
- //最后一天时长
- hours += endHoursMin - stWorkTime;
- //是否有午休
- if (endHoursMin >= freeTimeAft)
- hours = hours - freeTime;
- }
- days = Math.floor(hours / hour);
- hours = hours % hour;
- date = {
- "days": days,
- "hours": hours
- };
- }
- this.detailData.leaveDuration = Math.round((date.days * 8 + date.hours) * 10) /10
- return date;
- // var endtime = new Date(this.detailData.endDate)
- // var starttime = new Date(this.detailData.startDate)
- // console.log(endtime - starttime)
- // this.detailData.leaveDuration = Math.floor((endtime - starttime) / (3600 * 1000))
- // this.endDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
-
- },
- submit() {
- if (!this.detailData.leaveType || this.detailData.leaveType == '选择请假类型') {
- this.$api.msg('请假类型不能为空')
- return
- }
- if (!this.detailData.startDate) {
- this.$api.msg('请选择请假开始时间')
- return
- }
- if (!this.detailData.endDate || this.detailData.endDate == '选择结束时间') {
- this.$api.msg('请选择请假结束时间')
- return
- }
- if (!this.detailData.leaveDuration) {
- this.$api.msg('请输入请假时长')
- return
- }
- if (!this.detailData.reasonForLeave) {
- this.$api.msg('请假事由不能为空')
- return
- }
- var that = this
- uni.showModal({
- content: "确定提交请假信息?",
- showCancel: true,
- confirmText: '提交',
- success: function(res) {
- if (res.confirm) {
- that.detailData.compId = uni.getStorageSync('pcUserInfo').compId
- that.detailData.commonId = uni.getStorageSync('pcUserInfo').userId
- that.detailData.dept = uni.getStorageSync('pcUserInfo').deptName
- that.detailData.phone = uni.getStorageSync('pcUserInfo').userMobilePhone
- that.detailData.empName = uni.getStorageSync('userInfo').userName
- uni.showLoading({
- title: '加载中',
- mask: true
- })
- that.$api.doRequest('post', '/leaveInfo/api/addLeave', that.detailData)
- .then(res => {
- if (res.data.code == 200) {
- that.$api.msg('提交成功')
- uni.hideLoading()
- that.value = 1
- that.getList()
- // uni.navigateTo({
- // url: '/pages/leave/the_leave_record'
- // })
- } else {
- that.$api.msg('提交失败')
- }
- })
- }
- }
- })
- },
- clockRecord() {
- this.value = 1
- uni.setNavigationBarTitle({
- title: '请假记录'
- });
- this.getList()
- // uni.navigateTo({
- // url: '/pages/leave/the_leave_record'
- // })
- },
- clocksubmit() {
- this.value = 0
- uni.setNavigationBarTitle({
- title: '请假'
- });
- // uni.navigateTo({
- // url: '/pages/leave/the_leave'
- // })
- },
- },
- }
- </script>
- <style lang='scss' scoped>
- page {
- background: #F5F6FA;
- }
- .title_b {
- margin: 20rpx 20rpx 0rpx 20rpx;
- padding: 20rpx 10rpx 20rpx 10rpx;
- font-size: 18px;
- font-weight: 550;
- }
- .c-row {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center;
- padding: 20rpx 30rpx;
- position: relative;
- }
- .con-list {
- -webkit-box-flex: 1;
- -webkit-flex: 1;
- flex: 1;
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-orient: vertical;
- -webkit-box-direction: normal;
- -webkit-flex-direction: column;
- flex-direction: column;
- color: #303133;
- line-height: 40rpx;
- text-align: right;
- padding-right: 20rpx;
- }
- .wrap {
- padding-top: 15px;
- padding-bottom: 20px;
- font-size: 14px;
- background: #fff;
- margin: 10px;
- border-radius: 10px;
- input {
- font-size: 14px;
- }
- >.title {
- padding: 10px 16px;
- }
- .wenzi {
- text-align: right;
- border-radius: 10rpx;
- margin-right: 30rpx;
- height: 10rpx;
- }
- .audit1 {
- color: red;
- }
- .audit2 {
- color: #afafe6;
- }
- .audit3 {
- color: red;
- }
- .c-row {
- display: -webkit-box;
- display: -webkit-flex;
- display: flex;
- -webkit-box-align: center;
- -webkit-align-items: center;
- align-items: center;
- padding: 5rpx 30rpx;
- position: relative;
- }
- }
- /* .footer {
- background: #fff;
- position: fixed;
- bottom: 0;
- width: 100%;
- padding: 20px 10px;
- z-index: 10;
- .button {
- background: #22C572;
- width: 90%;
- margin: 20rpx auto;
- padding: 10px;
- color: #fff;
- text-align: center;
- border-radius: 30px;
- }
- } */
- .submit {
- width: 40%;
- background: #22C572;
- border-radius: 10rpx;
- }
- .bottom-btn {
- padding: 30rpx;
- background: #FFFFFF;
- width: 100%;
- position: fixed;
- bottom: 0rpx;
- z-index: 9999;
- }
- .buns_item {
- display: flex;
- padding: 80rpx 0 50rpx 0;
- justify-content: space-around;
- }
- .but_css {
- background: #22C572;
- width: 40%;
- padding: 20rpx;
- color: #fff;
- text-align: center;
- border-radius: 20rpx;
- }
- /deep/.u-radio-group {
- flex-direction: row-reverse;
- }
- .no-boder {
- border: 0;
- }
- .textarea {
- background: #F9F9FA;
- border: 1px solid #EEEEEE;
- }
- .u-page__item__slot-icon {
- width: 20px;
- height: 20px;
- }
- .content {
- padding-bottom: 150rpx;
- overflow: hidden;
- }
- </style>
|