Noverify.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. <template>
  2. <div class='page-table-template' style='display: flex;flex-direction: column;flex-grow: 1;flex-shrink: 1;'>
  3. <div class="btn-box">
  4. <el-button type='danger' @click='someDel'>批量删除</el-button>
  5. </div>
  6. <el-table
  7. :data='tableData'
  8. style='width: 100%'
  9. border
  10. class='data-table'
  11. v-loading='loading'
  12. @selection-change='handleSelectionChange'
  13. >
  14. <el-table-column type='selection' width='55' align='center'></el-table-column>
  15. <el-table-column header-align='center' align='center' prop='BuildName' label='建筑' width='150'></el-table-column>、
  16. <el-table-column header-align='center' align='center' prop='floorName' label='楼层' width='80'></el-table-column>
  17. <el-table-column header-align='center' align='center' prop='FamilyName' label='设备族'></el-table-column>
  18. <el-table-column header-align='center' align='center' label='本地编码' width='250'>
  19. <template slot-scope='scope'>
  20. <span>{{scope.row.Infos.EquipLocalID || scope.row.Infos.EquipID || '--'}}</span>
  21. </template>
  22. </el-table-column>
  23. <el-table-column header-align='center' align='center' prop='FmName' label='本地名称'></el-table-column>
  24. <el-table-column header-align='center' align='center' prop='spaceName' label='所在元空间'></el-table-column>
  25. <el-table-column header-align='center' align='center' prop='eq' label='对应设备类'></el-table-column>
  26. <el-table-column header-align='center' align='center' prop='bimXY' label='BIM模型中坐标'></el-table-column>
  27. <el-table-column header-align='center' align='center' prop='PointName' label='对应的岗位' width='120'>
  28. <template slot-scope='scope'>
  29. <el-button v-if="scope.row.EquipmentId" type='primary' plain size='mini' @click='post(scope.row)'>查看岗位详情</el-button>
  30. </template>
  31. </el-table-column>
  32. <el-table-column header-align='center' align='center' prop='PointName' label='操作' width='150'>
  33. <template slot-scope='scope'>
  34. <el-button type='primary' plain size='mini' @click='look(scope.row)'>查看</el-button>
  35. <el-button type='danger' plain size='mini' @click='del(scope.row)'>删除</el-button>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <base-pagination
  40. class='data-table-pagination'
  41. :currentPages='pageNum'
  42. :total='total'
  43. @pageChanged='pageChanged'
  44. ></base-pagination>
  45. <saga-dialog ref='dialog' :iframeSrc='iframeSrc'></saga-dialog>
  46. </div>
  47. </template>
  48. <script>
  49. import { mapGetters } from 'vuex'
  50. import SagaDialog from './Frame'
  51. //api
  52. import {
  53. getErrAssets, //获取异常资产type不同不同tab
  54. delErrAssets,
  55. getSpaceId,
  56. getSpaceName
  57. } from '@/api/scan/request'
  58. export default {
  59. name: 'noverify',
  60. data() {
  61. return {
  62. loading: false,
  63. tableData: [],
  64. total: 0,
  65. pageNum: 1,
  66. pageSize: 10,
  67. iframeSrc: '',
  68. allChecked: [],
  69. //dict
  70. EquipmentObj: {}
  71. }
  72. },
  73. props: {
  74. buildVlaue: {
  75. default: ''
  76. },
  77. floorsObj: {
  78. default: {}
  79. },
  80. allFamilyObj: {},
  81. allEquipObj: {
  82. default: {}
  83. }
  84. },
  85. components: {
  86. SagaDialog
  87. },
  88. computed: {
  89. ...mapGetters('peojMess', ['projectId', 'userId', 'secret'])
  90. },
  91. methods: {
  92. look(row) {
  93. this.iframeSrc =
  94. process.env.BASE_URL +
  95. ':8889/#/details?perjectId=' +
  96. this.projectId +
  97. '&secret=' +
  98. this.secret +
  99. '&FmId=' +
  100. row.FmId +
  101. '&type=1&code=' +
  102. row.Family
  103. this.$refs['dialog'].show()
  104. },
  105. post(row) {
  106. this.iframeSrc =
  107. process.env.BASE_URL +
  108. ':8889/#/details?perjectId=' +
  109. this.projectId +
  110. '&secret=' +
  111. this.secret +
  112. '&FmId=' +
  113. row.FmId +
  114. '&type=1&code=' +
  115. row.eqCode
  116. this.$refs['dialog'].show()
  117. },
  118. handleSelectionChange(arr) {
  119. this.allChecked = arr.map(ele => ele.FmId)
  120. },
  121. someDel() {
  122. if (this.allChecked.length) {
  123. this.delOp(this.allChecked)
  124. } else {
  125. this.$message({
  126. message: '请至少选择一条',
  127. type: 'warning'
  128. })
  129. }
  130. },
  131. del(row) {
  132. let paramList = [row.FmId]
  133. this.delOp(paramList)
  134. },
  135. delOp(paramList) {
  136. this.$confirm('此操作将永久删除, 是否继续?', '提示', {
  137. confirmButtonText: '确定',
  138. cancelButtonText: '取消',
  139. type: 'warning'
  140. })
  141. .then(() => {
  142. let param = {
  143. ProjId: this.projectId,
  144. UserId: this.userId
  145. }
  146. delErrAssets(param, paramList).then(result => {
  147. if (result.data.Result == 'success') {
  148. this.getAsset()
  149. this.$message({
  150. message: '删除成功',
  151. type: 'success'
  152. })
  153. }
  154. })
  155. })
  156. .catch(() => {
  157. this.$message({
  158. type: 'info',
  159. message: '已取消删除'
  160. })
  161. })
  162. },
  163. pageChanged(page, size) {
  164. this.pageNum = page
  165. this.pageSize = size
  166. this.getAsset()
  167. },
  168. getAsset() {
  169. this.loading = true
  170. let param = {
  171. BuildId: this.buildVlaue || undefined,
  172. PageNum: this.pageNum,
  173. PageSize: this.pageSize,
  174. Type: 4,
  175. ProjId: this.projectId,
  176. UserId: this.userId,
  177. CodeType: 1
  178. }
  179. getErrAssets(param).then( async res => {
  180. // this.tableData = list
  181. if (res.data.Result == 'success') {
  182. let list = res.data.FmList
  183. list.forEach((ele, index) => {
  184. ele.floorName = this.floorsObj[ele.FloorId] || '--'
  185. let x = ''
  186. let y = ''
  187. if (ele.X == 0) {
  188. x = '空'
  189. } else {
  190. x = ele.X || ''
  191. }
  192. if (ele.Y == 0) {
  193. y = '空'
  194. } else {
  195. y = ele.Y || ''
  196. }
  197. ele.bimXY = x + (x || y ? ',' : '-') + y
  198. })
  199. this.total = res.data.Count
  200. this.tableData = list
  201. await this.getEq(list)
  202. await this.getSp(list)
  203. this.loading = false
  204. }
  205. })
  206. },
  207. async getEq(list) {
  208. let param = {},
  209. idArr = [],
  210. i = 0,
  211. dataArr = list
  212. for (; i < dataArr.length; i++) {
  213. if (dataArr[i].EquipmentId) {
  214. idArr.push({
  215. id: dataArr[i].EquipmentId
  216. })
  217. }
  218. }
  219. param = {
  220. perjectId: this.projectId,
  221. secret: this.secret,
  222. list: idArr
  223. }
  224. let ret = await this.batchQuery(param)
  225. ret.forEach(ele => {
  226. this.EquipmentObj[ele.id] = ele.category.slice(2)
  227. })
  228. list.forEach(ele => {
  229. if (ele.EquipmentId) {
  230. ele.eq = this.allEquipObj[this.EquipmentObj[ele.EquipmentId]]
  231. ele.eqCode = this.EquipmentObj[ele.EquipmentId]
  232. } else {
  233. ele.eq = null
  234. }
  235. })
  236. },
  237. async getSp(list) {
  238. let param = {},
  239. idArr = [],
  240. i = 0,
  241. dataArr = list
  242. for (; i < dataArr.length; i++) {
  243. if (dataArr[i].EquipmentId) {
  244. idArr.push({
  245. from_id: dataArr[i].EquipmentId,
  246. graph_id: 'GtEquipinSpace001',
  247. rel_type: '1'
  248. })
  249. }
  250. }
  251. param = {
  252. perjectId: this.projectId,
  253. secret: this.secret,
  254. list: idArr
  255. }
  256. let ret = await this.getSpId(param)
  257. let arr = []
  258. let eqObj = {}
  259. ret.forEach(ele => {
  260. if (ele.Content.length > 0) {
  261. arr.push({ id: ele.Content[0].to_id })
  262. eqObj[ele.Content[0].from_id] = ele.Content[0].to_id
  263. }
  264. })
  265. list.forEach(list1 => {
  266. if (eqObj[list1.EquipmentId]) {
  267. list1.toSpace = eqObj[list1.EquipmentId]
  268. } else {
  269. list1.toSpace = null
  270. }
  271. })
  272. let params = {
  273. perjectId: this.projectId,
  274. secret: this.secret,
  275. list: arr
  276. }
  277. let retu = await this.batchQuery(params)
  278. let spObj = {}
  279. retu.forEach(retu1 => {
  280. spObj[retu1.id] = retu1.infos
  281. })
  282. list.forEach(list2 => {
  283. if (spObj[list2.toSpace]) {
  284. list2.spaceName = spObj[list2.toSpace].RoomLocalName
  285. } else {
  286. list2.spaceName = null
  287. }
  288. })
  289. },
  290. async batchQuery(param) {
  291. let res = await getSpaceName(param)
  292. let ret = res.data.Content
  293. if (res.data.Count > 0) {
  294. return ret
  295. }
  296. return []
  297. },
  298. async getSpId(param) {
  299. let res = await getSpaceId(param)
  300. let ret = res.data.Content
  301. if (res.data.Count > 0) {
  302. return ret
  303. }
  304. return []
  305. }
  306. },
  307. watch: {
  308. buildVlaue() {
  309. this.getAsset()
  310. }
  311. }
  312. }
  313. </script>
  314. <style scoped lang='less'>
  315. .btn-box {
  316. padding: 10px;
  317. }
  318. </style>