fix: 优化旧账号的重置密码逻辑
This commit is contained in:
parent
f48f8da512
commit
c2732a05a6
|
@ -50,3 +50,12 @@ export function checkUsername (username) {
|
|||
params: { username }
|
||||
})
|
||||
}
|
||||
|
||||
// 重置子账号密码
|
||||
export function resetPassword (subAccountId, newPassword) {
|
||||
return httpRequest({
|
||||
url: httpRequest.adornUrl(`/merchant-api/subaccount/${subAccountId}/reset-password`),
|
||||
method: 'put',
|
||||
data: httpRequest.adornData({ newPassword })
|
||||
})
|
||||
}
|
||||
|
|
|
@ -35,6 +35,12 @@
|
|||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="warning" @click="openResetPasswordDialog">重置密码</el-button>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态">
|
||||
<el-switch v-model="form.enable" active-text="启用" inactive-text="禁用"></el-switch>
|
||||
</el-form-item>
|
||||
</template>
|
||||
|
||||
<el-form-item label="姓名" prop="name">
|
||||
|
@ -63,6 +69,23 @@
|
|||
<el-button type="primary" @click="save">保存</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<el-dialog
|
||||
title="重置密码"
|
||||
:visible.sync="resetPasswordDialogVisible"
|
||||
width="30%"
|
||||
@close="newPassword = ''"
|
||||
>
|
||||
<el-form label-width="80px">
|
||||
<el-form-item label="新密码">
|
||||
<el-input v-model="newPassword" type="password" placeholder="请输入新密码"></el-input>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button @click="resetPasswordDialogVisible = false">取 消</el-button>
|
||||
<el-button type="primary" @click="handleResetPassword">确 定</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
@ -73,7 +96,8 @@ import {
|
|||
getSubAccountList,
|
||||
getSubAccountDetail,
|
||||
updateSubAccount,
|
||||
checkUsername
|
||||
checkUsername,
|
||||
resetPassword
|
||||
} from '@/api/modules/subaccount'
|
||||
import routerConfig from '@/router/full-routers'
|
||||
|
||||
|
@ -131,6 +155,8 @@ export default {
|
|||
};
|
||||
|
||||
return {
|
||||
resetPasswordDialogVisible: false,
|
||||
newPassword: '',
|
||||
form: {
|
||||
operationType: 'create',
|
||||
username: '',
|
||||
|
@ -139,7 +165,8 @@ export default {
|
|||
mobile: '',
|
||||
permissionCodes: [],
|
||||
remark: '',
|
||||
accountId: null
|
||||
accountId: null,
|
||||
enable: true
|
||||
},
|
||||
subAccountList: [],
|
||||
permissionList: [],
|
||||
|
@ -210,13 +237,30 @@ export default {
|
|||
this.permissionList = mapTreeForElTree(filteredTree);
|
||||
});
|
||||
},
|
||||
openResetPasswordDialog() {
|
||||
if (!this.form.accountId) {
|
||||
this.$message.error('请先选择要更新的账号');
|
||||
return;
|
||||
}
|
||||
this.resetPasswordDialogVisible = true;
|
||||
},
|
||||
handleResetPassword() {
|
||||
if (!this.newPassword) {
|
||||
this.$message.error('请输入新密码');
|
||||
return;
|
||||
}
|
||||
resetPassword(this.form.accountId, this.newPassword).then(() => {
|
||||
this.$message.success('密码重置成功');
|
||||
this.resetPasswordDialogVisible = false;
|
||||
});
|
||||
},
|
||||
handleTreeCheck() {
|
||||
// getCheckedKeys(true) will return an array of keys of the currently checked leaf nodes.
|
||||
this.form.permissionCodes = this.$refs.permissionTree.getCheckedKeys(true);
|
||||
},
|
||||
loadSubAccountList() {
|
||||
getSubAccountList().then(res => {
|
||||
this.subAccountList = res.data.data || [];
|
||||
this.subAccountList = res.data.data.data || [];
|
||||
});
|
||||
},
|
||||
handleAccountChange(accountId) {
|
||||
|
@ -227,6 +271,7 @@ export default {
|
|||
this.form.mobile = accountDetails.mobile;
|
||||
this.form.remark = accountDetails.remark;
|
||||
this.form.permissionCodes = accountDetails.permissionCodes || [];
|
||||
this.form.enable = accountDetails.enabled;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.permissionTree.setCheckedKeys(this.form.permissionCodes);
|
||||
});
|
||||
|
@ -255,7 +300,7 @@ export default {
|
|||
mobile: this.form.mobile,
|
||||
permissionCodes: this.form.permissionCodes,
|
||||
remark: this.form.remark,
|
||||
enabled: true // 根据示例,默认为 true
|
||||
enabled: this.form.enable
|
||||
};
|
||||
updateSubAccount(updateData).then(() => {
|
||||
this.$message.success('更新成功');
|
||||
|
|
Loading…
Reference in New Issue