|
|
|
@ -1,14 +1,16 @@
|
|
|
|
|
import { useEffect } from 'react';
|
|
|
|
|
import { Link } from 'react-router-dom';
|
|
|
|
|
import { Row, Col, Space, Table } from 'antd';
|
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { Link, useNavigate } from 'react-router-dom';
|
|
|
|
|
import { App, Space, Table, Button, Modal } from 'antd';
|
|
|
|
|
import SearchForm from '@/components/SearchForm';
|
|
|
|
|
import dayjs from 'dayjs';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import useProductsStore from '@/stores/Products/Index';
|
|
|
|
|
import useProductsStore, { copyAgencyDataAction } from '@/stores/Products/Index';
|
|
|
|
|
import useFormStore from '@/stores/Form';
|
|
|
|
|
import { objectMapper } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
function Index() {
|
|
|
|
|
const { notification, message } = App.useApp();
|
|
|
|
|
const navigate = useNavigate()
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [loading, agencyList, searchAgency] = useProductsStore((state) => [state.loading, state.agencyList, state.searchAgency]);
|
|
|
|
|
const [searchValues, setSearchValues] = useProductsStore((state) => [state.searchValues, state.setSearchValues]);
|
|
|
|
@ -21,6 +23,24 @@ function Index() {
|
|
|
|
|
searchAgency(searchParam);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const [copyModalVisible, setCopyModalVisible] = useState(false);
|
|
|
|
|
const [sourceAgency, setSourceAgency] = useState({});
|
|
|
|
|
const [copyLoading, setCopyLoading] = useState(false);
|
|
|
|
|
const handleCopyAgency = async (toID) => {
|
|
|
|
|
setCopyLoading(true);
|
|
|
|
|
const success = await copyAgencyDataAction(sourceAgency.travel_agency_id, toID);
|
|
|
|
|
setCopyLoading(false);
|
|
|
|
|
success ? message.success('复制成功') : message.error('复制失败');
|
|
|
|
|
|
|
|
|
|
setCopyModalVisible(false);
|
|
|
|
|
navigate(`/products/${toID}/${searchValues.use_year || 'all'}/${searchValues.audit_state || 'all'}/edit`);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const openCopyModal = (from) => {
|
|
|
|
|
setSourceAgency(from);
|
|
|
|
|
setCopyModalVisible(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
// handleSearchAgency();
|
|
|
|
|
}, []);
|
|
|
|
@ -41,6 +61,7 @@ function Index() {
|
|
|
|
|
<Space size={'large'}>
|
|
|
|
|
<Link to={`/products/${r.travel_agency_id}/${searchValues.use_year || 'all'}/${searchValues.audit_state || 'all'}/edit`}>{t('Edit')}</Link>
|
|
|
|
|
<Link to={`/products/${r.travel_agency_id}/${searchValues.use_year || 'all'}/${searchValues.audit_state || 'all'}/audit`}>{t('Audit')}</Link>
|
|
|
|
|
<Button type='link' onClick={() => openCopyModal(r)}>{t('Copy')}</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
@ -69,19 +90,27 @@ function Index() {
|
|
|
|
|
handleSearchAgency(formVal);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
<Row>
|
|
|
|
|
<Col md={24} lg={24} xxl={24}>
|
|
|
|
|
<Table
|
|
|
|
|
bordered={true}
|
|
|
|
|
columns={columns}
|
|
|
|
|
dataSource={agencyList}
|
|
|
|
|
pagination={{ defaultPageSize: 20, showTotal: showTotal }}
|
|
|
|
|
loading={loading}
|
|
|
|
|
rowKey={'travel_agency_id'}
|
|
|
|
|
/>
|
|
|
|
|
</Col>
|
|
|
|
|
<Col md={24} lg={24} xxl={24}></Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Table bordered={true} columns={columns} dataSource={agencyList} pagination={{ defaultPageSize: 20, showTotal: showTotal }} loading={loading} rowKey={'travel_agency_id'} />
|
|
|
|
|
|
|
|
|
|
{/* 复制弹窗 */}
|
|
|
|
|
<Modal width={600} open={copyModalVisible} title={`复制供应商产品`} footer={false} onCancel={() => setCopyModalVisible(false)} destroyOnClose>
|
|
|
|
|
<div className='py-2'>复制源: {sourceAgency.travel_agency_name}</div>
|
|
|
|
|
<SearchForm formName='copyform' loading={copyLoading}
|
|
|
|
|
confirmText={t('Confirm')}
|
|
|
|
|
fieldsConfig={{
|
|
|
|
|
shows: ['agency'],
|
|
|
|
|
fieldProps: {
|
|
|
|
|
agency: { label: `目标${t('products:Vendor')}`, col: 12 },
|
|
|
|
|
},
|
|
|
|
|
fieldComProps: {
|
|
|
|
|
agency: { mode: null }, // 单选
|
|
|
|
|
},
|
|
|
|
|
}}
|
|
|
|
|
onSubmit={(err, formVal, filedsVal) => {
|
|
|
|
|
handleCopyAgency(formVal.agency);
|
|
|
|
|
}}
|
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
</Space>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|