wente
2023-12-05 bb9bf60cbd34d0638f1df89c69358533b2cc220c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
<template>
  <div class="aui-wrapper aui-page__login aui-page__login__border">
    <h2 class="login__h2">{{ $t('brand.lg') }}</h2>
    <div class="aui-content__wrapper">
      <div class="clear"></div>
      <main class="aui-content">
        <img class="login-left-bg" src="../../assets/img/vis-map2.png"/>
        <div class="login-content">
          <div class="login-header">
            <!--<h3 class="login-title">{{ $t('login.title') }}</h3>-->
          </div>
          <div class="login-body">
            <h3 class="login-title">{{ $t('login.title') }}</h3>
            <el-form :model="dataForm" ref="dataForm" @keyup.enter.native="formSubmit()" status-icon>
              <zt-form-item class="login-form-margin" prop="username" rules="required">
                <el-input v-model="dataForm.username" :placeholder="$t('login.username')">
                <span slot="prefix" class="el-input__icon">
                  <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-user"></use></svg>
                </span>
                </el-input>
              </zt-form-item>
              <zt-form-item class="login-form-margin" prop="password" rules="required">
                <el-input v-model="dataForm.password" type="password" :placeholder="$t('login.password')">
                <span slot="prefix" class="el-input__icon">
                  <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-lock"></use></svg>
                </span>
                </el-input>
              </zt-form-item>
              <zt-form-item prop="captcha" rules="required" v-if="$config.IS_LOGIN_NEED_CAPTURE">
                <el-row :gutter="20">
                  <el-col :span="14">
                    <el-input v-model="dataForm.captcha" :placeholder="$t('login.captcha')">
                    <span slot="prefix" class="el-input__icon">
                      <svg class="icon-svg" aria-hidden="true"><use xlink:href="#icon-safetycertificate"></use></svg>
                    </span>
                    </el-input>
                  </el-col>
                  <el-col :span="10" class="login-captcha">
                    <img :src="captchaPath" @click="getCaptcha()">
                  </el-col>
                </el-row>
              </zt-form-item>
              <el-form-item class="login-form-margin">
                <el-button style="margin-bottom:0;" type="primary" @click="formSubmit()">{{
                  $t('login.clickTitle') }}
                </el-button>
                <el-button style="margin-bottom:0;" type="primary" @click="changePassword()">修改密码</el-button>
                <el-button style="margin-bottom:0;" @click="register">用户注册
                </el-button>
              </el-form-item>
            </el-form>
            <add-or-update ref="register"/>
<!--            <UserChangePassword ref="changePassword"/>-->
          </div>
        </div>
        <div class="login-time">
          <span v-text="day"></span>
          <br/>
          <span v-text="time"></span>
        </div>
      </main>
    </div>
  </div>
</template>
 
