<template>
  <div style="display: inline-block">
    <el-dialog
      :visible.sync="dialog"
      :close-on-click-modal="false"
      :title="title"
      append-to-body
      width="700px"
    >
      <el-form
        ref="form1"
        :model="form"
        :rules="rules"
        size="small"
        label-position="left"
        label-width="120px"
        hide-required-asterisk
      >
        <el-form-item label="登陆账号" prop="staffNo">
          <div>{{ form.staffNo }}</div>
        </el-form-item>
        <el-form-item label="员工号" prop="staffNo">
          <div>{{ form.upId }}</div>
        </el-form-item>
        <el-form-item label="姓名" prop="name">
          <div>{{ form.name }}</div>
        </el-form-item>
        <el-form-item label="投顾执业证号" prop="license">
          <div>{{ form.license }}</div>
        </el-form-item>
        <el-form-item label="投顾手机号" prop="license">
          <div>{{ form.phone }}</div>
        </el-form-item>
        <el-form-item label="投顾所在营业部" prop="name">
          <div>{{ form.deptName }}</div>
        </el-form-item>
        <el-form-item label="展业姓名" prop="showName">
          <div>{{ form.showName }}</div>
        </el-form-item>
        <el-form-item label="性别" prop="sex" v-if="true">
          <div>{{ form.sex === 1 ? "男" : "女" }}</div>
        </el-form-item>
        <el-form-item label="展示头像">
          <img :src="form.avatar" width="70" height="70" />
          <img
            :src="form.avatar"
            style="width: 70px; height: 70px; border-radius: 50%"
          />
        </el-form-item>
        <el-form-item label="个人简介" prop="profile">
          <div>{{ form.profile }}</div>
        </el-form-item>
        <el-form-item label="展示标签" prop="tagList">
          <el-tag
            v-for="tag in form.tagList"
            :key="tag.id"
            style="margin-right: 10px"
            >{{ tag.name }}</el-tag
          >
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="resetForm">取消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { getTgInfo } from "@/api/adviser.js";

export default {
  data() {
    return {
      loading: false,
      dialog: false,
      title: "查看投顾",
      result: 0,
      reason: "",
      form: {
        username: "",
        name: "",
        type: "",
        profile: "",
        sex: "",
        tags: [],
        license: "",
        result: null,
        rules: ""
      },
      rules: {
        // reason: [
        //   { required: true, message: '请输入驳回理由', trigger: 'blur' },
        //   {
        //     min: 3,
        //     max: 200,
        //     message: '长度在 3 到 200 个字符',
        //     trigger: 'blur'
        //   }
        // ]
      }
    };
  },
  watch: {
    dialog(newName) {
      if (newName) {
        this.getInfo();
      }
    }
  },
  methods: {
    // 获取详情
    async getInfo() {
      const data = await getTgInfo({
        id: this.form.id
      });
      if (data.code === 0) {
        this.form = data.data;
      } else {
        this.$message.error(data.message);
      }
      console.log(this.form);
    },
    cancel() {
      this.resetForm();
    },
    resetForm() {
      this.dialog = false;
      this.form = {
        name: "",
        profile: "",
        sex: "",
        tagList: [],
        license: "",
        userName: "",
        userNo: "",
        showName: "",
        deptName: ""
      };
    },
    // 分页器
    sizeChange(e) {
      this.page = 0;
      this.size = e;
    },
    pageChange(e) {
      this.page = e - 1;
    }
  }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped></style>
