index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  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 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"/>
  43. <exhibitionVideo :exhibitionVideo="exhibitionVideo"/>
  44. <exhibitionFile :exhibitionFile="exhibitionFile"/>
  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. style:2
  130. },
  131. exhibitionEnergy: {
  132. title: '能耗信息',
  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. },
  151. exhibitionVideo: {
  152. title: '视频',
  153. list: {}
  154. },
  155. instance: {},//实例信息处理
  156. }
  157. },
  158. methods: {
  159. deepCopy(obj) {
  160. return JSON.parse(JSON.stringify(obj))
  161. },
  162. cruxSuccess(){
  163. this.getData()
  164. },
  165. // 获取表头和实例数据(动态数据在组件中获取,在此格式化请求参数)
  166. getData() {
  167. let params1 = {
  168. data: {
  169. Orders: "sort asc",
  170. PageNumber: 1,
  171. PageSize: 1000
  172. },
  173. type: this.type
  174. }, params2 = {
  175. Filters: `EquipID='${this.id}'`,
  176. };
  177. let promise1 = new Promise((resolve, reject) => {
  178. getDataDictionary(params1, res => {
  179. resolve(res)
  180. })
  181. })
  182. let promise2 = new Promise((resolve, reject) => {
  183. queryEquip(params2, res => {
  184. resolve(res)
  185. })
  186. })
  187. Promise.all([promise1, promise2]).then(values => {
  188. this.pointData = values[0].Content;
  189. this.exampleData = values[1].Content[0];
  190. this.name = this.exampleData.EquipLocalName?this.exampleData.EquipLocalName:this.exampleData.EquipName?this.exampleData.EquipName:'';
  191. this.code = this.exampleData.EquipLocalID?this.exampleData.EquipLocalID:'';
  192. let obj = this.deepCopy(values[1].Content[0]);
  193. obj = tools.flattenKeys(obj);
  194. this.instance = obj;
  195. this.handleRadios(1)
  196. this.pointData.forEach(item => {
  197. if (item.InputMode == "L" || item.InputMode == "L1" || item.InputMode == "L2" || item.InputMode == "M") {
  198. let cur = tools.dataForKey(this.exampleData, item.Path);
  199. if (cur) {
  200. this.criterias.push({
  201. id: this.exampleData.EquipID,
  202. code: item.InfoPointCode
  203. })
  204. }
  205. }
  206. })
  207. let params = { //获取动态参数
  208. secret: this.secret,
  209. ProjId: this.projectId,
  210. data: {
  211. criterias: this.criterias
  212. }
  213. }
  214. if (this.criterias.length) {
  215. BeatchQueryParam(params, res => {
  216. res.Content.map(child => {
  217. this.pointData.forEach(head => {
  218. if (head.InfoPointCode == child.code) {
  219. this.exhibitionEnergy.dynamic.push({
  220. InfoPointCode: head.InfoPointCode,
  221. InfoPointName: head.InfoPointName,
  222. Path: head.Path,
  223. value: child.value,
  224. data: child.data || '--',
  225. receivetime: child.receivetime || '',
  226. error: child.error || '',
  227. Unit: head.Unit || ''
  228. })
  229. }
  230. })
  231. });
  232. })
  233. }
  234. })
  235. },
  236. handleRadios(val) { //判断radio的值显示关键信息,基本信息,图片,文件
  237. let arr = []
  238. //关键信息点
  239. this.exhibitionCrux.cruxArray = this.pointData.filter(i => i.KeyWord)
  240. this.exhibitionCrux.cruxArray.map(i => {
  241. if (this.instance.hasOwnProperty(i.Path)) {
  242. return {
  243. ...i,
  244. value: this.instance[i.Path]
  245. }
  246. }
  247. })
  248. if (val == 1) { //需采集信息
  249. arr = this.pointData.filter(i => i.Visible)
  250. // 图片和的处理
  251. this.handlePicList(arr)
  252. // 文件处理
  253. this.handleFileList(arr)
  254. } else if (val == 2) { //有值信息点
  255. let list = this.pointData
  256. list.map(j => {
  257. if (this.instance.hasOwnProperty(j.Path)) {
  258. return {
  259. ...j,
  260. value: this.instance[j.Path]
  261. }
  262. }
  263. arr = list.filter(k => k.value)
  264. this.handlePicList(arr)
  265. this.handleFileList(arr)
  266. })
  267. } else { //全部信息点
  268. arr = this.pointData
  269. this.handlePicList(arr)
  270. this.handleFileList(arr)
  271. }
  272. this.displayData(arr)
  273. },
  274. handlePicList(arr) {
  275. let picObject = {}
  276. //处理数据格式
  277. arr.map(i => {
  278. if(i.InputMode == 'F2') {
  279. switch (i.Path) {
  280. case 'LedgerParam.PhotoDoc.Drawing':
  281. case 'LedgerParam.Siteinstall.InstallPic':
  282. case 'LedgerParam.Siteinstall.InstallDrawing':
  283. case 'LedgerParam.PhotoDoc.Nameplate':
  284. if (this.instance.hasOwnProperty(i.Path)) {
  285. i.PicList = this.instance[i.Path]
  286. }
  287. if (picObject[i.InfoPointName]) {
  288. } else {
  289. picObject[i.InfoPointName] = []
  290. }
  291. picObject[i.InfoPointName].push({
  292. ...i,
  293. })
  294. break;
  295. }
  296. }
  297. })
  298. //展示图片
  299. this.exhibitionImage.list = picObject
  300. },
  301. handleFileList(arr) {
  302. let picObject = {}
  303. //处理数据格式
  304. arr.map(i => {
  305. if (i.InputMode == 'F2') {
  306. switch (i.Path) {
  307. case 'LedgerParam.InsuranceDoc.InsuranceFile':
  308. case 'LedgerParam.PhotoDoc.Archive':
  309. case 'LedgerParam.Siteinstall.CheckReport':
  310. if (this.instance.hasOwnProperty(i.Path)) {
  311. i.fileList = this.instance[i.Path]
  312. }
  313. if (picObject[i.InfoPointName]) {
  314. } else {
  315. picObject[i.InfoPointName] = []
  316. }
  317. picObject[i.InfoPointName].push({
  318. ...i,
  319. })
  320. break
  321. }
  322. }
  323. })
  324. //展示文件
  325. this.exhibitionFile.list = picObject
  326. },
  327. changeRadio(val) { //1,需采集,2,有值,3,全部
  328. this.handleRadios(val)
  329. this.currentRadio = val
  330. },
  331. formatDate(str) {
  332. return str ? str.substr(0,4)+"-"+str.substr(4,2)+"-"+str.substr(6,2)+" "+str.substr(8,2) + ":" +str.substr(10,2) + ":"+str.substr(12,2) :'--'
  333. },
  334. displayData(arr) {//对数据进行处理传给组件展示
  335. const result = {}
  336. arr.forEach(i => {
  337. if (this.instance.hasOwnProperty(i.Path) && this.currentRadio != 2) {
  338. i.value = this.instance[i.Path]
  339. }
  340. if (i.InputMode == 'C5') {
  341. if (this.instance.hasOwnProperty(i.Path)) {
  342. let time = this.instance[i.Path]
  343. i.value = this.formatDate(time)
  344. }
  345. }
  346. if (i.DataSource && i.DataSource.length) {
  347. let source = JSON.parse(i.DataSource)
  348. //判断输入类型
  349. if (i.InputMode == 'D1L') {
  350. let d1l = tools.formatDataSource(i.DataSource)
  351. d1l.forEach(k => {
  352. if (k.Code == this.instance[i.Path]) {
  353. i.value = k.Name
  354. }
  355. })
  356. } else if (i.InputMode == 'D2' || i.InputMode == 'C6') {
  357. if (this.instance.hasOwnProperty(i.Path)) {
  358. if (!Array.isArray(this.instance[i.Path])) {
  359. let transArray = this.instance[i.Path].split(',')
  360. i.value = source.filter(item => transArray.includes(item.Code)).map(item => item.Name).join(',')
  361. }
  362. }
  363. }
  364. source.forEach(j => {
  365. if (j.Code == this.instance[i.Path]) {
  366. console.log(j.Name)
  367. i.value = j.Name
  368. }
  369. })
  370. }
  371. switch (i.InputMode) {
  372. case "L":
  373. case "L1":
  374. case "L2":
  375. case "M":
  376. break;
  377. default:
  378. if (result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`]) {
  379. result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`].paths.push({
  380. Path: i.Path,
  381. InfoPointName: i.InfoPointName,
  382. InfoPointCode: i.InfoPointCode,
  383. Value: i.value,
  384. Visible: i.Visible,
  385. KeyWord: i.KeyWord,
  386. InputMode:i.InputMode
  387. })
  388. } else {
  389. result[`${i.FirstName}${i.SecondName ? '/' + i.SecondName : ''}`] = {
  390. paths: [{
  391. Path: i.Path,
  392. InfoPointName: i.InfoPointName,
  393. InfoPointCode: i.InfoPointCode,
  394. Value: i.value,
  395. Visible: i.Visible,
  396. KeyWord: i.KeyWord,
  397. InputMode:i.InputMode
  398. }]
  399. }
  400. }
  401. }
  402. })
  403. this.exhibitionBaseInformation.information = result
  404. this.exhibitionCrux.allMessage = result
  405. },
  406. goBack() {
  407. this.$router.push({
  408. name: "facilityLedger",
  409. params: {
  410. deviceId: this.type
  411. }
  412. })
  413. },
  414. // 切换实例
  415. handleChangeExample() {
  416. this.selectRadio.initRadio = '1'
  417. this.getData();
  418. },
  419. },
  420. watch: {
  421. projectId() {
  422. this.$router.push({path: "/ledger/facility"})
  423. }
  424. }
  425. }
  426. </script>
  427. <style scoped lang="less">
  428. @bgc:#fff;
  429. .tableDisplay {
  430. .header {
  431. padding-bottom: 10px;
  432. .details-title {
  433. color: #333;
  434. font-size: 16px;
  435. margin-left: 20px;
  436. line-height: 32px;
  437. }
  438. }
  439. .content {
  440. display: flex;
  441. flex-direction: row;
  442. box-sizing: border-box;
  443. height: calc(100% - 95px);
  444. .content-left {
  445. display: flex;
  446. flex-direction: column;
  447. flex: 1;
  448. .content-keyPoint {
  449. border: 1px solid #ccc;
  450. box-sizing: border-box;
  451. height: 100px;
  452. margin-bottom: 10px;
  453. overflow: hidden;
  454. background: @bgc;
  455. }
  456. .content-showType {
  457. height: 50px;
  458. border: 1px solid #ccc;
  459. border-bottom: none;
  460. box-sizing: border-box;
  461. background: @bgc;
  462. }
  463. .content-point {
  464. display: flex;
  465. flex-direction: row;
  466. height: calc(100% - 160px);
  467. border: 1px solid #ccc;
  468. box-sizing: border-box;
  469. background: @bgc;
  470. .content-point-left {
  471. flex: 1;
  472. }
  473. .content-point-right {
  474. width: 400px;
  475. border-left: 1px solid #ccc;
  476. }
  477. }
  478. }
  479. .content-right {
  480. width: 400px;
  481. margin-left: 10px;
  482. .content-repair {
  483. height: 50px;
  484. line-height: 50px;
  485. margin-bottom: 10px;
  486. border: 1px solid #ccc;
  487. background: @bgc;
  488. box-sizing: border-box;
  489. }
  490. .content-media {
  491. height: calc(100% - 60px);
  492. border: 1px solid #ccc;
  493. box-sizing: border-box;
  494. }
  495. }
  496. }
  497. .footer {
  498. margin-top: 5px;
  499. height: 45px;
  500. background-color: #fff;
  501. box-sizing: border-box;
  502. border: 1px solid #ccc;
  503. }
  504. }
  505. /deep/ .el-scrollbar__wrap {
  506. overflow-x: hidden;
  507. }
  508. </style>