<script>
  import Cookies from 'js-cookie'
  import debounce from 'lodash/debounce'
  import {clearLoginInfo, getUUID} from '../../../packages/utils'
  // import AddOrUpdate from '../modules/sys/user-register'
  // import UserChangePassword from '../modules/sys/user-change-password'
 
  export default {
    data() {
      return {
        day: '',
        time: '',
        captchaPath: '',
        client: '',
        userRoleInfo: {},
        dataForm: {
          systemMarker: 'test',
          username: '',
          password: '',
          uuid: '',
          captcha: '',
          loginMethod: 'username'
        }
      }
    },
    computed: {},
    components: {
      // AddOrUpdate,
      // UserChangePassword,
    },
    mounted() {
      this.writeCurrentDate()
      this.kwReplacement()
      setInterval(this.writeCurrentDate, 1000)
    },
    created() {
      this.getCaptcha()
      this.getUserRoleInfo()
      this.getAdminRoleInfo()
    },
    methods: {
      writeCurrentDate() {
        var date = new Date()
        var year = date.getFullYear() // 获取当前年份
        var mon = date.getMonth() + 1 // 获取当前月份
        var da = date.getDate() // 获取当前日
        var h = date.getHours() // 获取小时
        var m = date.getMinutes() // 获取分钟
        var s = date.getSeconds() // 获取秒
        // 判断当数字小于等于9时 显示 01 02 ----- 08 09
        if (mon >= 1 && mon <= 9) {
          mon = '0' + mon
        }
        if (da >= 0 && da <= 9) {
          da = '0' + da
        }
        if (h >= 0 && h <= 9) {
          h = '0' + h
        }
        if (m >= 0 && m <= 9) {
          m = '0' + m
        }
        if (s >= 0 && s <= 9) {
          s = '0' + s
        }
        this.day = '北京时间:' + ' ' + year + '年' + mon + '月' + da + '日'
        this.time = h + ':' + m + ':' + s
      },
      async register() {
        this.$refs['register'].$refs['dialog'].init()
      },
      async changePassword() {
        this.$refs['changePassword'].$refs['dialog'].init()
      },
      async kwReplacement() {
        let res = await this.$http.get(`sys/dict/type/getDictMap`,{params:{dictType:"key_word"}})
        if (res.data != null) {
          this.$store.state.word = res.data
        }
      },
      // 获取验证码
      getCaptcha() {
        this.dataForm.uuid = getUUID()
        this.captchaPath = `${window.SITE_CONFIG['apiURL']}/captcha?uuid=${this.dataForm.uuid}`
      },
      // 获取当前用户登录信息
      async getUserRoleInfo() {
        return await this.$http.get('/user/userRoleInfo').then(res => {
          this.loading = false
          if (res.code !== 0) {
            return this.$message.error(res.msg)
          }
          this.userRoleInfo = res.data
          console.log(this.userRoleInfo)
        }).catch(() => {
        })
      },
      async getAdminRoleInfo() {
        return await this.$http.get('/user/adminRole').then(res => {
          console.log(res.data,'res.data')
          // console.log(res,'getAdminRoleInfo');
          this.$store.state.user.isAdmin = res.data.isAdmin
          this.$store.state.user.isAssistant = res.data.isAssistant
          this.$store.state.user.isTyRole = res.data.isTyRole
          this.$store.state.user.isCjRole = res.data.isCjRole
          this.$store.state.user.isZcRole = res.data.isZcRole
          this.$store.state.user.isCzRole = res.data.isCzRole
          this.$store.state.user.isBzRole = res.data.isBzRole
          this.$store.state.user.isTzRole = res.data.isTzRole
          this.$store.state.user.isYwzRole = res.data.isYwzRole
          this.$store.state.user.roles = res.data.roles
          this.$store.state.debug = res.data.debug
          this.$store.state.test = res.data.test
          this.$store.state.menuPos = res.data.menuPos
          window.SITE_CONFIG['isAdmin'] = res.data.isAdmin // 权限
          this.loading = false
          console.log(this.$store.state.user.isZcRole, 'this.$store.state.user.isZcRole')
        }).catch(() => {
          console.log('/user/adminRole', 'adminRole')
        })
      },
      // 表单提交
      formSubmit: debounce(function () {
        clearLoginInfo()
        this.$http.get('/loginOut', {params: {username: this.dataForm.username}}).then(ref => {
          this.$refs.dataForm.validate(async valid => {
            if (valid) {
              let res = await this.$http.post('/login', this.dataForm)
              console.log(this.dataForm,'this.dataForm')
              console.log(res,'res')
              this.getCaptcha()
              if (res.success) {
                let info = res.data.info
                console.log(info,'info')
                if (info !== 'OK') {
                  await this.$alert(info, '提示', {
                    confirmButtonText: '确定'
                  })
                  return
                } else {
                  console.log('login token:', res.data.token)
                  Cookies.set('token', res.data.token)
                  Cookies.set('loginMethod', 'username')
                  Cookies.set('djxlSystem', '')
                  Cookies.remove('systemId')
                  let isTest = res.data.test
                  this.$store.state.user.roleName=res.data.roleName
                  console.log(res.data.roleName,'res.data.roleName res.data.roleName')
                  if (res.data.roleName != null &&
                    (res.data.roleName.indexOf('系统管理员') >= 0 ||
                      res.data.roleName.indexOf('全部权限') >= 0 ||
                      res.data.roleName.indexOf('总体所角色') >= 0 ||
                      res.data.roleName.indexOf('代表室角色') >= 0 ||
                      res.data.roleName.indexOf('助理角色') >= 0 ||
                      res.data.roleName.indexOf('总厂角色') >= 0 ||
                      res.data.roleName.indexOf('部长角色') >= 0 ||
                      res.data.roleName.indexOf('处长角色') >= 0)
                  ) {
                    console.log('TestDjxlHome')
                    // this.$router.push({name: 'TestDjxlHome', params: {roleName: res.data.roleName}})
                    this.$router.push({name: 'home'})
                  } else {
                    console.log('home')
                    this.$router.push({name: 'home'})
                  }
                }
              }
            }
          })
        })
      }, 1000, {'leading': true, 'trailing': false})
    }
  }
