TitleBar.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529
  1. /* 标题栏 */
  2. <template>
  3. <div class="title-bar" onselectstart="return false">
  4. <el-row>
  5. <el-col :span="3">
  6. <img
  7. class="logo"
  8. src="../assets/img/main_window/logo.png"
  9. sytle="align-items"
  10. />
  11. </el-col>
  12. <el-col :span="0.1">
  13. <div>
  14. <el-dialog
  15. title="用户登录"
  16. v-model="dialogVisible"
  17. width="21%"
  18. :before-close="handleClose"
  19. :show-close="false"
  20. >
  21. <el-form :model="form">
  22. <el-form-item :label="loginMessage"> </el-form-item>
  23. <el-form-item label="用户名:" :label-width="formLabelWidth">
  24. <el-input
  25. v-model="form.name"
  26. autocomplete="off"
  27. type="text"
  28. placeholder="用户名"
  29. style="width: 80%"
  30. >
  31. </el-input>
  32. </el-form-item>
  33. <el-form-item label="密&emsp;码:" :label-width="formLabelWidth">
  34. <el-input
  35. v-model="form.psd"
  36. autocomplete="off"
  37. type="text"
  38. placeholder="密&emsp;码"
  39. style="width: 80%"
  40. show-password
  41. ></el-input>
  42. </el-form-item>
  43. <el-form-item
  44. label="验证码:"
  45. :label-width="formLabelWidth"
  46. style="display: none"
  47. >
  48. <el-input
  49. v-model="form.name"
  50. autocomplete="off"
  51. type="text"
  52. placeholder="验证码"
  53. style="width: 80%"
  54. >
  55. <template #append
  56. ><img src="" style="width: 50px; height: 20px"
  57. /></template>
  58. </el-input>
  59. </el-form-item>
  60. </el-form>
  61. <template #footer>
  62. <span class="dialog-footer">
  63. <el-button
  64. @click="dialogVisible = false"
  65. style="
  66. background-color: rgb(100, 100, 100);
  67. color: rgb(220, 220, 220);
  68. "
  69. >取 消</el-button
  70. >
  71. <el-button type="primary" @click="login">登 录</el-button>
  72. </span>
  73. </template>
  74. </el-dialog>
  75. </div>
  76. </el-col>
  77. <el-col :span="19" style="margin-left: 90px">
  78. <div class="titleinfoall">
  79. <div class="titleinfo" @dblclick="dbClicks(titleInfo.dailyPowerGeneration, '日发电量')">
  80. <span class="showTitle fontSty1">日发电量:</span>
  81. <span class="showvalue">{{
  82. titleInfo.dailyPowerGeneration?.value?.toFixed(2)
  83. }}</span>
  84. <span class="showTitle fontSty">万kW/h</span>
  85. </div>
  86. <div class="titleinfo" @dblclick="dbClicks(titleInfo.powerLossFault, '故障损失')" >
  87. <span class="showTitle fontSty1">故障损失:</span>
  88. <span
  89. :class="
  90. titleInfo.powerLossFault
  91. ? titleInfo.powerLossFault.trend === 'Counterpoise'
  92. ? 'showvalue'
  93. : titleInfo.powerLossFault.trend === 'Rise'
  94. ? 'showvalue-up'
  95. : 'showvalue-down'
  96. : ''
  97. "
  98. >{{ titleInfo.powerLossFault?.value.toFixed(2) }}</span
  99. >
  100. <span class="showTitle fontSty">万kW/h</span>
  101. </div>
  102. <div class="titleinfo" @dblclick="dbClicks(titleInfo.powerLossRestrictions, '限电损失')" >
  103. <span class="showTitle fontSty1">限电损失:</span>
  104. <span
  105. :class="
  106. titleInfo.powerLossRestrictions
  107. ? titleInfo.powerLossRestrictions.trend === 'Counterpoise'
  108. ? 'showvalue'
  109. : titleInfo.powerLossRestrictions.trend === 'Rise'
  110. ? 'showvalue-up'
  111. : 'showvalue-down'
  112. : ''
  113. "
  114. >{{ titleInfo.powerLossRestrictions?.value.toFixed(2) }}</span
  115. >
  116. <span class="showTitle fontSty">万kW/h</span>
  117. </div>
  118. <div class="titleinfo" @dblclick="dbClicks(titleInfo.powerLossInspection, '检修损失')" >
  119. <span class="showTitle fontSty1">检修损失:</span>
  120. <span
  121. :class="
  122. titleInfo.powerLossInspection
  123. ? titleInfo.powerLossInspection.trend === 'Counterpoise'
  124. ? 'showvalue'
  125. : titleInfo.powerLossInspection.trend === 'Rise'
  126. ? 'showvalue-up'
  127. : 'showvalue-down'
  128. : ''
  129. "
  130. >{{ titleInfo.powerLossInspection?.value.toFixed(2) }}</span
  131. >
  132. <span class="showTitle fontSty">万kW/h</span>
  133. </div>
  134. <div class="titleinfo" @dblclick="dbClicks(titleInfo.powerLossBurden, '受累损失')" >
  135. <span class="showTitle fontSty1">受累损失:</span>
  136. <span
  137. :class="
  138. titleInfo.powerLossBurden
  139. ? titleInfo.powerLossBurden.trend === 'Counterpoise'
  140. ? 'showvalue'
  141. : titleInfo.powerLossBurden.trend === 'Rise'
  142. ? 'showvalue-up'
  143. : 'showvalue-down'
  144. : ''
  145. "
  146. >{{ titleInfo.powerLossBurden?.value.toFixed(2) }}</span
  147. >
  148. <span class="showTitle fontSty">万kW/h</span>
  149. </div>
  150. <div class="titleinfo" @dblclick="dbClicks(titleInfo.powerLossPerformance, '性能损失')" >
  151. <span class="showTitle fontSty1">性能损失:</span>
  152. <span
  153. :class="
  154. titleInfo.powerLossPerformance
  155. ? titleInfo.powerLossPerformance.trend === 'Counterpoise'
  156. ? 'showvalue'
  157. : titleInfo.powerLossPerformance.trend === 'Rise'
  158. ? 'showvalue-up'
  159. : 'showvalue-down'
  160. : ''
  161. "
  162. >{{ titleInfo.powerLossPerformance?.value.toFixed(2) }}</span
  163. >
  164. <span class="showTitle fontSty">万kW/h</span>
  165. </div>
  166. <div class="titleinfo" @dblclick="dbClicks(titleInfo.fieldElectricity, '场用电量')">
  167. <span class="showTitle fontSty1">场用电量:</span>
  168. <span class="showvalue">{{
  169. titleInfo.fieldElectricity?.value.toFixed(2)
  170. }}</span>
  171. <span class="showTitle fontSty">万kW/h</span>
  172. </div>
  173. </div>
  174. </el-col>
  175. <el-col :span="1">
  176. <el-popover
  177. placement="bottom"
  178. :width="150"
  179. trigger="hover"
  180. :show-arrow="false"
  181. >
  182. <template #reference>
  183. <el-button
  184. @click="userClick"
  185. style="
  186. top: 10px;
  187. right: 70px;
  188. color: #ffffff;
  189. position: absolute;
  190. background-color: black;
  191. border: none;
  192. font-size: 16px;
  193. "
  194. >
  195. {{ usreName }}</el-button
  196. >
  197. </template>
  198. <div style="background-color: #363636">
  199. <!-- <el-button class="loginoption">编&emsp;辑</el-button> -->
  200. <el-button v-if="!isLogin" class="loginoption" @click="userClick"
  201. >登&emsp;录</el-button
  202. >
  203. <br v-if="!isLogin" />
  204. <el-button v-if="isLogin" class="loginoption" @click="logout"
  205. >注&emsp;销</el-button
  206. >
  207. </div>
  208. </el-popover>
  209. <div style="top: 7px; position: absolute; right: 10px">
  210. <button class="closeButton" v-on:click="mainClose">×</button>
  211. </div>
  212. </el-col>
  213. </el-row>
  214. <DataDetails
  215. @closed="closeds()"
  216. v-model="display"
  217. :datas="titleDetails"
  218. :partsName="partsName"
  219. echartsId="titleEcharts"
  220. @search-data="search"
  221. @original-data="originalData"
  222. ></DataDetails>
  223. </div>
  224. </template>
  225. <script>
  226. import BackgroundData from "utils/BackgroundData";
  227. import MessageBridge from "utils/MessageBridge";
  228. import DataDetails from "components/basicDataDetails.vue";
  229. import api from "api/index";
  230. import dayjs from "dayjs";
  231. export default {
  232. name: "TitleBar",
  233. components: {
  234. DataDetails,
  235. },
  236. data() {
  237. return {
  238. dialogVisible: false,
  239. dialogFormVisible: false,
  240. isLogin: false,
  241. form: {
  242. name: "",
  243. psd: "",
  244. },
  245. partsName: "",
  246. titleDetails: [],
  247. titleInfo: {},
  248. modelData: {},
  249. usreName: "未登录...",
  250. loginMessage: "", // 登录提示
  251. formLabelWidth: "120px",
  252. totalPower: 0, // 实时功率
  253. dailyPowerGeneration: 0, // 日发电量
  254. gridPower: 0, // 上网电量
  255. monthlyPowerGeneration: 0, // 月发电量
  256. annualPowerGeneration: 0, // 年发电量
  257. installedCapacity: 734, // 装机容量
  258. display: false,
  259. interval: 60,
  260. intervals: null,
  261. };
  262. },
  263. computed: {
  264. monthlyUtilizationHours: function () {
  265. // 月利用小时数
  266. return (
  267. (this.monthlyPowerGeneration * 10) /
  268. this.installedCapacity
  269. ).toFixed(2);
  270. },
  271. annualUtilizationHours: function () {
  272. // 年利用小时数
  273. return (
  274. (this.annualPowerGeneration * 10) /
  275. this.installedCapacity
  276. ).toFixed(2);
  277. },
  278. },
  279. created() {
  280. // this.refreshTimer = setInterval(this.refreshData, 2000);
  281. if (
  282. sessionStorage.getItem("ms_username") &&
  283. sessionStorage.getItem("ms_password")
  284. ) {
  285. this.form.name = sessionStorage.getItem("ms_username");
  286. this.form.psd = sessionStorage.getItem("ms_password");
  287. this.login();
  288. }
  289. this.titleInfos();
  290. this.intervals = setInterval(this.titleInfos, 10000);
  291. },
  292. methods: {
  293. titleInfos() {
  294. api.stationOverview().then((res) => {
  295. this.titleInfo = res.data;
  296. this.$store.commit("titleInfo", this.titleInfo);
  297. });
  298. },
  299. handleClose(done) {
  300. done();
  301. },
  302. mainClose() {
  303. const { remote } = require("electron");
  304. remote.getCurrentWindow().destroy();
  305. // remote.getCurrentWindow().minimize();
  306. },
  307. // refreshData() {
  308. // // todo 计算发电量的时候没有考虑光伏的,后续完善
  309. // let bd = BackgroundData.getInstance();
  310. // let val = bd.TopPoint;
  311. // for (let v in val) {
  312. // let pt = val[v];
  313. // if (pt.pointName == "TotalPower") {
  314. // this.totalPower = pt.value.toFixed(2);
  315. // } else if (pt.pointName == "DailyPowerGeneration") {
  316. // this.dailyPowerGeneration = pt.value.toFixed(2);
  317. // } else if (pt.pointName == "GridPower") {
  318. // this.gridPower = pt.value.toFixed(2);
  319. // } else if (pt.pointName == "MonthlyPowerGeneration") {
  320. // this.monthlyPowerGeneration = pt.value.toFixed(2);
  321. // } else if (pt.pointName == "AnnualPowerGeneration") {
  322. // this.annualPowerGeneration = pt.value.toFixed(2);
  323. // }
  324. // }
  325. // },
  326. /* 登录 */
  327. login() {
  328. // let bd = BackgroundData.getInstance();
  329. // this.loginMessage='正在登录...';
  330. // bd.login(this.form.name,this.form.psd,this.onLoged);
  331. api
  332. .login({
  333. username: this.form.name,
  334. password: this.form.psd,
  335. })
  336. .then((res) => {
  337. if (res) {
  338. this.onLoged(res);
  339. }
  340. });
  341. // api.login(this.form.name,this.form.psd,'11').then(res => {
  342. // if (res) {
  343. // this.onLoged(res)
  344. // }
  345. // })
  346. },
  347. onLoged(msg) {
  348. if (msg.status === 401) {
  349. this.loginMessage = msg.message;
  350. return;
  351. }
  352. sessionStorage.setItem("ms_username", this.form.name);
  353. sessionStorage.setItem("ms_password", this.form.psd);
  354. let user = msg.data;
  355. this.$store.commit("token", user.token);
  356. BackgroundData.getInstance().LoginUser = user;
  357. this.usreName = user.name;
  358. this.dialogVisible = false;
  359. this.loginMessage = "";
  360. this.form.name = this.form.psd = "";
  361. this.isLogin = true;
  362. },
  363. /* 用户点击 */
  364. userClick() {
  365. this.isLogin ? "" : (this.dialogVisible = true);
  366. },
  367. /* 用户注销 */
  368. logout() {
  369. BackgroundData.getInstance().LoginUser = null;
  370. this.usreName = "未登录...";
  371. this.isLogin = false;
  372. },
  373. dbClicks(data, partsName, timeValues) {
  374. this.modelData = data;
  375. let date = new Date();
  376. let endTs = timeValues
  377. ? timeValues[1] > date.getTime()
  378. ? date.getTime()
  379. : timeValues[1]
  380. : date.getTime();
  381. let startTs = timeValues ? timeValues[0] : endTs - 28800000;
  382. api
  383. .getPower({
  384. tagName: data.tag,
  385. startTs: startTs,
  386. endTs: endTs,
  387. interval: this.interval,
  388. })
  389. .then((res) => {
  390. if (res.data.length > 0) {
  391. this.partsName = partsName;
  392. this.display = true;
  393. this.titleDetails = res.data;
  394. } else {
  395. this.titleDetails = [];
  396. }
  397. });
  398. },
  399. original(data, partsName, timeValues) {
  400. this.modelData = data;
  401. let date = new Date();
  402. let endTs = timeValues
  403. ? timeValues[1] > date.getTime()
  404. ? date.getTime()
  405. : timeValues[1]
  406. : date.getTime();
  407. let startTs = timeValues ? timeValues[0] : endTs - 28800000;
  408. api
  409. .getOriginalPower({
  410. tagName: data.tag,
  411. startTs: startTs,
  412. endTs: endTs,
  413. })
  414. .then((res) => {
  415. if (res.data.length > 0) {
  416. this.partsName = partsName;
  417. this.display = true;
  418. this.titleDetails = res.data;
  419. } else {
  420. this.titleDetails = [];
  421. }
  422. });
  423. },
  424. search(values, interval) {
  425. this.interval = interval;
  426. this.dbClicks(this.modelData, this.partsName, values);
  427. },
  428. originalData(values) {
  429. this.original(this.modelData, this.partsName, values);
  430. },
  431. closeds() {
  432. this.display = false;
  433. this.interval = 60;
  434. },
  435. },
  436. unmounted() {
  437. clearInterval(this.intervals);
  438. this.intervals = null;
  439. },
  440. };
  441. </script>
  442. <style scoped>
  443. .loginoption {
  444. font-size: 16px;
  445. width: 150px;
  446. background-color: #292929;
  447. border: none;
  448. color: rgb(220, 220, 220);
  449. }
  450. .title-bar {
  451. /* height: 5vh; */
  452. background-color: #141414;
  453. margin-top: 0;
  454. margin-right: 0;
  455. margin-left: 0;
  456. }
  457. .logo {
  458. position: relative;
  459. top: 32%;
  460. margin-left: 30px;
  461. }
  462. .titleinfo {
  463. background-color: rgb(20, 20, 20);
  464. height: auto;
  465. width: auto;
  466. padding: 13px 8px;
  467. border-radius: 6px;
  468. margin-top: 5px;
  469. margin-bottom: 5px;
  470. margin-left: -9px;
  471. }
  472. .closeButton {
  473. font-size: 30px;
  474. color: white;
  475. background: rgb(41, 41, 41);
  476. width: 44px;
  477. height: 44px;
  478. border-radius: 8px;
  479. border: none;
  480. }
  481. .titleinfoall {
  482. display: flex;
  483. }
  484. .showTitle {
  485. color: #ffffff;
  486. margin-right: 10px;
  487. }
  488. .fontSty{
  489. font-size: 12px;
  490. }
  491. .fontSty1{
  492. font-weight: bold;;
  493. }
  494. .showvalue {
  495. color: #ffffff;
  496. font-size: 14px;
  497. font-weight: bold;
  498. margin-right: 10px;
  499. }
  500. .showvalue-down {
  501. color: #50ae56;
  502. font-size: 14px;
  503. font-weight: bold;
  504. margin-right: 10px;
  505. }
  506. .showvalue-up {
  507. color: red;
  508. font-size: 14px;
  509. font-weight: bold;
  510. margin-right: 10px;
  511. }
  512. </style>