feat(system): 实现登录时修改密码功能- 新增 externalUpdatePassword 接口用于登录时修改密码- 修改 ResetPasswordDialog 组件,支持登录时和登录后的不同修改密码流程-优化 login 页面的密码修改逻辑,处理需要验证码的情况- 调整 rule 接口和规则编辑页面的相关显示内容

This commit is contained in:
陈昱达
2025-08-14 15:25:51 +08:00
parent 520dbd2b14
commit 8a2e77687f
7 changed files with 152 additions and 52 deletions

View File

@@ -66,6 +66,15 @@ export function updatePassword(data) {
back: true
})
}
export function externalUpdatePassword(data) {
return request({
url: getUrl(`/sysUserEx/externalUpdatePassword`),
method: 'post',
data
// back: true
})
}
export function verifyUpdatePassword(data) {
return request({
url: getUrl(`/sysUserEx/verifyUpdatePassword`),

View File

@@ -4,7 +4,7 @@ import getUrl from '@/assets/js/utils/get-url'
// 分页查询
export function getRulePage(data) {
return request({
url: getUrl('/risk/check/rule/page'),
url: getUrl('/riskCheckRuleEx/page'),
method: 'post',
data
})

View File

@@ -70,6 +70,13 @@ const actions = {
message: res.content.resultMessage
})
break
case 51004:
// 需要验证码
resolve({
...res.content,
code: numberResult
})
break
default:
reject(res.content)
break

View File

@@ -121,6 +121,8 @@
<reset-password-dialog
:visible.sync="resetPasswordVisible"
:hideDialog="true"
:isLogin="true"
:user-name="loginForm.userName"
></reset-password-dialog>
</div>
</template>
@@ -299,11 +301,13 @@ export default {
this.$store
.dispatch('user/login', this.loginForm)
.then(res => {
if (res.code === 0) {
sessionStorage.setItem(
'tipMessage',
res.content.resultEnMessage ? res.content.resultEnMessage : ''
)
if (res.code === 0 || res.code === 51004) {
if (res.code === 51004) {
sessionStorage.setItem(
'tipMessage',
res.content.resultMessage ? res.content.resultMessage : ''
)
}
this.$router.push({ path: '/home' })
this.loading = false
return

View File

@@ -183,9 +183,9 @@ export default {
{ required: true, message: '请输入规则描述', trigger: 'blur' },
{
min: 1,
max: 300,
max: 1000,
message:
'规则描述支持录入汉字、大写字母、小写字母、数字、符号,不超过300个字请重新输入',
'规则描述支持录入汉字、大写字母、小写字母、数字、符号,不超过1000个字请重新输入',
trigger: 'blur'
}
],

View File

@@ -501,6 +501,54 @@ export default {
},
{ prop: 'ruleDesc', key: '规则描述' },
{ prop: 'riskScript', key: '风险提示话术' },
{
prop: 'hitCount',
key: '触发次数',
render: (h, params) => {
return h(
'el-tag',
{
props: {
type: 'info',
size: 'small'
}
},
params.row.hitCount ? params.row.hitCount + '次' : '0次'
)
}
},
{
prop: 'approvedCount',
key: '审批通过次数',
render: (h, params) => {
return h(
'el-tag',
{
props: {
type: 'success',
size: 'small'
}
},
params.row.approvedCount ? params.row.approvedCount + '次' : '0次'
)
}
},
{
prop: 'refusedCount',
key: '审批不通过次数',
render: (h, params) => {
return h(
'el-tag',
{
props: {
type: 'danger',
size: 'small'
}
},
params.row.refusedCount ? params.row.refusedCount + '次' : '0次'
)
}
},
{
prop: 'ruleStatus',
key: '规则状态',

View File

@@ -59,14 +59,18 @@
</r-dialog>
<send-phone-code
:visible.sync="phoneVisabled"
:resetPassword="true"
:resetPassword="!isLogin"
@handleSubmit="handleSubmit"
></send-phone-code>
</div>
</template>
<script>
import { updatePassword, verifyUpdatePassword } from '@/api/generatedApi/system'
import {
externalUpdatePassword,
updatePassword,
verifyUpdatePassword
} from '@/api/generatedApi/system'
import SendPhoneCode from '@/generatedComponents/send-phone-code.vue'
export default {
@@ -84,6 +88,14 @@ export default {
hideDialog: {
type: Boolean,
default: false
},
isLogin: {
type: Boolean,
default: false
},
userName: {
type: String,
default: ''
}
},
data() {
@@ -121,23 +133,39 @@ export default {
},
methods: {
handleSubmit(code) {
verifyUpdatePassword({
userPassword: this.form.userPassword,
newPassword: this.form.newPassword,
smsCode: code
}).then(async res => {
if (res) {
if (!this.hideDialog) {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
} else {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
if (!this.isLogin) {
verifyUpdatePassword({
userPassword: this.form.userPassword,
newPassword: this.form.newPassword,
smsCode: code
}).then(async res => {
if (res) {
if (!this.hideDialog) {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
} else {
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.phoneVisabled = false
this.handleClose()
}
}
})
} else {
externalUpdatePassword({
username: this.userName,
userPassword: this.form.userPassword,
newPassword: this.form.newPassword,
smsCode: code
}).then(res => {
if (res) {
this.$message.success('修改密码成功')
this.phoneVisabled = false
this.handleClose()
}
}
})
})
}
},
handleClose() {
this.$refs.form.resetFields()
@@ -146,34 +174,38 @@ export default {
submitForm() {
this.$refs.form.validate(valid => {
if (valid) {
this.loading = true
const data = {
userPassword: this.form.userPassword,
newPassword: this.form.newPassword
}
if (!this.isLogin) {
this.loading = true
const data = {
userPassword: this.form.userPassword,
newPassword: this.form.newPassword
}
updatePassword(data)
.then(async res => {
let number = Number(res.content.result)
switch (number) {
case 0:
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
break
case 51001:
this.phoneVisabled = true
break
default:
this.$message.error(res.content.resultMessage)
}
})
.catch(() => {
this.$message.error('系统异常,请联系管理员')
})
.finally(() => {
this.loading = false
})
updatePassword(data)
.then(async res => {
let number = Number(res.content.result)
switch (number) {
case 0:
this.$message.success('密码修改成功')
await this.$store.dispatch('user/logout')
this.$router.push(`/login?redirect=${this.$route.fullPath}`)
break
case 51001:
this.phoneVisabled = true
break
default:
this.$message.error(res.content.resultMessage)
}
})
.catch(() => {
this.$message.error('系统异常,请联系管理员')
})
.finally(() => {
this.loading = false
})
} else {
this.phoneVisabled = true
}
}
})
}