Commit d74941fa authored by rzf's avatar rzf

parent 82b30992
...@@ -7,7 +7,7 @@ function PageModal({ visible, onCancel, onPublish }) { ...@@ -7,7 +7,7 @@ function PageModal({ visible, onCancel, onPublish }) {
const [publish, setPublish] = useState(false) const [publish, setPublish] = useState(false)
const [pageData, setpageData] = useState('') const [pageData, setpageData] = useState('')
const { fetchData, updateIndex, dataCenter } = useContext(Root) const { fetchData, dataCenter } = useContext(Root)
const onChangePage = (values) => { const onChangePage = (values) => {
console.log(values); console.log(values);
...@@ -64,7 +64,6 @@ function PageModal({ visible, onCancel, onPublish }) { ...@@ -64,7 +64,6 @@ function PageModal({ visible, onCancel, onPublish }) {
console.log(dataCenter); console.log(dataCenter);
dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage') dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage')
.then((res) => { .then((res) => {
updateIndex()
}) })
}, []) }, [])
......
...@@ -25,7 +25,7 @@ const PublishModal = ({ visible, onCancel, data }) => { ...@@ -25,7 +25,7 @@ const PublishModal = ({ visible, onCancel, data }) => {
const [code, setcode] = useState('') const [code, setcode] = useState('')
const [pageName, setPageName] = useState('') const [pageName, setPageName] = useState('')
const [oldCode, setoldCode] = useState('') const [oldCode, setoldCode] = useState('')
const { fetchData, updateIndex, dataCenter } = useContext(Root) const { fetchData, dataCenter } = useContext(Root)
console.log(data); console.log(data);
const onCreate = (values) => { const onCreate = (values) => {
console.log(code); console.log(code);
...@@ -53,7 +53,7 @@ const PublishModal = ({ visible, onCancel, data }) => { ...@@ -53,7 +53,7 @@ const PublishModal = ({ visible, onCancel, data }) => {
message.success('发布成功!') message.success('发布成功!')
dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage') dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage')
.then((res) => { .then((res) => {
updateIndex()
}) })
} else { } else {
message.error(data.error || '发布失败') message.error(data.error || '发布失败')
...@@ -77,7 +77,7 @@ const PublishModal = ({ visible, onCancel, data }) => { ...@@ -77,7 +77,7 @@ const PublishModal = ({ visible, onCancel, data }) => {
message.success('发布成功!') message.success('发布成功!')
dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage') dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage')
.then((res) => { .then((res) => {
updateIndex()
}) })
} else { } else {
message.error(data.error || '发布失败') message.error(data.error || '发布失败')
......
...@@ -14,7 +14,7 @@ function RemoveType({ visible, onCancel }) { ...@@ -14,7 +14,7 @@ function RemoveType({ visible, onCancel }) {
const [typeModal, setTypeModal] = useState(false) const [typeModal, setTypeModal] = useState(false)
const [oldData, setoldData] = useState('') const [oldData, setoldData] = useState('')
const { fetchData, updateIndex, dataCenter } = useContext(Root) const { fetchData, dataCenter } = useContext(Root)
const changType = (data) => { const changType = (data) => {
setoldData(data) setoldData(data)
...@@ -26,9 +26,9 @@ function RemoveType({ visible, onCancel }) { ...@@ -26,9 +26,9 @@ function RemoveType({ visible, onCancel }) {
} }
useEffect(() => { useEffect(() => {
dataCenter?.type && fetchData('/query/queryChildType', { typeId: dataCenter?.type[0]?.typeId }, 'childType') dataCenter?.type && fetchData('/typeManage/queryTypeForManage', {}, 'childTypeData')
.then((res) => { .then((res) => {
updateIndex()
console.log(res); console.log(res);
}) })
}, []) }, [])
......
import React, {useContext, useEffect} from 'react'; import React, { useState, useEffect, useContext } from 'react';
import {Root} from "../dataCenter/Root"; import { Root } from "../dataCenter/Root";
import {Form, Input, message, Modal, Select} from 'antd'; import { Button, Modal, Form, Input, Radio, Select, message } from 'antd';
import { NEED_UPDATE_INDEX } from "../dataCenter/action";
const { Option } = Select; const { Option } = Select;
const ToolModal = ({ visible, onCancel, data }) => { const ToolModal = ({ visible, onCancel, data }) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const { fetchData, updateIndex, dataCenter } = useContext(Root) const { fetchData, dataCenter, dispatch } = useContext(Root)
const formItemLayout = { const formItemLayout = {
labelCol: { span: 4 }, labelCol: { span: 4 },
wrapperCol: { span: 18 }, wrapperCol: { span: 18 },
...@@ -28,7 +28,7 @@ const ToolModal = ({ visible, onCancel, data }) => { ...@@ -28,7 +28,7 @@ const ToolModal = ({ visible, onCancel, data }) => {
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
message.success('新建成功') message.success('新建成功')
updateIndex() dispatch(NEED_UPDATE_INDEX())
onCancel() onCancel()
} }
}) })
...@@ -38,7 +38,7 @@ const ToolModal = ({ visible, onCancel, data }) => { ...@@ -38,7 +38,7 @@ const ToolModal = ({ visible, onCancel, data }) => {
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
message.success('修改成功') message.success('修改成功')
updateIndex() dispatch(NEED_UPDATE_INDEX())
onCancel() onCancel()
} }
}) })
...@@ -51,7 +51,7 @@ const ToolModal = ({ visible, onCancel, data }) => { ...@@ -51,7 +51,7 @@ const ToolModal = ({ visible, onCancel, data }) => {
}); });
fetchData('/query/queryChildType', { typeId: value }, 'childType') fetchData('/query/queryChildType', { typeId: value }, 'childType')
.then((res) => { .then((res) => {
updateIndex()
console.log(res); console.log(res);
}) })
console.log(dataCenter); console.log(dataCenter);
...@@ -65,7 +65,7 @@ const ToolModal = ({ visible, onCancel, data }) => { ...@@ -65,7 +65,7 @@ const ToolModal = ({ visible, onCancel, data }) => {
useEffect(() => { useEffect(() => {
dataCenter?.type && fetchData('/query/queryChildType', { typeId: dataCenter?.type[0]?.typeId }, 'childType') dataCenter?.type && fetchData('/query/queryChildType', { typeId: dataCenter?.type[0]?.typeId }, 'childType')
.then((res) => { .then((res) => {
updateIndex()
console.log(res); console.log(res);
}) })
}, []) }, [])
......
import React, {useContext} from 'react'; import React from 'react';
import {Form, Input, message, Modal, Radio, Select, Tabs} from 'antd'; import { Button, Modal, Form, Input, Radio, Select, message, Tabs } from 'antd';
import {Root} from "../dataCenter/Root"; import { useContext, useEffect, useState } from "react";
import { Root } from "../dataCenter/Root";
import { NEED_UPDATE_INDEX } from "../dataCenter/action";
const { Option } = Select; const { Option } = Select;
const { TabPane } = Tabs; const { TabPane } = Tabs;
const TypeModal = ({ visible, onCancel, data }) => { const TypeModal = ({ visible, onCancel, data }) => {
...@@ -13,27 +14,27 @@ const TypeModal = ({ visible, onCancel, data }) => { ...@@ -13,27 +14,27 @@ const TypeModal = ({ visible, onCancel, data }) => {
wrapperCol: { span: 18 }, wrapperCol: { span: 18 },
}; };
const { fetchData, updateIndex } = useContext(Root) const { fetchData, dataCenter, dispatch } = useContext(Root)
const [value, setValue] = React.useState(1); const [value, setValue] = React.useState(1);
const onCreate = (values) => { const onCreate = (values) => {
console.log(values);
if (data) { if (data) {
} else { } else {
console.log(values);
fetchData('/add/addType', values) fetchData('/add/addType', values)
.then((res) => { .then((res) => {
if (res.success) { if (res.success) {
message.success('新建成功') message.success('新建成功')
updateIndex() dispatch(NEED_UPDATE_INDEX())
onCancel() onCancel()
} }
}) })
} }
}; };
// function callback(key) { // function callback(key) {
// console.log(key); // console.log(key);
// } // }
...@@ -43,6 +44,12 @@ const TypeModal = ({ visible, onCancel, data }) => { ...@@ -43,6 +44,12 @@ const TypeModal = ({ visible, onCancel, data }) => {
setValue(e.target.value); setValue(e.target.value);
}; };
const onGenderChange = (value) => {
form.setFieldsValue({
typeId: value,
});
};
return ( return (
<Modal <Modal
visible={visible} visible={visible}
...@@ -93,18 +100,28 @@ const TypeModal = ({ visible, onCancel, data }) => { ...@@ -93,18 +100,28 @@ const TypeModal = ({ visible, onCancel, data }) => {
</Form.Item> : </Form.Item> :
<> <>
<Form.Item <Form.Item
name="select" name="typeId"
label="父类型" label="父类型"
hasFeedback hasFeedback
rules={[{ required: true, message: '请选择父类型!' }]} rules={[{ required: true, message: '请选择父类型!' }]}
> >
<Select placeholder="请选择父类型"> <Select
<Option value="china">China</Option> placeholder="请选择父类型"
<Option value="usa">U.S.A</Option> onChange={onGenderChange}
// allowClear
>
{
dataCenter?.type?.length && dataCenter?.type.map(v => {
return (
<Option key={v.typeId} value={v.typeId}>{v.typeName}</Option>
)
})
}
</Select> </Select>
</Form.Item> </Form.Item>
<Form.Item <Form.Item
name="typeName" name="childTypeName"
label="子类型" label="子类型"
rules={[ rules={[
{ {
......
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