<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="100px"
    >
      <el-form-item label="用户名称" prop="UserName">
        <el-input
          v-model="queryParams.UserName"
          placeholder="请输入用户名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item label="身份证" prop="UserCord">
        <el-input
          v-model="queryParams.UserCord"
          placeholder="请输入身份证"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>

      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
      </el-form-item>
    </el-form>

    <el-table v-loading="loading" :data="personList">
      <el-table-column label="序号" align="center">
        <template slot-scope="scope">
          <span>{{ handleTableIndex(scope.$index, queryParams) }}</span>
        </template>
      </el-table-column>
      <el-table-column label="期次" align="center" prop="QiciYear">
        <template slot-scope="scope">
          <span
            >{{ scope.row.QiciYear }}年{{
              scope.row.Qici ? `第${scope.row.Qici}期` : ""
            }}</span
          >
        </template>
      </el-table-column>
      <el-table-column label="姓名" align="center" prop="UserName" />
      <el-table-column label="性别" align="center" prop="UserSex" />
      <el-table-column
        label="身份证号"
        align="center"
        prop="UserCord"
        width="200"
      />
      <el-table-column label="培训类别" align="center" prop="" width="150">
        <template>
          <span>监理工程师</span>
        </template>
      </el-table-column>
      <el-table-column
        label="证书编号"
        align="center"
        prop="zgzsh"
        width="200"
      />

      <el-table-column
        label="报名时间"
        align="center"
        prop="AddDate"
        width="150"
      />
      <el-table-column
        label="是否交费"
        align="center"
        prop="FeeShenheTime"
        width="150"
      >
        <template slot-scope="scope">
          <el-tag :type="scope.row.FeeFlg == 0 ? 'danger' : 'success'">{{
            scope.row.FeeFlg == 0 ? "未收费" : "已收费"
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="是否学完">
        <template slot-scope="scope">
          <el-tag :type="scope.row.wanchengflg == 0 ? 'danger' : 'success'">{{
            scope.row.wanchengflg == 0 ? "未学完" : "已学完"
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="是否考过">
        <template slot-scope="scope">
          <el-tag v-if="scope.row.PassState == 0" type="success">
            已通过
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            @click="handleViewDetails(scope.row)"
            icon="el-icon-view"
            type="text"
            size="mini"
            >详细</el-button
          >
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <el-dialog
      title="监理工程师网络教育报名详细信息"
      :visible.sync="enrollDia"
      width="1000px"
      :before-close="
        () => {
          enrollDia = false;
        }
      "
    >
      <div v-loading="isLoading">
        <Subheading titleText="企业信息">
          <el-form size="mini" label-width="120px" :inline="true">
            <el-form-item label="企业名称">
              <el-input readonly :value="companiesFormData.qyname"></el-input>
            </el-form-item>
            <el-form-item label="负责人姓名">
              <el-input readonly :value="companiesFormData.name"></el-input>
            </el-form-item>
            <el-form-item label="邮政编码">
              <el-input readonly :value="companiesFormData.yzbm"></el-input>
            </el-form-item>
            <el-form-item label="电子邮箱">
              <el-input readonly :value="companiesFormData.lxryx"></el-input>
            </el-form-item>
            <el-form-item label="手机号码">
              <el-input readonly :value="companiesFormData.photo"></el-input>
            </el-form-item>
          </el-form>
        </Subheading>
        <Subheading titleText="监理工程师信息">
          <el-form size="mini" label-width="120px" :inline="true">
            <el-form-item label="姓名">
              <el-input readonly :value="personFormData.UserName"></el-input>
            </el-form-item>
            <el-form-item label="证书类别">
              <el-input readonly value="监理工程师"></el-input>
            </el-form-item>
            <el-form-item label="证书签发日期">
              <el-input readonly :value="personFormData.QianFaDate"></el-input>
            </el-form-item>
            <el-form-item label="性别">
              <el-input readonly :value="personFormData.UserSex"></el-input>
            </el-form-item>
            <el-form-item label="证书编号">
              <el-input readonly :value="personFormData.zgzsh"></el-input>
            </el-form-item>
            <el-form-item label="联系电话">
              <el-input readonly :value="personFormData.UserPhone"></el-input>
            </el-form-item>
            <el-form-item label="职称">
              <el-input
                readonly
                :value="personFormData.zhichengzhicheng"
              ></el-input>
            </el-form-item>
            <el-form-item label="身份证号">
              <el-input readonly :value="personFormData.UserCord"></el-input>
            </el-form-item>
            <el-form-item label="证书有效期至">
              <el-input readonly :value="personFormData.Yxqz"></el-input>
            </el-form-item>
            <el-form-item label="学历">
              <el-input readonly :value="personFormData.xueli"></el-input>
            </el-form-item>
            <el-form-item label="职称批准单位">
              <el-input
                readonly
                :value="personFormData.ZCpizhunDept"
              ></el-input>
            </el-form-item>
          </el-form>
        </Subheading>
        <Subheading titleText="监理工程师业绩/简历">
          <el-table :data="yjList" style="width: 90%; margin: 0 auto">
            <el-table-column
              label="序号"
              align="center"
              type="index"
            ></el-table-column>
            <el-table-column align="center" label="添加时间">
              <template slot-scope="scope">
                <span>{{ parseTime(scope.row.Nian, "{y}-{m}-{d}") }}</span>
              </template>
            </el-table-column>
            <el-table-column
              align="center"
              label="工作单位"
              prop="QYLoginName"
            ></el-table-column>
            <el-table-column align="center" label="监理工程师业绩/简历">
              <template slot-scope="scope">
                <el-button
                  size="small"
                  @click="
                    viewDia = true;
                    activeText = scope.row.zyJianSheYeJi;
                  "
                  type="text"
                  >查看</el-button
                >
              </template>
            </el-table-column>
          </el-table>
        </Subheading>
        <Subheading titleText="开票信息">
          <el-form size="mini" label-width="120px" :inline="true">
            <div>
              <el-form-item disabled label="开票类型">
                <el-radio-group v-model="personFormData.kplx">
                  <el-radio label="0">增值税普通发票</el-radio>
                  <el-radio label="1">个人</el-radio>
                  <el-radio label="2">企业</el-radio>
                </el-radio-group>
              </el-form-item>
            </div>
            <div v-if="personFormData.kplx == '1'">
              <el-form-item label="个人姓名">
                <el-input readonly :value="personFormData.kpdw"></el-input>
              </el-form-item>
              <el-form-item label="个人邮箱">
                <el-input readonly :value="personFormData.kpGRemail"></el-input>
              </el-form-item>
            </div>
            <div v-if="personFormData.kplx == '2'">
              <el-form-item label="开票方式">
                <el-input readonly :value="personFormData.kpfs"></el-input>
              </el-form-item>
              <el-form-item label="开票单位">
                <el-input readonly :value="personFormData.kpdw"></el-input>
              </el-form-item>
              <el-form-item label="纳税人识别号">
                <el-input readonly :value="personFormData.nsrsbh"></el-input>
              </el-form-item>
              <el-form-item label="注册地址">
                <el-input readonly :value="personFormData.kpzcdz"></el-input>
              </el-form-item>
              <el-form-item label="注册电话">
                <el-input readonly :value="personFormData.kpzcdh"></el-input>
              </el-form-item>
              <el-form-item label="开户银行">
                <el-input readonly :value="personFormData.kpkhyh"></el-input>
              </el-form-item>
              <el-form-item label="银行账号">
                <el-input readonly :value="personFormData.yhzh"></el-input>
              </el-form-item>
              <el-form-item label="电子发票邮箱">
                <el-input readonly :value="personFormData.dzfpyx"></el-input>
              </el-form-item>
            </div>
          </el-form>
        </Subheading>

        <!-- <Subheading titleText="邮寄信息">
          <el-form size="mini" label-width="120px" :inline="true">
            <el-form-item label="收件人姓名">
              <el-input  :value="personFormData.sjr"></el-input>
            </el-form-item>
            <el-form-item label="邮寄地址">
              <el-input :value="personFormData.yjdz"></el-input>
            </el-form-item>
            <el-form-item label="收件人手机">
              <el-input :value="personFormData.sjrsj"></el-input>
            </el-form-item>
            <el-form-item label="邮政编码">
              <el-input :value="personFormData.yjbm"></el-input>
            </el-form-item>
          </el-form>
        </Subheading> -->

        <Subheading titleText="证件信息">
          <el-form size="mini" label-width="120px" :inline="true">
            <el-form-item
              v-for="item of personFormData.JsonProperty"
              :key="item.ID"
              :label="item.ZJName"
            >
              <el-image
                style="width: 100px; height: 100px"
                :src="item.ZJImgUrl"
                :preview-src-list="[imageBaseUrl + item.ZJImgUrl]"
              >
                <div slot="error" class="image-slot">
                  <i
                    style="font-size: 43px"
                    class="el-icon-picture-outline"
                  ></i>
                </div>
              </el-image>
            </el-form-item>
          </el-form>
        </Subheading>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="enrollDia = false">关 闭</el-button>
      </span>
    </el-dialog>

    <el-dialog
      title="业绩/简历查看"
      :visible.sync="viewDia"
      width="50%"
      :before-close="
        () => {
          viewDia = false;
        }
      "
    >
      <div v-html="activeText"></div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="viewDia = false">关 闭</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import { listPerson } from "@/api/xiehui/jxjy/onpayment";
import {
  getInquiryDetails,
  getPersonDetails,
} from "@/api/qiye/personnelInquiry";
import { handleTableIndex } from "@/utils/index";
export default {
  name: "Person",
  data() {
    return {
      viewDia: false,
      imageBaseUrl: process.env.VUE_APP_BASE_API,
      yjList: [],
      activeText: null,
      companiesFormData: {},
      //人员信息
      personFormData: {},

      enrollDia: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      isLoading: false,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // VIEW表格数据
      personList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        BMdept: this.$store.state.user.userInfo.id,
      },
    };
  },
  created() {
    this.getList();
  },
  methods: {
    //查看详细
    handleViewDetails(row) {
      this.isLoading = true;
      getPersonDetails({
        PersonId: row.PersonId,
      }).then((res) => {
        this.personFormData = res.data.person;
        this.companiesFormData = res.data.qiye;
        this.yjList = res.data.yjlist;
        this.isLoading = false;
      });
      this.enrollDia = true;
    },
    handleTableIndex,
    /** 查询VIEW列表 */
    getList() {
      this.loading = true;
      listPerson(this.queryParams).then((response) => {
        this.personList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },

    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "system/person/export",
        {
          ...this.queryParams,
        },
        `person_${new Date().getTime()}.xlsx`
      );
    },
  },
};
</script>

<style lang="scss" scoped>
.subheading {
}
</style>
