Merge remote-tracking branch 'origin/main'

perf/export-docx
Lei OT 11 months ago
commit 6dce885450

@ -1,11 +1,9 @@
import dayjs from "dayjs";
export const PROJECT_NAME = "GHHub";
// export const HT_HOST = import.meta.env.PROD ? "https://p9axztuwd7x8a7.mycht.cn" :"http://202.103.68.144:890"; //"http://202.103.68.231:889";
export const HT_HOST = import.meta.env.PROD ? "https://p9axztuwd7x8a7.mycht.cn" :"http://202.103.68.144:890"; //"http://202.103.68.231:889";
// 内部测试使用,正式环境要切换到上面的配置⬆️
export const HT_HOST = "http://202.103.68.144:890";
// export const HT_HOST = "http://202.103.68.144:890";
export const DATE_FORMAT = "YYYY-MM-DD";
export const DATE_FORMAT_MONTH = "YYYY-MM";

@ -130,6 +130,7 @@ export const useProductsStore = create(
setAgencyList: (agencyList) => set({ agencyList }),
setActiveAgency: (activeAgency) => set({ activeAgency }),
setAgencyProducts: (agencyProducts) => set({ agencyProducts }),
// TODO产品和价格会分开查询编辑
setEditingProduct: (product) => {
set(() => ({
editingProduct: product,
@ -170,12 +171,30 @@ export const useProductsStore = create(
weekdays: '5, 6'
}),
// TODO添加价格后重新读取列表
appendQuotationList: (newList) => {
set((state) => ({
quotationList: [...state.quotationList, ...newList]
}))
},
saveOrUpdateQuotation: (formValues) => {
const { quotationList } = get()
console.info('formValues: ', formValues)
const prevList = quotationList.filter(q => q.id === formValues.id)
console.info(prevList)
if (prevList.length > 0) {
const prevQuotation = prevList[0]
console.info('formValues: ', formValues)
console.info('prevQuotation: ', prevQuotation)
for (const [key, value] of Object.entries(formValues)) {
const prevValue = prevQuotation[key]
const hasChanged = prevValue === value
console.log(`${key}: ${prevValue} - ${value} (${hasChanged})`)
}
}
},
// side effects
searchAgency: async (param) => {
const { setLoading, setAgencyList } = get();

@ -637,3 +637,8 @@ export const formatColonTime = text => {
const minutes = text.substring(2);
return `${hours}:${minutes}`;
};
// 生成唯一 36 位数字,用于新增记录 ID 赋值React key 属性等
export const generateId = () => (
new Date().getTime().toString(36) + Math.random().toString(36).substring(2, 9)
)

@ -1,9 +1,9 @@
import { useEffect, useState } from 'react'
import { Table, Form, Modal, Button, Radio, Input, Flex, Card, Select, Typography, InputNumber, Checkbox, DatePicker, Space } from 'antd'
import { useTranslation } from 'react-i18next'
import dayjs from 'dayjs'
import { CloseOutlined, StarTwoTone, PlusOutlined, ExclamationCircleFilled } from '@ant-design/icons';
import { useDatePresets } from '@/hooks/useDatePresets'
import dayjs from 'dayjs'
import useProductsStore from '@/stores/Products/Index'
const { RangePicker } = DatePicker
@ -245,8 +245,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const datePresets = useDatePresets()
const [newEmptyQuotation, appendQuotationList, quotationList] =
useProductsStore((state) => [state.newEmptyQuotation, state.appendQuotationList, state.quotationList])
const [newEmptyQuotation, appendQuotationList, quotationList, saveOrUpdateQuotation] =
useProductsStore((state) => [state.newEmptyQuotation, state.appendQuotationList, state.quotationList, state.saveOrUpdateQuotation])
useEffect(() => {
console.info('quotationList: ', quotationList)
@ -266,9 +266,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
}
const onQuotationFinish = (values) => {
console.info(values)
saveOrUpdateQuotation(values)
setQuotationModalOpen(false)
// saveOrUpdateQuotation(values)
// .then(() => {
// setQuotationModalOpen(false)
// })
@ -282,20 +281,14 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
// })
}
const onQuotationFailed = (error) => {
console.log('Failed:', error)
// form.resetFields()
}
const onBatchSetupFinish = () => {
console.info(batchSetupForm.getFieldsValue())
let previewList = []
let priceList = []
const defList = batchSetupForm.getFieldsValue().defList
defList.forEach(definition => {
const previewPrice = definition?.priceList.map(price => {
const mappedPriceList = definition?.priceList.map(price => {
return {
id: 0,
id: null,
adult_cost: price.priceInput.audultPrice,
child_cost: price.priceInput.childrenPrice,
group_size_min: price.priceInput.numberStart,
@ -309,10 +302,10 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
weekdays: definition.weekend.join(','),
}
})
previewList.push(...previewPrice)
priceList.push(...mappedPriceList)
})
appendQuotationList(previewList)
appendQuotationList(priceList)
setBatchSetupModalOpen(false)
}
@ -379,18 +372,16 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
pagination={false}
/>
{
// editable &&
<Button onClick={() => onNewQuotation()} type='primary' ghost style={{ marginTop: 16 }}>
{t('products:addQuotation')}
</Button>
editable &&
<Space>
<Button onClick={() => onNewQuotation()} type='primary' ghost style={{ marginTop: 16 }}>
{t('products:addQuotation')}
</Button>
<Button onClick={() => setBatchSetupModalOpen(true)} type='primary' ghost style={{ marginTop: 16, marginLeft: 16 }}>
批量设置
</Button>
</Space>
}
{
// editable &&
<Button onClick={() => setBatchSetupModalOpen(true)} type='primary' ghost style={{ marginTop: 16, marginLeft: 16 }}>
批量设置
</Button>
}
<Modal
centered
title='批量设置价格'
@ -496,7 +487,6 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
wrapperCol={{ span: 20 }}
className='max-w-2xl'
onFinish={onQuotationFinish}
onFinishFailed={onQuotationFailed}
autoComplete='off'
>
{dom}

Loading…
Cancel
Save