ebd701f2
by1642146903
配件计划申请页面联调
|
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import React, {useEffect, useState} from 'react';
import {Modal, Button, Select, message} from 'antd';
import useInitail from "@/hooks/useInitail";
import {getDealerApi} from "@/common/api";
interface Props {
onCancel: () => any,
visible: boolean,
dealerList: any[],
onOk: (dealer: any) => any
}
const {Option} = Select;
export default function Index({ onCancel, visible, onOk, dealerList = [] }: Props) {
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
14
|
const [dealer, setDealer] = useState<any>({ settleDealerId: null, settleDealerName: null});
|
ebd701f2
by1642146903
配件计划申请页面联调
|
15
|
const { data: dealers } = useInitail<CommonApi.OptionVO[], CommonApi.DealerParam>(getDealerApi, [], {});
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
16
|
const suIds = dealerList.map(it => it.settleDealerId);
|
ebd701f2
by1642146903
配件计划申请页面联调
|
17
18
19
20
21
22
23
24
|
useEffect(() => {
if (!visible) {
setDealer({});
}
}, [visible]);
const handSave = () => {
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
25
|
if (!dealer.settleDealerId) {
|
ebd701f2
by1642146903
配件计划申请页面联调
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
message.error('请选择采购商家');
return;
}
onOk && onOk(dealer);
onCancel && onCancel();
};
return (
<Modal
width={400}
visible={visible}
title="采购商家"
onCancel={onCancel}
footer={[
<Button key="cancel" onClick={onCancel}>取消</Button>,
<Button
key="submit"
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
43
|
disabled={!dealer.settleDealerId}
|
ebd701f2
by1642146903
配件计划申请页面联调
|
44
45
46
47
48
49
50
51
52
53
54
|
onClick={handSave}
type="primary"
htmlType="submit"
>
确认
</Button>
]}
>
<div style={{display: 'flex', flexDirection: 'row', alignItems: 'center', marginBottom: 10}}>
<span>商家:</span>
<Select
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
55
|
value={dealer.settleDealerId}
|
ebd701f2
by1642146903
配件计划申请页面联调
|
56
57
|
style={{ width: 250 }}
placeholder="请选择商家"
|
b4b59dc8
jiangwei
配件系统选择器增加搜索功能
|
58
59
|
showSearch
optionFilterProp="children"
|
79d4a3b6
jiangwei
计划管理增加草稿和继续编辑功能
|
60
61
62
|
onChange={(settleDealerId) => {
const d = dealers.find(it => it.id == settleDealerId) || {};
setDealer({ settleDealerId, settleDealerName: d.name});
|
ebd701f2
by1642146903
配件计划申请页面联调
|
63
64
65
66
67
68
69
70
71
72
|
}}
>
{dealers.filter(it => !suIds.includes(it.id)).map((b) => (
<Option value={b.id || -1} key={b.id}>{b.name || ''}</Option>
))}
</Select>
</div>
</Modal>
);
}
|