<template>
	<view>
		<cu-custom bgColor="bg-gradual-blueness" :isBack="true">
			<block slot="backText">返回</block>
			<block slot="content">{{ form.APPLY_TYPE ==='2' ? '入职确认' : '解聘确认' }}</block>
		</cu-custom>
    <scroll-view scroll-y="false" >
		  <view class="form">
        <view class="cu-form-group">
          <view class="title">服务公司</view>
          <input v-model="form.CORP_NAME" disabled placeholder="请输入服务公司" name="input" style="color:#cccccc" />
        </view>
        <view class="cu-form-group margin-top-xs">
          <view class="title">所在部门</view>
          <input v-model="form.DEPARTMENT_NAME" disabled placeholder="请输入所在部门" name="input" style="color:#cccccc" />
        </view>
        <view class="cu-form-group margin-top-xs">
          <view class="title">任职岗位</view>
          <input v-model="form.POST_NAME" disabled placeholder="请输入任职岗位" name="input" style="color:#cccccc" />
        </view>
        <view class="cu-form-group margin-top-xs">
          <view class="title">确认结果</view>
          <radio-group v-model="form.REVIEW_RESULT" @change = "radioChange" style="width: 100%;">
            <label class="answer-lable">
              <radio class="blue" :class="form.REVIEW_RESULT=='1'?'checked':''" :checked="form.REVIEW_RESULT=='1'?true:false" value="1"></radio>
              <text class="title">同意</text>
            </label>
            <label class="answer-lable">
              <radio class="blue" :class="form.REVIEW_RESULT=='-1'?'checked':''" :checked="form.REVIEW_RESULT=='-1'?true:false" value="-1"></radio>
              <text class="title">拒绝</text>
            </label>
          </radio-group>
        </view>
        <view class="cu-form-group margin-top-xs">
          <view class="title">申请描述</view>
          <textarea v-model="form.APPLY_CONTENT" maxlength="200" placeholder="请输入描述(选填)"></textarea>
        </view>
      </view>
      <view class="cu-bar btn-group" style="margin-top: 30upx;">
        <button class="cu-btn bg-blue margin-tb-sm lg" @click="$noMultipleClicks(confirm)">提交申请</button>
<!--        <button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goback)">返回</button>-->
      </view>
    </scroll-view>
	</view>
</template>

<script>
import {basePath, loginUser} from "../../../common/tool";
	export default {
		data() {
			return {
        noClick: true,
        form:{

        }
			}
		},
    onShow() {
      this.getData()
    },
    methods: {
      getData() {
        var _this = this;
        uni.showLoading({
          title: '请稍候'
        })
        uni.request({
          url: basePath + '/app/user/getPractitionerEmploymentCorp',
          method: 'POST',
          dataType: 'json',
          header:{
            'Content-type':'application/x-www-form-urlencoded'
          },
          data: {
            USER_ID:loginUser.USER_ID,
            ISDELETE: '0',
            APPLY_STATUS: '0',
          },
          success: (res) => {
            if (res.data.pd) {
              uni.hideLoading();
              _this.form = res.data.pd;
              _this.$set(_this.form, 'REVIEW_RESULT', '');
            }
          }
        });
      },
      radioChange(e)  {
        this.form.REVIEW_RESULT = e.detail.value;
      },
			//跳转事件
      confirm(e) {
        console.log(this.form.REVIEW_RESULT)
        // 姓名
        if (this.form.REVIEW_RESULT === '') {
          uni.showToast({
            icon: 'none',
            title: '请选择确认结果',
            duration: 2000
          });
          return false;
        }
        var that = this
        uni.showModal({
          title: '温馨提示',
          content: '确定要提交吗？',
          cancelColor: "#000000",
          cancelText: '取消',
          confirmText: '确定',
          success: res => {
            if (res.confirm) {
              uni.request({
                url: basePath+'/app/user/setPractitionerConfirmByUser',
                method: 'POST',
                dataType: 'json',
                header: {
                  'Content-type':'application/x-www-form-urlencoded'
                },
                data: {
                  ...that.form,
                  USER_ID: loginUser.USER_ID,
                  NAME: loginUser.NAME
                },
                success: (res) => {
                  uni.hideLoading();
                  if ("success" == res.data.result) {
                    uni.showToast({
                      icon:'none',
                      title: '提交成功',
                      duration: 1500
                    });
                    that.goback()
                  }else{
                    uni.hideLoading();
                    uni.showToast({
                      icon:'none',
                      title: '系统错误',
                      duration: 2000
                    });
                  }
                }
              });
            } else {
              uni.hideLoading();
            }
          }
        })
			},
      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>
	page{
		background-color: #f3f2f2;
	}
  .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;
    font-weight: bold;
  }
  .cu-bar .action:first-child {
    font-size: 28upx;
  }
  .cu-form-group .picker{
    color: #808080;
  }
  .picker-tree{
    color: #808080;
  }
  .answer-lable{
    text-align: center;
    vertical-align: center;
    margin-bottom: 20upx;
  }
  .answer-lable:last-child{
    margin-bottom: 0;
  }
  .answer-lable radio{
    margin-left: 20upx;
    margin-right: 10upx;
  }
  .title {
    text-align: center;
    font-size: 40upx;
  }
</style>
