index.vue 19 KB

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