index.vue 17 KB

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