<template>
  <div class="app-container">
    <div style="background-color: #fff;padding: 20px;border-radius: 10px;">
      <p style="margin: 0; font-weight: 800;font-size: 16px;color: #343434;display: flex;align-items: center;margin-bottom: 20px;">
        <img src="../../../assets/images/icon_htgl_btzs.png" alt="" style="width: 16px;height: 20px;">
       <span style="margin-left: 10px;">房屋管理</span>
      </p>
      <div style="background: #F3F3F3;padding: 20px 15px; padding-bottom: 0;margin-bottom: 20px;">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="88px">
          <el-row>

            <el-col :span="24">
              <el-col :span="8">
                <el-form-item label="房屋状态" prop="houseStatus">
                        <el-select v-model="queryParams.houseStatus" placeholder="请选择房屋状态" clearable>
                          <el-option
                            v-for="dict in dict.type.house_status"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="房屋户号" prop="detailedAddress">
                        <el-input
                          v-model="queryParams.detailedAddress"
                          placeholder="请输入房屋户号"
                          clearable
                          @keyup.enter.native="handleQuery"
                        />
                      </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item label="小区名称" prop="communityName">
                        <el-input
                          v-model="queryParams.communityName"
                          placeholder="请输入房屋所在小区名称"
                          clearable
                          @keyup.enter.native="handleQuery"
                        />
                      </el-form-item>
              </el-col>
            </el-col>
            <el-col :span="24">
              <el-col :span="8">
                <el-form-item label="房屋用途" prop="usage">
                        <el-select v-model="queryParams.usage" placeholder="请选择房屋用途" clearable>
                          <el-option
                            v-for="dict in dict.type.use_remises"
                            :key="dict.value"
                            :label="dict.label"
                            :value="dict.value"
                          />
                        </el-select>
                      </el-form-item>
              </el-col>
              <el-col :span="8">
                <el-form-item class="butt bnjle">
                  <el-button size="mini" type="primary"   @click="handleQuery">搜索</el-button>
                  <el-button size="mini"   @click="resetQuery">重置</el-button>
                </el-form-item>
              </el-col>
            </el-col>
          </el-row>

        </el-form>
      </div>

      <div class="casr " >
              <el-row :gutter="10" class="mb8">
                <!-- <el-col :span="1.5">
                  <div style="font-weight: bold;font-size: 14px;color: #343434; display: flex;align-items: center;">
                    当夜全选
                  </div>
                </el-col> -->
                <el-col :span="1.5">
                  <el-button
                    type="primary"
                    plain
                    size="mini"
                    @click="handleAdd"
                    v-hasPermi="['wuYe:houseInfo:add']"
                  >添加</el-button>
                </el-col>
                <!-- <el-col :span="1.5">
                  <el-button
                    type="success"
                    plain
                    size="mini"
                    :disabled="single"
                    @click="handleUpdate"
                    v-hasPermi="['system:post:edit']"
                  >修改</el-button>
                </el-col>
                <el-col :span="1.5">
                  <el-button
                    type="danger"
                    plain
                    size="mini"
                    :disabled="multiple"
                    @click="handleDelete"
                    v-hasPermi="['system:post:remove']"
                  >删除</el-button>
                </el-col> -->
                <el-col :span="1.5">
                  <el-button
                    type="warning"
                    plain
                    size="mini"
                    @click="handleExport"
                    v-hasPermi="['wuYe:houseInfo:export']"
                  >导出</el-button>
                </el-col>
                <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
              </el-row>
              <div class="infinite-list" :style="dynamicStyle">
                <el-row :gutter="10" v-if="houseInfoList.length !=0" style="width: 100%;margin-left: 0;">
                  <el-col :span="6" v-for="(item,index) in houseInfoList" :key="index" >
                    <!-- @click="isac(item)" -->
                    <div v-if="isshoe"  :class=" item.isnum ==true ? 'ingwe' :'' " style="position: relative; background-color: #fff;box-shadow: 0px 0px 10px 0px #CDCDCD;border-radius: 4px;margin-bottom: 10px;">
                     <div class="carlist houselist" @click="isac(item)">
                     	<div class="ctop flexc" style="align-items: center;">
                     		<img src="../../../assets/images/icon_fwgl_yz.png" class="imgs" />
                     		<!-- <image src="../../../assets/images/icon_fwgl_zhs.png" class="imgs" v-if="ite.type==2"></image> -->
                     		<div class="tit">{{item.communityName ==null?'暂无数据' : item.communityName}}{{item.detailedAddress ==null?'暂无数据' : item.detailedAddress}}</div>
                     		<!-- div class="btn btnbga">预约</div>
                     		<div class="btn btnbgb">已来访</div>
                     		<div class="btn btnbgc">待来访</div> -->
                     		<div class="flex1"></div>
                     		<div class="txt ca" >
                          <dict-tag :options="dict.type.house_status" :value="item.houseStatus"/>
                        </div>
                     	<!-- 	<div class="txt cb" v-if="ite.type==2">租户</div> -->
                     	</div>
                     	<div class="clists">
                     		<div class="w50 flexc">
                     			<div class="clist" style="width: 100%;"><div class="tit">房屋所属</div>{{item.ownerName ==null?'暂无数据' : item.ownerName}}</div>
                     		</div>
                        <div class="w50 flexc">
                        	<div class="clist" style="width: 100%;"><div class="tit">建筑面积</div>{{item.area ==null?'' : item.area}}/m²</div>
                        </div>
                     		<div class="w50 flexc">
                     			<div class="clist" style="width: 100%;"><div class="tit">房屋坐落  </div>{{item.location ==null?'暂无数据' : item.location}}</div>
                     		</div>
                     		<!-- <div class="clist"><div class="tit">手机号码</div>13656788668</div> -->
                     	</div>
                     </div>
                      <div class="bortt tongty" style="justify-content: space-between;">
                        <p style="cursor: pointer;" ><span  v-hasPermi="['wuYe:houseInfo:edit']" @click="handleUpdate(item)">修改</span>  </p>
                        <!-- <span @click="handleUpdatef(item)">查看</span> -->
                         <p style="cursor: pointer;border-left: 1px solid #DADADA;border-right: 1px solid #DADADA;"> <span style="color: #46CB99;"  v-hasPermi="['wuYe:residentInfo:edit']" @click="handleUpdateg(item)">居住人员</span></p>
                        <p v-hasPermi="['wuYe:houseInfo:remove']" style="color:red;cursor: pointer;" @click="handleDelete(item)">删除</p>
                      </div>
                      <img v-if="item.isnum == true" src="../../../assets/images/icon_htgl_kp_gx.png" alt="" style="width: 35px;height: 35px;position: absolute;bottom: 0;right: 0;">
                    </div>
                  </el-col>
                </el-row>
                <div style="margin-top: 20px;display: flex;justify-content: center;align-items: center;" v-if="houseInfoList.length ==0">
                   <img   src="../../../assets/images/zwshjbig.png" alt="" style="">
                </div>
              </div>
      </div>


      <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </div>

    <!-- 添加或修改岗位对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="1200px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="120px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="坐落位置" prop="location">
                      <el-input v-model="form.location" placeholder="请输入房屋坐落位置" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="权利人姓名" prop="ownerName">
                      <el-input v-model="form.ownerName" placeholder="请输入权利人姓名" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="权利类型" prop="rightType">
                      <el-select v-model="form.rightType" placeholder="请选择权利类型，如所有权、使用权等">
                        <el-option
                          v-for="dict in dict.type.types_rights"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="不动产单元号" prop="propertyUnitNumber">
                      <el-input v-model="form.propertyUnitNumber" placeholder="请输入不动产单元号，唯一标识不动产单元" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="相关的字第号" prop="documentNumber">
                      <el-input v-model="form.documentNumber" placeholder="请输入房屋相关的字第号" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="是否有车位" prop="hasParkingSpace">
                      <el-select v-model="form.hasParkingSpace" placeholder="请选择是否有车位">
                        <el-option
                          v-for="dict in dict.type.sys_yes_no"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
                    </el-form-item>
          </el-col>

          <el-col :span="6">
           <el-form-item label="使用期限" prop="usagePeriod">
                     <el-input v-model="form.usagePeriod" placeholder="请输入房屋使用期限" />
                   </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="登记日期" prop="registrationDate">
                      <el-date-picker clearable
                       style="width: 100%;"
                        v-model="form.registrationDate"
                        type="datetime"
                        value-format="yyyy-MM-dd HH:mm:ss"
                        placeholder="请选择房屋登记日期">
                      </el-date-picker>
                    </el-form-item>
          </el-col>

          <el-col :span="6">
             <el-form-item label="房屋用途" prop="usageType">
                      <el-select v-model="form.usageType" placeholder="请选择房屋用途等">
                        <el-option
                          v-for="dict in dict.type.use_remises"
                          :key="dict.value"
                          :label="dict.label"
                          :value="dict.value"
                        ></el-option>
                      </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="6">
           <el-form-item label="共有人姓名" prop="coOwner">
                     <el-input v-model="form.coOwner" placeholder="请输入共有人姓名，多个共有人可以用逗号分隔" />
                   </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="共有情况" prop="coOwnership">
                      <el-input v-model="form.coOwnership" placeholder="请输入房屋的共有情况，如共有比例等" />
                    </el-form-item>
          </el-col>

          <el-col :span="6">
            <el-form-item label="小区名称" prop="communityName">
                      <el-input v-model="form.communityName" placeholder="请输入房屋所在小区名称" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="房屋状态" prop="houseStatus">
                      <el-select v-model="form.houseStatus" placeholder="请选择房屋状态：1-自住，2-出租，3-空闲，4-待售">
                        <el-option
                          v-for="dict in dict.type.house_status"
                          :key="dict.value"
                          :label="dict.label"
                          :value="parseInt(dict.value)"
                        ></el-option>
                      </el-select>
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="详细门牌号" prop="detailedAddress">
                      <el-input v-model="form.detailedAddress" placeholder="请输入房屋的详细门牌号" />
                    </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="面积(m²)" prop="area">
                <el-input v-model="form.area" placeholder="请输入面积" />
            </el-form-item>
          </el-col>


          <el-col :span="12">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark"  placeholder="请输入内容" />
            </el-form-item>
          </el-col>
          <el-col :span="24" class="unimg">
            <el-form-item label="上传房产证" prop="entrancePermit">
               <image-uploadshib @uploadedSuccessfully="uploadedSuccessfully"  :typeg = "4" :limit="1" v-model="form.entrancePermit"/>
              <!-- <image-upload v-model="form.entrancePermit"/> -->
            </el-form-item>
          </el-col>
        </el-row>



      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button v-if="ishoew" type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listHouseInfo, getHouseInfo, delHouseInfo, addHouseInfo, updateHouseInfo } from "@/api/wuguan/houseInfo";
