123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211 |
- <template>
- <el-dialog title="提示" :visible.sync="dialogVisible" :width="dialogWidth" @close="handleClose" id="delRelation">
- <span>确定要清除对应关系?</span>
- <div v-loading="loading">
- <div v-show="ltableData.length>1">
- <div style="margin:10px 0;">有多个设备标识对应了该设备实例,是否一并清除对应关系?</div>
- <el-row class="bgf5">
- <el-col :span="18">
- <el-table :data="ltableData" style="width: 100%;max-height:400px;" height="calc(100% - 160px)" @selection-change="changeSelection"
- ref="ltable">
- <el-table-column label="设备标识" align="right" class-name="bgfff">
- <el-table-column label="数据源" prop="Datasource" align="right" class-name="bgfff" show-overflow-tooltip></el-table-column>
- <el-table-column label="位置标签" prop="LocationFlag" align="right" class-name="bgfff" show-overflow-tooltip>
- <template slot-scope="scope">{{ scope.row.LocationFlag.toString() }}</template>
- </el-table-column>
- <el-table-column label="设备标识" prop="EquipmentMark" align="right" class-name="bgf5" show-overflow-tooltip></el-table-column>
- <el-table-column type="selection" class-name="bgf5"></el-table-column>
- </el-table-column>
- </el-table>
- </el-col>
- <el-col :span="6">
- <div class="singleDir pl-10 font-default">设备实例</div>
- <div class="pl-10 font-default">{{rtableData[0]?rtableData[0].EquipLocalName:'--'}}</div>
- <div class="pl-10 font-default">{{rtableData[0]?rtableData[0].BuildLocalName:'--'}}-{{rtableData[0]?rtableData[0].FloorLocalName:'--'}}</div>
- <div class="pl-10 font-default">{{rtableData[0]?rtableData[0].RoomLocalName:'--'}}</div>
- </el-col>
- </el-row>
- </div>
- <div v-show="rtableData.length>1">
- <div style="margin:10px 0;">有多个设备实例对应了该设备标识,是否一并清除对应关系?</div>
- <el-row class="bgf5">
- <el-col :span="6">
- <div class="singleDir pr-10 font-default tr">设备标识</div>
- <div class="pr-10 font-default tr">{{ltableData[0]?ltableData[0].EquipmentMark:'--'}}</div>
- <div class="pr-10 font-default tr">{{ltableData[0]?ltableData[0].LocationFlag.toString():'--'}}</div>
- <div class="pr-10 font-default tr">{{ltableData[0]?ltableData[0].Datasource:'--'}}</div>
- </el-col>
- <el-col :span="18">
- <el-table :data="rtableData" style="width: 100%;max-height:400px;" height="calc(100% - 160px)" @selection-change="changeSelection"
- ref="rtable">
- <el-table-column label="设备实例" class-name="bgfff">
- <el-table-column type="selection" class-name="bgf5"></el-table-column>
- <el-table-column label="设备实例名称" prop="EquipLocalName" class-name="bgf5" show-overflow-tooltip></el-table-column>
- <el-table-column label="设备实例编码" prop="ObjectID" class-name="bgfff" show-overflow-tooltip></el-table-column>
- <el-table-column label="所在建筑楼层" class-name="bgfff">
- <template slot-scope="scope">
- <el-tooltip :content="scope.row.BuildLocalName+'-'+scope.row.FloorLocalName" placement="top">
- <div class="tool-tip">{{scope.row.BuildLocalName}}-{{scope.row.FloorLocalName}}</div>
- </el-tooltip>
- </template>
- </el-table-column>
- <el-table-column label="所在业务空间" prop="RoomLocalName" class-name="bgfff" show-overflow-tooltip></el-table-column>
- </el-table-column>
- </el-table>
- </el-col>
- </el-row>
- </div>
- </div>
- <span slot="footer" class="dialog-footer">
- <el-button size="small" @click="handleClose">取消</el-button>
- <el-button size="small" type="primary" v-loading="loading" @click="handleDelete" :disabled="deleDisabled">清除已选</el-button>
- </span>
- </el-dialog>
- </template>
- <script>
- import { dynamicDeleteRelation, dynamicQueryPrompt } from "@/api/scan/request";
- export default {
- data() {
- return {
- dialogVisible: false, //弹窗显示与隐藏
- ltableData: [], // 左侧数据
- rtableData: [], // 右侧数据
- loading: false, //loading状态
- dialogWidth: "20%", //弹窗宽度
- selection: [],
- deleDisabled: false,
- deleParam: []
- };
- },
- methods: {
- //弹窗显示
- showDialog(row) {
- this.dialogVisible = true;
- this.loading = true;
- //需先用对象请求接口返回所需对象
- this.getDynamicQueryPrompt(row)
- },
- handleClose(done) {
- this.dialogVisible = false;
- },
- //确认清除对应关系
- handleDelete() {
- dynamicDeleteRelation(this.deleParam, res => {
- this.$emit("refresh");
- this.dialogVisible = false;
- this.$message.success('清除成功');
- });
- },
- //表格中选择事件 1-n or n-1 公用
- changeSelection(selection) {
- this.deleParam = []
- let tempObj = {}
- this.deleDisabled = selection.length <= 0
- if (this.ltableData.length > this.rtableData.length) {
- tempObj.Objs = [selection[0]]
- tempObj.Points = selection
- } else if (this.ltableData.length < this.rtableData.length) {
- tempObj.Objs = selection
- tempObj.Points = [selection[0]]
- } else {
- tempObj.Objs = selection
- tempObj.Points = selection
- }
- this.deleParam.push(tempObj)
- },
- //查询两边数据,同时拼删除param
- getDynamicQueryPrompt(row) {
- let p1 = {
- Filters: `TypeCode='${row.TypeCode}';SubTypeCode='${row.SubTypeCode}';EquipmentMark='${row.EquipmentMark}'`,
- PageNumber: 1,
- PageSize: 500
- }
- //通过标识查询设备实例
- let promise1 = new Promise((resolve, reject) => {
- dynamicQueryPrompt(p1, res => {
- resolve(res)
- })
- })
- let p2 = {
- Filters: `ObjectID='${row.ObjectID}'`,
- PageNumber: 1,
- PageSize: 500
- }
- let promise2 = new Promise((resolve, reject) => {
- dynamicQueryPrompt(p2, res => {
- resolve(res)
- })
- })
- Promise.all([promise1, promise2]).then(res => {
- this.deleParam = [];
- this.ltableData = res[1].Content;
- this.rtableData = res[0].Content;
- if (this.ltableData.length > 1 || this.rtableData.length > 1) {
- this.dialogWidth = "60%";
- } else {
- this.dialogWidth = "20%";
- }
- this.$nextTick(() => {
- this.toggleSelection(row);
- })
- this.loading = false;
- })
- },
- //设置默认选中
- toggleSelection(row) {
- if (this.ltableData.length > this.rtableData.length) {
- this.ltableData.map((t, i) => {
- if (t.ObjectID == row.ObjectID) {
- this.$refs.ltable.toggleRowSelection(this.ltableData[i], true)
- return;
- }
- })
- } else {
- this.rtableData.map((t, i) => {
- if (t.ObjectID == row.ObjectID) {
- this.$refs.rtable.toggleRowSelection(this.rtableData[i], true)
- return;
- }
- })
- }
- }
- },
- mounted() { },
- created() { }
- };
- </script>
- <style lang="scss" scoped>
- #delRelation {
- /deep/ .bgf5 {
- background-color: #f5f7fa;
- }
- /deep/ .bgfff {
- background-color: #fff;
- }
- div.singleDir {
- font-weight: 800;
- color: #606266;
- border-bottom: 1px solid #ebeef5;
- background: #fff;
- border-top: 1px solid #ebeef5;
- }
- .pl-10 {
- padding-left: 10px;
- }
- .pr-10 {
- padding-right: 10px;
- }
- .font-default {
- line-height: 42px;
- font-size: 12px;
- }
- .tr {
- text-align: right;
- }
- .tool-tip{
- white-space: nowrap;
- overflow: hidden;
- text-overflow: ellipsis;
- }
- }
- </style>
|