Commit 02b9c78f authored by 张子雨's avatar 张子雨

feat: 门店业务回显问题

parent c2dec122
...@@ -20,6 +20,7 @@ const StoreModal = props => { ...@@ -20,6 +20,7 @@ const StoreModal = props => {
formInfo, formInfo,
status, status,
productBusiness, productBusiness,
existTakewayShop,
} = props; } = props;
const [areaAddr, setAreaAddr] = useState([]); const [areaAddr, setAreaAddr] = useState([]);
const [visibleMap, setVisibleMap] = useState(false); const [visibleMap, setVisibleMap] = useState(false);
...@@ -30,7 +31,7 @@ const StoreModal = props => { ...@@ -30,7 +31,7 @@ const StoreModal = props => {
address: '', address: '',
}); });
const [disabled, setDisabled] = useState(false); const [disabled, setDisabled] = useState(false);
const [isDisabled, setIsDisabled] = useState(true); const [isDisabled, setIsDisabled] = useState(false);
const [businessModel, setBusinessModel] = useState([ const [businessModel, setBusinessModel] = useState([
{ label: '到家外卖业务(外卖配送业务)', value: 1 }, { label: '到家外卖业务(外卖配送业务)', value: 1 },
{ label: '实物商品业务员', value: 2 }, { label: '实物商品业务员', value: 2 },
...@@ -38,30 +39,11 @@ const StoreModal = props => { ...@@ -38,30 +39,11 @@ const StoreModal = props => {
]); ]);
const divDom = useRef(); const divDom = useRef();
useEffect(() => {
setDisabled(props.status);
}, [props.status]);
useEffect(() => {
if (props.productBusiness.length) {
businessModel.forEach(item => {
if (!props.productBusiness.includes(item.value)) {
item.disabled = true;
}
if (props.existTakewayShop && item.value === 1) {
item.disabled = true;
}
});
const val = props.productBusiness.includes(1);
setIsDisabled(val);
setBusinessModel(businessModel);
}
}, [props.productBusiness]);
const handleCancel = isSuccess => { const handleCancel = isSuccess => {
resetFields(); resetFields();
onCancel(isSuccess); onCancel(isSuccess);
}; };
const onSubmit = () => { const onSubmit = () => {
validateFields(async (error, fieldsValue) => { validateFields(async (error, fieldsValue) => {
if (!error) { if (!error) {
...@@ -252,7 +234,24 @@ const StoreModal = props => { ...@@ -252,7 +234,24 @@ const StoreModal = props => {
if (visible) { if (visible) {
resetFields(); resetFields();
const info = Object.assign({}, formInfo); const info = Object.assign({}, formInfo);
console.log(info); const val = info?.productBusiness?.includes(1);
setIsDisabled(val);
if (status === 'look') {
setDisabled(true);
} else {
setDisabled(false);
}
const data = [...businessModel];
data.forEach(item => {
item.disabled = !productBusiness.includes(item.value);
if (existTakewayShop && item.value === 1 && !val) {
item.disabled = true;
} else {
item.disabled = false;
}
});
setBusinessModel(data);
if (info && info.id) { if (info && info.id) {
info.week = info.businessHours.weeks; info.week = info.businessHours.weeks;
const hours = info.businessHours.hoursItems; const hours = info.businessHours.hoursItems;
...@@ -265,6 +264,7 @@ const StoreModal = props => { ...@@ -265,6 +264,7 @@ const StoreModal = props => {
}); });
}); });
} }
info.lnglat = `${info.longitude},${info.latitude}`; info.lnglat = `${info.longitude},${info.latitude}`;
info.addr = [info.provinceId, info.cityId, info.countyId]; info.addr = [info.provinceId, info.cityId, info.countyId];
info.shopHeadImage = (info.shopHeadImage && [info.shopHeadImage]) || []; info.shopHeadImage = (info.shopHeadImage && [info.shopHeadImage]) || [];
......
...@@ -25,7 +25,7 @@ export default () => { ...@@ -25,7 +25,7 @@ export default () => {
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [storeInfo, setStoreInfo] = useState({}); const [storeInfo, setStoreInfo] = useState({});
const [areaAddr, setAreaAddr] = useState([]); const [areaAddr, setAreaAddr] = useState([]);
const [status, setStatus] = useState(); const [status, setStatus] = useState(false);
const [dataList, setDataList] = useState([]); const [dataList, setDataList] = useState([]);
const [pageNo, setPageNo] = useState(1); const [pageNo, setPageNo] = useState(1);
const [totalNum, setTotalNum] = useState(0); const [totalNum, setTotalNum] = useState(0);
...@@ -41,18 +41,17 @@ export default () => { ...@@ -41,18 +41,17 @@ export default () => {
setProductBusiness(res.productBusiness || []); setProductBusiness(res.productBusiness || []);
setExistTakewayShop(res.existTakewayShop); setExistTakewayShop(res.existTakewayShop);
} }
setVisible(true);
}; };
const onCreate = () => { const onCreate = () => {
setStatus('add');
setStoreInfo({}); setStoreInfo({});
setVisible(true);
getBusiness(); getBusiness();
}; };
const onShowInfo = (info, val) => { const onShowInfo = (info, val) => {
setStoreInfo(info); setStoreInfo(info);
const value = val !== 'edit'; setStatus(val);
setStatus(value);
setVisible(true);
getBusiness(); getBusiness();
}; };
...@@ -272,7 +271,7 @@ export default () => { ...@@ -272,7 +271,7 @@ export default () => {
fixed: 'right', fixed: 'right',
render: (val, r) => ( render: (val, r) => (
<div className={style.actionBtn}> <div className={style.actionBtn}>
<Button key="look" onClick={() => onShowInfo(r)}> <Button key="look" onClick={() => onShowInfo(r, 'look')}>
查看 查看
</Button> </Button>
<Button key="seek" onClick={() => onShowInfo(r, 'edit')}> <Button key="seek" onClick={() => onShowInfo(r, 'edit')}>
......
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