dev-v2
Joe 5 months ago
parent 25476835e3
commit 20f03721da

@ -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

@ -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<UploadFile<any>>) => void;
value?: UploadFile<any>[];
onChange?: (fileList: UploadFile<any>[]) => void;
};
export default ((props) => {
console.log(props.value)
return (
<ImgCrop rotationSlider>
<Upload
@ -17,6 +18,7 @@ export default ((props) => {
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 && (
<div>

@ -101,8 +101,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (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<UpdateFormProps> = (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<UpdateFormProps> = (props) => {
label: '视频',
value: 2,
},
{
label: '文件',
value: 3,
},
]}
rules={[
{
@ -169,6 +182,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (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<UpdateFormProps> = (props) => {
]}
/> :
<ProFormUploadButton
label="上传视频"
name="pbcVideo"
label={pbcType === 2 ? "上传视频" : "上传文件"}
name={pbcType === 2 ? "pbcVideo" : "pbcFile"}
max={1}
fieldProps={{
name: 'file',
accept: 'video/mp4',
accept: pbcType === 2 ? 'video/mp4' : '.pdf',
multiple: true,
headers: {
authorization: localStorage.getItem('token') ?? '',
@ -233,8 +247,12 @@ const UpdateForm: React.FC<UpdateFormProps> = (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<UpdateFormProps> = (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<UpdateFormProps> = (props) => {
listType: 'picture-card',
}}
rules={[
{ required: true, message: '请上传视频' },
{ required: true, message: `请上传${pbcType === 2 ? '视频' : '文件'}'` },
]}
/>}
<ProForm.Item
{pbcType !== 3 ? <ProForm.Item
name="pbcContent"
label="趋势内容"
rules={[
@ -277,7 +295,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
]}
>
<Editor />
</ProForm.Item>
</ProForm.Item>:null}
</DrawerForm>
);
};

@ -98,6 +98,7 @@ const TableList: React.FC<any> = () => {
valueEnum: {
1: '图片',
2: '视频',
3: '文件',
},
},
{

@ -101,8 +101,11 @@ const UpdateForm: React.FC<UpdateFormProps> = (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,

@ -75,6 +75,7 @@ const Detail: React.FC<any> = () => {
// const inputRef = useRef<InputRef>(null);
const [selectedTags, setSelectedTags] = useState<number[]>([]);
const [pbcBusinessId, setPbcBusinessId] = useState<number>();
const [datas, setDatas] = useState<API.PbcProductVO>({});
const formRef = useRef<ProFormInstance>();
@ -135,6 +136,7 @@ const Detail: React.FC<any> = () => {
// 处理表单数据
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<any> = () => {
// 设置表单数据
formRef.current?.setFieldsValue(formData);
setDatas(res.data)
}
});
}
@ -274,6 +277,7 @@ const Detail: React.FC<any> = () => {
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<any> = () => {
}
const msg = await addOrUpdateProductForAdminUsingPost(params)
if (msg.retcode) {
message.success("创建成功!")
formRef.current?.resetFields()
message.success("保存成功!")
history.back();
return true
} else {

@ -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<ActionType>();
const access: any = useAccess();
const location = useLocation();
useEffect(() => {
actionRef.current?.reload();
}, [location.pathname]);
const columns: ProColumns<API.PbcProduct>[] = [
{
@ -184,6 +189,10 @@ const TableList: React.FC<{}> = () => {
<Popconfirm
title={`确定需要删除该商品?`}
onConfirm={async () => {
if (record.pbcState === 1) {
message.error("请先下架商品再删除")
return
}
deleteProductForAdminUsingGet({ pcbId: record.pbcId || 0 }).then(
(res) => {
if (res.retcode) {

Loading…
Cancel
Save