搜索弄成全局
This commit is contained in:
@ -1,10 +1,9 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Modal, Input, Select, Row, Col, Table, Button, Form, Tooltip } from 'antd';
|
||||
import { Modal, Input, Select, Row, Col, Table, Button, Form, Tooltip } from 'antd';
|
||||
import { RightOutlined, LeftOutlined } from '@ant-design/icons';
|
||||
import { coscoSupplierBase } from '../services';
|
||||
import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect'
|
||||
|
||||
const { Option } = Select;
|
||||
type OptionType = { label: string; value: string };
|
||||
|
||||
const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSelect?: (selected: any[]) => void; }> = ({ visible, onCancel, onSelect }) => {
|
||||
// 查询
|
||||
@ -21,25 +20,23 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
const [rightSelected, setRightSelected] = useState<React.Key[]>([]);
|
||||
//确认 已选供应商
|
||||
const [chosenSuppliers, setChosenSuppliers] = useState<any[]>([]);
|
||||
// 境内/境外下拉数据
|
||||
const [regionOptions, setRegionOptions] = useState<OptionType[]>([]);
|
||||
//已选供应商 去重
|
||||
const filteredData = (chosenSuppliers:any, selected:any) => {
|
||||
const ids = new Set(chosenSuppliers.map((item:any) => item.id));
|
||||
const filteredData = (chosenSuppliers: any, selected: any) => {
|
||||
const ids = new Set(chosenSuppliers.map((item: any) => item.id));
|
||||
// 只把 selected 里没出现过的加进去
|
||||
const newSelected = selected.filter((item:any) => !ids.has(item.id));
|
||||
const newSelected = selected.filter((item: any) => !ids.has(item.id));
|
||||
return [...chosenSuppliers, ...newSelected];
|
||||
};
|
||||
//获取已选供应商
|
||||
const moveToRight = () => {
|
||||
const selected = tableListData.filter((item:any) => leftSelected.includes(item.id));
|
||||
const selected = tableListData.filter((item: any) => leftSelected.includes(item.id));
|
||||
const chosenSuppliersNew = filteredData(chosenSuppliers, selected);
|
||||
setChosenSuppliers(chosenSuppliersNew);
|
||||
setLeftSelected([]);
|
||||
};
|
||||
// 删除已选供应商
|
||||
const moveToLeft = () => {
|
||||
const remaining = chosenSuppliers.filter((item:any) => !rightSelected.includes(item.id));
|
||||
const remaining = chosenSuppliers.filter((item: any) => !rightSelected.includes(item.id));
|
||||
setChosenSuppliers(remaining);
|
||||
setRightSelected([]);
|
||||
};
|
||||
@ -47,7 +44,7 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
const getTableList = async (values: any = {}, pageNo: number = 1, pageSize: number = 10) => {
|
||||
setLoading(true);
|
||||
try {
|
||||
const { code, data } = await coscoSupplierBase({ ...values, basePageRequest: { pageNo, pageSize} });
|
||||
const { code, data } = await coscoSupplierBase({ ...values, basePageRequest: { pageNo, pageSize } });
|
||||
if (code === 200) {
|
||||
setTableListData(data.records);
|
||||
setPagination({ current: pageNo, pageSize, total: data.total });
|
||||
@ -58,51 +55,43 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
};
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
if(visible) {
|
||||
// 境内/境外 下拉
|
||||
setRegionOptions([
|
||||
{ label: '境内企业', value: 'dvs' },
|
||||
{ label: '境外企业', value: 'ovs' },
|
||||
{ label: '个人', value: 'pe' },
|
||||
])
|
||||
if (visible) {
|
||||
const values = form.getFieldsValue();
|
||||
getTableList(values,1 , 10)
|
||||
getTableList(values, 1, 10)
|
||||
}
|
||||
}, [visible])
|
||||
//供应商名称
|
||||
const columns = [
|
||||
{ title: '供应商名称', dataIndex: 'name', ellipsis: true, width: 160, render: (_: any, record: any) => {
|
||||
const name = record.supplierType === "ovs"? record.nameEn : record.name;
|
||||
return(
|
||||
<Tooltip placement="topLeft" title={name}>
|
||||
{name}
|
||||
</Tooltip>)
|
||||
} },
|
||||
{ title: '统一社会信用代码/税号', ellipsis: true, dataIndex: 'unifiedCode' },
|
||||
{
|
||||
title: '供应商名称', dataIndex: 'name', ellipsis: true, width: 160, render: (_: any, record: any) => {
|
||||
const name = record.supplierType === "ovs" ? record.nameEn : record.name;
|
||||
return (
|
||||
<Tooltip placement="topLeft" title={name}>
|
||||
{name}
|
||||
</Tooltip>)
|
||||
}
|
||||
},
|
||||
{ title: '统一社会信用代码/税号', ellipsis: true, dataIndex: 'unifiedCode' },
|
||||
];
|
||||
return (
|
||||
<Modal title="选择供应商" visible={visible} onCancel={onCancel} footer={null} width="80%">
|
||||
|
||||
<Form layout="inline" form={form} onFinish={getTableList} style={{ marginBottom: 16 }}>
|
||||
<Form.Item name="name" label="供应商名称">
|
||||
<Input placeholder="请输入供应商名称关键字" style={{ width: 220 }} allowClear maxLength={20} />
|
||||
</Form.Item>
|
||||
<Form.Item name="supplierType" label="境内/境外">
|
||||
<Select style={{ width: 160 }} placeholder="请选择境内/境外" allowClear>
|
||||
{regionOptions.map(opt => (
|
||||
<Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
</Form.Item>
|
||||
<Input placeholder="请输入供应商名称关键字" style={{ width: 220 }} allowClear maxLength={20} />
|
||||
</Form.Item>
|
||||
<Form.Item name="supplierType" label="企业类型">
|
||||
<RegionTypeSelect />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit">查询</Button>
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button onClick={() => {
|
||||
form.resetFields()
|
||||
const values = form.getFieldsValue();
|
||||
getTableList(values,1 , 10)
|
||||
}}>重置</Button>
|
||||
<Button onClick={() => {
|
||||
form.resetFields()
|
||||
const values = form.getFieldsValue();
|
||||
getTableList(values, 1, 10)
|
||||
}}>重置</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
|
||||
@ -116,7 +105,7 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
dataSource={tableListData}
|
||||
columns={columns}
|
||||
loading={loading}
|
||||
pagination={pagination}
|
||||
pagination={pagination}
|
||||
onChange={(pagination) => {
|
||||
const values = form.getFieldsValue();
|
||||
getTableList(values, pagination.current!, pagination.pageSize!)
|
||||
|
@ -6,7 +6,7 @@ import type { ColumnsType, TablePaginationConfig } from 'antd/es/table';
|
||||
import ViewModal from './components/ViewModal';
|
||||
import CategorySelector from '@/components/CategorySelector';
|
||||
import AdmissionTypeSelect from '@/components/CommonSelect/AdmissionTypeSelect';
|
||||
import ApprovalStatusSelec from '@/components/ApprovalStatusSelec/index';
|
||||
import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect';
|
||||
//接口
|
||||
import { getPage } from './services'
|
||||
//统一列表分页
|
||||
@ -106,7 +106,7 @@ const SupplierCategoryEntryReview: React.FC = () => {
|
||||
<CategorySelector multiple={false} style={{ width: 150 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="approveStatus" label="审批状态">
|
||||
<ApprovalStatusSelec />
|
||||
<AccessStatusSelect />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
|
@ -1,10 +1,9 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { Modal, Input, Select, Row, Col, Table, Button, Form, Tooltip } from 'antd';
|
||||
import { Modal, Input, Row, Col, Table, Button, Form, Tooltip } from 'antd';
|
||||
import { RightOutlined, LeftOutlined } from '@ant-design/icons';
|
||||
import { coscoSupplierBase } from '../services';
|
||||
import RegionTypeSelect from '@/components/CommonSelect/RegionTypeSelect'
|
||||
|
||||
const { Option } = Select;
|
||||
type OptionType = { label: string; value: string };
|
||||
const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSelect?: (selected: any[]) => void; }> = ({ visible, onCancel, onSelect }) => {
|
||||
// 查询
|
||||
const [form] = Form.useForm();
|
||||
@ -20,8 +19,6 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
const [rightSelected, setRightSelected] = useState<React.Key[]>([]);
|
||||
//确认 已选供应商
|
||||
const [chosenSuppliers, setChosenSuppliers] = useState<any[]>([]);
|
||||
// 境内/境外下拉数据
|
||||
const [regionOptions, setRegionOptions] = useState<OptionType[]>([]);
|
||||
//已选供应商 去重
|
||||
const filteredData = (chosenSuppliers:any, selected:any) => {
|
||||
const ids = new Set(chosenSuppliers.map((item:any) => item.id));
|
||||
@ -58,12 +55,6 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
// 初始化
|
||||
useEffect(() => {
|
||||
if(visible) {
|
||||
// 境内/境外 下拉
|
||||
setRegionOptions([
|
||||
{ label: '境内企业', value: 'dvs' },
|
||||
{ label: '境外企业', value: 'ovs' },
|
||||
{ label: '个人', value: 'pe' },
|
||||
])
|
||||
const values = form.getFieldsValue();
|
||||
getTableList(values,1 , 10)
|
||||
}
|
||||
@ -87,12 +78,8 @@ const SupplierSelector: React.FC<{ visible: boolean; onCancel: () => void; onSel
|
||||
<Form.Item name="name" label="供应商名称">
|
||||
<Input placeholder="请输入供应商名称关键字" style={{ width: 220 }} allowClear maxLength={100} />
|
||||
</Form.Item>
|
||||
<Form.Item name="supplierType" label="境内/境外">
|
||||
<Select style={{ width: 160 }} placeholder="请选择境内/境外" allowClear>
|
||||
{regionOptions.map(opt => (
|
||||
<Select.Option key={opt.value} value={opt.value}>{opt.label}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
<Form.Item name="supplierType" label="企业类型">
|
||||
<RegionTypeSelect />
|
||||
</Form.Item>
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ import ResultModal from './components/ResultModal';
|
||||
import CreateModal from './components/CreateModal';
|
||||
import CategorySelector from '@/components/CategorySelector';
|
||||
import AdmissionTypeSelect from '@/components/CommonSelect/AdmissionTypeSelect';
|
||||
import ApprovalStatusSelec from '@/components/ApprovalStatusSelec/index';
|
||||
import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect';
|
||||
//接口
|
||||
import { getPage, startApprove } from './services'
|
||||
//统一列表分页
|
||||
@ -149,7 +149,7 @@ const AccessManagement: React.FC = () => {
|
||||
<CategorySelector multiple={false} style={{ width: 150 }} />
|
||||
</Form.Item>
|
||||
<Form.Item name="approveStatus" label="审批状态">
|
||||
<ApprovalStatusSelec />
|
||||
<AccessStatusSelect />
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item>
|
||||
|
Reference in New Issue
Block a user