You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					
					
						
							530 lines
						
					
					
						
							13 KiB
						
					
					
				
			
		
		
		
			
			
			
				
					
				
				
					
				
			
		
		
	
	
							530 lines
						
					
					
						
							13 KiB
						
					
					
				
								<template>
							 | 
						|
								  <div>
							 | 
						|
								    <div class="div_search">
							 | 
						|
								      <div class="resi-cell">
							 | 
						|
								        <div class="resi-cell-label">房主姓名</div>
							 | 
						|
								        <div class="resi-cell-value">
							 | 
						|
								          <el-input v-model="ownerName"
							 | 
						|
								                    class="resi-cell-input"
							 | 
						|
								                    size="small"
							 | 
						|
								                    clearable
							 | 
						|
								                    placeholder="请输入内容">
							 | 
						|
								          </el-input>
							 | 
						|
								
							 | 
						|
								        </div>
							 | 
						|
								      </div>
							 | 
						|
								      <div class="resi-cell">
							 | 
						|
								        <div class="resi-cell-label">房主手机</div>
							 | 
						|
								        <div class="resi-cell-value">
							 | 
						|
								          <el-input v-model="ownerPhone"
							 | 
						|
								                    class="resi-cell-input"
							 | 
						|
								                    size="small"
							 | 
						|
								                    clearable
							 | 
						|
								                    placeholder="请输入内容">
							 | 
						|
								          </el-input>
							 | 
						|
								
							 | 
						|
								        </div>
							 | 
						|
								      </div>
							 | 
						|
								      <el-button style="margin-left:10px"
							 | 
						|
								                 type="primary"
							 | 
						|
								                 size="small"
							 | 
						|
								                 @click="handleSearch">查询</el-button>
							 | 
						|
								    </div>
							 | 
						|
								    <div class="div_btn">
							 | 
						|
								      <el-button style="float:left"
							 | 
						|
								                 type="yellow"
							 | 
						|
								                 size="small"
							 | 
						|
								                 @click="handleExport">导出</el-button>
							 | 
						|
								      <el-button style="float:left"
							 | 
						|
								                 type="green"
							 | 
						|
								                 size="small"
							 | 
						|
								                 @click="handleAdd">新增房屋</el-button>
							 | 
						|
								      <el-button style="float:left"
							 | 
						|
								                 type="blue"
							 | 
						|
								                 size="small"
							 | 
						|
								                 @click="handleExportModule">下载房屋模板</el-button>
							 | 
						|
								      <el-upload ref="upload"
							 | 
						|
								                 :multiple='false'
							 | 
						|
								                 :show-file-list='false'
							 | 
						|
								                 :before-upload="beforeUpload"
							 | 
						|
								                 action=""
							 | 
						|
								                 accept=".xls,.xlsx"
							 | 
						|
								                 :limit="1"
							 | 
						|
								                 :on-exceed="handleExceed"
							 | 
						|
								                 :http-request="uploadFile">
							 | 
						|
								        <el-button style="margin-left:10px"
							 | 
						|
								                   size="small"
							 | 
						|
								                   type="red">导入房屋数据</el-button>
							 | 
						|
								      </el-upload>
							 | 
						|
								    </div>
							 | 
						|
								
							 | 
						|
								    <div class="div_table">
							 | 
						|
								      <el-table :data="tableData"
							 | 
						|
								                :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
							 | 
						|
								                v-loading="tableLoading"
							 | 
						|
								                border
							 | 
						|
								                :height="tableHeight"
							 | 
						|
								                style="width: 100%">
							 | 
						|
								        <el-table-column prop="houseName"
							 | 
						|
								                         label="房屋名称"
							 | 
						|
								                         width="120">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="neighborHoodName"
							 | 
						|
								                         label="所属小区"
							 | 
						|
								                         width="160">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="buildingName"
							 | 
						|
								                         label="所属楼栋">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="unitNum"
							 | 
						|
								                         label="单元号">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="doorName"
							 | 
						|
								                         label="门牌号">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="houseType"
							 | 
						|
								                         label="类型">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="purpose"
							 | 
						|
								                         label="用途">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="rentFlag"
							 | 
						|
								                         label="是否出租">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="ownerName"
							 | 
						|
								                         label="房主姓名">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="ownerPhone"
							 | 
						|
								                         label="房主电话"
							 | 
						|
								                         width="110">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column prop="ownerIdCard"
							 | 
						|
								                         label="身份证"
							 | 
						|
								                         width="170">
							 | 
						|
								        </el-table-column>
							 | 
						|
								        <el-table-column label="操作"
							 | 
						|
								                         fixed="right"
							 | 
						|
								                         width="140"
							 | 
						|
								                         header-align="center"
							 | 
						|
								                         align="center"
							 | 
						|
								                         class="operate">
							 | 
						|
								          <template slot-scope="scope">
							 | 
						|
								
							 | 
						|
								            <el-button type="text"
							 | 
						|
								                       style="color:#1C6AFD;text-decoration: underline;"
							 | 
						|
								                       size="small"
							 | 
						|
								                       @click="handleDetail(scope.row)">查看</el-button>
							 | 
						|
								            <el-button type="text"
							 | 
						|
								                       style="color:#00A7A9;text-decoration: underline;"
							 | 
						|
								                       size="small"
							 | 
						|
								                       @click="handleEdit(scope.row)">修改</el-button>
							 | 
						|
								
							 | 
						|
								            <el-button type="text"
							 | 
						|
								                       style="color:#D51010;text-decoration: underline;"
							 | 
						|
								                       size="small"
							 | 
						|
								                       @click="handleDelete(scope.row)">删除</el-button>
							 | 
						|
								          </template>
							 | 
						|
								        </el-table-column>
							 | 
						|
								      </el-table>
							 | 
						|
								      <div>
							 | 
						|
								        <el-pagination @size-change="handleSizeChange"
							 | 
						|
								                       @current-change="handleCurrentChange"
							 | 
						|
								                       :current-page.sync="pageNo"
							 | 
						|
								                       :page-sizes="[20, 50, 100, 200]"
							 | 
						|
								                       :page-size="pageSize"
							 | 
						|
								                       layout="sizes, prev, pager, next, total"
							 | 
						|
								                       :total="total">
							 | 
						|
								        </el-pagination>
							 | 
						|
								      </div>
							 | 
						|
								    </div>
							 | 
						|
								
							 | 
						|
								    <!-- 修改弹出框 -->
							 | 
						|
								    <el-dialog :visible.sync="formShow"
							 | 
						|
								               :close-on-click-modal="false"
							 | 
						|
								               :close-on-press-escape="false"
							 | 
						|
								               :title="formTitle"
							 | 
						|
								               width="900px"
							 | 
						|
								               @closed="diaClose">
							 | 
						|
								      <room-form ref="ref_form"
							 | 
						|
								                 @dialogCancle="addFormCancle"
							 | 
						|
								                 @dialogOk="addFormOk"></room-form>
							 | 
						|
								    </el-dialog>
							 | 
						|
								
							 | 
						|
								  </div>
							 | 
						|
								</template>
							 | 
						|
								
							 | 
						|
								<script>
							 | 
						|
								
							 | 
						|
								import roomForm from './roomForm'
							 | 
						|
								
							 | 
						|
								import { requestPost } from "@/js/dai/request";
							 | 
						|
								import { mapGetters } from 'vuex'
							 | 
						|
								import { Loading } from 'element-ui' // 引入Loading服务
							 | 
						|
								
							 | 
						|
								let loading // 加载动画
							 | 
						|
								export default {
							 | 
						|
								  data () {
							 | 
						|
								    return {
							 | 
						|
								      loading: false,
							 | 
						|
								      total: 0,
							 | 
						|
								      pageSize: 10,
							 | 
						|
								      pageNo: 0,
							 | 
						|
								      tableLoading: true,
							 | 
						|
								
							 | 
						|
								      agencyObj: {},//树所选的小区对象
							 | 
						|
								      ownerName: '',
							 | 
						|
								      ownerPhone: '',
							 | 
						|
								      tableData: [],
							 | 
						|
								
							 | 
						|
								      //form相关
							 | 
						|
								      formShow: false,
							 | 
						|
								      formTitle: '新增房屋',
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    }
							 | 
						|
								  },
							 | 
						|
								  components: {
							 | 
						|
								    roomForm
							 | 
						|
								  },
							 | 
						|
								  async mounted () {
							 | 
						|
								
							 | 
						|
								  },
							 | 
						|
								  computed: {
							 | 
						|
								    tableHeight () {
							 | 
						|
								
							 | 
						|
								      return (this.clientHeight - 300)
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    ...mapGetters(['clientHeight'])
							 | 
						|
								  },
							 | 
						|
								  methods: {
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    handleSearch () {
							 | 
						|
								      this.loadTable()
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    async loadTable (fromTree, treeObj) {
							 | 
						|
								      this.tableLoading = true
							 | 
						|
								      if (fromTree) {
							 | 
						|
								        this.agencyObj = treeObj
							 | 
						|
								      }
							 | 
						|
								      const url = "/gov/org/house/houselist"
							 | 
						|
								
							 | 
						|
								      let params = {
							 | 
						|
								        pageSize: this.pageSize,
							 | 
						|
								        pageNo: this.pageNo,
							 | 
						|
								        ownerName: this.ownerName,
							 | 
						|
								        ownerPhone: this.ownerPhone,
							 | 
						|
								        buildingId: this.agencyObj.id
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      const { data, code, msg } = await requestPost(url, params)
							 | 
						|
								
							 | 
						|
								      if (code === 0) {
							 | 
						|
								        this.total = data.total
							 | 
						|
								        this.tableData = data.list
							 | 
						|
								      } else {
							 | 
						|
								        this.$message.error(msg)
							 | 
						|
								      }
							 | 
						|
								      this.tableLoading = false
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    diaClose () {
							 | 
						|
								      this.$refs.ref_form.resetData()
							 | 
						|
								      this.formShow = false
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    handleDetail (row) {
							 | 
						|
								      this.formTitle = '房屋详情'
							 | 
						|
								      this.formShow = true
							 | 
						|
								      this.$nextTick(() => {
							 | 
						|
								        this.$refs.ref_form.initForm('detail', row, this.agencyObj)
							 | 
						|
								      })
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    handleAdd () {
							 | 
						|
								      this.formTitle = '新增房屋'
							 | 
						|
								      this.formShow = true
							 | 
						|
								      this.$nextTick(() => {
							 | 
						|
								        this.$refs.ref_form.initForm('add', null, this.agencyObj)
							 | 
						|
								      })
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    handleEdit (row) {
							 | 
						|
								      this.formTitle = '修改房屋'
							 | 
						|
								      this.formShow = true
							 | 
						|
								      this.$nextTick(() => {
							 | 
						|
								        this.$refs.ref_form.initForm('edit', row, this.agencyObj)
							 | 
						|
								      })
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    addFormCancle () {
							 | 
						|
								      this.formShow = false
							 | 
						|
								    },
							 | 
						|
								    addFormOk () {
							 | 
						|
								      this.formShow = false
							 | 
						|
								      this.loadTable()
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    async handleDelete (row) {
							 | 
						|
								
							 | 
						|
								      this.$confirm("确认删除?", "提示", {
							 | 
						|
								        confirmButtonText: "确定",
							 | 
						|
								        cancelButtonText: "取消",
							 | 
						|
								        type: "warning"
							 | 
						|
								      })
							 | 
						|
								        .then(() => {
							 | 
						|
								          this.deleteRoom(row)
							 | 
						|
								        })
							 | 
						|
								        .catch(err => {
							 | 
						|
								          if (err == "cancel") {
							 | 
						|
								            // this.$message({
							 | 
						|
								            //   type: "info",
							 | 
						|
								            //   message: "已取消删除"
							 | 
						|
								            // });
							 | 
						|
								          }
							 | 
						|
								
							 | 
						|
								        });
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    async deleteRoom (row) {
							 | 
						|
								      const url = "/gov/org/house/housedel"
							 | 
						|
								
							 | 
						|
								      let params = {
							 | 
						|
								        houseId: row.houseId
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      const { data, code, msg } = await requestPost(url, params)
							 | 
						|
								
							 | 
						|
								      if (code === 0) {
							 | 
						|
								        this.$message({
							 | 
						|
								          type: "success",
							 | 
						|
								          message: "删除成功"
							 | 
						|
								        });
							 | 
						|
								        this.$emit('refreshTree')
							 | 
						|
								        this.loadTable()
							 | 
						|
								      } else {
							 | 
						|
								        this.$message.error(msg)
							 | 
						|
								      }
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    //导出表格
							 | 
						|
								    async handleExport () {
							 | 
						|
								      let title = this.agencyObj.label
							 | 
						|
								      title = title + '—房屋列表'
							 | 
						|
								
							 | 
						|
								      const url = "/gov/org/house/exporthouseinfo"
							 | 
						|
								      let params = {
							 | 
						|
								        ownerName: this.ownerName,
							 | 
						|
								        ownerPhone: this.ownerPhone,
							 | 
						|
								        buildingId: this.agencyObj.id
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      app.ajax.exportFilePost(
							 | 
						|
								        url,
							 | 
						|
								        params,
							 | 
						|
								        (data, rspMsg) => {
							 | 
						|
								
							 | 
						|
								          this.download(data, title + '.xls')
							 | 
						|
								        },
							 | 
						|
								        (rspMsg, data) => {
							 | 
						|
								          this.$message.error(rspMsg);
							 | 
						|
								        }
							 | 
						|
								      );
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    // 下载文件
							 | 
						|
								    download (data, fileName) {
							 | 
						|
								      if (!data) {
							 | 
						|
								        return
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      var csvData = new Blob([data])
							 | 
						|
								
							 | 
						|
								      if (window.navigator && window.navigator.msSaveOrOpenBlob) {
							 | 
						|
								        window.navigator.msSaveOrOpenBlob(csvData, fileName);
							 | 
						|
								      }
							 | 
						|
								      // for Non-IE (chrome, firefox etc.)
							 | 
						|
								      else {
							 | 
						|
								        var a = document.createElement('a');
							 | 
						|
								        document.body.appendChild(a);
							 | 
						|
								        a.style = 'display: none';
							 | 
						|
								        var url = window.URL.createObjectURL(csvData);
							 | 
						|
								        a.href = url;
							 | 
						|
								        a.download = fileName;
							 | 
						|
								        a.click();
							 | 
						|
								        a.remove();
							 | 
						|
								        window.URL.revokeObjectURL(url);
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    handleExportModule () {
							 | 
						|
								      let title = ''
							 | 
						|
								      title = '房屋模板'
							 | 
						|
								
							 | 
						|
								      const url = "/gov/org/house/exporttemplate"
							 | 
						|
								      let params = {}
							 | 
						|
								
							 | 
						|
								      app.ajax.exportFilePost(
							 | 
						|
								        url,
							 | 
						|
								        params,
							 | 
						|
								        (data, rspMsg) => {
							 | 
						|
								
							 | 
						|
								          this.download(data, title + '.xls')
							 | 
						|
								        },
							 | 
						|
								        (rspMsg, data) => {
							 | 
						|
								          this.$message.error(rspMsg);
							 | 
						|
								        }
							 | 
						|
								      );
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    // 上传文件之前的钩子
							 | 
						|
								    beforeUpload (file) {
							 | 
						|
								      this.files = file;
							 | 
						|
								
							 | 
						|
								      const isText = file.type === 'application/vnd.ms-excel'
							 | 
						|
								      const isTextComputer = file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
							 | 
						|
								
							 | 
						|
								      if (!isText && !isTextComputer) {
							 | 
						|
								        this.$message.error('请选择正确格式的文件')
							 | 
						|
								        return false
							 | 
						|
								      } else {
							 | 
						|
								        this.fileName = file.name;
							 | 
						|
								        return true
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								    // 上传文件个数超过定义的数量
							 | 
						|
								    handleExceed (files, fileList) {
							 | 
						|
								      this.$message.warning(`当前限制选择 1 个文件,请删除后继续上传`)
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    async uploadFile () {
							 | 
						|
								      this.loading = true
							 | 
						|
								
							 | 
						|
								      if (this.fileName == "") {
							 | 
						|
								        this.$message.warning('请选择要上传的文件!')
							 | 
						|
								        return false
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								      //清空上传列表
							 | 
						|
								      this.$refs['upload'].clearFiles()
							 | 
						|
								
							 | 
						|
								      var url = '/gov/org/house/import'
							 | 
						|
								      let fileFormData = new FormData();
							 | 
						|
								      fileFormData.append('file', this.files);//filename是键,file是值,就是要传的文件,test.zip是要传的文件名
							 | 
						|
								
							 | 
						|
								      const { data, code, msg } = await requestPost(url, fileFormData)
							 | 
						|
								      if (code === 0) {
							 | 
						|
								        this.$message({
							 | 
						|
								          type: "success",
							 | 
						|
								          message: "导入成功"
							 | 
						|
								        });
							 | 
						|
								        this.$emit('refreshTree')
							 | 
						|
								        this.loadTable()
							 | 
						|
								      } else {
							 | 
						|
								        this.$message.error(msg)
							 | 
						|
								      }
							 | 
						|
								
							 | 
						|
								
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    handleSizeChange (val) {
							 | 
						|
								      this.pageSize = val
							 | 
						|
								      this.pageNo = 1
							 | 
						|
								      this.loadTable()
							 | 
						|
								    },
							 | 
						|
								    handleCurrentChange (val) {
							 | 
						|
								      this.pageNo = val
							 | 
						|
								      this.loadTable()
							 | 
						|
								    },
							 | 
						|
								
							 | 
						|
								    // 开启加载动画
							 | 
						|
								    startLoading () {
							 | 
						|
								      loading = Loading.service({
							 | 
						|
								        lock: true, // 是否锁定
							 | 
						|
								        text: '正在加载……', // 加载中需要显示的文字
							 | 
						|
								        background: 'rgba(0,0,0,.7)' // 背景颜色
							 | 
						|
								      })
							 | 
						|
								    },
							 | 
						|
								    // 结束加载动画
							 | 
						|
								    endLoading () {
							 | 
						|
								      // clearTimeout(timer);
							 | 
						|
								      if (loading) {
							 | 
						|
								        loading.close()
							 | 
						|
								      }
							 | 
						|
								    }
							 | 
						|
								  },
							 | 
						|
								  watch: {
							 | 
						|
								    filterText (val) {
							 | 
						|
								      this.$refs.tree.filter(val);
							 | 
						|
								    }
							 | 
						|
								  },
							 | 
						|
								  props: {
							 | 
						|
								
							 | 
						|
								  }
							 | 
						|
								}
							 | 
						|
								</script>
							 | 
						|
								<style lang="scss" scoped >
							 | 
						|
								@import "@/assets/scss/buttonstyle.scss";
							 | 
						|
								.div_search {
							 | 
						|
								  display: flex;
							 | 
						|
								
							 | 
						|
								  .resi-cell {
							 | 
						|
								    display: flex;
							 | 
						|
								    align-items: center;
							 | 
						|
								    .resi-cell-label {
							 | 
						|
								      width: 70px;
							 | 
						|
								      box-sizing: border-box;
							 | 
						|
								      margin-right: 15px;
							 | 
						|
								      text-align: right;
							 | 
						|
								      // line-height: 32;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    .resi-cell-input {
							 | 
						|
								      width: 180px;
							 | 
						|
								    }
							 | 
						|
								  }
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								.div_table {
							 | 
						|
								  margin-top: 20px;
							 | 
						|
								}
							 | 
						|
								.div_search {
							 | 
						|
								  display: flex;
							 | 
						|
								
							 | 
						|
								  .resi-cell {
							 | 
						|
								    display: flex;
							 | 
						|
								    align-items: center;
							 | 
						|
								    .resi-cell-label {
							 | 
						|
								      width: 70px;
							 | 
						|
								      box-sizing: border-box;
							 | 
						|
								      margin-right: 15px;
							 | 
						|
								      text-align: right;
							 | 
						|
								      // line-height: 32;
							 | 
						|
								    }
							 | 
						|
								
							 | 
						|
								    .resi-cell-input {
							 | 
						|
								      width: 180px;
							 | 
						|
								    }
							 | 
						|
								  }
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								.div_btn {
							 | 
						|
								  margin-top: 20px;
							 | 
						|
								}
							 | 
						|
								
							 | 
						|
								.el-row {
							 | 
						|
								  /* margin-bottom: 20px; */
							 | 
						|
								  display: flex;
							 | 
						|
								  flex-wrap: wrap;
							 | 
						|
								  margin-top: 10px;
							 | 
						|
								  margin-right: 50px;
							 | 
						|
								}
							 | 
						|
								</style>
							 | 
						|
								
							 |