Commit 4eda831e authored by guang.wu's avatar guang.wu

fix: 审核品牌

parent dbb6e05c
/**
* 数据模型转换-接口获取数据转换为表单数据
*/
export const transformVOToFormData = data => {
const params = { ...data };
if (params.authorizationUrl) {
params.authorizationUrl = [params.authorizationUrl];
}
if (params.horizontalLogo) {
params.horizontalLogo = [params.horizontalLogo];
}
if (params.logo) {
params.logo = [params.logo];
}
if (params.qualifyUrl) {
params.qualifyUrl = [params.qualifyUrl];
}
return params;
};
/*
* 表单数据转换-表单数据转换为接口数据
*/
export const transformFormDataToDTO = res => {
const params = { ...res };
if (params.authorizationUrl?.length) {
params.authorizationUrl = params.authorizationUrl.join(',');
}
if (params.horizontalLogo?.length) {
params.horizontalLogo = params.horizontalLogo.join(',');
}
if (params.logo?.length) {
params.logo = params.logo.join(',');
}
if (params.qualifyUrl?.length) {
params.qualifyUrl = params.qualifyUrl.join(',');
}
return params;
};
...@@ -2,21 +2,45 @@ import React from 'react'; ...@@ -2,21 +2,45 @@ import React from 'react';
import { BetaSchemaForm } from '@ant-design/pro-components'; import { BetaSchemaForm } from '@ant-design/pro-components';
import { brandInfoColumn } from '../staticData.js'; import { brandInfoColumn } from '../staticData.js';
import { layout } from '@/utils/bll'; import { layout } from '@/utils/bll';
import { apiBrandDetail, apiCreateBrand, apiEditBrand, apiAppendQualifyBrand } from '../services';
import { transformVOToFormData, transformFormDataToDTO } from '../bll.js';
const BrandInfo = props => { const BrandInfo = props => {
const refForm = React.useRef(); const refForm = React.useRef();
const { actionStatus, brandId } = props; const { actionStatus, brandId } = props;
const closeModal = v => { const closeModal = v => {
!v && props.onClose(); !v && props.onClose(false);
};
const getAPI = () => {
switch (actionStatus) {
case 'edit':
return apiEditBrand;
case 'supplement':
return apiAppendQualifyBrand;
default:
return apiCreateBrand;
}
}; };
const submitForm = async values => { const submitForm = async values => {
console.log(values); const params = transformFormDataToDTO(values);
params.brandId = brandId;
params.id = brandId;
const api = getAPI();
const res = api(params);
if (res) {
props.onClose(true);
}
}; };
const getInfo = () => const getInfo = async () => {
Promise.resolve({ if (brandId) {
imageList: ['https://img.yzcdn.cn/vant/cat.jpeg', 'https://img.yzcdn.cn/vant/cat.jpeg'], const res = await apiBrandDetail({ brandId });
}); if (res?.data) {
return transformVOToFormData(res.data);
}
}
return {};
};
const config = { actionStatus }; const config = { actionStatus };
......
...@@ -21,6 +21,11 @@ const BrandManage = () => { ...@@ -21,6 +21,11 @@ const BrandManage = () => {
setVisible(!0); setVisible(!0);
}; };
const onClose = refresh => {
setVisible(false);
refresh && refTable.current.reload();
};
return ( return (
<> <>
<ProTable <ProTable
...@@ -50,7 +55,7 @@ const BrandManage = () => { ...@@ -50,7 +55,7 @@ const BrandManage = () => {
添加 添加
</Button>, </Button>,
]} ]}
rowKey={r => r.id} rowKey={r => r.brandId}
bordered bordered
options={false} options={false}
/> />
...@@ -58,7 +63,7 @@ const BrandManage = () => { ...@@ -58,7 +63,7 @@ const BrandManage = () => {
visible={visible} visible={visible}
actionStatus={actionStatus} actionStatus={actionStatus}
brandId={id} brandId={id}
onClose={() => setVisible(false)} onClose={onClose}
id={id} id={id}
/> />
</> </>
......
import qs from 'qs';
import request from '@/utils/request'; import request from '@/utils/request';
import config from '@/../config/env.config'; import config from '@/../config/env.config';
...@@ -12,13 +13,13 @@ export async function apiBrandList(params) { ...@@ -12,13 +13,13 @@ export async function apiBrandList(params) {
...params, ...params,
pageNo: params.current, pageNo: params.current,
}; };
const [data] = await request.post(`${goodsApi}/api/merchants/brands/list`, param, { const res = await request.get(`/api/merchants/brands/list?${qs.stringify(param)}`, {
emulateJSON: true, prefix: kdspApi,
}); });
if (data) { if (res?.data) {
return { return {
total: data.total, total: res.data.total,
data: data.records, data: res.data.records,
}; };
} }
return { return {
...@@ -31,16 +32,33 @@ export async function apiBrandList(params) { ...@@ -31,16 +32,33 @@ export async function apiBrandList(params) {
* 添加品牌 * 添加品牌
* http://yapi.quantgroups.com/project/389/interface/api/66389 * http://yapi.quantgroups.com/project/389/interface/api/66389
* */ * */
export async function apiCreateBrand(params) { export async function apiCreateBrand(data) {
return request.post(`${goodsApi}/api/merchants/brands/add`, params); return request.post('/api/merchants/brands/add', {
data,
prefix: kdspApi,
});
} }
/** /**
* 编辑品牌 * 编辑品牌
* http://yapi.quantgroups.com/project/389/interface/api/66394 * http://yapi.quantgroups.com/project/389/interface/api/66394
*/ */
export async function apiEditBrand(params) { export async function apiEditBrand(data) {
return request.post(`${goodsApi}/api/merchants/brands/edit`, params); return request.post('/api/merchants/brands/edit', {
data,
prefix: kdspApi,
});
}
/**
* 补充资质
* http://yapi.quantgroups.com/project/389/interface/api/66399
*/
export async function apiAppendQualifyBrand(data) {
return request.post('/api/merchants/brands/qualify/add', {
data,
prefix: kdspApi,
});
} }
/** /**
...@@ -48,5 +66,7 @@ export async function apiEditBrand(params) { ...@@ -48,5 +66,7 @@ export async function apiEditBrand(params) {
* http://yapi.quantgroups.com/project/389/interface/api/66409 * http://yapi.quantgroups.com/project/389/interface/api/66409
* */ * */
export async function apiBrandDetail(params) { export async function apiBrandDetail(params) {
return request.get(`${goodsApi}/api/merchants/brands/detail`, params); return request.get(`/api/merchants/brands/detail?${qs.stringify(params)}`, {
prefix: kdspApi,
});
} }
...@@ -2,28 +2,62 @@ import React from 'react'; ...@@ -2,28 +2,62 @@ import React from 'react';
import { Button } from 'antd'; import { Button } from 'antd';
import UploadImage from '@/components/UploadImg/index.jsx'; import UploadImage from '@/components/UploadImg/index.jsx';
// 品牌审核状态 0待审核 1审核通过 2驳回 // 品牌审核状态
/**
* @description: 品牌审核状态 1-待审核
*/
export const auditStatusWait = 1;
/**
* @description: 品牌审核状态 2-审核通过
*/
export const auditStatusPass = 2;
/**
* @description: 品牌审核状态 3-审核拒绝
*/
export const auditStatusReject = 3;
/**
* @description: 品牌审核状态枚举 0-无 1-待审核,2-审核通过,3-审核拒绝
*/
export const brandStatusEnum = { export const brandStatusEnum = {
0: '待审核', 0: '-',
1: '审核通过', [auditStatusWait]: '待审核',
2: '驳回', [auditStatusPass]: '审核通过',
[auditStatusReject]: '驳回',
}; };
// 品牌审核 1审核通过 2驳回 /**
* @description: 品牌审核 2审核通过 3驳回
*/
export const brandAuditEnum = { export const brandAuditEnum = {
1: '审核通过', [auditStatusPass]: '审核通过',
2: '驳回', [auditStatusReject]: '驳回',
}; };
// 操作状态 查看、修改、添加、补充资质 // 操作状态 查看、修改、添加、补充资质
/**
* @description: 品牌操作状态 查看
*/
export const brandActionFind = 'find'; export const brandActionFind = 'find';
/**
* @description: 品牌操作状态 修改
*/
export const brandActionEdit = 'edit'; export const brandActionEdit = 'edit';
/**
* @description: 品牌操作状态 添加
*/
export const brandActionAdd = 'add'; export const brandActionAdd = 'add';
/**
* @description: 品牌操作状态 补充资质
*/
export const brandActionSupplement = 'supplement'; export const brandActionSupplement = 'supplement';
/**
* @description: 列表基础字段
*/
export const brandBaseColumn = [ export const brandBaseColumn = [
{ {
title: '品牌名称', title: '品牌名称',
dataIndex: 'brandName', dataIndex: 'name',
key: 'brandName', key: 'name',
}, },
{ {
title: '中文名称', title: '中文名称',
...@@ -60,6 +94,12 @@ export const brandColumn = config => { ...@@ -60,6 +94,12 @@ export const brandColumn = config => {
align: 'center', align: 'center',
valueEnum: brandStatusEnum, valueEnum: brandStatusEnum,
}, },
{
title: '驳回原因',
key: 'rejectReason',
dataIndex: 'rejectReason',
align: 'center',
},
{ {
title: '操作', title: '操作',
hideInSearch: true, hideInSearch: true,
...@@ -67,12 +107,18 @@ export const brandColumn = config => { ...@@ -67,12 +107,18 @@ export const brandColumn = config => {
align: 'center', align: 'center',
width: 200, width: 200,
render: (_, r) => [ render: (_, r) => [
<Button key="check" type="primary" onClick={() => onAction(r, 'edit')}> (r.modifiable && (
修改 <Button key="check" type="primary" onClick={() => onAction(r, 'edit')}>
</Button>, 修改
<Button key="update" type="primary" ghost onClick={() => onAction(r, 'supplement')}> </Button>
补充资质 )) ||
</Button>, '',
([null, auditStatusReject].includes(r.status) && (
<Button key="supplement" type="primary" ghost onClick={() => onAction(r, 'supplement')}>
补充资质
</Button>
)) ||
'',
], ],
}, },
]; ];
...@@ -81,7 +127,7 @@ export const brandColumn = config => { ...@@ -81,7 +127,7 @@ export const brandColumn = config => {
// 品牌信息字段 // 品牌信息字段
export const brandInfoColumn = config => { export const brandInfoColumn = config => {
const { actionStatus } = config; const { actionStatus } = config;
const disabled = brandActionEdit !== actionStatus; const disabled = brandActionSupplement === actionStatus;
const baseInfo = [ const baseInfo = [
{ {
title: '资质证书', title: '资质证书',
...@@ -154,7 +200,7 @@ export const brandInfoColumn = config => { ...@@ -154,7 +200,7 @@ export const brandInfoColumn = config => {
fieldProps: { fieldProps: {
disabled, disabled,
}, },
renderFormItem: () => <UploadImage limit={1} width={219} height={72} />, renderFormItem: () => <UploadImage limit={1} disabled={disabled} width={219} height={72} />,
}, },
{ {
title: 'LOGO上传', title: 'LOGO上传',
...@@ -166,7 +212,7 @@ export const brandInfoColumn = config => { ...@@ -166,7 +212,7 @@ export const brandInfoColumn = config => {
fieldProps: { fieldProps: {
disabled, disabled,
}, },
renderFormItem: () => <UploadImage limit={1} width={192} height={192} />, renderFormItem: () => <UploadImage limit={1} disabled={disabled} width={192} height={192} />,
}, },
]; ];
return baseInfo; return baseInfo;
......
...@@ -12,7 +12,7 @@ import config from '../../config/env.config'; ...@@ -12,7 +12,7 @@ import config from '../../config/env.config';
import IframeBridge from './iframeBridge'; import IframeBridge from './iframeBridge';
let isRefreshing = true; let isRefreshing = true;
let subscriber = []; const subscriber = [];
const codeMessage = { const codeMessage = {
200: '服务器成功返回请求的数据。', 200: '服务器成功返回请求的数据。',
...@@ -55,10 +55,12 @@ const request = extend({ ...@@ -55,10 +55,12 @@ const request = extend({
const addSubscriber = callback => subscriber.push(callback); const addSubscriber = callback => subscriber.push(callback);
const wait = async seconds => new Promise(resolve => setTimeout(resolve, seconds)); const wait = async seconds => new Promise(resolve => setTimeout(resolve, seconds));
const onAccessTokenFetched = () => { const onAccessTokenFetched = () => {
console.log('subscriber :>> ', subscriber);
subscriber.forEach(callback => callback()); subscriber.forEach(callback => callback());
subscriber = []; // subscriber = [];
}; };
const refreshRequest = async (url, options) => { const refreshRequest = async (url, options) => {
console.log('url, options :>> ', url, options);
const promise = new Promise(resolve => addSubscriber(() => resolve(request(url, options)))); const promise = new Promise(resolve => addSubscriber(() => resolve(request(url, options))));
if (isRefreshing) { if (isRefreshing) {
isRefreshing = false; isRefreshing = false;
...@@ -67,6 +69,7 @@ const refreshRequest = async (url, options) => { ...@@ -67,6 +69,7 @@ const refreshRequest = async (url, options) => {
if (data.code === 2000) { if (data.code === 2000) {
localStorage.set('token', data.data.accessToken); localStorage.set('token', data.data.accessToken);
} }
console.log('1111111 :>> ', subscriber.length);
onAccessTokenFetched(); onAccessTokenFetched();
isRefreshing = true; isRefreshing = true;
} }
...@@ -115,7 +118,7 @@ request.interceptors.response.use(async (response, options) => { ...@@ -115,7 +118,7 @@ request.interceptors.response.use(async (response, options) => {
}); });
} }
// token过期 // token过期
const url = response.url.split(config.api)[1]; const url = response.url.replace(options.prefix, '');
return refreshRequest(url, options); return refreshRequest(url, options);
} }
if (data.code === 4011) { if (data.code === 4011) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment