eqToSpaceTable.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div id="eqInSp">
  3. <el-row>
  4. <el-button type="primary" @click="add">添加{{inSpaceType}}</el-button>
  5. <el-tooltip class="item" effect="dark" :content="`可前往“全部关系总览”中,按坐标计算${typeToTips[type]}`" placement="right">
  6. <el-button>按空间计算</el-button>
  7. </el-tooltip>
  8. </el-row>
  9. <div class="table-box">
  10. <el-table :data="tableData" style="width: 100%" height="100%" v-loading="loading" :header-cell-style="headerStyle">
  11. <el-table-column :label="`${inSpaceType}名称`" show-overflow-tooltip min-width="100">
  12. <template slot-scope="scope">
  13. <div>
  14. {{scope.row.EquipLocalName||scope.row.EquipName||''}}
  15. </div>
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="EquipLocalID" :label="`${inSpaceType}本地编码`" show-overflow-tooltip min-width="100"></el-table-column>
  19. <el-table-column :label="`${inSpaceType}类`" show-overflow-tooltip min-width="100">
  20. <template slot-scope="scope">
  21. <div>
  22. {{scope.row.EquipCategory.EquipName}}
  23. </div>
  24. </template>
  25. </el-table-column>
  26. <el-table-column prop="action" label="操作" min-width="100">
  27. <template slot-scope="scope">
  28. <el-tooltip class="item" effect="dark" content="删除关系" placement="left">
  29. <el-button size="mini" @click="handleDelete(scope.$index, scope.row)" type="danger" plain icon="el-icon-delete"></el-button>
  30. </el-tooltip>
  31. </template>
  32. </el-table-column>
  33. <template slot="empty">
  34. <div style="height: 60%;transform: translateY(50%);">
  35. <i class="icon-wushuju iconfont"></i>
  36. 可前往“全部关系总览”中,按坐标计算{{typeToTips[type]}}
  37. </div>
  38. </template>
  39. </el-table>
  40. </div>
  41. <!-- 添加设备弹窗 -->
  42. <addEquipDialog ref="addEqDialog" :type="type" :spaceId="params.RoomID" :zone="params.zone" @refresh='getTableData'></addEquipDialog>
  43. </div>
  44. </template>
  45. <script>
  46. import {
  47. queryZone,
  48. eqInSpaceDelete, //设备所在业务空间--删除关系
  49. eqForSpaceDelete, //设备服务业务空间--删除关系
  50. } from "@/api/scan/request";
  51. import { mapGetters } from "vuex";
  52. import addEquipDialog from "@/components/business_space/newAddDialogs/addEquipDialog"
  53. export default {
  54. components: {
  55. addEquipDialog
  56. },
  57. computed: {
  58. ...mapGetters("layout", ["projectId"])
  59. },
  60. data() {
  61. return {
  62. inSpaceType: '设备',
  63. headerStyle: {
  64. backgroundColor: '#e1e4e5',
  65. color: '#2b2b2b',
  66. lineHeight: '30px'
  67. }, // 列表样式
  68. loading: false, // loading
  69. tableData: [], //列表数据
  70. typeToTips: {
  71. Equipment: '空间内的设备',
  72. EquipmentFor: '服务于空间的设备',
  73. }
  74. };
  75. },
  76. props: {
  77. params: {},
  78. type: {}
  79. },
  80. created() {
  81. this.getTableData()
  82. },
  83. methods: {
  84. // 删除关系
  85. handleDelete(index, row) {
  86. this.$confirm("确认删除该关系?", "提示", {
  87. confirmButtonText: '确定',
  88. cancelButtonText: '取消',
  89. type: 'warning'
  90. }).then(() => {
  91. let pa = {
  92. data: [row],
  93. type: this.params.zone
  94. }
  95. if (this.type == 'Equipment') {
  96. this.deleteEqInSpace(pa);
  97. } else {
  98. this.deleteEqForSpace(pa);
  99. }
  100. }).catch(() => {
  101. this.$message("取消删除")
  102. })
  103. },
  104. // 删除设备所在空间关系
  105. deleteEqInSpace(pa) {
  106. eqInSpaceDelete(pa, res => {
  107. this.$message.success('删除成功')
  108. this.getTableData()
  109. })
  110. },
  111. // 删除设备服务空间关系
  112. deleteEqForSpace(pa) {
  113. eqForSpaceDelete(pa, res => {
  114. this.$message.success('删除成功')
  115. this.getTableData()
  116. })
  117. },
  118. // 改变pagesize
  119. handleSizeChange(pageSize) {
  120. this.page.pageSize = pageSize;
  121. this.getTableData();
  122. },
  123. // 改变pageno
  124. handleCurrentChange(pageNo) {
  125. this.page.pageNumber = pageNo;
  126. this.getTableData();
  127. },
  128. // 获取列表数据
  129. getTableData() {
  130. let pa = {
  131. data: {
  132. Filters: `RoomID='${this.params.RoomID}'`,
  133. Cascade: [
  134. {
  135. Name: this.type.replace(this.type[0], this.type[0].toLowerCase()),
  136. Cascade: [{ Name: 'equipCategory' }]
  137. }
  138. ]
  139. },
  140. zone: this.params.zone
  141. }
  142. queryZone(pa, res => {
  143. this.tableData = res.Content[0][this.type] || []
  144. this.tableData.map(t => {
  145. t.SpaceId = res.Content[0].RoomID
  146. return t;
  147. })
  148. })
  149. },
  150. // 添加设备
  151. add() {
  152. this.$refs.addEqDialog.floor = this.params.buildFloorSelectd;
  153. this.$refs.addEqDialog.showDialog()
  154. }
  155. },
  156. watch: {
  157. type() {
  158. this.getTableData()
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="less" scoped>
  164. #eqInSp {
  165. height: 100%;
  166. .table-box {
  167. margin-top: 10px;
  168. height: calc(100% - 50px);
  169. }
  170. }
  171. </style>