index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  1. <template>
  2. <div class="login-container">
  3. <!-- 2025-01-13 gyf -->
  4. <!-- <div class="logo">-->
  5. <!-- <img v-if="isProd" class="img1" src="../../assets/images/logo.png" />-->
  6. <!-- <img v-else :src="login_logo" class="img2" />-->
  7. <!-- </div>-->
  8. <div class="right-panel-active container" id="container">
  9. <div class="overlay-container">
  10. <div class="overlay">
  11. <div class="overlay-panel overlay-left">
  12. <h1>欢迎使用</h1>
  13. <p>病案数据治理与服务平台</p>
  14. <img src="../../assets/images/login-sign-bg.png" alt="" class="overlay-left-img"/>
  15. </div>
  16. </div>
  17. </div>
  18. <!-- 登录 -->
  19. <div class="form-container sign-up-container">
  20. <p class="sign-title">病案数据治理与服务平台</p>
  21. <p class="sign-title-1">登录</p>
  22. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" :class="{prod: isProd}" auto-complete="on" label-position="left">
  23. <el-form-item>
  24. <span class="svg-container">
  25. <svg-icon icon-class="user" />
  26. </span>
  27. <el-input ref="username" v-model="loginForm.username" placeholder="请输入名称或账号" name="username" type="text" tabindex="1" auto-complete="on" />
  28. </el-form-item>
  29. <el-form-item prop="password">
  30. <span class="svg-container">
  31. <svg-icon icon-class="password" />
  32. </span>
  33. <el-input
  34. :key="passwordType"
  35. ref="password"
  36. v-model="loginForm.password"
  37. :type="passwordType"
  38. placeholder="请输入密码"
  39. name="password"
  40. tabindex="2"
  41. auto-complete="on"
  42. @keyup.enter.native="handleLogin"
  43. />
  44. <span class="show-pwd" @click="showPwd">
  45. <svg-icon :icon-class="passwordType === 'password' ? 'eye' : 'eye-open'" />
  46. </span>
  47. </el-form-item>
  48. <div class="checkbox-box">
  49. <el-checkbox v-model="checked">记住密码</el-checkbox>
  50. </div>
  51. <el-button :loading="loading" type="primary" class="submit-btn" @click.native.prevent="handleLogin">登录</el-button>
  52. </el-form>
  53. </div>
  54. <!-- 登录 -->
  55. </div>
  56. </div>
  57. </template>
  58. <script>
  59. import { validUsername } from '@/utils/validate';
  60. import menu from "@/menu/menu.js"
  61. export default {
  62. name: 'Login',
  63. data() {
  64. const validateUsername = (rule, value, callback) => {
  65. if (!validUsername(value)) {
  66. callback(new Error('请填写名称或账号!'));
  67. } else {
  68. callback();
  69. }
  70. };
  71. const validatePassword = (rule, value, callback) => {
  72. if (value.length == 0) {
  73. callback(new Error('密码不能为空!'));
  74. } else {
  75. callback();
  76. }
  77. };
  78. return {
  79. login_bg: require('../../assets/images/loginbj.jpg'),
  80. login_logo: require('../../assets/images/logo2.png'),
  81. loginForm: {
  82. username: '',
  83. password: '',
  84. },
  85. loginRules: {
  86. username: [{ required: true, trigger: 'blur', validator: validateUsername }],
  87. password: [{ required: true, trigger: 'blur', validator: validatePassword }],
  88. },
  89. loading: false,
  90. passwordType: 'password',
  91. redirect: undefined,
  92. preUrl: '',
  93. checked: false
  94. };
  95. },
  96. computed: {
  97. isProd() {
  98. return process.env.NODE_ENV === 'production'
  99. }
  100. },
  101. watch: {
  102. $route: {
  103. handler: function (route) {
  104. this.redirect = route.query && route.query.redirect;
  105. // this.preUrl = !!this.$route.query.preUrl ? this.$route.query.preUrl : sessionStorage.getItem('preUrl')
  106. this.preUrl = !!this.$route.query.preUrl ? this.$route.query.preUrl : undefined
  107. },
  108. immediate: true,
  109. },
  110. },
  111. created() {
  112. this.$nextTick(() => {
  113. // this.preUrl = !!this.$route.query.preUrl ? this.$route.query.preUrl : sessionStorage.getItem('preUrl')
  114. this.preUrl = !!this.$route.query.preUrl ? this.$route.query.preUrl : undefined
  115. })
  116. },
  117. methods: {
  118. showPwd() {
  119. if (this.passwordType === 'password') {
  120. this.passwordType = '';
  121. } else {
  122. this.passwordType = 'password';
  123. }
  124. this.$nextTick(() => {
  125. this.$refs.password.focus();
  126. });
  127. },
  128. handleLogin() {
  129. this.$refs.loginForm.validate(valid => {
  130. if (valid) {
  131. this.loading = true;
  132. this.$store.dispatch('user/login', this.loginForm).then(() => {
  133. this.loading = false;
  134. //获取权限菜单
  135. menu.getMenu().then( () =>{
  136. // const routes = JSON.parse(sessionStorage.getItem('route'))
  137. const routes = this.$store.state.user.menu
  138. let bSwitch = []
  139. for(let i=0; i<routes.length; i++) {
  140. if(routes[i].path === '/embedIndex') {
  141. bSwitch.push(2)
  142. } else if(routes[i].path === '/hospital') {
  143. bSwitch.push(1)
  144. } else if(routes[i].path === '/reviewIndex') {
  145. bSwitch.push(3)
  146. } else {
  147. bSwitch.push(0)
  148. }
  149. }
  150. if (this.preUrl) {
  151. if (this.preUrl === 'whitelist-search-specialty') {
  152. sessionStorage.setItem('preUrl', 'whitelist-search-specialty')
  153. this.$router.push({ path: '/whitelist-search-specialty', query: { from: 'kyts'} });
  154. return
  155. }
  156. if (bSwitch.includes(1) && this.preUrl === 'hospital') {
  157. sessionStorage.setItem('preUrl', 'hospital')
  158. this.$router.push({ path: '/hospital'});
  159. } else if (bSwitch.includes(2) && this.preUrl === 'embedIndex') {
  160. sessionStorage.setItem('preUrl', 'embedIndex')
  161. this.$router.push({ path: '/embedIndex' });
  162. } else if (bSwitch.includes(3) && this.preUrl === 'reviewIndex') {
  163. sessionStorage.setItem('preUrl', 'reviewIndex')
  164. this.$router.push({ path: '/reviewIndex' });
  165. } else {
  166. this.$message.error('没有页面权限,请联系管理员!')
  167. }
  168. } else {
  169. this.$router.push(this.redirect || '/');
  170. }
  171. }).catch((e) => {
  172. console.log(e)
  173. this.$message.error('获取导航菜单失败!');
  174. })
  175. }).catch(() => {
  176. this.loading = false;
  177. });
  178. } else {
  179. console.log('error submit!!');
  180. return false;
  181. }
  182. });
  183. },
  184. },
  185. };
  186. </script>
  187. <style lang="scss">
  188. /* 修复input 背景不协调 和光标变色 */
  189. /* Detail see https://github.com/PanJiaChen/vue-element-admin/pull/927 */
  190. $bg: #ffffff;
  191. $light_gray: #000;
  192. $cursor: #000;
  193. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  194. .login-container .el-input input {
  195. color: $cursor;
  196. }
  197. }
  198. /* reset element-ui css */
  199. .login-container {
  200. position: relative;
  201. .el-input {
  202. display: inline-block;
  203. width: 85%;
  204. input {
  205. background: transparent;
  206. border: 0px;
  207. -webkit-appearance: none;
  208. border-radius: 0px;
  209. padding: 12px 5px 12px 15px;
  210. color: $light_gray;
  211. caret-color: $cursor;
  212. &:-webkit-autofill {
  213. transition: background-color 50000s ease-in-out 0s;
  214. -webkit-text-fill-color: #454545; //记住密码的颜色
  215. caret-color: #454545;//改变输入框光标颜色,同时又不改变输入框里面的内容的颜色
  216. }
  217. }
  218. }
  219. .el-form-item {
  220. border: 1px solid rgba(255, 255, 255, 0.1);
  221. background: rgba(0, 0, 0, 0.1);
  222. border-radius: 5px;
  223. color: #454545;
  224. }
  225. }
  226. </style>
  227. <style lang="scss" scoped>
  228. $bg: #fff;
  229. $dark_gray: #889aa4;
  230. $light_gray: #000;
  231. ::v-deep .el-form-item__content {
  232. line-height: 1;
  233. }
  234. .submit-btn {
  235. width: 100%;
  236. margin-top: 30px;
  237. background: rgb(1, 78, 133);
  238. }
  239. .support {
  240. color: rgb(1, 78, 133);
  241. font-size: 14px;
  242. text-align: center;
  243. font-weight: 500;
  244. margin-bottom: 30px;
  245. }
  246. .logo {
  247. .img1 {
  248. padding-top: 40px;
  249. padding-left: 40px;
  250. width: 400px;
  251. }
  252. .img2 {
  253. width: 240px;
  254. padding-top: 20px;
  255. padding-left: 20px;
  256. }
  257. }
  258. .login-container {
  259. min-height: 100%;
  260. width: 100%;
  261. background-repeat: no-repeat;
  262. background-size: 100% 100%;
  263. overflow: hidden;
  264. .login-form {
  265. width: 100%;
  266. max-width: 100%;
  267. margin-top: 40px;
  268. &.prod {
  269. top: 200px;
  270. right: 100px;
  271. width: 360px;
  272. transform: none;
  273. }
  274. }
  275. .tips {
  276. font-size: 14px;
  277. color: #fff;
  278. margin-bottom: 10px;
  279. span {
  280. &:first-of-type {
  281. margin-right: 16px;
  282. }
  283. }
  284. }
  285. .svg-container {
  286. padding: 6px 5px 6px 15px;
  287. color: $dark_gray;
  288. vertical-align: middle;
  289. width: 30px;
  290. display: inline-block;
  291. }
  292. .title-container {
  293. position: relative;
  294. .title {
  295. font-size: 18px;
  296. color: $light_gray;
  297. margin: 0px auto 20px auto;
  298. font-weight: bold;
  299. text-align: center;
  300. }
  301. }
  302. .show-pwd {
  303. position: absolute;
  304. right: 10px;
  305. top: 14px;
  306. font-size: 16px;
  307. color: $dark_gray;
  308. cursor: pointer;
  309. user-select: none;
  310. }
  311. }
  312. // ============ 新界面样式 ==========
  313. .container {
  314. background-color: #fff;
  315. border-radius: 10px;
  316. box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22);
  317. position: relative;
  318. overflow: hidden;
  319. width: 860px;
  320. max-width: 100%;
  321. min-height: 528px;
  322. position: fixed;
  323. top: 50%;
  324. left: 50%;
  325. transform: translate(-50%, -50%);
  326. display: flex;
  327. }
  328. .overlay-container {
  329. width: 58%;
  330. transition: transform 0.6s ease-in-out;
  331. }
  332. .overlay{
  333. background: #4fb3ff;
  334. background: linear-gradient(to right, #3EACFF, #914dff);
  335. background-repeat: no-repeat;
  336. background-size: cover;
  337. background-position: 0 0;
  338. color: #FFFFFF;
  339. height: 100%;
  340. width: 100%;
  341. }
  342. .overlay-left{
  343. padding-top: 50px;
  344. padding-left: 60px;
  345. }
  346. .overlay-left h1{
  347. margin: 0;
  348. }
  349. .overlay-left p{
  350. padding-top: 10px;
  351. font-size: 18px;
  352. }
  353. .sign-up-container{
  354. flex: 1;
  355. padding-top: 50px;
  356. padding-left: 20px;
  357. padding-right: 20px;
  358. }
  359. .sign-title{
  360. font-size: 18px;
  361. font-weight: bold;
  362. color: rgb(58, 98, 215);
  363. text-align: center;
  364. }
  365. .sign-title-1{
  366. font-size: 15px;
  367. font-weight: bold;
  368. padding-top: 20px;
  369. }
  370. .overlay-left-img{
  371. margin: 50px auto 0;
  372. width: 240px;
  373. display: block;
  374. }
  375. </style>