huangmp пре 4 година
родитељ
комит
183c35c277

+ 12 - 0
src/api/community/building.js

@@ -32,6 +32,18 @@ export const remove = (ids) => {
   })
 }
 
+export const removeAll = (id) => {
+  return request({
+    url: '/api/cyzh-community/building/removeAll',
+    method: 'post',
+    params: {
+      id,
+    }
+  })
+}
+
+
+
 export const add = (row) => {
   return request({
     url: '/api/cyzh-community/building/submit',

+ 10 - 0
src/api/community/floor.js

@@ -48,3 +48,13 @@ export const update = (row) => {
   })
 }
 
+
+export const removeAll = (id) => {
+  return request({
+    url: '/api/cyzh-community/floor/removeAll',
+    method: 'post',
+    params: {
+      id,
+    }
+  })
+}

+ 10 - 0
src/api/community/room.js

@@ -48,3 +48,13 @@ export const update = (row) => {
   })
 }
 
+
+export const removeAll = (id) => {
+  return request({
+    url: '/api/cyzh-community/room/removeAll',
+    method: 'post',
+    params: {
+      id,
+    }
+  })
+}

+ 10 - 0
src/api/community/unit.js

@@ -32,6 +32,16 @@ export const remove = (ids) => {
   })
 }
 
+export const removeAll = (id) => {
+  return request({
+    url: '/api/cyzh-community/unit/removeAll',
+    method: 'post',
+    params: {
+      id,
+    }
+  })
+}
+
 export const add = (row) => {
   return request({
     url: '/api/cyzh-community/unit/submit',

+ 149 - 32
src/components/agency/agencymng.vue

@@ -1,31 +1,34 @@
 <template>
-  <el-dialog :title="title" center width="70%" @close="agencymng.isClose=true;" :visible.sync="agencymngShow"
-    :destroy-on-close="true" :modal-append-to-body="true" :append-to-body="true">
-    <div style="margin-top:-15px;padding-bottom:20px;display:flex;cursor: pointer">
-      <span style="font-size:14px">管理:</span>
-      <el-breadcrumb separator-class="el-icon-arrow-right">
-        <el-breadcrumb-item v-for="(item,index) in breadcrumbList" :key="index">
-          <span @click="breadcrumbClick(item,index)"
-            style="color:#3b8ff4;font-size:16px;cursor: pointer">{{item.label}}</span>
-        </el-breadcrumb-item>
-      </el-breadcrumb>
-    </div>
-    <div class="full">
-      <el-row :gutter="0">
-        <el-col :span="4">
-          <tree ref="tree" @nodeClick="nodeClick" v-if="$isNotEmpty(agencymng.agencyId)&&!this.agencymng.isClose">
-          </tree>
-        </el-col>
-        <el-col :span="20">
-          <residential v-if="listShow(0)"></residential>
-          <building v-if="listShow(1)"></building>
-          <unit v-if="listShow(2)"></unit>
-          <floor v-if="listShow(3)"></floor>
-          <room ref="room" v-show="agencymng.level==4||agencymng.level==5"></room>
-        </el-col>
-      </el-row>
-    </div>
-  </el-dialog>
+  <div>
+    <el-dialog :title="title" center width="70%" @close="agencymng.isClose=true;" :visible.sync="agencymngShow"
+      :destroy-on-close="true" :modal-append-to-body="true" :append-to-body="true">
+      <div @click="hideMenu" style="margin-top:-15px;padding-bottom:20px;display:flex;cursor: pointer">
+        <span style="font-size:14px">管理:</span>
+        <el-breadcrumb separator-class="el-icon-arrow-right">
+          <el-breadcrumb-item v-for="(item,index) in breadcrumbList" :key="index">
+            <span @click.stop="breadcrumbClick(item,index)"
+              style="color:#3b8ff4;font-size:16px;cursor: pointer">{{item.label}}</span>
+          </el-breadcrumb-item>
+        </el-breadcrumb>
+      </div>
+      <div class="full" @click="hideMenu">
+        <el-row :gutter="0">
+          <el-col :span="4">
+            <tree ref="tree" @nodeClick="nodeClick"
+              v-if="$isNotEmpty(agencymng.agencyId)&&!this.agencymng.isClose&&!isReload">
+            </tree>
+          </el-col>
+          <el-col :span="20">
+            <residential ref="residential" v-show="listShow(0)"></residential>
+            <building ref="building" v-show="listShow(1)"></building>
+            <unit ref="unit" v-show="listShow(2)"></unit>
+            <floor ref="floor" v-show="listShow(3)"></floor>
+            <room ref="room" v-show="agencymng.level==4||agencymng.level==5"></room>
+          </el-col>
+        </el-row>
+      </div>
+    </el-dialog>
+  </div>
 </template>
 
 <script>
@@ -54,6 +57,10 @@
     },
     data() {
       return {
+        isReload: false,
+
+        parentNode: {},
+
         breadcrumbList: [],
         agencymng: {
           isClose: false,
@@ -81,12 +88,17 @@
         }
       }
     },
-    destroyed() {
-      console.log("我已经摧毁了");
-    },
     methods: {
+      reload() {
+        this.isReload = true
+        setTimeout(() => {
+          this.isReload = false
+        }, 20)
+      },
+      hideMenu() {
+        this.$refs.tree.hideMenu()
+      },
       breadcrumbClick(item, index) {
-        console.log(item, "breadcrumbClick");
         let list = this.breadcrumbList.reverse()
         list.splice(0, list.length - index - 1)
         this.breadcrumbList = list.reverse()
@@ -146,7 +158,8 @@
         this.updateAgencymng(level, id)
       },
       showDialog(item) {
-        this.agencymng.isClose=false
+        this.parentNode = {}
+        this.agencymng.isClose = false
         this.breadcrumbList = []
         this.agencymngShow = true
         this.title = item.name
@@ -161,6 +174,110 @@
           level: 0
         }
         this.breadcrumbList.unshift(obj)
+      },
+      //右键增删改查
+      menuClick(evt) {
+        let data = evt.data
+        let node = evt.node
+        this.parentNode = node
+        let index = evt.index
+        let level = node.level
+        let refName = this.getRefName(level, index)
+        switch (index) {
+          case 0:
+            this.$refs[refName].showDetail(data)
+            break;
+          case 1:
+            this.$refs[refName].showAdd(data, node)
+            break;
+          case 2:
+            this.$refs[refName].showEdit(data)
+            break;
+          case 3:
+            this.clear(refName, data, level)
+            break;
+          default:
+            break;
+        }
+      },
+      clear(refName, data, level) {
+        let content = `确定清除【${data.name}】?`
+        switch (level) {
+          case 1:
+            content = content + `及其所有子节点:【楼栋/单元/楼层/房间】,操作成功后数据不可恢复!`
+            break;
+          case 2:
+            content = content + `及其所有子节点:【单元/楼层/房间】,操作成功后数据不可恢复!`
+            break;
+          case 3:
+            content = content + `及其所有子节点:【楼层/房间】,操作成功后数据不可恢复!`
+            break;
+          case 4:
+            content = content + `及其所有子节点:【房间】,操作成功后数据不可恢复!`
+            break;
+          case 5:
+            content = content + '操作成功后数据不可恢复!'
+            break;
+        }
+        this.$confirm(content, {
+            confirmButtonText: "确定",
+            cancelButtonText: "取消",
+            type: "warning"
+          })
+          .then(async () => {
+            let flag = await this.$refs[refName].delConfirm(data.id)
+            return flag;
+          })
+          .then(() => {
+            this.reload()
+            this.isReload = true
+            // this.$refs.tree.remove(data)
+            this.$message({
+              type: "success",
+              message: "清除成功!"
+            });
+          });
+      },
+      getRefName(level, index) {
+        let refName;
+        switch (level) {
+          case 1:
+            if (index == 1) {
+              //新增楼栋
+              refName = 'building'
+            } else {
+              refName = 'residential'
+            }
+            break;
+          case 2:
+            if (index == 1) {
+              //新增单元
+              refName = 'unit'
+            } else {
+              refName = 'building'
+            }
+            break;
+          case 3:
+            if (index == 1) {
+              //新增楼层
+              refName = 'floor'
+            } else {
+              refName = 'unit'
+            }
+            break;
+          case 4:
+            if (index == 1) {
+              //新增房间
+              refName = 'room'
+            } else {
+              refName = 'floor'
+            }
+            break;
+          case 5:
+            refName = 'room'
+            break;
+        }
+        return refName
       }
     }
   };

