Merge branch 'main' of github.com:hainatravel/GHHub

perf/export-docx
YCC 1 year ago
commit 31720a2930

@ -1,7 +1,7 @@
{ {
"name": "global-highlights-hub", "name": "global-highlights-hub",
"private": true, "private": true,
"version": "2.0.0-beta.2", "version": "2.0.0-beta.3",
"type": "module", "type": "module",
"scripts": { "scripts": {
"dev": "vite", "dev": "vite",

@ -3,7 +3,7 @@ import { devtools } from 'zustand/middleware';
import dayjs from 'dayjs' import dayjs from 'dayjs'
import { fetchJSON, postForm, postJSON } from '@/utils/request'; import { fetchJSON, postForm, postJSON } from '@/utils/request';
import { HT_HOST } from '@/config'; import { HT_HOST } from '@/config';
import { groupBy, generateId } from '@/utils/commons'; import { groupBy, generateId, isNotEmpty } from '@/utils/commons';
export const searchAgencyAction = async (param) => { export const searchAgencyAction = async (param) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param); const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/products_search`, param);
@ -184,7 +184,7 @@ export const useProductsStore = create(
dayjs().startOf('M'), dayjs().startOf('M'),
dayjs().endOf('M') dayjs().endOf('M')
], ],
weekdayList: ['5', '6'], weekdayList: [],
fresh: true // 标识是否是新记录,新记录才用添加列表 fresh: true // 标识是否是新记录,新记录才用添加列表
}), }),
@ -287,30 +287,43 @@ export const useProductsStore = create(
return mergedList return mergedList
}, },
deleteQuotationById: async(quotaionId) => { deleteQuotation: async(quotation) => {
const { editingProduct, quotationList, agencyProducts } = get() const { editingProduct, quotationList, agencyProducts } = get()
const productTypeId = editingProduct.info.product_type_id; const productTypeId = editingProduct.info.product_type_id;
const newList = quotationList.filter(q => { const quotationId = quotation.id
return q.id != quotaionId const newQuotationList = quotationList.filter(q => {
return q.key != quotation.key
}) })
const { result, success } = await deleteQuotationAction(quotaionId) const newProductList = agencyProducts[productTypeId].map(p => {
if (p.info.id == editingProduct.info.id) {
if (success) { return {
set({ ...editingProduct,
agencyProducts: { quotation: newQuotationList
...agencyProducts, }
[productTypeId]: [{ } else {
...editingProduct, return p
quotation: newList }
}] })
},
quotationList: newList set({
}) agencyProducts: {
return Promise.resolve(result) ...agencyProducts,
} else { [productTypeId]: newProductList
return Promise.reject(result) },
quotationList: newQuotationList
})
let promiseDelete = Promise.resolve(newQuotationList)
if (isNotEmpty(quotationId)) {
const { result, success } = await deleteQuotationAction(quotationId)
if (!success) {
promiseDelete = Promise.reject(result)
}
} }
return promiseDelete
}, },
// side effects // side effects

@ -75,6 +75,7 @@ export const NewProductModal = ({ initialValues }) => {
const handelAddProduct = (param) => { const handelAddProduct = (param) => {
const copyNewProduct = structuredClone(newProduct); const copyNewProduct = structuredClone(newProduct);
copyNewProduct.info.title = param.title; copyNewProduct.info.title = param.title;
copyNewProduct.info.product_title = param.title;
copyNewProduct.info.product_type_id = productsTypesMapVal[param.products_type.value].value; copyNewProduct.info.product_type_id = productsTypesMapVal[param.products_type.value].value;
copyNewProduct.info.product_type_name = productsTypesMapVal[param.products_type.value].label; copyNewProduct.info.product_type_name = productsTypesMapVal[param.products_type.value].label;
copyNewProduct.lgc_details[0].lgc = language; copyNewProduct.lgc_details[0].lgc = language;

@ -19,8 +19,6 @@ const batchSetupInitialValues = {
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [
'5',
'6'
], ],
'priceList': [ 'priceList': [
{ {
@ -65,8 +63,6 @@ const batchSetupInitialValues = {
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [
'5',
'6'
], ],
'priceList': [ 'priceList': [
{ {
@ -122,8 +118,6 @@ const defaultDefinitionValue = {
'unitId': '0', 'unitId': '0',
'currency': 'RMB', 'currency': 'RMB',
'weekend': [ 'weekend': [
'5',
'6'
], ],
'priceList': [ 'priceList': [
defaultPriceValue defaultPriceValue
@ -144,8 +138,8 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const datePresets = useDatePresets() const datePresets = useDatePresets()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotationById] = const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation] =
useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotationById]) useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation])
const triggerChange = (changedValue) => { const triggerChange = (changedValue) => {
onChange?.( onChange?.(
@ -180,13 +174,13 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
setBatchSetupModalOpen(false) setBatchSetupModalOpen(false)
} }
const onDeleteQuotation = (quotationId) => { const onDeleteQuotation = (quotation) => {
modal.confirm({ modal.confirm({
title: '请确认', title: '请确认',
icon: <ExclamationCircleFilled />, icon: <ExclamationCircleFilled />,
content: '你要删除这条价格吗?', content: '你要删除这条价格吗?',
onOk() { onOk() {
deleteQuotationById(quotationId) deleteQuotation(quotation)
.catch(ex => { .catch(ex => {
notification.error({ notification.error({
message: 'Notification', message: 'Notification',
@ -236,7 +230,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
return ( return (
<Space> <Space>
<Button type='link' disabled={!_rowEditable} onClick={() => onQuotationSeleted(quotation)}>{t('Edit')}</Button> <Button type='link' disabled={!_rowEditable} onClick={() => onQuotationSeleted(quotation)}>{t('Edit')}</Button>
<Button type='link' danger disabled={!_rowEditable} onClick={() => onDeleteQuotation(quotation.id)}>{t('Delete')}</Button> <Button type='link' danger disabled={!_rowEditable} onClick={() => onDeleteQuotation(quotation)}>{t('Delete')}</Button>
</Space> </Space>
) )
}, },

Loading…
Cancel
Save