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

fix: '产品配置'

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