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