Kaynağa Gözat

add floor and edit floor

haojianlong 5 yıl önce
ebeveyn
işleme
35ba1fadb0

+ 18 - 0
src/api/scan/request.js

@@ -1186,4 +1186,22 @@ export function dynamicQueryPrompt(param, success) {
 export function dynamicQueryAI(param, success) {
     let url = `${baseUrl}/pointconfig/dynamic/ai`;
     http.postJson(url, param, success)
+}
+
+//建筑楼层管理-创建楼层
+export function manageCreateFloor(param, success) {
+    let url = `${baseUrl}/datacenter/floor/create`;
+    http.postJson(url, param, success)
+}
+
+//建筑楼层管理-删除楼层
+export function manageDeleteFloor(param, success) {
+    let url = `${baseUrl}/datacenter/floor/delete`;
+    http.postJson(url, param, success)
+}
+
+//建筑楼层管理-修改楼层
+export function manageUpdateFloor(param, success) {
+    let url = `${baseUrl}/datacenter/floor/update`;
+    http.postJson(url, param, success)
 }

+ 1 - 1
src/components/ready/buildfloor/formItems.vue

@@ -43,7 +43,7 @@ export default {
           PageNumber: 1,
           PageSize: 50
         },
-        type: 'Building '
+        type: this.type
       };
       getDataDictionary(params, res => {
         this.InforsList = res.Content.map(item => {

+ 41 - 11
src/utils/buildfloor/tools.js

@@ -1,31 +1,40 @@
 const tools = {}
 
 /**
- * arr [a,b,c]
+ * @param arr [a,b,c]
  * 
  * val value
  */
 function returnNewObj(data, arr, val) {
-  if(arr.length > 1){
+  if (arr.length > 1) {
     let k = arr.shift()
-    let curk = arr[0]
-    if(!data[k]){
+    if (!data[k]) {
       data[k] = {}
-    } 
+    }
     returnNewObj(data[k], arr, val)
-  }else{
+  } else {
     let curk = arr[0]
     data[curk] = val;
   }
 }
 
-
+/**
+ * @param key a
+ * @param val {b:{c:''}}|''|1
+ * @return a.b.c
+ */
+function rKeyStrVal(key, val) {
+  let nk = key,arr = []
+  if (typeof (val) == 'object') {
+    // for(let k in )
+    return nk + '.' + rKeyStrVal()
+  }
+  return nk
+}
 
 /**
- * param data Object
- * 
- * 将对象中 key 为a.b.c 转换为a:{b:{c:''}}
- * 
+ * @param data Object
+ * @returns 将对象中 key 为a.b.c 转换为a:{b:{c:''}}
  */
 tools.formatData = (data) => {
   let newData = JSON.parse(JSON.stringify(data))
@@ -39,4 +48,25 @@ tools.formatData = (data) => {
   return newData
 }
 
+/**
+ * @param data {a:{b:{c:{}}}}
+ * 
+ * @returns a.b.c
+ * 
+ */
+tools.desFormatData = (data) => {
+  let newData = {}
+  for (let key in data) {
+    if (typeof (data[key]) == 'object') { 
+      for(let childK in data[key]){
+        let nk = `${key}.${childK}`
+        newData[nk] = data[key][childK]
+      }
+    } else {
+      newData[key] = data[key]
+    }
+  }
+  return newData
+}
+
 export default tools

+ 43 - 25
src/views/ready/buildfloor/addFloor/index.vue

@@ -10,7 +10,10 @@
   </el-dialog>
 </template>
 <script>
-import { getDataDictionary } from "@/api/scan/request";
+import {
+  manageCreateFloor,
+  manageUpdateFloor
+} from "@/api/scan/request";
 import formItems from "@/components/ready/buildfloor/formItems";
 import tools from "@/utils/buildfloor/tools";
 export default {
@@ -20,46 +23,61 @@ export default {
     },
     type: {
       default: 'Floor'
+    },
+    curBuildId: {
+      default: ''
+    },
+    curFloorId: {
+      default: ''
     }
   },
-  components:{
+  components: {
     formItems
   },
   data() {
     return {
       dialogVisible: false, //弹窗显示与隐藏
-      FloorTypeList: [
-        { "Code": "1", "Name": "普通楼层" },
-        { "Code": "2", "Name": "室外" },
-        { "Code": "3", "Name": "夹层" },
-        { "Code": "4", "Name": "屋顶平台" },
-        { "Code": "99", "Name": "其他" }
-      ],
-      InforsList:[]
+      floorData: {}
     };
   },
   methods: {
     showDialog(data) {
-      this.tableData = data || '';
+      this.floorData = data || {};
+      this.floorData = tools.desFormatData(this.floorData)
+      this.timeoutSetVal()
       this.dialogVisible = true;
-      let params = {
-        data: {
-          PageNumber: 1,
-          PageSize: 50
-        },
-        type: this.type
-      };
-      getDataDictionary(params, res => {
-        this.InforsList = res.Content
-      })
     },
-    handleClose(done) { },
-    //清除关系
+    timeoutSetVal() {
+      setTimeout(() => {
+        if (this.$refs.formItems) {
+          this.$refs.formItems.form = this.floorData
+        } else {
+          this.timeoutSetVal()
+        }
+      }, 500)
+    },
+    handleClose() { },
+    //创建
     confirm() {
       let form = this.$refs.formItems.form
       let newform = tools.formatData(form)
-      console.log('-------------')
-      console.log(newform)
+      newform.BuildID = this.curBuildId
+      let Param = {
+        Content: [newform]
+      }
+      if (newform.FloorID) {
+        manageUpdateFloor(Param, res => {
+          this.$message.success('更新成功')
+          this.$emit('refresh')
+          this.dialogVisible = false;
+        })
+      } else {
+        manageCreateFloor(Param, res => {
+          this.$message.success('创建成功')
+          this.$emit('refresh')
+          this.dialogVisible = false;
+        })
+      }
     }
   },
   mounted() { },

+ 97 - 23
src/views/ready/buildfloor/index.vue

@@ -3,16 +3,19 @@
     <el-row>
       <div class="l-list">
         <div class="action-box">
-          <el-button size="small" type="default" icon="el-icon-plus" @click="addBuild"></el-button>
-          <el-button size="small" type="default" icon="el-icon-minus" @click="delBuild"></el-button>
-          <el-button size="small" type="default" icon="el-icon-edit-outline" @click="editBuild"></el-button>
+          <div style="height:35px;"></div>
+          <div v-if="0">
+            <el-button size="small" type="default" icon="el-icon-plus" @click="addBuild"></el-button>
+            <el-button size="small" type="default" icon="el-icon-minus" @click="delBuild"></el-button>
+            <el-button size="small" type="default" icon="el-icon-edit-outline" @click="editBuild"></el-button>
+          </div>
         </div>
         <h4>建筑</h4>
-        <div class="floor-list">
-          <div v-for="item in floorList" :key="item.id" class="floor-item" @click="changeBuild">
+        <div class="build-list">
+          <div v-for="(item,index) in buildList" :key="item.BuildID" :class="{'floor-item':true,active:item.active}" @click="changeBuild(index)">
             <span>
-              {{item.name}}
-              <el-badge class="mark" is-dot />
+              {{item.BuildLocalName || item.BuildName}}
+              <el-badge class="mark" :is-dot="false" />
             </span>
           </div>
         </div>
@@ -23,10 +26,12 @@
         </div>
         <div class="table-box">
           <el-table :data="tableData" style="width: 100%" height="100%" v-loading="loading" :header-cell-style="headerStyle">
-            <el-table-column prop="EquipmentMark" label="楼层本地名" show-overflow-tooltip></el-table-column>
+            <el-table-column label="楼层本地名">
+              <template slot-scope="scope">{{scope.row.FloorLocalName||scope.row.FloorName}}</template>
+            </el-table-column>
             <el-table-column label="楼层信息">
               <template slot-scope="scope">
-                <el-button size="mini" @click="handleDelete(scope.$index, scope.row)" plain icon="el-icon-edit-outline"></el-button>
+                <el-button size="mini" @click="editFloorData(scope.row)" plain icon="el-icon-edit-outline"></el-button>
               </template>
             </el-table-column>
             <el-table-column prop="Datasource" label="平面图">
@@ -55,7 +60,7 @@
             </el-table-column>
             <el-table-column prop="action" label="操作">
               <template slot-scope="scope">
-                <el-button size="mini" @click="handleDelete(scope.$index, scope.row)" type="danger" plain icon="el-icon-delete"></el-button>
+                <el-button size="mini" @click="handleDelete(scope.row)" type="danger" plain icon="el-icon-delete"></el-button>
               </template>
             </el-table-column>
           </el-table>
@@ -67,15 +72,15 @@
       </div>
     </el-row>
     <!-- 添加-修改楼层 -->
-    <addFloor :title="floorTitle" ref="addFloorDialog"></addFloor>
+    <addFloor :title="floorTitle" ref="addFloorDialog" :curBuildId="curBuildId" :curFloorId="curFloorId" @refresh="refresh"></addFloor>
     <!-- 添加-修改建筑 -->
     <addBuild :title="buildTitle" ref="addBuildDialog"></addBuild>
     <!-- 删除建筑-删除楼层 -->
     <el-dialog title="提示" :visible.sync="delDialogVis" width="20%" @close="handleClose" id="messageDialog">
       <div>确定要删除该{{delText}}?</div>
       <span slot="footer" class="dialog-footer">
-        <el-button size="small">取消</el-button>
-        <el-button size="small" type="primary" @click="confirm">确认</el-button>
+        <el-button size="small" @click="delDialogVis=false">取消</el-button>
+        <el-button size="small" type="primary" @click="confirmDel">确认</el-button>
       </span>
     </el-dialog>
 
@@ -85,6 +90,11 @@
 <script>
 import addFloor from "@/views/ready/buildfloor/addFloor/index";
 import addBuild from "@/components/ready/buildfloor/addBuild";
+import {
+  buildingQuery,
+  floorQuery,
+  manageDeleteFloor
+} from "@/api/scan/request";
 export default {
   components: {
     addFloor,
@@ -101,11 +111,7 @@ export default {
         color: '#2b2b2b',
         lineHeight: '30px'
       },
-      floorList: [
-        { id: 1, name: '建筑a' },
-        { id: 2, name: '建筑b' },
-        { id: 3, name: '建筑c' },
-      ],
+      buildList: [],
       tableData: [
         {
           EquipmentMark: 1
@@ -117,28 +123,96 @@ export default {
         pageNumber: 1,
         total: 0
       },
-      loading: false
+      loading: false, //列表loading
+      curBuildId: '', //当前选中的建筑id
+      curFloorId: '', //当前选中的楼层id
     }
   },
   mounted() { },
+  created() {
+    let bdParam = {
+      PageNumber: 1,
+      PageSize: 500
+    }
+    buildingQuery(bdParam, res => {
+      this.buildList = res.Content;
+      if (this.buildList.length) {
+        this.changeBuild(0)
+      }
+    })
+  },
   methods: {
-    changeBuild() { },
+    //change build
+    changeBuild(index) {
+      this.buildList.map(item => {
+        item.active = false
+        return item
+      })
+      this.buildList[index].active = true;
+      this.curBuildId = this.buildList[index].BuildID;
+      this.getFloorTableData()
+      this.$forceUpdate()
+    },
+    //add build
     addBuild() {
       this.$refs.addBuildDialog.showDialog()
     },
+    //delete build
     delBuild() {
       this.delText = '建筑';
       this.delDialogVis = true
     },
+    //edit build
     editBuild() { },
-    handleDelete() {
+    //delete floor
+    handleDelete(floor) {
       this.delText = '楼层';
-      this.delDialogVis = true
+      this.delDialogVis = true;
+      this.curFloorId = floor.FloorID;
     },
+    //确认删除弹窗关闭
+    handleClose() { },
     handleSizeChange(pageSize) { },
     handleCurrentChange(pageNumber) { },
     addFloor() {
+      this.curFloorId = ''
       this.$refs.addFloorDialog.showDialog()
+    },
+    // 获取列表
+    getFloorTableData() {
+      let floorParam = {
+        Orders: "FloorSequenceID desc",
+        PageNumber: this.page.pageNumber,
+        PageSize: this.page.pageSize,
+        Filters: `BuildID='${this.curBuildId}'`
+      }
+      floorQuery(floorParam, res => {
+        this.tableData = res.Content;
+        this.page.total = res.Total
+      })
+    },
+    // 创建楼层成功
+    refresh(){
+      this.getFloorTableData()
+    },
+    // 确认删除(删除建筑-楼层公用)
+    confirmDel() {
+      if (this.delText == '楼层') {
+        let delParam = [{ FloorID: this.curFloorId }]
+        manageDeleteFloor(delParam, res => {
+          this.$message.success('删除成功');
+          this.delDialogVis = false;
+          this.getFloorTableData()
+        })
+      } else {
+        //todo
+      }
+    
+    },
+    // 修改楼层信息
+    editFloorData(floor){
+      this.curFloorId = floor.FloorID;
+      this.$refs.addFloorDialog.showDialog(floor)
     }
   }
 }
@@ -173,7 +247,7 @@ export default {
         border-bottom: 1px solid #dfe6ec;
         line-height: 44px;
       }
-      .floor-list {
+      .build-list {
         line-height: 48px;
         .floor-item {
           white-space: nowrap;