Scan.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <div>
  3. <div class="fh-login">
  4. <h2 style="font-size:30px;text-align: center;color: #fff"> 思康新材料</h2>
  5. <h2 style="font-size:30px;text-align: center;color: #fff">设备管理系统</h2>
  6. <div class="login-title">{{ user.realName }},辛苦了</div>
  7. <a-form
  8. :label-col="labelCol"
  9. :wrapper-col="wrapperCol"
  10. id="formLogin"
  11. ref="formLogin"
  12. :form="form"
  13. class="login-form"
  14. @submit="handleSubmit">
  15. <a-form-item>
  16. <a-input
  17. size="large"
  18. type="password"
  19. autocomplete="false"
  20. placeholder="请输入密码"
  21. class="login-input"
  22. max="6"
  23. v-decorator="[
  24. 'password',
  25. {rules: [{ required: true, message: '请输入密码' }], validateTrigger: 'blur'}
  26. ]"
  27. >
  28. <a-icon slot="prefix" type="lock" :style="{ color: 'rgba(0,0,0,.25)' }"/>
  29. </a-input>
  30. </a-form-item>
  31. <a-form-item>
  32. <a-button class="btn" type="primary" htmlType="submit" :loading="loading">
  33. {{ buttonText }}
  34. </a-button>
  35. </a-form-item>
  36. </a-form>
  37. </div>
  38. </div>
  39. </template>
  40. <script>
  41. import { fetchWorkUser, updateUserWorkFlag } from '@/api/upms/user'
  42. import { encryptPassword } from '@/common/common'
  43. export default {
  44. components: {
  45. },
  46. data () {
  47. return {
  48. labelCol: {
  49. xs: { span: 24 },
  50. sm: { span: 5 }
  51. },
  52. wrapperCol: {
  53. xs: { span: 24 },
  54. sm: { span: 12 }
  55. },
  56. form: this.$form.createForm(this),
  57. buttonText: '上班',
  58. password: null,
  59. loading: false,
  60. show: false,
  61. user: {
  62. realName: ''
  63. }
  64. }
  65. },
  66. created () {
  67. const url = location.href.split('?')[1] // 获取url中"?"符后的字串
  68. const userId = decodeURIComponent(url.split('=')[1])
  69. this.init(userId)
  70. this.loading = false
  71. this.show = false
  72. },
  73. methods: {
  74. init (userId) {
  75. fetchWorkUser({ userId: userId }).then(res => {
  76. this.user = res.data
  77. this.buttonText = this.user.workFlag ? '下班' : '上班'
  78. })
  79. },
  80. handleSubmit (e) {
  81. e.preventDefault()
  82. const { form: { validateFieldsAndScroll } } = this
  83. this.loading = true
  84. validateFieldsAndScroll((errors, values) => {
  85. if (errors) {
  86. this.loading = false
  87. return
  88. }
  89. const params = {
  90. userId: this.user.userId,
  91. workFlag: this.user.workFlag ? 0 : 1,
  92. password: values.password ? encryptPassword(values.password) : ''
  93. }
  94. updateUserWorkFlag(params).then(res => {
  95. this.loading = false
  96. this.init(this.user.userId)
  97. setTimeout(() => {
  98. this.$notification.success({
  99. message: '操作成功',
  100. description: this.user.realName + `,辛苦了`
  101. })
  102. }, 1000)
  103. })
  104. })
  105. }
  106. }
  107. }
  108. </script>
  109. <style scoped>
  110. /*.fh-login {*/
  111. /* !*width: 830px;*!*/
  112. /* height: 435px;*/
  113. /* position: fixed;*/
  114. /* top: 50%;*/
  115. /* left: 50%;*/
  116. /* margin-top: -250px;*/
  117. /* margin-left: -440px;*/
  118. /* !*background: url('~@/assets/logn.png') no-repeat;*!*/
  119. /*}*/
  120. /*.fh-login .fh-login-left {*/
  121. /* float: left;*/
  122. /* width: 50%;*/
  123. /*}*/
  124. /*.fh-login .fh-login-left img {*/
  125. /* margin: 132px auto 0;*/
  126. /* display: block;*/
  127. /*}*/
  128. .fh-login-left h2 {
  129. margin-top: 65px;
  130. margin-left: 8%;
  131. padding-bottom: 20px;
  132. color: #ffffff;
  133. font-size: 40px;
  134. font-weight: 600;
  135. text-align: center;
  136. }
  137. .login-title {
  138. font-size: 24px;
  139. color: #fff;
  140. padding: 15px 0px;
  141. /*border-bottom: 1px solid #ccc;*/
  142. text-align: center;
  143. }
  144. .fh-login .btn {
  145. display: inline-block;
  146. color: #FFF !important;
  147. text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25) !important;
  148. border: 5px solid #FFF;
  149. border-radius: 0;
  150. box-shadow: none !important;
  151. -webkit-transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  152. -o-transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  153. transition: background-color 0.15s, border-color 0.15s, opacity 0.15s;
  154. cursor: pointer;
  155. vertical-align: middle;
  156. width: 100%;
  157. height: 52px;
  158. border: none;
  159. /*margin:30px;*/
  160. margin-top: 30px;
  161. background: rgb(82, 166, 212) !important;
  162. color: rgb(255, 255, 255);
  163. user-select: none;
  164. }
  165. .fh-login .login-input{
  166. border: none!important;
  167. outline: none!important;
  168. /*background-color: #fff!important;*/
  169. height: 42px!important;
  170. width: 100%!important;
  171. /*margin-left: 35px;*/
  172. }
  173. /*设置输入图标大小*/
  174. .ant-input-affix-wrapper{
  175. font-size: 24px;
  176. }
  177. .login-form{
  178. /*margin-left: 35px;*/
  179. /*margin-top: 35px;*/
  180. padding: 20px 35px;
  181. }
  182. /*调整图标位置*/
  183. .login-form .ant-input-affix-wrapper .ant-input-prefix {
  184. left: 9px !important;
  185. }
  186. .login-form .ant-input-affix-wrapper .ant-input:not(:first-child){
  187. padding-left: 38px;
  188. }
  189. </style>