Joe 1 year ago
commit 71571f4200

@ -87,8 +87,8 @@ export default defineConfig({
plugins: ['duration'],
},
define: {
// 'process.env.BASE_URL': 'http://xft-cms.51jingcheng.com/api', // 接口服务器地址
'process.env.BASE_URL': 'http://cms.gjxfc.com/api', // 接口服务器地址
'process.env.BASE_URL': 'http://xft-cms.51jingcheng.com/api', // 接口服务器地址
// 'process.env.BASE_URL': 'http://cms.gjxfc.com/api', // 接口服务器地址
},
/**
* @name

@ -59,6 +59,7 @@ const Detail: React.FC<any> = () => {
const [info, setInfo] = useState<API.PbcBusiness>({});
const [form1] = Form.useForm();
const [form2] = Form.useForm();
const getInfo = () => {
if (params.id) {
@ -78,13 +79,17 @@ const Detail: React.FC<any> = () => {
activationConstraint: { distance: 10 },
});
const onDragEnd = ({ active, over }: DragEndEvent, fieldName: string) => {
const onDragEnd = ({ active, over }: DragEndEvent, fieldName: string, type: number) => {
if (active.id !== over?.id) {
const arr = form1.getFieldValue(fieldName) || []
const arr = type === 1 ? form1.getFieldValue(fieldName) || [] : form2.getFieldValue(fieldName)
const activeIndex = arr.findIndex((i: any) => i.uid === active.id);
const overIndex = arr.findIndex((i: any) => i.uid === over?.id);
const newArr = arrayMove(arr, activeIndex, overIndex)
form1.setFieldValue(fieldName, newArr)
if (type === 1) {
form1.setFieldValue(fieldName, newArr)
} else {
form2.setFieldValue(fieldName, newArr)
}
}
};
@ -116,9 +121,8 @@ const Detail: React.FC<any> = () => {
);
},
renderFormItem: (text, props: any) => {
console.log(props.id)
return (
<DndContext sensors={[sensor]} onDragEnd={(event) => onDragEnd(event, props.id)}>
<DndContext sensors={[sensor]} onDragEnd={(event) => onDragEnd(event, props.id, 1)}>
<SortableContext items={form1.getFieldValue(props.id) ? form1.getFieldValue(props.id).map((i: any) => i.uid) : []} strategy={verticalListSortingStrategy}>
<ProFormUploadButton
{...props}
@ -142,16 +146,14 @@ const Detail: React.FC<any> = () => {
return isLt2M;
},
onPreview: async (file) => {
console.log(file);
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
} else {
window.open(file.url);
}
},
}}
action={'/oss/imgUpload'}
action={process.env.BASE_URL + '/oss/imgUpload'}
onChange={(a: any) => {
props?.fieldProps.onChange(a.fileList);
}}
@ -200,11 +202,10 @@ const Detail: React.FC<any> = () => {
) {
for (let i = 0; i < record[key].length; i++) {
const element = record[key][i];
if (element.uid === '-1') {
pbcBusinessImage.push(element.url)
}
if (element.response && element.response.retcode) {
pbcBusinessImage.push(element.response.data)
} else {
pbcBusinessImage.push(element.url)
}
}
}
@ -215,11 +216,10 @@ const Detail: React.FC<any> = () => {
) {
for (let i = 0; i < record[key].length; i++) {
const element = record[key][i];
if (element.uid === '-1') {
pbcBusinessPosterUrl.push(element.url)
}
if (element.response && element.response.retcode) {
pbcBusinessPosterUrl.push(element.response.data)
} else {
pbcBusinessPosterUrl.push(element.url)
}
}
}
@ -411,43 +411,46 @@ const Detail: React.FC<any> = () => {
<span></span>
);
},
renderFormItem: (text, props) => {
renderFormItem: (text, props: any) => {
return (
<ProFormUploadButton
{...props}
{...props?.fieldProps}
icon={<PlusCircleOutlined style={{ fontSize: 30 }} />}
title={<div style={{ marginTop: 10, fontSize: 12 }}></div>}
fieldProps={{
name: 'file',
accept: 'image/*',
multiple: true,
listType: 'picture-card',
headers: {
authorization: localStorage.getItem('token') ?? '',
},
beforeUpload(file: RcFile) {
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isLt2M) {
message.error('图片大小不能超过10MB!');
}
return isLt2M;
},
onPreview: async (file) => {
console.log(file);
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
}}
action={'/oss/imgUpload'}
onChange={(a: any) => {
props?.fieldProps.onChange(a.fileList);
}}
/>
<DndContext sensors={[sensor]} onDragEnd={(event) => onDragEnd(event, props.id, 2)}>
<SortableContext items={form2.getFieldValue(props.id) ? form2.getFieldValue(props.id).map((i: any) => i.uid) : []} strategy={verticalListSortingStrategy}>
<ProFormUploadButton
{...props}
{...props?.fieldProps}
icon={<PlusCircleOutlined style={{ fontSize: 30 }} />}
title={<div style={{ marginTop: 10, fontSize: 12 }}></div>}
fieldProps={{
name: 'file',
accept: 'image/*',
multiple: true,
listType: 'picture-card',
headers: {
authorization: localStorage.getItem('token') ?? '',
},
itemRender: (originNode, file) => <DraggableUploadListItem originNode={originNode} file={file} />,
beforeUpload(file: RcFile) {
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isLt2M) {
message.error('图片大小不能超过10MB!');
}
return isLt2M;
},
onPreview: async (file) => {
if (file.response && file.response.retcode) {
window.open(file.response.data);
} else {
window.open(file.url);
}
},
}}
action={process.env.BASE_URL + '/oss/imgUpload'}
onChange={(a: any) => {
props?.fieldProps.onChange(a.fileList);
}}
/>
</SortableContext>
</DndContext>
);
},
},
@ -495,7 +498,7 @@ const Detail: React.FC<any> = () => {
editable={
access.businessSave && isEdit
? {
form: form1,
form: form2,
onSave: async (key, record: any, originRow) => {
let pbcBusinessHeadUserNoFrontUrl = "";
if (
@ -523,7 +526,7 @@ const Detail: React.FC<any> = () => {
pbcBusinessHeadUserNoBackUrl = record[key][0].response.data;
}
}
const pbcBusinessLicenseUrl = [];
let pbcBusinessLicenseUrl = [];
if (
key === 'pbcBusinessLicenseUrl' &&
record[key] &&
@ -531,11 +534,10 @@ const Detail: React.FC<any> = () => {
) {
for (let i = 0; i < record[key].length; i++) {
const element = record[key][i];
if (element.uid === '-1') {
pbcBusinessLicenseUrl.push(element.url)
}
if (element.response && element.response.retcode) {
pbcBusinessLicenseUrl.push(element.response.data)
} else {
pbcBusinessLicenseUrl.push(element.url)
}
}
}
@ -547,8 +549,7 @@ const Detail: React.FC<any> = () => {
key === 'pbcBusinessHeadUserNoFrontUrl' ? pbcBusinessHeadUserNoFrontUrl : info.pbcBusinessHeadUserNoFrontUrl,
pbcBusinessHeadUserNoBackUrl:
key === 'pbcBusinessHeadUserNoBackUrl' ? pbcBusinessHeadUserNoBackUrl : info.pbcBusinessHeadUserNoBackUrl,
pbcBusinessLicenseUrl:
key === 'pbcBusinessLicenseUrl' ? pbcBusinessLicenseUrl.join(',') : info.pbcBusinessLicenseUrl,
pbcBusinessLicenseUrl: key === 'pbcBusinessLicenseUrl' ? pbcBusinessLicenseUrl.join(',') : info.pbcBusinessLicenseUrl
})
.then((res) => {
if (res.retcode) {

@ -1,10 +1,11 @@
import React, { useEffect, useRef, useState } from 'react';
import { DrawerForm, ProFormCheckbox, ProFormInstance, ProFormText, ProFormUploadButton } from '@ant-design/pro-components';
import { DrawerForm, ProForm, ProFormCheckbox, ProFormInstance, ProFormText, ProFormUploadButton } from '@ant-design/pro-components';
import { PlusCircleOutlined } from '@ant-design/icons';
import { message } from 'antd';
import { RcFile } from 'antd/es/upload';
import Upload, { RcFile, UploadFile, UploadProps } from 'antd/es/upload';
import { specificationListUsingGet } from '@/services/pop-b2b2c/pbcSpecificationController';
import { getRecordByL3CategoryIdUsingGet } from '@/services/pop-b2b2c/pbcCommonDataController';
import ImgCrop from 'antd-img-crop';
export type FormValueType = {
target?: string;
template?: string;
@ -19,10 +20,26 @@ export type UpdateFormProps = {
values: Partial<API.PbcCategory>;
};
const normFile = (e: any) => {
if (Array.isArray(e)) {
return e;
}
return e?.fileList;
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const formRef = useRef<ProFormInstance>();
const [specList, setSpecList] = useState<API.PbcSpecification[]>([])
const [fileList, setFileList] = useState<UploadFile[]>(props.values.pbcCategoryImage ? [
{
uid: '-1',
name: 'image.png',
status: 'done',
url: props.values.pbcCategoryImage,
},
] : []);
useEffect(() => {
if (props.values.pbcCategoryLevel === 3) {
specificationListUsingGet().then(res => {
@ -54,6 +71,10 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
}
}, [props.values.pbcCategoryLevel, props.values.pbcId])
const onChange: UploadProps['onChange'] = ({ fileList: newFileList }) => {
setFileList(newFileList);
};
return (
<DrawerForm
width={640}
@ -63,15 +84,15 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
formRef={formRef}
onFinish={(value) => {
let pbcCategoryImage = ""
if (value.pbcCategoryImage && value.pbcCategoryImage.length > 0) {
if (value.pbcCategoryImage[0].uid === '-1') {
pbcCategoryImage = value.pbcCategoryImage[0].url;
if (fileList && fileList.length > 0) {
if (fileList[0].uid === '-1') {
pbcCategoryImage = fileList[0].url || '';
}
if (
value.pbcCategoryImage[0].response &&
value.pbcCategoryImage[0].response.retcode
fileList[0].response &&
fileList[0].response.retcode
) {
pbcCategoryImage = value.pbcCategoryImage[0].response.data;
pbcCategoryImage = fileList[0].response.data;
}
}
const arr = specList.filter(e => value.pbcSpecificationList && value.pbcSpecificationList.length > 0 && value.pbcSpecificationList.includes(e.pbcId))
@ -81,15 +102,7 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
destroyOnClose: true,
}}
initialValues={{
pbcCategoryName: props.values.pbcCategoryName,
pbcCategoryImage: props.values.pbcCategoryImage ? [
{
uid: '-1',
name: 'image.png',
status: 'done',
url: props.values.pbcCategoryImage,
},
] : []
pbcCategoryName: props.values.pbcCategoryName
}}
onOpenChange={(visible) => {
formRef.current?.resetFields();
@ -110,38 +123,67 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
width="md"
name="pbcCategoryName"
/>
<ProFormUploadButton
name="pbcCategoryImage"
label="图片"
icon={<PlusCircleOutlined style={{ fontSize: 30 }} />}
title={<div style={{ marginTop: 10, fontSize: 12 }}></div>}
max={1}
fieldProps={{
name: 'file',
accept: 'image/*',
listType: 'picture-card',
headers: {
authorization: localStorage.getItem('token') ?? '',
},
beforeUpload(file: RcFile) {
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isLt2M) {
message.error('图片大小不能超过10MB!');
}
return isLt2M;
},
onPreview: async (file) => {
console.log(file)
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
}}
action={process.env.BASE_URL + '/oss/imgUpload'}
/>
<ProForm.Item name="pbcCategoryImage" label="图片">
<ImgCrop rotationSlider>
<Upload
name="file"
accept="image/*"
headers={{
authorization: localStorage.getItem('token') ?? '',
}}
maxCount={1}
action={process.env.BASE_URL + '/oss/imgUpload'}
listType="picture-card"
fileList={fileList}
onChange={onChange}
onPreview={async (file) => {
console.log(file)
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
}}
>
{fileList.length === 0 && '点击上传图片'}
</Upload>
</ImgCrop>
</ProForm.Item>
{/* <ProFormUploadButton
name="pbcCategoryImage"
label="图片"
icon={<PlusCircleOutlined style={{ fontSize: 30 }} />}
title={<div style={{ marginTop: 10, fontSize: 12 }}></div>}
max={1}
fieldProps={{
name: 'file',
accept: 'image/*',
listType: 'picture-card',
headers: {
authorization: localStorage.getItem('token') ?? '',
},
beforeUpload(file: RcFile) {
const isLt2M = file.size / 1024 / 1024 < 10;
if (!isLt2M) {
message.error('图片大小不能超过10MB!');
}
return isLt2M;
},
onPreview: async (file) => {
console.log(file)
if (file.uid === '-1') {
window.open(file.url);
}
if (file.response && file.response.retcode) {
window.open(file.response.data);
}
},
}}
action={'/oss/imgUpload'}
/> */}
{props.values.pbcCategoryLevel === 3 ? <ProFormCheckbox.Group
label="类目规格"
width="md"

Loading…
Cancel
Save