Commit 7318ca79 authored by 皮倩雯's avatar 皮倩雯

fix: '产品配置'

parent 880d6544
...@@ -5,9 +5,10 @@ const { Item } = Form; ...@@ -5,9 +5,10 @@ const { Item } = Form;
const { Option } = Select; const { Option } = Select;
const { TextArea } = Input; const { TextArea } = Input;
const EditForm = props => { const EditForm = props => {
const { productObj, editCallback, handleDel } = props; const { productObj, editCallback, handleDel, userProductsList } = props;
const [config, setConfig] = useState(''); // 网站配置信息 const [config, setConfig] = useState(''); // 网站配置信息
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [but, setBut] = useState(false);
const [form] = Form.useForm(); const [form] = Form.useForm();
const layout = { const layout = {
layout: 'horizontal', layout: 'horizontal',
...@@ -27,7 +28,16 @@ const EditForm = props => { ...@@ -27,7 +28,16 @@ const EditForm = props => {
}, },
]; ];
useEffect(() => { useEffect(() => {
console.log(8888);
console.log(productObj, 'productObj');
console.log(userProductsList);
form.setFieldsValue({ ...productObj }); form.setFieldsValue({ ...productObj });
console.log(productObj.IsUsed, 'productObj.IsUsed');
if (!productObj.IsUsed) {
setBut(true);
} else {
setBut(false);
}
}, [productObj]); }, [productObj]);
// 提交选择 // 提交选择
const submit = value => {}; const submit = value => {};
...@@ -113,10 +123,7 @@ const EditForm = props => { ...@@ -113,10 +123,7 @@ const EditForm = props => {
]} ]}
> >
{/* <Input addonBefore="//" placeholder="请输入访问路由" allowClear /> */} {/* <Input addonBefore="//" placeholder="请输入访问路由" allowClear /> */}
<Input <Input placeholder="请输入访问路由,ip加端口号,示例//localhost:3001" allowClear />
placeholder="请输入访问路由,ip加端口号,示例//localhost:3001"
allowClear
/>
</Item> </Item>
<Item <Item
...@@ -135,11 +142,8 @@ const EditForm = props => { ...@@ -135,11 +142,8 @@ const EditForm = props => {
/> />
</Item> </Item>
<div style={{ display: 'flex', marginLeft: '35%' }}> <div style={{ display: 'flex', marginLeft: '35%' }}>
<Item <Item wrapperCol={{ span: 8, offset: 8 }} style={{ marginRight: '30px' }}>
wrapperCol={{ span: 8, offset: 8 }} <Button type="primary" htmlType="submit" disabled={but}>
style={{ marginRight: '30px' }}
>
<Button type="primary" htmlType="submit">
提交 提交
</Button> </Button>
</Item> </Item>
......
...@@ -9,9 +9,11 @@ const ProductConfig = props => { ...@@ -9,9 +9,11 @@ const ProductConfig = props => {
const [addVisible, setAddVisible] = useState(false); const [addVisible, setAddVisible] = useState(false);
const [productList, setProductList] = useState([]); const [productList, setProductList] = useState([]);
const [userProductsList, setUserProductsList] = useState([]); const [userProductsList, setUserProductsList] = useState([]);
const [productObj, setProductObt] = useState(null); const [productObj, setProductObt] = useState('');
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [flag, setFlag] = useState(1); const [flag, setFlag] = useState(1);
const [list, setList] = useState(new Set());
// 默认展示第一项
useEffect(() => { useEffect(() => {
setLoading(true); setLoading(true);
getProductList() getProductList()
...@@ -21,18 +23,80 @@ const ProductConfig = props => { ...@@ -21,18 +23,80 @@ const ProductConfig = props => {
const { const {
data: { AllProducts, UserProducts }, data: { AllProducts, UserProducts },
} = res; } = res;
setProductList(AllProducts); // setProductList(AllProducts);
setUserProductsList(UserProducts);
setProductObt(AllProducts[0]);
AllProducts.map(i => {
list.add(i.ProductType);
});
let a = [];
list.map(i => {
a.push(i);
});
let aa = [];
a.map((i, j) => {
let ad = [];
AllProducts.map(k => {
if (k.ProductType == i) {
ad.push(k);
}
});
aa.push(ad);
});
console.log(aa);
// console.log(...aa);
setProductList(aa);
}
})
.finally(() => {
setLoading(false);
});
}, []);
useEffect(() => {
setLoading(true);
getProductList()
.then(res => {
const { code } = res;
if (code === 0) {
const {
data: { AllProducts, UserProducts },
} = res;
// setProductList(AllProducts);
setUserProductsList(UserProducts); setUserProductsList(UserProducts);
// if (!productObj && data.length > 0) { // if (!productObj && data.length > 0) {
// setProductObt(data[0]); // setProductObt(data[0]);
// } // }
// setProductList(data); // setProductList(data);
AllProducts.map(i => {
list.add(i.ProductType);
});
let a = [];
list.map(i => {
a.push(i);
});
let aa = [];
a.map((i, j) => {
let ad = [];
AllProducts.map(k => {
if (k.ProductType == i) {
ad.push(k);
}
});
aa.push(ad);
});
console.log(aa);
setProductList(aa);
} }
}) })
.finally(() => { .finally(() => {
setLoading(false); setLoading(false);
}); });
}, [flag]); }, [flag]);
useEffect(() => {
console.log(productObj, 'productObj1111');
}, [productObj]);
// 展示新增抽屉 // 展示新增抽屉
const handleAdd = () => { const handleAdd = () => {
setAddVisible(true); setAddVisible(true);
...@@ -44,12 +108,13 @@ const ProductConfig = props => { ...@@ -44,12 +108,13 @@ const ProductConfig = props => {
.then(res => { .then(res => {
setLoading(false); setLoading(false);
if (res.code === 0) { if (res.code === 0) {
item.IsUsed = false;
setProductObt(item);
notification.success({ notification.success({
message: '提示', message: '提示',
description: '关闭成功', description: '关闭成功',
duration: 3, duration: 3,
}); });
setProductObt('');
setFlag(flag + 1); setFlag(flag + 1);
} else { } else {
notification.error({ notification.error({
...@@ -107,6 +172,9 @@ const ProductConfig = props => { ...@@ -107,6 +172,9 @@ const ProductConfig = props => {
description: '启用成功', description: '启用成功',
duration: 3, duration: 3,
}); });
item.IsUsed = true;
console.log(item, 'item');
setProductObt(item);
setFlag(flag + 1); setFlag(flag + 1);
} else { } else {
notification.error({ notification.error({
...@@ -127,48 +195,65 @@ const ProductConfig = props => { ...@@ -127,48 +195,65 @@ const ProductConfig = props => {
} }
}; };
const handleClickItem = value => { const handleClickItem = value => {
if (userProductsList.length > 0) { // console.log(productList);
let obj = userProductsList.find(i => i.PackageName === value.PackageName); // console.log(value);
if (obj) { // let obj = productList.find(i => i.PackageName === value.PackageName);
setProductObt(obj);
} else { setProductObt(value);
message.warning({ // if (userProductsList.length > 0) {
content: '请先启用产品', // let obj = userProductsList.find(i => i.PackageName === value.PackageName);
duration: 3, // console.log(value);
}); // console.log(obj);
} // if (obj) {
} else { // setProductObt(obj);
message.warning({ // } else {
content: '请先启用产品', // message.warning({
duration: 3, // content: '请先启用产品',
}); // duration: 3,
} // });
// }
// } else {
// message.warning({
// content: '请先启用产品',
// duration: 3,
// });
// }
}; };
const renderListItem = arr => // const changeBut = value => {
arr.map(item => ( // let obj = userProductsList.find(i => i.PackageName === value.PackageName);
<List.Item // setProductObt(obj);
key={item.PackageName} // };
className={classnames({ const renderListItem = arr => (
[styles.listItem]: true, <div style={{ marginBottom: '25px' }}>
[styles.selected]: item.PackageName === productObj?.PackageName, {arr.map(item => (
})} <List.Item
onClick={() => handleClickItem(item)} key={item.PackageName}
> className={classnames({
<div onClick={e => e.stopPropagation()}> [styles.listItem]: true,
<Switch [styles.selected]: item.PackageName === productObj?.PackageName,
// size="small" })}
// defaultChecked={item.IsUsed} onClick={() => handleClickItem(item)}
checked={item.IsUsed} >
checkedChildren="启用" <div onClick={e => e.stopPropagation()}>
unCheckedChildren="关闭" <Switch
onClick={e => { // size="small"
handleSwitchClick(e, item, userProductsList); // defaultChecked={item.IsUsed}
}} checked={item.IsUsed}
/> checkedChildren="启用"
</div> unCheckedChildren="关闭"
<span className={classnames({ [styles.itemspan]: true })}>{item.ProductName}</span> onClick={e => {
</List.Item> handleSwitchClick(e, item, userProductsList);
)); }}
// onChange={changeBut(item)}
/>
</div>
<span className={classnames({ [styles.itemspan]: true })}>{`${item.ProductName}【${
item.ProductType
}】`}</span>
</List.Item>
))}
</div>
);
return ( return (
<Spin spinning={loading} tip="loading..."> <Spin spinning={loading} tip="loading...">
<div className={styles.box}> <div className={styles.box}>
...@@ -182,22 +267,37 @@ const ProductConfig = props => { ...@@ -182,22 +267,37 @@ const ProductConfig = props => {
删除 删除
</Button> */} </Button> */}
</div> </div>
{console.log(productList, 'productList')}
{productList && productList.length > 0 ? ( {productList && productList.length > 0 ? (
<List>{renderListItem(productList)}</List> // <List>{renderListItem(productList)}</List>
// <div style={}></div>
productList.map(item => renderListItem(item))
) : ( ) : (
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无数据" /> <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} description="暂无数据" />
)} )}
</Card> </Card>
<Card className={styles.rightForm}> <Card className={styles.rightForm}>
{productList && productList.length > 0 && productObj ? ( <EditForm
<EditForm productObj={productObj} editCallback={editCallback} handleDel={handleDel} /> productObj={productObj}
editCallback={editCallback}
handleDel={handleDel}
userProductsList={userProductsList}
/>
{/* {productList && productList.length > 0 && productObj ? (
<EditForm
productObj={productObj}
editCallback={editCallback}
handleDel={handleDel}
userProductsList={userProductsList}
/>
) : ( ) : (
<Empty <Empty
style={{ marginTop: '60px' }} style={{ marginTop: '60px' }}
image={Empty.PRESENTED_IMAGE_SIMPLE} image={Empty.PRESENTED_IMAGE_SIMPLE}
description="当前未选中产品类型" description="当前未选中产品类型"
/> />
)} )} */}
{/* <Drawer {/* <Drawer
title="新增产品" title="新增产品"
destroyOnClose destroyOnClose
......
...@@ -67,7 +67,7 @@ const WebConfigPage = props => { ...@@ -67,7 +67,7 @@ const WebConfigPage = props => {
}, [curWeb]); }, [curWeb]);
// 获取产品列表 // 获取产品列表
const getProduct = () => { const getProduct = () => {
getProductList().then(res => { getProductList({ isDel: 0 }).then(res => {
const { code } = res; const { code } = res;
if (code === 0) { if (code === 0) {
const { const {
......
...@@ -142,6 +142,7 @@ const SiteManage = () => { ...@@ -142,6 +142,7 @@ const SiteManage = () => {
if (arr.indexOf('系统分组') == -1) { if (arr.indexOf('系统分组') == -1) {
let childData = { visibleTitle: '系统分组', roleList: [] }; let childData = { visibleTitle: '系统分组', roleList: [] };
childData.visibleValue = i.visibleValue; childData.visibleValue = i.visibleValue;
console.log(childData.roleList);
i.child.push(childData); i.child.push(childData);
} }
} }
...@@ -637,7 +638,7 @@ const SiteManage = () => { ...@@ -637,7 +638,7 @@ const SiteManage = () => {
console.log('22222222222'); console.log('22222222222');
// 插入到第一个子节点 // 插入到第一个子节点
// 子菜单不能拖拽到二级菜单组上方 // 子菜单不能拖拽到二级菜单组上方
if (dropObj.roleList[0].groupflag) { if (dropObj.roleList[0] && dropObj.roleList[0].groupflag) {
return; return;
} }
console.log(dropObj, '33333333333'); console.log(dropObj, '33333333333');
......
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