eqToSpaceTable.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.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?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. {{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: [row],
  95. type: this.params.zone
  96. }
  97. if (this.type == 'Equipment') {
  98. this.deleteEqInSpace(pa);
  99. } else {
  100. this.deleteEqForSpace(pa);
  101. }
  102. }).catch(() => {
  103. this.$message("取消删除")
  104. })
  105. },
  106. // 删除设备所在空间关系
  107. deleteEqInSpace(pa) {
  108. eqInSpaceDelete(pa, res => {
  109. this.$message.success('删除成功')
  110. this.getTableData()
  111. })
  112. },
  113. // 删除设备服务空间关系
  114. deleteEqForSpace(pa) {
  115. eqForSpaceDelete(pa, res => {
  116. this.$message.success('删除成功')
  117. this.getTableData()
  118. })
  119. },
  120. // 改变pagesize
  121. handleSizeChange(pageSize) {
  122. this.page.pageSize = pageSize;
  123. this.getTableData();
  124. },
  125. // 改变pageno
  126. handleCurrentChange(pageNo) {
  127. this.page.pageNumber = pageNo;
  128. this.getTableData();
  129. },
  130. // 获取列表数据
  131. getTableData() {
  132. this.loading = true;
  133. let pa = {
  134. Filters: `RoomID='${this.params.RoomID}'`,
  135. Cascade: [
  136. {
  137. Name: this.type.replace(this.type[0], this.type[0].toLowerCase()),
  138. Cascade: [{ Name: 'equipCategory' }]
  139. }
  140. ],
  141. ZoneType: this.params.zone
  142. }
  143. zoneQuery(pa, res => {
  144. this.loading = false;
  145. this.tableData = res.Content[0][this.type] || []
  146. this.tableData.map(t => {
  147. t.SpaceId = res.Content[0].RoomID
  148. return t;
  149. })
  150. })
  151. },
  152. // 添加设备
  153. add() {
  154. this.$refs.addEqDialog.floor = this.params.buildFloorSelectd;
  155. this.$refs.addEqDialog.showDialog()
  156. },
  157. changeContentStyle() {
  158. this.$route.name == "spaceLedger" ? this.hidden = false : this.hidden = true;
  159. }
  160. },
  161. watch: {
  162. type() {
  163. this.getTableData()
  164. },
  165. params() {
  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. height: calc(100% - 50px);
  177. }
  178. }
  179. </style>