index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344
  1. <template>
  2. <div class="login-container">
  3. <div class="title-container">
  4. <!-- <h3 class="title"><el-image class="logo" :src="logoImage" /></h3> -->
  5. <h3 class="title">合阳人民医院“六院联创” 综合管理平台</h3>
  6. </div>
  7. <div class="login-form-wrap">
  8. <el-form ref="loginForm" :model="loginForm" :rules="loginRules" class="login-form" auto-complete="on" label-position="left">
  9. <div class="title-container">
  10. <h3 class="form-title">深化“六院联创”建设,推动医院高质量发展</h3>
  11. </div>
  12. <el-form-item prop="username">
  13. <span class="svg-container">
  14. <svg-icon icon-class="user" />
  15. </span>
  16. <el-input
  17. ref="username"
  18. v-model="loginForm.username"
  19. placeholder="用户名/手机号/工号"
  20. name="username"
  21. type="text"
  22. tabindex="1"
  23. auto-complete="on"
  24. />
  25. </el-form-item>
  26. <el-tooltip v-model="capsTooltip" content="Caps lock is On" placement="right" manual>
  27. <el-form-item prop="password">
  28. <span class="svg-container">
  29. <svg-icon icon-class="password" />
  30. </span>
  31. <el-input
  32. :key="passwordType"
  33. ref="password"
  34. v-model="loginForm.password"
  35. :type="passwordType"
  36. placeholder="密码"
  37. name="password"
  38. tabindex="2"
  39. auto-complete="on"
  40. @keyup.native="checkCapslock"
  41. @blur="capsTooltip = false"
  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. </el-tooltip>
  49. <p class="tip-text">
  50. <span>*</span> 忘记密码可咨询管理人员重新获取
  51. </p>
  52. <el-button :loading="loading" type="primary" style="width:100%;margin-bottom:30px;" @click.native.prevent="handleLogin">
  53. 登录
  54. </el-button>
  55. </el-form>
  56. </div>
  57. </div>
  58. </template>
  59. <script>
  60. export default {
  61. name: 'Login',
  62. data() {
  63. const validateUsername = (rule, value, callback) => {
  64. if (value.length > 0 && value.length < 999) {
  65. callback()
  66. } else {
  67. callback(new Error('请输入正确的用户名/手机号/工号'))
  68. }
  69. }
  70. const validatePassword = (rule, value, callback) => {
  71. if (value.length < 6) {
  72. callback(new Error('密码不能少于6位'))
  73. } else {
  74. callback()
  75. }
  76. }
  77. return {
  78. loginForm: {
  79. username: '',
  80. password: ''
  81. },
  82. loginRules: {
  83. username: [{ required: true, trigger: 'blur', validator: validateUsername }],
  84. password: [{ required: true, trigger: 'blur', validator: validatePassword }]
  85. },
  86. loading: false,
  87. passwordType: 'password',
  88. capsTooltip: false,
  89. showDialog: false,
  90. redirect: undefined,
  91. logoImage: require('@/assets/images/logo/lylc_hos.png'),
  92. otherQuery: {}
  93. }
  94. },
  95. watch: {
  96. $route: {
  97. handler: function(route) {
  98. this.redirect = route.query && route.query.redirect
  99. },
  100. immediate: true
  101. }
  102. },
  103. created() {
  104. // 项目初始化时候清除路由缓存,为保证退出登录的时候浏览器反应迟钝没有清除干净
  105. localStorage.removeItem('permission_routes')
  106. localStorage.removeItem('tabIndex')
  107. },
  108. mounted() {
  109. if (this.loginForm.username === '') {
  110. this.$refs.username.focus()
  111. } else if (this.loginForm.password === '') {
  112. this.$refs.password.focus()
  113. }
  114. },
  115. destroyed() {},
  116. methods: {
  117. checkCapslock(e) {
  118. const { key } = e
  119. this.capsTooltip = key && key.length === 1 && (key >= 'A' && key <= 'Z')
  120. },
  121. showPwd() {
  122. if (this.passwordType === 'password') {
  123. this.passwordType = ''
  124. } else {
  125. this.passwordType = 'password'
  126. }
  127. this.$nextTick(() => {
  128. this.$refs.password.focus()
  129. })
  130. },
  131. handleLogin() {
  132. this.$refs.loginForm.validate(valid => {
  133. if (valid) {
  134. this.loading = true
  135. this.$store.dispatch('user/login', this.loginForm).then(() => {
  136. this.$router.push({ path: '/', query: this.otherQuery })
  137. this.loading = false
  138. }).catch(() => {
  139. this.loading = false
  140. })
  141. } else {
  142. return false
  143. }
  144. })
  145. },
  146. async detectionRedirectPath() {
  147. const permits = await this.$store.dispatch('user/getRoute')
  148. const accessRoutes = await this.$store.dispatch('permission/generateRoutes', permits)
  149. const routes = accessRoutes.map(item => item.path)
  150. const redirect = routes.includes(this.redirect) ? this.redirect : '/'
  151. this.$router.addRoutes(accessRoutes)
  152. this.$router.push({ path: redirect, query: this.otherQuery })
  153. this.loading = false
  154. },
  155. getOtherQuery(query) {
  156. return Object.keys(query).reduce((acc, cur) => {
  157. if (cur !== 'redirect') {
  158. acc[cur] = query[cur]
  159. }
  160. return acc
  161. }, {})
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss">
  167. /* 修复input 背景不协调 和光标变色 */
  168. $bg:#283443;
  169. $light_gray:#000;
  170. $cursor: #86909C;
  171. @supports (-webkit-mask: none) and (not (cater-color: $cursor)) {
  172. .login-container .el-input input {
  173. color: $cursor;
  174. }
  175. }
  176. /* reset element-ui css */
  177. .login-container {
  178. .el-input {
  179. display: inline-block;
  180. height: 37px;
  181. width: 85%;
  182. background:none;
  183. border:none;
  184. input {
  185. background: transparent;
  186. border: 0;
  187. -webkit-appearance: none;
  188. border-radius: 0;
  189. padding: 12px 5px 12px 15px;
  190. color: $light_gray;
  191. height: 37px;
  192. caret-color: $cursor;
  193. &:-webkit-autofill {
  194. box-shadow: 0 0 0 1000px $bg inset !important;
  195. -webkit-text-fill-color: $cursor !important;
  196. }
  197. }
  198. }
  199. .el-form-item {
  200. height: 43px;
  201. border: 1px solid #C6C6C6;
  202. background: #fff;
  203. border-radius: 5px;
  204. color: #454545;
  205. margin-bottom: 30px;
  206. }
  207. }
  208. </style>
  209. <style lang="scss" scoped>
  210. $bg: #2d3a4b;
  211. $dark_gray: #889aa4;
  212. $light_gray: #eee;
  213. .login-container {
  214. min-height: 100%;
  215. width: 100%;
  216. background-image: url("../../assets/images/login/login_ornament.png");
  217. background-size:100% 100%;
  218. background-repeat: no-repeat;
  219. overflow: hidden;
  220. position: relative;
  221. .login-form-wrap {
  222. position: absolute;
  223. // background: rgba(255, 255, 255, 0.8);
  224. right: 98px;
  225. top: 223px;
  226. border-radius: 16px;
  227. }
  228. .login-form {
  229. width: 420px;
  230. height: 437px;
  231. max-width: 100%;
  232. padding: 40px;
  233. margin: 0 auto;
  234. overflow: hidden;
  235. background: rgba(255, 255, 255, 0.8);
  236. border-radius: 16px;
  237. box-sizing: border-box;
  238. .icon-image {
  239. width: 20px;
  240. height: 20px;
  241. position: relative;
  242. top: 6px;
  243. }
  244. .form-title {
  245. font-size: 14px;
  246. font-weight: bold;
  247. color: #212121;
  248. margin-top: 0;
  249. margin-bottom: 34px;
  250. font-family: Be Vietnam;
  251. font-size: 28px;
  252. font-weight: 700;
  253. line-height: 41px;
  254. letter-spacing: 0em;
  255. }
  256. .tip-text {
  257. font-size: 12px;
  258. font-weight: bold;
  259. color: #7C878E;
  260. margin-bottom: 32px;
  261. span {
  262. color: #E41111;
  263. position: relative;
  264. top: 2px;
  265. margin-right: 5px;
  266. }
  267. }
  268. }
  269. .tips {
  270. font-size: 14px;
  271. color: #fff;
  272. margin-bottom: 10px;
  273. span {
  274. &:first-of-type {
  275. margin-right: 16px;
  276. }
  277. }
  278. }
  279. .svg-container {
  280. padding: 6px 5px 6px 15px;
  281. color: $dark_gray;
  282. vertical-align: middle;
  283. width: 30px;
  284. display: inline-block;
  285. }
  286. .title-container {
  287. position: relative;
  288. .title {
  289. font-size: 28px;
  290. color: $light_gray;
  291. margin: 26px auto 40px 43px;
  292. text-align: left;
  293. font-weight: bold;
  294. background-color:rgba(7, 28, 43, 0.03);
  295. box-shadow: 0px 4px 16px 0px rgba(0, 0, 0, 0.1);
  296. display: inline-block;
  297. }
  298. }
  299. .show-pwd {
  300. position: absolute;
  301. right: 10px;
  302. top: 7px;
  303. font-size: 16px;
  304. color: $dark_gray;
  305. cursor: pointer;
  306. user-select: none;
  307. }
  308. .thirdparty-button {
  309. position: absolute;
  310. right: 0;
  311. bottom: 6px;
  312. }
  313. @media only screen and (max-width: 470px) {
  314. .thirdparty-button {
  315. display: none;
  316. }
  317. }
  318. }
  319. </style>