CoreDeviceReport.vue 20 KB

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