index.vue 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  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. let video = []
  293. //处理数据格式
  294. arr.map(i => {
  295. if (i.InputMode == 'F2' || i.InputMode == 'F1') {
  296. switch (i.Path) {
  297. case 'LedgerParam.Siteinstall.InstallPic':
  298. case 'LedgerParam.PhotoDoc.Nameplate':
  299. case 'LedgerParam.PhotoDoc.Pic':
  300. if (this.instance.hasOwnProperty(i.Path)) {
  301. i.PicList = this.instance[i.Path].filter(i => i.Type === 'image' || i.Type === 'panorama')
  302. video = video.concat(this.instance[i.Path].filter(i => i.Type === 'video'))
  303. }
  304. if (picObject[i.InfoPointName]) {
  305. } else {
  306. picObject[i.InfoPointName] = []
  307. }
  308. picObject[i.InfoPointName].push({
  309. ...i,
  310. })
  311. break;
  312. }
  313. }
  314. })
  315. //展示图片
  316. this.exhibitionImage.list = picObject
  317. let isArray = [] //获取图片数组
  318. for (let i in picObject) {
  319. if (Array.isArray(picObject[i])) {
  320. let list = picObject[i]
  321. list.forEach(i => {
  322. if (i.PicList) {
  323. isArray.push(...i.PicList)
  324. }
  325. })
  326. }
  327. }
  328. this.exhibitionImage.arr = isArray
  329. this.exhibitionVideo.list = video
  330. //判断是否显示图片组件
  331. this.isShowImage = isArray.length ? true : false
  332. //判断是否显示video组件
  333. this.isShowVideo = video.length ? true : false
  334. },
  335. handleFileList(arr) {
  336. let picObject = {}
  337. //处理数据格式
  338. arr.map(i => {
  339. if (i.InputMode == 'F2') {
  340. switch (i.Path) {
  341. case 'LedgerParam.EquipManufactor.OriginalCertificate': //原厂证明
  342. case 'LedgerParam.SupplyPurchase.AcceptanceReport': //验收报告
  343. case 'LedgerParam.OperationMainte.MaintainManual': //维修保养手册
  344. case 'LedgerParam.PhotoDoc.Archive': //设备文档
  345. case 'LedgerParam.PhotoDoc.Drawing': //设备图纸
  346. case 'LedgerParam.SupplyPurchase.ApproachingAcceptance': //进场验收单
  347. case 'LedgerParam.EquipManufactor.TestReport': //检测报告
  348. case 'LedgerParam.SupplyPurchase.SupplierContract': //供应合同
  349. case 'LedgerParam.PhotoDoc.ProductCertification': //产品合格证
  350. case 'LedgerParam.PhotoDoc.OperationManual': //操作说明书
  351. case 'LedgerParam.InsuranceDoc.InsuranceFile': //保险文件
  352. case 'LedgerParam.Siteinstall.CheckReport': //安装质检报告
  353. case 'LedgerParam.Siteinstall.InstallDrawing': //安装图纸
  354. case 'LedgerParam.Siteinstall.InstallInstruction': //安装说明书
  355. case 'TechParam.CompleteMachine.DesignIDGraph': //设计工况空调机组处理过程焓湿图
  356. case 'TechParam.AirSupply.FanCharacterCurve': //风机性能曲线
  357. if (this.instance.hasOwnProperty(i.Path)) {
  358. i.fileList = this.instance[i.Path]
  359. }
  360. if (picObject[i.InfoPointName]) {
  361. } else {
  362. picObject[i.InfoPointName] = []
  363. }
  364. picObject[i.InfoPointName].push({
  365. ...i,
  366. })
  367. break
  368. }
  369. }
  370. })
  371. //展示文件
  372. this.exhibitionFile.list = picObject
  373. let isArray = [] //获取文件数组
  374. for (let i in picObject) {
  375. if (Array.isArray(picObject[i])) {
  376. let list = picObject[i]
  377. list.forEach(i => {
  378. if (i.fileList) {
  379. isArray.push(...i.fileList)
  380. }
  381. })
  382. }
  383. }
  384. //判断是否显示文件组件
  385. this.isShowFile = isArray.length ? true : false
  386. },
  387. changeRadio(val) { //1,需采集,2,有值,3,全部
  388. this.handleRadios(val)
  389. this.currentRadio = val
  390. },
  391. formatDate(str) {
  392. if (str) {
  393. if (str.includes('-')) {
  394. return str
  395. } else {
  396. 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)
  397. }
  398. } else {
  399. return '--'
  400. }
  401. },
  402. displayData(arr) {//对数据进行处理传给组件展示
  403. const result = {}
  404. const resultEnergy = {};
  405. arr.map(i => {
  406. if (this.instance.hasOwnProperty(i.Path) && this.currentRadio != 2) {
  407. i.value = this.instance[i.Path]
  408. }
  409. if (i.InputMode == 'C5') {
  410. if (this.instance.hasOwnProperty(i.Path)) {
  411. let time = this.instance[i.Path]
  412. i.value = this.formatDate(time)
  413. }
  414. }
  415. if (i.DataSource && i.DataSource.length) {
  416. let source = JSON.parse(i.DataSource)
  417. //判断输入类型
  418. if (i.InputMode == 'D1L') {
  419. let d1l = tools.formatDataSource(i.DataSource)
  420. d1l.forEach(k => {
  421. if (k.Code == this.instance[i.Path]) {
  422. i.value = k.Name
  423. }
  424. })
  425. } else if (i.InputMode == 'D2' || i.InputMode == 'C6') {
  426. if (this.instance.hasOwnProperty(i.Path)) {
  427. if (!Array.isArray(this.instance[i.Path])) {
  428. let transArray = this.instance[i.Path].split(',')
  429. i.value = source.filter(item => transArray.includes(item.Code)).map(item => item.Name).join(',')
  430. }
  431. }
  432. }
  433. Array.isArray(source) && source.forEach(j => {
  434. if (j.Code == this.instance[i.Path]) {
  435. i.value = j.Name
  436. }
  437. })
  438. }
  439. // 动态信息点处理
  440. switch (i.InputMode) {
  441. case "L":
  442. case "L1":
  443. case "L2":
  444. case "M":
  445. if (resultEnergy[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`]) {
  446. resultEnergy[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`].paths.push({
  447. Path: i.Path,
  448. InfoPointName: i.InfoPointName,
  449. InfoPointCode: i.InfoPointCode,
  450. value: i.svalue,
  451. Visible: i.Visible,
  452. KeyWord: i.KeyWord,
  453. InputMode: i.InputMode,
  454. data: i.data,
  455. receivetime: i.receivetime,
  456. error: i.error,
  457. Unit: i.Unit,
  458. FirstName: i.FirstName,
  459. })
  460. } else {
  461. resultEnergy[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`] = {
  462. paths: [{
  463. Path: i.Path,
  464. InfoPointName: i.InfoPointName,
  465. InfoPointCode: i.InfoPointCode,
  466. value: i.svalue,
  467. Visible: i.Visible,
  468. KeyWord: i.KeyWord,
  469. InputMode: i.InputMode,
  470. data: i.data,
  471. receivetime: i.receivetime,
  472. error: i.error,
  473. Unit: i.Unit,
  474. FirstName: i.FirstName,
  475. }]
  476. }
  477. }
  478. break;
  479. default:
  480. if (result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`]) {
  481. result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`].paths.push({
  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. } else {
  491. result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`] = {
  492. paths: [{
  493. Path: i.Path,
  494. InfoPointName: i.InfoPointName,
  495. InfoPointCode: i.InfoPointCode,
  496. Value: i.value,
  497. Visible: i.Visible,
  498. KeyWord: i.KeyWord,
  499. InputMode: i.InputMode
  500. }]
  501. }
  502. }
  503. }
  504. })
  505. this.exhibitionBaseInformation.information = result
  506. this.exhibitionCrux.allMessage = result
  507. this.exhibitionEnergy.list = resultEnergy;
  508. },
  509. goBack() {
  510. this.$router.push({
  511. name: "facilityLedger",
  512. params: {
  513. deviceId: this.type
  514. }
  515. })
  516. },
  517. // 切换实例
  518. handleChangeExample() {
  519. this.selectRadio.initRadio = '1';
  520. this.currentRadio = '1';
  521. this.getData();
  522. },
  523. // 切换上一个实例
  524. handleClickPrev() {
  525. let index = this.list.findIndex(item => item.value == this.id);
  526. this.id = this.list[index - 1].value;
  527. this.handleChangeExample();
  528. },
  529. // 切换下一个实例
  530. handleClickNext() {
  531. let index = this.list.findIndex(item => item.value == this.id);
  532. this.id = this.list[index + 1].value;
  533. this.handleChangeExample();
  534. },
  535. },
  536. watch: {
  537. projectId() {
  538. this.$router.push({path: "/ledger/facility"})
  539. }
  540. }
  541. }
  542. </script>
  543. <style scoped lang="less">
  544. @bgc: #fff;
  545. .tableDisplay {
  546. .header {
  547. padding-bottom: 10px;
  548. overflow: hidden;
  549. text-overflow: ellipsis;
  550. white-space: nowrap;
  551. .details-title {
  552. color: #333;
  553. font-size: 16px;
  554. margin-left: 20px;
  555. line-height: 32px;
  556. cursor: pointer;
  557. }
  558. }
  559. .content {
  560. height: calc(100% - 77px);
  561. .content-scrollbar {
  562. display: flex;
  563. height: 100%;
  564. flex-direction: row;
  565. box-sizing: border-box;
  566. background-color: #f2f2f2;
  567. .content-left {
  568. display: flex;
  569. flex-direction: column;
  570. flex: 1;
  571. box-sizing: border-box;
  572. .content-keyPoint {
  573. border: 1px solid #ccc;
  574. box-sizing: border-box;
  575. margin-bottom: 10px;
  576. // overflow: hidden;
  577. background: @bgc;
  578. }
  579. .content-showType {
  580. height: 50px;
  581. border: 1px solid #ccc;
  582. border-bottom: none;
  583. box-sizing: border-box;
  584. background: @bgc;
  585. }
  586. .content-point {
  587. display: flex;
  588. flex-direction: row;
  589. border: 1px solid #ccc;
  590. box-sizing: border-box;
  591. background: @bgc;
  592. .content-point-left {
  593. flex: 1;
  594. }
  595. .content-point-right {
  596. width: 300px;
  597. border-left: 1px solid #ccc;
  598. }
  599. }
  600. }
  601. .content-right {
  602. width: 400px;
  603. margin-left: 10px;
  604. box-sizing: border-box;
  605. .content-repair {
  606. height: 50px;
  607. line-height: 50px;
  608. margin-bottom: 10px;
  609. border: 1px solid #ccc;
  610. background: @bgc;
  611. box-sizing: border-box;
  612. }
  613. .content-media {
  614. box-sizing: border-box;
  615. }
  616. }
  617. }
  618. }
  619. .footer {
  620. position: fixed;
  621. bottom: 0;
  622. left: 235px;
  623. width: calc(100% - 235px);
  624. height: 45px;
  625. background-color: #fff;
  626. box-sizing: border-box;
  627. }
  628. }
  629. /deep/ .el-scrollbar__wrap {
  630. overflow-x: hidden;
  631. }
  632. </style>