From d5f7cd723ee76003620a7c58b460bf3305142635 Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 18 Feb 2025 17:23:55 +0800 Subject: [PATCH] up --- src/pages/RequirementAudits/detail.tsx | 169 ++++++ src/pages/RequirementAudits/index.tsx | 130 +++++ src/pages/TrainingClasses/add.tsx | 18 +- src/pages/TrainingClasses/detail.tsx | 684 +++++++++++++++++++------ src/pages/TrainingClasses/index.tsx | 2 +- 5 files changed, 835 insertions(+), 168 deletions(-) create mode 100644 src/pages/RequirementAudits/detail.tsx create mode 100644 src/pages/RequirementAudits/index.tsx diff --git a/src/pages/RequirementAudits/detail.tsx b/src/pages/RequirementAudits/detail.tsx new file mode 100644 index 0000000..9dcee83 --- /dev/null +++ b/src/pages/RequirementAudits/detail.tsx @@ -0,0 +1,169 @@ +import { + approvalSignNUsingPost, + approvalSignYUsingGet, + getRecordByBusinessIdAdminUsingGet, +} from '@/services/pop-b2b2c/pbcBusinessApprovalController'; +import { ModalForm, ProCard, ProFormTextArea } from '@ant-design/pro-components'; +import { PageContainer } from '@ant-design/pro-layout'; +import { Access, useAccess, useParams } from '@umijs/max'; +import { Button, Descriptions, Image, message } from 'antd'; +import React, { useEffect, useState } from 'react'; + +const Detail: React.FC = () => { + const params = useParams(); + const access: any = useAccess(); + + const [info, setInfo] = useState({}); + const [isModalOpen, setIsModalOpen] = useState(false); + + const getInfo = () => { + if (params.id) { + getRecordByBusinessIdAdminUsingGet({ businessId: parseInt(params.id) }).then((res) => { + if (res.retcode && res.data) { + setInfo(res.data); + } + }); + } + }; + + useEffect(() => { + getInfo(); + }, []); + + return ( + { + history.back(); + }} + > + 返回 + , + + + , + + + , + ] + : [ + , + ] + } + > + + + {info.pbcBusinessName} + {info.pbcBusinessType} + {info.pbcBusinessContact} + {info.pbcBusinessContactMobile} + {info.pbcBusinessHead} + {info.pbcBusinessHeadUserNo} + + + + + + + + + + + {info.pbcBusinessHead} + {info.pbcBusinessHeadUserNo} + {info.pbcBusinessStartDate} + {info.pbcBusinessBank} + + {info.pbcBusinessAccount} + + + {info.pbcBusinessMainCategory} + + + + + + + setIsModalOpen(false), + }} + requiredMark={false} + width={500} + onFinish={async (value: any) => { + console.log(value); + if (params.id) { + await approvalSignNUsingPost({ + pbcId: parseInt(params.id), + pbcBusinessApprovalRefusedReason: value.pbcBusinessApprovalRefusedReason, + }).then((res) => { + if (res.retcode) { + message.success('成功驳回'); + getInfo(); + setIsModalOpen(false); + } else { + message.error(res.retmsg); + } + }); + } + }} + > + + + + ); +}; + +export default Detail; diff --git a/src/pages/RequirementAudits/index.tsx b/src/pages/RequirementAudits/index.tsx new file mode 100644 index 0000000..e5c406b --- /dev/null +++ b/src/pages/RequirementAudits/index.tsx @@ -0,0 +1,130 @@ +import React, { useRef, useState } from 'react'; +import { Button } from 'antd'; +import { PageContainer } from '@ant-design/pro-layout'; +import { queryAllRoleUsingPost } from '@/services/pop-b2b2c/pbcRoleController'; +import Constants from '@/constants'; +import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; +import { handlePageQuery } from '@/utils/utils'; +import { pbcBusinessApprovalPageUsingPost } from '@/services/pop-b2b2c/pbcBusinessApprovalController'; +import { Link } from '@umijs/max'; + +/** + * 查询表格 + * @param param0 + */ +const fetchData = async (params: API.PageVO) => { + const msg = await pbcBusinessApprovalPageUsingPost(params); + return { + data: msg.data?.records, + total: msg.data?.total, + success: msg.retcode, + } as any; +}; + +// eslint-disable-next-line @typescript-eslint/ban-types +const TableList: React.FC<{}> = () => { + const actionRef = useRef(); + const [tabActiveKey, setTabActiveKey] = useState('0') + + const columns: ProColumns[] = [ + { + title: '商户名称', + dataIndex: 'pbcBusinessName', + }, + { + title: '联系人', + dataIndex: 'pbcBusinessContact', + }, + { + title: '商户手机号', + dataIndex: 'pbcBusinessContactMobile', + }, + { + title: '商户类别', + dataIndex: 'pbcBusinessType', + valueType: 'select', + valueEnum: Constants.pbcBusinessType + }, + { + title: '主营品类', + dataIndex: 'pbcBusinessMainCategory', + ellipsis: true, + search: false, + }, + { + title: '注册日期', + dataIndex: 'pbcCreateAt', + valueType: 'dateTimeRange', + render: (text, record) => record.pbcCreateAt + }, + { + title: '状态', + dataIndex: 'pbcBusinessApprovalResult', + valueEnum: Constants.pbcBusinessApprovalResult, + search: false + }, + { + title: '操作', + fixed: 'right', + valueType: 'option', + render: (text, record) => ( + + 详情 + + ), + }, + ]; + return ( + setTabActiveKey(key)} + tabList={[ + { + tab: "待审核", + key: "0" + }, + { + tab: "审核通过", + key: "1" + }, + { + tab: "审核驳回", + key: "2" + }, + ]} + > + + columns={columns} + actionRef={actionRef} + request={(param: any) => { + const queryParam = handlePageQuery(param); + return fetchData(queryParam); + }} + rowKey="pbcId" + size="small" + bordered + search={{ + labelWidth: 'auto', + span: 6 + }} + params={{ pbcBusinessApprovalResult: tabActiveKey }} + pagination={{ + defaultPageSize: 20, + showSizeChanger: true, + }} + scroll={{ + y: 'calc(100vh - 320px)', + }} + dateFormatter="string" + options={false} + toolBarRender={() => []} + /> + + ); +}; + +export default TableList; diff --git a/src/pages/TrainingClasses/add.tsx b/src/pages/TrainingClasses/add.tsx index 45e59d2..4e800b1 100644 --- a/src/pages/TrainingClasses/add.tsx +++ b/src/pages/TrainingClasses/add.tsx @@ -11,29 +11,20 @@ import { import { PageContainer } from '@ant-design/pro-layout'; import { Button, Col, message, Row } from 'antd'; import Upload, { RcFile } from 'antd/es/upload'; -import React, { useRef, useState } from 'react'; +import React, { useRef } from 'react'; import { history } from '@umijs/max'; import { getClassesTypeListForAdminUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesTypeController'; -import { addOrUpdateClassUsingPost, classDetailForAdminUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesController'; +import { addOrUpdateClassUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesController'; const Detail: React.FC = () => { const formRef = useRef(); - const [info, setInfo] = useState() const onSave = () => { formRef.current?.submit() } - const getInfo = (id: number) => { - classDetailForAdminUsingGet({ pbcId: id }).then((res) => { - if (res.retcode && res.data) { - setInfo(res.data); - } - }); - }; - const onSubmit = async (values: any) => { let pbcImages = "" @@ -55,10 +46,7 @@ const Detail: React.FC = () => { const msg = await addOrUpdateClassUsingPost(params) if (msg.retcode && msg.data) { message.success("创建成功!") - history.back(); - if (msg.data.pbcId) { - getInfo(msg.data.pbcId) - } + history.replace('/training-classes/detail/' + msg.data.pbcId + "?isEdit=1"); return true } else { message.error(msg.retmsg) diff --git a/src/pages/TrainingClasses/detail.tsx b/src/pages/TrainingClasses/detail.tsx index af89b8e..d528860 100644 --- a/src/pages/TrainingClasses/detail.tsx +++ b/src/pages/TrainingClasses/detail.tsx @@ -1,182 +1,562 @@ import { - changeProductStateForAdminUsingGet, - productDetailForAdminUsingGet, -} from '@/services/pop-b2b2c/pbcProductController'; -import { CheckCircleOutlined, InfoCircleOutlined } from '@ant-design/icons'; -import { ProCard } from '@ant-design/pro-components'; + ModalForm, + ProCard, + ProColumns, + ProForm, + ProFormDateTimeRangePicker, + ProFormDigit, + ProFormInstance, + ProFormSelect, + ProFormText, + ProFormUploadButton, + ProTable, +} from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; -import { Access, useAccess, useParams } from '@umijs/max'; -import { Button, Col, Descriptions, Image, message, Row, Tag } from 'antd'; -import React, { useEffect, useState } from 'react'; +import { Button, Col, message, Popconfirm, Row, Space } from 'antd'; +import Upload, { RcFile } from 'antd/es/upload'; +import React, { useRef, useState } from 'react'; +import { Access, history, useAccess, useParams, useSearchParams } from '@umijs/max'; +import { getClassesTypeListForAdminUsingPost } from '@/services/pop-b2b2c/pbcTrainingClassesTypeController'; +import { addOrUpdateClassUsingPost, classDetailForAdminUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesController'; +import { addOrUpdateChapterUsingPost, removeChapterUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesChapterController'; +import { addOrUpdateVideoUsingPost, removeVideoUsingGet } from '@/services/pop-b2b2c/pbcTrainingClassesVideoController'; + +/** + * 删除节点 + * @param id + */ +const handleRemove = async (id?: number) => { + const hide = message.loading('正在删除'); + if (!id) return false; + + try { + const msg = await removeChapterUsingGet({ + pbcId: id, + }); + hide(); + if (msg.retcode) { + message.success('删除成功,即将刷新'); + } else { + message.error(msg.retmsg ?? '删除失败,请重试'); + } + return true; + } catch (error) { + hide(); + message.error('删除失败,请重试'); + return false; + } +}; + +/** + * 删除节点 + * @param id + */ +const handleRemoveVideo = async (id?: number) => { + const hide = message.loading('正在删除'); + if (!id) return false; + + try { + const msg = await removeVideoUsingGet({ + pbcId: id, + }); + hide(); + if (msg.retcode) { + message.success('删除成功,即将刷新'); + } else { + message.error(msg.retmsg ?? '删除失败,请重试'); + } + return true; + } catch (error) { + hide(); + message.error('删除失败,请重试'); + return false; + } +}; const Detail: React.FC = () => { const params = useParams(); + const [searchParams] = useSearchParams(); + + const isEdit: boolean = searchParams.get('isEdit') === '1' const access: any = useAccess(); - const [info, setInfo] = useState({}); - const [images, setImages] = useState([]); - const [detailImages, setDetailImages] = useState([]); + const formRef = useRef(); + const formRef1 = useRef(); + const [info, setInfo] = useState() const getInfo = () => { if (params.id) { - productDetailForAdminUsingGet({ productId: parseInt(params.id) }).then((res) => { + classDetailForAdminUsingGet({ pbcId: parseInt(params.id) }).then((res) => { if (res.retcode && res.data) { setInfo(res.data); - if (res.data.pbcProductImages) { - const arr = res.data.pbcProductImages.split(','); - setImages(arr); - } - if (res.data.pbcProductDetailImages) { - const arr = res.data.pbcProductDetailImages.split(','); - setDetailImages(arr); - } } }); } }; - useEffect(() => { - getInfo(); - }, []); + const onSave = () => { + formRef.current?.submit() + } + + const onSubmit = async (values: any) => { + + let pbcImages = "" + if (values.pbcImages && values.pbcImages.length > 0) { + if (values.pbcImages[0].uid === '-1') { + pbcImages = values.pbcImages[0].url || ''; + } + if ( + values.pbcImages[0].response && + values.pbcImages[0].response.retcode + ) { + pbcImages = values.pbcImages[0].response.data; + } + } + + const params1: API.PbcTrainingClasses_ = { + ...info?.pbcTrainingClasses, + ...values, + pbcImages, + pbcTrainingStartDatetime: values.pbcTrainingStartDatetime[0], + pbcTrainingEndDatetime: values.pbcTrainingStartDatetime[1] + } + const msg = await addOrUpdateClassUsingPost(params1) + if (msg.retcode) { + message.success("保存成功!") + return true + } else { + message.error(msg.retmsg) + return false + } + } + + const [stepFormValues, setStepFormValues] = useState({}); + const [updateModalVisible, handleUpdateModalVisible] = useState(false); + const [stepFormValues1, setStepFormValues1] = useState({}); + const [updateModalVisible1, handleUpdateModalVisible1] = useState(false); + + const columns: ProColumns[] = [ + { + title: '课程目录', + dataIndex: 'pbcChapterName', + search: false, + }, + { + title: '创建时间', + dataIndex: 'pbcCreateAt', + search: false + }, + { + title: '操作', + fixed: 'right', + valueType: 'option', + render: (text, record) => ( + + + + + + + + + { + const success = await handleRemove(record.pbcId); + if (success) getInfo(); + }} + > + + + + + ), + }, + ]; + + const expandedRowRender = (row: API.PbcTrainingClassesChapter_) => { + return ( + ( + + + + + + { + const success = await handleRemoveVideo(record.pbcId); + if (success) getInfo(); + }} + > + + + + + ), + }, + ]} + headerTitle={false} + search={false} + options={false} + dataSource={row.videoList} + pagination={false} + /> + ); + }; return ( { - history.back(); + footer={[ + , + + ]} + > + { + if (params.id) { + const msg = await classDetailForAdminUsingGet({ pbcId: parseInt(params.id) }) + if (msg.retcode && msg.data) { + setInfo(msg.data); + return { + pbcClassesTypeName: msg.data.pbcTrainingClasses?.pbcClassesTypeName, + pbcTitle: msg.data.pbcTrainingClasses?.pbcTitle, + pbcClassesTypeId: msg.data.pbcTrainingClasses?.pbcClassesTypeId, + pbcClassesSubCount: msg.data.pbcTrainingClasses?.pbcClassesSubCount, + pbcImages: msg.data.pbcTrainingClasses?.pbcImages ? [{ + uid: '-1', + name: msg.data.pbcTrainingClasses?.pbcImages.substring(msg.data.pbcTrainingClasses?.pbcImages.lastIndexOf('/') + 1), + status: 'done', + url: msg.data.pbcTrainingClasses?.pbcImages, + }] : [], + pbcTeachMethod: msg.data.pbcTrainingClasses?.pbcTeachMethod, + pbcTrainingStartDatetime: msg.data.pbcTrainingClasses?.pbcTrainingStartDatetime && msg.data.pbcTrainingClasses?.pbcTrainingEndDatetime ? [msg.data.pbcTrainingClasses?.pbcTrainingStartDatetime, msg.data.pbcTrainingClasses?.pbcTrainingEndDatetime] : [], + } + } else { + return {} + } + } else { + return {} + } + }} requiredMark={false} formRef={formRef} onFinish={onSubmit} readonly={!isEdit} submitter={false}> + + + + + + - 基本信息 - {info.pbcState === 1 ? ( - } color="success"> - 上架中 - - ) : ( - } color="default"> - 已下架 - - )} - - } - column={3} - > - {info.pbcProductTitle} - - {info.pbcProductTopCategoryName}/{info.pbcProductParentCategoryName}/ - {info.pbcProductCategoryName} - - ¥{info.pbcProductPrice} - -
- {info.colorDataList?.map((e) => ( - - {e.pbcCommonDataSystem} - - - - - ))} -
-
- -
- - {images.map((e) => ( -
- -
- ))} -
-
-
- -
- - {detailImages.map((e) => ( -
- -
- ))} -
-
-
- - {info.productCommonDataList?.map((e) => ( - - - {e.pbcSystemName} - - - {e.pbcSystemInputType === 'select' - ? e.pbcCommonDataSystemValue - : e.pbcCommonDataSystem} - - - ))} - - - {info.pbcProductDetail} - - - {info.pbcProductVipLevels} - - + size='small' + rowKey="pbcId" + columns={columns} + dataSource={info?.chapterList} + expandable={{ expandedRowRender }} + search={false} + options={false} + toolBarRender={() => []} + pagination={false} + />
+ + handleUpdateModalVisible(false), + }} + requiredMark={false} + width={500} + initialValues={{ + pbcChapterName: stepFormValues.pbcChapterName + }} + onFinish={async (value: any) => { + if (params.id) { + await addOrUpdateChapterUsingPost({ + ...stepFormValues, + pbcChapterName: value.pbcChapterName, + }).then((res) => { + if (res.retcode) { + message.success('保存成功'); + getInfo(); + handleUpdateModalVisible(false); + } else { + message.error(res.retmsg); + } + }); + } + }} + > + + + handleUpdateModalVisible1(false), + }} + requiredMark={false} + width={500} + initialValues={{ + pbcVideoName: stepFormValues1.pbcVideoName, + }} + formRef={formRef1} + onFinish={async (value: any) => { + if (params.id) { + await addOrUpdateVideoUsingPost({ + ...stepFormValues1, + pbcVideoName: value.pbcVideoName, + }).then((res) => { + if (res.retcode) { + message.success('保存成功'); + getInfo(); + handleUpdateModalVisible1(false); + } else { + message.error(res.retmsg); + } + }); + } + }} + > + + { + switch (info.file.status) { + case 'done': + if (info.file.response.retcode === 0) { + message.error(info.file.response.retmsg); + formRef1.current?.setFieldValue('pbcVideoAddress', []) + } + break; + default: + break; + } + }, + action: process.env.BASE_URL + '/b2b2c/pbcTrainingClassesVideo/uploadVideoAndGetInfo', + onPreview: async (file) => { + if (file.uid === '-1') { + window.open(file.url); + } + if (file.response && file.response.retcode) { + window.open(file.response.data); + } + }, + progress: { + strokeColor: { + '0%': '#108ee9', + '100%': '#87d068', + }, + strokeWidth: 3, + format: (percent) => percent && `${parseFloat(percent.toFixed(2))}%`, + }, + }} + rules={[ + { required: true, message: '请上传视频' }, + ]} + /> +
); }; diff --git a/src/pages/TrainingClasses/index.tsx b/src/pages/TrainingClasses/index.tsx index 57f51f8..9c3ae36 100644 --- a/src/pages/TrainingClasses/index.tsx +++ b/src/pages/TrainingClasses/index.tsx @@ -137,7 +137,7 @@ const TableList: React.FC<{}> = () => { ] }} scroll={{ - y: 'calc(100vh - 320px)', + y: 'calc(100vh - 380px)', }} dateFormatter="string" options={false}