index.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <div class="tableDisplay">
  3. <div class="header">
  4. <el-button style="float:left;" size="small" type="default" icon="el-icon-back" @click="goBack"></el-button>
  5. <span :title="`${name} - ${code}`" class="details-title"><b>{{ name }} - {{ code }}</b></span>
  6. </div>
  7. <div class="content">
  8. <el-scrollbar style="height:100%;">
  9. <div class="content-scrollbar">
  10. <div class="content-left">
  11. <div class="content-keyPoint">
  12. <exhibitionCrux :exhibitionCrux="exhibitionCrux" :type="type" @cruxSuccess="cruxSuccess"/>
  13. </div>
  14. <div class="content-showType">
  15. <selectRadio
  16. :selectRadio="selectRadio"
  17. @changeRadio="changeRadio"
  18. />
  19. </div>
  20. <div class="content-point">
  21. <div class="content-point-left">
  22. <exhibitionBaseInformation :exhibitionBaseInformation="exhibitionBaseInformation"/>
  23. </div>
  24. <div class="content-point-right">
  25. <exhibitionEnergy :exhibitionEnergy="exhibitionEnergy"/>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="content-right">
  30. <div class="content-repair">
  31. <exhibitionMaintain :exhibitionMaintain="exhibitionMaintain"/>
  32. </div>
  33. <div class="content-media">
  34. <exhibitionImage :exhibitionImage="exhibitionImage" v-show="isShowImage"/>
  35. <exhibitionVideo :exhibitionVideo="exhibitionVideo" v-show="isShowVideo"/>
  36. <exhibitionFile :exhibitionFile="exhibitionFile" v-show="isShowFile"/>
  37. </div>
  38. </div>
  39. </div>
  40. </el-scrollbar>
  41. </div>
  42. <div class="footer">
  43. <el-button-group style="float:right;margin:8px 10px 0 0">
  44. <el-button
  45. :disabled="list.findIndex(item => item.value == id) == 0"
  46. @click="handleClickPrev"
  47. size="mini"
  48. icon="el-icon-arrow-left">
  49. 上一页
  50. </el-button>
  51. <el-select size="mini" style="float:left;margin:0 10px;" v-model="id" @change="handleChangeExample"
  52. placeholder="请选择">
  53. <el-option
  54. v-for="item in list"
  55. :key="item.value"
  56. :label="item.label"
  57. :value="item.value">
  58. </el-option>
  59. </el-select>
  60. <el-button
  61. :disabled="list.findIndex(item => item.value == id) == list.length-1"
  62. @click="handleClickNext"
  63. size="mini">
  64. 下一页
  65. <i class="el-icon-arrow-right el-icon--right"></i>
  66. </el-button>
  67. </el-button-group>
  68. </div>
  69. </div>
  70. </template>
  71. <script>
  72. import exhibitionBaseInformation from "@/components/ledger/details/detail/exhibitionBaseInformation";
  73. import exhibitionFile from "@/components/ledger/details/detail/exhibitionFile";
  74. import exhibitionImage from "@/components/ledger/details/detail/exhibitionImage";
  75. import exhibitionVideo from "@/components/ledger/details/detail/exhibitionVideo";
  76. import exhibitionCrux from "@/components/ledger/details/detail/exhibitionCrux";
  77. import exhibitionEnergy from "@/components/ledger/details/detail/exhibitionEnergy";
  78. import exhibitionMaintain from "@/components/ledger/details/detail/exhibitionMaintain";
  79. import selectRadio from "@/components/ledger/details/detail/selectRadio";
  80. import tools from "@/utils/scan/tools"
  81. import { BeatchQueryParam } from "@/api/scan/request";
  82. import { getDataDictionary } from "@/api/dict";
  83. import { queryEquip } from "@/api/object/equip"
  84. import { mapGetters } from "vuex";
  85. export default {
  86. name: "deviceDetails",
  87. components: {
  88. exhibitionBaseInformation,
  89. exhibitionFile,
  90. exhibitionVideo,
  91. exhibitionImage,
  92. exhibitionMaintain,
  93. selectRadio,
  94. exhibitionCrux,
  95. exhibitionEnergy
  96. },
  97. created() {
  98. this.id = this.$route.query.equipId;
  99. this.name = this.$route.query.equipName;
  100. this.code = this.$route.query.equipCode;
  101. this.type = this.$route.query.type;
  102. this.list = this.$route.query.data;
  103. this.getData();
  104. },
  105. computed: {
  106. ...mapGetters("layout", ["projectId", "secret", "userId"])
  107. },
  108. data() {
  109. return {
  110. id: '', //当前设备id
  111. name: '', //当前设备本地名称
  112. code: '', //当前设备的本地编码
  113. type: '', //设备类型
  114. list: [], //设备列表
  115. pointData: [], //信息点数据
  116. exampleData: {}, //实例数据
  117. currentRadio: '1',//当前选中的select
  118. criterias: [], //动态参数
  119. criteriasArray: [],
  120. selectRadio: {
  121. information: '设备信息点',
  122. initRadio: '1',
  123. radioList: [
  124. {
  125. value: '显示需采集信息点',
  126. label: '1'
  127. },
  128. {
  129. value: '显示有值信息点',
  130. label: '2'
  131. },
  132. {
  133. value: '显示全部信息点',
  134. label: '3'
  135. }
  136. ]
  137. },
  138. exhibitionBaseInformation: {
  139. information: {}
  140. },
  141. exhibitionEnergy: {
  142. title: '能耗信息',
  143. firstName: '',
  144. dynamic: [],
  145. list: {}
  146. },
  147. exhibitionMaintain: {
  148. title: '维修/维保记录'
  149. },
  150. exhibitionFile: {
  151. title: '文件',
  152. list: {}
  153. },
  154. exhibitionCrux: {
  155. title: '关键信息点:',
  156. cruxArray: [],
  157. allMessage: [],//全部信息点
  158. },
  159. exhibitionImage: {
  160. title: '图片',
  161. list: {},
  162. arr: []
  163. },
  164. exhibitionVideo: {
  165. title: '视频',
  166. list: []
  167. },
  168. instance: {},//实例信息处理
  169. isShowImage: false,
  170. isShowVideo: false,
  171. isShowFile: false,
  172. }
  173. },
  174. methods: {
  175. deepCopy(obj) {
  176. return JSON.parse(JSON.stringify(obj))
  177. },
  178. cruxSuccess() {
  179. this.getData()
  180. },
  181. // 获取表头和实例数据(动态数据在组件中获取,在此格式化请求参数)
  182. getData() {
  183. let params1 = {
  184. orders: "sort asc",
  185. pageNumber: 1,
  186. pageSize: 1000,
  187. type: this.type
  188. }, params2 = {
  189. filters: `id='${this.id}'`,
  190. };
  191. let promise1 = new Promise((resolve, reject) => {
  192. getDataDictionary(params1, res => {
  193. resolve(res)
  194. })
  195. })
  196. let promise2 = new Promise((resolve, reject) => {
  197. queryEquip(params2, res => {
  198. resolve(res)
  199. })
  200. })
  201. // 数据初始化
  202. this.exhibitionEnergy.dynamic = [];
  203. this.criterias = [];
  204. Promise.all([promise1, promise2]).then(values => {
  205. this.pointData = values[0].content;
  206. this.exampleData = values[1].content[0];
  207. this.name = this.exampleData.localName ? this.exampleData.localName : this.exampleData.name ? this.exampleData.name : '';
  208. this.code = this.exampleData.localId ? this.exampleData.localId : '';
  209. let obj = this.deepCopy(values[1].content[0]);
  210. obj = tools.flattenKeys(obj);
  211. for (let key in obj) { //删除对象中数组为空的项
  212. if (Array.isArray(obj[key]) && !obj[key].length) {
  213. delete obj[key]
  214. }
  215. }
  216. this.instance = obj;
  217. this.pointData.forEach(item => {
  218. if (item.inputMode == "L" || item.inputMode == "L1" || item.inputMode == "L2" || item.inputMode == "M") {
  219. let cur = tools.dataForKey(this.exampleData, item.path);
  220. if (cur) {
  221. this.criterias.push({
  222. objectId: this.exampleData.id,
  223. infoCode: item.code
  224. })
  225. }
  226. }
  227. })
  228. let params = { //获取动态参数
  229. groupCode: "WD",
  230. appId: "datacenter",
  231. projectId: this.projectId,
  232. data: []
  233. }
  234. params.data = this.criterias
  235. if (this.criterias.length) {
  236. BeatchQueryParam(params, res => {
  237. this.criteriasArray = res.data;
  238. res.data.length && res.data.map(child => {
  239. this.pointData.map(head => {
  240. if (head.code == child.infoCode) {
  241. // this.$set(head, 'svalue', child.value)
  242. this.$set(head, 'svalue', child.infoValue)
  243. this.$set(head, 'data', child.data)
  244. // this.$set(head, 'receivetime', child.receivetime)
  245. this.$set(head, 'receivetime', child.time)
  246. this.$set(head, 'error', child.error)
  247. }
  248. return head
  249. })
  250. })
  251. this.handleRadios(this.currentRadio);
  252. this.handleEnclosure() //处理图片视频文件信息
  253. })
  254. } else {
  255. this.handleRadios(this.currentRadio);
  256. this.handleEnclosure() //处理图片视频文件信息
  257. }
  258. })
  259. },
  260. handleEnclosure() {
  261. //图片文件处理,脱离radio控制
  262. let isList = this.pointData
  263. let isArr = []
  264. isList.map(j => {
  265. if (this.instance.hasOwnProperty(j.path)) {
  266. j.value = this.instance[j.path]
  267. return j
  268. }
  269. })
  270. isArr = isList.filter(k => k.value)
  271. this.handlePicList(isArr)
  272. this.handleFileList(isArr)
  273. },
  274. handleRadios(val) { //判断radio的值显示关键信息,基本信息,图片,文件
  275. let arr = []
  276. //关键信息点
  277. this.exhibitionCrux.cruxArray = this.pointData.filter(i => i.keyWord)
  278. this.exhibitionCrux.cruxArray.map(i => {
  279. if (this.instance.hasOwnProperty(i.path)) {
  280. return {
  281. ...i,
  282. value: this.instance[i.path]
  283. }
  284. }
  285. })
  286. if (val == 1) { //需采集信息
  287. arr = this.pointData.filter(i => i.visible)
  288. // // 图片和的处理
  289. // this.handlePicList(arr)
  290. // // 文件处理
  291. // this.handleFileList(arr)
  292. } else if (val == 2) { //有值信息点
  293. let list = this.pointData
  294. list.map(j => {
  295. if (this.instance.hasOwnProperty(j.path)) {
  296. return {
  297. ...j,
  298. value: this.instance[j.path]
  299. }
  300. }
  301. })
  302. arr = list.filter(k => k.value)
  303. // this.handlePicList(arr, 2)
  304. // this.handleFileList(arr, 2)
  305. } else { //全部信息点
  306. arr = this.pointData
  307. // this.handlePicList(arr)
  308. // this.handleFileList(arr)
  309. }
  310. this.displayData(arr)
  311. },
  312. handlePicList(arr) {
  313. let picObject = {}
  314. //处理数据格式
  315. arr.map(i => {
  316. if (i.inputMode == 'F2') {
  317. switch (i.path) {
  318. case 'infos.drawing':
  319. case 'infos.installPic':
  320. case 'infos.installDrawing':
  321. case 'infos.nameplate':
  322. case 'infos.pic':
  323. case 'pic' :
  324. if (this.instance.hasOwnProperty(i.path)) {
  325. i.PicList = this.instance[i.path]
  326. }
  327. if (picObject[i.name]) {
  328. } else {
  329. picObject[i.name] = []
  330. }
  331. picObject[i.name].push({
  332. ...i,
  333. })
  334. break;
  335. }
  336. }
  337. })
  338. //展示图片
  339. this.exhibitionImage.list = picObject
  340. let isArray = [] //获取图片数组
  341. for (let i in picObject) {
  342. if (Array.isArray(picObject[i])) {
  343. let list = picObject[i]
  344. list.forEach(i => {
  345. if (i.PicList) {
  346. isArray.push(...i.PicList)
  347. }
  348. })
  349. }
  350. }
  351. this.exhibitionImage.arr = isArray
  352. let video = isArray.filter(i => i.Type != 'image' && i.type != 'image')
  353. this.exhibitionVideo.list = video
  354. //判断是否显示图片组件
  355. this.isShowImage = isArray.length ? true : false
  356. //判断是否显示video组件
  357. this.isShowVideo = video.length ? true : false
  358. },
  359. handleFileList(arr) {
  360. let picObject = {}
  361. //处理数据格式
  362. arr.map(i => {
  363. if (i.inputMode == 'F2') {
  364. switch (i.path) {
  365. case 'infos.insuranceFile':
  366. case 'infos.archive':
  367. case 'infos.checkReport':
  368. if (this.instance.hasOwnProperty(i.path)) {
  369. i.fileList = this.instance[i.path]
  370. }
  371. if (picObject[i.name]) {
  372. } else {
  373. picObject[i.name] = []
  374. }
  375. picObject[i.name].push({
  376. ...i,
  377. })
  378. break
  379. }
  380. }
  381. })
  382. //展示文件
  383. this.exhibitionFile.list = picObject
  384. let isArray = [] //获取文件数组
  385. for (let i in picObject) {
  386. if (Array.isArray(picObject[i])) {
  387. let list = picObject[i]
  388. list.forEach(i => {
  389. if (i.fileList) {
  390. isArray.push(...i.fileList)
  391. }
  392. })
  393. }
  394. }
  395. //判断是否显示文件组件
  396. this.isShowFile = isArray.length ? true : false
  397. },
  398. changeRadio(val) { //1,需采集,2,有值,3,全部
  399. this.handleRadios(val)
  400. this.currentRadio = val
  401. },
  402. formatDate(str) {
  403. if (str) {
  404. if (str.includes('-')) {
  405. return str
  406. } else {
  407. return str.substr(0, 4) + "-" + str.substr(4, 2) + "-" + str.substr(6, 2) + " " + str.substr(8, 2) + ":" + str.substr(10, 2) + ":" + str.substr(12, 2)
  408. }
  409. } else {
  410. return '--'
  411. }
  412. },
  413. displayData(arr) {//对数据进行处理传给组件展示
  414. const result = {}
  415. const resultEnergy = {};
  416. arr.map(i => {
  417. if (this.instance.hasOwnProperty(i.path) && this.currentRadio != 2) {
  418. i.value = this.instance[i.path]
  419. }
  420. if (i.inputMode == 'C5') {
  421. if (this.instance.hasOwnProperty(i.path)) {
  422. let time = this.instance[i.path]
  423. i.value = this.formatDate(time)
  424. }
  425. }
  426. if (i.dataSource && i.dataSource.length) {
  427. // let source = JSON.parse(i.dataSource)
  428. let source = i.dataSource
  429. //判断输入类型
  430. if (i.inputMode == 'D1L') {
  431. let d1l = tools.formatDataSource(i.dataSource)
  432. d1l.forEach(k => {
  433. if (k.code == this.instance[i.path]) {
  434. i.value = k.name
  435. }
  436. })
  437. } else if (i.inputMode == 'D2' || i.inputMode == 'C6') {
  438. if (this.instance.hasOwnProperty(i.path)) {
  439. if (!Array.isArray(this.instance[i.path])) {
  440. let transArray = this.instance[i.path].split(',')
  441. i.value = source.filter(item => transArray.includes(item.code)).map(item => item.name).join(',')
  442. }
  443. }
  444. }
  445. source.forEach(j => {
  446. if (j.code == this.instance[i.path]) {
  447. i.value = j.name
  448. }
  449. })
  450. }
  451. // 动态信息点处理
  452. switch (i.inputMode) {
  453. case "L":
  454. case "L1":
  455. case "L2":
  456. case "M":
  457. if (resultEnergy[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`]) {
  458. resultEnergy[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`].paths.push({
  459. Path: i.path,
  460. InfoPointName: i.name,
  461. InfoPointCode: i.code,
  462. value: i.svalue,
  463. Visible: i.visible,
  464. KeyWord: i.keyWord,
  465. InputMode: i.inputMode,
  466. data: i.data,
  467. receivetime: i.receivetime,
  468. error: i.error,
  469. Unit: i.unit,
  470. FirstName: i.firstName,
  471. })
  472. } else {
  473. resultEnergy[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`] = {
  474. paths: [{
  475. Path: i.path,
  476. InfoPointName: i.name,
  477. InfoPointCode: i.code,
  478. value: i.svalue,
  479. Visible: i.visible,
  480. KeyWord: i.keyWord,
  481. InputMode: i.inputMode,
  482. data: i.data,
  483. receivetime: i.receivetime,
  484. error: i.error,
  485. Unit: i.unit,
  486. FirstName: i.firstName,
  487. }]
  488. }
  489. }
  490. break;
  491. default:
  492. if (result[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`]) {
  493. result[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`].paths.push({
  494. Path: i.path,
  495. InfoPointName: i.name,
  496. InfoPointCode: i.code,
  497. Value: i.value,
  498. Visible: i.visible,
  499. KeyWord: i.keyWord,
  500. InputMode: i.inputMode,
  501. classCode: i.classCode,
  502. id: i.id,
  503. groupCode: i.groupCode,
  504. type: i.type
  505. })
  506. } else {
  507. result[`${i.firstName}${i.secondName ? '/' + i.secondName : ''}`] = {
  508. paths: [{
  509. Path: i.path,
  510. InfoPointName: i.name,
  511. InfoPointCode: i.code,
  512. Value: i.value,
  513. Visible: i.visible,
  514. KeyWord: i.keyWord,
  515. InputMode: i.inputMode,
  516. classCode: i.classCode,
  517. id: i.id,
  518. groupCode: i.groupCode,
  519. type: i.type
  520. }]
  521. }
  522. }
  523. }
  524. })
  525. this.exhibitionBaseInformation.information = result
  526. this.exhibitionCrux.allMessage = result
  527. this.exhibitionEnergy.list = resultEnergy;
  528. },
  529. goBack() {
  530. this.$router.push({
  531. name: "facilityLedger",
  532. params: {
  533. deviceId: this.type
  534. }
  535. })
  536. },
  537. // 切换实例
  538. handleChangeExample() {
  539. this.selectRadio.initRadio = '1';
  540. this.currentRadio = '1';
  541. this.getData();
  542. },
  543. // 切换上一个实例
  544. handleClickPrev() {
  545. let index = this.list.findIndex(item => item.value == this.id);
  546. this.id = this.list[index - 1].value;
  547. this.handleChangeExample();
  548. },
  549. // 切换下一个实例
  550. handleClickNext() {
  551. let index = this.list.findIndex(item => item.value == this.id);
  552. this.id = this.list[index + 1].value;
  553. this.handleChangeExample();
  554. },
  555. },
  556. watch: {
  557. projectId() {
  558. this.$router.push({ path: "/ledger/facility" })
  559. }
  560. }
  561. }
  562. </script>
  563. <style scoped lang="less">
  564. @bgc: #fff;
  565. .tableDisplay {
  566. .header {
  567. padding-bottom: 10px;
  568. overflow: hidden;
  569. text-overflow: ellipsis;
  570. white-space: nowrap;
  571. .details-title {
  572. color: #333;
  573. font-size: 16px;
  574. margin-left: 20px;
  575. line-height: 32px;
  576. cursor: pointer;
  577. }
  578. }
  579. .content {
  580. height: calc(100% - 77px);
  581. .content-scrollbar {
  582. display: flex;
  583. height: 100%;
  584. flex-direction: row;
  585. box-sizing: border-box;
  586. background-color: #f2f2f2;
  587. .content-left {
  588. display: flex;
  589. flex-direction: column;
  590. flex: 1;
  591. box-sizing: border-box;
  592. .content-keyPoint {
  593. border: 1px solid #ccc;
  594. box-sizing: border-box;
  595. margin-bottom: 10px;
  596. // overflow: hidden;
  597. background: @bgc;
  598. }
  599. .content-showType {
  600. height: 50px;
  601. border: 1px solid #ccc;
  602. border-bottom: none;
  603. box-sizing: border-box;
  604. background: @bgc;
  605. }
  606. .content-point {
  607. display: flex;
  608. flex-direction: row;
  609. border: 1px solid #ccc;
  610. box-sizing: border-box;
  611. background: @bgc;
  612. .content-point-left {
  613. flex: 1;
  614. }
  615. .content-point-right {
  616. width: 300px;
  617. border-left: 1px solid #ccc;
  618. }
  619. }
  620. }
  621. .content-right {
  622. width: 400px;
  623. margin-left: 10px;
  624. box-sizing: border-box;
  625. .content-repair {
  626. height: 50px;
  627. line-height: 50px;
  628. margin-bottom: 10px;
  629. border: 1px solid #ccc;
  630. background: @bgc;
  631. box-sizing: border-box;
  632. }
  633. .content-media {
  634. box-sizing: border-box;
  635. }
  636. }
  637. }
  638. }
  639. .footer {
  640. position: fixed;
  641. bottom: 0;
  642. left: 235px;
  643. width: calc(100% - 235px);
  644. height: 45px;
  645. background-color: #fff;
  646. box-sizing: border-box;
  647. }
  648. }
  649. /deep/ .el-scrollbar__wrap {
  650. overflow-x: hidden;
  651. }
  652. </style>