<template>
  <div id="dataConfig">
    <search-box-new
      ref="searchBox"
      :formData="formData"
      :formList="formList"
      @search="search"
      @init="init"
      :shType="shType"
    />
    <table-list
      :tableSets="tableSet"
      :tableData="tableData"
      :navText="navText"
      @addClick="addClick"
      :loading="loading"
      @editInfo="editInfo"
    >
      <template slot="customize">
        <el-button size="small" type="success" @click="moreActive"
          >批量导出</el-button
        >
      </template>
      <template slot="btn" slot-scope="props">
        <el-button
          type="text"
          @click="addClick(props.scope.row, 0)"
          :disabled="
            !(
              props.scope.row.changeStatus === 2 || props.scope.row.status === 2
            )
          "
          >审核</el-button
        >
        <el-button type="text" @click="openRecord(props.scope.row)"
          >审核记录</el-button
        >
      </template>
    </table-list>
    <pagination
      :total="total"
      :pageSize="formData.pageSize"
      :currentPage="formData.pageNum"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
    <el-dialog
      @closed="loadingClose"
      :visible.sync="dialogVisible"
      width="900px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">资料审核</div>
        <div class="rightBoxs">
          <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
        </div>
      </div>
      <div slot="title" class="topStys">
        <div class="btnsTys">学员编码：{{ listData.userAccount }}</div>
        <div class="btnsTys">学员姓名：{{ listData.realname }}</div>
        <div class="btnsTys">学员身份证号码：{{ listData.idCard }}</div>
        <div class="btnsTys">绑定手机号码：{{ listData.telphone }}</div>
        <div style="clear: both"></div>
      </div>
      <div class="heightstybox gdt">
        <ul>
          <li class="dissty" v-for="(item, index) in listInfos" :key="index">
            <div
              style="
                width: 50px;
                color: red;
                align-self: flex-start;
                flex-shrink: 0;
              "
            >
              {{ item.status === 1 ? "有变更" : "" }}
            </div>
            <div class="stys">{{ item.fieldName }}：</div>
            <div v-if="pdStatus(item.fieldKey)">
              <div
                v-if="item.fieldKey === 'recent_photos'"
                style="width: 145px; height: 160px"
              >
                <el-image
                  v-if="item.value"
                  style="width: 100%; height: 100%"
                  :src="$methodsTools.splitImgHost(item.value)"
                  :preview-src-list="[$methodsTools.splitImgHost(item.value)]"
                >
                </el-image>
                <p v-else>暂无上传图片</p>
              </div>
              <div v-else-if="item.fieldKey === 'commitment_electr_signature'">
                <div>
                  本人自愿做出如下承诺：本人己仔细阅读《广东
                  省住房和城乡建设厅关于推进住房和城乡建设领域施
                  工现场专业人员职业培训工作的通知》
                  全部内容并知晓和理解，本人的学历证书、身份证、工作年限、相片等所有资料完全真实、符合报名条件、资格审查要求和相关规定，本人在报名、审查、培训、测试等有关的事项中会严格道守相关规定和要求，如有虛假或与实际规定不符等情况造成的一切后果由本人承担。
                  特此承诺！
                </div>
                <div
                  style="width: 300px; height: 150px; border: 1px solid #999"
                  v-if="item.value"
                >
                  <el-image
                    style="width: 100%; height: 100%"
                    :src="$methodsTools.splitImgHost(item.value)"
                    :preview-src-list="[$methodsTools.splitImgHost(item.value)]"
                  >
                  </el-image>
                </div>
                <p v-else>暂无上传图片</p>
              </div>
              <div v-else style="width: 224px; height: 160px">
                <el-image
                  v-if="item.value"
                  style="width: 100%; height: 100%"
                  :src="$methodsTools.splitImgHost(item.value)"
                  :preview-src-list="[$methodsTools.splitImgHost(item.value)]"
                >
                </el-image>
                <p v-else>暂无上传图片</p>
              </div>
            </div>
            <div v-else>{{ item.value }}</div>
          </li>
          <li class="dissty" style="border-bottom: none">
            <div class="stys">审核结果反馈：</div>
            <el-input
              v-model="listData.text"
              type="textarea"
              :rows="5"
            ></el-input>
          </li>
        </ul>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="close">取 消</el-button>
        <el-button :loading="disabledBtn" @click="submitTable(1)" type="success"
          >审核通过</el-button
        >
        <el-button :loading="disabledBtn" @click="submitTable(3)" type="danger"
          >审核不通过</el-button
        >
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogVisibleRecord"
      width="900px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">资料审核</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogVisibleRecord = false"
          />
        </div>
      </div>
      <div slot="title" class="topStys">
        <div class="btnsTys">
          学员编码：{{ recordList[activeIndex].userAccount }}
        </div>
        <div class="btnsTys">
          学员姓名：{{ recordList[activeIndex].realname }}
        </div>
        <div class="btnsTys">
          学员身份证号码：{{ recordList[activeIndex].idCard }}
        </div>
        <div class="btnsTys">
          绑定手机号码：{{ recordList[activeIndex].telphone }}
        </div>
        <div style="clear: both"></div>
      </div>
      <el-row :gutter="20">
        <el-col :span="6">
          <ul class="max_heightAuto">
            <li
              class="lsTYs"
              v-for="(item, index) in recordList"
              :key="index"
              :class="index === activeIndex ? 'active' : ''"
              @click="changeIndex(index)"
            >
              {{ $methodsTools.onlyForma(item.auditTime) }}
            </li>
          </ul>
        </el-col>
        <el-col :span="18">
          <transition>
            <div class="heightstybox gdt" v-if="showIS">
              <ul>
                <li>
                  <div class="float_lefts">
                    审核人：{{ recordList[activeIndex].createByName }}
                  </div>
                  <div class="float_lefts">
                    {{
                      recordList[activeIndex].status === 1
                        ? "审核通过"
                        : recordList[activeIndex].status === 2
                        ? "待审核"
                        : recordList[activeIndex].status === 3
                        ? "审核不通过"
                        : "无审核状态"
                    }}
                  </div>
                  <div style="clear: both"></div>
                </li>
                <li
                  class="dissty"
                  v-for="(item, index) in recordList[activeIndex]
                    .keyValueArrays"
                  :key="index"
                >
                  <div class="stys">{{ item.fieldName }}：</div>
                  <div v-if="pdStatus(item.fieldKey)">
                    <div
                      v-if="item.fieldKey === 'recent_photos'"
                      style="width: 145px; height: 160px"
                    >
                      <el-image
                        v-if="item.value"
                        style="width: 100%; height: 100%"
                        :src="$methodsTools.splitImgHost(item.value)"
                        :preview-src-list="[
                          $methodsTools.splitImgHost(item.value),
                        ]"
                      >
                      </el-image>
                      <p v-else>暂无上传图片</p>
                    </div>
                    <div
                      v-else-if="
                        item.fieldKey === 'commitment_electr_signature'
                      "
                    >
                      <div>
                        本人自愿做出如下承诺：本人己仔细阅读《广东
                        省住房和城乡建设厅关于推进住房和城乡建设领域施
                        工现场专业人员职业培训工作的通知》
                        全部内容并知晓和理解，本人的学历证书、身份证、工作年限、相片等所有资料完全真实、符合报名条件、资格审查要求和相关规定，本人在报名、审查、培训、测试等有关的事项中会严格道守相关规定和要求，如有虛假或与实际规定不符等情况造成的一切后果由本人承担。
                        特此承诺！
                      </div>
                      <div
                        style="
                          width: 300px;
                          height: 150px;
                          border: 1px solid #999;
                        "
                        v-if="item.value"
                      >
                        <el-image
                          style="width: 100%; height: 100%"
                          :src="$methodsTools.splitImgHost(item.value)"
                          :preview-src-list="[
                            $methodsTools.splitImgHost(item.value),
                          ]"
                        >
                        </el-image>
                      </div>
                      <p v-else>暂无上传图片</p>
                    </div>
                    <div v-else style="width: 224px; height: 160px">
                      <el-image
                        v-if="item.value"
                        style="width: 100%; height: 100%"
                        :src="$methodsTools.splitImgHost(item.value)"
                        :preview-src-list="[
                          $methodsTools.splitImgHost(item.value),
                        ]"
                      >
                      </el-image>
                      <p v-else>暂无上传图片</p>
                    </div>
                  </div>
                  <div v-else>{{ item.value }}</div>
                </li>
                <li class="dissty" style="border-bottom: none">
                  <div class="stys">审核结果反馈：</div>
                  <div>
                    {{ recordList[activeIndex].text }}
                  </div>
                </li>
              </ul>
            </div>
          </transition>
        </el-col>
      </el-row>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogVisibleRecord = false">取 消</el-button>
      </span>
    </el-dialog>
    <el-dialog
      :visible.sync="dialogDR"
      width="660px"
      :show-close="false"
      :close-on-click-modal="false"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">批量导出</div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Close@2x.png"
            alt=""
            @click="dialogDR = false"
          />
        </div>
      </div>
      <div>
        <div class="swq">
          <img
            style="width: 182px; height: 168px"
            src="@/assets/images/dr.png"
            alt=""
          />
        </div>
        <div style="padding: 40px">
          <el-row>
            <el-col :span="12"><div style="text-align:end;padding-right:14px;">填写资料审核状态： </div></el-col>
            <el-col :span="12">
              <el-radio-group v-model="activeDCIndex">
                <el-radio
                style="display:block;margin-bottom:16px;"
                  v-for="(items, indexs) in DCLIST"
                  :key="indexs"
                  :label="items.value"
                  >{{ items.label }}</el-radio
                >
              </el-radio-group>
            </el-col>
          </el-row>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="dialogDR = false">取消</el-button>
        <el-button type="primary">确定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
