index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  1. <template>
  2. <div class="alarm-body">
  3. <div class="search-form">
  4. <div class="select-form">
  5. <div class="select-item">
  6. 报警类型:
  7. <el-select
  8. size="mini"
  9. v-model="alarmType"
  10. placeholder="请选择"
  11. @change="alarmTypeChanged"
  12. >
  13. <el-option
  14. v-for="item in alarmOptions"
  15. :key="item.id"
  16. :label="item.name"
  17. :value="item.code"
  18. >
  19. </el-option>
  20. </el-select>
  21. </div>
  22. <div class="select-item" v-if="alarmType == 'booststation'">
  23. 升压站:
  24. <el-select
  25. size="mini"
  26. v-model="sub"
  27. placeholder="请选择"
  28. @change="subChanged"
  29. filterable
  30. >
  31. <el-option
  32. v-for="item in subOptions"
  33. :key="item.id"
  34. :label="item.name"
  35. :value="item.id"
  36. >
  37. </el-option>
  38. </el-select>
  39. </div>
  40. <div class="select-item" v-if="alarmType != 'booststation'">
  41. 场站:
  42. <el-select
  43. size="mini"
  44. v-model="station"
  45. placeholder="请选择"
  46. @change="stationChanged"
  47. filterable
  48. >
  49. <el-option
  50. v-for="item in wpOptions"
  51. :key="item.id"
  52. :label="item.name"
  53. :value="item.id"
  54. >
  55. </el-option>
  56. </el-select>
  57. </div>
  58. <div class="select-item" v-if="alarmType != 'booststation'">
  59. 设备:
  60. <el-select
  61. size="mini"
  62. v-model="wind"
  63. placeholder="请选择"
  64. @change="windChanged"
  65. filterable
  66. clearable
  67. >
  68. <el-option
  69. v-for="item in wtOptions"
  70. :key="item.id"
  71. :label="item.name"
  72. :value="item.id"
  73. >
  74. </el-option>
  75. </el-select>
  76. </div>
  77. <div class="select-item">
  78. 描述:
  79. <el-input size="mini" v-model="description" placeholder="请输入">
  80. </el-input>
  81. </div>
  82. <div class="select-item">
  83. 开始日期:
  84. <el-date-picker
  85. v-model="begin"
  86. :disabled-date="disabledDate"
  87. type="datetime"
  88. value-format="YYYY-MM-DD HH:mm:ss"
  89. placeholder="选择日期"
  90. size="mini"
  91. popper-class="date-select"
  92. >
  93. </el-date-picker>
  94. </div>
  95. <div class="select-item">
  96. 结束日期:
  97. <el-date-picker
  98. v-model="end"
  99. :disabled-date="disabledDate2"
  100. type="datetime"
  101. value-format="YYYY-MM-DD HH:mm:ss"
  102. placeholder="选择日期"
  103. size="mini"
  104. popper-class="date-select"
  105. >
  106. </el-date-picker>
  107. </div>
  108. </div>
  109. <div class="btns">
  110. <el-button round size="mini" class="buttons" @click="getTableData(0)"
  111. >搜 索</el-button
  112. >
  113. </div>
  114. </div>
  115. <div class="alarm-list">
  116. <div class="line">
  117. <div class="left-content"><span>报警列表</span></div>
  118. <div class="right-content"></div>
  119. </div>
  120. <div class="economicTable">
  121. <el-table
  122. ref="table"
  123. :data="alarmData"
  124. height="calc(100% - 35px)"
  125. style="width: 100%"
  126. fit
  127. v-loading="loading"
  128. element-loading-text="加载中..."
  129. element-loading-background="rgba(4, 12, 11, 0.8)"
  130. empty-text=" "
  131. stripe
  132. >
  133. <el-table-column
  134. v-for="(item, index) in tableHeader"
  135. :key="index"
  136. sortable
  137. :prop="item.code"
  138. :label="item.title"
  139. :align="item.code != 'description' ? 'center' : 'left'"
  140. :width="item.width"
  141. >
  142. <template #default="{ row }">
  143. <span v-if="item.code == 'rank'">{{ getRank(row.rank) }}</span>
  144. <span
  145. v-else-if="item.code == 'endts' && item.title == '是否解除'"
  146. >{{ row.endts ? "已解除" : "未解除" }}</span
  147. >
  148. <span v-else-if="item.code == 'endts'">{{
  149. row.endts ? getTime(row.endts) : "--"
  150. }}</span>
  151. <span v-else>{{ row[item.code] || "--" }}</span>
  152. </template>
  153. </el-table-column>
  154. </el-table>
  155. <el-pagination
  156. @current-change="handleCurrentChange"
  157. :current-page="page.currentPage"
  158. :page-size="page.pagesize"
  159. layout="total, prev, pager, next, jumper"
  160. :total="page.total"
  161. >
  162. </el-pagination>
  163. </div>
  164. </div>
  165. </div>
  166. </template>
  167. <script>
  168. import { getWpList, getSubList } from "@/api/economic/index";
  169. import { getApiequipmentListByWp } from "@/api/monthlyPerformanceAnalysis.js";
  170. import { GetTableData } from "@/api/zhbj/index.js";
  171. import dayjs from "dayjs";
  172. export default {
  173. name: "commonAlarm",
  174. components: {},
  175. data() {
  176. return {
  177. route: { id: "", station: "", wind: "", ts: "", endts: "" },
  178. routeFlag: 0,
  179. station: "",
  180. wpOptions: [],
  181. wind: "",
  182. wtOptions: [],
  183. sub: "",
  184. subOptions: [],
  185. alarmType: "windturbine",
  186. alarmOptions: [
  187. {
  188. code: "booststation",
  189. name: "升压站报警",
  190. },
  191. {
  192. code: "windturbine",
  193. name: "风机报警",
  194. },
  195. {
  196. code: "inverter",
  197. name: "逆变器报警",
  198. },
  199. ],
  200. booststation: "",
  201. booststationOptions: [],
  202. description: "",
  203. begin: dayjs().startOf("day").format("YYYY-MM-DD HH:mm:ss"),
  204. end: dayjs().format("YYYY-MM-DD HH:mm:ss"),
  205. alarmData: [],
  206. loading: false,
  207. tableHeader: [
  208. { title: "时间", code: "ts", width: "220" },
  209. { title: "场站名称", code: "stationname", width: "220" },
  210. { title: "设备名称", code: "devicename", width: "200" },
  211. { title: "报警描述", code: "description" },
  212. { title: "是否解除", code: "endts", width: "180" },
  213. { title: "解除时间", code: "endts", width: "200" },
  214. { title: "是否确认", code: "confirmed", width: "180" },
  215. ],
  216. tableHeader1: [
  217. { title: "时间", code: "ts" },
  218. { title: "报警描述显示", code: "description" },
  219. { title: "是否确认", code: "confirmed" },
  220. ],
  221. page: {
  222. pagesize: 22,
  223. currentPage: 1,
  224. total: 0,
  225. },
  226. };
  227. },
  228. created() {
  229. // this.GetWpOptions();
  230. },
  231. methods: {
  232. getTime(endts) {
  233. return dayjs(endts).format("YYYY-MM-DD HH:mm:ss");
  234. },
  235. getRank(rank) {
  236. if (rank === 1) {
  237. return "低级";
  238. } else if (rank === 2) {
  239. return "低中级";
  240. } else if (rank === 3) {
  241. return "中级";
  242. } else if (rank === 4) {
  243. return "中高级";
  244. } else if (rank === 5) {
  245. return "高级";
  246. }
  247. },
  248. // 时间选择器第一个禁用
  249. disabledDate(time) {
  250. if (this.end) {
  251. return time.getTime() > Date.parse(this.end);
  252. } else {
  253. return null;
  254. }
  255. },
  256. // 时间选择器第二个禁用
  257. disabledDate2(time) {
  258. if (this.begin) {
  259. return time.getTime() < Date.parse(this.begin);
  260. } else {
  261. return null;
  262. }
  263. },
  264. GetWpOptions(flag) {
  265. this.routeFlag = flag;
  266. getWpList({ type: 0 }).then(({ data }) => {
  267. if (data && data.data.length) {
  268. this.wpOptions = data.data;
  269. this.station = flag ? this.route.station : data.data[0].id;
  270. if (!flag) {
  271. this.getTableData(flag);
  272. }
  273. this.GetWtOptions(flag);
  274. } else {
  275. this.wpOptions = [];
  276. this.station = "";
  277. }
  278. });
  279. },
  280. GetWtOptions(flag) {
  281. getApiequipmentListByWp({ wpid: this.station }).then(({ data }) => {
  282. if (data && data.data.length) {
  283. this.wtOptions = data.data;
  284. this.wind = flag ? this.route.wind : "";
  285. if (flag) {
  286. this.getTableData(1);
  287. }
  288. } else {
  289. this.wtOptions = [];
  290. this.wind = "";
  291. }
  292. });
  293. },
  294. GetSubOptions(flag) {
  295. getSubList({ type: 0 }).then(({ data }) => {
  296. if (data && data.data.length) {
  297. this.subOptions = data.data;
  298. this.sub = flag ? this.route.station : this.subOptions[0].id;
  299. this.getTableData();
  300. } else {
  301. this.subOptions = [];
  302. this.sub = "";
  303. }
  304. });
  305. },
  306. getTableData(flag) {
  307. this.loading = true;
  308. let params = {};
  309. if (!flag) {
  310. params = {
  311. begin: this.begin,
  312. end: this.end,
  313. alarmType: this.alarmType,
  314. stationid: this.station,
  315. deviceid: this.wind,
  316. description: this.description,
  317. pageNum: this.page.currentPage,
  318. pageSize: this.page.pagesize,
  319. };
  320. if (this.alarmType != "booststation") {
  321. params.deviceid = this.wind;
  322. }
  323. } else {
  324. params = {
  325. id: this.route.id,
  326. begin: this.route.ts ? this.route.ts : this.begin,
  327. end: this.route.endts ? this.route.endts : this.end,
  328. alarmType: this.route.alarmType
  329. ? this.route.alarmType
  330. : this.alarmType,
  331. stationid: this.station,
  332. description: this.description,
  333. pageNum: this.page.currentPage,
  334. pageSize: this.page.pagesize,
  335. };
  336. if (this.alarmType != "booststation") {
  337. params.deviceid = this.wind;
  338. params.stationid = this.station;
  339. } else {
  340. params.stationid = this.sub;
  341. }
  342. }
  343. GetTableData(params).then(({ data }) => {
  344. this.loading = false;
  345. if (data.ls.length) {
  346. this.alarmData = data.ls.map((item) => {
  347. return {
  348. ...item,
  349. confirmed: item.confirmed ? "是" : "否",
  350. ts: dayjs(item.ts).format("YYYY-MM-DD HH:mm:ss"),
  351. };
  352. });
  353. this.page.total = data.total;
  354. } else {
  355. this.alarmData = [];
  356. this.page.total = 0;
  357. }
  358. });
  359. },
  360. alarmTypeChanged(val) {
  361. this.alarmType = val;
  362. this.page.currentPage = 1;
  363. if (val != "booststation") {
  364. this.GetWpOptions(0);
  365. } else {
  366. this.GetSubOptions(0);
  367. }
  368. },
  369. subChanged(val) {
  370. this.sub = val;
  371. this.page.currentPage = 1;
  372. this.getTableData(0);
  373. },
  374. stationChanged(val) {
  375. this.station = val;
  376. this.wind = "";
  377. this.page.currentPage = 1;
  378. this.GetWtOptions(0);
  379. this.getTableData(0);
  380. },
  381. windChanged(val) {
  382. this.wind = val;
  383. this.page.currentPage = 1;
  384. this.getTableData(0);
  385. },
  386. handleCurrentChange(val) {
  387. this.page.currentPage = val;
  388. this.getTableData();
  389. },
  390. },
  391. watch: {
  392. $route: {
  393. handler(val) {
  394. if (val.query && Object.keys(val.query).length) {
  395. this.route.id = val.query.id;
  396. this.route.station = val.query.stationId;
  397. this.route.wind = val.query.deviceId;
  398. this.route.ts = dayjs(Number(val.query.ts)).format(
  399. "YYYY-MM-DD HH:mm:ss"
  400. );
  401. this.route.endts = val.query.endts
  402. ? dayjs(Number(val.query.endts)).format("YYYY-MM-DD HH:mm:ss")
  403. : "";
  404. this.alarmType = val.query.alarmType;
  405. this.begin = this.route.ts;
  406. this.end = this.route.endts
  407. ? this.route.endts
  408. : dayjs().format("YYYY-MM-DD HH:mm:ss");
  409. if (!val.query.deviceId) {
  410. this.GetSubOptions(1);
  411. } else {
  412. this.GetWpOptions(1);
  413. }
  414. } else {
  415. this.route = { station: "", wind: "", ts: "", endts: "" };
  416. this.GetWpOptions(0);
  417. }
  418. },
  419. immediate: true,
  420. deep: true,
  421. },
  422. },
  423. };
  424. </script>
  425. <style scoped lang="less">
  426. .alarm-body {
  427. height: 100%;
  428. width: 100%;
  429. padding: 20px;
  430. display: flex;
  431. flex-direction: column;
  432. .search-form {
  433. display: flex;
  434. align-items: center;
  435. font-size: 14px;
  436. color: #b3b3b3;
  437. .select-form {
  438. display: flex;
  439. align-items: center;
  440. .select-item {
  441. margin-right: 10px;
  442. white-space: nowrap;
  443. display: flex;
  444. align-items: center;
  445. }
  446. }
  447. .btns {
  448. align-items: center;
  449. display: flex;
  450. .buttons {
  451. background-color: rgba(5, 187, 76, 0.2);
  452. border: 1px solid #3b6c53;
  453. color: #b3b3b3;
  454. font-size: 14px;
  455. &:hover,
  456. &.active {
  457. background-color: rgba(5, 187, 76, 0.5);
  458. color: #ffffff;
  459. }
  460. }
  461. }
  462. }
  463. .alarm-list {
  464. margin-top: 15px;
  465. height: calc(100% - 45px);
  466. .line {
  467. display: flex;
  468. flex-direction: row;
  469. align-items: center;
  470. justify-content: space-between;
  471. width: 100%;
  472. .left-content {
  473. width: 242px;
  474. height: 41px;
  475. display: flex;
  476. align-items: center;
  477. background: url("~@/assets/imgs/title_left_bg1.png") no-repeat;
  478. span {
  479. font-size: 16px;
  480. font-family: Microsoft YaHei;
  481. font-weight: 400;
  482. color: #05bb4c;
  483. margin-left: 25px;
  484. }
  485. }
  486. }
  487. .economicTable {
  488. height: calc(100% - 45px);
  489. .el-pagination {
  490. text-align: right;
  491. }
  492. }
  493. }
  494. }
  495. ::v-deep {
  496. input::placeholder {
  497. text-align: left;
  498. }
  499. }
  500. </style>