<template>
  <div>
    <title-bar title="工作单位">
      <van-icon slot="left" name="cross" size="24" />
    </title-bar>
    <div class="work-unit-content">
      <div class="work-unit-title">
        <div>{{ dataBasic.EMPLOYMENT }}</div>
        <div @click="goCompanySearch">企业查询</div>
      </div>
      <div>
        <table-double-view
          :keyValue="keyValueDouble"
          :data="dataBasic"
        ></table-double-view>
      </div>
      <van-popup
        v-model="searchPop"
        :close-on-click-overlay="false"
        closeable
        :style="{ height: '55%', width: '70%' }"
      >
        <div>
          <div class="popup-heater">公司选择</div>
          <div class="popup-body">
            <div class="popup-input-content">
              <div style="width:100%;" v-for="(item,index) in mainArray" :key="index">
                <div @click="clickItem(item)" class="companyItem">{{item.entName}}</div>
                <div class="line-style"></div>
              </div>
            </div>
          </div>
        </div>
      </van-popup>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Vue } from "vue-property-decorator";
import { NativeUI } from "@/public/ts/NativeUI";
import nettyApi from "@/constants/api/ms-netty/netty.api.ts";
import IF from "@/public/factory/InterFaceFactory";
import TableDoubleView from "@/public/TableDoubleView.vue";
import Public from "@/public/ts/Public";
/**
 * @Description 工作单位
 * @Author JiangTao
 * @Date 2021-11-10 下午 03:20
 */
@Component({
  name: "Employer",
  components: { TableDoubleView },
})
export default class Employer extends Vue {
  keyValueDouble = {
    POSITION: "职称",
    OCCUPATION: "职业",
    JOBYEARS: "目前工作持续年限(年)",
    WORKTYPE: "岗位性质",
    COMPANYADD: "单位地址",
    COMPANYTEL: "单位电话",
  };
  dataBasic: any = {};
  pageTitle = ""; // 页面标题
  mainArray:any = []; //公司数组
  value = "";
  flagShow = false; //展示搜索结果
  searchPop = false; //搜索弹出框
  // 查询工作单位信息
  selectInfoWork() {
    const param = {
      CUSTOMERID: this.$route.query.CUSTOMERID,
      tc: nettyApi.TRADE_CODE.selectPersonalWorkInfo,
    };
    NativeUI.showWaiting("正在查询...");
    return IF.transferDataInter(nettyApi.commonRq, param).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc == "1") {
        this.dataBasic = res;
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }
  //跳转到企业详情页面
  goCompanySearch() {
    this.onSearch();
  }
  onSearch() {
    const parm = {
      tc: nettyApi.TRADE_CODE.selectDim,
      ProdId: Public.getProdId(),
      SvrCode: Public.getSvrCode(nettyApi.TRADE_CODE.selectDim),
      ClientNo: "",
      name: this.dataBasic.EMPLOYMENT,
      orgTypes: "",
    };
    NativeUI.showWaiting("正在查询.....");
    IF.transferDataInter(nettyApi.commonRq, parm).then((res: any) => {
      NativeUI.closeWaiting();
      if (res.rc == "1") {
        this.mainArray = res.dataList;
        this.searchPop = true;
      } else {
        if (res.ret_code != "4999999" && res.ret_code != "000001") {
          NativeUI.toast(res.msg);
        }
      }
    });
  }
  mounted() {
    this.searchPop = false; //把弹窗置空
    this.selectInfoWork();
  }
  clickItem(item: any) {
    const parm = {
      tc: nettyApi.TRADE_CODE.selectCus,
      cus_name: item.entName,
    };
    NativeUI.showWaiting("正在查询...");
    IF.transferDataInter(nettyApi.commonRq, parm).then((res: any) => {
      NativeUI.closeWaiting();
      console.log(res);
      if (res.rc == "1") {
        this.searchPop = false;
        const cusinfo = {
          cus_name: res.cus_name,
          cert_type: res.cert_type,
          cert_code: res.cert_code,
          exist_flag: res.exist_flag,
          cus_id: res.cus_id,
          cus_status: res.cus_status,
        };
        this.$store.commit("setCusInfo", cusinfo);
        this.$router.push({
          path: "/CompanyDetails",
        });
      } else {
        NativeUI.toast(res.msg);
      }
    });
  }
}
</script>

<style scoped>
.work-unit-content {
  width: 82%;
  margin: 0 auto;
  margin-top: 2.5%;
  padding: 2% 3%;
  border: 1px solid rgba(215, 215, 215, 1);
  border-radius: 7px;
}
.work-unit-title {
  display: flex;
  justify-content: flex-start;
  align-items: flex-end;
}
.work-unit-title > div:nth-child(1) {
  font-size: 18px;
  color: #333333;
  font-weight: bold;
  margin-right: 3%;
  font-family: "苹方 粗体", "苹方 中等", "苹方";
}
.work-unit-title > div:nth-child(2) {
  color: #02a7f0;
}
table {
  width: 80%;
  margin: 0 auto;
}
table tr td {
  font-size: 16px;
  padding: 1%;
  font-family: "Arial Normal", "Arial";
}
table tr > td:nth-child(1),
table tr > td:nth-child(3) {
  text-align: right;
  color: #666666;
}
.popup-input-content {
  width: 80%;
  margin: 0 10%;
  margin-top: 10px;
  align-items: center;
  justify-content: center;
  display: flex;
  flex-direction: column;
}
.popup-heater {
  width: 100%;
  height: 13%;
  line-height: 55px;
  padding-left: 3%;
  font-size: 18px;
  font-family: "Arial Normal", "Arial";
  border-bottom: 1px solid #d7d7d7;
}
.popup-body {
  width: 96%;
  height: 70%;
  padding: 3.5% 0;
  margin: 0 auto;
}
.popup-footer {
  width: 50%;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-content: center;
}
.popup-footer button {
  flex: 1;
  border-radius: 30px;
  padding: 2% 0;
  margin: 0 2%;
  font-size: 16px;
}
.popup-footer > button:nth-child(1) {
  border: 1px solid #d7d7d7;
  color: #999999;
  background-color: white;
}
.popup-footer > button:nth-child(2) {
  border: 1px solid #fd5065;
  color: white;
  background-color: #fd5065;
}
.companyItem{
  font-size: 18px;
  width: 100%;
  font-weight: bold;
  line-height: 40px;
}
.line-style{
  height: 1px;
  width: 100%;
  background-color: #e0e1e2;
}
</style>
