eqToSpaceTable.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. <template>
  2. <div id="eqInSp">
  3. <el-row v-show="hidden">
  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" :style="heightData">
  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%);lineHeight:20px;">
  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. hidden: true,
  75. heightData: "height:calc(100% - 50px)"
  76. };
  77. },
  78. props: {
  79. params: {},
  80. type: {}
  81. },
  82. created() {
  83. this.getTableData()
  84. this.changeContentStyle();
  85. },
  86. methods: {
  87. // 删除关系
  88. handleDelete(index, row) {
  89. this.$confirm("确认删除该关系?", "提示", {
  90. confirmButtonText: '确定',
  91. cancelButtonText: '取消',
  92. type: 'warning'
  93. }).then(() => {
  94. let pa = {
  95. data: [row],
  96. type: this.params.zone
  97. }
  98. if (this.type == 'Equipment') {
  99. this.deleteEqInSpace(pa);
  100. } else {
  101. this.deleteEqForSpace(pa);
  102. }
  103. }).catch(() => {
  104. this.$message("取消删除")
  105. })
  106. },
  107. // 删除设备所在空间关系
  108. deleteEqInSpace(pa) {
  109. eqInSpaceDelete(pa, res => {
  110. this.$message.success('删除成功')
  111. this.getTableData()
  112. })
  113. },
  114. // 删除设备服务空间关系
  115. deleteEqForSpace(pa) {
  116. eqForSpaceDelete(pa, res => {
  117. this.$message.success('删除成功')
  118. this.getTableData()
  119. })
  120. },
  121. // 改变pagesize
  122. handleSizeChange(pageSize) {
  123. this.page.pageSize = pageSize;
  124. this.getTableData();
  125. },
  126. // 改变pageno
  127. handleCurrentChange(pageNo) {
  128. this.page.pageNumber = pageNo;
  129. this.getTableData();
  130. },
  131. // 获取列表数据
  132. getTableData() {
  133. let pa = {
  134. data: {
  135. Filters: `RoomID='${this.params.RoomID}'`,
  136. Cascade: [
  137. {
  138. Name: this.type.replace(this.type[0], this.type[0].toLowerCase()),
  139. Cascade: [{ Name: 'equipCategory' }]
  140. }
  141. ]
  142. },
  143. zone: this.params.zone
  144. }
  145. queryZone(pa, res => {
  146. this.tableData = res.Content[0][this.type] || []
  147. this.tableData.map(t => {
  148. t.SpaceId = res.Content[0].RoomID
  149. return t;
  150. })
  151. })
  152. },
  153. // 添加设备
  154. add() {
  155. this.$refs.addEqDialog.floor = [this.params.BuildingId, this.params.FloorId];
  156. this.$refs.addEqDialog.showDialog()
  157. },
  158. changeContentStyle(){
  159. // 在辅助屏不显示添加按钮,动态设置高度
  160. this.$route.name == "spaceLedger"?this.hidden = true:this.hidden = false;
  161. this.heightData = "height:750px";
  162. }
  163. },
  164. watch: {
  165. type() {
  166. this.getTableData()
  167. }
  168. }
  169. };
  170. </script>
  171. <style lang="less" scoped>
  172. #eqInSp {
  173. height: 100%;
  174. .table-box {
  175. margin-top: 10px;
  176. }
  177. }
  178. </style>