From 7a228d5837e006af03e76db757e0f559e131f4b4 Mon Sep 17 00:00:00 2001 From: zhaowei <zhaowei> Date: 星期五, 23 五月 2025 13:37:17 +0800 Subject: [PATCH] Merge remote-tracking branch 'origin/master' --- src/views/dnc/base/OperatorLogin.vue | 268 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 268 insertions(+), 0 deletions(-) diff --git a/src/views/dnc/base/OperatorLogin.vue b/src/views/dnc/base/OperatorLogin.vue new file mode 100644 index 0000000..1f57fad --- /dev/null +++ b/src/views/dnc/base/OperatorLogin.vue @@ -0,0 +1,268 @@ +<template> + <div class="login-bg"> + <div class="login-container"> + <a-card class="login-card"> + <h2 class="title">鐧诲綍</h2> + + <a-form-model :model="model" ref="form" :rules="validateRules" @keyup.enter.native="handleLogin"> + <!-- 鍒峰崱鐧诲綍杈撳叆妗� --> + <a-form-model-item prop="workNo" :has-feedback="feedbackConfig.workNoFeedback"> + <a-input v-model="model.workNo" placeholder="璇峰埛鍗℃垨杈撳叆鍗″彿" size="large" autocomplete="off" + @change="clearAnotherLoginInfo('workNo')"> + <a-icon slot="prefix" type="credit-card"/> + </a-input> + </a-form-model-item> + + <div class="divider"> + <span class="line"></span> + <span class="text">鎴�</span> + <span class="line"></span> + </div> + + <!-- 甯歌鐧诲綍琛ㄥ崟 --> + <a-form-model-item prop="username" :has-feedback="feedbackConfig.usernameFeedback"> + <a-input + v-model="model.username" + placeholder="鐢ㄦ埛鍚�" + size="large" + @change="clearAnotherLoginInfo('username')" + autocomplete="off" + > + <a-icon slot="prefix" type="user"/> + </a-input> + </a-form-model-item> + + <a-form-model-item prop="password" :has-feedback="feedbackConfig.passwordFeedback"> + <a-input-password + v-model="model.password" + placeholder="瀵嗙爜" + size="large" + @change="clearAnotherLoginInfo('password')" + autocomplete="off" + > + <a-icon slot="prefix" type="lock"/> + </a-input-password> + </a-form-model-item> + + <a-button type="primary" size="large" block :loading="loading" @click="handleLogin">鐧诲綍</a-button> + </a-form-model> + <!--<div class="footer">--> + <!--<a @click="handleRegister">娉ㄥ唽璐﹀彿</a>--> + <!--<a @click="handleForget">蹇樿瀵嗙爜</a>--> + <!--</div>--> + </a-card> + </div> + </div> +</template> + +<script> + import { mapActions } from 'vuex' + import { timeFix } from '@/utils/util' + + export default { + name: 'OperatorLogin', + data() { + return { + model: { + isOperator: true // 鍒ゆ柇鏄摢涓櫥褰曢〉鐧诲綍 + }, + feedbackConfig: { + workNoFeedback: true, + usernameFeedback: true, + passwordFeedback: true + }, + loading: false, + validateRules: { + workNo: [ + { validator: this.checkWorkNo, trigger: 'blur' } + ], + username: [ + { validator: this.checkUsername, trigger: 'blur' } + ], + password: [ + { validator: this.checkPassword, trigger: 'blur' } + ] + } + } + }, + methods: { + ...mapActions(['Login']), + + handleLogin() { + this.$refs.form.validate(valid => { + if (valid) { + this.loading = true + + if (this.model.workNo) this.$refs.form.clearValidate(['username', 'password']) + else this.$refs.form.clearValidate('workNo') + + console.log('鐧诲綍淇℃伅:', this.model) + + this.Login(this.model) + .then((res) => { + this.loginSuccess(res.result) + }) + .catch((err) => { + this.loginFailed(err, this.model.username) + }) + } else { + return false + } + }) + }, + + loginSuccess() { + this.$router.push({ path: '/terminal/index' }).catch(() => { + }) + + this.$notification.success({ + message: '娆㈣繋', + description: `${timeFix()}锛屾杩庡洖鏉 + }) + this.loading = false + }, + + //鐧诲綍鍚庡彴澶辫触 + loginFailed(err, username) { + let description = ((err.response || {}).data || {}).message || err.message || '璇锋眰鍑虹幇閿欒锛岃绋嶅悗鍐嶈瘯' + + this.$notification.error({ + message: '鐧诲綍澶辫触', + description: description + }) + this.loading = false + }, + + /** + * 杈撳叆妗嗗�兼敼鍙樻椂瑙﹀彂 + * @param inputProp 杈撳叆妗嗗搴斿睘鎬� + */ + clearAnotherLoginInfo(inputProp) { + this.feedbackConfig[inputProp + 'Feedback'] = true + + if (inputProp === 'workNo') { + delete this.model.username + delete this.model.password + this.$refs.form.clearValidate(['username', 'password']) + } else { + delete this.model.workNo + this.$refs.form.clearValidate('workNo') + } + }, + + checkWorkNo(rule, value, callback) { + if (!this.model.username && !this.model.password) { + if (!value) { + callback(new Error('璇峰埛鍗℃垨杈撳叆鍗″彿锛�')) + this.feedbackConfig.usernameFeedback = this.feedbackConfig.passwordFeedback = true + } else { + callback() + } + } else { + this.feedbackConfig.workNoFeedback = false + callback() + } + }, + + checkUsername(rule, value, callback) { + if (!this.model.workNo) { + if (!value) { + callback(new Error('璇疯緭鍏ョ敤鎴峰悕锛�')) + if (!this.model.password) this.feedbackConfig.workNoFeedback = true + } else { + callback() + } + } else { + this.feedbackConfig.usernameFeedback = false + callback() + } + }, + + checkPassword(rule, value, callback) { + if (!this.model.workNo) { + if (!value) { + callback(new Error('璇疯緭鍏ュ瘑鐮侊紒')) + if (!this.model.username) this.feedbackConfig.workNoFeedback = true + } else { + callback() + } + } else { + this.feedbackConfig.passwordFeedback = false + callback() + } + } + + // handleRegister() { + // this.$router.push('/register') + // }, + // handleForget() { + // this.$message.info('璇疯仈绯荤鐞嗗憳閲嶇疆瀵嗙爜') + // } + } + } +</script> + +<style lang="less" scoped> + .login-bg { + display: flex; + justify-content: center; + align-items: center; + min-height: 100vh; + background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), + url('../../../assets/operator-login-bg.png') no-repeat center; + background-size: cover; + + .login-container { + width: 100%; + max-width: 420px; + padding: 0 20px; + + .login-card { + border-radius: 8px; + box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); + background: rgba(255, 255, 255, 0.95); + + .title { + margin-bottom: 24px; + text-align: center; + color: #1890ff; + font-size: 24px; + font-weight: 500; + } + + .divider { + display: flex; + align-items: center; + margin: 20px 0; + + .line { + flex: 1; + height: 1px; + background: rgba(0, 0, 0, 0.15); + } + + .text { + padding: 0 16px; + color: rgba(0, 0, 0, 0.45); + } + } + + .footer { + display: flex; + justify-content: space-between; + margin-top: 16px; + + a { + color: #1890ff; + cursor: pointer; + + &:hover { + text-decoration: underline; + } + } + } + } + } + + } +</style> -- Gitblit v1.9.3