index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. <template>
  2. <div id="deviceList">
  3. <router-link to="/ledger/facility/addfacility"></router-link>
  4. <router-view></router-view>
  5. <saga-title :mess="mess"></saga-title>
  6. <div class="table-main">
  7. <div class="search-header">
  8. <floor-cascader @change="changeFloor"></floor-cascader>
  9. <my-cascader ref="cascader" @change="changeDevice" ></my-cascader>
  10. <el-button size="small" @click="handleLinkAssets" class="iconfont icon-batchassociation">批量关联资产</el-button>
  11. </div>
  12. <hanson-table @close="close" :graphyId="graphyId" ref="tableMain"></hanson-table>
  13. </div>
  14. <!-- <table-transfers></table-transfers> -->
  15. <linkassets-dialog :dialog="dialog"></linkassets-dialog>
  16. </div>
  17. </template>
  18. <script>
  19. import sagaTitle from "@/components/ledger/lib/title";
  20. import floorCascader from "@/components/ledger/lib/floorCascader";
  21. import myCascader from "@/components/ledger/lib/cascader";
  22. import hansonTable from "@/components/ledger/handsontables/device";
  23. import tableTransfers from "@/components/ledger/tableTransfers";
  24. import linkassetsDialog from "@/components/ledger/lib/linkassets";
  25. import { countEquip } from "@/api/object/equip";
  26. import { mapGetters } from "vuex";
  27. export default {
  28. components: {
  29. sagaTitle,
  30. floorCascader,
  31. myCascader,
  32. hansonTable,
  33. tableTransfers,
  34. linkassetsDialog
  35. },
  36. data() {
  37. return {
  38. currentBuilding:'',// 当前建筑楼层信息
  39. mess: {
  40. perjectName: "",
  41. name: [
  42. {
  43. key: "设备",
  44. num: 0
  45. },
  46. {
  47. key: "资产",
  48. num: 0
  49. }
  50. ]
  51. },
  52. param: {
  53. buildId: "",
  54. floorId: "",
  55. deviceId: "",
  56. ProjId: "",
  57. secret: ""
  58. },
  59. assetGroupList: [],
  60. graphyId: null,
  61. dialog: {
  62. linkAssets: false
  63. }
  64. };
  65. },
  66. computed: {
  67. ...mapGetters("layout", ["projectId", "projects", "secret", "userId"])
  68. },
  69. created() {
  70. this.param.ProjId = this.projectId
  71. this.param.secret = this.secret
  72. this.getProjName()
  73. this.getCount()
  74. let deviceId = this.$route.params.deviceId;
  75. if (deviceId) {
  76. this.$nextTick(() => {
  77. this.$refs.cascader.setValue(deviceId)
  78. })
  79. }
  80. },
  81. watch: {
  82. projectId() {
  83. this.param.ProjId = this.projectId
  84. this.param.secret = this.secret
  85. this.getProjName()
  86. this.getCount()
  87. }
  88. },
  89. methods: {
  90. getProjName() {
  91. this.projects.forEach((item) => {
  92. if (item.id == this.projectId)
  93. this.mess.perjectName = item.name
  94. })
  95. // this.getEqCode()
  96. },
  97. close(val) {
  98. this.getCount()
  99. if (val && this.$refs.cascader) {
  100. this.$refs.cascader.changeVal(val.code)
  101. }
  102. this.$refs.cascader.getData(this.currentBuilding)
  103. // this.$refs.tableMain.getHeaderData(this.param);
  104. },
  105. // getEqCode() {
  106. // getEquipmentFamily(res => {
  107. // debugger
  108. // this.assetGroupList = res.Content
  109. // this.getGraphyId()
  110. // })
  111. // },
  112. //获取统计数量
  113. getCount() {
  114. let param = {
  115. filters: "not propertyId isnull"
  116. }
  117. countEquip({}, res => {
  118. this.mess.name[0].num = res.count
  119. })
  120. countEquip(param, res => {
  121. this.mess.name[1].num = res.count
  122. })
  123. },
  124. // getGraphyId() {
  125. // let param = {
  126. // ProjId: this.param.ProjId,
  127. // secret: this.param.secret,
  128. // type: "SystemEquip"
  129. // }
  130. // getGraphyId(param).then(res => {
  131. // if (res.data.Result == "success") {
  132. // debugger
  133. // this.graphyId = res.data.graph_id
  134. // if (this.$refs.tableMain)
  135. // this.$refs.tableMain.setGraphyId(this.graphyId, this.assetGroupList);
  136. // } else {
  137. // this.$message.error("请求错误:" + res.data.ResultMsg)
  138. // }
  139. // }).catch(_ => {
  140. // this.$message.error("请求错误")
  141. // })
  142. // },
  143. //修改楼层
  144. changeFloor(value) {
  145. if (value[0]) {
  146. this.param.buildId = value[0]
  147. }
  148. if (value[1]) {
  149. this.param.floorId = value[1]
  150. } else {
  151. this.param.floorId = null
  152. }
  153. if (!!this.param.deviceId) {
  154. if (this.$refs.tableMain)
  155. this.$refs.tableMain.getHeaderData(this.param);
  156. }
  157. this.currentBuilding = value
  158. this.$refs.cascader.getData(value)
  159. },
  160. //修改设备族
  161. changeDevice(value) {
  162. if (value.code && value.facility) {
  163. this.param.deviceId = value.code
  164. this.param.name = value.facility
  165. if (this.$refs.tableMain)
  166. this.$refs.tableMain.getHeaderData(this.param);
  167. }
  168. },
  169. // 批量关联资产
  170. handleLinkAssets() {
  171. this.dialog.linkAssets = true
  172. }
  173. }
  174. };
  175. </script>
  176. <style lang="less" scoped>
  177. #deviceList {
  178. overflow: hidden;
  179. height: 100%;
  180. background-color: #fff;
  181. position: relative;
  182. .table-main {
  183. position: absolute;
  184. top: 87px;
  185. bottom: 0;
  186. left: 0;
  187. right: 0;
  188. background-color: #fff;
  189. // border-radius: 5px;
  190. // padding: 10px 0;
  191. }
  192. .search-header {
  193. overflow: hidden;
  194. padding-bottom: 10px;
  195. margin: 0 10px;
  196. border-bottom: 1px solid #bcbcbc;
  197. .icon-batchassociation {
  198. float: right;
  199. font-size: 12px;
  200. /deep/ span {
  201. margin-left: 5px;
  202. }
  203. }
  204. }
  205. }
  206. </style>