import searchBoxNew from "@/components/searchBoxNew";
import tableList from "@/components/tableList";
import pagination from "@/components/pagination";
export default {
  name: "DataConfig",
  components: { searchBoxNew, tableList, pagination },
  data() {
    return {
      dialogDR: false,
      disabledBtn: false,
      dialogVisibleRecord: false,
      shType: true,
      loading: false, //当前表单加载是否加载动画
      navText: {
        title: "填写资料审核",
        index: 0,
        ch: "条",
        num: true,
        border: true,
        choice: true,
        addHide: true,
        backFatherBtn: {
          status: false,
          title: "未定义",
        },
      },
      //搜索
      formList: [
        {
          prop: "educationTypeId",
          placeholder: "教育类型",
          scope: "educationType",
        },
        {
          prop: "businessId",
          placeholder: "业务层次",
          scope: "businessLevel",
          edu: "educationTypeId",
        },
        {
          prop: "schoolId",
          placeholder: "院校",
          scope: "schoolList",
          edu: "educationTypeId",
        },
        {
          prop: "majorId",
          placeholder: "专业",
          scope: "Professional",
          edu: "educationTypeId",
        },
        {
          prop: "changeStatus",
          placeholder: "变更状态",
          scope: "select",
          options: [
            {
              label: "正常",
              value: 1,
            },
            {
              label: "有变更",
              value: 2,
            },
          ],
        },
        {
          prop: "realname",
          placeholder: "请输入学员姓名",
        },
      ],
      formData: {
        status: "",
        pageSize: 10,
        pageNum: 1,
      },
      showIS: true,
      // 表单
      tableSet: [
        {
          label: "学员编码",
          prop: "userAccount",
          hidden: true,
        },
        {
          label: "学员姓名",
          prop: "realname",
          hidden: true,
        },

        {
          label: "学员身份证",
          prop: "idCard",
          hidden: true,
          width: "160px",
        },
        {
          label: "绑定手机号",
          prop: "telphone",
          hidden: true,
          width: "140px",
        },
        {
          label: "所购商品",
          hidden: true,
          width: "280px",
          scope: "getShops",
        },
        {
          label: "填写资料审核状态",
          prop: "status",
          hidden: true,
          scope: "isOptions",
          width: "160px",
          options: [
            {
              label: "通过",
              value: 1,
            },
            {
              label: "待审核",
              value: 2,
            },
            {
              label: "不通过",
              value: 3,
            },
          ],
        },
        {
          label: "填写资料变更状态",
          prop: "changeStatus",
          hidden: true,
          scope: "isOptions",
          width: "160px",
          options: [
            {
              label: "正常",
              value: 1,
            },

            {
              label: "有变更",
              value: 2,
              style: "color:red",
            },
          ],
        },
        {
          label: "第一次提交资料时间",
          prop: "oneTime",
          hidden: true,
          scope: "aTimeList",
          width: "160px",
        },
        {
          label: "最后一次提交资料时间",
          prop: "lastTime",
          hidden: true,
          scope: "aTimeList",
          width: "180px",
        },
        {
          label: "最后一次审核人",
          prop: "createByName",
          hidden: true,
          width: "160px",
        },
        {
          label: "最后一次审核时间",
          prop: "auditTime",
          hidden: true,
          scope: "aTimeList",
          width: "160px",
        },
      ],
      tableData: [], //表单数据
      total: 0, //一共多少条
      //   弹窗数据
      listData: {},
      statusPop: -1,
      dialogVisible: false,
      //表单验证
      rules: {
        natureName: [
          { required: true, message: "请输入收费性质名称", trigger: "blur" },
        ],
        status: [{ required: true, message: "请选择状态", trigger: "change" }],
      },
      listInfos: [],
      recordList: [{ keyValueArrays: [] }], //记录列表
      activeIndex: 0,
      activeDCIndex: 1, //导出按钮索引
      DCLIST: [
        { label: "全部", value: 1 },
        { label: "待审核", value: 2 },
        { label: "审核通过", value: 3 },
        { label: "审核不通过", value: 4 },
      ], //导出按钮列表
    };
  },
  mounted() {
    this.search();
  },
  activated() {
    this.search();
  },
  methods: {
    moreActive() {
      this.activeDCIndex = 1;
      this.dialogDR = true;
    },
    changeIndex(v) {
      if (this.activeIndex === v) {
        return;
      }
      this.showIS = false;
      this.activeIndex = v;
      setTimeout(() => {
        this.showIS = true;
      }, 50);
    },
    openRecord(v) {
      this.$api
        .inquirebaseprofilelistRecord({ userId: v.userId, goodsId: v.goodsId })
        .then((res) => {
          if (!res.rows.length) {
            this.$message.warning("该条数据无审核记录");
            return;
          }
          res.rows.forEach((item) => {
            item.keyValue = JSON.parse(item.keyValue);
            var arst = [];
            for (let k in item.keyValue) {
              arst.push(item.keyValue[k]);
            }
            item.keyValueArrays = arst;
          });

          this.recordList = res.rows;
          this.dialogVisibleRecord = true;
        });
    },
    pdStatus(int) {
      if (
        int === "recent_photos" ||
        int === "idcard_face_photo" ||
        int === "idcard_national_photo" ||
        int === "commitment_electr_signature"
      ) {
        return true;
      }
    },
    //1通过 3不通过
    submitTable(int) {
      this.disabledBtn = true;
      var data = JSON.parse(JSON.stringify(this.listData));
      for (let k in data.keyValue) {
        data.keyValue[k].status = 0;
      }
      data.keyValue = JSON.stringify(data.keyValue);
      data.status = int;
      data.changeStatus = 1;
      this.$api
        .editbaseprofilesss(data)
        .then((res) => {
          this.$message.success("提交成功");
          this.search();
          this.dialogVisible = false;
        })
        .catch(() => {
          this.disabledBtn = false;
        });
    },
    loadingClose() {
      this.disabledBtn = false;
    },
    editInfo(v) {
      this.addClick(v, 0);
    },
    search(int) {
      this.loading = true;
      if (int === 1) {
        this.formData.pageNum = 1;
      }
      if (int === 2) {
        this.formData = {
          status: "",
          pageSize: 10,
          pageNum: 1,
        };
      }
      this.$api
        .inquirebaseprofile(this.formData)
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.navText.index = res.total;
        })
        .finally(() => {
          this.loading = false;
        });
    },
    init() {
      this.search(2);
    },
    del(v) {
      this.$alert(
        "确定删除此内容？<br />内容删除后将无法恢复，请慎重考虑",
        "提示",
        {
          dangerouslyUseHTMLString: true,
        }
      )
        .then(() => {
          var data = {
            natureId: v.natureId,
            status: -1,
          };
          this.$api.editpaynature(data).then((res) => {
            this.$message.success("删除成功");
            this.search();
          });
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    addClick(v, int) {
      if (v === undefined) {
        this.listData = {};
      } else {
        this.$api.obtainbaseprofile(v.id).then((res) => {
          res.data.keyValue = JSON.parse(res.data.keyValue);
          this.listData = res.data;
          var arst = [];
          for (let k in res.data.keyValue) {
            arst.push(res.data.keyValue[k]);
          }
          this.listInfos = arst;
        });
      }
      this.dialogVisible = true;
    },
    submit() {
      this.disabledBtn = true;
      return;
      if (this.statusPop === 1) {
        this.$api
          .apppaynature(this.listData)
          .then((res) => {
            this.$message.success("新增成功");
            this.dialogVisible = false;
            this.search();
          })
          .catch(() => {
            this.disabledBtn = false;
          });
      }
      if (this.statusPop === 0) {
        this.$api
          .editpaynature(this.listData)
          .then((res) => {
            this.$message.success("修改成功");
            this.dialogVisible = false;
            this.search();
          })
          .catch(() => {
            this.disabledBtn = false;
          });
      }
    },
    close() {
      this.dialogVisible = false;
    },
    handleSizeChange(v) {
      this.formData.pageSize = v;
      this.formData.pageNum = 1;
      this.search();
    },
    handleCurrentChange(v) {
      this.formData.pageNum = v;
      this.search();
    },
  },
};
</script>

<style lang="less" scoped>
// 进入前和结束后的状态
.v-enter,
.v-leave-to {
  opacity: 0;
  // transform: translateX(80px);
}
// 进入和离开的动画时间段
.v-enter-active,
.v-leave-active {
  transition: all 0.5s ease;
}
.gdt {
  /* 设置滚动条的样式 */
  &::-webkit-scrollbar {
    width: 8px;
  }
  /* 滚动槽 */
  &::-webkit-scrollbar-track {
    -webkit-box-shadow: inset 6px rgba(0, 0, 0, 0.3);
    border-radius: 10px;
  }
  /* 滚动条滑块 */
  &::-webkit-scrollbar-thumb {
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.1);
    -webkit-box-shadow: inset 06px rgba(0, 0, 0, 0.5);
  }
  &::-webkit-scrollbar-thumb:window-inactive {
    background: rgba(182, 182, 182, 0.4);
  }
}
.max_heightAuto {
  padding: 0px 10px;
  max-height: 560px;
  overflow-y: auto;
}
.float_lefts {
  float: left;
  padding: 0px 10px;
  border-radius: 12px;
  background-color: #eee;
  height: 35px;
  line-height: 35px;
  margin-right: 10px;
}
.lsTYs {
  height: 40px;
  border-top: 1px solid #999;
  border-left: 1px solid #999;
  border-right: 1px solid #999;
  line-height: 40px;
  cursor: pointer;
  text-align: center;
  &:last-child {
    border-bottom: 1px solid #999 !important;
  }
}
.swq {
  text-align: center;
  border-bottom: 1px solid #eee;
}
.active {
  color: blue;
}
.heightstybox {
  padding: 20px;
  height: 600px;
  overflow-y: auto;
}
.dissty {
  display: flex;
  align-items: center;
  padding: 20px;
  border-bottom: 1px dotted #999;
}
.stys {
  flex-shrink: 0;
  align-self: flex-start;
  width: 200px;
  padding-left: 50px;
}
.topStys {
  padding: 20px;
  background-color: rgb(215, 215, 215);
  display: flex;
  align-items: center;
  overflow-x: auto;

  .btnsTys {
    flex-shrink: 0;
    margin-right: 16px;
    padding: 0px 7px;
    background-color: #fff;
    border-radius: 4px;
    font-size: 14px;
    height: 40px;
    line-height: 40px;
  }
}
/deep/.el-button {
  border-radius: 8px;
}
/deep/ .el-dialog__body {
  padding: 10px 0px;
}
/deep/.el-dialog {
  border-radius: 8px;
  .el-dialog__header {
    padding: 0;
    .hearders {
      height: 40px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0px 18px 0px 20px;
      border-bottom: 1px solid #e2e2e2;
      .leftTitle {
        font-size: 14px;
        font-weight: bold;
        color: #2f4378;
      }
      .rightBoxs {
        display: flex;
        align-items: center;
        img {
          width: 14px;
          height: 14px;
          margin-left: 13px;
          cursor: pointer;
        }
      }
    }
  }
  .el-dialog__footer {
    padding: 0;
    .dialog-footer {
      padding: 0px 40px;
      height: 70px;
      border-top: 1px solid #e2e2e2;
      display: flex;
      align-items: center;
      justify-content: center;
    }
  }
}
.imgBox {
  width: 100%;
  // height: 210px;
  border: 1px solid #e2e2e2;
  border-radius: 8px;
  padding: 8px 8px 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  .imgLabel {
    flex: 1;
    width: 100%;
    border: 1px dotted #e2e2e2;
    color: #999;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    .msPhoto {
      display: flex;
      justify-content: center;
      align-items: center;
      max-width: 100%;
      max-height: 270px;
      img {
        max-width: 100%;
        max-height: 270px;
      }
    }
    .imgbbx {
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      width: 100%;
      height: 100%;
      i {
        font-weight: bold;
        margin: 14px 0;
        font-size: 24px;
      }
    }
  }
  p {
    margin: 5px 0px;
  }
}
</style>

