TitleBar.vue 8.9 KB

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