This commit is contained in:
lyp 2025-05-27 11:35:21 +08:00
parent dea162cb7d
commit ca5c6f4a4d
2 changed files with 107 additions and 71 deletions

View File

@ -93,7 +93,7 @@ export default function AppEdit() {
return { return {
label: item.dataId, label: item.dataId,
value: item.dataName, value: item.dataName,
} }
})) }))
} catch (error: any) { } catch (error: any) {
@ -196,8 +196,8 @@ export default function AppEdit() {
getRunSystemList() getRunSystemList()
getBigClassList() getBigClassList()
if(appInfo.bigClassify) { if (appInfo.bigClassify) {
getSmallClassList(appInfo.bigClassify) getSmallClassList(appInfo.bigClassify)
} }
}, []); }, []);
const height = window.innerHeight - 180; const height = window.innerHeight - 180;
@ -302,6 +302,7 @@ export default function AppEdit() {
display: editProcess == 1 ? 'block' : 'none' display: editProcess == 1 ? 'block' : 'none'
}}> }}>
<AppCompany <AppCompany
appOrderId={appOrderId}
companyInfo={companyInfo} companyInfo={companyInfo}
setEditProcess={ setEditProcess={
(num: number) => { (num: number) => {
@ -318,6 +319,7 @@ export default function AppEdit() {
display: editProcess == 2 ? 'block' : 'none' display: editProcess == 2 ? 'block' : 'none'
}}> }}>
<EditAppInfo <EditAppInfo
appOrderId={appOrderId}
bigClass={bigClass} bigClass={bigClass}
systemList={systemList} systemList={systemList}
smallClass={smallClass} smallClass={smallClass}
@ -337,6 +339,7 @@ export default function AppEdit() {
display: editProcess == 3 ? 'block' : 'none' display: editProcess == 3 ? 'block' : 'none'
}}> }}>
<EditAppFiles <EditAppFiles
appOrderId={appOrderId}
filesInfo={filesInfo} filesInfo={filesInfo}
setEditProcess={ setEditProcess={
(num: number) => { (num: number) => {
@ -353,6 +356,7 @@ export default function AppEdit() {
} }
}></EditAppFunction> */} }></EditAppFunction> */}
<AppInfo <AppInfo
appOrderId={appOrderId}
companyInfo={companyInfo} companyInfo={companyInfo}
appInfo={appInfo} appInfo={appInfo}
filesInfo={filesInfo} filesInfo={filesInfo}

View File

