feat: 维护商户信息
This commit is contained in:
parent
5abb93d202
commit
66ba90718d
|
@ -32,3 +32,19 @@ export function listPlatformCategory(params) {
|
|||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function getMerchantList(params) {
|
||||
return request({
|
||||
url: '/merchant-api/merchant/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function updatePassword(data) {
|
||||
return request({
|
||||
url: '/merchant-api/auth/update_password',
|
||||
method: 'put',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
|
|
@ -136,13 +136,13 @@
|
|||
</template>
|
||||
|
||||
<template v-if="form.operationType === 'update'">
|
||||
<el-form-item label="选择商户账号" prop="accountId">
|
||||
<el-select v-model="form.accountId" placeholder="请选择要更新的商户账号" @change="handleAccountChange" style="width: 100%">
|
||||
<el-form-item label="选择商户账号" prop="merchantId">
|
||||
<el-select v-model="form.merchantId" placeholder="请选择要更新的商户账号" @change="handleAccountChange" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in merchantAccountList"
|
||||
:key="item.accountId"
|
||||
:key="item.merchantId"
|
||||
:label="item.name"
|
||||
:value="item.accountId"
|
||||
:value="item.merchantId"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
@ -194,9 +194,8 @@
|
|||
import {
|
||||
getAvailablePermissions,
|
||||
checkUsername,
|
||||
resetPassword
|
||||
} from '@/api/modules/subaccount' // Assuming some APIs can be reused
|
||||
import { inviteJoin, setMerchantPermissions, shopBaseConfig, listPlatformCategory } from '@/api/modules/merchant' // New merchant API
|
||||
import { inviteJoin, setMerchantPermissions, shopBaseConfig, listPlatformCategory, getMerchantList, updatePassword } from '@/api/modules/merchant' // New merchant API
|
||||
import { mer_admin } from '@/api/modules/mer_admin'
|
||||
import routerConfig from '@/router/full-routers'
|
||||
import { mapState } from 'vuex'
|
||||
|
@ -260,7 +259,7 @@ export default {
|
|||
mobile: '',
|
||||
password: '',
|
||||
permissionCodes: [],
|
||||
accountId: null,
|
||||
merchantId: null,
|
||||
enable: true,
|
||||
selectedMarketId: '',
|
||||
name: '',
|
||||
|
@ -333,7 +332,7 @@ export default {
|
|||
permissionCodes: [
|
||||
{ required: true, message: "请选择菜单权限", trigger: "change", type: 'array' },
|
||||
],
|
||||
accountId: [
|
||||
merchantId: [
|
||||
{ required: true, message: "请选择要更新的商户账号", trigger: "change" },
|
||||
],
|
||||
},
|
||||
|
@ -362,7 +361,7 @@ export default {
|
|||
this.form.mobile = '';
|
||||
this.form.password = '';
|
||||
this.form.permissionCodes = [];
|
||||
this.form.accountId = null;
|
||||
this.form.merchantId = null;
|
||||
|
||||
this.$nextTick(() => {
|
||||
this.$refs.ruleFormRef.clearValidate();
|
||||
|
@ -373,7 +372,7 @@ export default {
|
|||
}
|
||||
|
||||
if (newType === 'update') {
|
||||
// this.loadMerchantAccountList(); // To be implemented
|
||||
this.loadMerchantAccountList();
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -396,7 +395,7 @@ export default {
|
|||
});
|
||||
},
|
||||
openResetPasswordDialog() {
|
||||
if (!this.form.accountId) {
|
||||
if (!this.form.merchantId) {
|
||||
this.$message.error('请先选择要更新的商户账号');
|
||||
return;
|
||||
}
|
||||
|
@ -407,7 +406,7 @@ export default {
|
|||
this.$message.error('请输入新密码');
|
||||
return;
|
||||
}
|
||||
resetPassword(this.form.accountId, this.newPassword, this.form.selectedMarketId || this.marketId).then(() => {
|
||||
updatePassword({ password: this.newPassword }).then(() => {
|
||||
this.$message.success('密码重置成功');
|
||||
this.resetPasswordDialogVisible = false;
|
||||
});
|
||||
|
@ -445,22 +444,21 @@ export default {
|
|||
handlePermitsRemove(file, fileList) {
|
||||
this.form.permits = fileList;
|
||||
},
|
||||
// To be implemented
|
||||
// loadMerchantAccountList() {
|
||||
// getMerchantAccountList().then(res => {
|
||||
// this.merchantAccountList = res.data.data.data || [];
|
||||
// });
|
||||
// },
|
||||
handleAccountChange(accountId) {
|
||||
if (!accountId) return;
|
||||
// getMerchantAccountDetail(accountId).then(res => {
|
||||
// const accountDetails = res.data.data;
|
||||
// this.form.permissionCodes = accountDetails.permissionCodes || [];
|
||||
// this.form.enable = accountDetails.enabled;
|
||||
// this.$nextTick(() => {
|
||||
// this.$refs.permissionTree.setCheckedKeys(this.form.permissionCodes);
|
||||
// });
|
||||
// });
|
||||
loadMerchantAccountList() {
|
||||
getMerchantList({ marketId: this.form.selectedMarketId || this.marketId }).then(res => {
|
||||
this.merchantAccountList = res.data.data || [];
|
||||
});
|
||||
},
|
||||
handleAccountChange(merchantId) {
|
||||
if (!merchantId) return;
|
||||
const accountDetails = this.merchantAccountList.find(item => item.merchantId === merchantId);
|
||||
if (accountDetails) {
|
||||
this.form.permissionCodes = accountDetails.permissionCodes || [];
|
||||
this.form.enable = accountDetails.enabled;
|
||||
this.$nextTick(() => {
|
||||
this.$refs.permissionTree.setCheckedKeys(this.form.permissionCodes);
|
||||
});
|
||||
}
|
||||
},
|
||||
save() {
|
||||
this.$refs.ruleFormRef.validate((valid) => {
|
||||
|
@ -503,20 +501,19 @@ export default {
|
|||
});
|
||||
});
|
||||
} else if (this.form.operationType === 'update') {
|
||||
if (!this.form.accountId) {
|
||||
if (!this.form.merchantId) {
|
||||
this.$message.error('请先选择要更新的商户账号');
|
||||
return;
|
||||
}
|
||||
const updateData = {
|
||||
subAccountId: this.form.accountId,
|
||||
const permissionsData = {
|
||||
merchantAccountId: this.form.merchantId,
|
||||
permissionCodes: this.form.permissionCodes,
|
||||
enabled: this.form.enable,
|
||||
marketId
|
||||
};
|
||||
// updateMerchantAccount(updateData).then(() => { // To be implemented
|
||||
// this.$message.success('商户信息更新成功');
|
||||
// this.$refs.ruleFormRef.resetFields();
|
||||
// });
|
||||
setMerchantPermissions(permissionsData).then(() => {
|
||||
this.$message.success('商户信息更新成功');
|
||||
this.$refs.ruleFormRef.resetFields();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue