<template>
  <div id="personalManagement">
    <search-box :formList="formList" @search="search" @init="init" />
    <table-list
      :tableSets="tableSet"
      :tableData="tableData"
      :navText="navText"
      @addClick="addClick"
      :loading="loading"
      @getxq="getxq"
    >
      <template slot="btn" slot-scope="props">
        <el-button type="text" @click="xq(props.scope.row)">详情</el-button>
        <el-button type="text" @click="addClick(props.scope.row, 0)"
          >修改</el-button
        >
        <el-button type="text" @click="del(props.scope.row)">删除</el-button>
      </template>
    </table-list>
    <pagination
      :total="total"
      :pageSize="pageSize"
      :currentPage="currentPage"
      @handleSizeChange="handleSizeChange"
      @handleCurrentChange="handleCurrentChange"
    />
    <user-info ref="child"></user-info>
    <user-study-info ref="studyInfo"></user-study-info>
    <el-dialog
      :visible.sync="dialogBox"
      width="780px"
      :show-close="false"
      :destroy-on-close="true"
      :before-close="close"
      :fullscreen="fullscreen"
    >
      <div slot="title" class="hearders">
        <div class="leftTitle">
          {{ statusPop === 1 ? "添加" : statusPop === 0 ? "修改" : "详情" }}
        </div>
        <div class="rightBoxs">
          <img
            src="@/assets/images/Max@2x.png"
            alt=""
            @click="fullscreen = !fullscreen"
          />
          <img src="@/assets/images/Close@2x.png" alt="" @click="close" />
        </div>
      </div>
      <el-row class="contentBox" :span="24">
        <el-steps :active="1" finish-status="success" align-center>
          <el-step title="基础信息"></el-step>
          <el-step title="教育信息"></el-step>
        </el-steps>
        <el-form
          label-position="right"
          label-width="120px"
          :model="poppleData1"
          :rules="rules"
          ref="poppleData1"
        >
          <el-form-item label="姓名" prop="realname">
            <el-input v-model="poppleData1.realname"></el-input>
          </el-form-item>
          <el-form-item label="性别" prop="dictCode">
            <el-radio-group v-model="poppleData1.sex">
              <el-radio :label="1">男</el-radio>
              <el-radio :label="2">女</el-radio>
            </el-radio-group>
          </el-form-item>
          <el-form-item label="身份证">
            <el-input v-model="poppleData1.idCard"></el-input>
          </el-form-item>
          <el-form-item label="手机号码">
            <el-input v-model="poppleData1.telphone"></el-input>
          </el-form-item>
          <el-form-item label="邮箱">
            <el-input v-model="poppleData1.email"></el-input>
          </el-form-item>
          <!-- <el-form-item label="政治面貌">
            <el-select v-model="poppleData1.politic" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="婚姻状况">
            <el-select v-model="poppleData1.marry" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              >
              </el-option>
            </el-select>
          </el-form-item> -->
          <el-form-item label="户籍/国籍">
            <v-distpicker
              :province="poppleData1.province"
              :city="poppleData1.city"
              :area="poppleData1.district"
            ></v-distpicker>
          </el-form-item>
          <el-form-item label="所在城市">
            <v-distpicker
              :province="poppleData1.houseProvince"
              :city="poppleData1.houseCity"
              :area="poppleData1.houseDistrict"
            ></v-distpicker>
          </el-form-item>
          <el-form-item label="出生日期">
            <el-date-picker
              v-model="poppleData1.userBirth"
              type="date"
              placeholder="选择日期"
            >
            </el-date-picker>
          </el-form-item>
          <el-form-item label="身份证人像面"> 123 </el-form-item>
          <el-form-item label="身份证国徽面"> 123 </el-form-item>
          <el-form-item label="启用状态">
            <el-radio-group v-model="poppleData1.status">
              <el-radio :label="1">启用</el-radio>
              <el-radio :label="0">停用</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
      </el-row>
      <div slot="footer" class="dialog-footer">
        <el-button @click="close">关闭</el-button>
        <el-button type="primary">确定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import searchBox from "@/components/searchBox";
