master
Joe 1 year ago
parent 6b24b5b845
commit a78991ea38

@ -179,6 +179,13 @@ export default [
access: 'messageQuery', access: 'messageQuery',
component: './MessageList', component: './MessageList',
}, },
{
name: '字典管理',
path: '/dictionary-list',
icon: 'message',
access: 'dictionaryQuery',
component: './Dictionary',
},
{ path: '/' }, { path: '/' },
{ path: '*', layout: false, component: './404' }, { path: '*', layout: false, component: './404' },
]; ];

@ -45,6 +45,10 @@ export default function access(initialState: { currentUser?: API.PbcUsersVO | un
message: false, message: false,
messageQuery: false, messageQuery: false,
messageDelete: false, messageDelete: false,
dictionary: false,
dictionaryQuery: false,
dictionaryAdd: false,
dictionaryUpdate: false,
}; };
for (let i = 0; i < currentUser?.currentAuthority.length; i++) { for (let i = 0; i < currentUser?.currentAuthority.length; i++) {
const element = currentUser?.currentAuthority[i]; const element = currentUser?.currentAuthority[i];

@ -129,6 +129,13 @@ const Constants = {
link: '链接', link: '链接',
share: '分享' share: '分享'
}, },
/**
*
*/
pbcSystemInputType: {
select: '下拉框',
text: '文本框',
},
// 手机正则 // 手机正则
PHONE_PATTERN: /^(?:(0\d{2,3}-)?\d{7,8}|1[3-9]\d{9})$/, PHONE_PATTERN: /^(?:(0\d{2,3}-)?\d{7,8}|1[3-9]\d{9})$/,
//邮箱正则 //邮箱正则

@ -1,7 +1,7 @@
import { businessViewRankUsingPost, exportBusinessViewRankUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; import { businessViewRankUsingPost, exportBusinessViewRankUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController';
import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Link } from '@umijs/max'; import { Link, useSearchParams } from '@umijs/max';
import { Button, message } from 'antd'; import { Button, message } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React, { useRef } from 'react'; import React, { useRef } from 'react';
@ -46,6 +46,9 @@ const handleExport = async (values?: API.PbcOperationalDashboardDTO) => {
const TableList: React.FC<{}> = () => { const TableList: React.FC<{}> = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const ref = useRef<ProFormInstance<API.PbcBusinessViewRankVO>>(); const ref = useRef<ProFormInstance<API.PbcBusinessViewRankVO>>();
const [searchParams] = useSearchParams();
const startDate = searchParams.get('startDate');
const endDate = searchParams.get('endDate');
const columns: ProColumns<API.PbcBusinessViewRankVO>[] = [ const columns: ProColumns<API.PbcBusinessViewRankVO>[] = [
{ {
@ -93,9 +96,10 @@ const TableList: React.FC<{}> = () => {
search: false search: false
}, },
{ {
title: '注册日期', title: '浏览日期',
dataIndex: 'pbcCreateAt', dataIndex: 'pbcCreateAt',
hideInTable: true, hideInTable: true,
initialValue: [moment(startDate),moment(endDate)],
fieldProps:{ fieldProps:{
maxDate: moment() maxDate: moment()
}, },

@ -49,6 +49,8 @@ import moment from 'moment';
const ref = useRef<ProFormInstance<API.PbcChannelMerchantDetailVO>>(); const ref = useRef<ProFormInstance<API.PbcChannelMerchantDetailVO>>();
const [searchParams] = useSearchParams(); const [searchParams] = useSearchParams();
const type = searchParams.get('type'); const type = searchParams.get('type');
const startDate = searchParams.get('startDate');
const endDate = searchParams.get('endDate');
const columns: ProColumns<API.PbcChannelMerchantDetailVO>[] = [ const columns: ProColumns<API.PbcChannelMerchantDetailVO>[] = [
{ {
@ -77,6 +79,7 @@ import moment from 'moment';
title: '访问时间', title: '访问时间',
dataIndex: 'pbcCreateAt', dataIndex: 'pbcCreateAt',
hideInTable: true, hideInTable: true,
initialValue: [moment(startDate),moment(endDate)],
fieldProps:{ fieldProps:{
maxDate: moment() maxDate: moment()
}, },

@ -2,6 +2,7 @@ import Constants from '@/constants';
import { exportPeopleScanDetailUsingPost, peopleScanDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController'; import { exportPeopleScanDetailUsingPost, peopleScanDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController';
import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProFormInstance, ProTable } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { useSearchParams } from '@umijs/max';
import { Button, message } from 'antd'; import { Button, message } from 'antd';
import moment from 'moment'; import moment from 'moment';
import React, { useRef } from 'react'; import React, { useRef } from 'react';
@ -46,6 +47,9 @@ const handleExport = async (values?: API.PbcOperationalDashboardDTO) => {
const TableList: React.FC<{}> = () => { const TableList: React.FC<{}> = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const ref = useRef<ProFormInstance<API.PbcPeopleScanDetailVO>>(); const ref = useRef<ProFormInstance<API.PbcPeopleScanDetailVO>>();
const [searchParams] = useSearchParams();
const startDate = searchParams.get('startDate');
const endDate = searchParams.get('endDate');
const columns: ProColumns<API.PbcPeopleScanDetailVO>[] = [ const columns: ProColumns<API.PbcPeopleScanDetailVO>[] = [
{ {
@ -73,6 +77,7 @@ const TableList: React.FC<{}> = () => {
title: '扫码时间', title: '扫码时间',
dataIndex: 'pbcCreateAt', dataIndex: 'pbcCreateAt',
valueType: 'dateRange', valueType: 'dateRange',
initialValue: [moment(startDate),moment(endDate)],
fieldProps:{ fieldProps:{
maxDate: moment() maxDate: moment()
}, },

@ -254,9 +254,18 @@ const Welcome: React.FC = () => {
<Card title="扫码情况" bodyStyle={{ display: 'flex', justifyContent: 'space-between' }} bordered={false}> <Card title="扫码情况" bodyStyle={{ display: 'flex', justifyContent: 'space-between' }} bordered={false}>
<Statistic title="扫码次数" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={pbcScanCodeStatical.pbcScanNumber || 0} /> <Statistic title="扫码次数" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={pbcScanCodeStatical.pbcScanNumber || 0} />
<Statistic title="扫码人数" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={pbcScanCodeStatical.pbcScanUserNumber || 0} /> <Statistic title="扫码人数" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={pbcScanCodeStatical.pbcScanUserNumber || 0} />
<Link to="/dashboard/scan-detail"> <Button type='link' onClick={() => {
const param: any = ref.current?.getFieldsValue()
let startDate = param.pbcQueryType == 1 ? dayjs().format('YYYY-MM-DD') : dayjs().date(1).format('YYYY-MM-DD')
let endDate = dayjs().format('YYYY-MM-DD')
if (param.dateRange) {
startDate = dayjs(param.dateRange[0]).format('YYYY-MM-DD')
endDate = dayjs(param.dateRange[1]).format('YYYY-MM-DD')
}
history.push(`/dashboard/scan-detail?startDate=${startDate}&endDate=${endDate}`)
}}>
<Statistic title="老客扫码/新客扫码>" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={`${pbcScanCodeStatical.oldCustomerScanCount || 0}/${pbcScanCodeStatical.newCustomerScanCount || 0}`} /> <Statistic title="老客扫码/新客扫码>" valueStyle={{ color: '#3f8600', fontSize: 30 }} value={`${pbcScanCodeStatical.oldCustomerScanCount || 0}/${pbcScanCodeStatical.newCustomerScanCount || 0}`} />
</Link> </Button>
</Card> </Card>
</Col> </Col>
<Col span={8}> <Col span={8}>
@ -270,7 +279,16 @@ const Welcome: React.FC = () => {
<Row style={{ marginBottom: 12 }} gutter={16}> <Row style={{ marginBottom: 12 }} gutter={16}>
<Col span={12}> <Col span={12}>
<Card title="商户浏览量排行" extra={ <Card title="商户浏览量排行" extra={
<Link to="/dashboard/business-views">{'更多>>'}</Link> <Button type="link" onClick={() => {
const param: any = ref.current?.getFieldsValue()
let startDate = param.pbcQueryType == 1 ? dayjs().format('YYYY-MM-DD') : dayjs().date(1).format('YYYY-MM-DD')
let endDate = dayjs().format('YYYY-MM-DD')
if (param.dateRange) {
startDate = dayjs(param.dateRange[0]).format('YYYY-MM-DD')
endDate = dayjs(param.dateRange[1]).format('YYYY-MM-DD')
}
history.push(`/dashboard/business-views?startDate=${startDate}&endDate=${endDate}`)
}}>{'更多>>'}</Button>
} bordered={false}> } bordered={false}>
<Bar {...config} data={data1} onReady={(plot) => { <Bar {...config} data={data1} onReady={(plot) => {
plot.on('plot:click', (evt: { x: any; y: any; }) => { plot.on('plot:click', (evt: { x: any; y: any; }) => {
@ -304,7 +322,14 @@ const Welcome: React.FC = () => {
} }
} }
} }
history.push('/dashboard/channel-statistics?type='+type) const param: any = ref.current?.getFieldsValue()
let startDate = param.pbcQueryType == 1 ? dayjs().format('YYYY-MM-DD') : dayjs().date(1).format('YYYY-MM-DD')
let endDate = dayjs().format('YYYY-MM-DD')
if (param.dateRange) {
startDate = dayjs(param.dateRange[0]).format('YYYY-MM-DD')
endDate = dayjs(param.dateRange[1]).format('YYYY-MM-DD')
}
history.push(`/dashboard/channel-statistics?type=${type}&startDate=${startDate}&endDate=${endDate}`)
}); });
}} /> }} />
</Card> </Card>

@ -0,0 +1,83 @@
import React, { useRef } from 'react';
import { DrawerForm, ProFormInstance, ProFormSelect, ProFormText } from '@ant-design/pro-components';
import Constants from '@/constants';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.PbcSpecification>;
export type UpdateFormProps = {
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
onSubmit: (values: FormValueType) => Promise<void>;
updateModalVisible: boolean;
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const formRef = useRef<ProFormInstance>();
return (
<DrawerForm
width={640}
title={'新增规格'}
open={props.updateModalVisible}
formRef={formRef}
onFinish={(value: API.PbcSpecification) => {
return props.onSubmit({ ...value })
}}
drawerProps={{
destroyOnClose: true,
}}
onOpenChange={(visible) => {
formRef.current?.resetFields();
if (!visible) {
props.onCancel();
}
}}
>
<ProFormText
placeholder={'请输入规格key'}
label="规格key"
rules={[
{
required: true,
message: '规格key为必填项',
},
{
pattern: /^[A-Za-z]+$/,
message: '规格key格式为英文字母',
},
]}
width="md"
name="pbcSystemKey"
/>
<ProFormText
placeholder={'请输入规格名称'}
label="规格名称"
rules={[
{
required: true,
message: '规格名称为必填项',
},
]}
width="md"
name="pbcSystemName"
/>
<ProFormSelect
placeholder={'请输入输入类型'}
label="输入类型"
rules={[
{
required: true,
message: '输入类型为必填项',
}
]}
valueEnum={Constants.pbcSystemInputType}
width="md"
name="pbcSystemInputType"
/>
</DrawerForm>
);
};
export default UpdateForm;

@ -0,0 +1,53 @@
import React, { useRef } from 'react';
import { DrawerForm, ProFormInstance, ProFormText } from '@ant-design/pro-components';
export type FormValueType = {
target?: string;
template?: string;
type?: string;
time?: string;
frequency?: string;
} & Partial<API.PbcSpecification>;
export type UpdateFormProps = {
onCancel: (flag?: boolean, formVals?: FormValueType) => void;
onSubmit: (values: FormValueType) => Promise<void>;
updateModalVisible: boolean;
};
const UpdateItemForm: React.FC<UpdateFormProps> = (props) => {
const formRef = useRef<ProFormInstance>();
return (
<DrawerForm
width={640}
title={'新增规格项'}
open={props.updateModalVisible}
formRef={formRef}
onFinish={(value: API.PbcSpecification) => {
return props.onSubmit({ ...value })
}}
drawerProps={{
destroyOnClose: true,
}}
onOpenChange={(visible) => {
formRef.current?.resetFields();
if (!visible) {
props.onCancel();
}
}}
>
<ProFormText
placeholder={'请输入规格项名称'}
label="规格项名称"
rules={[
{
required: true,
message: '规格项名称为必填项',
},
]}
width="md"
name="pbcSystemValue"
/>
</DrawerForm>
);
};
export default UpdateItemForm;

@ -0,0 +1,243 @@
import { dashboardUsingPost, exportDashboardDetailUsingPost } from '@/services/pop-b2b2c/pbcUserRecordLogController';
import { Bar, Pie, WordCloud, WordCloudConfig } from '@ant-design/plots';
import dayjs from 'dayjs';
import { ActionType, PageContainer, ProCard, ProColumns, ProForm, ProFormDateRangePicker, ProFormGroup, ProFormInstance, ProFormRadio, ProFormText, ProTable } from '@ant-design/pro-components';
import { Button, Card, Col, message, Row, Spin, Statistic, Switch, Table } from 'antd';
import React, { useEffect, useRef, useState } from 'react';
import { Access, history, Link, useAccess } from '@umijs/max';
import Constants from '@/constants';
import { disabledDate } from '@/utils/utils';
import { addSpecificationItemUsingPost, addSpecificationUsingPost, changeSpecificationItemStateUsingPost, getSpecificationItemListUsingGet, specificationListUsingGet } from '@/services/pop-b2b2c/pbcSpecificationController';
import { FileAddFilled, PlusCircleFilled } from '@ant-design/icons';
import UpdateForm from './components/UpdateForm';
import UpdateItemForm from './components/UpdateItemForm';
/**
*
* @param param0
*/
const fetchData = async (params: any) => {
const msg = await getSpecificationItemListUsingGet(params);
return {
data: msg.data || [],
success: msg.retcode,
} as any;
};
const handleUpdateState = async (id: number, state: number) => {
const hide = message.loading('正在保存');
if (!id) return false;
try {
const msg = await changeSpecificationItemStateUsingPost({ pbcId: id, pbcState: state });
hide();
if (msg.retcode) {
message.success(!id ? '新增成功!' : '保存成功!');
return true;
}
message.error(msg.retmsg);
return false;
} catch (error) {
hide();
message.error(!id ? '新增失败,请重试!' : '保存失败,请重试!');
return false;
}
};
/**
*
* @param fields
*/
const handleUpdate = async (fields: API.PbcSpecification) => {
const hide = message.loading('正在保存');
try {
const msg = await addSpecificationUsingPost({ ...fields });
hide();
if (msg.retcode) {
message.success(!fields.pbcId ? '添加成功' : '保存成功');
return true;
}
message.error(msg.retmsg);
return false;
} catch (error) {
hide();
message.error(!fields.pbcId ? '添加失败请重试!' : '保存失败请重试!');
return false;
}
};
/**
*
* @param fields
*/
const handleItemUpdate = async (fields: API.PbcCommonDataValue) => {
const hide = message.loading('正在保存');
try {
const msg = await addSpecificationItemUsingPost({ ...fields });
hide();
if (msg.retcode) {
message.success(!fields.pbcId ? '添加成功' : '保存成功');
return true;
}
message.error(msg.retmsg);
return false;
} catch (error) {
hide();
message.error(!fields.pbcId ? '添加失败请重试!' : '保存失败请重试!');
return false;
}
};
const Welcome: React.FC = () => {
const actionRef = useRef<ActionType>();
const access: any = useAccess();
const [specList, setSpecList] = useState<API.PbcSpecification[]>([])
const [updateModalVisible, handleUpdateModalVisible] = useState<boolean>(false);
const [updateItemModalVisible, handleUpdateItemModalVisible] = useState<boolean>(false);
const [specificationId, setSpecificationId] = useState<number>()
const columns: ProColumns<API.PbcCommonDataValue>[] = [
{
title: 'ID',
dataIndex: 'pbcId',
},
{
title: '名称',
dataIndex: 'pbcSystemValue',
},
{
title: '最后操作人',
dataIndex: 'pbcUpdateByUserName',
},
{
title: '最后操作时间',
dataIndex: 'pbcUpdateAt',
},
{
title: '状态',
dataIndex: 'pbcState',
valueType: 'select',
valueEnum: Constants.state,
render: (_, record) => {
return (
<Access key="switch" accessible={access.dictionaryUpdate}>
<Switch
checked={record.pbcState === 1}
onChange={async (value) => {
const success = await handleUpdateState(record.pbcId || 0, value ? 1 : 2);
if (success) {
if (actionRef.current) {
actionRef.current.reload();
}
}
}}
/>
</Access>
);
},
},
]
const getData = () => {
specificationListUsingGet().then(res => {
if (res.retcode && res.data) {
setSpecList(res.data)
}
})
}
useEffect(() => {
getData()
}, [])
return (
<PageContainer
header={{
title: '',
breadcrumb: {},
}}
>
<Row gutter={16}>
<Col span={4}>
<Card title="规格" bodyStyle={{ maxHeight: 'calc(100vh - 175px)', overflowY: 'auto' }} bordered={false} extra={
<Access accessible={access.dictionaryAdd}><PlusCircleFilled style={{ color: '#1890ff', fontSize: 22 }} onClick={() => {
handleUpdateModalVisible(true)
}} /></Access>
}>
{specList.map(e => <p
style={{ padding: 10, margin: 0, backgroundColor: specificationId === e.pbcId ? '#1890ff' : undefined, color: specificationId === e.pbcId ? '#fff' : undefined }} onClick={() => {
setSpecificationId(e.pbcId)
}}>{e.pbcSystemName}</p>)}
</Card>
</Col>
<Col span={20}>
<Card title="规格项" bordered={false} extra={
<Access accessible={access.dictionaryAdd}><PlusCircleFilled style={{ color: '#1890ff', fontSize: 22 }} onClick={() => {
const index = specList.findIndex(e => e.pbcId === specificationId)
if (!specificationId) {
message.warning("请选择规格")
} else if (index >= 0 && specList[index].pbcSystemInputType === 'text') {
message.warning("所选规格为文本框,不能新增规格项")
} else {
handleUpdateItemModalVisible(true)
}
}} /></Access>
}>
<ProTable
request={fetchData}
actionRef={actionRef}
bordered
size='small'
rowKey="pbcId"
params={{ specificationId }}
manualRequest={true}
columns={columns}
search={false}
options={false}
scroll={{
y: 'calc(100vh - 280px)',
}}
toolBarRender={() => []}
pagination={false}
/>
</Card>
</Col>
</Row>
<UpdateForm
onSubmit={async (value: any) => {
const success = await handleUpdate(value);
if (success) {
handleUpdateModalVisible(false);
getData()
}
}}
onCancel={() => {
message.destroy();
handleUpdateModalVisible(false);
}}
updateModalVisible={updateModalVisible}
/>
<UpdateItemForm
onSubmit={async (value: any) => {
const success = await handleItemUpdate({...value, pbcSpecificationId: specificationId});
if (success) {
handleUpdateItemModalVisible(false);
actionRef.current?.reload()
}
}}
onCancel={() => {
message.destroy();
handleUpdateItemModalVisible(false);
}}
updateModalVisible={updateItemModalVisible}
/>
</PageContainer>
);
};
export default Welcome;

@ -1,9 +1,11 @@
import Constants from '@/constants'; import Constants from '@/constants';
import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController'; import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController';
import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController'; import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController';
import { getRecordByL3CategoryIdUsingGet } from '@/services/pop-b2b2c/pbcCommonDataController';
import { addOrUpdateProductForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductController'; import { addOrUpdateProductForAdminUsingPost } from '@/services/pop-b2b2c/pbcProductController';
import { getCities } from '@/utils/cities'; import { getCities } from '@/utils/cities';
import { import {
FormListActionType,
ProCard, ProCard,
ProForm, ProForm,
ProFormCascader, ProFormCascader,
@ -23,6 +25,9 @@ import React, { useRef, useState } from 'react';
const Detail: React.FC<any> = () => { const Detail: React.FC<any> = () => {
const [cities] = useState(() => getCities()) const [cities] = useState(() => getCities())
const [colorData, setColorData] = useState<API.PbcCommonData[]>()
const [commonDataList, setCommonDataList] = useState<API.PbcCommonData[]>()
const formRef = useRef<ProFormInstance>(); const formRef = useRef<ProFormInstance>();
const onSave = () => { const onSave = () => {
@ -39,6 +44,14 @@ const Detail: React.FC<any> = () => {
pbcProductParentCategoryName: c2?.pbcCategoryName, pbcProductParentCategoryName: c2?.pbcCategoryName,
pbcProductCategoryName: c3?.pbcCategoryName, pbcProductCategoryName: c3?.pbcCategoryName,
}) })
if (value.length === 3) {
getRecordByL3CategoryIdUsingGet({ l3CategoryId: value[2] }).then(res => {
if (res.retcode && res.data) {
setColorData(res.data.colorData)
setCommonDataList(res.data.commonDataList)
}
})
}
} }
const onSubmit = async (values: any) => { const onSubmit = async (values: any) => {
@ -49,11 +62,12 @@ const Detail: React.FC<any> = () => {
const [pbcProductTopCategoryId, pbcProductParentCategoryId, pbcProductCategoryId] = values.pbcProductCategoryIdList const [pbcProductTopCategoryId, pbcProductParentCategoryId, pbcProductCategoryId] = values.pbcProductCategoryIdList
console.log(values.colorItems) console.log(values.colorItems)
console.log(values.specItems) console.log(values.specItems)
const commonDataList: API.PbcProductCommonData[] = [] const specItems: API.PbcProductCommonData[] = []
if (values.colorItems && values.colorItems.length > 0) { if (colorData != null && values.colorItems && values.colorItems.length > 0) {
for (let i = 0; i < values.colorItems.length; i++) { for (let i = 0; i < values.colorItems.length; i++) {
const element = values.colorItems[i]; const element = values.colorItems[i];
commonDataList.push({ specItems.push({
pbcCommonDataId: colorData.length > 0 ? colorData[0].pbcId : undefined,
pbcSystemName: '颜色', pbcSystemName: '颜色',
pbcSystemInputType: 'text', pbcSystemInputType: 'text',
pbcCommonDataSystem: element.name, pbcCommonDataSystem: element.name,
@ -61,13 +75,21 @@ const Detail: React.FC<any> = () => {
}) })
} }
} }
if (values.specItems && values.specItems.length > 0) { if (commonDataList != null) {
for (let i = 0; i < values.specItems.length; i++) { for (let i = 0; i < commonDataList.length; i++) {
const element = values.specItems[i]; const element = commonDataList[i];
commonDataList.push({ console.log(values[`value${i}`])
pbcSystemName: element.name, let name = ''
pbcSystemInputType: 'text', if (element.pbcSystemInputType === 'select' && element.commonDataValueList) {
pbcCommonDataSystem: element.value name = element.commonDataValueList.find(e => e.pbcId === values[`value${i}`])?.pbcSystemValue || ''
}
specItems.push({
pbcCommonDataId: element.pbcId,
pbcSystemName: element.pbcSystemName,
pbcSystemInputType: element.pbcSystemInputType,
pbcCommonDataValueId: element.pbcSystemInputType === 'select' ? values[`value${i}`] : undefined,
pbcCommonDataSystemValue: element.pbcSystemInputType === 'select' ? name : undefined,
pbcCommonDataSystem: element.pbcSystemInputType === 'select' ? undefined : values[`value${i}`]
}) })
} }
} }
@ -78,7 +100,7 @@ const Detail: React.FC<any> = () => {
pbcProductTopCategoryId, pbcProductTopCategoryId,
pbcProductParentCategoryId, pbcProductParentCategoryId,
pbcProductCategoryId, pbcProductCategoryId,
productCommonDataList: commonDataList, productCommonDataList: specItems,
pbcProductImages: values.pbcProductImages.filter((e: any) => e.response && e.response.data).map((e: any) => e.response.data).join(','), pbcProductImages: values.pbcProductImages.filter((e: any) => e.response && e.response.data).map((e: any) => e.response.data).join(','),
pbcProductDetailImages: values.pbcProductDetailImages.filter((e: any) => e.response && e.response.data).map((e: any) => e.response.data).join(','), pbcProductDetailImages: values.pbcProductDetailImages.filter((e: any) => e.response && e.response.data).map((e: any) => e.response.data).join(','),
pbcZone: undefined, pbcZone: undefined,
@ -189,7 +211,7 @@ const Detail: React.FC<any> = () => {
]} /> ]} />
</Col> </Col>
</Row> </Row>
<ProForm.Item isListField style={{ marginBlockEnd: 0 }} label="颜色" required> {colorData != null ? <ProForm.Item isListField style={{ marginBlockEnd: 0 }} label="颜色" required>
<ProFormList <ProFormList
name="colorItems" name="colorItems"
creatorButtonProps={{ creatorButtonProps={{
@ -254,7 +276,7 @@ const Detail: React.FC<any> = () => {
</Col> </Col>
</Row> </Row>
</ProFormList> </ProFormList>
</ProForm.Item> </ProForm.Item> : null}
<Row gutter={20}> <Row gutter={20}>
<Col span={24}> <Col span={24}>
<ProFormUploadButton <ProFormUploadButton
@ -327,32 +349,26 @@ const Detail: React.FC<any> = () => {
/> />
</Col> </Col>
</Row> </Row>
<ProForm.Item isListField style={{ marginBlockEnd: 0 }} label="规格" required> {commonDataList != null ? commonDataList.map((e, index) => <Row key={e.pbcId} align="middle" gutter={20}>
<ProFormList <Col span={6}>
name="specItems" <ProFormText width="sm" disabled name={`name${index}`} initialValue={e.pbcSystemName} placeholder="请输入规格名称" rules={[
creatorButtonProps={{ { required: true, message: '请输入规格名称' }
creatorButtonText: '新增', ]} />
icon: false, </Col>
type: 'link', <Col span={6}>
style: { width: 'unset' }, {e.pbcSystemInputType === 'select' ? <ProFormSelect name={`value${index}`} options={e.commonDataValueList?.map(item => {
}} return {
copyIconProps={false} label: item.pbcSystemValue || '',
deleteIconProps={{ tooltipText: '删除' }} value: item.pbcId
> }
<Row align="middle" gutter={20}> })} rules={[
<Col span={12}> { required: true, message: '请选择规格描述' },
<ProFormText width="sm" name={['name']} placeholder="请输入规格名称" rules={[ ]} /> : <ProFormText width="sm" name={`value${index}`} placeholder="请输入规格描述" rules={[
{ required: true, message: '请输入规格名称' } { required: true, message: '请输入规格描述' }
]} /> ]} />
</Col> }
<Col span={12}> </Col>
<ProFormText width="sm" name={['value']} placeholder="请输入规格描述" rules={[ </Row>) : null}
{ required: true, message: '请输入规格描述' }
]} />
</Col>
</Row>
</ProFormList>
</ProForm.Item>
<Row gutter={20}> <Row gutter={20}>
<Col span={24}> <Col span={24}>
<ProFormTextArea label="详情描述" name="pbcProductDetail" rules={[ <ProFormTextArea label="详情描述" name="pbcProductDetail" rules={[

@ -12,6 +12,7 @@ import { Button, Image, message, Popconfirm, Switch } from 'antd';
import React, { useRef, useState } from 'react'; import React, { useRef, useState } from 'react';
import { Access, useAccess } from 'umi'; import { Access, useAccess } from 'umi';
import UpdateForm from './components/UpdateForm'; import UpdateForm from './components/UpdateForm';
import { setSpecificationForCategoryUsingPost } from '@/services/pop-b2b2c/pbcCommonDataController';
/** /**
* *
@ -30,17 +31,18 @@ const fetchData = async (params: any) => {
* *
* @param fields * @param fields
*/ */
const handleUpdate = async (fields: API.PbcCategory) => { const handleUpdate = async (fields: API.PbcCategory & API.PbcSetSpecificationDTO) => {
const hide = message.loading('正在保存'); const hide = message.loading('正在保存');
try { try {
const msg = await saveOrUpdateCategoryUsingPost({ ...fields }); const msg = await saveOrUpdateCategoryUsingPost({ ...fields });
const msg1 = await setSpecificationForCategoryUsingPost({ pbcCategory: {...fields, pbcId: msg.data}, pbcSpecificationList: fields.pbcSpecificationList });
hide(); hide();
if (msg.retcode) { if (msg.retcode && msg1.retcode) {
message.success(!fields.pbcId ? '添加成功' : '保存成功'); message.success(!fields.pbcId ? '添加成功' : '保存成功');
return true; return true;
} }
message.error(msg.retmsg); message.error(!msg.retcode ? msg.retmsg : msg1.retmsg);
return false; return false;
} catch (error) { } catch (error) {
hide(); hide();

@ -1,8 +1,10 @@
import React, { useRef, useState } from 'react'; import React, { useEffect, useRef, useState } from 'react';
import { DrawerForm, ProFormInstance, ProFormText, ProFormUploadButton } from '@ant-design/pro-components'; import { DrawerForm, ProFormCheckbox, ProFormInstance, ProFormText, ProFormUploadButton } from '@ant-design/pro-components';
import { PlusCircleOutlined } from '@ant-design/icons'; import { PlusCircleOutlined } from '@ant-design/icons';
import { message } from 'antd'; import { message } from 'antd';
import { RcFile } from 'antd/es/upload'; import { RcFile } from 'antd/es/upload';
import { specificationListUsingGet } from '@/services/pop-b2b2c/pbcSpecificationController';
import { getRecordByL3CategoryIdUsingGet } from '@/services/pop-b2b2c/pbcCommonDataController';
export type FormValueType = { export type FormValueType = {
target?: string; target?: string;
template?: string; template?: string;
@ -19,6 +21,39 @@ export type UpdateFormProps = {
const UpdateForm: React.FC<UpdateFormProps> = (props) => { const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const formRef = useRef<ProFormInstance>(); const formRef = useRef<ProFormInstance>();
const [specList, setSpecList] = useState<API.PbcSpecification[]>([])
useEffect(() => {
if (props.values.pbcCategoryLevel === 3) {
specificationListUsingGet().then(res => {
if (res.retcode && res.data) {
setSpecList(res.data)
}
})
if (props.values.pbcId) {
getRecordByL3CategoryIdUsingGet({ l3CategoryId: props.values.pbcId }).then(res => {
if (res.retcode && res.data) {
const arr = new Set()
if (res.data.colorData) {
for (let i = 0; i < res.data.colorData.length; i++) {
const element = res.data.colorData[i];
arr.add(element.pbcSpecificationId)
}
}
if (res.data.commonDataList) {
for (let i = 0; i < res.data.commonDataList.length; i++) {
const element = res.data.commonDataList[i];
arr.add(element.pbcSpecificationId)
}
}
const ids = Array.from(arr);
formRef.current?.setFieldValue("pbcSpecificationList", ids)
}
})
}
}
}, [props.values.pbcCategoryLevel, props.values.pbcId])
return ( return (
<DrawerForm <DrawerForm
width={640} width={640}
@ -27,7 +62,6 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
formRef={formRef} formRef={formRef}
onFinish={(value) => { onFinish={(value) => {
let pbcCategoryImage = "" let pbcCategoryImage = ""
console.log(value)
if (value.pbcCategoryImage && value.pbcCategoryImage.length > 0) { if (value.pbcCategoryImage && value.pbcCategoryImage.length > 0) {
if (value.pbcCategoryImage[0].uid == '-1') { if (value.pbcCategoryImage[0].uid == '-1') {
pbcCategoryImage = value.pbcCategoryImage[0].url; pbcCategoryImage = value.pbcCategoryImage[0].url;
@ -39,8 +73,8 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
pbcCategoryImage = value.pbcCategoryImage[0].response.data; pbcCategoryImage = value.pbcCategoryImage[0].response.data;
} }
} }
console.log(pbcCategoryImage) const arr = specList.filter(e => value.pbcSpecificationList && value.pbcSpecificationList.length > 0 && value.pbcSpecificationList.includes(e.pbcId))
return props.onSubmit({ ...props.values, ...value, pbcCategoryImage, pbcId: props.values.pbcId }) return props.onSubmit({ ...props.values, ...value, pbcSpecificationList: arr, pbcCategoryImage, pbcId: props.values.pbcId })
}} }}
drawerProps={{ drawerProps={{
destroyOnClose: true, destroyOnClose: true,
@ -107,6 +141,17 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
}} }}
action={process.env.BASE_URL + '/oss/imgUpload'} action={process.env.BASE_URL + '/oss/imgUpload'}
/> />
{props.values.pbcCategoryLevel === 3 ? <ProFormCheckbox.Group
label="类目规格"
width="md"
options={specList.map(e => {
return {
label: e.pbcSystemName || '',
value: e.pbcId || ''
}
})}
name="pbcSpecificationList"
/> : null}
</DrawerForm> </DrawerForm>
); );
}; };

@ -2,41 +2,41 @@
/* eslint-disable */ /* eslint-disable */
import request from '@/utils/request'; import request from '@/utils/request';
/** errorHtml GET /error */ /** error GET /error */
export async function errorHtmlUsingGet(options?: { [key: string]: any }) { export async function errorUsingGet(options?: { [key: string]: any }) {
return request<API.ModelAndView>('/error', { return request<Record<string, any>>('/error', {
method: 'GET', method: 'GET',
...(options || {}), ...(options || {}),
}); });
} }
/** errorHtml PUT /error */ /** error PUT /error */
export async function errorHtmlUsingPut(options?: { [key: string]: any }) { export async function errorUsingPut(options?: { [key: string]: any }) {
return request<API.ModelAndView>('/error', { return request<Record<string, any>>('/error', {
method: 'PUT', method: 'PUT',
...(options || {}), ...(options || {}),
}); });
} }
/** errorHtml POST /error */ /** error POST /error */
export async function errorHtmlUsingPost(options?: { [key: string]: any }) { export async function errorUsingPost(options?: { [key: string]: any }) {
return request<API.ModelAndView>('/error', { return request<Record<string, any>>('/error', {
method: 'POST', method: 'POST',
...(options || {}), ...(options || {}),
}); });
} }
/** errorHtml DELETE /error */ /** error DELETE /error */
export async function errorHtmlUsingDelete(options?: { [key: string]: any }) { export async function errorUsingDelete(options?: { [key: string]: any }) {
return request<API.ModelAndView>('/error', { return request<Record<string, any>>('/error', {
method: 'DELETE', method: 'DELETE',
...(options || {}), ...(options || {}),
}); });
} }
/** errorHtml PATCH /error */ /** error PATCH /error */
export async function errorHtmlUsingPatch(options?: { [key: string]: any }) { export async function errorUsingPatch(options?: { [key: string]: any }) {
return request<API.ModelAndView>('/error', { return request<Record<string, any>>('/error', {
method: 'PATCH', method: 'PATCH',
...(options || {}), ...(options || {}),
}); });

@ -102,7 +102,7 @@ export async function saveOrUpdateCategoryUsingPost(
body: API.PbcCategory, body: API.PbcCategory,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.AjaxResult>('/b2b2c/pbccategory/saveOrUpdateCategory', { return request<API.AjaxResultLong_>('/b2b2c/pbccategory/saveOrUpdateCategory', {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',

@ -32,13 +32,13 @@ export async function addSpecificationItemUsingPost(
}); });
} }
/** changeSpecificationItemState 修改规格项状态传pbcId和pbcState GET /b2b2c/pbcSpecification/changeSpecificationItemState */ /** changeSpecificationItemState 修改规格项状态传pbcId和pbcState POST /b2b2c/pbcSpecification/changeSpecificationItemState */
export async function changeSpecificationItemStateUsingGet( export async function changeSpecificationItemStateUsingPost(
body: API.PbcCommonDataValue, body: API.PbcCommonDataValue,
options?: { [key: string]: any }, options?: { [key: string]: any },
) { ) {
return request<API.AjaxResultString_>('/b2b2c/pbcSpecification/changeSpecificationItemState', { return request<API.AjaxResultString_>('/b2b2c/pbcSpecification/changeSpecificationItemState', {
method: 'GET', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
}, },

Loading…
Cancel
Save