提交 657c23a4 作者: 龚洪江

Merge branch 'develop'

......@@ -14,4 +14,4 @@ patches:
images:
- name: REGISTRY/NAMESPACE/IMAGE:TAG
newName: mmc-registry.cn-shenzhen.cr.aliyuncs.com/sharefly-dev/admin
newTag: 2bc3f5681467023eaf7d732d8bffde2e434fe72a
newTag: 843987a0ad1fd382895fe3cccbd37490f1b36f28
......@@ -17,6 +17,7 @@ const EditableCell: React.FC<
EditableCellProps & {
selectOption?: { name: string; id: number }[];
uploadSuccess?: (record: any, result: any) => void;
rules?: any;
}
> = ({
editing,
......@@ -28,6 +29,7 @@ const EditableCell: React.FC<
selectOption,
uploadSuccess,
children,
rules,
...restProps
}) => {
const inputNode = () => {
......@@ -60,32 +62,10 @@ const EditableCell: React.FC<
return <Input placeholder={`请输入${title}`} />;
}
};
const getMessage = () => {
switch (inputType) {
case 'number':
case 'text':
return `请输入${title}`;
case 'select':
return `请选择${title}`;
case 'uploader':
return `请上传${title}`;
default:
return `请输入${title}`;
}
};
return (
<td {...restProps}>
{editing ? (
<Form.Item
name={dataIndex + record.id}
style={{ margin: 0 }}
rules={[
{
required: true,
message: getMessage(),
},
]}
>
<Form.Item name={dataIndex + record.id} style={{ margin: 0 }} rules={rules}>
{inputNode()}
</Form.Item>
) : (
......
......@@ -88,12 +88,14 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
align: 'center',
dataIndex: 'specName',
editable: true,
rules: [{ required: true, message: '请输入选项名称' }],
},
{
title: '料号',
align: 'center',
dataIndex: 'partNo',
editable: true,
rules: [{ required: true, message: '请输入料号' }],
},
{
title: '操作',
......@@ -143,6 +145,7 @@ const AddOrEditSkuModal: React.FC<ModalProps & selfProps> = ({
dataIndex: col.dataIndex,
title: col.title,
editing: true,
rules: col.rules,
}),
};
});
......
......@@ -70,7 +70,7 @@ const RichText: React.FC<PropsType> = ({
//富文本修改
const richTextChange = (editor: IDomEditor) => {
if (onChange) {
onChange(editor.getHtml() || '');
onChange(editor.isEmpty() ? '' : editor.getHtml());
}
};
useEffect(() => {
......
......@@ -17,7 +17,7 @@ interface selfProps {
//上传机构请求类型
type insertOrgParametersType = Omit<InterReqType<insertOrgType>, 'trainingProgramsVOS'>;
const BaseInfo: FC<selfProps> = forwardRef((props, ref) => {
const BaseInfo: FC<selfProps> = forwardRef((_props, ref) => {
const [baseInfoForm] = Form.useForm<insertOrgParametersType>();
//地图地点选择
const [selectMapShow, setSelectMapShow] = useState<boolean>(false);
......@@ -157,11 +157,7 @@ const BaseInfo: FC<selfProps> = forwardRef((props, ref) => {
<UploadOutlined />
</Uploader>
</Form.Item>
<Form.Item
label='机构副图'
name='auxiliaryPicture'
rules={[{ required: true, message: '请上传机构副图' }]}
>
<Form.Item label='机构副图' name='auxiliaryPicture'>
<Uploader
fileUpload
listType='picture-card'
......@@ -206,7 +202,7 @@ const BaseInfo: FC<selfProps> = forwardRef((props, ref) => {
name='name'
rules={[{ required: true, message: '请输入机构名称' }]}
>
<Input placeholder='请输入机构名称' maxLength={30} />
<Input placeholder='请输入机构名称' maxLength={25} />
</Form.Item>
<Form.Item
label='机构地区'
......
......@@ -4,6 +4,10 @@
font-weight: bold;
margin-bottom: 10px;
line-height: 20px;
&:before{
content: '*';
color: red;
}
}
&-rich{
......
......@@ -4,6 +4,10 @@
font-weight: bold;
margin-bottom: 10px;
line-height: 20px;
&:before{
content: '*';
color: red;
}
}
&-table{
......
......@@ -32,7 +32,7 @@ interface selfProps {
ref: any;
}
const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
const SkuInfo: FC<selfProps> = forwardRef((_props, ref) => {
const [skuForm] = Form.useForm<any>();
//机型下拉列表
const [modelsList, setModelsList] = useState<modelsListType>([]);
......@@ -41,11 +41,25 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
//执照类型列表
const [typeList, setTypeList] = useState<typeListType>([]);
//价格正则
const priceValidator = (_rule: any, value: any) => {
const reg = /^\d+(\.\d{1,2})?$/;
if (reg.test(value)) {
if (value < 0 || value > 100000) {
return Promise.reject(new Error('价格大于0且小于10万'));
}
} else {
return Promise.reject(new Error('价格为数字且保留小数点后两位'));
}
return Promise.resolve();
};
const defaultColumns: (ColumnTypes[number] & {
editable?: boolean;
dataIndex?: string;
selectOption?: { name: string; id: number }[];
inputType?: string;
rules?: any;
})[] = [
{
title: '序号',
......@@ -60,6 +74,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
width: '10%',
inputType: 'uploader',
editable: true,
rules: [{ required: true, message: '请上传培训主图' }],
},
{
title: '培训机型',
......@@ -69,6 +84,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
inputType: 'select',
width: '15%',
selectOption: modelsList,
rules: [{ required: true, message: '请选择培训机型' }],
},
{
title: '培训等级',
......@@ -78,6 +94,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
inputType: 'select',
width: '15%',
selectOption: gradeList,
rules: [{ required: true, message: '请选择培训等级' }],
},
{
title: '培训类型',
......@@ -87,6 +104,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
inputType: 'select',
width: '15%',
selectOption: typeList,
rules: [{ required: true, message: '请选择培训类型' }],
},
{
title: '培训价格',
......@@ -94,6 +112,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
editable: true,
dataIndex: 'price',
width: '12%',
rules: [{ required: true, validator: priceValidator }],
},
{
title: '操作',
......@@ -142,6 +161,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
selectOption: col.selectOption,
inputType: col.inputType,
uploadSuccess: col.inputType === 'uploader' ? uploadSuccess : undefined,
rules: col.rules,
}),
};
});
......@@ -211,6 +231,7 @@ const SkuInfo: FC<selfProps> = forwardRef((props, ref) => {
setTypeList(result || []);
});
};
useEffect(() => {
getLicenceModelsList();
getLicenceGradeList();
......
......@@ -43,6 +43,9 @@ const AddOrEditInstitution = () => {
skuRef.current.getForm().validateFields(),
])
.then((value) => {
if (!introduceInfo) {
return message.warning('机构介绍不能为空');
}
const skuReqData = skuRef.current.getTableData().map((v: tableDataType) => {
return Object.getOwnPropertyNames(v).reduce((pre: any, cur: string) => {
if (Object.getOwnPropertyNames(value[1]).includes(cur + v.id)) {
......@@ -94,7 +97,7 @@ const AddOrEditInstitution = () => {
if (institutionDetail) {
baseRef.current.getForm().setFieldsValue({
mainImage: institutionDetail.mainImage,
auxiliaryPicture: institutionDetail.auxiliaryPicture,
auxiliaryPicture: institutionDetail.auxiliaryPicture || undefined,
video: institutionDetail.video,
name: institutionDetail.name,
region: institutionDetail.region,
......@@ -117,21 +120,25 @@ const AddOrEditInstitution = () => {
},
]);
baseRef.current.getDefaultDataEvent().setSubImgList(
institutionDetail.auxiliaryPicture.split(',').map((v: string) => ({
institutionDetail.auxiliaryPicture?.split(',').map((v: string) => ({
id: Math.random(),
uid: Math.random(),
url: v,
name: 'auxiliaryPicture',
})),
})) || [],
);
baseRef.current.getDefaultDataEvent().setVideoList(
institutionDetail.video
? [
{
id: Math.random(),
uid: Math.random(),
url: institutionDetail.video,
name: 'video',
},
]
: [],
);
baseRef.current.getDefaultDataEvent().setVideoList([
{
id: Math.random(),
uid: Math.random(),
url: institutionDetail.video,
name: 'video',
},
]);
const programsList = institutionDetail.programsDOList.map((v) => ({
...v,
fileList: [
......
import SearchBox, { searchColumns } from '~/components/search-box';
import { Button, message, Modal, Table, Tag } from 'antd';
import { Button, message, Modal, Table } from 'antd';
import { ColumnsType } from 'antd/es/table';
import { PlusOutlined } from '@ant-design/icons';
import { useNavigate } from 'react-router-dom';
import { PilotTrainAPI } from '~/api';
import { useEffect, useState } from 'react';
import { InterDataType, PaginationProps } from '~/api/interface';
import { listOrgPageType } from '~/api/interface/pilotTrainType';
import { InterDataType, InterReqType, PaginationProps } from '~/api/interface';
import {
licenceGradeListType,
licenceModelsListType,
licenceTypeListType,
listOrgPageType,
} from '~/api/interface/pilotTrainType';
import { filterObjAttr } from '~/utils';
//机构列表返回类型
type institutionListType = InterDataType<listOrgPageType>['list'];
//机型下拉返回类型
type modelsListType = InterDataType<licenceModelsListType>;
//等级下拉返回类型
type gradeListType = InterDataType<licenceGradeListType>;
//执照类型返回类型
type typeListType = InterDataType<licenceTypeListType>;
//机构列表请求参数类型
type listOrgPageParametersType = InterReqType<listOrgPageType>;
const InstitutionsList = () => {
const navigate = useNavigate();
//培训类型下拉
//机型下拉列表
const [modelsList, setModelsList] = useState<modelsListType>([]);
//等级下拉列表
const [gradeList, setGradeList] = useState<gradeListType>([]);
//执照类型列表
const [typeList, setTypeList] = useState<typeListType>([]);
const search: searchColumns[] = [
{ label: '机构名称', name: '', placeholder: '请输入机构名称', type: 'input' },
{ label: '培训类型', name: '', placeholder: '请选择培训类型', type: 'select', options: [] },
{ label: '选择日期', name: '', placeholder: '请选择日期', type: 'rangePicker', options: [] },
{ label: '机构名称', name: 'name', placeholder: '请输入机构名称', type: 'input' },
{
label: '培训等级',
name: 'gradeId',
placeholder: '请选择培训等级',
type: 'select',
options: gradeList,
},
{
label: '培训机型',
name: 'modelsId',
placeholder: '请选择培训机型',
type: 'select',
options: modelsList,
},
{
label: '培训类型',
name: 'typeId',
placeholder: '请选择培训类型',
type: 'select',
options: typeList,
},
{
label: '选择日期',
name: 'time',
placeholder: '请选择日期',
type: 'rangePicker',
options: [],
},
];
const tableColumns: ColumnsType<institutionListType[0]> = [
{
......@@ -36,7 +80,11 @@ const InstitutionsList = () => {
title: '培训类型',
align: 'center',
render: (_text: string, record) =>
record.programsDOList.map((v) => <Tag key={v.id}>{v.typeName}</Tag>),
record.programsDOList[0].gradeName +
'/' +
record.programsDOList[0].modelsName +
'/' +
record.programsDOList[0].typeName,
width: '20%',
},
{
......@@ -65,25 +113,28 @@ const InstitutionsList = () => {
pageSize: 10,
totalCount: 0,
});
const [query, setQuery] = useState<listOrgPageParametersType>();
const toAddInstitutions = () => {
navigate('/pilotTraining/institutionsList/add');
};
//机构列表
const getListOrgPage = () => {
PilotTrainAPI.getListOrgPage({ pageNo: pagination.pageNo, pageSize: pagination.pageSize }).then(
({ result }) => {
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
setPagination(pagination);
},
);
const getListOrgPage = (query?: listOrgPageParametersType) => {
PilotTrainAPI.getListOrgPage({
pageNo: pagination.pageNo,
pageSize: pagination.pageSize,
...query,
}).then(({ result }) => {
setTableData(result.list || []);
pagination.totalCount = result.totalCount;
setPagination(pagination);
});
};
//分页-监听
const paginationChange = (pageNo: number, pageSize: number) => {
pagination.pageNo = pageNo;
pagination.pageSize = pageSize;
getListOrgPage();
getListOrgPage(query);
};
//机构删除
const deleteInstitutionsClick = (record: institutionListType[0]) => {
......@@ -107,8 +158,42 @@ const InstitutionsList = () => {
const editInstitutionsClick = (record: institutionListType[0]) => {
navigate({ pathname: '/pilotTraining/institutionsList/edit', search: `id=${record.id}` });
};
//培训机型下拉
const getLicenceModelsList = () => {
PilotTrainAPI.getLicenceModelsList().then(({ result }) => {
setModelsList(result || []);
});
};
//培训等级下拉
const getLicenceGradeList = () => {
PilotTrainAPI.getLicenceGradeList().then(({ result }) => {
setGradeList(result || []);
});
};
//培训类型下拉
const getLicenceTypeList = () => {
PilotTrainAPI.getLicenceTypeList().then(({ result }) => {
setTypeList(result || []);
});
};
//筛选
const searchSuccess = (value: any) => {
const req = {
...filterObjAttr(value, ['time']),
startTime: value.startTime ? value.startTime.split(' ')[0] : undefined,
endTime: value.endTime ? value.endTime.split(' ')[0] : undefined,
};
setQuery(req);
pagination.pageNo = 1;
pagination.pageSize = 10;
getListOrgPage(req);
};
useEffect(() => {
getListOrgPage();
getLicenceModelsList();
getLicenceGradeList();
getLicenceTypeList();
}, []);
return (
<div className='institutions-list'>
......@@ -119,11 +204,13 @@ const InstitutionsList = () => {
新增
</Button>
}
searchData={searchSuccess}
/>
<Table
bordered
columns={tableColumns}
dataSource={tableData}
rowKey='id'
pagination={{
total: pagination.totalCount,
pageSize: pagination.pageSize,
......
......@@ -22,7 +22,7 @@ export const authRouterList = async () => {
const getRouteList = (data: RouteObjectType[]) => {
return data.reduce((pre: RouteObjectType[], cur) => {
const Obj: RouteObjectType = { ...cur };
if (ids.includes(Obj.meta.id) || Obj.meta.hidden || Obj.path?.includes('pilotTraining')) {
if (ids.includes(Obj.meta.id) || Obj.meta.hidden) {
if (Obj.children) {
Obj.children = [...getRouteList(Obj.children)];
}
......
......@@ -33,6 +33,7 @@ import {
ReadOutlined,
ThunderboltOutlined,
BankOutlined,
VerifiedOutlined,
} from '@ant-design/icons';
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
......@@ -102,14 +103,14 @@ const CategoryDetail = React.lazy(() => import('~/pages/categoryManage/category/
// 目录管理
const DirectoryManage = React.lazy(() => import('~/pages/categoryManage/directoryManage'));
// //飞手培训
// const InstitutionsListView = React.lazy(
// () => import('~/pages/pilotTraining/ licensureExamination/institutionsList'),
// );
// //机构上传
// const AddInstitutionsView = React.lazy(
// () => import('~/pages/pilotTraining/ licensureExamination/addOrEditInstitution'),
// );
//飞手培训
const InstitutionsListView = React.lazy(
() => import('~/pages/pilotTraining/ licensureExamination/institutionsList'),
);
//机构上传
const AddInstitutionsView = React.lazy(
() => import('~/pages/pilotTraining/ licensureExamination/addOrEditInstitution'),
);
// 系统管理
import AccountManageView from '~/pages/systemManage/accountManage';
......@@ -895,50 +896,50 @@ export const routerList: Array<RouteObjectType> = [
// },
// ],
// },
// {
// path: '/pilotTraining',
// element: <LayoutView />,
// errorElement: <ErrorPage />,
// meta: {
// id: 1500,
// icon: <BankOutlined />,
// title: '飞手培训',
// },
// children: [
// {
// path: '/pilotTraining/institutionsList',
// element: withLoadingComponent(<InstitutionsListView />),
// errorElement: <ErrorPage />,
// meta: {
// id: 1510,
// title: '执照考试',
// icon: <VerifiedOutlined />,
// },
// },
// {
// path: '/pilotTraining/institutionsList/add',
// element: withLoadingComponent(<AddInstitutionsView />),
// errorElement: <ErrorPage />,
// meta: {
// id: 1520,
// title: '机构上传',
// icon: <UserOutlined />,
// hidden: true,
// },
// },
// {
// path: '/pilotTraining/institutionsList/edit',
// element: withLoadingComponent(<AddInstitutionsView />),
// errorElement: <ErrorPage />,
// meta: {
// id: 1530,
// title: '机构编辑',
// icon: <UserOutlined />,
// hidden: true,
// },
// },
// ],
// },
{
path: '/pilotTraining',
element: <LayoutView />,
errorElement: <ErrorPage />,
meta: {
id: 1600,
icon: <BankOutlined />,
title: '飞手培训',
},
children: [
{
path: '/pilotTraining/institutionsList',
element: withLoadingComponent(<InstitutionsListView />),
errorElement: <ErrorPage />,
meta: {
id: 1610,
title: '执照考试',
icon: <VerifiedOutlined />,
},
},
{
path: '/pilotTraining/institutionsList/add',
element: withLoadingComponent(<AddInstitutionsView />),
errorElement: <ErrorPage />,
meta: {
id: 1520,
title: '机构上传',
icon: <UserOutlined />,
hidden: true,
},
},
{
path: '/pilotTraining/institutionsList/edit',
element: withLoadingComponent(<AddInstitutionsView />),
errorElement: <ErrorPage />,
meta: {
id: 1530,
title: '机构编辑',
icon: <UserOutlined />,
hidden: true,
},
},
],
},
{
path: '/systemManage',
element: <LayoutView />,
......
// 不能输入数字,其他可输入
// 不能输入数字,其他可输入
export const exceptNumber = (val: any) => {
val.target.value = val.target.value.replace(/1?(\d|([1-9]\d+))(.\d+)?$/g, '').replace(/\s/g, '');
};
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论