Ver código fonte

deploy

master
Soleilw 4 meses atrás
pai
commit
833d0b4276

+ 1
- 0
dist/339.486c3be2.async.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 0
- 1
dist/7.7990c9ae.async.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 1
- 1
dist/index.html Ver arquivo

@@ -8,6 +8,6 @@
</head>
<body>
<div id="root"></div>
<script src="/umi.1071646d.js"></script>
<script src="/umi.745f16d0.js"></script>
</body>
</html>

+ 0
- 1
dist/p__Information__Article__index.4e01b61f.async.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 1
- 0
dist/p__Information__Article__index.916cbde7.async.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


dist/umi.745f16d0.js
Diferenças do arquivo suprimidas por serem muito extensas
Ver arquivo


+ 14
- 11
src/apis/types/information.d.ts Ver arquivo

@@ -1,16 +1,16 @@

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,
cover_img?: String,
doc_url?: String,
@@ -19,5 +19,8 @@ declare namespace InformationType {
stick_top?: Number,
hot?: Number,
author?: String
}

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

+ 37
- 6
src/components/Render/Main/Information/Article/create/index.tsx Ver arquivo

@@ -9,7 +9,8 @@ import {
ProForm,
FormControlRender,
ProFormDependency,
ProFormSwitch
ProFormSwitch,
ProFormCascader
} from '@ant-design/pro-components';
import { ConfigProvider, Flex, Space, Modal, message, Image, Row, Col, Switch, Form, Typography } from 'antd';
import { addArticle, updateArticle, listSection, GetArticleDetail } from '@/apis/api';
@@ -18,9 +19,13 @@ import UploadModel from '@/components/Common/upload';
import DragUpload from '@/components/Common/dragupload';
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 formRef = useRef<ProFormInstance>();
const [openPreview, setOpenPreview] = useState(false);
@@ -68,6 +73,7 @@ const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, open
if (id) {
let res = await GetArticleDetail({ id: id })
setUploadedFilephotoName(res.data.cover_img)
res.data.section_arr = [res.data.section_name]
setDetail(res.data)
return res.data;
} else {
@@ -98,13 +104,23 @@ const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, open
}}
onFinish={async (values) => {
values.cover_img = uploadedFilephotoName ? uploadedFilephotoName : '';
console.log(values)
if (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)
message.success('提交成功')
dispatch({ type: 'openModel/getOpenModal', payload: false })
} 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)
message.success('提交成功')
dispatch({ type: 'openModel/getOpenModal', payload: false })
@@ -119,7 +135,7 @@ const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, open
/>

<Row gutter={[16, 16]}>
{
{
detail ?
<Col span={24} style={{ display: 'flex' }}>
<UploadModel multiple={false} form_name="cover_img" image_length={1} uploadTxt="上传封面图" image_type={3} onUploadComplete={handleFileUploadedphoto}></UploadModel>
@@ -147,7 +163,22 @@ const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, open
</>
}

<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
name="section_id"
label="栏目/频道"
@@ -160,7 +191,7 @@ const PagesMainInformationArticleCreate: React.FC = ({ dispatch, dictModel, open
return res.data.sections;
})
}
/>
/> */}
<Row gutter={[16, 16]}>
<Col span={24}>
<Form.Item

+ 5
- 0
src/utils/dataHelper.ts Ver arquivo

@@ -2,4 +2,9 @@ export const findId = (array: [], id: number) => {
let result = false;
result = array.includes(id);
return result;
}

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

Carregando…
Cancelar
Salvar