+ 2 - 2
src/components/agency/comps/batch-add-dialog.vue

@@ -127,6 +127,7 @@
   import {saveBatch} from "@/api/community/agencymng.js"
   export default {
     name: '',
+    inject: ['agencymng','index'],
     data() {
       return {
         labelWidth: '90px',
@@ -234,10 +235,9 @@
           Object.assign(model,this.form,this.buildingForm,this.unitForm,this.floorForm,this.roomForm)
           saveBatch(model).then(res=>{
             if (res.data.success) {
+              this.index.reload()
               this.$message.success("操作成功")
               this.dialogShow=false
-              this.index.agencymngShow=false
-              this.$emit('reloadData')
             }
           })
         }

+ 114 - 12
src/components/agency/comps/tree.vue

@@ -1,10 +1,19 @@
 <template>
-  <div>
+  <div @click="hideMenu">
     <div style="max-height:650px;overflow: scroll">
-      <el-button @click="batchAdd" type="primary" style="margin-bottom:10px;" size="mini">批量添加</el-button>
+      <el-button @click.stop="batchAdd" type="primary" style="margin-bottom:10px;" size="mini">批量添加</el-button>
+
       <el-tree style="height:100%" :props="props" ref="elTree" node-key="id" accordion @node-expand="nodeExpand"
-        @node-click="nodeClick" :load="loadNode" lazy>
+        @node-contextmenu="nodeContextmenu" @node-click="nodeClick" :load="loadNode" lazy>
       </el-tree>
+
+      <div class="tree_menu" v-show="menuShow" :style="menuStyle">
+        <div  v-if="item.show" class="tree_menu_item" style="width:100%"  @click="handel(index)" v-for="(item,index) in menuList" :key="index">
+          <i :class="item.icon" style="font-size:12px;margin-right:4px"></i>
+          {{item.name}}
+        </div>
+      </div>
+
     </div>
     <batch-add-dialog ref="batchAddDialog"></batch-add-dialog>
   </div>
@@ -27,16 +36,43 @@
   import {
     getList as getRoomList
   } from "@/api/community/room.js"
-  import {deepClone} from "@/util/deepClone.js"
+  import {
+    deepClone
+  } from "@/util/deepClone.js"
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng', 'index'],
     components: {
       batchAddDialog
     },
     data() {
       return {
-        residentialList :[],
-        
+        nodeContextmenuItem: {},
+
+        menuShow: false,
+        menuStyle: {},
+        menuList: [{
+            show:true,
+            name: '详情',
+            icon: 'el-icon-view'
+          },
+          {
+            show:true,
+            name: '新增',
+            icon: 'el-icon-circle-plus-outline'
+          },
+          {
+            show:true,
+            name: '编辑',
+            icon: 'el-icon-edit'
+          },
+          {
+            show:true,
+            name: '清除',
+            icon: 'el-icon-delete'
+          }
+        ],
+        residentialList: [],
+
         isload: false,
 
         page: {
@@ -53,10 +89,13 @@
       };
     },
     methods: {
+      hideMenu() {
+        this.menuShow = false
+      },
       nodeClick(data, node) {
         let level = node.level
         let list = []
-        let item=node
+        let item = node
         for (var i = 0; i < level; i++) {
           if (item.label) {
             let obj = {
@@ -67,18 +106,40 @@
           }
           item = item.parent
         }
-        let obj={
+        let obj = {
           list,
           node
         }
         this.$emit('nodeClick', obj)
       },
       nodeExpand(data, node) {
+        this.index.hideMenu()
         if (this.isload) {
           return
         }
         this.updateAgencymng(node.level, data.id)
-        console.log(this.agencymng,"nodeExpand");
+      },
+      append(data,parentNode){
+        this.$refs.elTree.append(data,parentNode)
+      },
+      remove(data){
+        this.$refs.elTree.remove(data)
+      },
+      nodeContextmenu(dom, data, node) {
+        if (node.level==5) {
+          this.menuList[1].show=false
+        }else{
+          this.menuList[1].show=true
+        }
+        this.menuShow = true
+        this.menuStyle = {
+          left: dom.x + 'px',
+          top: dom.y + 'px'
+        }
+        this.nodeContextmenuItem = {
+          data,
+          node
+        }
       },
       async loadNode(node, resolve) {
         this.isload = true
@@ -97,7 +158,7 @@
             data = (await getResidentialList(this.page.currentPage, this.page.pageSize, {
               agencyId: id
             })).data.data.records
-            this.residentialList=data
+            this.residentialList = data
             break;
           case 1:
             data = (await getBuildingList(this.page.currentPage, this.page.pageSize, {
@@ -152,7 +213,48 @@
             break;
         }
       },
-
+      handel(index) {
+        this.nodeContextmenuItem.index = index
+        this.index.menuClick(this.nodeContextmenuItem)
+      }
     }
   };
 </script>
+
+<style lang="scss" scoped>
+  .tree_menu {
+    cursor: pointer;
+    width:80px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    flex-direction: column;
+    position: fixed;
+    z-index: 1024;
+    flex-wrap: wrap;
+    background-color: #fff;
+    border: 1px solid #e4e7ed;
+    border-radius: 4px;
+  }
+
+  .tree_menu_item{
+    padding: 5px 0px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+    widht:100%;
+  }
+  .tree_menu_item:first-child{
+    padding-top:10px
+  }
+  .tree_menu_item:last-child{
+    padding-bottom:10px
+  }
+
+  .tree_menu_item:hover {
+    color: #409eff;
+    background: #ecf5ff;
+    border-color: #b3d8ff;
+
+  }
+</style>

+ 66 - 10
src/components/agency/form/building.vue

@@ -10,6 +10,12 @@
         </el-button>
       </template>
     </avue-crud>
+    
+    <!-- tree新增 -->
+    <el-dialog :modal-append-to-body="true" :append-to-body="true" title="新增楼栋" :destroy-on-close="true" :center="true"
+      :visible.sync="addShow" width="45%" :close-on-click-modal="false" top="4%">
+      <avue-form ref="avueForm" :option="option" v-model="addForm" @submit="addSubmit"></avue-form>
+    </el-dialog>
   </basic-container>
 </template>
 
@@ -19,7 +25,8 @@
     getDetail,
     add,
     update,
-    remove
+    remove,
+    removeAll
   } from "@/api/community/building";
   import {
     mapGetters
@@ -29,9 +36,9 @@
   } from "@/util/validator.js";
   let _this;
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng', 'index'],
     watch: {
-      agencymng: {
+      'agencymng.residentialId': {
         handler: (value) => {
           _this.refreshChange()
         },
@@ -43,6 +50,10 @@
     },
     data() {
       return {
+        addShow: false,
+        addForm: {},
+
+
         form: {},
         query: {},
         loading: true,
@@ -53,6 +64,8 @@
         },
         selectionList: [],
         option: {
+          editBtnText: '确认',
+
           dialogWidth: '46%',
           searchMenuSpan: 5,
           labelWidth: 120,
@@ -69,6 +82,9 @@
           menu: false,
           searchShow: false,
           dialogClickModal: false,
+          viewTitle: '',
+          addTitle: '',
+          editTitle: '',
           column: [{
               label: "楼栋名称",
               prop: "name",
@@ -78,12 +94,19 @@
                 trigger: "blur"
               }]
             },
+            {
+              label: "所属区域",
+              prop: "residentialName",
+              disabled: true
+            },
             {
               label: "所属区域",
               prop: "residentialId",
               slot: true,
               type: "select",
               search: true,
+              display: false,
+              hide: true,
               searchFilterable: true,
               // cascaderItem: ['buildingId'],
               dicUrl: "/api/cyzh-community/residential/select?size=100",
@@ -188,24 +211,53 @@
       }
     },
     methods: {
-      showAdd() {
-        this.$refs.crud.rowAdd()
+      //树的crud
+      showAdd(row) {
+        this.addForm = {
+          residentialId: row.id,
+          residentialName: row.name
+        }
+        this.addShow = true
       },
-      rowSave(row, done, loading) {
-        add(row).then(() => {
+      async addSubmit(row, done, loading) {
+        let flag = await this.rowSave(row, done, loading)
+        this.addShow = false
+      },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.isTreeAdd = false
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
+      delConfirm(id) {
+        removeAll(id).then(res => {
+          return res.data.success
+        })
+      },
+      //树的crud
+      async rowSave(row, done, loading) {
+        let res = await add(row)
+        let flag = res.data.success
+        if (flag) {
           this.onLoad(this.page);
           this.$message({
             type: "success",
             message: "操作成功!"
           });
           done();
-        }, error => {
+
+        } else {
           loading();
           window.console.log(error);
-        });
+        }
+        return flag
       },
       rowUpdate(row, index, done, loading) {
         update(row).then(() => {
+          this.index.reload()
           this.onLoad(this.page);
           this.$message({
             type: "success",
@@ -214,7 +266,6 @@
           done();
         }, error => {
           loading();
-          console.log(error);
         });
       },
       rowDel(row) {
@@ -291,6 +342,11 @@
         this.onLoad(this.page, this.query);
       },
       onLoad(page, params = {}) {
+        let residentialId = this.agencymng.residentialId
+        if (this.$isEmpty(residentialId)) {
+          return
+        }
+        console.log("加载楼栋");
         this.loading = true;
         this.query.residentialId = this.agencymng.residentialId
         getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {

+ 73 - 14
src/components/agency/form/floor.vue

@@ -10,6 +10,12 @@
         </el-button>
       </template>
     </avue-crud>
+
+    <!-- tree新增 -->
+    <el-dialog :modal-append-to-body="true" :append-to-body="true" title="新增楼层" :destroy-on-close="true" :center="true"
+      :visible.sync="addShow" width="45%" :close-on-click-modal="false" top="4%">
+      <avue-form ref="avueForm" :option="option" v-model="addForm" @submit="addSubmit"></avue-form>
+    </el-dialog>
   </basic-container>
 </template>
 
@@ -19,7 +25,8 @@
     getDetail,
     add,
     update,
-    remove
+    remove,
+    removeAll
   } from "@/api/community/floor";
   import {
     mapGetters
@@ -29,11 +36,11 @@
   } from "@/util/validator.js";
   let _this;
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng','index'],
     watch: {
-      agencymng: {
+      'agencymng.unitId': {
         handler: (value) => {
-         _this.refreshChange()
+          _this.refreshChange()
         },
         deep: true
       }
@@ -43,6 +50,10 @@
     },
     data() {
       return {
+        addShow: false,
+        addForm: {},
+
+
         form: {},
         query: {},
         loading: true,
@@ -69,6 +80,9 @@
           menu: false,
           searchShow: false,
           dialogClickModal: false,
+          viewTitle: '',
+          addTitle: '',
+          editTitle: '',
           column: [{
               label: "楼层名称",
               width: 100,
@@ -80,15 +94,15 @@
               }]
             },
             {
-              prop:'residentialName',
-              label:"所属区域"
+              prop: 'residentialName',
+              label: "所属区域"
             },
             {
               label: "所属区域",
               prop: "residentialId",
               type: "select",
               cascaderItem: ['buildingId'],
-              hide:true,
+              hide: true,
               remote: true,
               //回显的时候有问题,如果所选不在前十条内,下拉框只会显示id
               dicUrl: "/api/cyzh-community/residential/list?size=900",
@@ -109,8 +123,8 @@
               }]
             },
             {
-              prop:'buildingName',
-              label:'所属楼栋'
+              prop: 'buildingName',
+              label: '所属楼栋'
             },
             {
               label: "所属楼栋",
@@ -118,7 +132,7 @@
               // width: 100,
               slot: true,
               search: true,
-              hide:true,
+              hide: true,
               type: "select",
               // cascaderIndex:0,
               cascaderItem: ['unitId'],
@@ -139,8 +153,8 @@
               }]
             },
             {
-              prop:'unitName',
-              label:'所属单元'
+              prop: 'unitName',
+              label: '所属单元'
             },
             {
               label: "所属单元",
@@ -148,7 +162,7 @@
               // width: 100,
               search: true,
               slot: true,
-              hide:true,
+              hide: true,
               type: "select",
               dicFlag: false,
               // cascaderIndex: 1,
@@ -339,9 +353,48 @@
       }
     },
     methods: {
-      showAdd() {
+      //树的crud
+      showAdd(row) {
+        this.addForm = {
+          unitId:row.id,
+          unitName:row.name,
+          buildingId: row.buildingId,
+          buildingName: row.buildingName,
+          residentialId: row.residentialId,
+          residentialName: row.residentialName,
+        }
+        this.addShow = true
+      },
+      async addSubmit(row, done, loading) {
+        let flag = await this.rowSave(row, done, loading)
+        this.addShow = false
+      },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
+      delConfirm(id) {
+        removeAll(id).then(res => {
+          return res.data.success
+        })
+      },
+      //树的crud
+      showAdd(row) {
+        this.option.addTitle = `新增楼层`
         this.$refs.crud.rowAdd()
       },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
       rowSave(row, done, loading) {
         add(row).then(() => {
           this.onLoad(this.page);
@@ -357,6 +410,7 @@
       },
       rowUpdate(row, index, done, loading) {
         update(row).then(() => {
+          this.index.reload()
           this.onLoad(this.page);
           this.$message({
             type: "success",
@@ -442,6 +496,11 @@
         this.onLoad(this.page, this.query);
       },
       onLoad(page, params = {}) {
+        let unitId = this.agencymng.unitId
+        if (this.$isEmpty(unitId)) {
+          return
+        }
+        console.log("加载楼层");
         this.loading = true;
         this.query.unitId = this.agencymng.unitId
         getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {

+ 21 - 10
src/components/agency/form/residential.vue

@@ -29,9 +29,9 @@
   } from "@/util/validator.js";
   let _this;
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng','index'],
     watch: {
-      agencymng: {
+      'agencymng.agencyId': {
         handler: (value) => {
           _this.refreshChange()
         },
@@ -71,6 +71,9 @@
           menu: false,
           searchShow: false,
           dialogClickModal: false,
+          viewTitle: '',
+          addTitle: '',
+          editTitle: '',
           column: [{
               label: "名称",
               overHidden: true,
@@ -318,9 +321,18 @@
       }
     },
     methods: {
-      showAdd() {
+      showAdd(row) {
+        this.option.addTitle = `新增区域`
         this.$refs.crud.rowAdd()
       },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
       rowSave(row, done, loading) {
         add(row).then(() => {
           this.onLoad(this.page);
@@ -336,6 +348,7 @@
       },
       rowUpdate(row, index, done, loading) {
         update(row).then(() => {
+          this.index.reload()
           this.onLoad(this.page);
           this.$message({
             type: "success",
@@ -412,17 +425,20 @@
         this.$refs.crud.toggleSelection();
       },
       currentChange(currentPage) {
-        console.log(currentPage);
         this.page.currentPage = currentPage;
       },
       sizeChange(pageSize) {
-        console.log(pageSize);
         this.page.pageSize = pageSize;
       },
       refreshChange() {
         this.onLoad(this.page, this.query);
       },
       onLoad(page, params = {}) {
+        let agencyId = this.agencymng.agencyId
+        if (this.$isEmpty(agencyId)) {
+          return
+        }
+        console.log("加载区域");
         this.loading = true;
         this.query.agencyId = this.agencymng.agencyId
         getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {
@@ -437,8 +453,3 @@
     }
   };
 </script>
-
-<style>
-
-
-</style>

+ 61 - 2
src/components/agency/form/room.vue

@@ -22,6 +22,12 @@
         {{scope.row.floorName}}
       </template>
     </avue-crud>
+
+    <!-- tree新增 -->
+    <el-dialog :modal-append-to-body="true" :append-to-body="true" title="新增房间" :destroy-on-close="true" :center="true"
+      :visible.sync="addShow" width="45%" :close-on-click-modal="false" top="4%">
+      <avue-form ref="avueForm" :option="option" v-model="addForm" @submit="addSubmit"></avue-form>
+    </el-dialog>
   </basic-container>
 </template>
 
@@ -35,6 +41,7 @@
     add,
     update,
     remove,
+    removeAll,
     getRoomList,
     getRoomDetail
   } from "@/api/community/room";
@@ -42,9 +49,12 @@
     mapGetters
   } from "vuex";
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng','index'],
     data() {
       return {
+        addShow: false,
+        addForm: {},
+
         form: {},
         query: {},
         loading: true,
@@ -65,8 +75,12 @@
           viewBtn: true,
           menuWidth: 350,
           // delBtn: false,
-          selection: true,
+          selection: false,
           dialogClickModal: false,
+          viewTitle: '',
+          addTitle: '',
+          editTitle: '',
+          menu: false,
           column: [{
               label: "门牌号 ",
               width: 100,
@@ -289,6 +303,50 @@
       }
     },
     methods: {
+      //树的crud
+      showAdd(row) {
+        this.addForm = {
+          floorId: row.id,
+          floorName: row.name,
+          unitId: row.unitId,
+          unitName: row.unitName,
+          buildingId: row.buildingId,
+          buildingName: row.buildingName,
+          residentialId: row.residentialId,
+          residentialName: row.residentialName,
+        }
+        this.addShow = true
+      },
+      async addSubmit(row, done, loading) {
+        let flag = await this.rowSave(row, done, loading)
+        this.addShow = false
+      },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
+      delConfirm(id) {
+        removeAll(id).then(res => {
+          return res.data.success
+        })
+      },
+      //树的crud
+      showAdd(row) {
+        this.option.addTitle = `添加【${row.name}】`
+        this.$refs.crud.rowAdd()
+      },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
       rowSave(row, done, loading) {
         row.userNumber = 0;
         add(row).then(() => {
@@ -305,6 +363,7 @@
       rowUpdate(row, index, done, loading) {
         // done()
         update(row).then(() => {
+          this.index.reload()
           this.onLoad(this.page);
           this.$message({
             type: "success",

+ 72 - 7
src/components/agency/form/unit.vue

@@ -10,6 +10,12 @@
         </el-button>
       </template>
     </avue-crud>
+
+    <!-- tree新增 -->
+    <el-dialog :modal-append-to-body="true" :append-to-body="true" title="新增单元" :destroy-on-close="true" :center="true"
+      :visible.sync="addShow" width="45%" :close-on-click-modal="false" top="4%">
+      <avue-form ref="avueForm" :option="option" v-model="addForm" @submit="addSubmit"></avue-form>
+    </el-dialog>
   </basic-container>
 </template>
 
@@ -19,7 +25,8 @@
     getDetail,
     add,
     update,
-    remove
+    remove,
+    removeAll
   } from "@/api/community/unit";
   import {
     mapGetters
@@ -29,9 +36,9 @@
   } from "@/util/validator.js";
   let _this;
   export default {
-    inject: ['agencymng'],
+    inject: ['agencymng', 'index'],
     watch: {
-      agencymng: {
+      'agencymng.buildingId': {
         handler: (value) => {
           _this.refreshChange()
         },
@@ -43,6 +50,10 @@
     },
     data() {
       return {
+        addShow: false,
+        addForm: {},
+
+
         form: {},
         query: {},
         loading: true,
@@ -69,6 +80,9 @@
           menu: false,
           searchShow: false,
           dialogClickModal: false,
+          viewTitle: '',
+          addTitle: '',
+          editTitle: '',
           column: [{
               label: "单元名称",
               prop: "name",
@@ -112,6 +126,7 @@
               type: "select",
               search: true,
               hide: true,
+              display: false,
               cascaderItem: ['buildingId'],
               // remote: true,
               //回显的时候有问题,如果所选不在前十条内,下拉框只会显示id
@@ -132,11 +147,13 @@
             },
             {
               prop: 'residentialName',
-              label: "所属区域"
+              label: "所属区域",
+              disabled: true
             },
             {
               label: '所属楼栋',
-              prop: 'buildingName'
+              prop: 'buildingName',
+              disabled: true
             },
             {
               label: "所属楼栋",
@@ -146,6 +163,7 @@
               type: "select",
               search: true,
               hide: true,
+              display: false,
               dicUrl: `/api/cyzh-community/building/list?residentialId={{key}}`,
               dicFormatter: (res) => {
                 return res.data.records; //返回字典的层级结构
@@ -278,8 +296,50 @@
       }
     },
     methods: {
-      showAdd() {
-        this.$refs.crud.rowAdd()
+      //树的crud
+      showAdd(row) {
+        this.addForm = {
+          buildingId: row.id,
+          buildingName: row.name,
+          residentialId: row.residentialId,
+          residentialName: row.residentialName,
+        }
+        this.addShow = true
+      },
+      async addSubmit(row, done, loading) {
+        let flag = await this.rowSave(row, done, loading)
+        this.addShow = false
+      },
+      showDetail(row) {
+        this.option.viewTitle = `查看【${row.name}】`
+        this.$refs.crud.rowView(row)
+      },
+      showEdit(row) {
+        this.option.editTitle = `编辑【${row.name}】`
+        this.$refs.crud.rowEdit(row)
+      },
+      delConfirm(id) {
+        removeAll(id).then(res => {
+          return res.data.success
+        })
+      },
+      //树的crud
+      async rowSave(row, done, loading) {
+        let res = await add(row)
+        let flag = res.data.success
+        if (flag) {
+          this.onLoad(this.page);
+          this.$message({
+            type: "success",
+            message: "操作成功!"
+          });
+          done();
+
+        } else {
+          loading();
+          window.console.log(error);
+        }
+        return flag
       },
       rowSave(row, done, loading) {
         add(row).then(() => {
@@ -296,6 +356,7 @@
       },
       rowUpdate(row, index, done, loading) {
         update(row).then(() => {
+          this.index.reload()
           this.onLoad(this.page);
           this.$message({
             type: "success",
@@ -381,6 +442,10 @@
         this.onLoad(this.page, this.query);
       },
       onLoad(page, params = {}) {
+        let buildingId = this.agencymng.buildingId
+        if (this.$isEmpty(buildingId)) {
+          return
+        }
         this.loading = true;
         this.query.buildingId = this.agencymng.buildingId
         getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => {

+ 2 - 2
src/components/map/divide.vue

@@ -357,7 +357,7 @@
             this.$refs.deviceList.fetchDeviceList()
             markers.remove([id])
             this.addMarkers(this.operaEditItem.id, old.position, this.operaEditItem.name, 'marker')
-            this.message({
+            this.$message({
               type: "success",
               message: "操作成功!"
             });
@@ -694,7 +694,7 @@
             this.$refs.deviceList.fetchDeviceList()
             //删除标记
             markers.remove([data.id])
-            this.message({
+            this.$message({
               type: "success",
               message: "操作成功!"
             });

+ 2 - 2
src/styles/element-rewrite/avue-form.scss

@@ -10,8 +10,8 @@
     font-family: Microsoft YaHei;
     font-weight: 400;
     color: #333333 !important;
-    position: absolute;
-    left: calc(50% - 14px)
+    // position: absolute;
+    // left: calc(50% - 14px)
 }
 
 .avue-crud__dialog__header {

+ 0 - 7
src/views/wel/index.vue

@@ -100,13 +100,6 @@
         },
       }
     },
-    created() {
-      let list=[5,4,3,2,1]
-      let level=5
-      let len=list.length
-      list.splice(0,(len-level))
-      console.log(list);
-    },
     methods: {
 
     }