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

feat: 门店业务回显问题

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