Commit d74941fa authored by rzf's avatar rzf

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