Merge remote-tracking branch 'origin/main'

perf/export-docx
Lei OT 10 months ago
commit 2c674d5a03

@ -207,7 +207,7 @@ export const useProductsStore = create(
const generatedList = [] const generatedList = []
defList.forEach(definition => { defList.forEach(definition => {
// 增加多个有效日期批量设置: definition?.useDateList.map(useDateItem => {
const mappedPriceList = definition?.priceList.map(price => { const mappedPriceList = definition?.priceList.map(price => {
return { return {
id: null, id: null,
@ -219,8 +219,8 @@ export const useProductsStore = create(
currency: definition.currency, currency: definition.currency,
unit_id: definition.unitId, unit_id: definition.unitId,
// 保持和 API 返回格式一致,日期要转换为字符串 // 保持和 API 返回格式一致,日期要转换为字符串
use_dates_start: definition.useDate[0].format('YYYY-MM-DD'), use_dates_start: useDateItem.useDate[0].format('YYYY-MM-DD'),
use_dates_end: definition.useDate[1].format('YYYY-MM-DD'), use_dates_end: useDateItem.useDate[1].format('YYYY-MM-DD'),
weekdays: definition.weekend.join(','), weekdays: definition.weekend.join(','),
WPI_SN: editingProduct.info.id, WPI_SN: editingProduct.info.id,
WPP_VEI_SN: activeAgency.travel_agency_id, WPP_VEI_SN: activeAgency.travel_agency_id,
@ -232,6 +232,7 @@ export const useProductsStore = create(
}) })
generatedList.push(...mappedPriceList) generatedList.push(...mappedPriceList)
}) })
})
const mergedList = [...quotationList,...generatedList] const mergedList = [...quotationList,...generatedList]
set(() => ({ set(() => ({

@ -1,5 +1,5 @@
import { useState } from 'react' import { useState } from 'react'
import { Table, Form, Modal, Button, Radio, Input, Flex, Card, InputNumber, Checkbox, DatePicker, Space, App, Tooltip } from 'antd' import { Table, Form, Modal, Typography, Button, Radio, Input, Flex, Card, InputNumber, Checkbox, DatePicker, Space, App, Tooltip } from 'antd'
import { useTranslation } from 'react-i18next' import { useTranslation } from 'react-i18next'
import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled, QuestionCircleOutlined, QuestionOutlined } from '@ant-design/icons' import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled, QuestionCircleOutlined, QuestionOutlined } from '@ant-design/icons'
import { useDatePresets } from '@/hooks/useDatePresets' import { useDatePresets } from '@/hooks/useDatePresets'
@ -12,9 +12,13 @@ const { RangePicker } = DatePicker
const batchSetupInitialValues = { const batchSetupInitialValues = {
'defList': [ 'defList': [
// //
{
'useDateList': [
{ {
'useDate': [ 'useDate': [
dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y') dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')
]
}
], ],
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
@ -56,9 +60,13 @@ const batchSetupInitialValues = {
] ]
}, },
// //
{
'useDateList': [
{ {
'useDate': [ 'useDate': [
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M') dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
]
}
], ],
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
@ -111,17 +119,16 @@ const defaultPriceValue = {
} }
} }
const defaultUseDate = {
'useDate': [dayjs().add(1, 'year').startOf('y'), dayjs().add(1, 'year').endOf('y')]
}
const defaultDefinitionValue = { const defaultDefinitionValue = {
'useDate': [ 'useDateList': [defaultUseDate],
dayjs().add(1, 'year').subtract(2, 'M').startOf('M'), dayjs().add(1, 'year').endOf('M')
],
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [],
], 'priceList': [defaultPriceValue]
'priceList': [
defaultPriceValue
]
} }
const ProductInfoQuotation = ({ editable, ...props }) => { const ProductInfoQuotation = ({ editable, ...props }) => {
@ -306,9 +313,25 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
options={['5', '6', '7']} options={['5', '6', '7']}
/> />
</Form.Item> </Form.Item>
<Form.Item label='有效期' name={[field.name, 'useDate']}> <Form.Item label='有效期'>
<Form.List name={[field.name, 'useDateList']}>
{(useDateFieldList, useDateOptList) => (
<Flex gap='middle' vertical>
{useDateFieldList.map((useDateField, index) => (
<Space key={useDateField.key}>
<Form.Item noStyle name={[useDateField.name, 'useDate']}>
<RangePicker style={{ width: '100%' }} allowClear={true} inputReadOnly={true} presets={datePresets} placeholder={['From', 'Thru']} /> <RangePicker style={{ width: '100%' }} allowClear={true} inputReadOnly={true} presets={datePresets} placeholder={['From', 'Thru']} />
</Form.Item> </Form.Item>
{index == 0 ? <StarTwoTone twoToneColor='#eb2f96' /> : <CloseOutlined onClick={() => useDateOptList.remove(useDateField.name)} />}
</Space>
))}
<Button type='dashed' icon={<PlusOutlined />} onClick={() => useDateOptList.add(defaultUseDate)} block>
新增有效期
</Button>
</Flex>
)}
</Form.List>
</Form.Item>
<Form.Item label='人等'> <Form.Item label='人等'>
<Form.List name={[field.name, 'priceList']}> <Form.List name={[field.name, 'priceList']}>
{(priceFieldList, priceOptList) => ( {(priceFieldList, priceOptList) => (
@ -336,6 +359,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
</Flex> </Flex>
)} )}
</Form.List> </Form.List>
<Form.Item noStyle shouldUpdate>
{() => (
<Typography>
<pre>{JSON.stringify(batchSetupForm.getFieldsValue(), null, 2)}</pre>
</Typography>
)}
</Form.Item>
</Form> </Form>
</Modal> </Modal>

Loading…
Cancel
Save