<template>
  <div>
    <el-drawer :title="title" :visible.sync="show" :with-header="false" :size="'600px'" :before-close="closeDetail" direction="rtl">
      <div class="drawer_title">审批详情</div>
      <div v-loading="detail_loading">
        <div class="detail_popup" v-if="detail_info !== null">
          <el-row :gutter="10" style="padding-bottom:20px;border-bottom:1px #f8f8f8 solid;position: relative;">
            <el-col :span="24">
              <template>
                <userImage v-if="detail_info.employee_info" :id="detail_info.employee_id" :user_name="detail_info.employee_info.name" :img_url="detail_info.employee_info.img_url" class="fl" width="50px" height="50px" fontSize="15"></userImage>
              </template>
              <template>
                <span v-if="detail_info.employee_info" style="line-height:50px; margin-left:10px;margin-right:4px;"><WWOpenData type="userName" :openid="detail_info.employee_info.name"></WWOpenData></span>
                <span class="color_red point" v-show="detail_info.point >= 0 && detail_info.point">
                  <span v-if="(detail_info.review_point == 0 ? detail_info.point : detail_info.review_point) >= 0">+</span>
                  {{ detail_info.review_point == 0 ? detail_info.point : detail_info.review_point }} {{ $getTypsName(detail_info.pt_id) }}
                </span>
                <span class="color_green point" v-show="detail_info.point < 0 && detail_info.point">{{ detail_info.point }} {{ $getTypsName(detail_info.pt_id) }}</span>
              </template>
              <br />
              <template>
                <b style="font-size:13px;position: absolute;left:65px;top:45px">
                  <span v-if="detail_info.status == 1" style="color:#67C23A;">审批通过</span>
                  <span v-else-if="detail_info.status == 2" style="color:#F56C6C;">审批驳回</span>
                  <span v-else-if="detail_info.status == 0" style="color:#E6A23C;">待审批</span>
                  <span v-else></span>
                </b>
              </template>
            </el-col>
          </el-row>

          <!-- <el-row :gutter="10" v-show="detail_info.source_type_mark">
          <el-col :span="4">来源类型</el-col>
          <el-col :span="20">{{ detail_info.source_type_mark }}</el-col>
        </el-row> -->

          <el-row :gutter="10" v-for="(item, index) in detail_info.detail" :key="index">
            <el-col :span="4">{{ item.key }}</el-col>
            <el-col :span="20" v-if="item.key == '附件'">
              <el-image v-for="(items, indexs) in item.value" :key="indexs" style="width: 100px; height: 100px;margin:2px;" :src="items" :preview-src-list="item.value"></el-image>
            </el-col>
            <el-col :span="20" v-else-if="item.key == '工作留存'">
              <el-image v-for="(items, indexs) in item.value" :key="indexs" style="width: 100px; height: 100px;margin:2px;" :src="items" :preview-src-list="item.value"></el-image>
            </el-col>
            <el-col :span="20" v-else-if="item.key == '奖扣目标'">
              <WWOpenData type="userName" :openid="item.value"></WWOpenData>
            </el-col>
            <el-col :span="20" v-else-if="item.key == '申请人'">
              <WWOpenData type="userName" :openid="item.value"></WWOpenData>
            </el-col>
            <el-col :span="20" v-else-if="item.key == '收益人'">
              <WWOpenData type="userName" :openid="item.value"></WWOpenData>
            </el-col>
            <el-col :span="20" v-else>{{ item.value }}</el-col>
          </el-row>

          <el-row :gutter="10" v-if="detail_info.files != null && detail_info.files > 0">
            <el-col :span="4">图片</el-col>
            <el-col :span="20"><el-image style="width: 100px; height: 100px" :src="detail_info.files[0]" :preview-src-list="detail_info.files"></el-image></el-col>
          </el-row>

          <div v-show="detail_info.item_name != ''">
            <p class="row_title">
              规则依据 &nbsp;
              <span class="row_tips" style="font-size:12px;color:#909399">此事件打分参考以下积分规则</span>
            </p>
            <el-row>
              <el-col :span="4">积分分类</el-col>
              <el-col :span="20">{{ detail_info.rule_name }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="4">积分规则</el-col>
              <el-col :span="20">{{ detail_info.item_name }}</el-col>
            </el-row>
            <el-row>
              <el-col :span="4">积分分数</el-col>
              <el-col :span="20">
                <span v-if="detail_info.item_range_type == 2">
                  {{ detail_info.item_min_point + ' ～ ' + detail_info.item_max_point }}
                </span>
                <span v-else><span v-show="detail_info.point > 0">+</span>{{ detail_info.point }}</span>
                {{ detail_info.pt_id == 3 ? 'B分' : detail_info.pt_id == 2 ? 'A分' : detail_info.pt_id == 1 ? '绩效分' : '' }}
              </el-col>
            </el-row>
          </div>
          <div v-show="detail_info.process && detail_info.process.length > 0"><Steps :process="detail_info.process"></Steps></div>

          <el-row style="border-top: 1px #f8f8f8 solid;">
            <el-col :span="24" style="text-align: right;padding-top:20px" v-if="detail_info.status == 0">
              <el-button v-if="detail_info.pt_id == 1" @click="closeDetail">取消</el-button>
              <el-button v-else @click="rejectBtn">驳回</el-button>
              <el-button type="primary" @click="adoptBtn">通过</el-button>
            </el-col>
            <el-col :span="24" style="text-align: right;padding-top:20px" v-if="detail_info.can_refuse==1">
              <span style="color:#909399;font-size:12px;padding-right:20px">撤回后需重新审批</span>
              <el-button type="primary" @click="revokeApproval">撤回审批</el-button>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-drawer>

    <el-dialog title="审批驳回" :visible.sync="rejectShow" :before-close="rejectClose" width="520px">
      <el-form :model="rejectForm" ref="rejectForm" label-width="80px" v-loading="rejectLoading">
        <el-form-item
          label="审批意见"
          prop="remark"
          :rules="[
            { required: true, message: '请输入审批意见', trigger: 'blur' },
            {
              min: 3,
              max: 50,
              message: '长度在 3 到 50 个字符',
              trigger: 'blur'
            }
          ]"
        >
          <el-input type="textarea" :rows="4" v-model="rejectForm.remark" placeholder="请输入审批意见(限50字)"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button @click="cancelReject('rejectForm')">取消</el-button>
          <el-button type="primary" @click="confirmReject('rejectForm')">确认驳回</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>

    <el-dialog title="审批通过" :visible.sync="adoptShow" width="571px" :before-close="adoptClose">
      <el-form :model="adoptForm" ref="adoptForm" label-width="80px" v-loading="determinedBy">
        <el-form-item label="指定规则" v-if="!detail_info.rule_id && !detail_info.item_id && detail_info.source_type != 4">
          <el-switch v-model="adoptForm.ruleOrItem" active-color="#13ce66"></el-switch>
        </el-form-item>
        <el-form-item
          label="分类"
          v-if="detail_info.source_type != 4"
          v-show="(detail_info.rule_id && !detail_info.item_id) || !adoptForm.ruleOrItem"
          prop="rule_id"
          :rules="[{ required: true, message: '请选择规则分类', trigger: 'blur' }]"
        >
          <el-cascader
            :disabled="!!detail_info.rule_id || !!detail_info.item_id"
            class="date-picker-width"
            v-model="adoptForm.rule_id"
            :options="ruleTrees"
            :props="{ value: 'id', label: 'name', children: 'child' }"
            @change="ruleChange"
            ref="rule"
            clearable
            filterable
            change-on-select
            placeholder="请选择规则分类"
          ></el-cascader>
        </el-form-item>
        <!-- <el-form-item label="规则" v-if="detail_info.item_id">
					<span>{{detail_info.item_name}}</span>
				</el-form-item> -->
        <el-form-item label="规则内容" v-if="(!!detail_info.rule_id && detail_info.item_name) || (!!detail_info.item_id && detail_info.item_name)">
          <span>{{ detail_info.item_name }}</span>
        </el-form-item>
        <!-- <el-form-item label="规则积分" v-if="!!detail_info.rule_id && detail_info.point || !!detail_info.item_id && detail_info.point">
					<span><span v-show="detail_info.point>0">+</span>{{detail_info.point}} {{detail_info.pt_id==3?'B分':detail_info.pt_id==2?'A分':detail_info.pt_id==1?'绩效分':''}}</span>
				</el-form-item> -->
        <el-form-item
          label="规则"
          v-if="detail_info.source_type != 4"
          v-show="(detail_info.rule_id && detail_info.item) || adoptForm.ruleOrItem"
          prop="item_id"
          :rules="[{ required: true, message: '请选择规则细则', trigger: 'blur' }]"
        >
          <el-cascader
            :disabled="!!detail_info.rule_id || !!detail_info.item_id"
            class="date-picker-width"
            :popper-class="'itemClass'"
            v-model="adoptForm.item_id"
            :options="item_list"
            :props="{
              value: 'id',
              label: 'name',
              children: 'child',
              emitPath: 'false'
            }"
            :show-all-levels="false"
            ref="ruleItem"
            @change="cascaderItemIdChange"
            placeholder="请选择规则细则"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="规则积分" v-show="detail_info.item_id">
          {{
            detail_info.item_range_type == 1
              ? detail_info.item_min_point
              : detail_info.item_range_type == -1
              ? detail_info.item_min_point
              : detail_info.item_min_point + '～' + detail_info.item_max_point
          }}{{ detail_info.pt_id == 3 ? 'B分' : detail_info.pt_id == 2 ? 'A分' : detail_info.pt_id == 1 ? '绩效分' : '' }}
        </el-form-item>

        <el-form-item label="" v-if="rangeType.rule_rangeType_pt_id == 2 || rangeType.rule_rangeType_pt_id == 3">
          <span>
            {{ rangeType.rule_min_point == rangeType.rule_max_point ? rangeType.rule_min_point : rangeType.rule_min_point + '~' + rangeType.rule_max_point
            }}{{ rangeType.rule_rangeType_pt_id == 3 ? 'B分' : 'A分' }}
          </span>
        </el-form-item>

        <el-form-item label="" v-if="rangeType.rule_rangeType_name != ''">
          <span>{{ rangeType.rule_rangeType_name }}</span>
        </el-form-item>

        <el-form-item label="审批积分">
          <!-- <el-col :span="6" >
            <el-select v-model="awardPoints" placeholder="请选择" :disabled="detail_info.item_range_type==1 || forbiddenInputNum">
              <el-option
                v-for="item in awardPointsArray"
                :key="item.value"
                :label="item.name"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-col> -->
          <el-col :span="10">
            <!-- <el-input-number v-if="detail_info.item_range_type==2" :min="1" :max="itemMaxPoint" v-model="adoptForm.point" type="number"></el-input-number> -->
            <el-input-number
              v-if="detail_info.item_range_type == 2"
              :min="detail_info.item_min_point"
              :max="detail_info.item_max_point"
              v-model="adoptForm.point"
              type="number"
            ></el-input-number>
            <el-input-number
              v-else-if="detail_info.item_range_type == 1"
              :disabled="detail_info.item_range_type == 1"
              :min="1"
              v-model="adoptForm.point"
              placeholder="请输入分值"
            ></el-input-number>
            <div v-else>
              <el-input-number
                v-if="rangeType.rule_range_type == 2"
                :disabled="forbiddenInputNum"
                :min="rangeType.rule_min_point"
                :max="rangeType.rule_max_point"
                v-model="adoptForm.point"
                placeholder="请输入分值"
              ></el-input-number>
              <!-- <el-input-number v-show="rangeType.rule_range_type==1" :disabled="forbiddenInputNum"
                v-model="adoptForm.point"
                placeholder="请输入分值"
              ></el-input-number> -->
              <el-input-number v-else :disabled="forbiddenInputNum" v-model="adoptForm.point" placeholder="请输入分值"></el-input-number>
            </div>
          </el-col>
        </el-form-item>
        <el-form-item
          v-if="detail_info.source_type == 4"
          label="审批意见"
          prop="remark"
          :rules="[{ required: true, message: '请输入审批意见', trigger: 'blur' }, { max: 100, message: '长度不能超过 100 个字符', trigger: 'blur' }]"
        >
          <el-input :rows="4" type="textarea" v-model="adoptForm.remark" placeholder="说点什么(限100字)"></el-input>
        </el-form-item>
        <div style="padding-left: 80px">奖票用于优秀表现和重要事项的表彰</div>
        <el-form-item label="发放奖票"><el-switch v-model="adoptForm.switch" active-color="#13ce66"></el-switch></el-form-item>
        <el-form-item label="递交审批">

          <!-- <el-row>
            <el-col :span="18">
              <el-input auto-complete="off" v-model="manager" placeholder="请选择上级递交审批"></el-input>
              <div @click="show_employee_selector = true" style=" position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9;"></div>
            </el-col>
          </el-row> -->

          
          <el-row>
            <el-col :span="18">
              <el-input v-show="manager=='' || manager== null" auto-complete="off" v-model="manager" placeholder="请选择审批人"></el-input>
              <div @click="show_employee_selector = true" style=" position: absolute; top: 0; right: 0; left: 0; bottom: 0; z-index: 9;"></div>
              <div v-if="manager!='' && manager!= null"  @click="show_employee_selector = true" class="zindexName">
                  <WWOpenData type="userName" :openid="manager"></WWOpenData>
              </div>
            </el-col>
          </el-row>

          <EmployeeSelector
            :is_filtration_creator="false"
            :is_superior="true"
            :user_employee_list="true"
            :employee_list="employee_lists"
            :multi="false"
            :isChecKedAll="false"
            :include_self="false"
            :selected="manager_selected"
            :visible.sync="show_employee_selector"
            @confirm="employee_confirm"
          />
        </el-form-item>
        <el-form-item v-if="detail_info.source_type != 4" label="审批意见" prop="remark" :rules="[{ max: 100, message: '长度不能超过 100 个字符', trigger: 'blur' }]">
          <el-input :rows="4" type="textarea" v-model="adoptForm.remark" placeholder="说点什么(限100字)"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button @click="adoptClose">取 消</el-button>
          <el-button type="primary" @click="submitAdopt('adoptForm')">确定通过</el-button>
        </el-form-item>
      </el-form>

      <!-- <span slot="footer">
			<el-button @click="adoptClose">取 消</el-button>
			<el-button type="primary" @click="submitAdopt('adoptForm')">确定通过</el-button>
      </span> -->
    </el-dialog>
  </div>
