Commit b78dabe2 authored by GuanHua's avatar GuanHua
parents d75fc513 9ea094b9
import React, { useState } from 'react';
import { PageHeaderWrapper } from "@ant-design/pro-layout";
import ReutrnEle from '@/components/ReturnEle';
// 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, FormEffectHooks } from '@formily/antd'
import { createFormActions, FormButtonGroup, Submit, FormEffectHooks } from '@formily/antd'
import advertisementInfoSchema from './schema/advertisementInfoSchema';
import { Input, Select, Button } from 'antd';
import { Input, Select, Button, Card } from 'antd';
// import CustomUpload from '@/components/NiceForm/components/CustomUpload';
import { useInitialValues } from '../hooks/useInitialValues';
import CustomUpload from '../components/WrapCustomUpload';
import useCustomValidator from '../hooks/useValidator'
import { sortedList, ADVERTISE_WEB_COLUMN_TYPE, ADVERTISE_APP_COLUMN_TYPE} from '../utils/utils';
// import useCustomValidator from '../hooks/useValidator'
import { ADVERTISE_WEB_COLUMN_TYPE, ADVERTISE_APP_COLUMN_TYPE} from '../utils/utils';
import { getManageContentAdvertGet, postManageContentAdvertAdd, postManageContentAdvertUpdate } from '@/services/ManageV2Api';
import NiceForm from '@/components/NiceForm';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
enum ChannelEnum {
WEB = 1,
......@@ -35,8 +36,8 @@ const APP_COLUMN_TYPE = Object.keys(ADVERTISE_APP_COLUMN_TYPE).map((item) => {
const actions = createFormActions();
const { onFieldValueChange$ } = FormEffectHooks;
const AdvertisementInfo = () => {
useCustomValidator()
const AdvertisementInfo: React.FC = () => {
// useCustomValidator()
const { id, preview } = usePageStatus();
const initialValues = useInitialValues({id:id}, getManageContentAdvertGet);
const [submitLoading, setSubmitLoading ] = useState(false);
......@@ -73,16 +74,15 @@ const AdvertisementInfo = () => {
} else {
options = APP_COLUMN_TYPE
}
console.log(options);
actions.setFieldState('columnType', (state) => {
state.props["x-component-props"]["options"] = options;
state.props["enum"] = options;
if(isActive) {
state.value = "";
}
})
})
}
const handleCancel = () => {
history.push('/content/advertisement')
}
......@@ -90,15 +90,15 @@ const AdvertisementInfo = () => {
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
// backIcon={<ReutrnEle description="返回" />}
title={isAdd ? '新建广告' : isEdit ? '编辑广告' : '查看广告'}
>
<Card>
<SchemaForm
<NiceForm
schema={advertisementInfoSchema}
actions={actions}
components={{
Input, Select, Submit, CustomUpload
Select, Submit, CustomUpload
}}
initialValues={initialValues?.data}
onSubmit={handleSubmit}
......@@ -127,7 +127,7 @@ const AdvertisementInfo = () => {
)
: <></>
}
</SchemaForm>
</NiceForm>
<Prompt when={unsaved && (isAdd || isEdit)} message="内容未保存,确定离开?"></Prompt>
</Card>
</PageHeaderWrapper>
......
This diff is collapsed.
......@@ -17,7 +17,6 @@ const schema = {
title: {
type: 'string',
title: '标题',
'x-component': 'Input',
'x-component-props': {
placeholder: '最长60个字符,30个汉字'
},
......@@ -35,13 +34,10 @@ const schema = {
channel: {
title: '投放渠道',
type: 'string',
"x-component": 'Select',
'x-component-props': {
options: [
{ label: 'Web', value: 1 },
{ label: 'App', value: 2 },
],
},
enum: [
{ label: 'Web', value: 1 },
{ label: 'App', value: 2 },
],
"x-rules": [{
"required": true,
"message": "请选择投放渠道"
......@@ -50,10 +46,11 @@ const schema = {
columnType: {
title: '栏目',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: []
},
enum: [],
// 'x-component': 'Select',
// 'x-component-props': {
// options: []
// },
"x-rules": [{
"required": true,
"message": "请选择栏目"
......@@ -62,10 +59,7 @@ const schema = {
sort: {
title: '广告排序',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: sortListOptions
},
enum: sortListOptions,
"x-rules": [{
"required": true,
"message": "请选择广告排序"
......@@ -74,7 +68,6 @@ const schema = {
link: {
title: '跳转链接',
type: 'string',
'x-component': 'Input',
"x-rules": [
{
limitByte: true, // 自定义校验规则
......
import EyePreview from '@/components/EyePreview';
import { DownOutlined } from '@ant-design/icons';
import { TimeList } from '../../statusList';
import moment from 'moment';
import React from 'react';
import {ADVERTISE_WEB_COLUMN_TYPE, ADVERTISE_APP_COLUMN_TYPE} from '../../utils/utils';
const ALL_TYPE = Object.assign({}, ADVERTISE_WEB_COLUMN_TYPE, ADVERTISE_APP_COLUMN_TYPE);
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { ISchema } from '@formily/antd';
const CustomTimeList = [{label: '全部', value: 0}].concat(TimeList.slice(1));
const columns = [
{title: 'ID', dataIndex: 'id'},
{ title: '标题',
dataIndex: 'title',
render: (text: string, record: any) => (
<EyePreview
url={`/content/advertisement/detail?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{
title: '栏目', dataIndex: 'columnType',
render: (text, record) => {
return (
<div>{ALL_TYPE[text]}</div>
)
},
},
{
title: '发布时间',
dataIndex: 'createTime',
render: (text) => (
moment(text).format('YYYY-MM-DD HH:mm:ss')
)
},
{title: '状态', dataIndex: 'status', render: "{{renderStatus}}"},
{title: '操作', render: "{{renderOperation}}"}
];
/**
* 广告管理列表也 schemat
*/
const advertisementSchema = {
type: 'object',
properties: {
layout: {
type: 'object',
// 'x-component': 'mega-layout',
'x-component': 'CustomFlexRowLayout',
'x-component-props': {
justify: 'space-between',
align: 'center'
},
properties: {
'left-layout': {
export const schema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
properties: {
topLayout: {
type: 'object',
name: 'left-layout',
'x-component': 'CustomFlexRowLayout',
'x-component': 'Mega-Layout',
'x-component-props': {
justify: 'start',
align: 'center'
grid: true,
},
properties: {
createBtn: {
type: "object",
name: "createBtn",
"x-component": "button",
"x-component-props": {
"onClick": "{{goToCreate}}",
"children": "新建",
"type": 'primary',
style: {
width: '112px',
margin: '0 0 15px 0'
}
}
ctl: {
type: 'object',
// 'x-component': 'Children',
// 'x-component-props': {
// children: '{{controllerBtns}}',
// },
"x-component": 'ControllerBtns'
},
}
title: {
type: 'string',
'x-component': 'Search',
'x-component-props': {
placeholder: '标题',
},
},
},
},
'right-layout': {
type: 'object',
name: 'rigth-layout',
"x-component": 'CustomFlexColumnLayout',
properties: {
controllers: {
type: 'object',
name: 'controllers',
'x-component': 'CustomFlexRowLayout',
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
colStyle: {
marginLeft: 20,
},
},
properties: {
status: {
type: 'string',
enum: [
{label: '全部', value: '0'},
{label: '待上架', value: '1'},
{label: '已上架',value: '2'},
{label: '已下架',value: '3'},
],
'x-component-props': {
justify: 'end',
placeholder: '状态',
allowClear: true,
},
properties: {
search: {
type: 'string',
name: 'name',
'x-component': 'CustomSearch',
'x-component-props': {
placeholder: "请填写标题名称",
"onSearch": "{{search}}",
}
},
'HIGHT_FILTER_BTN': {
type: 'string',
name: 'HIGHT_FILTER_BTN',
'x-component': 'button',
'x-component-props': {
"children": (
<div>高级搜索 <DownOutlined /></div>
),
"onClick": "{{toggleFilters}}",
style: {
margin: '0 15px'
}
}
},
reset: {
type: 'string',
name: 'reset',
"x-component": "button",
"x-component-props": {
"onClick": "{{reset}}",
"children": "重置",
}
},
}
},
'FILTERS': {
type: 'object',
name: 'FILTERS',
'x-component': 'CustomFlexRowLayout',
"[startTime, endTime]": {
type: 'daterange',
'x-component-props': {
placeholder: ["发布开始时间", "发布结束时间"],
allowClear: true,
},
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
justify: 'end'
children: '查询',
},
properties: {
status: {
name: 'status',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: [
{label: '状态(全部)', value: '0'},
{label: '待上架', value: '1'},
{label: '已上架',value: '2'},
{label: '已下架',value: '3'},
],
defaultValue: '0',
placeholder: '请选择状态',
style: {
width: '160px',
margin: '0 15px'
}
}
},
time: {
name: 'time',
type: 'string',
'x-component': 'Select',
'x-component-props': {
placeholder: '发布时间(全部)',
options: CustomTimeList,
style: {
width: '160px',
}
}
}
}
}
}
}
}
},
"table": {
"key": "table",
"type": "object",
"name": "table",
"x-component": "Table",
"x-component-props": {
"columns": columns,
"rowKey": "id",
pagination: false,
}
},
},
},
},
},
},
};
pagination: {
type: 'object',
'x-component': "TablePagination",
'x-style': {
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-end'
},
'x-component-props': {
showQuickJumper: true,
pageSize: 10,
size: 'small'
}
}
}
}
export default advertisementSchema
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