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.

281 lines
7.3 KiB

8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
7 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
6 months ago
6 months ago
8 months ago
6 months ago
8 months ago
6 months ago
8 months ago
  1. <template>
  2. <div class="pda-login">
  3. <div class="login-card">
  4. <!-- 语言切换 -->
  5. <div class="lang-switch">
  6. <el-dropdown trigger="click">
  7. <span class="lang-text">
  8. {{ $t('home.locale') }}<i class="el-icon-arrow-down el-icon--right"></i>
  9. </span>
  10. <el-dropdown-menu slot="dropdown">
  11. <el-dropdown-item
  12. v-for="lang in languageList"
  13. :key="lang.languageCode"
  14. @click.native="switch_the_language(lang.languageCode)"
  15. >
  16. {{ lang.languageName }}
  17. </el-dropdown-item>
  18. </el-dropdown-menu>
  19. </el-dropdown>
  20. </div>
  21. <div class="logo-area">
  22. <svg viewBox="0 0 100 80" width="90" height="72">
  23. <!-- 立体货架左侧 -->
  24. <polygon points="20,30 20,70 50,80 50,40" fill="#2B2523"/>
  25. <!-- 立体货架右侧 -->
  26. <polygon points="50,40 50,80 90,70 90,30" fill="#23201E"/>
  27. <!-- 立体货架顶面 -->
  28. <polygon points="20,30 50,20 90,30 50,40" fill="#3A3532"/>
  29. <!-- 横向货架层 -->
  30. <polyline points="20,40 50,48" stroke="#fff" stroke-width="2" opacity="0.7"/>
  31. <polyline points="20,50 50,56" stroke="#fff" stroke-width="2" opacity="0.7"/>
  32. <polyline points="20,60 50,64" stroke="#fff" stroke-width="2" opacity="0.7"/>
  33. <!-- 横向货架层 -->
  34. <polyline points="90,40 50,48" stroke="#fff" stroke-width="2" opacity="0.7"/>
  35. <polyline points="90,50 50,56" stroke="#fff" stroke-width="2" opacity="0.7"/>
  36. <polyline points="90,60 50,64" stroke="#fff" stroke-width="2" opacity="0.7"/>
  37. <!-- 纵向货架分隔线 -->
  38. <polyline points="35,25 35,75" stroke="#fff" stroke-width="2" opacity="0.5"/>
  39. <polyline points="65,25 65,75" stroke="#fff" stroke-width="2" opacity="0.5"/>
  40. <!-- #17B3A3色系货箱在货架格子里 -->
  41. <rect x="53" y="44" width="8" height="6" fill="#17B3A3" rx="1" />
  42. <rect x="73" y="54" width="8" height="6" fill="#17B3A3" rx="1" />
  43. <rect x="33" y="62" width="8" height="6" fill="#17B3A3" rx="1" />
  44. </svg>
  45. <h1>{{ $t('home.pdaName') }}</h1>
  46. </div>
  47. <el-form class="login-form" @keyup.enter.native="dataFormSubmit()">
  48. <!-- 用户名 -->
  49. <div class="input-group" :class="{focus: usernameFocus}">
  50. <input placeholder="Username"
  51. type="text"
  52. v-model="dataForm.userName"
  53. @focus="usernameFocus=true"
  54. @blur="handleUsernameBlur"
  55. required />
  56. </div>
  57. <!-- 密码 -->
  58. <div class="input-group" :class="{focus: passwordFocus}">
  59. <input placeholder="Password"
  60. :type="showPassword ? 'text' : 'password'"
  61. v-model="dataForm.password"
  62. @focus="passwordFocus=true"
  63. @blur="passwordFocus=false"
  64. required />
  65. </div>
  66. <!-- 工厂下拉框site -->
  67. <el-select
  68. v-if="siteList.length"
  69. v-model="selectedSite"
  70. placeholder="请选择工厂"
  71. style="width: 100%; margin-bottom: 1.5rem"
  72. :popper-append-to-body="false">
  73. <el-option
  74. v-for="item in siteList"
  75. :key="item.siteCode"
  76. :label="item.siteName"
  77. :value="item.siteCode" />
  78. </el-select>
  79. <!-- 登录按钮 -->
  80. <button type="submit" class="login-btn" :disabled="loading" @click.prevent="dataFormSubmit">
  81. <span v-if="!loading">Login</span>
  82. <span v-else class="loading-dots"></span>
  83. </button>
  84. </el-form>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import {searchSysLanguage} from "@/api/sysLanguage.js"
  90. export default {
  91. data() {
  92. return {
  93. dataForm: {
  94. userName: '',
  95. password: '',
  96. uuid: ''
  97. },
  98. usernameFocus: false,
  99. passwordFocus: false,
  100. showPassword: false,
  101. loading: false,
  102. siteList: [{ "siteCode": "1", "siteName": "苏州工厂" },
  103. { "siteCode": "2", "siteName": "南京工厂" }],
  104. languageList: [],
  105. selectedSite: ''
  106. };
  107. },
  108. created() {
  109. this.getLanguageList();
  110. },
  111. methods: {
  112. // 获取多语言列表
  113. getLanguageList() {
  114. searchSysLanguage({languageCode: this.$i18n.locale}).then(({data}) => {
  115. this.languageList = data.rows
  116. })
  117. },
  118. switch_the_language(val) {
  119. localStorage.setItem('locale', val)
  120. this.$i18n.locale = val; // 修改当前语言
  121. location.reload()
  122. },
  123. handleUsernameBlur() {
  124. },
  125. dataFormSubmit() {
  126. if (!this.selectedSite) {
  127. this.$message.error('请选择工厂');
  128. return;
  129. }
  130. this.loading = true;
  131. this.$http({
  132. url: this.$http.adornUrl('/sys/login'),
  133. method: 'post',
  134. data: this.$http.adornData({
  135. username: this.dataForm.userName,
  136. password: this.dataForm.password,
  137. uuid: this.dataForm.uuid,
  138. site: this.selectedSite
  139. })
  140. }).then(({ data }) => {
  141. this.loading = false;
  142. if (data && data.code === 0) {
  143. this.$cookie.set('token', data.token);
  144. localStorage.setItem('userName', this.dataForm.userName);
  145. localStorage.setItem('site', this.selectedSite);
  146. this.$router.replace({ name: 'home' });
  147. } else {
  148. this.$alert("用户名或密码错误", '错误', {
  149. confirmButtonText: '确定'
  150. });
  151. }
  152. });
  153. }
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. .pda-login {
  159. height: 100vh;
  160. display: flex;
  161. justify-content: center;
  162. align-items: center;
  163. background: #f5f5f5; /* 修改为与 index.vue 一致的背景色 */
  164. font-family: 'Segoe UI', sans-serif;
  165. }
  166. .login-card {
  167. position: relative;
  168. width: 90%;
  169. max-width: 400px;
  170. padding: 2rem;
  171. background: white;
  172. border-radius: 16px;
  173. box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
  174. }
  175. .lang-switch {
  176. position: absolute;
  177. top: 18px;
  178. right: 20px;
  179. }
  180. .lang-text {
  181. cursor: pointer;
  182. font-size: 14px;
  183. color: #17B3A3;
  184. }
  185. .logo-area {
  186. text-align: center;
  187. margin-bottom: 1.5rem;
  188. }
  189. .logo-area svg {
  190. width: 64px;
  191. height: 64px;
  192. filter: drop-shadow(0 2px 4px rgba(23, 179, 163, 0.3)); /* 修改阴影颜色 */
  193. }
  194. h1 {
  195. color: #333;
  196. font-size: 1.5rem;
  197. margin-top: 1rem;
  198. }
  199. .input-group {
  200. position: relative;
  201. margin-bottom: 1.2rem;
  202. border-bottom: 1px solid #ccc;
  203. transition: all 0.3s ease;
  204. }
  205. .input-group.focus {
  206. border-color: #17B3A3;
  207. }
  208. .input-group input {
  209. width: 100%;
  210. padding: 10px 0;
  211. border: none;
  212. outline: none;
  213. font-size: 15px;
  214. }
  215. .input-group.site-select {
  216. border: none;
  217. padding-top: 8px;
  218. }
  219. .pwd-toggle {
  220. position: absolute;
  221. right: 0;
  222. top: 50%;
  223. transform: translateY(-50%);
  224. background: none;
  225. border: none;
  226. color: #17B3A3;
  227. font-size: 12px;
  228. cursor: pointer;
  229. }
  230. .login-btn {
  231. width: 100%;
  232. padding: 12px;
  233. background: #17B3A3;
  234. color: white;
  235. border: none;
  236. border-radius: 8px;
  237. font-size: 16px;
  238. margin-top: 1.2rem;
  239. transition: all 0.3s;
  240. }
  241. .login-btn:hover {
  242. background: #1dc5ef;
  243. }
  244. .login-btn:disabled {
  245. background: #a0d4ff;
  246. }
  247. .loading-dots {
  248. letter-spacing: 2px;
  249. animation: blink 1.2s infinite;
  250. }
  251. @keyframes blink {
  252. 0%, 100% { opacity: 0.2 }
  253. 50% { opacity: 1 }
  254. }
  255. </style>