<template>
  <basic-container>
    <avue-form :option="option" v-model="reviewDetail" ref="form">
    </avue-form>
    <div v-if="reviewType">
      <el-row>
        <el-col span="24" align="right">
          <el-button type="primary" icon="el-icon-check" size="small" @click="reviewExamine(1)">通过</el-button>
          <el-button type="info" icon="el-icon-delete" size="small" @click="reviewExamine(2)">不通过</el-button>
        </el-col>
      </el-row>
    </div>
  </basic-container>
</template>

<script>
import {updateByCheckStatus, getDetail} from "@/api/estate/applyuser";
import {validatePhone} from "../../util/validator";
import done from "@/views/work/done";
export default {
  name: 'houseuser-check',
  props: {
    closeFn: {type: Function},
    reviewDetail: {},
    url: '',
    reviewType: false,
  },
  data() {
    return {
      option:{
        menuBtn: false,
        column: [
          {
            label: "住户姓名",
            prop: "name",
            disabled: true,
          },
          {
            label: "性别",
            prop: "sex",
            type: "select",
            dataType: "string",
            disabled: true,
            hide: true,
            width: 80,
            dicData:[
              {
                label: "未定义",
                value: -1
              },
              {
                label: "男",
                value: 1
              },
              {
                label: "女",
                value: 2
              },
            ],
            // dicUrl: "/api/blade-system/dict-biz/dictionary?code=sex",
            // props: {
            //   label: "dictValue",
            //   value: "dictKey"
            // },
          },
          {
            label: "住户类型",
            prop: "type",
            type: "select",
            dataType: "string",
            disabled: true,
            hide: true,
            dicData:[
              {
                label: "业主",
                value: 0
              },
              {
                label: "家属",
                value: 1
              },
              {
                label: "租客",
                value: 2
              },
            ],

            // dicUrl: "/api/blade-system/dict-biz/dictionary?code=household-type",
            // props: {
            //   label: "dictValue",
            //   value: "dictKey"
            // },
          },
          {
            label: "身份证",
            prop: "idCard",
            width: 150,
            disabled: true,
          },
          {
            label: "小区名称",
            prop: "residentialName",
            editDisplay: false,
            addDisplay: false,
            disabled: true,
            hide: true,
          },
          // {
          //   label: "所属小区",
          //   prop: "residentialId",
          //   type: "select",
          //   disabled: 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: "请输入所属小区id",
          //     trigger: "blur"
          //   }]
          // },
          // {
          //   label: "小区名称",
          //   prop: "residentialName",
          //   display: false,
          //   hide: true,
          //   rules: [{
          //     required: true,
          //     message: "请输入小区名称",
          //     trigger: "blur"
          //   }]
          // },
          // {
          //   label: "所属楼栋",
          //   prop: "buildingId",
          //   type: "select",
          //   disabled: true,
          //   search: true,
          //   cascaderItem: ['unitId'],
          //   dicUrl: "/api/cyzh-community/building/list?residentialId={{key}}",
          //   dicFormatter:(res)=>{
          //     return res.data.records;//返回字典的层级结构
          //   },
          //   props: {
          //     label: "name",
          //     value: "id"
          //   },
          //   rules: [{
          //     required: false,
          //     message: "请输入楼栋id",
          //     trigger: "blur"
          //   }]
          // },
          {
            label: "楼栋名称",
            prop: "buildingName",
            editDisplay: false,
            addDisplay: false,
            disabled: true,
            hide: true,
          },
          // {
          //   label: "所属单元",
          //   prop: "unitId",
          //   type: "select",
          //   disabled: true,
          //   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: false,
          //     message: "请输入所属单元id",
          //     trigger: "blur"
          //   }]
          // },
          {
            label: "单元名称",
            prop: "unitName",
            editDisplay: false,
            addDisplay: false,
            disabled: true,
            hide: true,
          },
          // {
          //   label: "所属房间",
          //   prop: "roomId",
          //   type: "select",
          //   disabled: true,
          //   search: true,
          //   dicUrl: "/api/cyzh-community/room/list?floorId={{key}}",
          //   dicFormatter:(res)=>{
          //     return res.data.records;//返回字典的层级结构
          //   },
          //   filterable: true,
          //   props: {
          //     label: "name",
          //     value: "id"
          //   },
          //   rules: [{
          //     required: false,
          //     message: "请输入所属房间id",
          //     trigger: "blur"
          //   }]
          // },
          {
            label: "房间名称",
            prop: "roomName",
            editDisplay: false,
            addDisplay: false,
            disabled: true,
            hide: true,
          },
          {
            label: "联系电话",
            prop: "tel",
            editDisplay: false,
            addDisplay: false,
            disabled: true,
            rules: [{
              required: true,
              message: "请输入联系电话",
            },{
              validator: validatePhone,
              trigger: "blur"
            }]
          },
          {
            label: "审核状态",
            prop: "checkState",
            type: 'select',
            disabled: !this.reviewType,
            dicData:[
              {
                label: '待审核',
                value: 0
              },
             {
                label: '审核通过',
                value: 1
              },{
                label: '审核不通过',
                value: 2
              }
            ],
            viewDisplay: true,
            display: false,
          },
          {
            label: "护照照片",
            prop: "passportImgUri",
            hide: true,
            display: false,
            disabled: true,
            type: 'upload',
            listType: 'picture-img',
            propsHttp: {
              res: "data",
              url: "link"
            },
            action: "/api/blade-resource/oss/endpoint/put-file",
            tip: '只能生产jpg/png图片，且不超过500kb',
          },
          {
            label: "入境证明",
            prop: "entryImgUri",
            hide: true,
            display: false,
            disabled: true,
            type: 'upload',
            listType: 'picture-img',
            propsHttp: {
              res: "data",
              url: "link"
            },
            action: "/api/blade-resource/oss/endpoint/put-file",
            tip: '只能生产jpg/png图片，且不超过500kb',
          },
          {
            label: "人脸图片",
            prop: "imageUri",
            hide: true,
            disabled: true,
            type: 'upload',
            row: true,
            listType: 'picture-img',
            propsHttp: {
              res: "data",
              url: "link"
            },
            action: "/api/blade-resource/oss/endpoint/put-file",
            tip: '只能生产jpg/png图片，且不超过500kb',
          },
          {
            label: "审核意见",
            prop: "checkOpinion",
            type: 'textarea',
            disabled: !this.reviewType,
            rules: [{
              required: false,
              message: "请输入审核意见",
              trigger: "blur"
            }]
          }
        ]
      }
    }
  },
  created(){
    if(this.reviewType){
      this.option.column[9].display = false;
    }else{
      this.option.column[9].display = true;
    }
  },
  methods: {
    reviewExamine(examine, done) {
      if (examine == 2 && !this.reviewDetail.checkOpinion) {
        this.$message({
          type: "error",
          message: "请输入审核意见!"
        })
        return;
      }
      this.reviewDetail.checkState = examine;
      updateByCheckStatus(this.reviewDetail).then(()=>{
        this.$message({
          type: "success",
          message: "操作成功!"
        })
        this.$emit('updateEmit', false);
      }, error => {
        console.log(error);
      })
    },
  }
}

</script>

<style scoped>

</style>







