<template>
  <div class="applicant" v-if="existsStaff">
    <NavHeader color="#0687D2" title="申请人信息" @back="$router.go(-1)" />
    <div class="content">
      <div class="card" v-for="(item, index) in mockList" :key="index">
        <van-swipe-cell>
          <div class="top">
            <div class="left">
              <div class="img">
                <img
                  src="./img/idIcon.png"
                  v-if="item.staffState != 1"
                  alt=""
                />
                <img v-else src="./img/idIcon-no.png" alt="" />
              </div>
              <div class="name">{{ item.name }}</div>
            </div>
            <div class="right" v-if="item.staffState == 2" @click="next(item)">
              <p class="nopass">未通过</p>
              <img src="./img/editIcon.png" alt="" />
            </div>
            <div v-if="item.staffState == 0 || item.staffState == 1" class="right" @click="view(item)">
              <p class="pass">查看</p>
            </div>
          </div>
          <div class="bottom">{{ item.idCard }}</div>
          <template
            #right
            style="width: 90px; height: 100%"
            v-if="item.staffState == 2"
          >
            <van-button
              style="height: 100%"
              square
              type="danger"
              @click="delout(item)"
              text="删除"
            />
          </template>
        </van-swipe-cell>
      </div>
    </div>
    <div class="operation">
      <!-- <van-button class="button" block color="#0687D2" @click="add">
        新增
      </van-button> -->
      <van-button block round color="#0687D2" @click="ensure1"> 返回上一级 </van-button>
    </div>
  </div>
  <div class="applidetail" v-else>
    <NavHeader color="#0687D2" title="申请人信息" @back="$router.go(-1)" />
    <van-form class="form">
      <div class="reject" v-if="form.rejectReason">
        <div class="reason">拒绝原因：</div>
        <div class="details">{{ form.rejectReason }}</div>
      </div>
      <div class="section">
        <van-field
          v-model="form.name"
          :disabled="this.disable == true"
          label="姓名"
          required
          placeholder="请填写申请人姓名"
          :rules="[{ required: true, message: '请填写申请人姓名' }]"
        />
        <van-field
          v-model="form.phone"
          :disabled="this.disable == true"
          label="手机号码"
          required
          placeholder="请填写手机号码"
          :rules="[
            { required: true, message: '请填写正确的手机号码' },
            { pattern: phoneReg, message: '请填写正确的手机号码' },
          ]"
        />
        <van-field
          :value="form.idcard"
          :disabled="this.disable == true"
          label="身份证号码或护照号码"
          required
          @input="(val)=>{
            form.idcard = val;
            talent = '';
          }"
          placeholder="请填写身份证号码或护照号码"
          :rules="[
            { required: true, message: '请填写身份证号码或护照号码' },
          ]"
        />
        <van-field
          label="人才类型"
          :disabled="this.disable == true"
          :value="talent"
          required
          readonly
          placeholder="请获取人才类型"
        >
          <template #button v-if="this.disable == false">
            <van-button size="small" round color="#0687D2" native-type="button" @click="obtain">获取人才类型</van-button>
          </template>
        </van-field>
        <van-field
          v-model="form.university"
          :disabled="this.disable == true"
          label="毕业院校"
          required
          placeholder="请填写毕业院校"
          :rules="[{ required: true, message: '请填写毕业院校' }]"
        />
        <van-field
          label="毕业时间"
          :disabled="this.disable == true"
          :value="graduation"
          @click="()=>{if (!this.disable) showPicker1 = true}"
          required
          readonly
          placeholder="请选择毕业时间"
        />
        <van-popup v-model="showPicker1" position="bottom" round>
          <van-datetime-picker
            v-model="currentDate"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @cancel="showPicker1 = false"
            @confirm="onConfirm1"
          />
        </van-popup>
        <van-field
          label="学历"
          :disabled="this.disable == true"
          :value="education"
          @click="()=>{if (!this.disable) showPicker2 = true}"
          required
          readonly
          placeholder="请选择学历"
        />
        <van-popup v-model="showPicker2" position="bottom" round>
          <van-picker
            show-toolbar
            :columns="
              columns2.map((item) => {
                return item.label;
              })
            "
            title="学历"
            @cancel="showPicker2 = false"
            @confirm="onConfirm2"
          />
        </van-popup>
        <van-field
          label="学位"
          v-if="
            this.education == '本科' ||
            this.education == '硕士研究生' ||
            this.education == '博士研究生'
          "
          :disabled="this.disable == true"
          :value="degree"
          @click="()=>{if (!this.disable) showPicker3 = true}"
          required
          readonly
          placeholder="请选择学位"
        />
        <van-popup v-model="showPicker3" position="bottom" round>
          <van-picker
            show-toolbar
            :columns="
              columns3.map((item) => {
                return item.label;
              })
            "
            title="学位"
            @cancel="showPicker3 = false"
            @confirm="onConfirm3"
          />
        </van-popup>
        <van-field
          label="市区缴纳养老保险开始时间"
          :disabled="this.disable == true"
          :value="provide"
          @click="()=>{if (!this.disable) showPicker4 = true}"
          required
          readonly
          placeholder="请选择市区缴纳养老保险开始时间"
        />
        <van-popup v-model="showPicker4" position="bottom" round>
          <van-datetime-picker
            v-model="currentDate4"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @cancel="showPicker4 = false"
            @confirm="onConfirm4"
          />
        </van-popup>
        <van-field
          label="劳动合同开始时间"
          :disabled="this.disable == true"
          :value="begintime"
          @click="()=>{if (!this.disable) showPicker5 = true}"
          required
          readonly
          placeholder="请选择劳动合同开始时间"
        />
        <van-popup v-model="showPicker5" position="bottom" round>
          <van-datetime-picker
            v-model="currentDate5"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @cancel="showPicker5 = false"
            @confirm="onConfirm5"
          />
        </van-popup>
        <van-field
          label="劳动合同结束时间"
          :disabled="this.disable == true"
          :value="endtime"
          @click="()=>{if (!this.disable) showPicker6 = true}"
          required
          readonly
          placeholder="请选择劳动合同结束时间"
        />
        <van-popup v-model="showPicker6" position="bottom" round>
          <van-datetime-picker
            v-model="currentDate6"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @cancel="showPicker6 = false"
            @confirm="onConfirm6"
          />
        </van-popup>
        <van-field
          v-model="form.located"
          :disabled="this.disable == true"
          label="不动产权证坐落"
          required
          placeholder="请填写不动产权证坐落"
          :rules="[{ required: true, message: '请填写不动产权证坐落' }]"
        />
        <van-field
          v-model="form.certificate"
          :disabled="this.disable == true"
          label="不动产权证号"
          required
          placeholder="请填写不动产权证号"
          :rules="[{ required: true, message: '请填写不动产权证号' }]"
        />
        <van-field
          v-model="form.building"
          :disabled="this.disable == true"
          label="建筑面积（m2）"
          required
          placeholder="请填写建筑面积（m2）"
          :rules="[{ required: true, message: '请填写建筑面积（m2）' }]"
        />
        <van-field
          v-model="form.openbank"
          :disabled="this.disable == true"
          label="个人银行卡开户行"
          required
          placeholder="请填写个人银行卡开户行"
          :rules="[{ required: true, message: '请填写个人银行卡开户行' }]"
        />
        <van-field
          v-model="form.cardno"
          :disabled="this.disable == true"
          label="个人银行卡号"
          required
          placeholder="请填写个人银行卡号"
          :rules="[{ required: true, message: '请填写个人银行卡号' }]"
        />
        <van-field
          label="购房时间（网签时间）"
          :disabled="this.disable == true"
          :value="onlinetime"
          @click="()=>{if (!this.disable) showPicker7 = true}"
          required
          readonly
          placeholder="请选择购房时间（网签时间）"
        />
        <van-popup v-model="showPicker7" position="bottom" round>
          <van-datetime-picker
            v-model="currentDate7"
            type="date"
            title="选择年月日"
            :min-date="minDate"
            :max-date="maxDate"
            @cancel="showPicker7 = false"
            @confirm="onConfirm7"
          />
        </van-popup>
        <van-field
          v-model="form.premium"
          :disabled="this.disable == true"
          label="缴纳金额（元）"
          required
          placeholder="请填写缴纳金额（元）"
          :rules="[{ required: true, message: '请填写缴纳金额（元）' }]"
        />
        <van-field
          v-model="form.taxable"
          :disabled="this.disable == true"
          label="计税房价（元）"
          required
          placeholder="请填写计税房价（元）"
          :rules="[{ required: true, message: '请填写计税房价（元）' }]"
        />
      </div>
      <div class="section">
        <van-field
          label="上传个人申请表"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              v-model="form.apply"
              :disabled="disable"
              :deletable="!disable"
              max-count="1"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传个人身份证（正、反）照"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.idimg"
              max-count="2"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传个人银行卡号照"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.bankcard"
              max-count="1"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传商品买卖合同"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.contract"
              max-count="10"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传不动产权证书"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.estate"
              max-count="10"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传契税完税凭证"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.payment"
              max-count="10"
            />
          </template>
        </van-field>
      </div>
      <div class="section">
        <van-field
          label="上传劳动或聘用合同"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.employment"
              max-count="10"
            />
          </template>
        </van-field>
      </div>
      <div class="section" v-if="this.$route.query.guideId == 1000159">
        <van-field
          label="上传镇江籍证明材料(身份证或初高中毕业证书)"
          :disabled="this.disable == true"
          required
        >
          <template #input>
            <van-uploader
              :after-read="afterRead"
              :disabled="disable"
              :deletable="!disable"
              v-model="form.prove"
              max-count="2"
            />
          </template>
        </van-field>
      </div>
    </van-form>
    <div class="operation">
      <van-button
        v-if="type == 'edit' && !disable"
        class="button"
        block
        round
        color="#BFBFBF"
        @click="del"
      >
        返回上一级
      </van-button>
      <van-button block round color="#0687D2" @click="ensure"> 确定 </van-button>
    </div>
  </div>
