syInSpaceTable.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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">
  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.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 prop="action" label="操作" min-width="100">
  20. <template slot-scope="scope">
  21. <el-tooltip class="item" effect="dark" content="删除关系" placement="left">
  22. <el-button size="mini" @click="handleDelete(scope.$index, scope.row)" type="danger" plain icon="el-icon-delete"></el-button>
  23. </el-tooltip>
  24. </template>
  25. </el-table-column>
  26. <template slot="empty">
  27. <div style="height: 60%;transform: translateY(50%);lineHeight:20px;">
  28. <i class="icon-wushuju iconfont"></i>
  29. 可前往“全部关系总览”中,按坐标计算{{typeToTips[type]}}
  30. </div>
  31. </template>
  32. </el-table>
  33. </div>
  34. <addSystemDialog ref="addSyDialog" :type="type" :spaceId="params.RoomID" :zone="params.zone" @refresh='getTableData'></addSystemDialog>
  35. </div>
  36. </template>
  37. <script>
  38. import {
  39. zoneQuery,
  40. syInSpaceDelete
  41. } from "@/api/scan/request";
  42. import { mapGetters } from "vuex";
  43. import addSystemDialog from "@/components/business_space/newAddDialogs/addSystemDialog";
  44. export default {
  45. components: {
  46. addSystemDialog
  47. },
  48. computed: {
  49. ...mapGetters("layout", ["projectId"])
  50. },
  51. data() {
  52. return {
  53. inSpaceType: '系统',
  54. headerStyle: {
  55. backgroundColor: '#e1e4e5',
  56. color: '#2b2b2b',
  57. lineHeight: '30px'
  58. }, // 列表样式
  59. loading: false, // loading
  60. tableData: [], //列表数据
  61. typeToTips: {
  62. generalSystem: '空间内的系统',
  63. },
  64. hidden: true,
  65. loading: false
  66. };
  67. },
  68. props: {
  69. params: {},
  70. type: {}
  71. },
  72. created() {
  73. this.getTableData();
  74. this.changeContentStyle();
  75. },
  76. methods: {
  77. // 删除关系
  78. handleDelete(index, row) {
  79. this.$confirm("确认删除该关系?", "提示", {
  80. confirmButtonText: '确定',
  81. cancelButtonText: '取消',
  82. type: 'warning'
  83. }).then(() => {
  84. let pa = {
  85. data: [{
  86. sysId: row.id,
  87. spaceId: row.spaceId
  88. }],
  89. type: this.params.zone
  90. }
  91. this.deleteSyInSpace(pa)
  92. }).catch(() => {
  93. this.$message("取消删除")
  94. })
  95. },
  96. // 删除关系
  97. deleteSyInSpace(pa) {
  98. syInSpaceDelete(pa, res => {
  99. this.$message.success('删除成功');
  100. this.getTableData();
  101. })
  102. },
  103. // 获取列表数据
  104. getTableData() {
  105. this.loading = true;
  106. let pa = {
  107. Cascade: [{ Name: "generalSystem" }],
  108. Filters: `id="${this.params.RoomID}"`,
  109. ZoneType: this.params.zone
  110. }
  111. zoneQuery(pa, res => {
  112. this.loading = false;
  113. this.tableData = res.content[0].generalSystem || [];
  114. this.tableData.map(t => {
  115. t.spaceId = res.content[0].id;
  116. return t;
  117. })
  118. })
  119. },
  120. // 添加系统
  121. add() {
  122. this.$refs.addSyDialog.showDialog()
  123. },
  124. changeContentStyle() {
  125. // 在辅助屏不显示添加按钮,动态设置高度
  126. this.$route.name == "spaceLedger" ? this.hidden = false : this.hidden = true;
  127. }
  128. },
  129. watch: {
  130. type() {
  131. this.getTableData()
  132. },
  133. params() {
  134. this.getTableData()
  135. }
  136. }
  137. };
  138. </script>
  139. <style lang="less" scoped>
  140. #eqInSp {
  141. height: 100%;
  142. .table-box {
  143. margin-top: 10px;
  144. height: calc(100% - 50px);
  145. }
  146. }
  147. </style>