From 20f03721da4de21f42f83fe897156b997fbc9e22 Mon Sep 17 00:00:00 2001 From: Joe Date: Sat, 24 May 2025 00:09:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/config.ts | 5 ++- src/components/CropImage/index.tsx | 12 ++++-- .../FashionTrend/components/UpdateForm.tsx | 38 ++++++++++++++----- src/pages/FashionTrend/index.tsx | 1 + .../components/UpdateForm.tsx | 5 ++- src/pages/ProductList/add.tsx | 7 +++- src/pages/ProductList/index.tsx | 13 ++++++- 7 files changed, 61 insertions(+), 20 deletions(-) diff --git a/config/config.ts b/config/config.ts index 81eb9a2..782030a 100644 --- a/config/config.ts +++ b/config/config.ts @@ -40,6 +40,7 @@ export default defineConfig({ keepalive: [/./], tabsLayout: { hasDropdown: true, + hasFixedHeader: true }, /** * @name moment 的国际化配置 @@ -91,8 +92,8 @@ export default defineConfig({ plugins: ['duration'], }, define: { - // 'process.env.BASE_URL': 'http://xft-cms.51jingcheng.com/api', // 接口服务器地址 - 'process.env.BASE_URL': process.env.NODE_ENV === 'development' ? '' : 'http://xfcadminv2.51jingcheng.com/api', // 接口服务器地址 + 'process.env.BASE_URL': 'http://cms.gjxfc.com/api', // 接口服务器地址 + // 'process.env.BASE_URL': process.env.NODE_ENV === 'development' ? '' : 'http://xfcadminv2.51jingcheng.com/api', // 接口服务器地址 }, /** * @name 国际化插件 diff --git a/src/components/CropImage/index.tsx b/src/components/CropImage/index.tsx index 7d2994e..e1b4401 100644 --- a/src/components/CropImage/index.tsx +++ b/src/components/CropImage/index.tsx @@ -1,13 +1,14 @@ import { PlusOutlined } from "@ant-design/icons"; import { message, Upload } from "antd"; import ImgCrop from "antd-img-crop"; -import { RcFile, UploadChangeParam, UploadFile } from "antd/es/upload"; +import { RcFile, UploadFile } from "antd/es/upload"; type ImageBase64UploadProps = { - value?: string; - onChange?: (info: UploadChangeParam>) => void; + value?: UploadFile[]; + onChange?: (fileList: UploadFile[]) => void; }; export default ((props) => { + console.log(props.value) return ( { headers={{ authorization: localStorage.getItem('token') ?? '', }} + fileList={props.value} maxCount={1} action={process.env.BASE_URL + '/oss/imgUpload'} style={{ width: '100%' }} @@ -36,7 +38,9 @@ export default ((props) => { window.open(file.response.data); } }} - onChange={props.onChange} + onChange={(info) => { + props.onChange?.(info.fileList) + }} > {!props.value && (
diff --git a/src/pages/FashionTrend/components/UpdateForm.tsx b/src/pages/FashionTrend/components/UpdateForm.tsx index 2d543e4..2ecc967 100644 --- a/src/pages/FashionTrend/components/UpdateForm.tsx +++ b/src/pages/FashionTrend/components/UpdateForm.tsx @@ -101,8 +101,11 @@ const UpdateForm: React.FC = (props) => { } else if (value.pbcType === 2 && value.pbcVideo.length > 0) { pbcPicAddress = value.pbcVideo[0].url || value.pbcVideo[0].response.data; pbcThumbNail = videoThumbnail; + } else if (value.pbcType === 3 && value.pbcFile.length > 0) { + pbcPicAddress = value.pbcFile[0].url || value.pbcFile[0].response.data; + pbcThumbNail = "https://oss-xfc.popshejie.com/pop-b2b2c/pdf_fac16828-ea35-4034-9ad8-263605611960.png"; } - return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcId: props.values.pbcId }) + return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcContent: value.pbcType === 3 ? '预览文件' : value.pbcContent, pbcId: props.values.pbcId }) }} drawerProps={{ destroyOnClose: true, @@ -124,6 +127,12 @@ const UpdateForm: React.FC = (props) => { status: 'done', url: props.values.pbcPicAddress, }] : [], + pbcFile: props.values.pbcType === 3 && props.values.pbcPicAddress ? [{ + uid: '-1', + name: props.values.pbcPicAddress.substring(props.values.pbcPicAddress.lastIndexOf('/') + 1), + status: 'done', + url: props.values.pbcPicAddress, + }] : [], pbcContent: props.values.pbcContent }} onOpenChange={(visible) => { @@ -157,6 +166,10 @@ const UpdateForm: React.FC = (props) => { label: '视频', value: 2, }, + { + label: '文件', + value: 3, + }, ]} rules={[ { @@ -169,6 +182,7 @@ const UpdateForm: React.FC = (props) => { setPbcType(e.target.value) formRef.current?.setFieldValue('pbcImage', []); formRef.current?.setFieldValue('pbcVideo', []); + formRef.current?.setFieldValue('pbcFile', []); }, }} /> @@ -218,12 +232,12 @@ const UpdateForm: React.FC = (props) => { ]} /> : = (props) => { case 'done': if (info.file.response.retcode === 0) { message.error(info.file.response.retmsg); - formRef.current?.setFieldValue('pbcVideo', []) - } else if (info.file.response && info.file.response.retcode) { + if (pbcType === 2) { + formRef.current?.setFieldValue('pbcVideo', []) + } else { + formRef.current?.setFieldValue('pbcFile', []) + } + } else if (info.file.response && info.file.response.retcode && pbcType === 2) { // 视频上传成功后,获取视频首帧作为缩略图 const videoUrl = info.file.response.data; generateVideoThumbnail(videoUrl); @@ -248,7 +266,7 @@ const UpdateForm: React.FC = (props) => { beforeUpload(file: RcFile) { const isLt30M = file.size / 1024 / 1024 < 30; if (!isLt30M) { - message.error('视频大小不能超过30MB!'); + message.error(`${pbcType === 2 ? '视频' : '文件'}大小不能超过30MB!`); } return isLt30M || Upload.LIST_IGNORE; }, @@ -263,10 +281,10 @@ const UpdateForm: React.FC = (props) => { listType: 'picture-card', }} rules={[ - { required: true, message: '请上传视频' }, + { required: true, message: `请上传${pbcType === 2 ? '视频' : '文件'}'` }, ]} />} - = (props) => { ]} > - + :null} ); }; diff --git a/src/pages/FashionTrend/index.tsx b/src/pages/FashionTrend/index.tsx index 02e7cf7..941f1c2 100644 --- a/src/pages/FashionTrend/index.tsx +++ b/src/pages/FashionTrend/index.tsx @@ -98,6 +98,7 @@ const TableList: React.FC = () => { valueEnum: { 1: '图片', 2: '视频', + 3: '文件', }, }, { diff --git a/src/pages/InnovativeService/components/UpdateForm.tsx b/src/pages/InnovativeService/components/UpdateForm.tsx index bf7990a..3e863d3 100644 --- a/src/pages/InnovativeService/components/UpdateForm.tsx +++ b/src/pages/InnovativeService/components/UpdateForm.tsx @@ -101,8 +101,11 @@ const UpdateForm: React.FC = (props) => { } else if (value.pbcType === 2 && value.pbcVideo.length > 0) { pbcPicAddress = value.pbcVideo[0].url || value.pbcVideo[0].response.data; pbcThumbNail = videoThumbnail; + } else if (value.pbcType === 3 && value.pbcFile.length > 0) { + pbcPicAddress = value.pbcFile[0].url || value.pbcFile[0].response.data; + pbcThumbNail = "https://oss-xfc.popshejie.com/pop-b2b2c/pdf_fac16828-ea35-4034-9ad8-263605611960.png"; } - return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcId: props.values.pbcId }) + return props.onSubmit({ ...value, pbcPicAddress, pbcThumbNail, pbcContent: value.pbcType === 3 ? '预览文件' : value.pbcContent, pbcId: props.values.pbcId }) }} drawerProps={{ destroyOnClose: true, diff --git a/src/pages/ProductList/add.tsx b/src/pages/ProductList/add.tsx index 17557fa..e400f7e 100644 --- a/src/pages/ProductList/add.tsx +++ b/src/pages/ProductList/add.tsx @@ -75,6 +75,7 @@ const Detail: React.FC = () => { // const inputRef = useRef(null); const [selectedTags, setSelectedTags] = useState([]); const [pbcBusinessId, setPbcBusinessId] = useState(); + const [datas, setDatas] = useState({}); const formRef = useRef(); @@ -135,6 +136,7 @@ const Detail: React.FC = () => { // 处理表单数据 const formData = { ...data, + pbcState: data.pbcState ? `${data.pbcState}` : null, pbcProductCategoryIdList: [data.pbcProductTopCategoryId, data.pbcProductParentCategoryId, data.pbcProductCategoryId], pbcZone: data.pbcProductOriginalProvince ? [data.pbcProductOriginalProvince, data.pbcProductOriginalCity] : undefined, pbcProductImages: data.pbcProductImages ? data.pbcProductImages.split(',').map((url: string) => ({ @@ -186,6 +188,7 @@ const Detail: React.FC = () => { // 设置表单数据 formRef.current?.setFieldsValue(formData); + setDatas(res.data) } }); } @@ -274,6 +277,7 @@ const Detail: React.FC = () => { labelAssociationList = tags.filter(it => it.pbcId && selectedTags.includes(it.pbcId)) } const params: API.PbcProductDTO = { + ...datas, ...values, labelAssociationList, pbcProductOriginalProvince, @@ -291,7 +295,8 @@ const Detail: React.FC = () => { } const msg = await addOrUpdateProductForAdminUsingPost(params) if (msg.retcode) { - message.success("创建成功!") + formRef.current?.resetFields() + message.success("保存成功!") history.back(); return true } else { diff --git a/src/pages/ProductList/index.tsx b/src/pages/ProductList/index.tsx index 72c9c78..41984d1 100644 --- a/src/pages/ProductList/index.tsx +++ b/src/pages/ProductList/index.tsx @@ -8,10 +8,10 @@ import { } from '@/services/pop-b2b2c/pbcProductController'; import { ActionType, ProColumns, ProTable } from '@ant-design/pro-components'; import { PageContainer } from '@ant-design/pro-layout'; -import { Access, useAccess, history } from '@umijs/max'; +import { Access, useAccess, history, useLocation } from '@umijs/max'; import { Button, message, Popconfirm, Space } from 'antd'; import moment from 'moment'; -import React, { useRef } from 'react'; +import React, { useRef, useEffect } from 'react'; /** * 查询表格 @@ -34,6 +34,11 @@ const fetchData = async (params: any) => { const TableList: React.FC<{}> = () => { const actionRef = useRef(); const access: any = useAccess(); + const location = useLocation(); + + useEffect(() => { + actionRef.current?.reload(); + }, [location.pathname]); const columns: ProColumns[] = [ { @@ -184,6 +189,10 @@ const TableList: React.FC<{}> = () => { { + if (record.pbcState === 1) { + message.error("请先下架商品再删除") + return + } deleteProductForAdminUsingGet({ pcbId: record.pbcId || 0 }).then( (res) => { if (res.retcode) {