index_old.vue 15 KB

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