Commit 5d3290d8 authored by 武广's avatar 武广

fix: 修改门店筛选问题

parent f61bb2a3
...@@ -24,6 +24,16 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -24,6 +24,16 @@ const FormRuleSetting = forwardRef((props, ref) => {
const [form] = Form.useForm(); const [form] = Form.useForm();
const customer = useContext(ServiceContext); const customer = useContext(ServiceContext);
// 判断是否有禁用的店铺 禁用店铺不显示
const getIsInShops = arr => {
const list = [];
arr.forEach(item => {
// eslint-disable-next-line no-unused-expressions
supplierIdList.some(s => +s.id === +item) && list.push(item);
});
return list;
};
useEffect(() => { useEffect(() => {
if (customer.isEdit) { if (customer.isEdit) {
if (!editData) return; if (!editData) return;
...@@ -31,6 +41,16 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -31,6 +41,16 @@ const FormRuleSetting = forwardRef((props, ref) => {
} }
}, [customer.isEdit, editData]); }, [customer.isEdit, editData]);
useEffect(() => {
if ((customer.isEdit, supplierIdList.length)) {
if (!editData) return;
const shopIds = getIsInShops(editData.shopIds);
form.setFieldsValue({
shopIds,
});
}
}, [supplierIdList]);
const onCheck = async () => { const onCheck = async () => {
try { try {
const { useTime, purchaseTime, ...values } = await form.validateFields(); const { useTime, purchaseTime, ...values } = await form.validateFields();
...@@ -98,7 +118,14 @@ const FormRuleSetting = forwardRef((props, ref) => { ...@@ -98,7 +118,14 @@ const FormRuleSetting = forwardRef((props, ref) => {
label="适用门店" label="适用门店"
rules={[{ required: true, message: '请选择适用门店!', type: 'array' }]} rules={[{ required: true, message: '请选择适用门店!', type: 'array' }]}
> >
<Select mode="multiple" placeholder="请选择适用门店"> <Select
mode="multiple"
placeholder="请选择适用门店"
showSearch
filterOption={(input, option) =>
option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
}
>
{(supplierIdList || []).map(item => ( {(supplierIdList || []).map(item => (
<Option value={+item.id} key={item.id}> <Option value={+item.id} key={item.id}>
{item.name} {item.name}
......
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