dev-v2
Joe 8 months ago
parent f2ec57601c
commit e6c5a68e2c

@ -173,7 +173,7 @@ export default [
{ {
name: '课程类型管理', name: '课程类型管理',
path: 'category', path: 'category',
// access: 'trainingClassesCategoryQuery', access: 'trainingClassesCategoryQuery',
component: './TrainingClasses/category', component: './TrainingClasses/category',
}, },
// { // {

@ -76,7 +76,7 @@ const TableList: React.FC<any> = () => {
const columns: ProColumns<API.PbcTrainingClassesType_>[] = [ const columns: ProColumns<API.PbcTrainingClassesType_>[] = [
{ {
title: '课程类型', title: '课程类型',
dataIndex: 'PbcTrainingClassesType_Name', dataIndex: 'pbcType',
}, },
{ {
title: '创建时间', title: '创建时间',
@ -90,7 +90,7 @@ const TableList: React.FC<any> = () => {
width: 180, width: 180,
render: (text, record) => ( render: (text, record) => (
<span> <span>
<Access key="config" accessible={access.productCategorySave}> <Access key="config" accessible={access.trainingClassesCategorySave}>
<Button <Button
size="small" size="small"
type="link" type="link"
@ -102,7 +102,7 @@ const TableList: React.FC<any> = () => {
</Button> </Button>
</Access> </Access>
<Access key="remove" accessible={access.productCategoryDelete}> <Access key="remove" accessible={access.trainingClassesCategoryRemove}>
<Popconfirm <Popconfirm
title={`确定需要删除该课程类型?`} title={`确定需要删除该课程类型?`}
onConfirm={async () => { onConfirm={async () => {
@ -147,7 +147,7 @@ const TableList: React.FC<any> = () => {
> >
{searchText} {searchText}
</Button>, </Button>,
<Access key="primary" accessible={access.productCategorySave}> <Access key="primary" accessible={access.trainingClassesCategorySave}>
<Button <Button
icon={<PlusOutlined />} icon={<PlusOutlined />}
type="primary" type="primary"

@ -1,27 +1,16 @@
import Constants from '@/constants'; import { getClassPageForAdminUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesController';
import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController';
import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController';
import {
changeProductStateForAdminUsingGet,
getProductPageForAdminUsingPost,
} from '@/services/pop-b2b2c/pbcProductController';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout'; import { PageContainer } from '@ant-design/pro-layout';
import { Access, Link, useAccess, history } from '@umijs/max'; import { Access, Link, useAccess, history } from '@umijs/max';
import { Button, message } from 'antd'; import { Button } from 'antd';
import moment from 'moment';
import React, { useRef } from 'react'; import React, { useRef } from 'react';
/** /**
* *
* @param param0 * @param param0
*/ */
const fetchData = async (params: any) => { const fetchData = async (params: API.PbcTrainingClasses_) => {
if (params.pbcProductCategoryId && params.pbcProductCategoryId.length === 3) { const msg = await getClassPageForAdminUsingPost(params);
params.pbcProductCategoryId = params.pbcProductCategoryId[2];
}
params.pbcUserType = 2
const msg = await getProductPageForAdminUsingPost(params);
return { return {
data: msg.data?.records, data: msg.data?.records,
total: msg.data?.total, total: msg.data?.total,
@ -29,146 +18,77 @@ const fetchData = async (params: any) => {
} as any; } as any;
}; };
// const handleUpdateState = async (id: number, state: number) => {
// const hide = message.loading('正在保存');
// if (!id) return false;
// try {
// const msg = await updateCategoryRecordStateUsingGet({ pbcId: id, state: state });
// hide();
// if (msg.retcode) {
// message.success(!id ? '新增成功!' : '保存成功!');
// return true;
// }
// message.error(msg.retmsg);
// return false;
// } catch (error) {
// hide();
// message.error(!id ? '新增失败,请重试!' : '保存失败,请重试!');
// return false;
// }
// };
// eslint-disable-next-line @typescript-eslint/ban-types // eslint-disable-next-line @typescript-eslint/ban-types
const TableList: React.FC<{}> = () => { const TableList: React.FC<{}> = () => {
const actionRef = useRef<ActionType>(); const actionRef = useRef<ActionType>();
const access: any = useAccess(); const access: any = useAccess();
const columns: ProColumns<API.PbcProduct>[] = [ const columns: ProColumns<API.PbcTrainingClasses_>[] = [
{
title: '商品类目',
dataIndex: 'pbcProductCategoryId',
hideInTable: true,
valueType: 'cascader',
fieldProps: {
fieldNames: { label: 'pbcCategoryName', value: 'pbcId', children: 'children' },
},
request: async () => {
const msg = await listAdminTreeUsingGet({ type: 2 });
if (msg.retcode && msg.data) {
return msg.data;
}
return [];
},
},
{
title: '商品大类',
dataIndex: 'pbcProductTopCategoryName',
search: false,
},
{ {
title: '商品中类', title: '课程缩略图',
dataIndex: 'pbcProductParentCategoryName', dataIndex: 'pbcImages',
search: false, search: false,
}, },
{ {
title: '商品小类', title: '课程名称',
dataIndex: 'pbcProductCategoryName', dataIndex: 'pbcTitle',
search: false, search: false,
}, },
{ {
title: '商品名称', title: '课程类型',
dataIndex: 'pbcProductTitle', dataIndex: 'pbcClassesTypeName',
},
{
title: '款号',
dataIndex: 'pbcProductCode',
},
{
title: '价格',
dataIndex: 'pbcProductPrice',
search: false, search: false,
}, },
{ {
title: '所属商户', title: '总课次',
dataIndex: 'pbcBusinessName', dataIndex: 'pbcClassesSubCount',
search: false, search: false,
}, },
{
title: '所属商户',
dataIndex: 'pbcBusinessId',
hideInTable: true,
valueType: 'select',
fieldProps: {
showSearch: true,
fieldNames: { label: 'pbcBusinessName', value: 'pbcId' },
},
request: async () => {
const msg = await getPbcBusinessListUsingPost();
if (msg.retcode && msg.data) {
return msg.data;
}
return [];
},
},
{ {
title: '创建时间', title: '创建时间',
dataIndex: 'pbcCreateAt', dataIndex: 'pbcCreateAt',
hideInTable: true,
fieldProps:{
maxDate: moment()
},
valueType: 'dateRange'
},
{
title: '产品类型',
dataIndex: 'pbcProductType',
valueType: 'select',
valueEnum: Constants.pbcProductTypeList,
search: false search: false
}, },
{
title: '状态',
dataIndex: 'pbcState',
valueType: 'select',
valueEnum: Constants.pbcProductState,
},
{ {
title: '操作', title: '操作',
fixed: 'right', fixed: 'right',
valueType: 'option', valueType: 'option',
render: (text, record) => ( render: (text, record) => (
<span> <span>
<Link to={'/product/detail/' + record.pbcId}></Link> {/* <Access key="switch" accessible={access.productCategoryUpdateState}>
<Access key="config" accessible={access.productUpdateState}> <Switch
{record.pbcState === 1 ? ( checked={record.pbcState === 1}
<Button onChange={async (value) => {
type="link" const success = await handleUpdateState(record.pbcId || 0, value ? 1 : 2);
onClick={() => {
changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 2 }).then( if (success) {
(res) => { if (actionRef.current) {
if (res.retcode) { actionRef.current.reload();
message.success('已下架');
actionRef.current?.reload();
} else {
message.error(res.retmsg);
} }
},
);
}}
>
</Button>
) : (
<Button
type="link"
onClick={() => {
changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 1 }).then(
(res) => {
if (res.retcode) {
message.success('已上架');
actionRef.current?.reload();
} else {
message.error(res.retmsg);
} }
},
);
}} }}
> />
</Access> */}
</Button> <Link to={'/training-classes/save/' + record.pbcId}></Link>
)}
</Access>
</span> </span>
), ),
}, },
@ -180,17 +100,10 @@ const TableList: React.FC<{}> = () => {
breadcrumb: {}, breadcrumb: {},
}} }}
> >
<ProTable<API.PbcProduct> <ProTable<API.PbcTrainingClasses_>
columns={columns} columns={columns}
actionRef={actionRef} actionRef={actionRef}
request={(param: any) => { request={fetchData}
const queryParam = {
...param,
startDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[0] : undefined,
endDate: param.pbcCreateAt && param.pbcCreateAt.length > 1 ? param.pbcCreateAt[1] + ' 23:59:59' : undefined
}
return fetchData(queryParam);
}}
rowKey="pbcId" rowKey="pbcId"
size="small" size="small"
bordered bordered
@ -205,7 +118,7 @@ const TableList: React.FC<{}> = () => {
toolbar={{ toolbar={{
actions: [ actions: [
<Access key="add" accessible={access.productAdd}> <Access key="add" accessible={access.productAdd}>
<Button type="primary" onClick={() => history.push('/product/add')}></Button> <Button type="primary" onClick={() => history.push('/product/add')}></Button>
</Access> </Access>
] ]
}} }}

Loading…
Cancel
Save