TitleBar.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  1. /* 标题栏 */
  2. <template>
  3. <div class="title-bar" onselectstart="return false">
  4. <el-row>
  5. <el-col :span="2">
  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="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" :label-width="formLabelWidth">
  23. </el-form-item>
  24. <el-form-item label="用户名:" :label-width="formLabelWidth">
  25. <el-input
  26. v-model="form.name"
  27. autocomplete="off"
  28. type="text"
  29. placeholder="用户名"
  30. style="width: 80%"
  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. ><template #append
  55. ><img
  56. src="../../src\assets\logo.png"
  57. style="width: 50px; height: 20px" /></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. <el-popover
  76. placement="bottom"
  77. :width="521"
  78. trigger="hover"
  79. class="popoverBack"
  80. :show-arrow="false"
  81. visible-arrow="false"
  82. v-model="popovermodel"
  83. >
  84. <ul>
  85. <li>编辑</li>
  86. <li>注销</li>
  87. </ul>
  88. </el-popover>
  89. </div>
  90. </el-col>
  91. <el-col :span="2.3">
  92. <div class="titleinfo">
  93. <ul>
  94. <li>
  95. <TitleBarCard
  96. title="装机容量"
  97. unit="MW"
  98. :value="installedCapacity"
  99. ></TitleBarCard>
  100. </li>
  101. </ul>
  102. </div>
  103. </el-col>
  104. <el-col :span="2.3">
  105. <div class="titleinfo">
  106. <ul>
  107. <li>
  108. <TitleBarCard
  109. title="实时功率"
  110. unit="MW"
  111. :value="totalPower"
  112. ></TitleBarCard>
  113. </li>
  114. </ul>
  115. </div>
  116. </el-col>
  117. <el-col :span="2.3">
  118. <div class="titleinfo">
  119. <ul>
  120. <li>
  121. <TitleBarCard
  122. title="日发电量"
  123. unit="kWh"
  124. :value="dailyPowerGeneration"
  125. ></TitleBarCard>
  126. </li>
  127. </ul>
  128. </div>
  129. </el-col>
  130. <el-col :span="2.3">
  131. <div class="titleinfo">
  132. <ul>
  133. <li>
  134. <TitleBarCard
  135. title="上网电量"
  136. unit="kWh"
  137. :value="gridPower"
  138. ></TitleBarCard>
  139. </li>
  140. </ul>
  141. </div>
  142. </el-col>
  143. <el-col :span="2.3">
  144. <div class="titleinfo">
  145. <ul>
  146. <li>
  147. <TitleBarCard
  148. title="月发电量"
  149. unit="kWh"
  150. :value="monthlyPowerGeneration"
  151. ></TitleBarCard>
  152. </li>
  153. </ul>
  154. </div>
  155. </el-col>
  156. <el-col :span="2.3">
  157. <div class="titleinfo">
  158. <ul>
  159. <li>
  160. <TitleBarCard
  161. title="年发电量"
  162. unit="kWh"
  163. :value="annualPowerGeneration"
  164. ></TitleBarCard>
  165. </li>
  166. </ul>
  167. </div>
  168. </el-col>
  169. <el-col :span="2.3">
  170. <div class="titleinfo">
  171. <ul>
  172. <li>
  173. <TitleBarCard
  174. title="月利用小时"
  175. unit="小时"
  176. :value="monthlyUtilizationHours"
  177. ></TitleBarCard>
  178. </li>
  179. </ul>
  180. </div>
  181. </el-col>
  182. <el-col :span="2.3">
  183. <div class="titleinfo">
  184. <ul>
  185. <li>
  186. <TitleBarCard
  187. title="年利用小时"
  188. unit="小时"
  189. :value="annualUtilizationHours"
  190. ></TitleBarCard>
  191. </li>
  192. </ul>
  193. </div>
  194. </el-col>
  195. <el-col :span="1.6">
  196. <div @click="userClick" @mouseover="popovermodel=false" style="top: 18px; right: 100px; color: #ffffff; position: absolute">{{usreName}}</div>
  197. <!-- <el-button
  198. v-popover:loginref
  199. type="text"
  200. @click="dialogVisible = true"
  201. style="top:9px;right: 85px;color: #ffffff;position: absolute;">管理员</el-button> -->
  202. </el-col>
  203. <el-col :span="1">
  204. <div style="margin-top: 7px; position: absolute; right: 10px">
  205. <button class="closeButton" v-on:click="mainClose">×</button>
  206. </div>
  207. </el-col>
  208. </el-row>
  209. </div>
  210. </template>
  211. <script>
  212. import TitleBarCard from "./area/mainwindow/TitleBarCard.vue";
  213. import BackgroundData from "../assets/script/BackgroundData";
  214. export default {
  215. name: "TitleBar",
  216. components: {
  217. TitleBarCard,
  218. },
  219. data() {
  220. return {
  221. popovermodel: false,
  222. dialogVisible: false,
  223. dialogFormVisible: false,
  224. form: {
  225. name: "",
  226. psd: "",
  227. },
  228. usreName:"未登录...",
  229. loginMessage: "", // 登录提示
  230. formLabelWidth: "120px",
  231. totalPower: 0, // 实时功率
  232. dailyPowerGeneration: 0, // 日发电量
  233. gridPower: 0, // 上网电量
  234. monthlyPowerGeneration: 0, // 月发电量
  235. annualPowerGeneration: 0, // 年发电量
  236. installedCapacity: 734, // 装机容量
  237. };
  238. },
  239. computed: {
  240. monthlyUtilizationHours: function () {
  241. // 月利用小时数
  242. return (
  243. (this.monthlyPowerGeneration * 10) /
  244. this.installedCapacity
  245. ).toFixed(2);
  246. },
  247. annualUtilizationHours: function () {
  248. // 年利用小时数
  249. return (
  250. (this.annualPowerGeneration * 10) /
  251. this.installedCapacity
  252. ).toFixed(2);
  253. },
  254. },
  255. created() {
  256. this.refreshTimer = setInterval(this.refreshData, 2000);
  257. },
  258. methods: {
  259. handleClose(done) {
  260. done();
  261. },
  262. mainClose() {
  263. const { remote } = require("electron");
  264. remote.getCurrentWindow().destroy();
  265. },
  266. refreshData() {
  267. // todo 计算发电量的时候没有考虑光伏的,后续完善
  268. var bd = BackgroundData.getInstance();
  269. var val = bd.TopPoint;
  270. for (var v in val) {
  271. var pt = val[v];
  272. if (pt.pointName == "TotalPower") {
  273. this.totalPower = pt.value.toFixed(2);
  274. } else if (pt.pointName == "DailyPowerGeneration") {
  275. this.dailyPowerGeneration = pt.value.toFixed(2);
  276. } else if (pt.pointName == "GridPower") {
  277. this.gridPower = pt.value.toFixed(2);
  278. } else if (pt.pointName == "MonthlyPowerGeneration") {
  279. this.monthlyPowerGeneration = pt.value.toFixed(2);
  280. } else if (pt.pointName == "AnnualPowerGeneration") {
  281. this.annualPowerGeneration = pt.value.toFixed(2);
  282. }
  283. }
  284. },
  285. /* 登录 */
  286. login() {
  287. var bd = BackgroundData.getInstance();
  288. this.loginMessage='正在登录...';
  289. bd.login(this.form.name,this.form.psd,this.onLoged);
  290. },
  291. onLoged(msg){
  292. if(!msg.data){
  293. this.loginMessage=msg;
  294. return;
  295. }
  296. var user = msg.data;
  297. if(!user.isValid){
  298. this.loginMessage=user.message;
  299. return;
  300. }
  301. BackgroundData.getInstance().LoginUser=user;
  302. this.usreName=user.name;
  303. this.dialogVisible = false;
  304. this.loginMessage='';
  305. this.form.name=this.form.psd='';
  306. },
  307. /* 用户点击 */
  308. userClick() {
  309. this.dialogVisible = true;
  310. },
  311. },
  312. };
  313. </script>
  314. <style scoped>
  315. .title-bar {
  316. height: 6vh;
  317. background-color: #000000;
  318. margin-top: 0;
  319. margin-right: 0;
  320. margin-left: 0;
  321. }
  322. .logo {
  323. position: relative;
  324. top: 33%;
  325. }
  326. .titleinfo {
  327. background-color: rgb(20, 20, 20);
  328. height: auto;
  329. padding: 13px;
  330. border-radius: 6px;
  331. margin-top: 5px;
  332. margin-bottom: 5px;
  333. margin-left: -9px;
  334. }
  335. .closeButton {
  336. font-size: 30px;
  337. color: white;
  338. background: rgb(41, 41, 41);
  339. width: 44px;
  340. height: 44px;
  341. border-radius: 8px;
  342. border: none;
  343. }
  344. </style>