Commit 63eca444 authored by Bill's avatar Bill

修改咨询查询搜索上下架

parent bfe6b521
......@@ -41,7 +41,7 @@
{
path: '/content/infomationInfo',
name: 'infomationInfo',
component: '@/pages/content/infomation/infomationInfo',
component: '@/pages/content/infomation/infomationInfo1',
hideInMenu: true,
hidePageHeader: true,
}
......
......@@ -9,7 +9,7 @@ const CustomEditor = (props) => {
const parentProps = props.props['x-component-parent-props'];
return (
<div {...parentProps}>
<BraftEditor {...editorProps} />
<BraftEditor {...editorProps} value={props.value || ''} onChange={(editorState) => props.mutators.change(editorState)}/>
</div>
)
}
......
......@@ -30,7 +30,7 @@ const Tags = (props) => {
})
}
const dataSource = props.props['x-component-props']['dataSource'];
const dataSource = props.props['x-component-props']['dataSource'] || [];
const selected = dataSource.filter((item) => tags.includes(item.value) )
return (
<div className={styles.tagContainer}>
......
This diff is collapsed.
import React, { useState } from 'react';
import React, { useEffect, useState } from 'react';
import { SchemaForm,Submit, FormButtonGroup, Reset, createVirtualBox, createFormActions } from '@formily/antd';
import { Card, Select, Input, Checkbox, Grid, Button } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
......@@ -9,6 +9,9 @@ import { FlexRowLayout } from '../components/FilterTable';
import CustomUpload from '@/components/NiceForm/components/CustomUpload';
import { CustomTags } from '../components/Tags';
import CustomEditor from '../components/CustomEditor';
import BraftEditor from 'braft-editor';
import { useInitialValues } from '../hooks/useInitialValues';
import { PublicApi } from '@/services/api';
import { action } from 'mobx';
const actions = createFormActions();
......@@ -45,8 +48,8 @@ const schema = {
"labelAlign": "left",
},
properties: {
name: {
name: 'name',
title : {
name: 'title',
title: '标题',
'x-component': 'Input',
'x-component-props': {
......@@ -71,8 +74,8 @@ const schema = {
"message": "请选择咨询说明"
},
},
recommendedTag: {
name: 'recommendedTag',
recommendLabel: {
name: 'recommendLabel',
title: '推荐标签',
type: 'string',
'x-component': 'Select',
......@@ -113,8 +116,8 @@ const schema = {
},
}
},
view: {
name: 'view',
readCount: {
name: 'readCount',
title: '浏览数',
type: 'string',
'x-component': 'Input',
......@@ -128,11 +131,11 @@ const schema = {
"wrapperCol": 12,
},
"onChange": "{{tagOnChange}}",
dataSource: [
{ label: '政策法规', value: 1 },
{ label: '跨境交易', value: 2 },
{ label: '行业报告', value: 3 }
]
// dataSource: [
// { label: '政策法规', value: 1 },
// { label: '跨境交易', value: 2 },
// { label: '行业报告', value: 3 }
// ]
}
},
imageUpload: {
......@@ -144,7 +147,11 @@ const schema = {
size: '无',
onChange: "{{uploadImage}}",
fileMaxSize: 300
}
},
// "x-rules": {
// "required": true,
// "message": "请上传图片"
// },
},
digest: {
type: 'string',
......@@ -178,11 +185,15 @@ const schema = {
border: '1px solid #DCDFE6'
}
},
"x-rules": {
"required": true,
"message": "请输入内容"
},
"x-component-props": {
contentStyle: {
height: 256,
},
onChange: "{{editorChange}}",
// onChange: "{{editorChange}}",
excludeControls: [
'letter-spacing',
'line-height',
......@@ -205,17 +216,77 @@ const schema = {
}
const InfomationInfo = () => {
const { id, validateId } = usePageStatus();
const { id, preview } = usePageStatus();
const [isTop, setIsTop] = useState(1);
const [labelIds, setLabelIds] = useState<number[]>([]);
const [imageUrl, setImageUrl] = useState("");
const [submitLoading, setSubmitLoading ] = useState(false);
const initialValues = useInitialValues({id:id}, PublicApi.getManageContentInformationGet);
const isEdit = id && !preview;
const isAdd = !id && !preview;
// 设置form 的某字段的值
const setFormStatus = (name: string, key: string, value: any) => {
actions.setFieldState(name, state => {
// @ts-ignore
state.props['x-component-props'][key] = value
})
}
useEffect(() => {
async function getColumn() {
const res = await PublicApi.getManageContentColumnAll();
const columns = res.data.map((item) => ({label: item.name, value: item.id}));
setFormStatus("layout.columnId", "options", columns)
}
if(!preview) {
getColumn()
}
}, [])
useEffect(() => {
async function getLabels() {
const res = await PublicApi.getManageContentLabelAll();
const labels = res.data.map((item) => ({label: item.name, value: item.id}));
setFormStatus("layout.labelIds", "dataSource", labels)
}
if(!preview) {
getLabels()
}
})
const handleSubmit = (value) => {
console.log(isTop)
console.log(labelIds);
console.log(value)
console.log(value);
const content = value.content.toHTML();
const tempPostData = {
...value,
top: isTop,
labelIds: labelIds,
content: content,
imageUrl: imageUrl
}
const handleClick = () => {
const test = {"blocks":[{"key":"63n0e","text":"TEST","type":"unstyled","depth":0,"inlineStyleRanges":[],"entityRanges":[],"data":{}}],"entityMap":{}};
const serviceActions = isAdd
? PublicApi.postManageContentInformationAdd
: PublicApi.postManageContentInformationUpdate
const postData = isAdd ? tempPostData : {...tempPostData, id: id};
setSubmitLoading(true)
serviceActions(postData).then((data) => {
setSubmitLoading(false);
history.push('/content/infomations')
})
}
const handleClick = () => {
const test = {"blocks":[{"key":"1aqu1","text":"Hello World!","type":"unstyled","depth":0,"inlineStyleRanges":[{"offset":0,"length":12,"style":"COLOR-669900"},{"offset":0,"length":12,"style":"FONTSIZE-13"},{"offset":0,"length":12,"style":"LETTERSPACING-0.7"},{"offset":0,"length":12,"style":"BGCOLOR-F9F9F9"},{"offset":6,"length":6,"style":"BOLD"}],"entityRanges":[],"data":{"nodeAttributes":{}}}],"entityMap":{}};
const htmlString = `<p>Hello <b>World!</b></p>`
// 将HTML字符串转换为编辑器所需要的EditorState实例
const editorState = BraftEditor.createEditorState(test)
actions.setFieldState('layout.contentLayout.content', (state) => {
//@ts-ignore
state.props['x-component-props'].value = editorState;
})
}
return (
......@@ -227,8 +298,10 @@ const InfomationInfo = () => {
>
<Card>
<SchemaForm
initialValues={initialValues?.data}
onSubmit={handleSubmit}
schema={schema}
editable={isAdd || isEdit}
actions={actions}
components={{
Input, Select, Submit,
......@@ -242,25 +315,28 @@ const InfomationInfo = () => {
tagOnChange: (value) => {
setLabelIds(value);
},
editorChange: (editorState) => {
console.log(editorState.toRAW())
},
uploadImage: (values) => {
//http://10.0.0.28:88/group1/M00/00/0B/CgAAHF9rAu2AdfJMAAQ0taO65Rw451.jpg
actions.setFieldState('layout.imageUpload', (state) => {
// @ts-ignore
state.props['x-component-props'].imgUrl = values;
})
setImageUrl(values)
console.log(values)
}
}}
>
{
isAdd || isEdit
? (
<FormButtonGroup offset={3}>
<Submit>提交</Submit>
<Submit loading={submitLoading}>提交</Submit>
<Reset>取消</Reset>
</FormButtonGroup>
)
: <></>
}
</SchemaForm>
{/* <Button onClick={}></Button> */}
</Card>
</PageHeaderWrapper>
</div>
......
import EyePreview from '@/components/EyePreview';
import { DownOutlined, DeleteOutlined, UpOutlined } from '@ant-design/icons';
import { timeRange } from '@/utils/index';
import { TimeList } from '@/pages/logistics/statusList';
import moment from 'moment';
import React from 'react';
const columns = [
{title: 'ID', dataIndex: 'id'},
{
title: '栏目', dataIndex: 'columnName',
},
{ title: '标题',
dataIndex: 'title',
render: (text: string, record: any) => (
<EyePreview
url={`/content/infomationInfo?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
)
},
{
title: '操作时间',
dataIndex: 'createTime',
render: (text) => (
moment(text).format('YYYY-MM-DD HH:mm:ss')
)
},
{title: '状态', dataIndex: 'status', render: "{{renderStatus}}"},
{title: '操作', render: "{{renderOperation}}"}
];
/**
* 这等于是一个flex 布局
* flexRow, FlewColumn 布局的高级搜索
* 咨询管理 schema
*/
const infomationSchema = {
type: 'object',
properties: {
layout: {
type: 'object',
// 'x-component': 'mega-layout',
'x-component': 'FlexRowLayout',
'x-component-props': {
justify: 'space-between',
align: 'center'
},
properties: {
'left-layout': {
type: 'object',
name: 'left-layout',
'x-component': 'FlexRowLayout',
'x-component-props': {
justify: 'start',
align: 'center'
},
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'
}
}
},
batchGrounding: {
type: 'object',
name: 'batchUpdata',
'x-component': 'button',
'x-component-props': {
"onClick": "{{batchGrounding}}",
"children": "批量上架",
style: {
margin: '0 0 0 15px'
}
}
},
undercarriage: {
type: 'object',
name: 'undercarriage',
'x-component': 'button',
'x-component-props': {
"onClick": "{{undercarriage}}",
"children": "批量下架",
style: {
margin: '0 15px'
}
}
},
more: {
type: 'object',
name: 'more',
'x-component': 'SchemaDropDown',
'x-component-props': {
overlay: "{{menu}}",
children: '更多',
icon: <DownOutlined />
}
}
}
},
'right-layout': {
type: 'object',
name: 'rigth-layout',
"x-component": 'FlexColumnLayout',
properties: {
controllers: {
type: 'object',
name: 'controllers',
'x-component': 'FlexRowLayout',
'x-component-props': {
justify: 'end',
},
properties: {
search: {
type: 'string',
name: 'name',
'x-component': 'Search',
'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': 'FlexRowLayout',
'x-component-props': {
justify: 'end'
},
properties: {
columns: {
name: 'columns',
type: 'string',
'x-component': 'Select',
'x-component-props': {
placeholder: '请选择栏目',
style: {
width: '160px'
}
}
},
status: {
name: 'status',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: [
{label: '全部', value: '0'},
{label: '待上架', value: '1'},
{label: '已上架',value: '2'},
{label: '已下架',value: '3'},
],
placeholder: '请选择状态',
style: {
width: '160px',
margin: '0 15px'
}
}
},
time: {
name: 'time',
type: 'string',
'x-component': 'Select',
'x-component-props': {
options: TimeList,
style: {
width: '160px',
}
}
}
}
}
}
}
}
},
"table": {
"key": "table",
"type": "object",
"name": "table",
"x-component": "Table",
"x-component-props": {
"columns": columns,
"rowKey": "id",
"pagination": {
showQuickJumper: true,
size: "small",
"onChange": "{{paginationChange}}",
},
"rowSelection": "{{rowSelection}}"
}
},
}
}
export {
infomationSchema
}
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