</template>

<script>
// import request from '@/utils/request'
import EmployeeSelector from '@/views/common/EmployeeSelector';
import Steps from '@/components/Steps.vue';

export default {
  name: 'examinePopup',
  data() {
    return {
      employee_lists: [],
      itemParticulars: false,
      rangeType: {
        rule_range_type: 0,
        rule_min_point: 0,
        rule_max_point: 0,
        rule_rangeType_pt_id: 0,
        rule_rangeType_name: ''
      },
      itemMaxPoint: 1,
      forbiddenInputNum: false,
      determinedBy: false, //确定通过loading
      rejectLoading: false, //驳回loading
      detail_id: null,
      detail_loading: false,
      detailShow: false,
      detail_info: {
        rule_id: ''
      },
      employee_map: JSON.parse(localStorage.getItem('SET_EMPLOYEE_MAP')),
      rejectShow: false,
      adoptShow: false,
      rejectForm: {
        remark: ''
      },
      adoptForm: {
        ruleOrItem: false,
        rule_id: null,
        item_id: 0,
        showPoint: null,
        point: null,
        switch: false,
        remark: ''
      },
      // 规则 or 细则
      ruleTrees: null,
      item_list: null,
      // 奖扣积分数组
      awardPointsArray: [{ name: '奖分', value: 1 }, { name: '扣分', value: 2 }],
      awardPoints: 1,

      // 下一个审批人
      manager: '',
      employee_not_select: [],
      manager_selected: { dept: [], employee: [] },
      show_employee_selector: false
    };
  },
  props: {
    id: {
      type: Number,
      default: 0
    },
    show: {
      type: Boolean,
      default: false
    },
    title: {
      type: String,
      default: ''
    }
  },
  watch: {
    id(val) {
      this.detail_id = val;
    },
    show(val) {
      if (val) {
        this.getDetail();
      }
    },
    'adoptForm.ruleOrItem'(val) {
      if (val) {
        this.adoptForm.rule_id = 0;
      } else {
        this.rangeType = {
          rule_range_type: 0,
          rule_min_point: 0,
          rule_max_point: 0,
          rule_rangeType_pt_id: 0,
          rule_rangeType_name: ''
        };
        this.forbiddenInputNum = false;
        this.adoptForm.item_id = 0;
      }
    }
  },
  components: { EmployeeSelector, Steps },
  mounted() {
    this.getRuleItem();
    this.getRuleItemTree();
    this.employee_lists = this.$store.getters.user_info.employee_detail.superior_list
    //刷新当前角色上级
    this.$http('get', '/api/employee/detail').then(res => {
        let list = res.data.data.user
        this.employee_lists = list.employee_detail.superior_list
    })
  },
  methods: {
    cascaderItemIdChange(val) {
      let datas = this.$refs['ruleItem'].getCheckedNodes()[0].data;
      if (datas.range_type == 1) {
        this.forbiddenInputNum = true;
      } else {
        this.forbiddenInputNum = false;
      }
      // this.adoptForm.point = val.showPoint
      this.adoptForm.point = datas.min_point;
      this.rangeType.rule_range_type = datas.range_type;
      this.rangeType.rule_min_point = datas.min_point;
      this.rangeType.rule_max_point = datas.max_point;
      this.rangeType.rule_rangeType_pt_id = datas.pt_id;
      this.rangeType.rule_rangeType_name = datas.name;

      // if(datas.min_point >=0){
      //   this.awardPoints = 1
      // }else{
      //   this.awardPoints = 2
      // }
      this.adoptForm.rule_id = datas.rule_id;
    },
    //审批撤销
    revokeApproval() {
      this.$confirm('确定要撤回此项吗？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.detail_loading = true;
          this.$http('DELETE','/api/integral/review',{ review_id: this.detail_id })
            .then(res => {
              if (res.data.code == 1) {
                this.$message.success(res.data.msg);
                this.closeDetail(); //关闭抽屉
                setTimeout(() => {
                  this.detail_loading = false;
                }, 200);
                this.$parent.get_list(); //刷新列表
              }
            })
            .catch(err => {
              this.detail_loading = false;
              this.$message.error(err.data.msg);
            })
            .fially(() => {
              this.detail_loading = false;
            });
        })
        .catch(() => {});
    },
    // 选择规则分类关闭down
    ruleChange(val) {
      if (val.length == 0) {
        this.adoptForm.rule_id = 0;
      } else {
        this.adoptForm.rule_id = val[val.length - 1];
      }
      this.$nextTick(() => {
        this.$refs.rule.dropDownVisible = false;
      });
    },
    // 选择规则细则
    itemChange(val) {
      if (val.length == 0) {
        this.adoptForm.item_id = 0;
      } else {
        this.adoptForm.item_id = val[val.length - 1];
      }
      this.$nextTick(() => {
        this.$refs.ruleItem.dropDownVisible = false;
      });
    },
    // 获取规则细则树
    getRuleItemTree() {
      let self = this;
      let params = {
        pt_id: this.detail_info.pt_id,
        cycle_type: '1'
      };
      this.$http('get','/api/integral/rule/trees',params,'v2').then(res => {
          if (res.data.code == 1) {
            self.item_list = res.data.data.tree;
          } else {
            self.$message.error(res.data.data.msg);
          }
        })
    },
    // 获取规则分类规则细则信息
    getRuleItem() {
      let self = this;
      let params = {
        cycle_type: 1
      };
      this.$http('get','/api/integral/rule/trees',params).then(res => {
          if (res.data.code == 1) {
            self.ruleTrees = this.getTreeData(res.data.data.rule_tree);
          } else {
            self.$message.error(res.data.data.msg);
          }
        })
    },
    // 打开详情
    getDetail() {
      let self = this;
      let params = {
        review_id: self.detail_id
      };
      self.detailShow = true;
      self.detail_loading = true;
      this.$http('get','/api/integral/review',params ).then(res => {
          if (res.data.code == 1) {
            self.detail_info = res.data.data;
            self.detail_info.rule_id ? (self.adoptForm.rule_id = self.detail_info.rule_id) : '';
            if (res.data.data.item_id) {
              self.adoptForm.item_id = self.detail_info.item_id;
              self.adoptForm.showPoint = self.detail_info.point;
              self.detail_info.point > 0 ? (self.awardPoints = 1) : (self.awardPoints = 2);
              self.adoptForm.point = Math.abs(self.detail_info.point);
            }
          } else {
            self.$message.error(res.data.data.msg);
          }
          self.detail_loading = false;
        })
        .catch(e => {
          self.$message.error(e.data.data.msg);
          self.detail_loading = false;
        });
    },
    getEmployeeName(id) {
      for (const key in this.employee_map) {
        if (this.employee_map[key].id == id) {
          return this.employee_map[key].name;
        }
      }
    },
    // 关闭抽屉
    closeDetail() {
      this.$emit('update:show', false);
    },
    // 驳回按钮
    rejectBtn() {
      this.rejectShow = true;
    },
    // 关闭驳回弹窗
    rejectClose() {
      this.rejectShow = false;
      this.$refs['rejectForm'].resetFields();
    },
    // 确定驳回
    confirmReject(formName) {
      let self = this;
      self.$refs[formName].validate(valid => {
        if (valid) {
          let data = {
            review_id: self.detail_id,
            action: 'refuse',
            ticket_count: '0',
            remark: self.rejectForm.remark
          };

          this.rejectLoading = true;
          this.$http('post','/api/integral/review',data)
            .then(res => {
              if (res.data.code == 1) {
                self.rejectShow = false;
                self.detail_info.status = 2;
                self.$message.success(res.data.msg);
                this.rejectClose(); //关闭驳回弹窗
                setTimeout(() => {
                  //延迟关闭，防止重复点击
                  this.rejectLoading = false;
                }, 200);
                this.closeDetail(); //关闭抽屉
                this.$parent.get_list(); //刷新列表
              } else {
                self.$message.error(res.data.msg);
                this.rejectLoading = false;
              }
            })
            .catch(e => {
              self.$message.close();
            });
        }
      });
    },
    // 取消驳回
    cancelReject(formName) {
      this.rejectShow = false;
      this.$refs[formName].resetFields();
    },
    // 通过按钮
    adoptBtn() {
      if(this.detail_info.item_range_type == 1){
        this.adoptForm.point = Math.abs(this.detail_info.point);
      }else{
        this.adoptForm.point = this.detail_info.point;
      }
      this.detail_info.point > 0 ? (this.awardPoints = 1) : (this.awardPoints = 2);
      this.adoptForm.rule_id = this.detail_info.rule_id;
      this.adoptForm.item_id = this.detail_info.item_id;
      if (this.detail_info.rule_id == 0 && this.detail_info.item_id == 0 && this.detail_info.pt_id != 1) {
        //没有  规则分类 与 规则细则 与 不是绩效任务时，才请求规则细则（减少请求）
        this.getRuleItemTree();
      }
      this.adoptShow = true;

      this.rangeType = {
        rule_range_type: 0,
        rule_min_point: 0,
        rule_max_point: 0,
        rule_rangeType_pt_id: 0,
        rule_rangeType_name: ''
      };
    },
    // 递归判断列表，把最后的child设为undefined
    getTreeData(data) {
      for (var i = 0; i < data.length; i++) {
        if (data[i].child.length < 1) {
          // child若为空数组，则将child设为undefined
          data[i].child = undefined;
        } else {
          // child若不为空数组，则继续 递归调用 本方法
          this.getTreeData(data[i].child);
        }
      }
      return data;
    },
    // 下一个审批人
    employee_confirm(data) {
      this.manager_selected = { dept: [], employee: [] };
      this.adoptForm.reviewer_id = '';
      this.manager = '';
      if (data.employee !== null && data.employee.length != 0) {
        this.manager_selected.employee = data.employee;
        this.adoptForm.reviewer_id = data.employee[0].id;
        this.manager = data.employee[0].name;
      }
    },
    // 关闭通过弹窗
    adoptClose() {
      this.adoptForm.rule_id = 0;
      this.adoptForm.reviewer_id = 0;
      this.adoptForm.item_id = 0;
      this.adoptForm.reviewer_id = 0;
      this.forbiddenInputNum = false;
      this.adoptShow = false;
      this.manager = '';//清空递交审批
      this.manager_selected = { dept: [], employee: [] };//清空递交审批
      this.adoptForm.remark = ''
      this.adoptForm.switch = false
      // this.$refs["adoptForm"].resetFields();
    },
    // 确定通过
    submitAdopt(formName) {
      let self = this;
      self.$refs[formName].validate(valid => {
        if (valid) {
          let data = {
            review_id: self.detail_id,
            action: 'complete',
            rule_id: self.adoptForm.rule_id,
            item_id: 0,
            point: self.adoptForm.point,
            reviewer_id: '',
            remark: self.adoptForm.remark,
            ticket_count: 0
          };
          console.log(self.adoptForm.reviewer_id)
          self.adoptForm.item_id ? (data.item_id = self.adoptForm.item_id) : (data.item_id = 0);
          self.adoptForm.reviewer_id ? (data.reviewer_id = self.adoptForm.reviewer_id) : (data.reviewer_id = 0);
          self.adoptForm.switch ? (data.ticket_count = 1) : (data.ticket_count = 0);
          if(this.detail_info.item_range_type == 1){
            if (self.awardPoints === 1) {
              data.point = self.adoptForm.point;
            } else {
              data.point = self.adoptForm.point * -1;
            }
          }
          if (data.rule_id == '' || data.rule_id == null) {
            data.rule_id = 0;
          }
          if(this.detail_info.item_range_type == -1){
            let itemID = '';
            for (let i in data.item_id) {
              itemID = data.item_id[i];
            }
            data.item_id = itemID;
          }
          if (data.item_id == '' || data.item_id == null) {
            data.item_id = 0;
          }
          this.determinedBy = true;
          this.$http('post','/api/integral/review',data)
            .then(res => {
              if (res.data.code == 1) {
                self.adoptShow = false;
                self.detail_info.status = 2;
                self.$message.success(res.data.msg);
                this.adoptClose(); //关闭通过弹窗
                setTimeout(() => {
                  //预防重复点击
                  this.determinedBy = false;
                }, 200);
                this.closeDetail(); //关闭抽屉
                this.$parent.get_list(); //刷新列表
              } else {
                self.$message.error(res.data.msg);
                this.determinedBy = false;
              }
            })
            .catch(e => {
              self.$message.close();
              this.determinedBy = false;
            });
        }
      });
    }
  }
};
</script>

<style lang="scss">
.itemClass .el-cascader-menu .el-cascader-menu__wrap li.el-cascader-node {
  height: auto;
  max-width: 500px;
  .el-cascader-node__label {
    white-space: initial;
    overflow: initial;
    text-overflow: initial;
  }
}

.detail_popup {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden !important;
  height: calc(100vh - 60px);
  .row_title {
    position: relative;
    margin: 0 0 20px 0;
    padding-top: 12px;
    font-size: 16px;
    color: #303133;
    line-height: 22px;
  }
  .row_title:before {
    position: absolute;
    top: 0;
    content: ' ';
    width: 100%;
    border-top: 1px #f8f8f8 solid;
  }
  .el-row {
    margin-bottom: 10px;
    font-size: 14px;
    .el-col-4 {
      color: #606266;
    }
  }
}
.drawer_title {
  font-size: 18px;
  padding: 20px;
  border-bottom: 1px #efefef solid;
}

.zindexName{
    position: absolute;
    top: 0;
    right: 0;
    left: 0;
    bottom: 0;
    z-index: 9;
    border:1px solid rgb(224, 224, 224);
    width:360px;
    border-radius:3px;
    padding-left:15px;
    overflow: hidden;
}
</style>
