CoreDeviceReport.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611
  1. <!-- 核心设备报表 -->
  2. <template>
  3. <div class="core-device-report">
  4. <div class="main-left">
  5. <Select
  6. class="system-select"
  7. width="217"
  8. :isReadOnly="true"
  9. tipPlace="top"
  10. caption="系统名称:"
  11. @change="changeCurSystem"
  12. v-model="systemId"
  13. :selectdata="systemList"
  14. :placeholder="'请选择'"
  15. />
  16. <div class="system-content">
  17. <div v-for="(item) in systemContentData" :key="'key_' + item.category_code" class="item-content" :class="{'active': item.isActive}" @click="changeEquipment(item.category_code)">
  18. <div class="first-row">
  19. <div>{{item.name}}</div>
  20. <div>{{item.isMaintenance?'维保中' : ''}}</div>
  21. </div>
  22. <div class="sec-row">
  23. <div>{{item.num}}<span>台</span></div>
  24. <span :class="{'abnormal': item.abnormal}">{{item.statusNum !== 0?item.statusNum : ''}}</span>
  25. </div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="main-right">
  30. <div class="search-container">
  31. <Input iconType="search" v-model="searchKey" placeholder="搜索" width="192" @pressEnter="getTableData" @clear="getTableData"/>
  32. </div>
  33. <el-table :data="tableData" style="width: 100%;margin-bottom: 63px;" @row-click="showEquipmentStatus">
  34. <el-table-column label="序号" type="index" :index="indexMethod"></el-table-column>
  35. <el-table-column prop="sbjc" label="设备简称"></el-table-column>
  36. <el-table-column prop="sbjbm" label="设备编号"></el-table-column>
  37. <el-table-column prop="is_exception" label="状态">
  38. <template slot-scope="scope">
  39. <span style="display: inline-block;width: 6px;height:6px;border-radius: 3px;background: #0091FF;" :style="{'background': !scope.row.is_exception?'#0091FF' : '#F54E45'}"></span>
  40. <span style="margin-left: 10px">{{ !scope.row.is_exception?'正常' : '异常' }}</span>
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="photos_num" label="照片">
  44. <template slot-scope="scope">
  45. <span style="color: #025BAA" @click="showPicturesDetail(scope.row, 'equip')">{{ scope.row.photos_num?(scope.row.photos_num + '张') : '—' }}</span>
  46. <!-- <span style="color: #025BAA" @click="showPicturesDetail(scope.row)">1张</span> -->
  47. </template>
  48. </el-table-column>
  49. <el-table-column prop="attachments_num" label="报告">
  50. <template slot-scope="scope">
  51. <span style="color: #025BAA" @click="showReportDetail(scope.row, 'equip')">{{ scope.row.attachments_num?(scope.row.attachments_num+ '张') : '—'}}</span>
  52. </template>
  53. </el-table-column>
  54. </el-table>
  55. <div class="page">
  56. <el-pagination
  57. background
  58. layout="prev, pager, next"
  59. :total="tatol"
  60. :current-page="curPage"
  61. :page-size="pageSize"
  62. @current-change="changeTablePage">
  63. </el-pagination>
  64. </div>
  65. <el-dialog :title="equipTitle" :visible.sync="dialogTableVisible" width="1260px">
  66. <el-date-picker
  67. style="margin-bottom: 12px;"
  68. v-model="dialogTime"
  69. type="daterange"
  70. range-separator="至"
  71. @change="changeTime"
  72. start-placeholder="开始日期"
  73. end-placeholder="结束日期">
  74. </el-date-picker>
  75. <el-table :data="historyTableData" style="margin-bottom: 55px;" max-height="500">
  76. <el-table-column width="200" property="finishDate" label="日期"></el-table-column>
  77. <el-table-column width="100" property="typeName" label="事项类型"></el-table-column>
  78. <el-table-column property="taskName" label="事项名称"></el-table-column>
  79. <el-table-column width="100" property="photosNum" label="照片">
  80. <template slot-scope="scope">
  81. <span style="color: #025BAA" @click="showPicturesDetail(scope.row, 'his')">{{ scope.row.photosNum || scope.row.photosNum === 0?(scope.row.photosNum + '张') : '—' }}</span>
  82. <!-- <span style="color: #025BAA" @click="showPicturesDetail(scope.row)">1张</span> -->
  83. </template>
  84. </el-table-column>
  85. <el-table-column width="100" property="attachmentsNum" label="报告">
  86. <template slot-scope="scope">
  87. <span style="color: #025BAA" @click="showReportDetail(scope.row, 'his')">{{ scope.row.attachmentsNum?(scope.row.attachmentsNum+ '张') : '—'}}</span>
  88. </template>
  89. </el-table-column>
  90. </el-table>
  91. <div class="page">
  92. <el-pagination
  93. background
  94. layout="prev, pager, next"
  95. :current-page="hisCurPage"
  96. :page-size="hisPageSize"
  97. :total="hisTotal"
  98. @current-change="changeHisTablePage">
  99. </el-pagination>
  100. </div>
  101. </el-dialog>
  102. <div class="img-detail-container">
  103. <el-dialog :title="detailTitle" :visible.sync="showDetail" width="1260px">
  104. <div class="detail-container">
  105. <div class="pictures-menu">
  106. <div v-for="(item) in pictureList" :key="'id_' + item.id" class="item" @click="changeCurImg(item.id)" :class="{'active': item.isActive}">
  107. <img :src="item.url" alt="">
  108. <div class="name" :title="item.name">{{item.name}}</div>
  109. </div>
  110. </div>
  111. <div class="cur-img-container">
  112. <img :src="curImg.url" alt="">
  113. </div>
  114. </div>
  115. </el-dialog>
  116. </div>
  117. </div>
  118. </div>
  119. </template>
  120. <script>
  121. import { Select, Input } from 'meri-design';
  122. import { querySystemList, queryEquipmentList, queryTableData, queryHistoryTableData, queryDetailData } from '../../api/coreDeviceReport';
  123. import _ from 'lodash';
  124. import moment from 'moment';
  125. import { log } from 'util';
  126. export default {
  127. data () {
  128. return {
  129. systemId: '', // 当前系统Id
  130. systemList: [], // 系统
  131. systemContentData: [
  132. // {id: 1, name: '高压配电柜', isMaintenance: true, num: 95, statusNum: 0, abnormal: false, isActive: true},
  133. // {id: 2, name: '变压器', isMaintenance: false, num: 256, statusNum: 12, abnormal: true, isActive: false},
  134. // {id: 3, name: '低压配电柜', isMaintenance: false, num: 354, statusNum: 0, abnormal: false, isActive: false},
  135. // {id: 4, name: '直流屏', isMaintenance: false, num: 175, statusNum: 0, abnormal: false, isActive: false},
  136. // {id: 5, name: '柴油发电机组', isMaintenance: false, num: 186, status: 0, abnormal: false, isActive: false},
  137. ], // 系统下的各种组成
  138. searchKey: '', // 搜索关键字
  139. tableData: [
  140. // {serialNumber: 1, equipmentName: 2, equipmentNumber: 3, status: '正常', photo: 5, report: 6},
  141. // {serialNumber: 1, equipmentName: 2, equipmentNumber: 3, status: '异常', photo: 5, report: 6},
  142. // {serialNumber: 1, equipmentName: 2, equipmentNumber: 3, status: '正常', photo: 5, report: 6},
  143. ], // 表数据
  144. curPage: 1, // 当前页码
  145. pageSize: 10, // 每页条数
  146. tatol: 0, // 总数据
  147. dialogTableVisible: false, // 弹窗显示状态
  148. // 核心设备实例
  149. equipTitle: '', // 核心设备弹窗名称
  150. assetnum: null, // 设备台账编码
  151. historyTableData: [], // 核心设备实例的所有历史事项信息
  152. dialogTime: null, // 弹框内的时间
  153. hisCurPage: 1, // 当前页码
  154. hisPageSize: 8, // 当前页码
  155. hisTotal: 0, // 总条数
  156. startTime: null, // 开始时间
  157. endTime: null, // 结束事件
  158. showDetail: false, // 显示照片、报告详情
  159. detailTitle: '图片预览', // 弹窗名称
  160. pictureList: [
  161. // {id: 1, url: require('../../assets/images/login_back.png'), name: '图层名称1.jpg'},
  162. // {id: 2, url: require('../../assets/images/matter_pop3.png'), name: '图层名称2.jpg'},
  163. // {id: 3, url: require('../../assets/images/login_back.png'), name: '图层名称3.jpg'},
  164. ], // 图片列表
  165. curImg: {}, // 当前图片
  166. }
  167. },
  168. components: {
  169. Select,
  170. Input
  171. },
  172. computed: {},
  173. mounted() {
  174. this.getSystemList();
  175. // this.getEquipmentOfSystem();
  176. },
  177. methods: {
  178. /**
  179. * 获取系统列表数据
  180. */
  181. getSystemList() {
  182. querySystemList().then((res) => {
  183. if (res.result === 'success') {
  184. let data = res.data;
  185. let newData = [];
  186. _.forEach(data, (item) => {
  187. newData.push({
  188. id: item.code,
  189. name: item.name
  190. })
  191. })
  192. this.systemList = newData;
  193. const { query } = this.$route;
  194. if (!_.isEmpty(query)) {
  195. this.systemId = query.smsxt || newData[0].id;
  196. } else {
  197. this.systemId = newData[0].id;
  198. }
  199. this.getEquipmentOfSystem();
  200. }
  201. })
  202. },
  203. /**
  204. * 切换系统名称
  205. */
  206. changeCurSystem(val) {
  207. console.log('val', val)
  208. this.getEquipmentOfSystem();
  209. },
  210. /**
  211. * 获取系统下的设备
  212. */
  213. getEquipmentOfSystem() {
  214. let param = {
  215. plazaId: 1000423,
  216. ccode: 1002347,
  217. smsxt: this.systemId
  218. }
  219. queryEquipmentList('/data/home/querySystemCard', param).then((res) => {
  220. const { result, data } = res;
  221. if (result === 'success') {
  222. let newData = [], abnormalList = [];
  223. _.forEach(data[0].assetTypeList, (item, index) => {
  224. let itemData = {
  225. name: item.category_name,
  226. isMaintenance: item.is_detecting,
  227. statusNum: item.is_exception_num,
  228. num: item.asset_num,
  229. abnormal: item.is_exception_num !== 0,
  230. category_code: item.category_code
  231. }
  232. if (item.is_exception_num === 0) {
  233. newData.push(itemData)
  234. } else {
  235. abnormalList.push(itemData);
  236. }
  237. })
  238. newData = abnormalList.concat(newData);
  239. _.map(newData, (o, i) => {return o.isActive = i === 0});
  240. const { query } = this.$route;
  241. this.systemContentData = newData;
  242. if (!_.isEmpty(query) && query.equipId) {
  243. _.map(this.systemContentData, (o) => {return o.isActive = o.id == query.equipId});
  244. }
  245. this.getTableData();
  246. }
  247. })
  248. },
  249. /**
  250. * 切换系统下的设备
  251. */
  252. changeEquipment(id) {
  253. _.map(this.systemContentData, (o) => {return o.isActive = o.category_code === id});
  254. this.getTableData();
  255. },
  256. /**
  257. * 获取表数据
  258. */
  259. getTableData() {
  260. let query = {
  261. category_code: _.find(this.systemContentData, (o) => {return o.isActive}).category_code
  262. }
  263. let url = `/data/glsms_asset/query?plazaId=1000423&page=${this.curPage}&size=${this.pageSize}&orderBy=is_exception,0`;
  264. if (_.trim(this.searchKey) !== '') {
  265. url = `${url}&keyword=${this.searchKey}:sbjc,sbjbm`
  266. }
  267. queryTableData(url, query).then((res) => {
  268. const { result, count, data } = res;
  269. if (result === 'success') {
  270. this.tatol = count;
  271. this.tableData = data;
  272. }
  273. })
  274. },
  275. /**
  276. * 表第一列序号
  277. */
  278. indexMethod(index) {
  279. return index + 1;
  280. },
  281. /**
  282. * 切换页码
  283. */
  284. changeTablePage(page) {
  285. this.curPage = page;
  286. this.getTableData();
  287. },
  288. /**
  289. * 显示设备实例的维保、专维等状态
  290. */
  291. showEquipmentStatus(row, column, e) {
  292. setTimeout(() => {
  293. if (this.showDetail) return
  294. this.equipTitle = row.sbjc;
  295. this.dialogTableVisible = true;
  296. this.assetnum = row.assetnum;
  297. this.initTimePicker();
  298. }, 36)
  299. },
  300. /**
  301. * 获取核心设备实例的所有历史事项信息
  302. */
  303. getEquipmentHistoryMsg() {
  304. this.historyTableData = [];
  305. let param = {
  306. page: this.hisCurPage,
  307. size: this.hisPageSize,
  308. plazaId: 1000423,
  309. // assetnum: this.assetnum,
  310. assetnum: 24071,
  311. // startDate: this.startTime,
  312. startDate: 20000101000000,
  313. // endDate: this.endTime
  314. endDate: 20200201000000
  315. }
  316. queryHistoryTableData('/data/base/queryDateByAssetNum', param).then((res) => {
  317. const { result, data, count } = res;
  318. if (result === 'success') {
  319. this.historyTableData = data;
  320. this.hisTotal = count;
  321. _.forEach(this.historyTableData, (item) => {
  322. let name;
  323. switch (item.type) {
  324. case 0:
  325. name = '专维'
  326. break
  327. case 1:
  328. name = '维保专业'
  329. break
  330. case 2:
  331. name = '第三方视图'
  332. break
  333. }
  334. item.typeName = name;
  335. item.finishDate = moment.unix(item.finishDate / 1000).format('YYYY.MM.DD');
  336. })
  337. }
  338. })
  339. },
  340. /**
  341. * 初始化时间选择器
  342. */
  343. initTimePicker() {
  344. let endTime = new Date(),
  345. startTime = new Date(endTime.getTime() - 1000*60*60*24*30);
  346. this.dialogTime = [startTime, endTime];
  347. this.changeTime();
  348. },
  349. /**
  350. * 切换时间
  351. */
  352. changeTime() {
  353. this.hisCurPage = 1;
  354. if (this.dialogTime) {
  355. this.startTime = moment.unix(new Date(this.dialogTime[0]).getTime() / 1000).format('YYYYMMDDHHmmss');
  356. this.endTime = moment.unix(new Date(this.dialogTime[1]).getTime() / 1000).format('YYYYMMDDHHmmss');
  357. } else {
  358. this.initTimePicker();
  359. }
  360. this.getEquipmentHistoryMsg();
  361. },
  362. /**
  363. * 切换设备台账下所有历史事项信息页码
  364. */
  365. changeHisTablePage(page) {
  366. this.hisCurPage = page;
  367. this.getEquipmentHistoryMsg();
  368. },
  369. /**
  370. * 显示图片详情
  371. */
  372. showPicturesDetail(val, type) {
  373. console.log('val', val)
  374. if (type === 'equip') {
  375. if (!val.file_type || !val.file_type_id) {
  376. return
  377. }
  378. } else {
  379. if (!val.photosNum) {
  380. return
  381. }
  382. }
  383. this.showDetail = true;
  384. this.detailTitle = '图片预览';
  385. this.getDetailData(val);
  386. },
  387. /**
  388. * 显示附件详情
  389. */
  390. showReportDetail(val) {
  391. console.log('val', val)
  392. if (type === 'equip') {
  393. if (!val.file_type || !val.file_type_id) {
  394. return
  395. }
  396. } else {
  397. if (!val.attachments_num) {
  398. return
  399. }
  400. }
  401. this.showDetail = true;
  402. this.detailTitle = '附件预览';
  403. this.getDetailData(val);
  404. },
  405. /**
  406. * 获取图片/报告详情
  407. */
  408. getDetailData(val, type) {
  409. let param = {
  410. file_type: type === 'equip'?val.file_type : val.type,
  411. // file_type: 0,
  412. file_type_id: type === 'equip'?val.file_type_id : val.id,
  413. // file_type_id: 2914,
  414. type: this.detailTitle === '图片预览'? 0 : 1
  415. }
  416. queryDetailData('/data/base/queryFileDetails', param).then((res) => {
  417. console.log('res', res)
  418. const { result, data } = res;
  419. if (result === 'success') {
  420. let newData = [];
  421. _.forEach(data, (item, index) => {
  422. newData.push({
  423. id: item.id,
  424. url: item.urlname,
  425. isActive: index === 0,
  426. name: item.description
  427. })
  428. })
  429. if (this.detailTitle === '图片预览') {
  430. this.pictureList = newData;
  431. this.curImg = this.pictureList[0];
  432. } else {
  433. }
  434. }
  435. })
  436. },
  437. /**
  438. * 切换当前预览大图
  439. */
  440. changeCurImg(id) {
  441. _.map(this.pictureList, (o) => {return o.isActive = o.id === id});
  442. this.curImg = _.find(this.pictureList, (o) => {return o.isActive});
  443. }
  444. }
  445. }
  446. </script>
  447. <style lang='less' scoped>
  448. .core-device-report {
  449. display: flex;
  450. width: 100%;
  451. height: 100%;
  452. .main-left {
  453. padding-left: 16px;
  454. padding-right: 14px;
  455. padding-top: 12px;
  456. padding-bottom: 12px;
  457. width: 247px;
  458. border-top: 1px solid #e4e6e7;
  459. border-right: 1px solid #e4e6e7;
  460. .system-select {
  461. margin-bottom: 16px;
  462. }
  463. .item-content {
  464. padding-left: 12px;
  465. padding-right: 21px;
  466. padding-top: 7px;
  467. padding-bottom: 8px;
  468. border-bottom: 1px solid #e4e6e7;
  469. cursor: pointer;
  470. > div {
  471. display: flex;
  472. }
  473. .first-row {
  474. margin-bottom: 6px;
  475. display: flex;
  476. justify-content: space-between;
  477. > div:first-child {
  478. font-size: 14px;
  479. color: #1f2429;
  480. line-height: 19px;
  481. }
  482. > div:nth-of-type(2) {
  483. margin-left: 8px;
  484. font-size: 12px;
  485. color: #cd981d;
  486. line-height: 20px;
  487. }
  488. }
  489. .sec-row {
  490. margin-bottom: 6px;
  491. > div:first-child {
  492. font-size: 14px;
  493. color: #1f2429;
  494. line-height: 19px;
  495. > span {
  496. font-size: 12px;
  497. color: #646c73;
  498. }
  499. }
  500. // >div:nth-of-type(2){
  501. // padding-left: 8px;
  502. // padding-right: 8px;
  503. // font-size: 12px;
  504. // color: #0065B3;
  505. // line-height: 22px;
  506. // background: #E1F2FF;
  507. // }
  508. .abnormal {
  509. margin-left: 11px;
  510. padding-left: 3px;
  511. padding-right: 3px;
  512. font-size: 12px;
  513. color: #f54e45 !important;
  514. background: #fde3e2 !important;
  515. border-radius: 9px;
  516. }
  517. }
  518. }
  519. .system-content {
  520. .active {
  521. background: #e5eef5;
  522. border-radius: 2px;
  523. .first-row > div:first-child,
  524. .sec-row > div {
  525. color: #025baa;
  526. > span {
  527. color: #025baa;
  528. }
  529. }
  530. }
  531. }
  532. }
  533. .main-right {
  534. flex: 1;
  535. background: #fff;
  536. padding-left: 15px;
  537. padding-right: 13px;
  538. padding-top: 13px;
  539. padding-bottom: 25px;
  540. .search-container {
  541. margin-bottom: 12px;
  542. }
  543. .page {
  544. display: flex;
  545. justify-content: flex-end;
  546. }
  547. }
  548. .el-dialog{
  549. min-height: 600px;
  550. }
  551. .detail-container{
  552. display: flex;
  553. height: 600px
  554. }
  555. .pictures-menu{
  556. margin-right: 21px;
  557. padding-top: 16px;
  558. padding-bottom: 16px;
  559. width: 180px;
  560. height: 100%;
  561. overflow: auto;
  562. .item{
  563. >img{
  564. width: 180px;
  565. border: 4px solid rgba(245,246,247,1);
  566. border-radius: 4px;
  567. }
  568. .name{
  569. font-size: 12px;
  570. color: #1F2429;
  571. line-height: 16px;
  572. margin-top: 12px;
  573. text-align: center;
  574. overflow: hidden;
  575. text-overflow: ellipsis;
  576. white-space: nowrap;
  577. }
  578. &:not(:last-of-type){
  579. margin-bottom: 20px;
  580. }
  581. }
  582. .active>img{
  583. border-color: rgba(31, 35, 41, 0.15);
  584. }
  585. }
  586. .cur-img-container{
  587. padding: 20px;
  588. flex: 1;
  589. height: 100%;
  590. background: #F5F6F7;
  591. display: flex;
  592. justify-content: center;
  593. align-items: center;
  594. >img{
  595. max-width: 730px;
  596. max-height: 530px;
  597. }
  598. }
  599. }
  600. </style>