<template>
  <ns-view-detail api="/api/parking_merchant/objs/person/detail" :detail="detail" />
</template>
<script lang="ts">
  import { defineComponent, reactive } from 'vue';
  import { getCodeNameFromValue } from './index';
  import { dateUtil } from '/nerv-lib/util/date-util';
  export default defineComponent({
    name: 'NsViewUserDetail',
    setup() {
      const detail = [
        {
          title: '基本信息',
          items: [
            {
              label: '姓名',
              name: 'personName',
            },
            {
              label: '性别',
              name: 'sex',
              format: (value: any, data: any) => {
                switch (value) {
                  case 1:
                    return '男';
                  case 0:
                    return '女';
                  default:
                    return '-';
                }
              },
            },
            {
              label: '员工编号',
              name: 'personNum',
            },
            {
              label: '身份证号',
              name: 'idCard',
            },
            {
              label: '手机号码',
              name: 'telNum',
            },
            {
              label: '民族',
              name: 'nation',
              format: (value: any, data: any) => {
                console.log(value, data, 'value');
                if (!value) return;
                let temp = getCodeNameFromValue('MZ', value);
                if (temp) {
                  return temp;
                } else {
                  return '-';
                }
              },
            },
            {
              label: '所属部门',
              name: 'departmentNameList',
              format: (value: any, data: any) => {
                if (value) {
                  let temp = '';
                  let jdgeTemp = false;
                  value.forEach((element: any[]) => {
                    if (jdgeTemp) {
                      temp += ',';
                      temp += element.join('/');
                    } else {
                      jdgeTemp = true;
                      temp += element.join('/');
                    }
                  });
                  return temp;
                } else {
                  return '-';
                }
              },
            },
            {
              label: '主部门',
              name: 'departmentMainName',
            },
            {
              label: '员工角色',
              name: 'roleVOList',
              format: (value: any) => {
                if (value) {
                  let apusic = '';
                  value.forEach((element: any) => {
                    apusic = element.roleName;
                  });
                  return apusic;
                } else {
                  return '-';
                }
              },
            },
            {
              label: '居住地址',
              name: 'homeAddress',
            },
            {
              label: '详细地址',
              name: 'address',
            },
            {
              label: '员工图片',
              name: 'personPicUuid',
              type: 'image',
              format: (value: string, data: any) => {
                return '/api/parking_merchant/objs/sys/ParkPic/' + value;
              },
            },
            {
              label: '身份证扫描件',
              name: 'idCardPicUuid',
              type: 'image',
              format: (value: any, data: any) => {
                return '/api/parking_merchant/objs/sys/IdCardPic/' + value;
              },
            },
          ],
        },
        {
          title: '其他信息',
          items: [
            {
              label: '婚姻状况',
              name: 'maritalStatus',
              format: (value: any, data: any) => {
                let temp = getCodeNameFromValue('HYZK', value);
                if (temp) {
                  return temp;
                } else {
                  return '-';
                }
              },
            },
            {
              label: '文化程度',
              name: 'education',
              format: (value: any, data: any) => {
                let temp = getCodeNameFromValue('WHCD', value);
                if (temp) {
                  return temp;
                } else {
                  return '-';
                }
              },
            },
            {
              label: '入职日期',
              name: 'entryTime',
              format: (value: any) => {
                return dateUtil(value).format('YYYY-MM-DD HH:mm:ss');
              },
            },
            {
              label: '毕业院校',
              name: 'graduatedSchool',
            },
            {
              label: '所属专业',
              name: 'major',
            },
            {
              label: '邮箱地址',
              name: 'email',
            },
            {
              label: '户籍地址',
              name: 'residenceAddress',
            },
            {
              label: '备注',
              name: 'remarks',
            },
          ],
        },
      ];
      return { detail };
    },
  });
</script>
