Commit c7dc455e authored by 前端-钟卫鹏's avatar 前端-钟卫鹏
parents 1785684f f942d16d
...@@ -3,10 +3,10 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout"; ...@@ -3,10 +3,10 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi'; import { history, Prompt } from 'umi';
import { Card } from 'antd'; import { Card, Modal } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, Submit, Reset } from '@formily/antd' import { SchemaForm, createFormActions, FormButtonGroup, Submit, Reset } from '@formily/antd'
import advertisementInfoSchema from './schema/advertisementInfoSchema'; import advertisementInfoSchema from './schema/advertisementInfoSchema';
import { Input, Select } from 'antd'; import { Input, Select, Button } from 'antd';
// import CustomUpload from '@/components/NiceForm/components/CustomUpload'; // import CustomUpload from '@/components/NiceForm/components/CustomUpload';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { useInitialValues } from '../hooks/useInitialValues'; import { useInitialValues } from '../hooks/useInitialValues';
...@@ -20,6 +20,7 @@ const AdvertisementInfo = () => { ...@@ -20,6 +20,7 @@ const AdvertisementInfo = () => {
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const initialValues = useInitialValues({id:id}, PublicApi.getManageContentAdvertGet); const initialValues = useInitialValues({id:id}, PublicApi.getManageContentAdvertGet);
const [submitLoading, setSubmitLoading ] = useState(false); const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
const isView = id && preview; const isView = id && preview;
...@@ -33,7 +34,8 @@ const AdvertisementInfo = () => { ...@@ -33,7 +34,8 @@ const AdvertisementInfo = () => {
let tempData = value; let tempData = value;
const postData = isAdd ? tempData : {...tempData, id}; const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true) setSubmitLoading(true);
setUnsaved(false);
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -42,6 +44,10 @@ const AdvertisementInfo = () => { ...@@ -42,6 +44,10 @@ const AdvertisementInfo = () => {
}) })
} }
const handleCancel = () => {
history.push('/content/advertisement')
}
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
...@@ -76,12 +82,13 @@ const AdvertisementInfo = () => { ...@@ -76,12 +82,13 @@ const AdvertisementInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
<Prompt when={unsaved} message="内容未保存,确定离开?"></Prompt>
</Card> </Card>
</PageHeaderWrapper> </PageHeaderWrapper>
) )
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable'; import { FilterTable } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Popconfirm } from 'antd'; import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Popconfirm, Modal } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd'; import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi'; import { history, Link } from 'umi';
import { DownOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, UpOutlined } from '@ant-design/icons';
...@@ -75,11 +75,17 @@ const Advertisement = () => { ...@@ -75,11 +75,17 @@ const Advertisement = () => {
} }
const handleDelete = (id) => { const handleDelete = (id) => {
PublicApi.postManageContentAdvertDelete({id: id}) Modal.confirm({
.then((data) => { title: '确定要执行这个操作吗',
const paginationValue = actions.getFieldValue('pagination'); onOk: () => {
handleSearch({...paginationValue}) PublicApi.postManageContentAdvertDelete({id: id})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
})
},
}) })
} }
// 修改状态 // 修改状态
......
...@@ -3,8 +3,8 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout"; ...@@ -3,8 +3,8 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi'; import { history, Prompt } from 'umi';
import { Card } from 'antd'; import { Card, Button } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, Submit, Reset } from '@formily/antd' import { SchemaForm, createFormActions, FormButtonGroup, Submit } from '@formily/antd'
import announceInfoSchema from './schema/announceInfoSchema'; import announceInfoSchema from './schema/announceInfoSchema';
import { Input, Select } from 'antd'; import { Input, Select } from 'antd';
import CustomUpload from '@/components/NiceForm/components/CustomUpload'; import CustomUpload from '@/components/NiceForm/components/CustomUpload';
...@@ -23,6 +23,7 @@ const AdvertisementInfo = () => { ...@@ -23,6 +23,7 @@ const AdvertisementInfo = () => {
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const initialValues: any = useInitialValues({id:id}, PublicApi.getManageContentNoticeGet); const initialValues: any = useInitialValues({id:id}, PublicApi.getManageContentNoticeGet);
const [submitLoading, setSubmitLoading ] = useState(false); const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
const isView = id && preview; const isView = id && preview;
...@@ -49,6 +50,7 @@ const AdvertisementInfo = () => { ...@@ -49,6 +50,7 @@ const AdvertisementInfo = () => {
let tempData = {...rest, content: editorContent, top: top ? 1 : 0}; let tempData = {...rest, content: editorContent, top: top ? 1 : 0};
const postData = isAdd ? tempData : {...tempData, id}; const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true) setSubmitLoading(true)
setUnsaved(false)
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -57,6 +59,10 @@ const AdvertisementInfo = () => { ...@@ -57,6 +59,10 @@ const AdvertisementInfo = () => {
}) })
} }
const handleCancel = () => {
history.push('/content/announcements')
}
return ( return (
<PageHeaderWrapper <PageHeaderWrapper
onBack={() => history.goBack()} onBack={() => history.goBack()}
...@@ -91,12 +97,13 @@ const AdvertisementInfo = () => { ...@@ -91,12 +97,13 @@ const AdvertisementInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?"></Prompt>
</Card> </Card>
</PageHeaderWrapper> </PageHeaderWrapper>
) )
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable'; import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Popconfirm } from 'antd'; import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Popconfirm, Modal } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd'; import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi'; import { history, Link } from 'umi';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
...@@ -48,8 +48,8 @@ const Announcements = () => { ...@@ -48,8 +48,8 @@ const Announcements = () => {
onFieldValueChange$('time'), onFieldValueChange$('time'),
).subscribe( ).subscribe(
fieldState => { fieldState => {
// 这里有个bug, 当FILTER 收起就不行了
if(fieldState.value) { if(fieldState.active && fieldState.value != null) {
handleSearch({}) handleSearch({})
} }
} }
...@@ -71,8 +71,8 @@ const Announcements = () => { ...@@ -71,8 +71,8 @@ const Announcements = () => {
title: title || '', title: title || '',
columnType: columnType != 0 ? columnType : '', columnType: columnType != 0 ? columnType : '',
status: status != 0 ? status : '', status: status != 0 ? status : '',
startTime: st, startTime: st && st * 1000,
endTime: et, endTime: et && et * 1000,
current: 1, current: 1,
pageSize: 10, pageSize: 10,
...params ...params
...@@ -81,11 +81,17 @@ const Announcements = () => { ...@@ -81,11 +81,17 @@ const Announcements = () => {
} }
const handleDelete = (id) => { const handleDelete = (id) => {
PublicApi.postManageContentNoticeDelete({id: id}) Modal.confirm({
.then((data) => { title: '确定要执行这个操作?',
const paginationValue = actions.getFieldValue('pagination'); onOk: () => {
handleSearch({...paginationValue}) PublicApi.postManageContentNoticeDelete({id: id})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
})
}
}) })
} }
// 修改状态 // 修改状态
......
...@@ -91,6 +91,7 @@ const ColumnInfo = () => { ...@@ -91,6 +91,7 @@ const ColumnInfo = () => {
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const [ submitLoading, setSubmitLoading ] = useState(false); const [ submitLoading, setSubmitLoading ] = useState(false);
const initialValues = useInitialValues(id); const initialValues = useInitialValues(id);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
...@@ -102,6 +103,7 @@ const ColumnInfo = () => { ...@@ -102,6 +103,7 @@ const ColumnInfo = () => {
const postData = {id, name, sort}; const postData = {id, name, sort};
setSubmitLoading(true) setSubmitLoading(true)
setUnsaved(false)
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -110,6 +112,10 @@ const ColumnInfo = () => { ...@@ -110,6 +112,10 @@ const ColumnInfo = () => {
}) })
} }
const handleCancel = () => {
history.push('/content/columnsManagement')
}
return ( return (
<div> <div>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -130,7 +136,7 @@ const ColumnInfo = () => { ...@@ -130,7 +136,7 @@ const ColumnInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
...@@ -139,7 +145,7 @@ const ColumnInfo = () => { ...@@ -139,7 +145,7 @@ const ColumnInfo = () => {
</SchemaForm> </SchemaForm>
</Card> </Card>
</PageHeaderWrapper> </PageHeaderWrapper>
{/* <Prompt when={true} message="您还有未保存的内容,是否确定要离开?" /> */} <Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</div> </div>
) )
} }
......
...@@ -7,9 +7,16 @@ import BraftEditor from 'braft-editor'; ...@@ -7,9 +7,16 @@ import BraftEditor from 'braft-editor';
const CustomEditor = (props) => { const CustomEditor = (props) => {
const editorProps = props.props['x-component-props']; const editorProps = props.props['x-component-props'];
const parentProps = props.props['x-component-parent-props']; const parentProps = props.props['x-component-parent-props'];
const handleChange = (editorState) => {
const isEmpty = editorState.isEmpty();
const value = isEmpty ? null : editorState
props.mutators.change(value)
}
return ( return (
<div {...parentProps}> <div {...parentProps}>
<BraftEditor {...editorProps} value={props.value || ''} onChange={(editorState) => props.mutators.change(editorState)}/> <BraftEditor {...editorProps} value={props.value || ''} onChange={handleChange}/>
</div> </div>
) )
} }
......
...@@ -18,9 +18,13 @@ const useCustomValidator = () => { ...@@ -18,9 +18,13 @@ const useCustomValidator = () => {
return str.length > maxByte ? message : ""; return str.length > maxByte ? message : "";
}, },
isInteger: (value, des, rules) => { isInteger: (value, des, rules) => {
if(typeof value == 'undefined' || value == '') {
return ''
}
const isNumber = /^\d+$/;
const message = des ? "只允许填写正整数" : des const message = des ? "只允许填写正整数" : des
const pattern = /[0-9]+\.[0-9]*/; const pattern = /[0-9]+\.[0-9]*/;
return pattern.test(value) ? message : "" return !isNumber.test(value) || pattern.test(value) ? message : ""
} }
}); });
......
...@@ -3,7 +3,7 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout"; ...@@ -3,7 +3,7 @@ import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
import { history, Prompt } from 'umi'; import { history, Prompt } from 'umi';
import { Card } from 'antd'; import { Card, Button } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, FormEffectHooks, Submit, Reset } from '@formily/antd' import { SchemaForm, createFormActions, FormButtonGroup, FormEffectHooks, Submit, Reset } from '@formily/antd'
import imageInfoSchema from './schema/imageInfoSchema'; import imageInfoSchema from './schema/imageInfoSchema';
import { Input, Select } from 'antd'; import { Input, Select } from 'antd';
...@@ -24,6 +24,7 @@ const ImageInfo = () => { ...@@ -24,6 +24,7 @@ const ImageInfo = () => {
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
const initialValues: any = useInitialValues({id:id}, PublicApi.getManageContentImageGet); const initialValues: any = useInitialValues({id:id}, PublicApi.getManageContentImageGet);
const [submitLoading, setSubmitLoading ] = useState(false); const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
const isView = id && preview; const isView = id && preview;
...@@ -36,6 +37,7 @@ const ImageInfo = () => { ...@@ -36,6 +37,7 @@ const ImageInfo = () => {
let tempData = value; let tempData = value;
const postData = isAdd ? tempData : {...tempData, id}; const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true) setSubmitLoading(true)
setUnsaved(false)
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -44,15 +46,23 @@ const ImageInfo = () => { ...@@ -44,15 +46,23 @@ const ImageInfo = () => {
}) })
} }
const handleCancel = () => {
history.push('/content/imagesManagement')
}
const ImageInfoEffects = () => () => { const ImageInfoEffects = () => () => {
onFieldValueChange$('layout.useScene').subscribe((state) => { onFieldValueChange$('layout.useScene').subscribe((state) => {
actions.setFieldValue('layout.position', "")
setFormStatus( if(state.initialValue != state.value) {
actions, actions.setFieldValue('layout.position', null)
'layout.position', setFormStatus(
'options', actions,
state.value == 1 ? WEB_OPTION : APP_OPTION 'layout.position',
) 'options',
state.value == 1 ? WEB_OPTION : APP_OPTION
)
}
}) })
} }
...@@ -91,13 +101,14 @@ const ImageInfo = () => { ...@@ -91,13 +101,14 @@ const ImageInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
</Card> </Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper> </PageHeaderWrapper>
) )
} }
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable'; import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Select, Space, Popconfirm } from 'antd'; import { Card, Input, Button, Table, Dropdown, Select, Space, Popconfirm } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks } from '@formily/antd'; import { createVirtualBox, createFormActions, FormEffectHooks } from '@formily/antd';
import { history, Link } from 'umi'; import { history, Link } from 'umi';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable'; import { FilterTable, SchemaFlexRowLayout, SchemaFlexColumnLayout } from '../components/FilterTable';
import { Card, Input, Button, Table, Dropdown, Menu, Select, Space } from 'antd'; import { Card, Input, Button, Table, Dropdown, Menu, Select, Space, Modal, Popconfirm } from 'antd';
import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd'; import { createVirtualBox, createFormActions, FormEffectHooks, createEffectHook } from '@formily/antd';
import { history, Link } from 'umi'; import { history, Link } from 'umi';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
...@@ -76,7 +76,7 @@ const Infomation = () => { ...@@ -76,7 +76,7 @@ const Infomation = () => {
onFieldValueChange$('status'), onFieldValueChange$('status'),
onFieldValueChange$('time') onFieldValueChange$('time')
).subscribe((state) => { ).subscribe((state) => {
if(state.value != null) { if(state.active && state.value != null) {
handleSearch({}) handleSearch({})
} }
}) })
...@@ -131,10 +131,15 @@ const Infomation = () => { ...@@ -131,10 +131,15 @@ const Infomation = () => {
} }
const handleDelete = (id) => { const handleDelete = (id) => {
PublicApi.postManageContentInformationDelete({id: id}) Modal.confirm({
.then((data) => { title: '确定要执行这个操作?',
const paginationValue = actions.getFieldValue('pagination'); onOk: () => {
handleSearch({...paginationValue}) PublicApi.postManageContentInformationDelete({id: id})
.then((data) => {
const paginationValue = actions.getFieldValue('pagination');
handleSearch({...paginationValue})
})
}
}) })
} }
// 重设页码 // 重设页码
...@@ -197,9 +202,15 @@ const Infomation = () => { ...@@ -197,9 +202,15 @@ const Infomation = () => {
return ( return (
<Space> <Space>
{/* 这里反向操作, 上架的对应的是下架, 待上架,下架对应的是上架 */} {/* 这里反向操作, 上架的对应的是下架, 待上架,下架对应的是上架 */}
<a onClick={() => handleUpdateState(record.id, status[record.status] == '上架' ? 2 : 3)}> <Popconfirm
{status[record.status]} title="确定要执行这个操作吗"
</a> onConfirm={() => handleUpdateState(record.id, status[record.status] == '上架' ? 2 : 3)}
okText="是"
cancelText="否"
>
<a href="#">{status[record.status]}</a>
</Popconfirm>
{ {
CAN_MODIFY.includes(record.status) CAN_MODIFY.includes(record.status)
? <Dropdown overlay={menu}> ? <Dropdown overlay={menu}>
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { SchemaForm,Submit, FormButtonGroup, Reset, createFormActions, registerValidationRules } from '@formily/antd'; import { SchemaForm,Submit, FormButtonGroup, Reset, createFormActions, registerValidationRules } from '@formily/antd';
import { Card, Select, Input, Checkbox, InputNumber} from 'antd'; import { Card, Select, Input, Checkbox, Button} from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import ReutrnEle from '@/components/ReturnEle'; import ReutrnEle from '@/components/ReturnEle';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
...@@ -25,7 +25,7 @@ const InfomationInfo = () => { ...@@ -25,7 +25,7 @@ const InfomationInfo = () => {
const [isTop, setIsTop] = useState(1); const [isTop, setIsTop] = useState(1);
const [labelIds, setLabelIds] = useState<number[]>([]); const [labelIds, setLabelIds] = useState<number[]>([]);
const [submitLoading, setSubmitLoading ] = useState(false); const [submitLoading, setSubmitLoading ] = useState(false);
const [unsaved, setUnsaved] = useState(true);
const initialValues = useInitialValues({id:id}, PublicApi.getManageContentInformationGet); const initialValues = useInitialValues({id:id}, PublicApi.getManageContentInformationGet);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
...@@ -86,6 +86,7 @@ const InfomationInfo = () => { ...@@ -86,6 +86,7 @@ const InfomationInfo = () => {
const postData = isAdd ? tempPostData : {...tempPostData, id: id}; const postData = isAdd ? tempPostData : {...tempPostData, id: id};
console.log("postData", postData); console.log("postData", postData);
setSubmitLoading(true) setSubmitLoading(true)
setUnsaved(false)
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -94,6 +95,10 @@ const InfomationInfo = () => { ...@@ -94,6 +95,10 @@ const InfomationInfo = () => {
}) })
} }
const handleCancel = () => {
history.push('/content/infomations')
}
return ( return (
<div> <div>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -112,7 +117,6 @@ const InfomationInfo = () => { ...@@ -112,7 +117,6 @@ const InfomationInfo = () => {
Input, Select, Submit, Input, Select, Submit,
TextArea, Checkbox, TextArea, Checkbox,
CustomUpload, CustomTags, CustomEditor, CustomUpload, CustomTags, CustomEditor,
InputNumber
}} }}
expressionScope={{ expressionScope={{
isTop: ( isTop: (
...@@ -144,13 +148,14 @@ const InfomationInfo = () => { ...@@ -144,13 +148,14 @@ const InfomationInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
</Card> </Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper> </PageHeaderWrapper>
</div> </div>
) )
......
...@@ -62,6 +62,7 @@ const schema = { ...@@ -62,6 +62,7 @@ const schema = {
type: 'string', type: 'string',
'x-component': 'Select', 'x-component': 'Select',
"x-component-props": { "x-component-props": {
allowClear: true,
options: [ options: [
{label: '头条文章', value: 1}, {label: '头条文章', value: 1},
{label: '轮播新闻', value: 2}, {label: '轮播新闻', value: 2},
...@@ -93,7 +94,9 @@ const schema = { ...@@ -93,7 +94,9 @@ const schema = {
style: { style: {
width: '98%' width: '98%'
}, },
options: sortedList options: sortedList,
allowClear: true,
} }
}, },
} }
...@@ -102,7 +105,7 @@ const schema = { ...@@ -102,7 +105,7 @@ const schema = {
name: 'readCount', name: 'readCount',
title: '浏览数', title: '浏览数',
type: 'string', type: 'string',
'x-component': 'InputNumber', 'x-component': 'Input',
'x-component-props': { 'x-component-props': {
style: { style: {
width: '100%' width: '100%'
......
...@@ -67,6 +67,7 @@ const TagInfo = () => { ...@@ -67,6 +67,7 @@ const TagInfo = () => {
const initialValues = useInitialValues({id:id}, PublicApi.getManageContentLabelGet); const initialValues = useInitialValues({id:id}, PublicApi.getManageContentLabelGet);
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
const [unsaved, setUnsaved] = useState(true);
const handleSubmit = (value) => { const handleSubmit = (value) => {
console.log(value) console.log(value)
const { id, name, explain} = value; const { id, name, explain} = value;
...@@ -77,6 +78,7 @@ const TagInfo = () => { ...@@ -77,6 +78,7 @@ const TagInfo = () => {
let tempData = {name, explain}; let tempData = {name, explain};
const postData = isAdd ? {...tempData, id: 0} : {...tempData, id}; const postData = isAdd ? {...tempData, id: 0} : {...tempData, id};
setSubmitLoading(true) setSubmitLoading(true)
setUnsaved(false);
serviceActions(postData).then((data) => { serviceActions(postData).then((data) => {
setSubmitLoading(false); setSubmitLoading(false);
if(data.code === 1000) { if(data.code === 1000) {
...@@ -84,6 +86,10 @@ const TagInfo = () => { ...@@ -84,6 +86,10 @@ const TagInfo = () => {
} }
}) })
} }
const handleCancel = () => {
history.push('/content/tagsManagement')
}
return ( return (
<div> <div>
<PageHeaderWrapper <PageHeaderWrapper
...@@ -104,13 +110,14 @@ const TagInfo = () => { ...@@ -104,13 +110,14 @@ const TagInfo = () => {
? ( ? (
<FormButtonGroup offset={3}> <FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit> <Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset> <Button onClick={handleCancel}>取消</Button>
</FormButtonGroup> </FormButtonGroup>
) )
: <></> : <></>
} }
</SchemaForm> </SchemaForm>
</Card> </Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper> </PageHeaderWrapper>
</div> </div>
) )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment