<template>
	<view :class="isUps == true ? 'prevent' : ''">
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true" >
			<block slot="backText">返回</block>
			<block slot="content">离岗信息</block>
		</cu-custom>
		<view class="form">
      <view class="wui-form-list">
        <view class="cu-form-group">
          <view class="title">申请人:</view>
          <input :disabled="forbidEdit" v-model="pd.USER_NAME" placeholder="申请人"></input>
        </view>
        <view class="cu-form-group">
          <view class="title">离岗开始时间:</view>
          <input :disabled="forbidEdit" v-model="pd.STARTTIME" placeholder="请选择离离岗开始时间"></input>
        </view>
        <view class="cu-form-group">
          <view class="title">离岗结束时间:</view>
          <input :disabled="forbidEdit" v-model="pd.ENDTIME" placeholder="请选择离岗结束时间"></input>
        </view>
        <view class="cu-form-group">
          <view class="title">离岗原因:</view>
          <textarea :disabled="forbidEdit" maxlength="-1" v-model="pd.DESCR" placeholder="请输入离岗原因"></textarea>
        </view>
        <view class="cu-form-group ">
          <view class="title">审批状态</view>
          <template v-if="pd.REVIEW_STATUS === '0'">待审批</template>
          <template v-else-if="pd.REVIEW_STATUS === '1'">审批通过</template>
          <template v-else-if="pd.ISDELETE === '1' && pd.REVIEW_STATUS === '-1'">
            <template v-if="pd.CREATOR === pd.OPERATOR">申请人取消</template>
            <template v-else>审批人取消</template>
          </template>
          <template v-else-if="pd.REVIEW_STATUS === '-1'">审批未通过</template>
          <template v-else-if="pd.REVIEW_STATUS === '2'">无需审批</template>
        </view>
        <view v-if="pd.REVIEW_STATUS !== '2'" class="cu-form-group ">
          <view class="title">审批人</view>
          <text>{{ pd.REVIEW_USER_NAME + ' [' + pd.REVIEW_USER_DEPARTMENTNAME + ']' }}</text>
        </view>
        <view v-if="pd.REVIEW_STATUS === '1' || pd.REVIEW_STATUS === '-1'" class="cu-form-group">
          <view class="title">{{ pd.ISDELETE === '0' ? '审批意见' : '取消原因' }}:</view>
          <textarea :disabled="forbidEdit" maxlength="-1" v-model="pd.REVIEW_DESC"></textarea>
        </view>
			</view>
		</view>
		<view class="padding flex flex-direction">
			<button class="cu-btn bg-blue margin-tb-sm lg" @click="$noMultipleClicks(goback)">返回</button>
		</view>
		<view class="padding flex flex-direction">

		</view>
	</view>
</template>

<script>
	import {
		basePath,corpinfoId,deptId,loginUser,formatDate,loginSession,baseImgPath,setIsRest
	} from '@/common/tool.js';
	import tkiTree from "@/components/select-tree/select-tree.vue"
	import ruiDatePicker from '@/components/rattenking-dtpicker/rattenking-dtpicker.vue';
	export default {
		components: {
			tkiTree,ruiDatePicker
		},
		data() {
			return {
        forbidEdit: true,
				isUps:false,
        noClick:true,
        pd: {
          USER_NAME: '',
          STARTTIME: '',
          ENDTIME: '',
          DESCR: '',
          REVIEW_USER_NAME: '',
          REVIEW_USER_DEPARTMENTNAME: '',
          REVIEW_STATUS: '',
          REVIEW_DESC: '',
          ISDELETE: ''
        },// 数据
				todayDate:''

			}
		},
		onLoad(event){
      this.pd.OFFDUTY_ID = event.OFFDUTY_ID;
			this.todayDate =  formatDate(new Date(), 'yyyy-MM-dd');
      this.getData();
			loginSession();
		},
		methods: {
      getData() {
        var _this = this;
        uni.showLoading({
          title: '请稍候'
        })
        uni.request({
          url: basePath + '/app/offduty/goEdit',
          method: 'POST',
          header: {
            'Content-type': 'application/x-www-form-urlencoded'
          },
          data: {
            OFFDUTY_ID:this.pd.OFFDUTY_ID
          },
          success: (res) => {
            if ("success" == res.data.result) {
              uni.hideLoading();
              _this.pd = res.data.pd; //参数map
            } else if ("exception" == data.result) {
              uni.showToast({
                title: '错误',
                duration: 2000
              });
            }
          }
        });
      },
			goback(){
				var pages = getCurrentPages();	// 获取当前页面栈
				var prePage = pages[pages.length - 2];	// 上二级页面
				prePage.$vm.initflag = true;    // A 页面 init方法 为true
				uni.navigateBack({delta: 1});
				uni.hideLoading();
			},
		}
	}
</script>

<style>
	.prevent {
			width: 100%;
			height: 100%;
			position: fixed;
			top: 0;
			left: 0;
			overflow: hidden;
		}
	.cu-form-title{
		padding: 20upx 0;
	}
	.cu-form-textarea{
		background-color: #ffffff;
		padding: 1upx 30upx 20upx;
		min-height: 100upx;
	}
	.cu-form-textarea textarea {
		height: 4.6em;
		width: 100%;
		line-height: 1.2em;
		flex: 1;
		font-size: 28upx;
		padding: 0;
	}
	.selected{
		display: flex;
		align-items: center;
		height: 100upx;
	}
	.selected .radio{
		 transform:scale(0.8);
		 margin-right: 10upx;
	}
	.group{
		display: flex;
		align-items: center;
	}
	.cu-form-group .title{
		font-size: 28upx;
		color: #000;
		font-weight: bold;
	}
	.cu-bar .action:first-child {
	    font-size: 28upx;
	}
	.cu-form-group .picker{
			color: #808080;
		}
		.picker-tree{
			color: #808080;
		}
</style>