123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291 |
- <template>
- <view>
- <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" />
- <view style='position:absolute;right:10px;bottom:20px;color:#AFB3BF;'>
- {{detailData.reasonForLeave.length}}/100个字
- </view>
- </view>
- </view>
- <view class="footer">
- <view @click='clockRecord' class="button">记录</view>
- <view @click='submit' class="button">提交</view>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
-
- show: false,
- show1: false,
- show2: false,
- detailData: {
- leaveType:'选择请假类型',
- reasonForLeave:"",
- startDate:'',
- endDate:'选择结束时间',
- leaveDuration:'',
- },
- params: {
- year: true,
- month: true,
- day: true,
- hour: true,
- minute: true,
-
- },
- type: 'textarea',
- border: true,
- height: 150,
- autoHeight: true,
- // endDate1:"",
- // startDate1: "",
- leaveTypeList: [{
- leaveType: "事假"
- },
- {
- leaveType: "病假"
- },
- ],
- }
- },
- 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;
- },
- methods: {
- 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"
- }
- },
- dateChange(e) {
- this.detailData.startDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
- // this.startDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
- // + ":" + "00"
- },
- dateChange1(e) {
- this.detailData.endDate = e.year + "-" + e.month + "-" + e.day + " " + e.hour + ":" + e.minute
- // this.endDate1 = e.year + "-" + e.month + "-" + e.day + "-" + e.hour + "-" + e.minute + "-" + e.second
- },
- submit() {
- if (!this.detailData.leaveType) {
- this.$api.msg('请假类型不能为空')
- return
- }
- if (!this.detailData.startDate) {
- this.$api.msg('请选择请假开始时间')
- return
- }
- if (!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
- that.$api.doRequest('post', '/leaveInfo/api/addLeave', that.detailData)
- .then(res => {
- if (res.data.code == 200) {
- that.$api.msg('提交成功')
- } else {
- that.$api.msg('提交失败')
- }
- })
- }
- }
- })
- },
- clockRecord() {
- uni.navigateTo({
- url: '/pages/leave/the_leave_record'
- })
- },
- },
- }
- </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-bottom: 10px;
- font-size: 14px;
- background: #fff;
- margin: 10px;
- border-radius: 10px;
- input {
- font-size: 14px;
- }
- >.title {
- padding: 10px 16px;
- }
- }
- .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;
- }
- }
- .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;
- }
- </style>
|