提交 18e30af0 作者: 龚洪江

修复:加盟资料必填

上级 0b41fdb3
......@@ -9,6 +9,7 @@ interface PropsType {
fileUpload: boolean; // 是否上传到服务器(返回文件流还是返回上传后的地址)
fileLength?: number; // 最大上传文件数量
children: React.ReactNode; // 上传按钮
showUploadList?: boolean; //是否隐藏上传文件列表
onChange?: (
fileList: {
id: number;
......@@ -27,6 +28,7 @@ export const Uploader: React.FC<PropsType> = (props) => {
fileType: ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'],
onChange: () => {},
defaultFileList: [],
showUploadList: true,
};
const {
fileType = ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/bmp'],
......@@ -37,12 +39,14 @@ export const Uploader: React.FC<PropsType> = (props) => {
fileLength,
onChange,
defaultFileList,
showUploadList,
} = props;
const [fileList, setFileList] = useState<any[]>([]);
// 上传文件配置
const uploadProps: UploadProps = {
listType,
fileList,
showUploadList,
beforeUpload: (res) => {
const isType = fileType?.includes(res.type);
const isSize = res.size / 1024 / 1024 < (fileSize || 2);
......
import { Button, Col, Divider, Form, Input, Row } from 'antd';
import { Button, Col, Divider, Form, Input, message, Row } from 'antd';
import { useRouter } from 'next/router';
import { useEffect, useState } from 'react';
import LayoutView from '~/components/layout';
......@@ -26,22 +26,27 @@ export default function JoinPolicy() {
}, [router.query.tagId]);
//提交
const submitApply = () => {
form.validateFields().then((valid) => {
api
.cooperationApply({
...valid,
cooperationTagId: tagId,
})
.then((res) => {
if (res.code === '200') {
window.messageApi.success('提交成功');
form.resetFields();
setTimeout(() => {
router.push('/');
}, 1500);
}
});
});
form
.validateFields()
.then((valid) => {
api
.cooperationApply({
...valid,
cooperationTagId: tagId,
})
.then((res) => {
if (res.code === '200') {
window.messageApi.success('提交成功');
form.resetFields();
setTimeout(() => {
router.push('/');
}, 1500);
}
});
})
.catch((err: any) => {
message.warning(err.errorFields[0].errors[0]);
});
};
//上传变更
const uploadChange = (value: any) => {
......@@ -96,7 +101,9 @@ export default function JoinPolicy() {
</Form.Item>
<Row>
<Col span={2}>
<div>上传资料:</div>
<div>
<span style={{ color: 'red' }}>*</span>上传资料:
</div>
</Col>
<Col span={10}>
<div className={styles.uploadTip}>
......@@ -105,7 +112,10 @@ export default function JoinPolicy() {
<div> 3. 文件大小不超过10M</div>
</div>
<div className={styles.uploadOperate}>
<Form.Item name='attachmentList'>
<Form.Item
name='attachmentList'
rules={[{ required: true, message: '请上传资料' }]}
>
<Uploader
fileUpload
listType='text'
......
import React, { useContext, useEffect, useState } from 'react';
import { OrderForGoodsBox } from './styled';
import type { FormInstance, RadioChangeEvent } from 'antd';
import type { RadioChangeEvent } from 'antd';
import { Button, Radio, Space, Input, message, Modal, Image } from 'antd';
import api, { UserAddress, GetOrderForGoods } from './api';
import moment from 'moment';
......
import { Form, Input, Modal, Upload, Image, Button, Row, Col } from 'antd';
import type { UploadProps } from 'antd/es/upload';
import { Form, Input, Modal, Image, Button, Row, Col } from 'antd';
import type { UploadFile } from 'antd/es/upload/interface';
import { useContext, useEffect, useState } from 'react';
import gApi from '~/api';
import { useContext, useState } from 'react';
import NImage from 'next/image';
import api from './api';
import { useGeolocation } from '~/lib/hooks';
......@@ -10,6 +8,7 @@ import { UserContext } from '~/lib/userProvider';
import uploadImg from '~/assets/images/upload.png';
import deleteIcon from '~/assets/images/delete-icon.png';
import styles from './index.module.scss';
import { Uploader } from '~/components/uploader';
type Props = {
open: boolean;
......@@ -18,7 +17,6 @@ type Props = {
};
const normFile = (e: any) => {
console.log('Upload event:', e);
if (Array.isArray(e)) {
return e;
}
......@@ -29,63 +27,12 @@ export default function PublishMessage(props: Props) {
const [fileList, setFileList] = useState<UploadFile[]>([]);
const [showLoading, setShowLoad] = useState(false);
const [form] = Form.useForm();
const { userInfo, setNeedLogin } = useContext(UserContext);
const { userInfo } = useContext(UserContext);
const position = useGeolocation();
const [token, setToken] = useState('');
useEffect(() => {
setToken(window.localStorage.getItem('token') || '');
}, []);
//图片上传
const handleChange: UploadProps['onChange'] = (info) => {
const isSize = (info.file as any).size / 1024 / 1024 < 5;
if (!isSize) {
window.messageApi.error('上传文件最大5M');
return;
}
const isType = [
'video/mp4',
'video/avi',
'video/wmv',
'video/rmvb',
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/bmp',
].includes(info.file.type as string);
if (!isType) {
window.messageApi.error('上传文件类型错误');
return;
}
if (info.file.status === 'uploading') {
let find = fileList.find((item) => {
return item.uid === info.file.uid;
});
if (!find) {
setFileList([...fileList, info.file]);
}
return;
} else if (info.file.status === 'done') {
if (info.file.response.code === '200' && info.file.response.result) {
let fileList1 = fileList.map((item) => {
if (item.uid === info.file.uid) {
info.file.url = info.file.response.result;
return info.file;
}
return item;
});
setFileList([...fileList1]);
} else {
window.messageApi.error(info.file.response?.message || '上传失败');
info.fileList = fileList.filter((item) => {
return item.uid !== info.file.uid;
});
setFileList([...info.fileList]);
}
} else {
setFileList([...info.fileList]);
}
const fileUploadChange = (value: any) => {
setFileList([...fileList, ...value]);
};
//删除媒体
const deleteMedia = (file: UploadFile) => {
......@@ -95,7 +42,6 @@ export default function PublishMessage(props: Props) {
//提交
const onFinish = (values: any) => {
setShowLoad(true);
if (userInfo) {
api
.publish({
......@@ -186,19 +132,26 @@ export default function PublishMessage(props: Props) {
<Col>
<Form.Item valuePropName='picture' getValueFromEvent={normFile}>
<Upload
name='uploadFile'
action={gApi.fileUpload}
listType='picture-card'
onChange={handleChange}
<Uploader
fileUpload
showUploadList={false}
maxCount={1}
headers={{ token: token }}
fileSize={5}
fileLength={9}
fileType={[
'video/mp4',
'video/avi',
'video/wmv',
'video/rmvb',
'image/png',
'image/jpeg',
'image/jpg',
'image/gif',
'image/bmp',
]}
onChange={fileUploadChange}
>
{fileList.length >= 9 ? null : (
<NImage src={uploadImg} alt='' width={100} height={100} />
)}
</Upload>
<NImage src={uploadImg} alt='' width={100} height={100} />
</Uploader>
</Form.Item>
</Col>
</Row>
......
import { Button, Image, Space, Input, Modal, Form, List, Divider, Skeleton } from 'antd';
import { Button, Image, Space, Input, Form, Divider, Skeleton } from 'antd';
import Layout from '~/components/layout';
import styles from './index.module.scss';
import errImg from '~/assets/errImg';
......@@ -192,19 +192,6 @@ export default function Forum() {
),
)}
</Space>
{/*<Image.PreviewGroup*/}
{/*>*/}
{/* <Space size={6} wrap>*/}
{/* {item?.mediaVO*/}
{/* ?.filter((v) => v.type === 0)*/}
{/* ?.map((img, index: number) => {*/}
{/* return (*/}
{/* );*/}
{/* })}*/}
{/* </Space>*/}
{/*</Image.PreviewGroup>*/}
</div>
<div className={styles.ctrls}>
<div className={styles.ctrlsItem} onClick={() => openComment(item)}>
......
......@@ -15,6 +15,7 @@ export interface Job {
serviceName: string;
teamName: string;
price: number;
inspComtAmount: number;
}
export interface ListPageJobInfoResp {
......
......@@ -41,7 +41,7 @@ export default function JobServices() {
</div>
</div>
<div className='item-bottom'>
<div className='bottom-left'>{Math.round(Math.random() * (150 - 100) + 100)}条评价</div>
<div className='bottom-left'>{item.inspComtAmount}条评价</div>
{/* <div className="bottom-right">专业飞手团队,精通巡航业务</div> */}
<div className='com'>{item.teamName}</div>
</div>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论