Browse Source

deploy

master
Soleilw 4 months ago
parent
commit
833d0b4276

+ 1
- 0
dist/339.486c3be2.async.js
File diff suppressed because it is too large
View File


+ 0
- 1
dist/7.7990c9ae.async.js
File diff suppressed because it is too large
View File


+ 1
- 1
dist/index.html View File

</head> </head>
<body> <body>
<div id="root"></div> <div id="root"></div>
<script src="/umi.1071646d.js"></script>
<script src="/umi.745f16d0.js"></script>
</body> </body>
</html> </html>

+ 0
- 1
dist/p__Information__Article__index.4e01b61f.async.js
File diff suppressed because it is too large
View File


+ 1
- 0
dist/p__Information__Article__index.916cbde7.async.js
File diff suppressed because it is too large
View File


dist/umi.745f16d0.js
File diff suppressed because it is too large
View File


+ 14
- 11
src/apis/types/information.d.ts View File



declare namespace InformationType { declare namespace InformationType {
type section = {
id ?: Number,
name ?: String,
cover_img ?: String,
parent_id ?: Number,
description ?: String,
display ?: Number
}
type section = {
id?: Number,
name?: String,
cover_img?: String,
parent_id?: Number,
description?: String,
display?: Number
}


type article = {
id ?: Number,
type article = {
id?: Number,
title?: String, title?: String,
cover_img?: String, cover_img?: String,
doc_url?: String, doc_url?: String,
stick_top?: Number, stick_top?: Number,
hot?: Number, hot?: Number,
author?: String author?: String
}

// 其他参数
section_arr?: number[]
}
} }

+ 37
- 6
src/components/Render/Main/Information/Article/create/index.tsx View File

ProForm, ProForm,
FormControlRender, FormControlRender,
ProFormDependency, ProFormDependency,
ProFormSwitch
ProFormSwitch,
ProFormCascader
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { ConfigProvider, Flex, Space, Modal, message, Image, Row, Col, Switch, Form, Typography } from 'antd'; import { ConfigProvider, Flex, Space, Modal, message, Image, Row, Col, Switch, Form, Typography } from 'antd';
import { addArticle, updateArticle, listSection, GetArticleDetail } from '@/apis/api'; import { addArticle, updateArticle, listSection, GetArticleDetail } from '@/apis/api';
import DragUpload from '@/components/Common/dragupload'; import DragUpload from '@/components/Common/dragupload';
import RichComponent from '@/components/Common/rich'; import RichComponent from '@/components/Common/rich';


const selectfieldNames = { label: 'name', value: 'id' };

import { isArrayOfType } from '@/utils/dataHelper';




const selectfieldNames = { label: 'name', value: 'id' };
const cascaderfieldNames = { label: 'name', value: 'id', children: 'childs' };

const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, openModel, id }: any) => { const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, openModel, id }: any) => {
const formRef = useRef<ProFormInstance>(); const formRef = useRef<ProFormInstance>();
const [openPreview, setOpenPreview] = useState(false); const [openPreview, setOpenPreview] = useState(false);
if (id) { if (id) {
let res = await GetArticleDetail({ id: id }) let res = await GetArticleDetail({ id: id })
setUploadedFilephotoName(res.data.cover_img) setUploadedFilephotoName(res.data.cover_img)
res.data.section_arr = [res.data.section_name]
setDetail(res.data) setDetail(res.data)
return res.data; return res.data;
} else { } else {
}} }}
onFinish={async (values) => { onFinish={async (values) => {
values.cover_img = uploadedFilephotoName ? uploadedFilephotoName : ''; values.cover_img = uploadedFilephotoName ? uploadedFilephotoName : '';
console.log(values)
if (id) { if (id) {
values.id = id; values.id = id;
// 判断是字符串数组还是数字数组
if (isArrayOfType(values.section_arr, 'string')) {
// 是字符串
values.section_id = detail?.section_id
} else {
values.section_id = values.section_arr.length > 0 ? values.section_arr[values.section_arr.length - 1] : 0;
delete values.section_arr;
}
let res = await updateArticle(values) let res = await updateArticle(values)
message.success('提交成功') message.success('提交成功')
dispatch({ type: 'openModel/getOpenModal', payload: false }) dispatch({ type: 'openModel/getOpenModal', payload: false })
} else { } else {
values.section_id = values.section_arr.length > 0 ? values.section_arr[values.section_arr.length - 1] : 0;
delete values.section_arr;
let res = await addArticle(values) let res = await addArticle(values)
message.success('提交成功') message.success('提交成功')
dispatch({ type: 'openModel/getOpenModal', payload: false }) dispatch({ type: 'openModel/getOpenModal', payload: false })
/> />


<Row gutter={[16, 16]}> <Row gutter={[16, 16]}>
{
{
detail ? detail ?
<Col span={24} style={{ display: 'flex' }}> <Col span={24} style={{ display: 'flex' }}>
<UploadModel multiple={false} form_name="cover_img" image_length={1} uploadTxt="上传封面图" image_type={3} onUploadComplete={handleFileUploadedphoto}></UploadModel> <UploadModel multiple={false} form_name="cover_img" image_length={1} uploadTxt="上传封面图" image_type={3} onUploadComplete={handleFileUploadedphoto}></UploadModel>
</> </>
} }


<ProFormSelect
<ProFormCascader
label="栏目/频道"
name="section_arr"
fieldProps={{
fieldNames: cascaderfieldNames,
changeOnSelect: true
}}
placeholder="请选择栏目/频道"
request={(keyword) =>
listSection({ page: 1, pagesize: 100, keyword: keyword.keyWords }).then(res => {
return res.data.sections;
})
}
/>

{/* <ProFormSelect
showSearch showSearch
name="section_id" name="section_id"
label="栏目/频道" label="栏目/频道"
return res.data.sections; return res.data.sections;
}) })
} }
/>
/> */}
<Row gutter={[16, 16]}> <Row gutter={[16, 16]}>
<Col span={24}> <Col span={24}>
<Form.Item <Form.Item

+ 5
- 0
src/utils/dataHelper.ts View File

let result = false; let result = false;
result = array.includes(id); result = array.includes(id);
return result; return result;
}

// 判断是字符串数组还是number数组
export const isArrayOfType = (arr: [], type: 'string' | 'number'): boolean => {
return arr.every(item => typeof item === type);
} }

Loading…
Cancel
Save