浏览代码

根据设备或部件批量创建资产详情页

zhangyu 5 年之前
父节点
当前提交
8dbc2c90e6

+ 10 - 5
src/components/ledger/handsontables/assets.vue

@@ -186,8 +186,9 @@ export default {
       addData: {}, //添加资产选择的资产类型
       numParams: { // 查询设备部件数量条件
         category:'',
-        buildingId:'',
-        floorId:''
+        buildId:'',
+        floorId:'',
+        Family:''
       },
       dieNum: 0 // 查询设备部件数量
     };
@@ -388,12 +389,16 @@ export default {
     },
     //查看详情
     toDetaiPage() {
-      
+      this.$router.push({
+        path: "/ledger/addPropertys",
+        query: this.numParams
+      })
     },
     //选择设备类型-添加资产
     changeCader(val) {
-      this.addData.Family = val.code;
-      this.addData.name = val.facility;
+      this.addData.Family = val.code
+      this.addData.name = val.facility
+      this.numParams.Family = val.code
     },
     //选择设备或部件
     changeDevice(val) {

+ 6 - 0
src/components/ledger/lib/floorCascader.vue

@@ -53,6 +53,12 @@
             }
         },
         methods: {
+            //设置默认选项
+            setValue(val) {
+                if (val && val.length) {
+                    this.value = val
+                }
+            },
             //获取数据
             getData() {
                 let data, buildParams = {

+ 10 - 5
src/components/ledger/lib/partsDieList.vue

@@ -41,15 +41,20 @@ export default {
       this.value = [''];
       this.getAllData()
     },
-    Family(val) {
-      if(val != "") {
-        this.getAllData();
-      }
+    Family: {
+      handler: function (val) {
+        if(val != "") {
+          this.getAllData()
+        }
+      },
+      immediate: true
     }
   },
   methods: {
     setValue(val) {
-      this.value = val
+      if (val && val.length) {
+        this.value = val
+      }
     },
     //修改val
     changeVal(val) {

+ 7 - 1
src/router/system.js

@@ -42,7 +42,7 @@ import partsadd from '@/views/ledger/facility/partsmanage/addparts/index'
 import deviceadd from '@/views/ledger/facility/addfacility'
 import propertyadd from '@/views/ledger/property/addproperty'
 import propertyLedger from '@/views/ledger/property/index'
-import dialogSystem from '@/views/ledger/property/addproperty'
+import addPropertys from '@/views/ledger/property/addpropertys'//根据未关联资产的设备或部件批量创建设备
 import cenotelist from '@/views/ledger/cenotelist/index' //竖井清单
 import cenoteadd from '@/views/ledger/cenotelist/cenoteadd/index' //添加竖井
 import auth from '@/views/system/auth'
@@ -197,6 +197,12 @@ export default [
                 meta: { keepAlive: false, breadcrumbs: [{ label: '台账管理', path: '/ledger/facility' }, { label: '资产清单', path: '/ledger/property' }, { label: '添加资产' }] }
             },
             {
+                path: 'addPropertys',
+                name: 'addPropertys',
+                component: addPropertys,
+                meta: { keepAlive: false, breadcrumbs: [{ label: '台账管理', path: '/ledger/facility' }, { label: '资产清单', path: '/ledger/property' }, { label: '批量创建' }] }
+            },
+            {
                 path: 'cenotelist',
                 name: 'cenotelist',
                 component: cenotelist,

+ 224 - 0
src/views/ledger/property/addpropertys.vue

@@ -0,0 +1,224 @@
+<template>
+  <div class="box">
+    <div class="condition">
+      <div class="header">
+        <i style="float:left;font-size:30px;padding-right:10px;cursor:pointer;" title="返回" @click="goBack" class="el-icon-back"></i>
+        <die-cascader ref="dieCascader" :Family="params.Family" @change="changeDevice"></die-cascader>
+        <floor-cascader ref="floorCascader" @change="changeFloor"></floor-cascader>
+        <el-button style="float:right;margin-top:1px;" @click="handleClickCreate">创建已选</el-button>
+      </div>
+      <div class="main">
+        <el-table ref="multipleTable" :data="tableData" v-loading='loading' stripe height="100%" @selection-change="handleSelectionChange">
+          <el-table-column type="selection" width="55"></el-table-column>
+          <el-table-column label="设备名称" width="200">
+            <template slot-scope="scope">{{ scope.row.EquipLocalName?scope.row.EquipLocalName:scope.row.EquipName }}</template>
+          </el-table-column>
+          <el-table-column label="设备本地编码" show-overflow-tooltip>
+            <template slot-scope="scope">{{ scope.row.EquipLocalID?scope.row.EquipLocalID:scope.row.EquipID }}</template>
+          </el-table-column>
+          <el-table-column prop="Category" label="设备类型" show-overflow-tooltip width="200"></el-table-column>
+          <el-table-column prop="BuildingId" label="所属建筑"></el-table-column>
+          <el-table-column prop="FloorId" label="所属楼层"></el-table-column>
+          <el-table-column prop="address" label="操作" width="100">
+            <template slot-scope="scope">
+              <el-button @click.native.prevent="handleOpenDetail(scope.row, tableData)" type="text" size="small">详情</el-button>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <div class=footer>
+        <el-pagination
+          class="right"
+          v-show="tableData && tableData.length"
+          @size-change="handleSizeChange"
+          @current-change="handleCurrentChange"
+          :current-page="page.pageNumber"
+          :page-sizes="page.pageSizes"
+          :page-size="page.pageSize"
+          layout="total, sizes, prev, pager, next, jumper"
+          :total="page.total">
+        </el-pagination>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import { mapGetters } from "vuex"
+//组件
+import floorCascader from "@/components/ledger/lib/floorCascader"
+import dieCascader from "@/components/ledger/lib/partsDieList"
+//api
+import { queryPartsDie, createPropertys } from "@/api/scan/request";
+export default {
+  data() {
+    return {
+      params: {},
+      loading: false,
+      page: {
+        pageSize: 50,
+        pageSizes: [10, 20, 50, 100],
+        pageNumber: 1,
+        total: 0
+      },
+      tableData: [],
+      multipleSelection:[]
+    }
+  },
+  computed: {
+    ...mapGetters("layout", ["projectId", "userId", "secret"])
+  },
+  components: {
+    floorCascader,
+    dieCascader
+  },
+  created() {
+    this.params = this.$route.query
+  },
+  mounted() {
+    if (this.params.category) {
+      this.$refs.dieCascader.setValue([this.params.category])
+    }
+    if (this.params.buildId && this.params.floorId) {
+      this.$refs.floorCascader.setValue([this.params.buildId,this.params.floorId])
+    } else if (this.params.buildId && !this.params.floorId) {
+      this.$refs.floorCascader.setValue([this.params.buildId])
+    } else {
+      this.$refs.floorCascader.setValue(['all'])
+    }
+  },
+  watch: {
+    projectId() {}
+  },
+  methods: {
+    //返回
+    goBack() {
+      this.$router.push({
+        path: "/ledger/property",
+        query: { Family: this.params.Family }
+      })
+    },
+    //选择设备或部件
+    changeDevice(val) {
+      if(val.code) {
+        this.params.category = val.code
+      } else {
+        this.params.category = ''
+      }
+      this.getTableData()
+    },
+    //选择建筑楼层
+    changeFloor(value) {
+      if (value[0]) {
+        this.params.buildId = value[0]
+      }
+      if (value[1]) {
+        this.params.floorId = value[1]
+      } else {
+        this.params.floorId = ''
+      }
+      this.getTableData()
+    },
+    //获取表格数据
+    getTableData() {
+      this.loading = true
+      let param = this.formatFilter()
+      queryPartsDie(param, res => {
+        this.tableData = res.Content
+        this.loading = false
+      })
+    },
+    //格式化条件
+    formatFilter() {
+      let param = {
+        Filters: `category='${this.params.category}'`,
+        Orders: "createTime desc, EquipID asc",
+        PageNumber: this.page.pageNumber,
+        PageSize: this.page.pageSize
+      }
+
+      if (this.params.buildId == "noKnow") {
+        param.Filters += `;buildingId isNull`
+      } else if (this.params.buildId && this.params.buildId != "all") {
+        param.Filters += `;buildingId='${this.params.buildId}'`
+      }
+
+      if (this.params.floorId == "noKnow") {
+        param.Filters += `;floorId isNull`
+      } else if (this.params.floorId && this.params.floorId != "all") {
+        param.Filters += `;floorId='${this.params.floorId}'`
+      }
+
+      return param
+    },
+    //选择的设备或部件
+    handleSelectionChange(val) {
+      this.multipleSelection = val;
+    },
+    //切换每页显示多少条数据
+    handleSizeChange(val) {
+      this.page.pageSize = val
+      this.getTableData()
+    },
+    //切换页数
+    handleCurrentChange(val) {
+      this.page.pageNumber = val
+      this.getTableData()
+    },
+    //查看详情
+    handleOpenDetail(row) {
+      // window.open(`http://adm.sagacloud.cn:8058/spread?id=${row.EquipID}&pid=${this.projectId}&secret=${this.secret}`,"_blank")
+      this.$message("开发中...")
+    },
+    //创建已选
+    handleClickCreate() {
+      let list = this.multipleSelection.map((item) => {
+        return item.EquipID
+      })
+      let param = {
+        Filters: `EquipID in ${JSON.stringify(list)}`
+      }
+      createPropertys(param, res => {
+        this.$message.success("创建成功!")
+        this.$router.push({
+          path: "/ledger/property",
+          query: { Family: this.params.Family }
+        })
+      })
+    }
+  }
+};
+</script>
+
+<style scoped lang='less'>
+.box {
+  .condition {
+    padding: 10px;
+    display: flex;
+    height: 100%;
+    flex-direction: column;
+    border: 1px solid #dfe6ec;
+    background: #fff;
+    margin-bottom: 10px;
+    .header{
+      padding-bottom: 10px;
+      border-bottom: 1px solid #bcbcbc;
+    }
+    .main{
+      margin-top: 10px;
+      height: calc(100% - 96px);
+    }
+    .footer{
+      margin-bottom: 10px;
+    }
+  }
+}
+</style>
+
+<style lang="less">
+.el-table th {
+  background-color: #d9d9d9;
+  color: #000;
+}
+</style>
+