propertySet.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. <template>
  2. <div class="hui-flex-box hui-flex hui-table">
  3. <div class="hui-content-insert">
  4. <el-button type="primary" size="medium" @click="insertDepartment({})">新建资产</el-button>
  5. </div>
  6. <div class="hui-flex-box">
  7. <el-table :data="treeData" row-key="id" border height="100%">
  8. <el-table-column label="资产名称" prop="name"></el-table-column>
  9. <el-table-column label="操作" width="240">
  10. <template slot-scope="scope">
  11. <div class="hui-table-operation">
  12. <span class="table-operation" @click="insertDepartment(scope.row)">
  13. 添加子资产
  14. </span>
  15. <span class="table-operation" v-if="scope.row.children.length === 0"
  16. @click="model(scope.row)">
  17. 3D模型
  18. </span>
  19. <span class="table-operation" v-if="!scope.row.isp" @click="updateDepartment(scope.row)">
  20. 编辑
  21. </span>
  22. <span class="table-operation" v-if="!scope.row.isp" @click="deleteDepartment(scope.row)">
  23. 删除
  24. </span>
  25. </div>
  26. </template>
  27. </el-table-column>
  28. <template slot="empty">
  29. <empty description="暂无数据"></empty>
  30. </template>
  31. </el-table>
  32. </div>
  33. <el-dialog :close-on-click-modal="false" :title="isUpdate?'编辑':'新增'" :visible.sync="visible" width="900px"
  34. :append-to-body="true">
  35. <depart-form v-if="visible" @callback="callback" :isUpdate="isUpdate" :part="part">
  36. </depart-form>
  37. </el-dialog>
  38. <el-dialog :close-on-click-modal="false" title="模型列表" :visible.sync="modelVisible" width="1100px"
  39. :append-to-body="true">
  40. <model-down v-if="modelVisible" :modelLevelId="nowLevel.modelLevelId" :levelId="nowLevel.id"></model-down>
  41. </el-dialog>
  42. </div>
  43. </template>
  44. <script>
  45. import {
  46. initDevicePartList,
  47. getDevicePartList,
  48. deleteDeviceDepartment
  49. } from '@/httpApi/property'
  50. import departForm from '@/components/work/property/departForm'
  51. import modelDown from '@/components/work/common/modelDown'
  52. export default {
  53. data() {
  54. return {
  55. treeData: [],
  56. visible: false,
  57. isUpdate: false,
  58. part: {},
  59. drawer: false,
  60. modelVisible: false,
  61. nowLevel: {}
  62. }
  63. },
  64. created() {
  65. this.init();
  66. },
  67. methods: {
  68. init() {
  69. getDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id).then(res => {
  70. if (res.state) {
  71. if (res.data.length === 0) {
  72. initDevicePartList(this.$store.getters.organization.id, this.$store.getters.project.id)
  73. .then(res => {
  74. if (res.state) {
  75. getDevicePartList(this.$store.getters.organization.id, this.$store
  76. .getters.project.id).then(res => {
  77. if (res.state) {
  78. this.treeData = res.data;
  79. }
  80. })
  81. }
  82. })
  83. } else {
  84. this.treeData = res.data;
  85. }
  86. }
  87. })
  88. },
  89. model(item) {
  90. this.nowLevel = item;
  91. this.modelVisible = true;
  92. },
  93. currentChange(currPage) {
  94. this.currPage = currPage;
  95. this.init();
  96. },
  97. insertDepartment(val) {
  98. this.part = val;
  99. this.visible = true;
  100. this.isUpdate = false;
  101. },
  102. lookFlow(val) {
  103. this.detailId = val.id;
  104. this.drawer = true;
  105. },
  106. updateDepartment(val) {
  107. this.part = val;
  108. this.isUpdate = true;
  109. this.visible = true;
  110. },
  111. deleteDepartment(val) {
  112. this.$confirm('确定要删除该资产层级?', () => {
  113. deleteDeviceDepartment(val.id).then(res => {
  114. if (res.state) {
  115. this.$message.success('操作成功');
  116. this.init();
  117. }
  118. })
  119. });
  120. },
  121. callback(type) {
  122. this.visible = false;
  123. if (type === 'init') this.init();
  124. }
  125. },
  126. components: {
  127. departForm,
  128. modelDown
  129. },
  130. }
  131. </script>
  132. <style lang="scss">
  133. </style>