<!--
 * @Author: Liugh
 * @Date: 2021-05-17 16:22:06
 * @LastEditTime: 2021-05-18 09:47:22
 * @LastEditors: Do not edit
 * @Description: 
-->
<template>
  <main class="user-attributes-detail">
    <el-form ref="ruleForm" :model="detailInfo" label-width="120px" v-if="detailInfo.id" label-suffix="：">
      <el-row>
        <el-col :span="item.span ? item.span : 12" v-for="(item, index) in typeData[userInfo.userType]" :key="index">
          <el-form-item :label="item.label">
            <!-- 业务域翻译 -->
            <template v-if="item.value == 'policeBusiness' && showTagTree">
              {{ transferBusinessTag(detailInfo[item.value]) }}
            </template>
            <template v-else>
              <!-- 表码翻译 -->
              <template v-if="item.code">
                <div class="u-detail__text" v-translate="{ code: item.code }">
                  {{ detailInfo[item.value] }}
                </div>
              </template>
              <!-- 枚举翻译 -->
              <template v-else-if="item.enum">
                <div class="u-detail__text" v-translate="{ enum: item.enum }">
                  {{ detailInfo[item.value] }}
                </div>
              </template>
              <!-- 普通文本 -->
              <div v-else>{{ detailInfo[item.value] }}</div>
            </template>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <!-- <Table
            ref="myTable"
            :url="tableUrl"
            :headerData="UserTableData"
            :condition="reportForm"
            v-if="userInfo.userType == '10'"
        /> -->
    <el-row v-footer>
      <dg-button @click="handleClose">关闭</dg-button>
    </el-row>
  </main>
</template>

<script>
import { UserTableData, typeData } from '../DataConfig';
import { getAuthUserDetail } from '@/api/data-auth';
import transferBusinessTagMixin from '@/mixins/transfer-business-tag';

export default {
  name: 'user-attributes-detail', // 组件名称
  props: {
    // 接收父组件的数据
    userInfo: Object
  },
  mixins: [transferBusinessTagMixin],
  data() {
    // 组件内部参数
    return {
      UserTableData,
      typeData,
      detailInfo: {}
    };
  },
  computed: {
    showTagTree() {
      return this.tagTree.length > 0;
    }
  },
  methods: {
    getDetail() {
      return new Promise((resolve) => {
        getAuthUserDetail(this.userInfo.id).then((res) => {
          this.detailInfo = res.data;
          resolve(res.data);
        });
      });
    },
    handleClose() {
        this.$emit("close");
    }
  }, // 内部方法
  async created() {
    await this.getDetail();
  }
};
</script>
<style lang="scss" scoped></style>