</template>

<script>
import NavHeader from "@/components/NavHeader";
import Vue from "vue";
import {
  Button,
  DatetimePicker,
  Field,
  Form,
  Icon,
  Picker,
  Popup,
  Uploader,
  SwipeCell,
  Dialog,
} from "vant";
import { phoneReg } from "@/utils/constant";
import { uploadFile } from "@/api/talents";
import { encryptByDES } from "@/utils/utils";
import {
  mattersHouseRejectDetails,
  mattersHouseRejectStaffList,
  mattersHouseRejectStaffInfo,
  mattersHouseRejectStaffUpdate,
  deleteMattersStaffHouse,
  mattersHouseTalentType
} from "@/api/policy";
Vue.use(Form)
  .use(Button)
  .use(Field)
  .use(Uploader)
  .use(Icon)
  .use(Popup)
  .use(Picker)
  .use(DatetimePicker)
  .use(SwipeCell);
export default {
  components: { NavHeader },
  data() {
    return {
      // 列表
      passcode: 1,
      mockList: [],
      // 公共
      departmentCode: "",
      guideId: "",
      talentCode: "",
      matterType: "",
      userInfo: {},
      existsStaff: true,
      staffCode: "",
      code: "",
      // 详情
      disable: false, // 判断是否查看禁用输入框
      addinfo: false, // 判断是否新增员工信息
      form: {
        rejectReason: "", // 拒绝原因
        name: "", // 申请人姓名
        idcard: "", // 身份证号码或护照号码
        phone: "", // 手机号码
        university: "", // 毕业院校
        located: "", // 不动产权证坐落
        certificate: "", // 不动产权证号
        building: "", // 建筑面积（m2）
        openbank: "", // 个人银行卡开户行
        cardno: "", // 个人银行卡号
        premium: "", // 缴纳金额
        taxable: "", // 计税房价
        apply: [], //个人申请表
        idimg: [], //身份证照片
        bankcard: [], //银行卡照
        contract: [], //商品买卖合同
        estate: [], //不动产权证
        payment: [], //契税完税证
        employment: [], //劳动聘用合同
        prove: [], //证明材料
      },
      // 人才类型
      talent: "",
      // 毕业时间
      graduation: "",
      showPicker1: false,
      minDate: new Date(1950, 0, 1),
      maxDate: new Date(2050, 0, 1),
      currentDate: new Date(2021, 7, 30),
      // 学历
      education: "",
      showPicker2: false,
      columns2: [
        {
          id: "1",
          label: "小学",
        },
        {
          id: "2",
          label: "初中",
        },
        {
          id: "3",
          label: "中专",
        },
        {
          id: "4",
          label: "高中",
        },
        {
          id: "5",
          label: "大专",
        },
        {
          id: "6",
          label: "本科",
        },
        {
          id: "7",
          label: "硕士研究生",
        },
        {
          id: "8",
          label: "博士研究生",
        },
      ],
      // 学位
      degree: "",
      showPicker3: false,
      columns3: [
        {
          id: "1",
          label: "学士学位",
        },
        {
          id: "2",
          label: "硕士学位",
        },
        {
          id: "3",
          label: "博士学位",
        },
      ],
      // 市区养老保险缴纳开始时间
      provide: "",
      showPicker4: false,
      currentDate4: new Date(2021, 7, 30),
      // 劳动合同开始时间
      begintime: "",
      showPicker5: false,
      currentDate5: new Date(2021, 7, 30),
      // 劳动合同结束时间
      endtime: "",
      showPicker6: false,
      currentDate6: new Date(2021, 7, 30),
      // 购房时间（网签时间）
      onlinetime: "",
      showPicker7: false,
      currentDate7: new Date(2021, 7, 30),
      type: "edit",
      phoneReg,
    };
  },
  methods: {
    init() {
      let params = {
        code: this.code,
        appId: 1234,
      };
      // alert(JSON.stringify(params))
      mattersHouseRejectDetails(params).then((res) => {
        console.log(res);
        if (res.data.staffState == 2) {
          this.existsStaff = true;
        }
      });
      mattersHouseRejectStaffList(params).then((res) => {
        // alert(JSON.stringify(res))
        console.log(res);
        this.mockList = res.data;
      });
    },
    // 列表
    // 左滑删除
    delout(item) {
      console.log(item);
      Dialog.confirm({
        message: "确定删除吗？",
      }).then(() => {
        let params = {
          staffCode: item.code,
        };
        deleteMattersStaffHouse(params).then((res) => {
          console.log("删除--------", res);
          Dialog.alert({
            message: "删除成功！",
          });
          this.init();
        });
      });
    },
    // 新增
    // add() {
    //   this.existsStaff = false;
    //   this.disable = false;
    //   this.addinfo = true;
    // },
    // 查看
    view(item) {
      console.log(item);
      let params = {
        staffCode: item.code,
      };
      mattersHouseRejectStaffInfo(params).then((res) => {
        // alert(JSON.stringify(res))
        console.log(res);
        this.form.name = res.data.name; // 申请人姓名
        this.form.idcard = res.data.idCard; // 身份证号码或护照号码
        this.form.phone = res.data.mobile; // 手机号码
        this.form.university = res.data.graduateSchool; // 毕业院校
        this.form.located = res.data.realEstateAddress; // 不动产权证坐落
        this.form.certificate = res.data.realEstateCard; // 不动产权证号
        this.form.building = res.data.square; // 建筑面积（m2）
        this.form.openbank = res.data.bank; // 个人银行卡开户行
        this.form.cardno = res.data.bankCard; // 个人银行卡号
        this.form.premium = res.data.taxesValue; // 缴纳金额
        this.form.taxable = res.data.taxableHouseValue; // 计税房价
        this.form.apply = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 3;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //个人申请表
        this.form.idimg = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 4;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //身份证照片
        this.form.bankcard = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 5;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //银行卡照
        this.form.contract = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 6;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //商品买卖合同
        this.form.estate = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 7;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //不动产权证
        this.form.payment = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 8;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //契税完税证
        this.form.employment = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 9;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //劳动聘用合同
        this.form.prove = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 10;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //证明材料
        this.talent = res.data.staffType; //人才类型
        this.graduation = res.data.graduationTime; //毕业时间
        this.education = res.data.highestEducation; // 学历
        this.degree = res.data.highestDegree; //学位
        this.provide = res.data.payEndowmentInsuranceBeginTime; //养老保险开始缴纳时间
        this.begintime = res.data.laborContractBeginTime; //劳动合同开始时间
        this.endtime = res.data.laborContractEndTime; //劳动合同介绍时间
        this.onlinetime = res.data.buyHouseTime; //购房时间
        this.disable = true;
        this.existsStaff = false; 
      });
    },
    // 编辑
    next(item) {
      this.disable = false;
      console.log(item);
      this.staffCode = item.code;
      let params = {
        staffCode: item.code,
      };
      mattersHouseRejectStaffInfo(params).then((res) => {
        // alert(JSON.stringify(res))
        console.log(res);
        this.form.rejectReason = res.data.rejectReason; // 拒绝原因
        this.form.name = res.data.name; // 申请人姓名
        this.form.idcard = res.data.idCard; // 身份证号码或护照号码
        this.form.phone = res.data.mobile; // 手机号码
        this.form.university = res.data.graduateSchool; // 毕业院校
        this.form.located = res.data.realEstateAddress; // 不动产权证坐落
        this.form.certificate = res.data.realEstateCard; // 不动产权证号
        this.form.building = res.data.square; // 建筑面积（m2）
        this.form.openbank = res.data.bank; // 个人银行卡开户行
        this.form.cardno = res.data.bankCard; // 个人银行卡号
        this.form.premium = res.data.taxesValue; // 缴纳金额
        this.form.taxable = res.data.taxableHouseValue; // 计税房价
        this.form.apply = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 3;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //个人申请表
        this.form.idimg = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 4;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //身份证照片
        this.form.bankcard = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 5;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //银行卡照
        this.form.contract = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 6;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //商品买卖合同
        this.form.estate = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 7;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //不动产权证
        this.form.payment = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 8;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //契税完税证
        this.form.employment = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 9;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //劳动聘用合同
        this.form.prove = res.data.pictureList
          .filter((item) => {
            return item.pictureType == 10;
          })
          .map((item) => {
            return { url: item.picture, pictureType: item.pictureType };
          }); //证明材料
        this.talent = res.data.staffType; //人才类型
        this.graduation = res.data.graduationTime; //毕业时间
        this.education = res.data.highestEducation; // 学历
        this.degree = res.data.highestDegree; //学位
        this.provide = res.data.payEndowmentInsuranceBeginTime; //养老保险开始缴纳时间
        this.begintime = res.data.laborContractBeginTime; //劳动合同开始时间
        this.endtime = res.data.laborContractEndTime; //劳动合同介绍时间
        this.onlinetime = res.data.buyHouseTime; //购房时间
        this.existsStaff = false;
      });
    },
    // 确定
    ensure() {
      if (this.mockList) {
        if (this.disable) {
          // 查看确定
          this.existsStaff = true;
        } else if (this.addinfo == false) {
          if (
            this.form.openbank &&
            this.form.cardno &&
            this.onlinetime &&
            this.form.university &&
            this.graduation &&
            this.education &&
            this.form.idcard &&
            this.begintime &&
            this.endtime &&
            this.form.phone &&
            this.form.name &&
            this.provide &&
            this.form.located &&
            this.form.certificate &&
            this.form.building &&
            this.talent &&
            this.form.taxable &&
            this.form.premium &&
            this.form.apply.length > 0 &&
            this.form.idimg.length > 1 &&
            this.form.bankcard.length > 0 &&
            this.form.contract.length > 0 &&
            this.form.estate.length > 0 &&
            this.form.payment.length > 0 &&
            this.form.employment.length > 0
          ) {
            if ((this.$route.query.guideId == 1000159 && this.form.prove.length > 0) || this.$route.query.guideId != 1000159) {
              // 修改确定
              // this.form.idcard = encryptByDES(this.form.idcard, "MnuYbhGv");
              let a = [];
              [
                {
                  i: this.form.apply.map((item) => {
                    return item.url;
                  }),
                  type: 3,
                }, //个人申请表
                {
                  i: this.form.idimg.map((item) => {
                    return item.url;
                  }),
                  type: 4,
                }, //身份证照片
                {
                  i: this.form.bankcard.map((item) => {
                    return item.url;
                  }),
                  type: 5,
                }, //银行卡照
                {
                  i: this.form.contract.map((item) => {
                    return item.url;
                  }),
                  type: 6,
                }, //商品买卖合同
                {
                  i: this.form.estate.map((item) => {
                    return item.url;
                  }),
                  type: 7,
                }, //不动产权证
                {
                  i: this.form.payment.map((item) => {
                    return item.url;
                  }),
                  type: 8,
                }, //契税完税证
                {
                  i: this.form.employment.map((item) => {
                    return item.url;
                  }),
                  type: 9,
                }, //劳动聘用合同
                {
                  i: this.form.prove.map((item) => {
                    return item.url;
                  }),
                  type: 10,
                }, //劳动聘用合同
              ].forEach((item) => {
                item.i.forEach((item1) => {
                  a.push({ picture: item1, pictureType: item.type });
                  return a;
                });
              });
              let params = {
                bank: this.form.openbank,
                bankCard: this.form.cardno,
                buyHouseTime: this.onlinetime,
                code: this.staffCode,
                educationState: 0,
                graduateSchool: this.form.university,
                graduationTime: this.graduation,
                highestDegree: this.degree,
                highestEducation: this.education,
                idCard: encryptByDES(this.form.idcard, "MnuYbhGv"),
                laborContractBeginTime: this.begintime,
                laborContractEndTime: this.endtime,
                mobile: this.form.phone,
                name: this.form.name,
                payEndowmentInsuranceBeginTime: this.provide,
                pictureList: a,
                realEstateAddress: this.form.located,
                realEstateCard: this.form.certificate,
                square: this.form.building,
                staffState: 0,
                staffType: this.talent,
                taxableHouseValue: this.form.taxable,
                taxesValue: this.form.premium,
                guideId: this.guideId,
                // userId: this.userInfo.userId,
              };
              // alert(JSON.stringify(params))
              mattersHouseRejectStaffUpdate(params).then((res) => {
                console.log(res);
                Dialog.alert({
                  message: "修改成功",
                }).then(() => {
                  this.form = {};
                  this.talent = "";
                  this.graduation = "";
                  this.education = "";
                  this.degree = "";
                  this.provide = "";
                  this.begintime = "";
                  this.endtime = "";
                  this.onlinetime = "";
                  this.existsStaff = true;
                  this.init();
                });
              });
            } else {
              Dialog.alert({
                message: "请上传镇江籍证明材料",
              });
            }
          } else if (this.idimg.length < 2) {
            Dialog.alert({
              message: "请将身份证照片信息上传完整",
            });
          } else {
            Dialog.confirm({
              message: "请将信息填写完整",
            });
          }
        }
        //  else if(this.addinfo == true){
        //   if (
        //     this.form.openbank &&
        //     this.form.cardno &&
        //     this.onlinetime &&
        //     this.form.university &&
        //     this.graduation &&
        //     this.degree &&
        //     this.education &&
        //     this.form.idcard &&
        //     this.begintime &&
        //     this.endtime &&
        //     this.form.phone &&
        //     this.form.name &&
        //     this.provide &&
        //     this.form.located &&
        //     this.form.certificate &&
        //     this.form.building &&
        //     this.talent &&
        //     this.form.taxable &&
        //     this.form.premium &&
        //     this.form.apply.length > 0 &&
        //     this.form.idimg.length > 0 &&
        //     this.form.bankcard.length > 0 &&
        //     this.form.contract.length > 0 &&
        //     this.form.estate.length > 0 &&
        //     this.form.payment.length > 0 &&
        //     this.form.employment.length > 0
        //   ) {
        //     // 新增确定
        //     this.form.idcard = encryptByDES(this.form.idcard, "MnuYbhGv");
        //     let a = [];
        //     [
        //       {
        //         i: this.form.apply.map((item) => {
        //           return item.url;
        //         }),
        //         type: 3,
        //       }, //个人申请表
        //       {
        //         i: this.form.idimg.map((item) => {
        //           return item.url;
        //         }),
        //         type: 4,
        //       }, //身份证照片
        //       {
        //         i: this.form.bankcard.map((item) => {
        //           return item.url;
        //         }),
        //         type: 5,
        //       }, //银行卡照
        //       {
        //         i: this.form.contract.map((item) => {
        //           return item.url;
        //         }),
        //         type: 6,
        //       }, //商品买卖合同
        //       {
        //         i: this.form.estate.map((item) => {
        //           return item.url;
        //         }),
        //         type: 7,
        //       }, //不动产权证
        //       {
        //         i: this.form.payment.map((item) => {
        //           return item.url;
        //         }),
        //         type: 8,
        //       }, //契税完税证
        //       {
        //         i: this.form.employment.map((item) => {
        //           return item.url;
        //         }),
        //         type: 9,
        //       }, //劳动聘用合同
        //     ].forEach((item) => {
        //       item.i.forEach((item1) => {
        //         a.push({ picture: item1, pictureType: item.type });
        //         return a;
        //       });
        //     });
        //     let params = {
        //       bank: this.form.openbank,
        //       bankCard: this.form.cardno,
        //       buyHouseTime: this.onlinetime,
        //       code: "",
        //       educationState: 0,
        //       graduateSchool: this.form.university,
        //       graduationTime: this.graduation,
        //       highestDegree: this.degree,
        //       highestEducation: this.education,
        //       idCard: this.form.idcard,
        //       laborContractBeginTime: this.begintime,
        //       laborContractEndTime: this.endtime,
        //       mobile: this.form.phone,
        //       name: this.form.name,
        //       payEndowmentInsuranceBeginTime: this.provide,
        //       pictureList: a,
        //       realEstateAddress: this.form.located,
        //       realEstateCard: this.form.certificate,
        //       square: this.form.building,
        //       staffState: 0,
        //       staffType: this.talent,
        //       taxableHouseValue: this.form.taxable,
        //       taxesValue: this.form.premium,
        //       guideId: this.guideId,
        //       userId: this.userInfo.userId,
        //     };
        //     saveMattersStaffHouse(params).then((res) => {
        //       console.log(res);
        //       Dialog.confirm({
        //         message: "保存成功",
        //       }).then(() => {
        //         this.form = {};
        //         this.talent = "";
        //         this.graduation = "";
        //         this.education = "";
        //         this.degree = "";
        //         this.provide = "";
        //         this.begintime = "";
        //         this.endtime = "";
        //         this.onlinetime = "";
        //         this.existsStaff = true;
        //       });
        //     });
        //   }else {
        //     Dialog.confirm({
        //       message: "请将信息填写完整",
        //     });
        //   }
        // }
      }
    },
    ensure1() {
      this.$router.go(-1);
    },
    // 详情
    // 获取人才类型
    obtain() {
      if( this.form.idcard ){
        let params = {
          idCard: this.form.idcard
        }
        mattersHouseTalentType(params).then((res) => {
          console.log(res);
          if ( res == 'A' || res == 'B' || res == 'C' || res == 'D' || res == 'E' || res == 'F') {
            this.talent = res
          } else {
            this.$dialog.alert({
              message: res
            });
            this.talent = ''
          }
        })
      }else {
        this.$dialog.alert({
          message: '请填写身份证号码或护照号码后获取'
        });
        this.talent = ''
      }
    },
    // 毕业时间
    onConfirm1() {
      let a = this.currentDate.getFullYear();
      let b =
        this.currentDate.getMonth() + 1 > 10
          ? this.currentDate.getMonth() + 1
          : "0" + (this.currentDate.getMonth() + 1);
      let c =
        this.currentDate.getDate() > 10
          ? this.currentDate.getDate()
          : "0" + this.currentDate.getDate();
      let d = a + "-" + b + "-" + c;
      // let d = a + '-' + b + '-' + c + ' ' + '00:00:00'
      this.graduation = d;
      this.showPicker1 = false;
    },
    // 学历列表
    onConfirm2(value, index) {
      this.value = value;
      this.degree = '';
      // this.placeCode = this.columns[index].id;
      this.education = this.columns2[index].label;
      this.showPicker2 = false;
    },
    // 学位列表
    onConfirm3(value, index) {
      this.value = value;
      // this.placeCode = this.columns[index].id;
      this.degree = this.columns3[index].label;
      this.showPicker3 = false;
    },
    // 市区缴纳养老保险开始时间
    onConfirm4() {
      let a = this.currentDate4.getFullYear();
      let b =
        this.currentDate4.getMonth() + 1 > 10
          ? this.currentDate4.getMonth() + 1
          : "0" + (this.currentDate4.getMonth() + 1);
      let c =
        this.currentDate4.getDate() > 10
          ? this.currentDate4.getDate()
          : "0" + this.currentDate4.getDate();
      let d = a + "-" + b + "-" + c;
      this.provide = d;
      this.showPicker4 = false;
    },
    // 劳动合同开始时间
    onConfirm5() {
      let a = this.currentDate5.getFullYear();
      let b =
        this.currentDate5.getMonth() + 1 > 10
          ? this.currentDate5.getMonth() + 1
          : "0" + (this.currentDate5.getMonth() + 1);
      let c =
        this.currentDate5.getDate() > 10
          ? this.currentDate5.getDate()
          : "0" + this.currentDate5.getDate();
      let d = a + "-" + b + "-" + c;
      this.begintime = d;
      this.showPicker5 = false;
    },
    // 劳动合同结束时间
    onConfirm6() {
      let a = this.currentDate6.getFullYear();
      let b =
        this.currentDate6.getMonth() + 1 > 10
          ? this.currentDate6.getMonth() + 1
          : "0" + (this.currentDate6.getMonth() + 1);
      let c =
        this.currentDate6.getDate() > 10
          ? this.currentDate6.getDate()
          : "0" + this.currentDate6.getDate();
      let d = a + "-" + b + "-" + c;
      this.endtime = d;
      this.showPicker6 = false;
    },
    // 购房时间（网签时间）
    onConfirm7() {
      let a = this.currentDate7.getFullYear();
      let b =
        this.currentDate7.getMonth() + 1 > 10
          ? this.currentDate7.getMonth() + 1
          : "0" + (this.currentDate7.getMonth() + 1);
      let c =
        this.currentDate7.getDate() > 10
          ? this.currentDate7.getDate()
          : "0" + this.currentDate7.getDate();
      let d = a + "-" + b + "-" + c;
      this.onlinetime = d;
      this.showPicker7 = false;
    },
    // 此时可以自行将文件上传至服务器
    afterRead(file) {
      file.status = "uploading";
      file.message = "上传中...";
      let param = new FormData();
      param.append("file", file.file);
      this.$toast.loading({
        duration: 0, // 持续展示 toast
        forbidClick: true,
        message: "上传图片中...",
      });
      uploadFile(param)
        .then((res) => {
          this.$toast.clear();
          file.status = "done";
          file.message = "上传成功";
          file.url = res;
        })
        .catch((err) => {
          console.log(err);
          file.status = "failed";
          file.message = "上传失败";
        });
    },
    // 删除信息
    del() {
      this.$dialog
        .confirm({
          message: "确定清空所填信息，返回上一级吗?",
          showCancelButton: true,
        })
        .then(() => {
          // on confirm
          this.form = {};
          this.talent = "";
          this.graduation = "";
          this.education = "";
          this.degree = "";
          this.provide = "";
          this.begintime = "";
          this.endtime = "";
          this.onlinetime = "";
          this.$router.go(-1)
        })
        .catch(() => {
          // on cancel
        });
    },
  },
  created() {
    this.departmentCode = this.$route.query.departmentCode;
    this.guideId = this.$route.query.guideId;
    this.talentCode = this.$route.query.talentCode;
    this.matterType = this.$route.query.matterType;
    this.userInfo = this.$route.query.userInfo;
    this.code = this.$route.query.code;
    this.init();
  },
};
</script>