import 'videojs-flash'
export default {
  name: "HouseInfo",
    dicts: ['sys_notice_status', 'use_remises','types_rights','resident_type','sys_yes_no','house_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
     // 房屋信息表格数据
           houseInfoList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
                pageSize: 10,
                ownerName: null,
                location: null,
                rightType: null,
                area: null,
                documentNumber: null,
                propertyUnitNumber: null,
                coOwnership: null,
                usage: null,
                usagePeriod: null,
                registrationDate: null,
                coOwner: null,
                detailedAddress: null,
                hasParkingSpace: null,
                communityName: null,
                houseStatus: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        communityName: [
                  { required: true, message: "不能为空", trigger: "blur" }
                ],
       location: [
                 { required: true, message: "房屋坐落位置不能为空", trigger: "blur" }
               ],
               detailedAddress: [
                 { required: true, message: "房屋的详细门牌号不能为空", trigger: "blur" }
               ],
               area: [
                 { required: true, message: "不能为空", trigger: "blur" }
               ],
      },
      activeName:'first',
      videoState: false, // 视频播放状态
      poster:true,
      controls:true,
      videoData:{},
       player: null,
       isshoe:true,
       ishoew:false,
       tableMaxHeight:'200',
    };
  },
  computed: {
    dynamicStyle() {
      return {
        overflow:'auto',
        height: this.tableMaxHeight+ 'px',
        paddingTop:'10px'
      }
    }
    },
  created() {
    this.getList();
  window.onresize = () => {
  	      this.changeTableMaxHeight()
  	    }
  	    this.changeTableMaxHeight()
  },
  mounted() {
  	window.onresize = () => {
  	          this.changeTableMaxHeight()
  	        }
  	        this.changeTableMaxHeight()
  },
  beforeDestroy() {
      if (this.player) {
        this.player.dispose()
      }
    },
  methods: {
    /** 查询岗位列表 */
    getList() {
      this.loading = true;
      listHouseInfo(this.queryParams).then(response => {
        this.houseInfoList  = response.rows;
        this.houseInfoList .filter(rou=>{
          rou.isnum = false
        })
        this.total = response.total;
        this.loading = false;
      });
   },
   uploadedSuccessfully(row){
     if(row.length !=0){
       row.filter(rou=>{
         this.form.ownerName  = rou.ownerName
         this.form.area  = rou.area
         this.form.coOwner  = rou.coOwner
         this.form.coOwnership  = rou.coOwnership
         this.form.documentNumber  = rou.documentNumber
         this.form.location  = rou.location
         this.form.propertyUnitNumber  = rou.propertyUnitNumber
         this.form.registrationDate  = rou.registrationDate
         this.form.rightType  = rou.rightType
         this.form.usagePeriod  = rou.usagePeriod
         this.form.usageType  = rou.usageType
       })
     }



   },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
              houseId: null,
              ownerName: null,
              location: null,
              rightType: null,
              area: null,
              documentNumber: null,
              propertyUnitNumber: null,
              coOwnership: null,
              usage: null,
              usagePeriod: null,
              registrationDate: null,
              coOwner: null,
              detailedAddress: null,
              hasParkingSpace: null,
              communityName: null,
              houseStatus: null,
              createBy: null,
              createTime: null,
              updateBy: null,
              updateTime: null,
              remark: null
            };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.houseId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加房屋信息(先上传房产证可识别信息)";
      this.ishoew = true
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
           const houseId = row.houseId || this.ids
           getHouseInfo(houseId).then(response => {
             this.form = response.data;
             this.open = true;
             this.ishoew = true
             this.title = "修改房屋信息";
           });
    },
    handleUpdateg(row){
      this.$router.push({
        path: '/renyuanxiangguan/renyuan',
        query: {
        	'id':row.houseId,
        }
      })
    },
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
         if (valid) {
                  if (this.form.houseId != null) {
                    updateHouseInfo(this.form).then(response => {
                      this.$modal.msgSuccess("修改成功");
                      this.open = false;
                      this.getList();
                    });
                  } else {
                    addHouseInfo(this.form).then(response => {
                      this.$modal.msgSuccess("新增成功");
                      this.open = false;
                      this.getList();
                    });
          }
        }
      });
    },
     /** 删除按钮操作 */
        handleDelete(row) {
          const houseIds = row.houseId || this.ids;
          this.$modal.confirm('是否确认删除房屋信息编号为"' + houseIds + '"的数据项？').then(function() {
            return delHouseInfo(houseIds);
          }).then(() => {
            this.getList();
            this.$modal.msgSuccess("删除成功");
          }).catch(() => {});
        },
    /** 导出按钮操作 */
    handleExport() {
      this.download('wuYe/houseInfo/export', {
        ...this.queryParams
      }, `houseInfo_${new Date().getTime()}.xlsx`)
    },

      handleClick(){

      },
    isac(val){
      console.log(5,val)
      // val.isnum = !val.isnum
      // this.isshoe = false
      // this.isshoe = true
      this.ishoew = false
      // this.open = true
      this.reset();
           const houseId = val.houseId
           getHouseInfo(houseId).then(response => {
             this.form = response.data;
             this.open = true;
             this.ishoew = true
             this.title = "修改房屋信息";
           });
    },
    // 获取屏幕高度
    showFilterForm () {
          this.filterActive = !this.filterActive
          this.changeTableMaxHeight()
        },

        changeTableMaxHeight () {
          let height = document.body.offsetHeight // 网页可视区域高度
          // if (this.filterActive) {
          //   this.tableMaxHeight = height - 320
          // } else {
            this.tableMaxHeight = height - 150
          // }
          console.log(height)
        }

  }
};
</script>
<style  lang="scss">
  .unimg{
    .el-upload--picture-card{
      width:102px;
      height: 102px;
      line-height: 102px;
    }
    .el-upload-list--picture-card .el-upload-list__item{
      width:102px;
      height: 102px;
    }
  }

  .bnjle{
    margin-left: 20px;
  }
  .butt{
    .el-button--small{
      padding: 9px 23px !important;
      font-size: 14px;
    }
  }
  .casr{
    .el-tabs__item.is-active{
      color: #196CFF;
    }
    .el-tabs--card > .el-tabs__header .el-tabs__item{
      padding: 0  30px !important;
    }
  }
  .el-table .el-table__header-wrapper th{
    background-color:#F5F6F8;
    color:#343434;
  }
  .el-table{
    color:#343434;
  }