@ -1,13 +1,14 @@
import { useState,useEffect } from 'react' import { useState, useEffect } from 'react'
import './app-company.css' import './app-company.css'
import { uploadFileUrl } from '../../../../request/request' import { uploadFileUrl, showImage } from '../../../../request/request'
import { Button, Form, Input, message, import {
Button, Form, Input, message,
// Select, DatePicker, // Select, DatePicker,
Upload, Image, Upload, Image,
// Cascader // Cascader
} from "antd" } from "antd"
import { LoadingOutlined, } from '@ant-design/icons'; import { LoadingOutlined, } from '@ant-design/icons';
import type { GetProp, UploadProps } from 'antd'; import type { UploadProps } from 'antd';
// import { // import {
// getCityList // getCityList
// } from '../../../../request/api' // } from '../../../../request/api'
@ -21,7 +22,7 @@ import type { GetProp, UploadProps } from 'antd';
// // pId: string; // // pId: string;
// } // }
export default function AppCompany(props: any) { export default function AppCompany(props: any) {
// 定义 beforeUpload 函数 // 定义 beforeUpload 函数
const beforeUpload = (file: any) => { const beforeUpload = (file: any) => {
const isJpgOrPng = ['image/jpeg', 'image/png', 'image/bmp'].includes(file.type); const isJpgOrPng = ['image/jpeg', 'image/png', 'image/bmp'].includes(file.type);
@ -34,13 +35,13 @@ export default function AppCompany(props: any) {
} }
return isJpgOrPng && isLt4M; return isJpgOrPng && isLt4M;
}; };
type FileType = Parameters<GetProp<UploadProps, 'beforeUpload'>>[0]; // type FileType = Parameters<GetProp<UploadProps, 'beforeUpload'>>[0];
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const getBase64 = (img: FileType, callback: (url: string) => void) => { // const getBase64 = (img: FileType, callback: (url: string) => void) => {
const reader = new FileReader(); // const reader = new FileReader();
reader.addEventListener('load', () => callback(reader.result as string)); // reader.addEventListener('load', () => callback(reader.result as string));
reader.readAsDataURL(img); // reader.readAsDataURL(img);
}; // };
const [imageUrl, setImageUrl] = useState(''); const [imageUrl, setImageUrl] = useState('');
const handleChange: UploadProps['onChange'] = (info) => { const handleChange: UploadProps['onChange'] = (info) => {
if (info.file.status === 'uploading') { if (info.file.status === 'uploading') {
@ -49,12 +50,18 @@ export default function AppCompany(props: any) {
} }
if (info.file.status === 'done') { if (info.file.status === 'done') {
// Get this url from response in real world. // Get this url from response in real world.
getBase64(info.file.originFileObj as FileType, (url) => { // getBase64(info.file.originFileObj as FileType, (url) => {
setLoading(false); // setLoading(false);
setImageUrl(url); // setImageUrl(url);
}); // });
console.log(info); // console.log(info.file.response.data.fileId);
setLoading(false);
const fileId = info.file.response.data.fileId;
const url = showImage(fileId, false);
setImageUrl(url);
form.setFieldsValue({
img: fileId,
})
} }
if (info.file.status === 'error') { if (info.file.status === 'error') {
setLoading(false); setLoading(false);
@ -66,21 +73,52 @@ export default function AppCompany(props: any) {
}) })
} }
}; };
const[textloading, setTextLoading] = useState(false);
const [textImageUrl, setTextImageUrl] = useState('');
const textHandleChange: UploadProps['onChange'] = (info) => {
if (info.file.status === 'uploading') {
setTextLoading(true);
return;
}
if (info.file.status === 'done') {
// Get this url from response in real world.
// getBase64(info.file.originFileObj as FileType, (url) => {
// setLoading(false);
// setImageUrl(url);
// });
// console.log(info.file.response.data.fileId);
setTextLoading(false);
const fileId = info.file.response.data.fileId;
const url = showImage(fileId, false);
setTextImageUrl(url);
form.setFieldsValue({
textImg: fileId,
})
}
if (info.file.status === 'error') {
setTextLoading(false);
// 显示错误提示
message.error(`上传失败`);
//伤处表单name为ing的值
form.setFieldsValue({
textImg: '', // 将值设置为 undefined 以清除错误状态
})
}
};
// 自定义验证规则 // 自定义验证规则
const validateUpload = () => { // const validateUpload = () => {
if (loading) { // if (loading) {
return Promise.reject(new Error('文件上传中,请等待上传完成')); // return Promise.reject(new Error('文件上传中,请等待上传完成'));
} // }
if (!imageUrl) { // if (!imageUrl) {
return Promise.reject(new Error('请上传有效的文件')); // return Promise.reject(new Error('请上传有效的文件'));
} // }
return Promise.resolve(); // return Promise.resolve();
}; // };
const token = sessionStorage.getItem('token') const token = sessionStorage.getItem('token')
const submitInfo = (values: any) => { const submitInfo = (values: any) => {
message.success('提交成功'); message.success('提交成功');
@ -95,7 +133,7 @@ export default function AppCompany(props: any) {
const handleSubmit = () => { const handleSubmit = () => {
// console.log(form); // console.log(form);
props.setEditProcess(2); // props.setEditProcess(2);
// 调用表单实例的 submit 方法 // 调用表单实例的 submit 方法
form.submit(); form.submit();
@ -108,12 +146,12 @@ export default function AppCompany(props: any) {
}; };
useEffect(() => { useEffect(() => {
// console.log('认证数据',props.companyInfo); // console.log('认证数据',props.companyInfo);
if(props.companyInfo.companyName){ if (props.companyInfo.companyName) {
console.log('嘻嘻'); console.log('嘻嘻');
} }
},[props.companyInfo]) }, [props.companyInfo])
return ( return (
<div className='appInfoBox'> <div className='appInfoBox'>
{/* {contextHolder} */} {/* {contextHolder} */}
@ -134,7 +172,7 @@ export default function AppCompany(props: any) {
// background: 'pink' // background: 'pink'
}}> }}>
<div className='appInfoFormInput'> <div className='appInfoFormInput'>
<div className='FormInputTitle'>/<span style={{color:'red',}}>*</span></div> <div className='FormInputTitle'>/<span style={{ color: 'red', }}>*</span></div>
<Form.Item name="name" label="" rules={[{ required: true, message: '请输入企业/机构名称' }, <Form.Item name="name" label="" rules={[{ required: true, message: '请输入企业/机构名称' },
]}> ]}>
@ -146,10 +184,10 @@ export default function AppCompany(props: any) {
}} placeholder="请输入企业/机构名称" /> }} placeholder="请输入企业/机构名称" />
</Form.Item> </Form.Item>
</div> </div>
<div className='appInfoFormInput'> <div className='appInfoFormInput'>
<div className='FormInputTitle' style={{ <div className='FormInputTitle' style={{
}}><span style={{color:'red',}}>*</span></div> }}><span style={{ color: 'red', }}>*</span></div>
<Form.Item name="type" label="" rules={[{ required: true, message: '请输入证件号' }, <Form.Item name="type" label="" rules={[{ required: true, message: '请输入证件号' },
]}> ]}>
@ -163,7 +201,7 @@ export default function AppCompany(props: any) {
</div> </div>
</div> </div>
<div style={{ <div style={{
display: 'flex', display: 'flex',
justifyContent: 'space-between', justifyContent: 'space-between',
@ -171,15 +209,15 @@ export default function AppCompany(props: any) {
}}> }}>
<div className='appInfoFormInput'> <div className='appInfoFormInput'>
<div className='FormInputTitle' style={{ <div className='FormInputTitle' style={{
}}><span style={{color:'red',}}>*</span></div> }}><span style={{ color: 'red', }}>*</span></div>
<div style={{ <div style={{
// background: 'pink', // background: 'pink',
position: 'relative', position: 'relative',
}}> }}>
<Form.Item name="img" label="" rules={[ <Form.Item name="img" label="" rules={[
// { required: true, message: '请上传文件' }, { required: true, message: '请上传文件' },
// 添加自定义验证规则 // 添加自定义验证规则
{ validator: validateUpload } // { validator: validateUpload }
]}> ]}>
<Upload <Upload
@ -188,12 +226,9 @@ export default function AppCompany(props: any) {
// defaultFileList={upImgArray} // defaultFileList={upImgArray}
beforeUpload={beforeUpload} beforeUpload={beforeUpload}
onChange={handleChange} onChange={handleChange}
onRemove={() => {
// setUpArray([])
// setDisabled(false)
}}
headers={{ 'Auth': `Bearer ${token}` }} headers={{ 'Auth': `Bearer ${token}` }}
disabled={!!imageUrl} // disabled={!!imageUrl}
// beforeUpload={beforeUpload} // beforeUpload={beforeUpload}
> >
{imageUrl ? {imageUrl ?
@ -239,20 +274,20 @@ export default function AppCompany(props: any) {
}} }}
onClick={() => { onClick={() => {
setImageUrl('') setImageUrl('')
form.setFieldsValue({
img: '', // 将值设置为 undefined 以清除错误状态
})
}} }}
></div> ></div>
</div> </div>
</div> </div>
<div className='appInfoFormInput'> <div className='appInfoFormInput'>
<div className='FormInputTitle' style={{ <div className='FormInputTitle' style={{
}}><span style={{color:'red',}}>*</span> }}><span style={{ color: 'red', }}>*</span>
<a style={{ <a style={{
// background:'pink',
textAlign: 'center', textAlign: 'center',
paddingLeft: 23, paddingLeft: 23,
// color: '#4ca8e6',
display: 'block', display: 'block',
// cursor: 'pointer',
}} }}
onClick={() => { onClick={() => {
alert('下载授权书') alert('下载授权书')
@ -260,37 +295,31 @@ export default function AppCompany(props: any) {
></a> ></a>
</div> </div>
<div style={{ <div style={{
// background: 'pink',
position: 'relative', position: 'relative',
}}> }}>
<Form.Item name="img" label="" rules={[ <Form.Item name="textImg" label="" rules={[
// { required: true, message: '请上传文件' }, { required: true, message: '请上传文件' },
// 添加自定义验证规则
{ validator: validateUpload }
]}> ]}>
<Upload <Upload
showUploadList={false} showUploadList={false}
action={uploadFileUrl()} action={uploadFileUrl()}
// defaultFileList={upImgArray}
beforeUpload={beforeUpload} beforeUpload={beforeUpload}
onChange={handleChange} onChange={textHandleChange}
onRemove={() => { onRemove={() => {
// setUpArray([])
// setDisabled(false)
}} }}
headers={{ 'Auth': `Bearer ${token}` }} headers={{ 'Auth': `Bearer ${token}` }}
disabled={!!imageUrl} // disabled={!!imageUrl}
// beforeUpload={beforeUpload}
> >
{imageUrl ? {textImageUrl ?
<div style={{ <div style={{
height: '150px', height: '150px',
width: '300px', width: '300px',
}}> }}>
<Image src={imageUrl} style={{ width: '300px', height: '150px' }} <Image src={textImageUrl} style={{ width: '300px', height: '150px' }}
preview={{ preview={{
mask: '查看', // 设置点击放大时显示的文字 mask: '查看',
}} }}
/> />
@ -302,9 +331,9 @@ export default function AppCompany(props: any) {
borderRadius: '5px', borderRadius: '5px',
color: '#929292', color: '#929292',
}} }}
disabled={loading} disabled={textloading}
> >
{loading ? <span><span style={{ marginRight: 5 }}></span><LoadingOutlined /></span> : {textloading ? <span><span style={{ marginRight: 5 }}></span><LoadingOutlined /></span> :
'点击上传文件' '点击上传文件'
@ -321,10 +350,13 @@ export default function AppCompany(props: any) {
padding: '5px 10px', padding: '5px 10px',
cursor: 'pointer', cursor: 'pointer',
color: 'red', color: 'red',
display: imageUrl ? 'block' : 'none', display: textImageUrl ? 'block' : 'none',
}} }}
onClick={() => { onClick={() => {
setImageUrl('') setTextImageUrl('')
form.setFieldsValue({
textImg: '', // 将值设置为 undefined 以清除错误状态
})
}} }}
></div> ></div>
</div> </div>