<template>
  <basic-container>
    <avue-form :option="option"
               v-model="form">
    </avue-form>
  </basic-container>
</template>

<script>
  import {detailByParentId} from "@/api/person/elderlypeople";
  import {validatePhone} from "../../util/validator";
  export default {
    name:'elderTags-detail',
    props:{
      basicData:{type:Object}
    },
    data() {
      return {
        form: {},
        option: {
          height:'auto',
          calcHeight: 30,
          labelWidth: 120,
          tip: false,
          submitBtn:false,
          emptyBtn:false,
          disabled:true,
          group:[
            {
              icon:'el-icon-info',
              label: '基础信息',
              prop: 'group',
              column:[
                {
                  label: "基本表Id",
                  prop: "parentId",
                  hide: true,
                  display: false,
                  rules: [{
                    required: false,
                    message: "请输入基本表Id",
                    trigger: "blur"
                  }]
                },
                {
                  label:'姓名',
                  prop:'name',
                  search:true,
                  editDisplay:false
                },
                {
                  label: "有无子女",
                  prop: "children",
                  type: 'select',
                  dataType: 'number',
                  hide: true,
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=children",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "有无子女",
                    trigger: "blur"
                  }]
                },
                {
                  label: "紧急联系人",
                  prop: "emergencyContactPerson",
                  rules: [{
                    required: false,
                    message: "请输入紧急联系人",
                    trigger: "blur"
                  }]
                },
                {
                  label: "联系人电话",
                  prop: "emergencyContactPhone",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入紧急联系人电话",
                    trigger: "blur"
                  },{
                    validator: validatePhone,
                    trigger: "blur"
                  }]
                },
                // {
                //   label: "所属社区",
                //   prop: "agencyId",
                //   slot: true,
                //   search: true,
                //   cascaderItem: ['residentialId'],
                //   type: "select",
                //   remote: true,
                //   dicUrl: "/api/cyzh-community/agency/list",
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请选择所属社区",
                //     trigger: "blur"
                //   }]
                // },
                // {
                //   label: "所属小区",
                //   prop: "residentialId",
                //   slot: true,
                //   type: "select",
                //   search: true,
                //   cascaderItem: ['buildingId'],
                //   dicUrl: "/api/cyzh-community/residential/list?agencyId={{key}}",
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   // dicFlag: false,
                //   filterable: true,
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请选择所属小区",
                //     trigger: "blur"
                //   }]
                // },
                // {
                //   label: "所属楼栋",
                //   prop: "buildingId",
                //   slot: true,
                //   type: "select",
                //   search: true,
                //   cascaderItem: ['unitId'],
                //   dicUrl: `/api/cyzh-community/building/list?residentialId={{key}}`,
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   // dicFlag: false,
                //   filterable: true,
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请输入楼栋Id",
                //     trigger: "blur"
                //   }]
                // },
                // {
                //   label: "所属单元",
                //   prop: "unitId",
                //   slot: true,
                //   type: "select",
                //   search: true,
                //   cascaderItem: ['floorId'],
                //   dicUrl: "/api/cyzh-community/unit/list?buildingId={{key}}",
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   // dicFlag: false,
                //   filterable: true,
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请输入单元Id",
                //     trigger: "blur"
                //   }]
                // },
                // {
                //   label: "所属楼层",
                //   prop: "floorId",
                //   slot: true,
                //   type: "select",
                //   search: true,
                //   cascaderItem: ['roomId'],
                //   dicUrl: "/api/cyzh-community/floor/list?unitId={{key}}",
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   // dicFlag: false,
                //   filterable: true,
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请输入楼层Id",
                //     trigger: "blur"
                //   }]
                // },
                // {
                //   label: "所属房间",
                //   prop: "roomId",
                //   slot: true,
                //   type: "select",
                //   search: true,
                //   dicUrl: "/api/cyzh-community/room/list?floorId={{key}}",
                //   dicFormatter:(res)=>{
                //     return res.data.records;//返回字典的层级结构
                //   },
                //   // dicFlag: false,
                //   filterable: true,
                //   props: {
                //     label: "name",
                //     value: "id"
                //   },
                //   rules: [{
                //     required: true,
                //     message: "请输入房间Id",
                //     trigger: "blur"
                //   }]
                // },
                ]
            },
            {
              icon:"el-icon-s-cooperation",
              label:'健康信息',
              prop: 'group',
              column: [
                {
                  label: "血压",
                  prop: "bloodPressure",
                  hide: true,
                  rules: [{
                    required: true,
                    message: "请输入血压",
                    trigger: "blur"
                  }]
                },
                {
                  label: "血氧",
                  prop: "bloodOxygen",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入血氧",
                    trigger: "blur"
                  }]
                },
                {
                  label: "血糖",
                  prop: "bloodSugar",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入血糖",
                    trigger: "blur"
                  }]
                },
                {
                  label: "既往病史",
                  prop: "medicalHistory",
                  rules: [{
                    required: false,
                    message: "请输入既往病史",
                    trigger: "blur"
                  }]
                },
                {
                  label: "行为能力",
                  prop: "ability",
                  type: 'select',
                  dataType: 'number',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=ability",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: false,
                    message: "具有的行为能力",
                    trigger: "blur"
                  }]
                },
                {
                  label: "功能障碍",
                  prop: "dysfunction",
                  type: 'select',
                  multiple: true,
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=dysfunction",
                  dataType:'string',
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "功能障碍 (可多选)",
                    trigger: "blur"
                  }]
                },
                {
                  label: "服务需求",
                  prop: "serviceDemand",
                  type: 'select',
                  multiple:true,
                  dataType:'string',
                  dicUrl: "/api/blade-system/dict-biz/dictionary?code=service-demand",
                  props: {
                    label: "dictValue",
                    value: "dictKey"
                  },
                  rules: [{
                    required: true,
                    message: "服务需求 (可多选)",
                    trigger: "blur"
                  }]
                },
              ]
            },
            {
              icon:'el-icon-s-opportunity',
              label: '社会能力',
              prop: 'group',
              column: [
                {
                  label: "生活爱好",
                  prop: "hobby",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入生活爱好",
                    trigger: "blur"
                  }]
                },
                {
                  label: "生活嗜好",
                  prop: "addiction",
                  hide: true,
                  rules: [{
                    required: false,
                    message: "请输入生活嗜好",
                    trigger: "blur"
                  }]
                },
              ]
            }
          ],
        },
      };
    },
    mounted() {
      this.loadData();
    },
    methods: {
      loadData(){
        detailByParentId(this.basicData.id).then(res => {
          this.form = res.data.data;
        });
      },
    }
  };
</script>

<style>
</style>
