plm前端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

250 lines
6.7 KiB

3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
2 years ago
3 years ago
  1. <template>
  2. <div class="site-wrapper site-page--login">
  3. <div class="site-content__wrapper">
  4. <div style="text-align: right;float: right;margin-top: 0%;height: 30%;width: 100%;vertical-align:middle;" >
  5. <img style="margin-top: 5px;margin-right: 5px;max-width: 10%;max-height: 100%;vertical-align:middle;" src="~@/assets/img/ccl.png" >
  6. </div>
  7. <div class="site-content">
  8. <div class="login-main">
  9. <h3 class="login-title">用户登陆</h3>
  10. <el-form :model="dataForm" :rules="dataRule" ref="dataForm" @keyup.enter.native="dataFormSubmit()" status-icon>
  11. <el-form-item>
  12. <el-select v-model="dataForm.site" style="width: 230px"
  13. placeholder="请选择工厂">
  14. <el-option
  15. v-for="(item,index) in siteList"
  16. :key="index"
  17. :label="item.siteID+' - '+item.siteName"
  18. :value="item.siteID"
  19. >
  20. </el-option>
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item prop="userName">
  24. <el-input v-model="dataForm.userName" placeholder="帐号"></el-input>
  25. </el-form-item>
  26. <el-form-item prop="password">
  27. <el-input v-model="dataForm.password" type="password" placeholder="密码"></el-input>
  28. </el-form-item>
  29. <el-form-item>
  30. <el-button class="login-btn-submit" type="primary" @click="dataFormSubmit()">登录</el-button>
  31. </el-form-item>
  32. </el-form>
  33. </div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import { getUUID } from '@/utils'
  40. import {getConfigParams} from '@/api/sysConfig.js'
  41. import {
  42. getSiteDataActive,
  43. } from "@/api/base/site.js"
  44. export default {
  45. data () {
  46. return {
  47. src: 'http://192.168.1.83/upload/ifs.png',
  48. dataForm: {
  49. userName: '',
  50. password: '',
  51. uuid: '',
  52. captcha: '',
  53. site:''
  54. },
  55. siteList:[],
  56. dataRule: {
  57. userName: [
  58. { required: true, message: '帐号不能为空', trigger: 'blur' }
  59. ],
  60. password: [
  61. { required: true, message: '密码不能为空', trigger: 'blur' }
  62. ]
  63. },
  64. captchaPath: ''
  65. }
  66. },
  67. computed: {
  68. multiLanguage: {
  69. get() {
  70. return this.$store.state.user.multiLanguage
  71. },
  72. set(val) {
  73. this.$store.commit('user/updateMultiLanguage', val)
  74. }
  75. },
  76. authControl: {
  77. get() {
  78. return this.$store.state.user.authControl
  79. },
  80. set(val) {
  81. this.$store.commit('user/updateAuthControl', val)
  82. }
  83. }
  84. },
  85. created () {
  86. this.userName();
  87. this.getSiteData();
  88. },
  89. methods: {
  90. getSiteData(){
  91. let data={};
  92. getSiteDataActive(data).then(({data}) => {
  93. this.siteList = data.rows
  94. if(this.siteList.length>0){
  95. this.dataForm.site=this.siteList[0].siteID
  96. }
  97. })
  98. },
  99. // 获取上次登陆的用户名
  100. userName(){
  101. this.dataForm.userName = localStorage.getItem('userName')
  102. },
  103. // 提交表单
  104. dataFormSubmit () {
  105. this.$refs['dataForm'].validate((valid) => {
  106. if (valid) {
  107. this.$http({
  108. url: this.$http.adornUrl('/sys/login'),
  109. method: 'post',
  110. data: this.$http.adornData({
  111. 'username': this.dataForm.userName,
  112. 'password': this.dataForm.password,
  113. 'uuid': this.dataForm.uuid,
  114. 'site': this.dataForm.site,
  115. })
  116. }).then(({data}) => {
  117. if (data && data.code === 0) {
  118. this.$cookie.set('token_plm', data.token)
  119. this.$router.replace({ name: 'home' })
  120. this.$i18n.locale=data.language
  121. localStorage.setItem('locale', data.language)
  122. localStorage.setItem('refresh', "0")
  123. localStorage.setItem('userName', this.dataForm.userName)
  124. localStorage.setItem('accessSite', this.dataForm.site)
  125. this.getConfigParams()
  126. } else {
  127. this.$message.error(data.msg)
  128. }
  129. })
  130. }
  131. })
  132. },
  133. // 获取全局参数变量
  134. getConfigParams() {
  135. getConfigParams().then(({data}) => {
  136. if (data && data.code == 0) {
  137. localStorage.setItem('configParams', JSON.stringify(data.data))
  138. // this.multiLanguage = JSON.parse(localStorage.getItem('configParams')).multiLanguage
  139. // this.authControl = JSON.parse(localStorage.getItem('configParams')).authControl
  140. }
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. .site-wrapper.site-page--login {
  148. position: absolute;
  149. top: 0;
  150. right: 0;
  151. bottom: 0;
  152. left: 0;
  153. background-color: rgba(38, 50, 56, 0);
  154. overflow: hidden;
  155. &:before {
  156. position: fixed;
  157. top: 0;
  158. left: 0;
  159. z-index: -1;
  160. width: 80%;
  161. height: 100%;
  162. content: "";
  163. background-image: url(~@/assets/img/login_bg.jpg);
  164. background-size: cover;
  165. }
  166. .site-content__wrapper {
  167. position: absolute;
  168. top: 0;
  169. right: 0;
  170. bottom: 0;
  171. left: 0;
  172. padding: 0;
  173. margin: 0;
  174. overflow-x: hidden;
  175. overflow-y: auto;
  176. background-color: transparent;
  177. }
  178. .site-content {
  179. min-height: 100%;
  180. padding: 15% 500px 30px 30px;
  181. }
  182. .brand-info {
  183. margin: 220px 100px 0 90px;
  184. color: #fff;
  185. }
  186. .brand-info__text {
  187. margin: 0 0 22px 0;
  188. font-size: 48px;
  189. font-weight: 400;
  190. text-transform : uppercase;
  191. }
  192. .brand-info__intro {
  193. margin: 10px 0;
  194. font-size: 16px;
  195. line-height: 1.58;
  196. opacity: .6;
  197. }
  198. .login-main {
  199. position: absolute;
  200. top: 0;
  201. right: 0;
  202. padding: 15% 60px 180px;
  203. width: 350px;
  204. min-height: 100%;
  205. background-color: transparent;
  206. }
  207. .login-main-2 {
  208. position: absolute;
  209. top: 0;
  210. right: 0;
  211. padding: 15% 60px 180px;
  212. width: 350px;
  213. min-height: 100%;
  214. background-color: transparent;
  215. }
  216. .login-title {
  217. font-size: 30px;
  218. }
  219. .login-captcha {
  220. overflow: hidden;
  221. > img {
  222. width: 100%;
  223. cursor: pointer;
  224. }
  225. }
  226. .login-btn-submit {
  227. width: 100%;
  228. }
  229. .login-main .el-input__inner{
  230. margin-top: 10px;
  231. height: 45px;
  232. }
  233. .el-button--medium {
  234. margin-top: 0px;
  235. padding: 5px 11px;
  236. font-size: 16px;
  237. border-radius: 4px;
  238. }
  239. .el-form-item {
  240. margin-bottom: 5px;
  241. }
  242. }
  243. </style>