Commit ed6485b7 authored by Bill's avatar Bill

feat: 添加内容管理分类管理,修改内容管理资讯

parent 9dd58334
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
// import rfqRoute from './rfqRoute' // 询价单路由 // import rfqRoute from './rfqRoute' // 询价单路由
// import rfqOfferRoute from './rfqOfferRoute' // 询价单路由 // import rfqOfferRoute from './rfqOfferRoute' // 询价单路由
// import commentRoutes from './commentRoutes'; // import commentRoutes from './commentRoutes';
// import contentRoute from './contentRoute'; // 内容管理 import contentRoute from './contentRoute'; // 内容管理
// import balancedRoute from './balancedRoute'; // 平台结算管理 // import balancedRoute from './balancedRoute'; // 平台结算管理
// import capitalAccount from './capitalAccountRoute'; // 会员资金账户 // import capitalAccount from './capitalAccountRoute'; // 会员资金账户
// import messageRoute from './messgeRoute'; // 消息管理 // import messageRoute from './messgeRoute'; // 消息管理
...@@ -39,18 +39,18 @@ const routeList = [ ...@@ -39,18 +39,18 @@ const routeList = [
// pageCustomized, // pageCustomized,
// calssPropertyRoute, // calssPropertyRoute,
// trademarkRoute, // trademarkRoute,
// commodity, // commodity,
// rfqRoute, // rfqRoute,
// rfqOfferRoute, // rfqOfferRoute,
// logisticsRoutes, // logisticsRoutes,
// memberAbility, // memberAbility,
// ruleSettingRoutes, // ruleSettingRoutes,
// authConfig, // authConfig,
// commentRoutes, // commentRoutes,
// contentRoute, // contentRoute,
// balancedRoute, // balancedRoute,
// demandRoute, // demandRoute,
// procurementRoute, // procurementRoute,
// demandQuoteOrderRoute, // demandQuoteOrderRoute,
// capitalAccount, // capitalAccount,
// messageRoute, // messageRoute,
...@@ -58,7 +58,7 @@ const routeList = [ ...@@ -58,7 +58,7 @@ const routeList = [
// orderSystemRoutes, // orderSystemRoutes,
// productionNoticeRoutes, // productionNoticeRoutes,
// exchangeManageRoutes, // exchangeManageRoutes,
// returnManageRoute, // returnManageRoute,
// repairManageRoute, // repairManageRoute,
] ]
......
/**
* 内容管理常量
*/
/**
* 栏目管理 - 栏目分类 - 市场行情
* @value = 1
*/
export const COLUMN_MARKET_CATEGORY = 1;
/**
* 栏目管理 - 栏目分类 - 资讯
* @value = 2
*/
export const COLUMN_INFOMATION_CATEGORY = 2;
/**
*
*/
export const COLUMN_CATEGORY = {
[COLUMN_MARKET_CATEGORY]: '市场行情',
[COLUMN_INFOMATION_CATEGORY]: '资讯'
}
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
// global main color // global main color
@main-color: #00B37A; @main-color: #00B37A;
@secondary-color: #E4F7EF;
// layout // layout
@header-global-nav-bg: #38414A; @header-global-nav-bg: #38414A;
...@@ -29,4 +30,3 @@ ...@@ -29,4 +30,3 @@
@status-invalid: #FFC400; // 未生成,无效、待审核 @status-invalid: #FFC400; // 未生成,无效、待审核
@status-nopass: #EF6260; // 审核不通过 @status-nopass: #EF6260; // 审核不通过
import React from 'react'; import React from 'react';
import { Input } from 'antd'; import { Input } from 'antd';
import styles from './styles.less'
const { Search } = Input; const { Search } = Input;
...@@ -11,17 +12,19 @@ const CustomSearch = (props) => { ...@@ -11,17 +12,19 @@ const CustomSearch = (props) => {
} }
return ( return (
// <Search disabled={!editable} value={props.value} onChange={handleChange}>置顶</Search> <div className={styles.container}>
<Search <Search
disabled={!editable} disabled={!editable}
value={props.value} value={props.value}
onChange={handleChange} onChange={handleChange}
{...componentProps} {...componentProps}
// onSearch={value => console.log(value)} // onSearch={value => console.log(value)}
/> />
</div>
) )
} }
CustomSearch.isFieldComponent = true CustomSearch.isFieldComponent = true
export default CustomSearch export default CustomSearch
\ No newline at end of file
.container {
:global {
.input-search {
// background-color: red;
.ant-input-wrapper {
.ant-input {
height: 32px !important;
}
}
}
}
}
.tagContainer { .tagContainer {
.selection { .selection {
...@@ -14,11 +15,11 @@ ...@@ -14,11 +15,11 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
background-color: #4279DF; background-color: @secondary-color;
color: #fff; color: @main-color;
border-radius: 4px; border-radius: 4px;
.icon { .icon {
margin-left: 4px; margin-left: 4px;
cursor: pointer; cursor: pointer;
...@@ -54,4 +55,4 @@ ...@@ -54,4 +55,4 @@
margin-bottom: 16px; margin-bottom: 16px;
} }
} }
} }
\ No newline at end of file
...@@ -14,12 +14,26 @@ import { PublicApi } from '@/services/api'; ...@@ -14,12 +14,26 @@ import { PublicApi } from '@/services/api';
import infomationInfoSchema from './schema/infomationInfoSchema'; import infomationInfoSchema from './schema/infomationInfoSchema';
import CustomUpload from '../components/WrapCustomUpload'; import CustomUpload from '../components/WrapCustomUpload';
import useCustomValidator from '../hooks/useValidator' import useCustomValidator from '../hooks/useValidator'
import { GetManageContentCategoryAllResponse } from '@/services/PlatformApi';
import { COLUMN_CATEGORY } from '@/constants/const/content';
const actions = createFormActions(); const actions = createFormActions();
const { onFieldValueChange$ } = FormEffectHooks const { onFieldValueChange$ } = FormEffectHooks
const { TextArea } = Input; const { TextArea } = Input;
/**
* 栏目分类
* 1.市场行情;2.资讯
*/
type ColumnType = 0 | 1 | 2;
type ColumnListType = {
label: string,
value: number,
type: 1 | 2
}
const InfomationInfo = () => { const InfomationInfo = () => {
useCustomValidator(); useCustomValidator();
const { id, preview } = usePageStatus(); const { id, preview } = usePageStatus();
...@@ -27,7 +41,10 @@ const InfomationInfo = () => { ...@@ -27,7 +41,10 @@ const InfomationInfo = () => {
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 [unsaved, setUnsaved] = useState(true);
const [type, setType] = useState<ColumnType>(0);
const initialValues = useInitialValues({id:id}, PublicApi.getManageContentInformationGet); const initialValues = useInitialValues({id:id}, PublicApi.getManageContentInformationGet);
const [category, setCategory] = useState<GetManageContentCategoryAllResponse>([]);
const [column, setColumn] = useState<ColumnListType[]>([])
const isEdit = id && !preview; const isEdit = id && !preview;
const isAdd = !id && !preview; const isAdd = !id && !preview;
const isView = id && preview; const isView = id && preview;
...@@ -43,8 +60,9 @@ const InfomationInfo = () => { ...@@ -43,8 +60,9 @@ const InfomationInfo = () => {
useEffect(() => { useEffect(() => {
async function getColumn() { async function getColumn() {
const res = await PublicApi.getManageContentColumnAll(); const res = await PublicApi.getManageContentColumnAll();
const columns = res.data.map((item) => ({label: item.name, value: item.id, type: item.type})); const list = res.data.map((item) => ({label: item.name, value: item.id, type: item.type}));
setFormStatus("layout.columnId", "options", columns) setFormStatus("layout.columnId", "options", list)
setColumn(list)
} }
getColumn() getColumn()
}, []) }, [])
...@@ -58,6 +76,21 @@ const InfomationInfo = () => { ...@@ -58,6 +76,21 @@ const InfomationInfo = () => {
getLabels() getLabels()
}, []) }, [])
/**
* 获取行情分类
*/
useEffect(() => {
async function getCategory() {
const { data, code, message } = await PublicApi.getManageContentCategoryAll();
if (code !== 1000) return;
const list = data.map((_item) => ({ label: _item.name, value: _item.id, children: _item.list }) );
setFormStatus("layout.categoryLayout.firstCategoryId", "options", list);
// sethasGetCategory(true)
setCategory(data);
}
getCategory();
}, [])
useEffect(() => { useEffect(() => {
const data = initialValues.data || {} const data = initialValues.data || {}
const content = data.content; const content = data.content;
...@@ -66,17 +99,40 @@ const InfomationInfo = () => { ...@@ -66,17 +99,40 @@ const InfomationInfo = () => {
actions.setFieldValue('layout.contentLayout.content', editorState); actions.setFieldValue('layout.contentLayout.content', editorState);
} }
setFormStatus('layout.contentLayout.content', 'readOnly', isView); setFormStatus('layout.contentLayout.content', 'readOnly', isView);
if(category) {
const secondCategory = category.filter((_row) => _row.id === data.firstCategoryId)[0]?.list || [];
const options = secondCategory.map((_row: any) => ({label: _row.name, value: _row.id, children: _row.list }))
setFormStatus('layout.categoryLayout.secondCategoryId', 'options', options);
actions.setFieldValue('layout.categoryLayout.secondCategoryId', data.secondCategoryId);
const thirdCategory = options.filter((_row) => _row.value === data.secondCategoryId)[0]?.children || [];
const thirdOptions = thirdCategory.map((_row: any) => ({label: _row.name, value: _row.id, children: _row.list }))
setFormStatus('layout.categoryLayout.thirdlyCategoryId', 'options', thirdOptions);
actions.setFieldValue('layout.categoryLayout.thirdlyCategoryId', data.thirdlyCategoryId);
}
if (column) {
const targetColumn = column.filter((_item) => _item.value === data.columnId)[0];
if(targetColumn) {
actions.setFieldState('layout.columnId', state => {
state.props['description'] = `栏目分类:${COLUMN_CATEGORY[targetColumn?.type] || ''}`
})
setType(targetColumn?.type)
}
}
setFormStatus('layout.imageUpload', 'imgUrl', data.imageUrl) setFormStatus('layout.imageUpload', 'imgUrl', data.imageUrl)
setIsTop(data.top); setIsTop(data.top);
setLabelIds(data.labelIds) setLabelIds(data.labelIds)
setFormStatus('layout.labelIds', 'seletedTag', data.labelIds) setFormStatus('layout.labelIds', 'seletedTag', data.labelIds)
}, [initialValues]) }, [initialValues, category, column])
const handleSubmit = (value) => { const handleSubmit = (value) => {
const content = value.content.toHTML(); const content = value.content.toHTML();
const tempPostData = { const tempPostData = {
...value, ...value,
top: isTop, top: isTop,
type: type,
labelIds: labelIds, labelIds: labelIds,
content: content, content: content,
} }
...@@ -119,13 +175,26 @@ const InfomationInfo = () => { ...@@ -119,13 +175,26 @@ const InfomationInfo = () => {
TextArea, Checkbox, TextArea, Checkbox,
CustomUpload, CustomTags, CustomEditor, CustomUpload, CustomTags, CustomEditor,
}} }}
effects={() => { effects={($) => {
onFieldValueChange$('layout.columnId').subscribe(({ value }) => { onFieldValueChange$('layout.columnId').subscribe(({ value }) => {
actions.setFieldState('layout.columnId', state => { actions.setFieldState('layout.columnId', state => {
const currentType = state.props["x-component-props"]!.options.filter((_row) => _row.value === value)[0]; const currentType = state.props["x-component-props"]!.options?.filter((_row) => _row.value === value)[0];
state["props"]["description"] = `栏目分类:${currentType && (currentType.type === 1 ? '市场行情': '资讯') || ''}` state["props"]["description"] = `栏目分类:${currentType && (COLUMN_CATEGORY[currentType.type])}`;
setType(currentType ? currentType.type : 0)
})
})
onFieldValueChange$('layout.categoryLayout.*(firstCategoryId,secondCategoryId)').subscribe(({ value, props, name }) => {
const childrenName = name === 'firstCategoryId' ? 'secondCategoryId' : 'thirdlyCategoryId';
const optionChildren = props["x-component-props"]!.options.filter((_row) => _row.value === value)[0]?.children || [];
console.log(optionChildren)
const list = optionChildren?.map((_item) => ({ label: _item.name, value: _item.id, children: _item.list }) );
actions.setFieldState(`layout.categoryLayout.${childrenName}`, state => {
state.value = "",
state.props['x-component-props']!["options"] = list;
}) })
}) })
}} }}
expressionScope={{ expressionScope={{
isTop: ( isTop: (
...@@ -164,7 +233,7 @@ const InfomationInfo = () => { ...@@ -164,7 +233,7 @@ const InfomationInfo = () => {
} }
</SchemaForm> </SchemaForm>
</Card> </Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" /> <Prompt when={(isAdd || isEdit) && unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper> </PageHeaderWrapper>
</div> </div>
) )
......
...@@ -2,17 +2,22 @@ import EyePreview from '@/components/EyePreview'; ...@@ -2,17 +2,22 @@ import EyePreview from '@/components/EyePreview';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons'; import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
import { timeRange } from '@/utils/index'; import { timeRange } from '@/utils/index';
import { TimeList } from '../../statusList'; import { TimeList } from '../../statusList';
import { COLUMN_CATEGORY } from '@/constants/const/content';
import moment from 'moment'; import moment from 'moment';
import React from 'react'; import React from 'react';
const CustomTimeList = [{label: '全部', value: 0}].concat(TimeList.slice(1)); const CustomTimeList = [{label: '全部', value: 0}].concat(TimeList.slice(1));
const columns = [ const columns = [
{title: 'ID', dataIndex: 'id'}, { title: 'ID', dataIndex: 'id' },
{ {
title: '栏目', dataIndex: 'columnName', title: '栏目分类',
}, dataIndex: 'type',
{ title: '标题', render: (text) => COLUMN_CATEGORY[text],
},
{ title: '栏目', dataIndex: 'columnName' },
{
title: '标题',
dataIndex: 'title', dataIndex: 'title',
render: (text: string, record: any) => ( render: (text: string, record: any) => (
<EyePreview <EyePreview
...@@ -22,9 +27,17 @@ const columns = [ ...@@ -22,9 +27,17 @@ const columns = [
</EyePreview> </EyePreview>
) )
}, },
{ title: '分类', dataIndex: 'categoryName' },
{ title: '推荐标签', dataIndex: 'labelNames' },
{ {
title: '操作时间', title: '排序',
dataIndex: 'sort',
sorter: (a, b) => a.sort - b.sort,
},
{
title: '发布时间',
dataIndex: 'createTime', dataIndex: 'createTime',
sorter: (a, b) => a.createTime - b.createTime,
render: (text) => ( render: (text) => (
moment(text).format('YYYY-MM-DD HH:mm:ss') moment(text).format('YYYY-MM-DD HH:mm:ss')
) )
...@@ -138,6 +151,9 @@ const infomationSchema = { ...@@ -138,6 +151,9 @@ const infomationSchema = {
'x-component': 'CustomSearch', 'x-component': 'CustomSearch',
'x-component-props': { 'x-component-props': {
placeholder: "请填写标题名称", placeholder: "请填写标题名称",
style: {
marginRight: '12px'
},
"onSearch": "{{search}}", "onSearch": "{{search}}",
} }
}, },
......
...@@ -61,20 +61,6 @@ const schema = { ...@@ -61,20 +61,6 @@ const schema = {
"message": "请选择咨询说明" "message": "请选择咨询说明"
}, },
}, },
// columnLayout: {
// type: 'object',
// 'x-component': 'mega-layout',
// 'x-component-props': {
// "label": '栏目',
// // full: true,
// "layoutProps": {
// "wrapperCol": 10
// }
// },
// properties: {
// }
// },
recommendLabel: { recommendLabel: {
name: 'recommendLabel', name: 'recommendLabel',
title: '推荐标签', title: '推荐标签',
...@@ -128,12 +114,9 @@ const schema = { ...@@ -128,12 +114,9 @@ const schema = {
sort: { sort: {
name: 'sort', name: 'sort',
type: 'string', type: 'string',
title: '推荐标签', title: '推荐排序',
'x-component': 'Select', 'x-component': 'Select',
'x-component-props': { 'x-component-props': {
// style: {
// width: '100%'
// },
options: sortedList, options: sortedList,
allowClear: true, allowClear: true,
...@@ -165,25 +148,41 @@ const schema = { ...@@ -165,25 +148,41 @@ const schema = {
"wrapperCol": 24, "wrapperCol": 24,
}, },
properties: { properties: {
category: { firstCategoryId: {
type: 'string', type: 'string',
"x-component": "Select", "x-component": "Select",
wrapperCol: 24,
'x-component-props': { 'x-component-props': {
// layoutProps: { options: [],
// }, },
style: { 'x-linkages': [
width: '100%', {
} type: 'value:visible',
} target: '*(secondCategoryId)',
condition: `{{!!$value}}`,
},
]
}, },
category2: { secondCategoryId: {
type: 'string', type: 'string',
"x-component": "Select", 'x-component': "Select",
'x-component-props': {
options: [],
},
'x-linkages': [
{
type: 'value:visible',
target: '*(thirdlyCategoryId)',
condition: '{{!!$value}}'
},
]
}, },
category3: { thirdlyCategoryId: {
type: 'string', type: 'string',
"x-component": "Select", 'x-component': "Select",
'x-component-props': {
options: [],
},
} }
} }
}, },
......
.anchorWrap { .anchorWrap {
:global { : {
.ant-anchor { .ant-anchor {
display: flex; display: flex;
.ant-anchor-ink { .ant-anchor-ink {
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
/** 卡片样式 */ /** 卡片样式 */
.card { .card {
margin: 24px; margin: 24px;
:global { : {
.ant-card { .ant-card {
margin-bottom: 24px; margin-bottom: 24px;
.ant-card-head { .ant-card-head {
......
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