Commit 4febc025 authored by Bill's avatar Bill

内容管理-广告管理添加 投放渠道字段

parent 492b2cb3
......@@ -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, Modal } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, Submit, Reset } from '@formily/antd'
import { Card } from 'antd';
import { SchemaForm, createFormActions, FormButtonGroup, Submit, FormEffectHooks } from '@formily/antd'
import advertisementInfoSchema from './schema/advertisementInfoSchema';
import { Input, Select, Button } from 'antd';
// import CustomUpload from '@/components/NiceForm/components/CustomUpload';
......@@ -12,8 +12,28 @@ import { PublicApi } from '@/services/api';
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';
enum ChannelEnum {
WEB = 1,
APP = 2,
}
const WEB_COLUMN_TYPE = Object.keys(ADVERTISE_WEB_COLUMN_TYPE).map((item) => {
return {
label: ADVERTISE_WEB_COLUMN_TYPE[item],
value: parseInt(item)
}
})
const APP_COLUMN_TYPE = Object.keys(ADVERTISE_APP_COLUMN_TYPE).map((item) => {
return {
label: ADVERTISE_APP_COLUMN_TYPE[item],
value: parseInt(item)
}
})
const actions = createFormActions();
const { onFieldValueChange$ } = FormEffectHooks;
const AdvertisementInfo = () => {
useCustomValidator()
......@@ -24,14 +44,14 @@ const AdvertisementInfo = () => {
const isEdit = id && !preview;
const isAdd = !id && !preview;
const isView = id && preview;
const handleSubmit = (value) => {
console.log(value)
// const { title, columnType, sort, link, imageUrl} = value;
const serviceActions = isAdd
? PublicApi.postManageContentAdvertAdd
: PublicApi.postManageContentAdvertUpdate
let tempData = value;
const postData = isAdd ? tempData : {...tempData, id};
setSubmitLoading(true);
......@@ -44,6 +64,25 @@ const AdvertisementInfo = () => {
})
}
const formEffects = () => () => {
onFieldValueChange$('channel').subscribe(fieldState => {
const isActive = fieldState.active;
let options: {label: string, value: number| string}[] = []
if(fieldState.value === ChannelEnum.WEB) {
options = WEB_COLUMN_TYPE
} else {
options = APP_COLUMN_TYPE
}
actions.setFieldState('columnType', (state) => {
state.props["x-component-props"]["options"] = options;
if(isActive) {
state.value = "";
}
})
})
}
const handleCancel = () => {
history.push('/content/advertisement')
}
......@@ -64,11 +103,12 @@ const AdvertisementInfo = () => {
initialValues={initialValues?.data}
onSubmit={handleSubmit}
editable={isAdd || isEdit}
effects={formEffects()}
expressionScope={{
label: (
<div>
{
isAdd || isEdit
isAdd || isEdit
? <span style={{color: '#ff4d4f'}}>* </span>
: null
}
......@@ -78,12 +118,12 @@ const AdvertisementInfo = () => {
}}
>
{
isAdd || isEdit
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit loading={submitLoading}>提交</Submit>
<Button onClick={handleCancel}>取消</Button>
</FormButtonGroup>
</FormButtonGroup>
)
: <></>
}
......@@ -94,4 +134,4 @@ const AdvertisementInfo = () => {
)
}
export default AdvertisementInfo
\ No newline at end of file
export default AdvertisementInfo
import { sortedList, ADVERTISE_COLUMN_TYPE } from '../../utils/utils';
const columnType = (() => {
const res = Object.keys(ADVERTISE_COLUMN_TYPE).map((item) => {
return {
label: ADVERTISE_COLUMN_TYPE[item],
value: parseInt(item)
}
})
return res;
})()
import { sortedList, } from '../../utils/utils';
const sortListOptions = sortedList(1, 6);
......@@ -38,16 +28,31 @@ const schema = {
},
{
limitByte: true, // 自定义校验规则
maxByte: 60,
maxByte: 60,
}
]
},
channel: {
title: '投放渠道',
type: 'string',
"x-component": 'Select',
'x-component-props': {
options: [
{ label: 'Web', value: 1 },
{ label: 'App', value: 2 },
],
},
"x-rules": [{
"required": true,
"message": "请选择投放渠道"
}],
},
columnType: {
title: '栏目',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: columnType
options: []
},
"x-rules": [{
"required": true,
......@@ -73,7 +78,7 @@ const schema = {
"x-rules": [
{
limitByte: true, // 自定义校验规则
maxByte: 100,
maxByte: 100,
}
]
},
......@@ -90,10 +95,10 @@ const schema = {
"required": true,
"message": "请上传图片"
},
},
},
}
}
}
}
export default schema
\ No newline at end of file
export default schema
......@@ -3,7 +3,8 @@ import { DownOutlined } from '@ant-design/icons';
import { TimeList } from '../../statusList';
import moment from 'moment';
import React from 'react';
import {ADVERTISE_COLUMN_TYPE} from '../../utils/utils';
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);
const CustomTimeList = [{label: '全部', value: 0}].concat(TimeList.slice(1));
......@@ -23,7 +24,7 @@ const columns = [
title: '栏目', dataIndex: 'columnType',
render: (text, record) => {
return (
<div>{ADVERTISE_COLUMN_TYPE[text]}</div>
<div>{ALL_TYPE[text]}</div>
)
},
},
......
......@@ -55,13 +55,18 @@ const sortedList = (start, end) => {
return res
}
// 内容管理 - 广告栏目
const ADVERTISE_COLUMN_TYPE = {
"1": "会员首页-活动广告1",
"2": "会员首页-活动广告2",
// 内容管理 - 广告栏目
const ADVERTISE_WEB_COLUMN_TYPE = {
"1": "会员首页-活动广告1",
"2": "会员首页-活动广告2",
"3": "会员首页-活动广告3"
}
const ADVERTISE_APP_COLUMN_TYPE = {
"4": '找店铺广告图',
"5": "人气店铺广告图"
}
// 内容管理 - 公告栏目
const ANNOUNCE_COLUMN_TYPE = {
'1': '会员首页公告',
......@@ -83,7 +88,7 @@ const POSITION = {
}
/**
* 将字典转换成 {label: 'xx', value: 1}
* @param maps
* @param maps
*/
const transfer2Options = (maps) => {
const res = Object.keys(maps).map((item) => {
......@@ -101,9 +106,11 @@ export {
setTableDataSource,
getTableDataSource,
sortedList,
ADVERTISE_COLUMN_TYPE,
ADVERTISE_WEB_COLUMN_TYPE,
ADVERTISE_APP_COLUMN_TYPE,
// ADVERTISE_COLUMN_TYPE,
ANNOUNCE_COLUMN_TYPE,
transfer2Options,
SCENE,
POSITION
}
\ No newline at end of file
}
......@@ -36,24 +36,25 @@ const Message: React.FC<{}> = () => {
}
const handleRead = (id, url: string) => {
console.log("当前功能还未开发")
// PublicApi.getReportMessageMemberRead({id: id})
// .then((data) => {
// if(url) {
// if(/http/.test(url)) {
// location.href = url
// } else {
// history.push(url);
// }
// } else {
// getList(pagination);
// }
// })
PublicApi.getReportMessagePlatformRead({id: id})
.then((data) => {
if(url) {
if(/http/.test(url)) {
location.href = url
} else {
history.push(url);
}
return;
}
if(data.code === 1000) {
getList(pagination)
}
})
}
const renderMessage = (data) => {
return (
<div onClick={() => handleRead(data.id, data.url)}>
<div onClick={() => handleRead(data.id, data.url)} style={{cursor: "pointer"}}>
<StatusTag type={data.type == 1 ? 'primary' : 'success'} title={data.type === 1 ? '系统消息' : '平台消息'} />
<span className={styles.messageTitle}>{data.title || ''}</span>
<span className={styles.messageText}>{data.content || ''}</span>
......
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