</style>
<style scoped lang="scss">
  .flexc{
    display: flex;
    justify-content: space-between;
  }
  	.carlist{background: #FFFFFF;border-radius: 10px;margin-bottom: 14px;
  		.ctop{border-bottom: 1px solid #E5E5E5;padding:13px 12px;
  			.imgs{width: 20px;height: 21px;margin-right: 15px;}
  			.tit{font-size: 16px;color: #272727;font-weight: bold;margin-right: 7px;}
  			.txt{font-weight: 500;font-size: 14px;
  				&.ca{color: #3565ED;}
  				&.cb{color: #FE5A0E;}
  				&.cc{color: #28C529;}
  			}
  			.txta{font-weight: 500;font-size: 14px;color: #AAAAAA;}
  			.num{font-size: 14px;color: #AAAAAA;}
  		}
  		.btn{height: 17px;border-radius: 9px;display: flex;align-items: center;justify-content: center;padding: 0 5px;font-size:12px;margin-right: 12px;
  			&.btna{border: 1px solid #06C770;color: #06C770;}
  			&.btnb{border: 1px solid #3565ED;color: #3565ED;}
  			&.btnc{border: 1px solid #FE5A0E;color: #FE5A0E;}
  			&.btnbga{border: 1px solid #0156FE;color: #3565ED;background: #DFEAFF;height: 18px;}
  			&.btnbgb{border: 1px solid #C1C1C1;color: #666666;background: #F1F1F1;height: 18px;}
  			&.btnbgc{border: 1px solid #FE5A0E;color:#FE5A0E;background:#FFEEE6;height: 18px;}
  		}
  		.clists{padding: 12px 12px 4px;
  			.clist{font-weight: 500;margin-bottom: 8px;
  	font-size: 13px;color: #272727;display: flex;line-height: 17px;
  				.tit{font-size: 14px;color: #AAAAAA;flex: 0 0 auto;margin-right: 8px;text-align-last: justify;}
  				.imgas{display: flex;align-items: center;flex-wrap: wrap;
  					image{width: 71px;height: 71px;margin-right: 15px;margin-top:4px;}
  				}
  			}
  			.w50{
  				.clist{width: 50%;}
  			}
  		}
  	}
  	.houselist{
  		.clists{padding-bottom: 1px !important;}
  		.clist{margin-bottom: 11px !important;}
  	}
  .goe{
    p{
      margin: 0;
      font-weight: 800;
      font-size: 16px;
      color: #161616;
      margin-top: 10px;
      margin-bottom: 3px;
      padding: 0 10px;
      overflow: hidden;
      text-overflow: ellipsis;
      display:-webkit-box; //作为弹性伸缩盒子模型显示。
      -webkit-box-orient:vertical; //设置伸缩盒子的子元素排列方式--从上到下垂直排列
      -webkit-line-clamp:1; //显示的行
    }
    p:nth-child(2){

    }
  }
  .ingwe{
    border: 2px solid #196CFF;
  }
  .renyuangs{
    p{
      font-weight: 500;
      font-size: 14px;
      color: #161616;
      padding: 0;
    }
  }
  .tongty{
    display: flex;
    align-items: center;
  }
  .bortt{
    border-top: 1px solid #DADADA;
    margin-top: 15px;

    p{
      margin: 0;
      font-weight: bold;
      font-size: 14px;
      color: #5F8BF4;
      width:50%;
      padding: 10px;
      text-align: center;
    }
  }
  </style>


