123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265 |
- <template>
- <el-dialog title="批量关联资产" :visible.sync="dialog.linkAssets" width="700px">
- <el-row>
- <span class="condition-title">设备类型:</span>
- <el-select v-model="deviceType" filterable size="small" @change="handleChangeDevice" style="width:250px;">
- <el-option v-for="item in deviceTypeList" :key="item.code" :label="item.facility" :value="item.code"></el-option>
- </el-select>
- </el-row>
- <el-row style="margin-top:30px;">
- <span class="condition-title">建筑楼层:</span>
- <el-cascader :options="bfoptions" v-model="buildFloor" filterable size="small" @change="handleChangeBf" style="width:250px;"></el-cascader>
- </el-row>
- <el-row style="margin-top:30px;" v-if="spaceShow">
- <span class="condition-title">分区类型空间实例:</span>
- <el-cascader v-model="space" filterable clearable collapse-tags size="small" :options="spaceList" :props="props" @change="handleChangeSpace" @active-item-change='handleChangeSpaceItem' style="width:250px;"></el-cascader>
- </el-row>
- <span slot="footer" class="dialog-footer">
- <el-button @click="handleClickClose">取 消</el-button>
- <el-button type="primary" @click="toLinkAssets">确 认</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import { floorQuery, buildingQuery, queryDictionaryHead, queryZone } from '@/api/scan/request'
- import { mapGetters } from "vuex"
- export default {
- props: {
- dialog: {
- type: Object,
- default: function () {
- return {
- linkAssets: false
- };
- }
- }
- },
- computed: {
- ...mapGetters("layout", ["projectId", "secret", "userId"])
- },
- data() {
- return {
- bfoptions: [], //建筑楼层列表
- buildFloor: ['all'], //选择的建筑楼层
- deviceTypeList: [], //未关联资产的设备或部件列表
- deviceType: '', //选择的设备类型
- spaceList: [], //空间实例列表
- space: [], //选择的空间实例
- spaceShow: false,
- props: {
- multiple: true,
- children: 'children'
- }, //多选级联配置
- };
- },
- created() {
- this.getBuildFloorData() //获取建筑楼层数据
- this.getSpaceData() //获取分区类型数据
- },
- mounted() { },
- methods: {
- //获取建筑楼层数据
- getBuildFloorData() {
- let data, buildParams = {
- PageNumber: 1,
- PageSize: 1000,
- Projection: [
- "BuildID",
- "BuildLocalName"
- ]
- }, floorParams = {
- Orders: "FloorSequenceID desc",
- PageNumber: 1,
- PageSize: 1000,
- Projection: [
- "BuildID",
- "FloorID",
- "FloorLocalName",
- "FloorSequenceID"
- ]
- }
- let promise1 = new Promise((resolve, reject) => {
- buildingQuery(buildParams, res => {
- resolve(res)
- })
- })
- let promise2 = new Promise((resolve, reject) => {
- floorQuery(floorParams, res => {
- resolve(res)
- })
- })
- Promise.all([promise1, promise2]).then(values => {
- let builData = values[0].Content, floorData = values[1].Content
- data = builData.map(build => {
- return {
- value: build.BuildID,
- label: build.BuildLocalName
- }
- })
- data.unshift({
- value: "all",
- label: "全部"
- }, {
- value: "noKnow",
- label: "不在建筑内"
- })
- data.forEach(build => {
- floorData.forEach(floor => {
- if (build.value == floor.BuildID && floor.FloorID && floor.FloorLocalName) {
- if (build.children) {
- build.children.push({
- value: floor.FloorID,
- label: floor.FloorLocalName,
- FloorSequenceID: floor.FloorSequenceID
- })
- } else {
- build.children = []
- build.children.push({
- value: "all",
- label: "全部"
- }, {
- value: 'noKnow',
- label: "不在楼层内"
- }, {
- value: floor.FloorID,
- label: floor.FloorLocalName,
- FloorSequenceID: floor.FloorSequenceID
- })
- }
- }
- })
- })
- this.bfoptions = data
- })
- },
- //获取空间分区数据
- getSpaceData(){
- let params = {
- Filters: "parentId = 'Space'",
- PageNumber: 1,
- PageSize: 1000,
- Projection: [ "Code", "Name" ]
- }
- queryDictionaryHead(params, res => {
- this.spaceList = res.Content.map((item) => {
- return {
- label: item.Name,
- value: item.Code,
- children: []
- }
- })
- })
- },
- // 修改设备类型
- handleChangeDevice() {
- },
- // 修改建筑楼层
- handleChangeBf(val) {
- let lastVal = val.slice(-1)[0]
- // 重置空间实例选择
- this.space = []
- this.spaceList.map(item => {
- if (item.children)
- item.children = []
- })
- if(!lastVal || lastVal == 'noKnow' || val[0] == 'all') {
- this.spaceShow = false
- } else {
- this.spaceShow = false
- this.$nextTick(() => {
- this.spaceShow = true
- })
- }
- },
- // 获取空间实例
- handleChangeSpaceItem(val) {
- let type = val[0]
- if(val.length == 1) {
- if(type) {
- let zone = type,
- nodes = []
- let recursionGetData = (pageNum, zone) => {
- pageNum = pageNum ? pageNum : 1
- let params = {
- zone: zone,
- data: {
- Orders: "CreateTime desc, RoomID asc",
- PageNumber: pageNum,
- PageSize: 1000,
- Projection: ["RoomID", "RoomName", "RoomLocalName", "CreateTime"]
- },
- }
- if(this.spaceShow) {
- if(this.buildFloor.length == 2 && this.buildFloor[1] != 'all') {
- params.data.Filters = `buildingId='${this.buildFloor[0]}';floorId='${this.buildFloor[1]}'`
- } else {
- params.data.Filters = `buildingId='${this.buildFloor[0]}'`
- }
- }
- queryZone(params, res => {
- nodes = nodes.concat(res.Content.map(item => ({
- value: item.RoomID,
- label: item.RoomLocalName?item.RoomLocalName:item.RoomName
- })))
- if (res.Total / (res.PageSize * res.PageNumber) > 1) {
- recursionGetData(res.PageNumber + 1, zone)
- } else {
- this.spaceList.map(item => {
- if(item.value == type) {
- item.children = nodes
- }
- })
- }
- })
- }
- recursionGetData(1, zone)
- }
- }
- },
- // 点击取消关闭弹窗
- handleClickClose() {
- this.dialog.linkAssets = false
- },
- // 批量关联资产详情页
- toLinkAssets() {
- let query = {}
- // 校验必填项
- if(!this.deviceType) {
- this.$messge.info('请选择设备类型!')
- } else if (!this.buildFloor.length) {
- this.$messge.info('请选择建筑楼层!')
- }
- if(this.spaceShow) {
- } else {
- query = {
- deviceType: this.deviceType
- }
- }
- }
- },
- watch: {
-
- }
- };
- </script>
- <style lang="less" scoped>
- .condition-title{
- width: 200px;
- display: inline-block;
- text-align: right;
- margin-left: 10px;
- margin-right: 12px;
- color: #999999;
- font-size: 14px;
- }
- /deep/ .el-dialog__body {
- max-height: 420px;
- overflow-y: auto;
- }
- </style>
|