dev-v2
Joe 8 months ago
parent f2ec57601c
commit e6c5a68e2c

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

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

@ -1,27 +1,16 @@
import Constants from '@/constants';
import { getPbcBusinessListUsingPost } from '@/services/pop-b2b2c/pbcBusinessController';
import { listAdminTreeUsingGet } from '@/services/pop-b2b2c/pbcCategoryController';
import {
changeProductStateForAdminUsingGet,
getProductPageForAdminUsingPost,
} from '@/services/pop-b2b2c/pbcProductController';
import { getClassPageForAdminUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesController';
import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components';
import { PageContainer } from '@ant-design/pro-layout';
import { Access, Link, useAccess, history } from '@umijs/max';
import { Button, message } from 'antd';
import moment from 'moment';
import { Button } from 'antd';
import React, { useRef } from 'react';
/**
*
* @param param0
*/
const fetchData = async (params: any) => {
if (params.pbcProductCategoryId && params.pbcProductCategoryId.length === 3) {
params.pbcProductCategoryId = params.pbcProductCategoryId[2];
}
params.pbcUserType = 2
const msg = await getProductPageForAdminUsingPost(params);
const fetchData = async (params: API.PbcTrainingClasses_) => {
const msg = await getClassPageForAdminUsingPost(params);
return {
data: msg.data?.records,
total: msg.data?.total,
@ -29,146 +18,77 @@ const fetchData = async (params: 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
const TableList: React.FC<{}> = () => {
const actionRef = useRef<ActionType>();
const access: any = useAccess();
const columns: ProColumns<API.PbcProduct>[] = [
{
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 [];
},
},
const columns: ProColumns<API.PbcTrainingClasses_>[] = [
{
title: '商品大类',
dataIndex: 'pbcProductTopCategoryName',
title: '课程缩略图',
dataIndex: 'pbcImages',
search: false,
},
{
title: '商品中类',
dataIndex: 'pbcProductParentCategoryName',
title: '课程名称',
dataIndex: 'pbcTitle',
search: false,
},
{
title: '商品小类',
dataIndex: 'pbcProductCategoryName',
search: false,
},
{
title: '商品名称',
dataIndex: 'pbcProductTitle',
},
{
title: '款号',
dataIndex: 'pbcProductCode',
},
{
title: '价格',
dataIndex: 'pbcProductPrice',
title: '课程类型',
dataIndex: 'pbcClassesTypeName',
search: false,
},
{
title: '所属商户',
dataIndex: 'pbcBusinessName',
title: '总课次',
dataIndex: 'pbcClassesSubCount',
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: '创建时间',
dataIndex: 'pbcCreateAt',
hideInTable: true,
fieldProps:{
maxDate: moment()
},
valueType: 'dateRange'
},
{
title: '产品类型',
dataIndex: 'pbcProductType',
valueType: 'select',
valueEnum: Constants.pbcProductTypeList,
search: false
},
{
title: '状态',
dataIndex: 'pbcState',
valueType: 'select',
valueEnum: Constants.pbcProductState,
},
{
title: '操作',
fixed: 'right',
valueType: 'option',
render: (text, record) => (
<span>
<Link to={'/product/detail/' + record.pbcId}></Link>
<Access key="config" accessible={access.productUpdateState}>
{record.pbcState === 1 ? (
<Button
type="link"
onClick={() => {
changeProductStateForAdminUsingGet({ pcbId: record.pbcId || 0, state: 2 }).then(
(res) => {
if (res.retcode) {
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);
}
},
);
}}
>
</Button>
)}
</Access>
{/* <Access key="switch" accessible={access.productCategoryUpdateState}>
<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> */}
<Link to={'/training-classes/save/' + record.pbcId}></Link>
</span>
),
},
@ -180,17 +100,10 @@ const TableList: React.FC<{}> = () => {
breadcrumb: {},
}}
>
<ProTable<API.PbcProduct>
<ProTable<API.PbcTrainingClasses_>
columns={columns}
actionRef={actionRef}
request={(param: any) => {
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);
}}
request={fetchData}
rowKey="pbcId"
size="small"
bordered
@ -205,7 +118,7 @@ const TableList: React.FC<{}> = () => {
toolbar={{
actions: [
<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>
]
}}

Loading…
Cancel
Save