</script>
<style>
  .login__h2 {
    float: left;
    margin: 0;
    margin-left: 35.5%;
    color: rgba(123, 224, 244, 1);
    font-size: 40px;
    margin-top: 20px;
    font-weight: 400;
    letter-spacing: 8px;
    text-align: center;
    margin-bottom: -80px;
  }
 
  .clear {
    clear: both;
  }
 
  .login__h2::before,
  .login__h2::after {
    display: inline;
    margin: 5px;
    content: '/////';
    font-size: 25px;
    font-weight: bold;
    font-style: oblique;
  }
 
  .login-left-bg {
    position: absolute;
    width: 50%;
    top: -6%;
    left: 0;
    transform: scale(1.1);
    /*transition:all 1s ease-out;*/
  }
 
  .login-content {
    position: absolute;
    width: 25%;
    border: 15px solid transparent;
    border-image: url(../../assets/img/page-border.png) 20 stretch;
    right: 7%;
    top: 20%;
  }
 
  .login-h6 {
    font-size: 10px;
    margin-left: -7px;
    margin-top: -6px;
    margin-bottom: 25px;
  }
 
  .login-body .el-input__inner {
    border-radius: 3px;
    height: 60px;
    font-size: 17px;
    color: rgba(123, 224, 244, 1);
    background: transparent;
    border: 1px solid rgba(123, 224, 244, 0.3);
  }
 
  .aui-page__login__border .el-input {
    border: 1px solid rgba(123, 224, 244, 0.3);
    border-radius: 4px;
  }
 
  .aui-page__login__border .el-input:hover,
  .aui-page__login__border .el-input:active {
    border-radius: 4px;
    border: 1px solid rgba(123, 224, 244, 1);
  }
 
  .aui-page__login__border .el-form-item {
    margin-bottom: 35px;
  }
 
  .aui-page__login__border .el-form-item__content .el-button {
    height: 50px;
  }
 
  .aui-page__login__border .el-form-item__content .el-input__inner {
    background: transparent !important;;
  }
 
  .aui-page__login__border .login-body .el-input__prefix .el-input__icon {
    font-size: 25px;
  }
 
  .aui-page__login__border .el-button {
    font-size: 20px;
  }
 
  .login-time {
    position: absolute;
    font-family: "Source Han Sans CN", serif;
    color: rgba(11, 222, 243, 1);
    z-index: 1;
    left: 4%;
    bottom: 7%;
  }
 
  .login-time span:nth-child(1) {
    font-size: 30px;
  }
 
  .login-time span:nth-child(3) {
    font-size: 80px;
  }
 
  .aui-page__login__border.el-button--primary:hover,
  .aui-page__login__border.el-button--primary:focus {
    color: rgba(0, 153, 255, 1)
  }
 
  input:-webkit-autofill,
  textarea:-webkit-autofill,
  select:-webkit-autofill {
    -webkit-text-fill-color: rgba(123, 224, 244, 1) !important;
    -webkit-box-shadow: 0 0 0 1000px transparent inset !important;
    background-color: transparent;
    background-image: none;
    transition: background-color 50000s ease-in-out 5000s;
  }
</style>