Commit e43599c4 authored by rzf's avatar rzf

parent 8dda73e7
......@@ -50,13 +50,13 @@ const PublishModal = ({ visible, onCancel, data }) => {
.then(data => {
if (data.success) {
onCancel()
message.success('发布成功!')
message.success('替换成功!')
dataCenter?.type && fetchData('/page/queryPage', {}, 'queryPage')
.then((res) => {
})
} else {
message.error(data.error || '发布失败')
message.error( '替换失败')
}
});
} else {
......
import {Menu, Modal, Popconfirm, Space, Table} from 'antd';
import React, {useContext, useEffect, useState} from 'react';
import { Menu, Modal, Popconfirm, Space, Table, message } from 'antd';
import React, { useContext, useEffect, useState } from 'react';
import TypeModal from '../modal/TypeModal'
import {Root} from "../dataCenter/Root";
import { NEED_UPDATE_INDEX } from "../dataCenter/action";
import { Root } from "../dataCenter/Root";
const menu = (
<Menu>
......@@ -13,88 +14,76 @@ const menu = (
function RemoveType({ visible, onCancel }) {
const [typeModal, setTypeModal] = useState(false)
const [typeData, settypeData] = useState('')
const [oldData, setoldData] = useState('')
const { fetchData, dataCenter } = useContext(Root)
const { fetchData, dataCenter, dispatch } = useContext(Root)
const changType = (data) => {
setoldData(data)
setTypeModal(true)
}
const changeData = (list, cb) => {
return list.map((item, index) => {
const res = cb(item);
if (item.children) res.children = changeData(item.children, item => ({
isRemove: true,
key: item.childTypeId,
typeId: item.childTypeId,
typeName: item.childTypeName,
}));
return res;
})
}
const removeType = (data) => {
console.log(data);
fetchData('/typeManage/deleteChildType', { childTypeId: data.typeId })
.then((res) => {
if (res.success) {
message.success('刪除成功')
dispatch(NEED_UPDATE_INDEX())
queryData()
// onCancel()
}else{
message.error('刪除失败')
}
})
}
useEffect(() => {
const queryData = () => {
dataCenter?.type && fetchData('/typeManage/queryTypeForManage', {}, 'childTypeData')
.then((res) => {
console.log(res);
// console.log(res.data);
const newData = changeData(res.data, item => ({
key: item.typeId,
typeId: item.typeId,
typeName: item.typeName,
}));
// console.log(newData);
settypeData(newData)
})
}
useEffect(() => {
queryData()
}, [])
const columns = [
{ title: '类型名', width: 100, dataIndex: 'name', key: 'name' },
{ title: 'Id', width: 100, dataIndex: 'platform', align: 'center', key: 'platform' },
{ title: '类型名', width: 100, dataIndex: 'typeName', key: 'typeName' },
{ title: 'Id', width: 100, dataIndex: 'typeId', align: 'center', key: 'typeId' },
{
title: '操作', width: 100, key: 'operation', align: 'center',
render: (text, record) => (
<Space size="middle">
<Popconfirm title="确定删除吗?" okText="确定" cancelText="取消" onConfirm={() => removeType(record)}>
<a href="#">删除</a>
</Popconfirm>
{record.isRemove && <Popconfirm title="确定删除吗?" okText="确定" cancelText="取消" onConfirm={() => removeType(record)}>
<a href="#" >删除</a>
</Popconfirm>}
<a href="#" onClick={() => changType(record)}>修改</a>
</Space>
)
},
];
const data = [{
key: 1,
name: '甲类型1',
platform: 'iOS',
version: '10.3.4.5654',
upgradeNum: 500,
creator: 'Jack',
createdAt: '2014-12-24 23:12:00',
children: [
{
key: 3,
platform: '3',
name: '子类型31',
upgradeNum: 'Upgraded: 3',
},
]
}, {
key: 2,
name: '甲类型2',
platform: 'iOS',
version: '10.3.4.5654',
upgradeNum: 500,
creator: 'Jack',
createdAt: '2014-12-24 23:12:00',
children: [
{
key: 3,
platform: '32',
name: '子类型32',
upgradeNum: 'Upgraded: 3',
},
]
}, {
key: 3,
name: '甲类型3',
platform: 'iOS',
upgradeNum: 500,
children: [
{
key: 3,
platform: '33',
name: '子类型33',
upgradeNum: 'Upgraded: 3',
},
]
}];
return (
<Modal
visible={visible}
......@@ -107,13 +96,16 @@ function RemoveType({ visible, onCancel }) {
>
<Table
columns={columns}
dataSource={data}
dataSource={typeData}
/>
{typeModal && <TypeModal
visible={typeModal}
onCancel={() =>
setTypeModal(false)
}
queryData={() =>
queryData()
}
data={oldData}
/>}
</Modal>
......
......@@ -22,14 +22,17 @@ const ToolModal = ({ visible, onCancel, data }) => {
input = {
...input,
typeId: values.type,
childType: values.childType
childTypeId: values.childType
}
console.log(input);
fetchData('/add/addToolBox', input)
.then((res) => {
if (res.success) {
message.success('新建成功')
dispatch(NEED_UPDATE_INDEX())
onCancel()
} else {
message.error('新建失败')
}
})
......@@ -40,6 +43,8 @@ const ToolModal = ({ visible, onCancel, data }) => {
message.success('修改成功')
dispatch(NEED_UPDATE_INDEX())
onCancel()
} else {
message.error('新建失败')
}
})
}
......
......@@ -5,10 +5,14 @@ import { Root } from "../dataCenter/Root";
import { NEED_UPDATE_INDEX } from "../dataCenter/action";
const { Option } = Select;
const { TabPane } = Tabs;
const TypeModal = ({ visible, onCancel, data }) => {
const TypeModal = ({ visible, onCancel, queryData, data }) => {
console.log(data);
const [form] = Form.useForm();
if (data) {
form.setFieldsValue({
typeName: data.typeName,
});
}
const formItemLayout = {
labelCol: { span: 4 },
wrapperCol: { span: 18 },
......@@ -19,9 +23,33 @@ const TypeModal = ({ visible, onCancel, data }) => {
const onCreate = (values) => {
if (data) {
console.log(data);
let input = {
typeId: '',
typeName: ''
}
if (!data.isRemove) {
input = {
typeId: data.typeId,
typeName: values.typeName
}
} else {
input = {
childTypeId: data.typeId,
childTypeName: values.typeName
}
}
fetchData('/typeManage/updateType', input)
.then((res) => {
if (res.success) {
message.success('修改成功')
dispatch(NEED_UPDATE_INDEX())
queryData()
onCancel()
}
})
} else {
console.log(values);
fetchData('/add/addType', values)
......
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