FanDataStatisticTable.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <!-- 风机原始数据统计表页面 -->
  3. <div class="AllPage">
  4. <!-- 页面头部 multiple多选属性 -->
  5. <el-card>
  6. <el-space wrap>
  7. <div class="search-input">
  8. <span class="lable">报警类型:</span>
  9. <el-select
  10. v-model="state.typeVal"
  11. size="mini"
  12. placeholder="全部"
  13. popper-class="select"
  14. @change="changeType"
  15. >
  16. <el-option
  17. v-for="item in state.typeList"
  18. :key="item.value"
  19. :value="item.value"
  20. :label="item.label"
  21. >
  22. </el-option>
  23. </el-select>
  24. </div>
  25. <div class="search-input">
  26. <span class="lable">场站:</span>
  27. <el-select
  28. v-model="state.changZhan"
  29. @change="changeChangzhan"
  30. placeholder="全部场站"
  31. >
  32. <el-option
  33. v-for="item in changZhanArray"
  34. :key="item.id"
  35. :label="item.name"
  36. :value="item.id"
  37. >
  38. </el-option>
  39. </el-select>
  40. </div>
  41. <div class="search-input" v-if="state.typeVal !== 'booststation'">
  42. <span class="lable">型号:</span>
  43. <el-select
  44. v-model="state.modelId"
  45. @change="changeModel"
  46. placeholder="全部型号"
  47. >
  48. <el-option
  49. v-for="item in modelList"
  50. :key="item.id"
  51. :label="item.name"
  52. :value="item.id"
  53. >
  54. </el-option>
  55. </el-select>
  56. </div>
  57. <div class="search-input" v-if="state.typeVal !== 'booststation'">
  58. <span class="lable">部件:</span>
  59. <el-select
  60. v-model="state.components"
  61. multiple
  62. collapse-tags
  63. clearable
  64. placeholder="全部部件"
  65. @change="changeComponents"
  66. >
  67. <el-option
  68. v-for="item in componentList"
  69. :key="item.id"
  70. :label="item.name"
  71. :value="item.nemCode"
  72. >
  73. </el-option>
  74. </el-select>
  75. </div>
  76. <div class="search-input" v-if="state.typeVal !== 'booststation'">
  77. <span class="lable">报警描述:</span>
  78. <el-select
  79. v-model="state.alarmIds"
  80. multiple
  81. clearable
  82. collapse-tags
  83. placeholder="全部描述"
  84. >
  85. <el-option
  86. v-for="item in state.alarmIdList"
  87. :key="item.id"
  88. :label="item.description"
  89. :value="item.alarmId"
  90. >
  91. </el-option>
  92. </el-select>
  93. </div>
  94. <div class="search-input">
  95. <span class="lable">开始日期:</span>
  96. <el-date-picker
  97. v-model="state.starttime"
  98. type="datetime"
  99. placeholder="选择日期"
  100. value-format="YYYY-MM-DD HH:mm:ss"
  101. >
  102. </el-date-picker>
  103. </div>
  104. <div class="search-input">
  105. <span class="lable">结束日期:</span>
  106. <el-date-picker
  107. v-model="state.endtime"
  108. type="datetime"
  109. placeholder="选择日期"
  110. value-format="YYYY-MM-DD HH:mm:ss"
  111. >
  112. </el-date-picker>
  113. </div>
  114. <el-button type="primary" @click="getTableList">查询</el-button>
  115. </el-space>
  116. </el-card>
  117. <!-- 页面下部---统计表 -->
  118. <div class="table_all">
  119. <el-table
  120. :data="state.tableData"
  121. border
  122. :cell-class-name="tableCell"
  123. :header-row-class-name="tableRowClassName"
  124. @cell-click="handle"
  125. height="100%"
  126. width="100%"
  127. >
  128. <el-table-column
  129. prop="wtname"
  130. label="设备编号"
  131. align="center"
  132. width="80"
  133. />
  134. <el-table-column
  135. :label="item.label"
  136. v-for="(item, index) in state.tHeard"
  137. :key="index"
  138. header-align="center"
  139. show-overflow-tooltip
  140. sortable
  141. :sort-method="
  142. (a, b) => {
  143. return thSort(a, b, item);
  144. }
  145. "
  146. >
  147. <template #default="{ row }">
  148. <div class="bar">
  149. <div
  150. class="bar-percent"
  151. :style="{
  152. width:
  153. (row[`${item.code}_count`] /
  154. (row[`${item.code}_count`] + row[`${item.code}_time`])) *
  155. 100 +
  156. 'px',
  157. }"
  158. ></div>
  159. <span class="value">{{ row[`${item.code}_count`] }} 次数</span>
  160. </div>
  161. <div class="bar">
  162. <div
  163. class="bar-percent"
  164. :style="{
  165. width:
  166. (row[`${item.code}_time`] /
  167. (row[`${item.code}_count`] + row[`${item.code}_time`])) *
  168. 100 +
  169. 'px',
  170. }"
  171. ></div>
  172. <span class="value">{{ row[`${item.code}_time`] }} 分钟</span>
  173. </div>
  174. </template>
  175. </el-table-column>
  176. </el-table>
  177. </div>
  178. <el-dialog
  179. v-model="dialogVisible"
  180. width="80%"
  181. :before-close="dialogClose"
  182. custom-class="currentPdfDialogStyle"
  183. >
  184. <el-table
  185. :data="DataDetail"
  186. border
  187. :cell-class-name="tableCell"
  188. :header-row-class-name="tableRowClassName"
  189. height="600px"
  190. @row-click="handle"
  191. >
  192. <el-table-column prop="windturbineId" label="风机编号" align="center" />
  193. <el-table-column prop="alarmName" label="报警名称" align="center" />
  194. <el-table-column prop="alarmDate" label="时间" align="center" />
  195. <el-table-column prop="type" label="类型(触发/解除)" align="center">
  196. <template #default="scope">
  197. <!-- <span v-if="scope.row.type === 1">触发</span>
  198. <span v-if="scope.row.type === 0">解除</span> -->
  199. {{ scope.row.type === 1 ? "触发" : "解除" }}
  200. </template>
  201. </el-table-column>
  202. </el-table>
  203. </el-dialog>
  204. <!-- <el-pagination
  205. small
  206. background
  207. layout="total, prev, pager, next"
  208. :current-page="pageParam.pagenum"
  209. :page-size="pageParam.pagesize"
  210. :total="pageParam.total"
  211. @current-change="changePage"
  212. ></el-pagination> -->
  213. </div>
  214. </template>
  215. <script setup>
  216. import { useStore } from "vuex";
  217. import BASE from "@tools/basicTool.js";
  218. import {
  219. ref,
  220. onMounted,
  221. watch,
  222. reactive,
  223. computed,
  224. onUnmounted,
  225. nextTick,
  226. } from "vue";
  227. import {
  228. getAlarmCountList,
  229. fetchModel,
  230. fetchRelatePartAndAlarmType,
  231. GetAlarmId,
  232. getWpList,
  233. } from "/@/api/api.js";
  234. import dayjs from "dayjs";
  235. onMounted(() => {
  236. getWpArray();
  237. getequipmentmodel_list();
  238. getfetchRelatePart();
  239. // getTableList();
  240. });
  241. const store = useStore();
  242. const changZhanArray = ref([]);
  243. const state = reactive({
  244. typeVal: "windturbine",
  245. typeList: [
  246. {
  247. label: "升压站",
  248. value: "booststation",
  249. },
  250. // {
  251. // label: "自定义",
  252. // value: "custom",
  253. // },
  254. {
  255. label: "风机",
  256. value: "windturbine",
  257. },
  258. {
  259. label: "光伏",
  260. value: "inverter",
  261. },
  262. ],
  263. tableData: [],
  264. tHeard: [],
  265. changZhan: "",
  266. components: "", //部件
  267. modelId: "", //型号
  268. alarmIds: "",
  269. alarmIdList: [],
  270. modelListAll: {},
  271. fetchListAll: {},
  272. starttime: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  273. endtime: dayjs().format("YYYY-MM-DD HH:mm:ss"),
  274. dialogVisible: false,
  275. });
  276. const changeType = (value) => {
  277. state.typeVal = value;
  278. getWpArray();
  279. };
  280. const getWpArray = async () => {
  281. const { data } = await getWpList(state.typeVal);
  282. changZhanArray.value = data;
  283. if (state.typeVal != "booststation") {
  284. state.changZhan =
  285. state.typeVal == "windturbine" ? "SXJ_KGDL_DJY_FDC_STA" : "";
  286. } else {
  287. state.changZhan = "";
  288. state.modelId = "";
  289. getTableList();
  290. }
  291. };
  292. // 机型
  293. const getequipmentmodel_list = async () => {
  294. const { data } = await fetchModel();
  295. state.modelListAll = data;
  296. };
  297. //所属部件
  298. const getfetchRelatePart = async () => {
  299. const { data } = await fetchRelatePartAndAlarmType();
  300. state.fetchListAll = data;
  301. };
  302. //型号列表
  303. const modelList = computed(() => {
  304. if (state.changZhan == "") {
  305. return [];
  306. } else {
  307. return state.modelListAll[state.changZhan];
  308. }
  309. });
  310. //部件列表
  311. const componentList = computed(() => {
  312. if (state.changZhan == "") {
  313. return [];
  314. } else {
  315. if (state.changZhan.includes("FDC")) {
  316. return state.fetchListAll?.fjbj;
  317. } else {
  318. return state.fetchListAll?.gfbj;
  319. }
  320. }
  321. });
  322. watch(
  323. () => [modelList, componentList],
  324. (val) => {
  325. if (state.typeVal != "booststation") {
  326. let arr = val.map((item) => item.value);
  327. if (arr[0] && arr[0].length && arr[1] && arr[1].length) {
  328. state.modelId = [arr[0][0]?.nemCode];
  329. let componenDefaultSelect =
  330. arr[1]?.find((ele) => {
  331. return ele.nemCode === "ZZ";
  332. })?.nemCode || "";
  333. componenDefaultSelect
  334. ? (state.components = [componenDefaultSelect])
  335. : arr[1]?.[0]?.nemCode
  336. ? (state.components = [arr[1]?.[0]?.nemCode])
  337. : (state.components = []);
  338. getAlarmId();
  339. }
  340. }
  341. },
  342. {
  343. deep: true,
  344. immediate: true,
  345. }
  346. );
  347. function changeModel(val) {
  348. state.modelId = val;
  349. getAlarmId();
  350. }
  351. function changeComponents(val) {
  352. state.components = val;
  353. getAlarmId();
  354. }
  355. function changeChangzhan(val) {
  356. state.changZhan = val;
  357. if (state.typeVal != "booststation") {
  358. getAlarmId();
  359. }
  360. }
  361. function getAlarmId() {
  362. GetAlarmId({
  363. components: state.components,
  364. modelId: state.modelId,
  365. wpId: state.changZhan,
  366. }).then(({ data }) => {
  367. state.alarmIdList = data;
  368. state.alarmIds = [];
  369. // state.alarmIds =
  370. // data.length <= 5
  371. // ? data.map((item) => item.alarmId)
  372. // : data.slice(0, 5).map((item) => item.alarmId);
  373. getTableList();
  374. });
  375. }
  376. // 获取列表数据 调用接口
  377. function getTableList() {
  378. if (state.components?.length) {
  379. getAlarmCountList({
  380. stationid: state.changZhan || "",
  381. begin: state.starttime,
  382. end: state.endtime,
  383. timeType: "m",
  384. components: state.typeVal === "booststation" ? "" : state.components,
  385. modelId: state.modelId,
  386. alarmIds: state.alarmIds,
  387. alarmType: state.typeVal,
  388. }).then((res) => {
  389. if (res.length) {
  390. let tableData = [];
  391. let tHeard = [];
  392. let data = res;
  393. data.forEach((pEle) => {
  394. for (let wtId in pEle) {
  395. let wtItem = data.find((tableItem) => {
  396. return wtId === tableItem.windturbineId;
  397. });
  398. !wtItem && (wtItem = { wtId });
  399. pEle[wtId].forEach((cEle) => {
  400. let someRes = tHeard.some((findEle) => {
  401. return findEle.label == cEle.alertText;
  402. });
  403. if (!someRes) {
  404. tHeard.push({
  405. label: cEle.alertText,
  406. code: cEle.alarmid,
  407. });
  408. }
  409. wtItem[`${cEle.alarmid}_count`] = cEle.count;
  410. wtItem[`${cEle.alarmid}_time`] = cEle.time;
  411. wtItem["wtname"] = cEle.windturbineCode;
  412. });
  413. tableData.push(wtItem);
  414. }
  415. });
  416. state.tHeard = tHeard;
  417. state.tableData = tableData;
  418. } else {
  419. state.tHeard = [];
  420. state.tableData = [];
  421. }
  422. });
  423. } else {
  424. BASE.showMsg({
  425. msg: "部件至少选择一项才可查询",
  426. });
  427. }
  428. }
  429. const thSort = function (a, b, item) {
  430. return a[`${item.code}_count`] - b[`${item.code}_count`];
  431. };
  432. // // 单元格点击事件
  433. // handle(row, column, event, cell) {
  434. // let parts =
  435. // this.tHeard.find((ele) => {
  436. // return ele.label === column.label;
  437. // })?.parts || "";
  438. // getDialogData({
  439. // stationid: this.changZhan || "",
  440. // starttime: dayjs(this.starttime).format("YYYY-MM-DD"),
  441. // endtime: dayjs(this.endtime).format("YYYY-MM-DD"),
  442. // windturbineid: row.wtId,
  443. // parts,
  444. // }).then((res) => {
  445. // if (res && res.status === 20000) {
  446. // if (res.data.length) {
  447. // if (column.property !== "wtId") {
  448. // this.DataDetail = res.data;
  449. // let tableArr = [];
  450. // res.data.forEach((currentItem) => {
  451. // // if (currentItem.type === 1) {
  452. // // currentItem.type = '触发'
  453. // // }
  454. // // else if (currentItem.type === 0) {
  455. // // currentItem.type = '解除'
  456. // // }
  457. // tableArr.push(currentItem);
  458. // });
  459. // this.dialogVisible = true;
  460. // }
  461. // } else {
  462. // BASE.showMsg({
  463. // msg: "所选风机暂无数据",
  464. // });
  465. // }
  466. // }
  467. // });
  468. // },
  469. </script>
  470. <style lang="scss" scoped>
  471. .AllPage {
  472. height: 100%;
  473. .Head {
  474. display: flex;
  475. width: 100%;
  476. height: 5%;
  477. margin: 5px 0;
  478. }
  479. .bar {
  480. display: flex;
  481. align-items: center;
  482. height: 16px;
  483. margin: 8px 0;
  484. .bar-percent {
  485. height: 100%;
  486. background: #6198ff;
  487. margin-right: 8px;
  488. }
  489. }
  490. }
  491. </style>
  492. <style lang="scss">
  493. .table_all {
  494. height: calc(100% - 74px - 30px);
  495. padding: 10px;
  496. margin-top: 10px;
  497. background: #fff;
  498. .el-table {
  499. .el-table__row {
  500. td {
  501. cursor: pointer;
  502. &:first-child {
  503. cursor: auto;
  504. }
  505. }
  506. }
  507. }
  508. }
  509. </style>