login.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <div style="width: 100%; overflow-y: auto; background-color: white">
  3. <sticky class-name="sub-navbar2" v-if="activeIndex==1 || activeIndex==2">
  4. <div class="top-wrapper">
  5. <router-link to="/">
  6. <img src="../assets/img/title_gongfang.png" style="height:35px; margin-top: 5px;">
  7. </router-link>
  8. <div style="float: right;">
  9. <router-link :to="'/signup'">
  10. <el-button type="text" round>没有账户?请注册</el-button>
  11. </router-link>
  12. <el-button type="info" size="small" round @click="activeIndex=0">登录系统</el-button>
  13. </div>
  14. </div>
  15. </sticky>
  16. <div v-if="activeIndex==0">
  17. <div class="top-wrapper">
  18. <img src="../assets/img/title_login.png" style="height:100px; margin-top: 2px;">
  19. </div>
  20. <div class="back-width">
  21. <div class="login-body">
  22. <section class="login">
  23. <!--<header class="login-header">
  24. <h1 style="text-align:center;margin-top:70px;margin-bottom:40px;"><router-link to="/"><img src="../assets/img/logo.png" style="height:80px;"></router-link></h1>
  25. <el-alert v-if="error" :title="error.title" type="warning" :description="error.message" show-icon/>
  26. </header>-->
  27. <el-card class="box-card">
  28. <!--<div slot="header" class="clearfix">
  29. <span style="font-weight: bold;">用户登录</span>
  30. </div>-->
  31. <el-menu size="small" :default-active="activeIndex+''" @select="handleSelect" mode="horizontal">
  32. <el-menu-item index="0">
  33. <i class="el-icon-tickets"></i>
  34. <span>登录</span>
  35. </el-menu-item>
  36. <el-menu-item index="1">
  37. <i class="el-icon-bell"></i>
  38. <span>通知中心</span>
  39. </el-menu-item>
  40. <el-menu-item index="2">
  41. <i class="el-icon-document"></i>
  42. <span>文件下载中心</span>
  43. </el-menu-item>
  44. </el-menu>
  45. <el-row>
  46. <!--<el-col :span="12">
  47. <div class="demo-image__placeholder">
  48. <div class="block">
  49. <img style="width: 280px; height: 280px; margin-top: 15px" src="../assets/img/login_left.png" />
  50. </div>
  51. </div>
  52. </el-col>-->
  53. <el-col :span="24">
  54. <el-form
  55. class="login-form"
  56. auto-complete="off"
  57. :model="model"
  58. :rules="rules"
  59. ref="user"
  60. label-position="top"
  61. >
  62. <el-form-item label="用户名" prop="username">
  63. <el-input type="text" v-model="model.username" placeholder="请输入用户名">
  64. <el-select
  65. v-model="loginMode"
  66. slot="append"
  67. placeholder="登录类型"
  68. style="width: 110px;"
  69. >
  70. <el-option label="PTR认证" :value="2"></el-option>
  71. <el-option label="普通账户" :value="1"></el-option>
  72. </el-select>
  73. </el-input>
  74. </el-form-item>
  75. <el-form-item label="密码" prop="password">
  76. <el-input
  77. type="password"
  78. v-model="model.password"
  79. placeholder="请输入密码"
  80. @keyup.enter.native="loginall()"
  81. />
  82. </el-form-item>
  83. <el-button
  84. type="primary"
  85. :loading="loading"
  86. @click="loginall()"
  87. >{{ loading ? '登录中...' : '登录' }}</el-button>
  88. <el-row>
  89. <el-col :span="12">
  90. <router-link :to="'/signup'">
  91. <el-button type="text" round>没有账户?请注册</el-button>
  92. </router-link>
  93. </el-col>
  94. <el-col :span="12">
  95. <router-link :to="'/passwordback'">
  96. <el-button type="text" round>忘记密码?</el-button>
  97. </router-link>
  98. </el-col>
  99. </el-row>
  100. </el-form>
  101. </el-col>
  102. </el-row>
  103. </el-card>
  104. </section>
  105. </div>
  106. </div>
  107. </div>
  108. <div v-if="activeIndex==1">
  109. <div
  110. class="components-container home-wrapper"
  111. style="background-color: white;">
  112. <el-table
  113. :data="noticeList"
  114. height="50%"
  115. style="width: 100%; height: 100vh;"
  116. >
  117. <el-table-column prop="Name" label="通知标题">
  118. <template slot-scope="scope">
  119. <!--<i class="el-icon-caret-right"></i>-->
  120. <el-link :href="getDownloadFile(scope.row.FileURL)" target="_blank" type="primary">{{ scope.row.Name }}</el-link>
  121. </template>
  122. </el-table-column>
  123. <el-table-column prop="CreateOn" label="时间" width="141">
  124. <template slot-scope="scope">{{ jstimehandle(scope.row.CreateOn+'') }}</template>
  125. </el-table-column>
  126. </el-table>
  127. </div>
  128. </div>
  129. <div v-if="activeIndex==2">
  130. <div
  131. class="components-container home-wrapper"
  132. style="background-color: white">
  133. <el-table
  134. :data="fileList"
  135. height="50%"
  136. style="width: 100%; height: 100vh;"
  137. >
  138. <el-table-column prop="Name" label="文件名">
  139. <template slot-scope="scope">
  140. <!--<i class="el-icon-caret-right"></i>-->
  141. <el-link :href="getDownloadFile(scope.row.FileURL)" target="_blank" type="primary">{{ scope.row.Name }}</el-link>
  142. </template>
  143. </el-table-column>
  144. <el-table-column prop="CreateOn" label="时间" width="141">
  145. <template slot-scope="scope">{{ jstimehandle(scope.row.CreateOn+'') }}</template>
  146. </el-table-column>
  147. </el-table>
  148. </div>
  149. </div>
  150. <div>
  151. <footer class="login-footer" style="color:#A9A9A9">
  152. ©企业法规处 版权所有
  153. </footer>
  154. </div>
  155. <!--<div>
  156. <footer class="login-footer1">
  157. <div
  158. class="foot-wrapper"
  159. style="height: 30px; background-color: transparent; color:#A9A9A9; padding-top: 10px; text-align: right"
  160. >©企管法规处 版权所有</div>
  161. </footer>
  162. </div>-->
  163. </div>
  164. </template>
  165. <script>
  166. import Vue from "vue";
  167. import Component from "class-component";
  168. import Sticky from "@/components/Sticky";
  169. import api from "@/api/rtxservice/rtx";
  170. @Component({
  171. data() {
  172. // form model
  173. // TODO: remove default values
  174. const model = {
  175. username: "",
  176. password: ""
  177. };
  178. // form validate rules
  179. const rules = {
  180. username: [
  181. {
  182. required: true,
  183. message: "请输入用户名"
  184. }
  185. ],
  186. password: [
  187. {
  188. required: true,
  189. message: "请输入密码"
  190. }
  191. ]
  192. };
  193. return {
  194. loginMode: 2,
  195. model: model,
  196. rules: rules,
  197. error: null,
  198. loading: false,
  199. noticeList: [], //通知列表
  200. fileList: [], //文档列表
  201. activeName: "first",
  202. activeIndex: "0",
  203. flag: 0
  204. };
  205. },
  206. created() {
  207. this.initNoticeListData();
  208. this.initFileListData();
  209. },
  210. components: {
  211. Sticky
  212. },
  213. methods: {
  214. //获取通知列表
  215. initNoticeListData() {
  216. let _this = this;
  217. //传递列名
  218. const params = {
  219. colName: "NoticeTab"
  220. };
  221. _this.$axios
  222. .get("/document/getdocumentnameandtime", { params })
  223. .then(function(response) {
  224. _this.noticeList = response.data;
  225. })
  226. .catch(function(error) {
  227. console.log(error);
  228. });
  229. },
  230. //获取文件列表
  231. initFileListData() {
  232. let _this = this;
  233. //传递列名
  234. const params = {
  235. colName: "DocTab"
  236. };
  237. _this.$axios
  238. .get("/document/getdocumentnameandtime", { params })
  239. .then(function(response) {
  240. _this.fileList = response.data;
  241. })
  242. .catch(function(error) {
  243. console.log(error);
  244. });
  245. },
  246. //下载文件
  247. DownloadFile(row) {
  248. let val = row.FileURL;
  249. let urlArr = val.split("|");
  250. location.href = "http://" + urlArr[0];
  251. },
  252. getDownloadFile(val) {
  253. let urlArr = val.split("|")
  254. let retUrl = urlArr[0]
  255. //内网服务器专用
  256. if (process.client && retUrl.indexOf('/upfile') === 0) {
  257. const myDomain = window.location.host
  258. retUrl = myDomain + '/' + retUrl
  259. }
  260. return "http://" + retUrl
  261. },
  262. //格式化时间
  263. jstimehandle(val) {
  264. if (val === "") {
  265. return "----";
  266. } else if (val === "0001-01-01T08:00:00+08:00") {
  267. return "----";
  268. } else if (val === "5000-01-01T23:59:59+08:00") {
  269. return "永久";
  270. } else {
  271. val = val.replace("T", " ");
  272. return val.substring(0, 10);
  273. }
  274. },
  275. handleSelect(key, keyPath) {
  276. this.activeIndex = key;
  277. },
  278. isChrome() {
  279. //取得浏览器的userAgent字符串
  280. let userAgent = navigator.userAgent;
  281. //判断是否Chrome浏览器
  282. if (userAgent.indexOf("Chrome") > -1) {
  283. return true;
  284. } else {
  285. return false;
  286. }
  287. },
  288. loginall() {
  289. if (this.loginMode == 1) {
  290. this.login();
  291. } else {
  292. this.loginptr();
  293. }
  294. },
  295. loginptr() {
  296. let params = {
  297. username: this.model.username,
  298. password: this.model.password
  299. };
  300. api
  301. .rtxLogin(params, this.$axios)
  302. .then(res => {
  303. if (res.data.items === 1) {
  304. this.flag = 1;
  305. this.login();
  306. } else if (res.data.items === 2) {
  307. this.flag = 2;
  308. this.login();
  309. }else if (res.data.items === 3) {
  310. this.$message.warning("您无权限登陆本系统");
  311. }else {
  312. this.$message.warning("账号或密码错误");
  313. }
  314. })
  315. .catch(err => {
  316. this.$message.warning("账号或密码错误");
  317. console.error(err);
  318. });
  319. }
  320. }
  321. })
  322. export default class Login extends Vue {
  323. layout() {
  324. return "empty";
  325. }
  326. login() {
  327. if (!this.isChrome()) {
  328. this.$alert(
  329. "请用谷歌浏览器、360浏览器(极速模式)等,Chrome内核浏览器打开本系统",
  330. "不支持的浏览器",
  331. {}
  332. );
  333. return false;
  334. }
  335. this.logging = true;
  336. this.$refs.user.validate(async valid => {
  337. try {
  338. if (valid) {
  339. await this.$store.dispatch("auth/login", {
  340. fields: {
  341. username: this.model.username.replace(/(^\s*)|(\s*$)/g, ""),
  342. password: this.model.password.replace(/(^\s*)|(\s*$)/g, ""),
  343. flag: this.flag
  344. }
  345. });
  346. if (process.env.appclient == "lims") {
  347. this.$router.push(this.$route.query.page || "/");
  348. } else if (process.env.appclient == "cellbank") {
  349. this.$router.push(this.$route.query.page || "/indexdqm");
  350. } else {
  351. this.$router.push(this.$route.query.page || "/");
  352. }
  353. }
  354. } catch (e) {
  355. if(e.response.status==777){
  356. this.$message.warning("您无权限登录本系统");
  357. }else{
  358. this.$message.warning("账号或密码错误");
  359. }
  360. } finally {
  361. this.logging = false;
  362. }
  363. });
  364. }
  365. logout() {
  366. this.$store.dispatch("logout");
  367. }
  368. }
  369. </script>
  370. <style lang="scss" scoped>
  371. @import "../assets/styles/base/variables";
  372. .components-container div {
  373. margin-top: 20px;
  374. }
  375. .top-wrapper {
  376. margin: 0px auto;
  377. width: 1004px;
  378. /*text-align: right;
  379. alignment: right;*/
  380. flex-direction: row;
  381. }
  382. .home-wrapper {
  383. margin: 0px auto;
  384. width: 1004px;
  385. flex-direction: column;
  386. margin-bottom: 45px;
  387. }
  388. .foot-wrapper {
  389. margin: 0px auto;
  390. width: 1004px;
  391. display: flex;
  392. alignment: center;
  393. align-items: center;
  394. flex-direction: column;
  395. }
  396. .back-width1 {
  397. background-color: #2f79f6;
  398. margin: 0px auto;
  399. left: 0;
  400. right: 0;
  401. top: 20px;
  402. width: 1004px;
  403. }
  404. .login-footer1 {
  405. position: fixed;
  406. background-color: #34393d;
  407. font-size: 10px;
  408. clear: both;
  409. display: block;
  410. text-align: center;
  411. margin: 0px auto;
  412. bottom: 0px;
  413. width: 100%;
  414. }
  415. /*-----------*/
  416. .time {
  417. font-size: 13px;
  418. color: #999;
  419. }
  420. .bottom {
  421. margin-top: 13px;
  422. line-height: 12px;
  423. }
  424. .button {
  425. padding: 0;
  426. float: right;
  427. }
  428. .image {
  429. width: 100%;
  430. display: block;
  431. }
  432. .clearfix:before,
  433. .clearfix:after {
  434. display: table;
  435. content: "";
  436. }
  437. .clearfix:after {
  438. clear: both;
  439. }
  440. .back-width {
  441. background-color: white;
  442. position: fixed;
  443. margin: auto;
  444. left: 0;
  445. right: 0;
  446. top: 100px;
  447. width: 100%;
  448. height: 520px;
  449. }
  450. .login-body {
  451. background: url("../assets/img/gf.png") no-repeat left;
  452. font-family: "Open Sans", sans-serif;
  453. background-color: white; /*#3273FC*/
  454. background-size: cover;
  455. /*background-size: cover;
  456. -webkit-background-size: cover;
  457. -moz-background-size: cover;
  458. -o-background-size: cover;*/
  459. /*min-height: 1050px;*/
  460. position: absolute;
  461. margin: auto;
  462. left: 0px;
  463. right: 0;
  464. top: 0;
  465. width: 100%;
  466. height: 520px;
  467. /*margin: auto;
  468. left: 0px;
  469. top: 0px;
  470. right: 0;
  471. bottom: 0;
  472. width: 100%;
  473. height: calc(100vh - 40px);*/
  474. }
  475. .login-footer {
  476. font-size: 10px;
  477. clear: both;
  478. display: block;
  479. text-align: center;
  480. margin: 0px auto;
  481. position: absolute;
  482. bottom: 10px;
  483. width: 100%;
  484. a {
  485. color: $brand-color;
  486. }
  487. }
  488. .login {
  489. /*flex: 1;
  490. width: 100%;*/
  491. position: relative;
  492. max-width: 27rem;
  493. top: 40px;
  494. left: 50%;
  495. margin-left: 100px;
  496. font-size: 0.875rem;
  497. opacity: 0.9;
  498. &-header {
  499. margin-bottom: 1rem;
  500. .brand {
  501. margin: 4.5rem 0 3.5rem;
  502. text-align: center;
  503. letter-spacing: 0.125rem;
  504. a {
  505. margin: 0;
  506. color: $brand-color;
  507. font: 300 3rem sans-serif;
  508. &:hover {
  509. color: $brand-hover-color;
  510. text-shadow: 0 0 1rem $brand-hover-color;
  511. }
  512. }
  513. }
  514. }
  515. &-form {
  516. /*margin-bottom: 2.5rem;
  517. padding: 1.875rem 1.25rem;
  518. background: $login-form-background;*/
  519. color: $login-form-color;
  520. /*.heading {
  521. margin: 0 0 1rem;
  522. font-weight: 400;
  523. font-size: 1.5rem;
  524. }*/
  525. .el-button {
  526. margin-top: 0.5rem;
  527. width: 100%;
  528. }
  529. }
  530. }
  531. </style>