import tableList from "@/components/tableList";
import pagination from "@/components/pagination";
import userInfo from "@/components/userInfoS";
import userStudyInfo from "@/components/userStudyInfo";
import VDistpicker from "v-distpicker";
export default {
  components: {
    searchBox,
    tableList,
    pagination,
    userInfo,
    userStudyInfo,
    VDistpicker,
  },
  data() {
    return {
      loading: false, //当前表单加载是否加载动画
      navText: {
        title: "学员考试安排",
        index: 0,
        ch: "条",
        num: true,
        choice: true,
        addHide: true,
        backFatherBtn: {
          status: false,
          title: "未定义",
        },
      },
      tableSet: [
        {
          label: "姓名",
          prop: "realname",
          hidden: true,
        },
        {
          label: "用户手机号",
          prop: "telphone",
          hidden: true,
        },
        {
          label: "身份证号",
          prop: "idCard",
          hidden: true,
        },
        {
          label: "课程数量",
          prop: "courseNum",
          hidden: true,
        },
        {
          label: "学习时长(小时)",
          prop: "studyTime",
          hidden: true,
          scope: "timeBtn",
        },
        {
          label: "账号启用状态",
          prop: "status",
          hidden: true,
          scope: "status",
        },
      ], //表头信息
      tableData: [], //表单数据
      total: 0, //一共多少条
      pageSize: 10, //每页多少条数据
      currentPage: 1, //当前页码
      formList: [
        {
          label: "手机号",
          prop: "telphone",
          placeholder: "请输入手机号",
        },
        {
          label: "姓名",
          prop: "realname",
          placeholder: "请输入姓名",
        },
        // {
        //   label: "开通方式",
        //   prop: "examTypeId",
        //   placeholder: "请选择开通方式",
        //   scope: "select",
        // },
        {
          label: "身份证号",
          prop: "idCard",
          placeholder: "请输入身份证号",
        },
        {
          label: "状态",
          prop: "status",
          placeholder: "请选择身份",
          scope: "select",
          options: [
            {
              label: "启用",
              value: 1,
            },
            {
              label: "停用",
              value: 0,
            },
          ],
        },
      ], //搜索
      fullscreen: false,
      dialogBox: false,
      statusPop: 0,
      poppleData1: {},
      poppleData2: {},
      marryList:{},
    };
  },
  mounted() {
    this.search();
    this.getDictData()
  },
  methods: {
    search(v) {
      console.log(v);
      if (v === undefined) {
        v = {
          status: "0,1",
          pageSize: this.pageSize,
          pageNum: this.currentPage,
        };
      }
      var data = {
        telphone: v.telphone || "",
        realname: v.realname || "",
        status: v.status === undefined ? "0,1" : v.status,
        idCard: v.idCard || "",
        pageSize: this.pageSize,
        pageNum: this.currentPage,
      };
      this.loading = true;
      this.$api
        .inquireappuserlists(data)
        .then((res) => {
          this.tableData = res.rows;
          this.total = res.total;
          this.navText.index = res.total;
          this.loading = false;
        })
        .catch((err) => {
          this.loading = false;
        });
    },
    init() {
      this.search();
    },
    del() {},
    getDictData(){
      this.$api.obtaindictdata({dictTypeId:22}).then(res => {
        this.marryList = res.rows
      })
    },
    addClick(v, int) {
      this.statusPop = int;
      this.$api.obtainappuser(v.userId).then((res) => {
        if (res.code === 200) {
          this.poppleData1 = res.data;
        }
      });
      this.$api.obtainappuserschoolinfo(v.userId).then((res) => {
        if (res.code === 200) {
          this.poppleData2 = res.data;
        }
      });
      this.dialogBox = true;
    },
    submit() {},
    close() {
      this.$confirm("是否关闭该窗口", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {})
        .catch(() => {});
    },
    handleSizeChange(v) {
      this.pageSize = v;
      this.currentPage = 1;
      this.search();
    },
    handleCurrentChange(v) {
      this.currentPage = v;
      this.search();
    },
    xq(option) {
      this.$refs.child.getInfos(option.userId);
    },
    getxq(option) {
      this.$refs.studyInfo.getInfos(option);
    },
  },
};
</script>

<style lang="less" scoped>
/deep/.el-button {
  border-radius: 8px;
}
/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: flex-end;
    }
  }
}
.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>
