index_old.vue 19 KB

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