<style lang="stylus" scoped>
// 列表
.content {
  height: calc(100vh - 220px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;

  .card {
    background: #FFFFFF;
    border-radius: 15px;
    margin: 20px 10px 0 10px;

    .top {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 20px;

      .left {
        display: flex;

        .img {
          width: 40px;
          height: 40px;
          display: flex;

          img {
            width: 100%;
            height: 100%;
          }
        }

        .name {
          font-size: 32px;
          font-family: PingFangSC-Medium, PingFang SC;
          font-weight: 500;
          color: #333333;
          padding: 0 20px;
        }
      }

      .right {
        height: 30px;
        display: flex;

        .nopass {
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #F02828;
        }

        .pass {
          font-size: 28px;
          font-family: PingFangSC-Regular, PingFang SC;
          font-weight: 400;
          color: #55D06B;
        }

        img {
          width: 30px;
          height: 30px;
          padding: 0 0 0 10px;
        }
      }
    }

    .bottom {
      font-size: 28px;
      font-family: PingFangSC-Regular, PingFang SC;
      font-weight: 400;
      color: #666666;
      padding: 0 80px 30px 80px;
    }
  }
}

.operation {
  display: flex;
  padding: 20px 30px;
  justify-content: space-between;

  .button {
    margin-right: 20px;
  }
}

// 详情
.reject {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  background: #fff;
  padding: 20px;
  border-bottom: 2px solid #f3f3f0;

  .reason {
    font-size: 28px;
    font-weight: 600;
    line-height: 40px;
  }

  .details {
    display: flex;
    flex-wrap: wrap;
    font-size: 26px;
    font-weight: 500;
    line-height: 30px;
    color: #f3654a;
  }
}

.form {
  height: calc(100vh - 220px);
  overflow-y: auto;

  .section {
    margin-bottom: 20px;
  }
}

.operation {
  display: flex;
  padding: 20px 30px;
  justify-content: space-between;

  .button {
    margin-right: 20px;
  }
}
</style>