index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  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. </div>
  11. <hanson-table @close="close" :graphyId="graphyId" ref="tableMain"></hanson-table>
  12. </div>
  13. <!-- <table-transfers></table-transfers> -->
  14. </div>
  15. </template>
  16. <script>
  17. import sagaTitle from "@/components/ledger/lib/title";
  18. import floorCascader from "@/components/ledger/lib/floorCascader";
  19. import myCascader from "@/components/ledger/lib/cascader";
  20. import hansonTable from "@/components/ledger/handsontables/device";
  21. import tableTransfers from "@/components/ledger/tableTransfers";
  22. import { getNumber, getFamilyList, getSpaceName, getGraphyId, getEquipmentFamily } from "@/api/scan/request"
  23. import {
  24. mapGetters,
  25. mapActions
  26. } from "vuex";
  27. export default {
  28. components: {
  29. sagaTitle,
  30. floorCascader,
  31. myCascader,
  32. hansonTable,
  33. tableTransfers
  34. },
  35. data() {
  36. return {
  37. mess: {
  38. perjectName: "",
  39. name: [
  40. {
  41. key: "设备",
  42. num: 0
  43. },
  44. {
  45. key: "资产",
  46. num: 0
  47. }
  48. ]
  49. },
  50. param: {
  51. buildId: "",
  52. floorId: "",
  53. deviceId: "",
  54. ProjId: "",
  55. secret: ""
  56. },
  57. assetGroupList: [],
  58. graphyId: null
  59. };
  60. },
  61. computed: {
  62. ...mapGetters("layout", [
  63. "projectId",
  64. "secret",
  65. "userId"
  66. ])
  67. },
  68. created() {
  69. this.param.ProjId = this.projectId
  70. this.param.secret = this.secret
  71. this.getProjName()
  72. let deviceId = this.$route.query.deviceId;
  73. if (deviceId) {
  74. this.$nextTick(() => {
  75. this.$refs.cascader.changeVal([deviceId])
  76. })
  77. }
  78. },
  79. watch: {
  80. projectId() {
  81. this.param.ProjId = this.projectId
  82. this.param.secret = this.secret
  83. this.getProjName()
  84. }
  85. },
  86. methods: {
  87. getProjName() {
  88. let param = {
  89. list: [{ id: this.param.ProjId }],
  90. perjectId: this.param.ProjId,
  91. secret: this.param.secret,
  92. }
  93. getSpaceName(param).then(res => {
  94. if (res.data.Result == "success") {
  95. this.mess.perjectName = res.data.Content[0].infos.ProjLocalName
  96. this.getEqCode()
  97. } else {
  98. this.$message.error("请求失败:" + res.data.ResultMsg)
  99. }
  100. }).catch(_ => {
  101. this.$message.error("请求失败")
  102. })
  103. },
  104. close(val) {
  105. this.getEqCode()
  106. if (val && this.$refs.cascader)
  107. this.$refs.cascader.changeVal([val.code])
  108. // this.$refs.tableMain.getHeaderData(this.param);
  109. },
  110. getEqCode() {
  111. getEquipmentFamily(res => {
  112. this.assetGroupList = res.Content
  113. this.getGraphyId()
  114. })
  115. },
  116. getFamilyList() {
  117. let param = {
  118. ProjId: this.param.ProjId,
  119. secret: this.param.secret,
  120. data: { type: "Eq" }
  121. }
  122. getFamilyList(param, res => {
  123. if (this.$refs.cascader) {
  124. this.$refs.cascader.pushData(res.Content)
  125. }
  126. })
  127. },
  128. //获取header的list
  129. getNumber() {
  130. let param = {
  131. ProjId: this.param.ProjId,
  132. secret: this.param.secret,
  133. data: { type: "Eq" }
  134. }
  135. getNumber(param, res => {
  136. this.mess.name[0].num = res.content.count
  137. this.mess.name[1].num = res.content.bindingCount
  138. this.getFamilyList()
  139. })
  140. },
  141. getGraphyId() {
  142. let param = {
  143. ProjId: this.param.ProjId,
  144. secret: this.param.secret,
  145. type: "SystemEquip"
  146. }
  147. getGraphyId(param).then(res => {
  148. if (res.data.Result == "success") {
  149. this.graphyId = res.data.graph_id
  150. if (this.$refs.tableMain)
  151. this.$refs.tableMain.setGraphyId(this.graphyId, this.assetGroupList);
  152. this.getNumber()
  153. } else {
  154. this.$message.error("请求错误:" + res.data.ResultMsg)
  155. }
  156. }).catch(_ => {
  157. this.$message.error("请求错误")
  158. })
  159. },
  160. //修改楼层
  161. changeFloor(value) {
  162. if (value[0]) {
  163. this.param.buildId = value[0]
  164. }
  165. if (value[1]) {
  166. this.param.floorId = value[1]
  167. } else {
  168. this.param.floorId = null
  169. }
  170. if (!!this.param.deviceId) {
  171. if (this.$refs.tableMain)
  172. this.$refs.tableMain.getHeaderData(this.param);
  173. } else {
  174. return;
  175. }
  176. },
  177. //修改设备族
  178. changeDevice(value) {
  179. this.param.deviceId = value.code
  180. this.param.name = value.facility
  181. if (!!value) {
  182. if (this.$refs.tableMain)
  183. this.$refs.tableMain.getHeaderData(this.param);
  184. } else {
  185. return;
  186. }
  187. }
  188. }
  189. };
  190. </script>
  191. <style lang="less" scoped>
  192. #deviceList {
  193. overflow: hidden;
  194. height: 100%;
  195. background-color: #fff;
  196. position: relative;
  197. .table-main {
  198. position: absolute;
  199. top: 87px;
  200. bottom: 0;
  201. left: 0;
  202. right: 0;
  203. background-color: #fff;
  204. // border-radius: 5px;
  205. // padding: 10px 0;
  206. }
  207. .search-header {
  208. overflow: hidden;
  209. padding: 0 10px 10px 10px;
  210. border-bottom: 1px solid #bcbcbc;
  211. }
  212. }
  213. </style>