eqToSpaceTable.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <div id="eqInSp">
  3. <el-row v-if="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 v-show="type=='Equipment'">按空间计算</el-button>
  7. </el-tooltip>
  8. </el-row>
  9. <div class="table-box">
  10. <el-table :data="tableData" style="width: 100%" height="100%" :header-cell-style="headerStyle" v-loading="loading">
  11. <el-table-column :label="`${inSpaceType}名称`" show-overflow-tooltip min-width="100">
  12. <template slot-scope="scope">
  13. <div>
  14. {{scope.row.localName||scope.row.name||''}}
  15. </div>
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="localId" :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?scope.row.equipCategory.name:''}}
  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. {{type=='Equipment'?`可前往“全部关系总览”中,按坐标计算${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. zoneQuery,
  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. };
  76. },
  77. props: {
  78. params: {},
  79. type: {}
  80. },
  81. created() {
  82. this.getTableData()
  83. this.changeContentStyle();
  84. },
  85. methods: {
  86. // 删除关系
  87. handleDelete(index, row) {
  88. this.$confirm("确认删除该关系?", "提示", {
  89. confirmButtonText: '确定',
  90. cancelButtonText: '取消',
  91. type: 'warning'
  92. }).then(() => {
  93. let pa = {
  94. data: [{
  95. equipId: row.id,
  96. spaceId: row.spaceId
  97. }],
  98. type: this.params.zone
  99. }
  100. if (this.type == 'equipment') {
  101. this.deleteEqInSpace(pa);
  102. } else {
  103. this.deleteEqForSpace(pa);
  104. }
  105. }).catch(() => {
  106. this.$message("取消删除")
  107. })
  108. },
  109. // 删除设备所在空间关系
  110. deleteEqInSpace(pa) {
  111. eqInSpaceDelete(pa, res => {
  112. this.$message.success('删除成功')
  113. this.getTableData()
  114. })
  115. },
  116. // 删除设备服务空间关系
  117. deleteEqForSpace(pa) {
  118. eqForSpaceDelete(pa, res => {
  119. this.$message.success('删除成功')
  120. this.getTableData()
  121. })
  122. },
  123. // 改变pagesize
  124. handleSizeChange(pageSize) {
  125. this.page.pageSize = pageSize;
  126. this.getTableData();
  127. },
  128. // 改变pageno
  129. handleCurrentChange(pageNo) {
  130. this.page.pageNumber = pageNo;
  131. this.getTableData();
  132. },
  133. // 获取列表数据
  134. getTableData() {
  135. this.loading = true;
  136. let pa = {
  137. filters: `id='${this.params.RoomID}'`,
  138. cascade: [
  139. {
  140. name: this.type.replace(this.type[0], this.type[0].toLowerCase()),
  141. cascade: [{ name: 'equipCategory' }]
  142. }
  143. ],
  144. zoneType: this.params.zone
  145. }
  146. zoneQuery(pa, res => {
  147. this.loading = false;
  148. this.tableData = res.content[0][this.type] || []
  149. this.tableData.map(t => {
  150. t.spaceId = res.content[0].id
  151. return t;
  152. })
  153. })
  154. },
  155. // 添加设备
  156. add() {
  157. this.$refs.addEqDialog.floor = this.params.buildFloorSelectd;
  158. this.$refs.addEqDialog.showDialog()
  159. },
  160. changeContentStyle() {
  161. this.$route.name == "spaceLedger" ? this.hidden = false : this.hidden = true;
  162. }
  163. },
  164. watch: {
  165. type() {
  166. this.getTableData()
  167. },
  168. params() {
  169. this.getTableData()
  170. }
  171. }
  172. };
  173. </script>
  174. <style lang="less" scoped>
  175. #eqInSp {
  176. height: 100%;
  177. .table-box {
  178. margin-top: 10px;
  179. height: calc(100% - 50px);
  180. }
  181. }
  182. </style>