feat: 增加删除价格出错提示;给每个 Store 命名,方便调试

perf/export-docx
Jimmy Liow 2 years ago
parent fe562c260f
commit eba209ea15

@ -1,9 +1,8 @@
export const PROJECT_NAME = "GHHub";
// mode: test内部测试使用
export const HT_HOST = import.meta.env.MODE === 'test' ? 'http://202.103.68.144:890' : import.meta.env.PROD ? "https://p9axztuwd7x8a7.mycht.cn" : '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";

@ -1,4 +1,5 @@
import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { fetchJSON, postForm } from '@/utils/request'
import { isEmpty, isNotEmpty } from '@/utils/commons'
import { HT_HOST } from "@/config"
@ -67,7 +68,7 @@ export const fetchTravelAgencyByName = async (name) => {
return errcode !== 0 ? {} : result
}
const useAccountStore = create((set, get) => ({
const useAccountStore = create(devtools((set) => ({
accountList: [],
@ -171,6 +172,6 @@ const useAccountStore = create((set, get) => ({
accountList: mapAccoutList
}))
},
}))
}), { name: 'accountStore' }))
export default useAccountStore

@ -1,4 +1,5 @@
import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { appendRequestParams, fetchJSON, postForm } from '@/utils/request'
import { HT_HOST } from "@/config"
import { loadPageSpy } from '@/pageSpy'
@ -56,7 +57,7 @@ const initialState = {
permissionList: []
}
const useAuthStore = create((set, get) => ({
const useAuthStore = create(devtools((set, get) => ({
...initialState,
@ -197,6 +198,6 @@ const useAuthStore = create((set, get) => ({
})
},
}))
}), { name: 'authStore' }))
export default useAuthStore

@ -116,7 +116,7 @@ const useFeedbackStore = create(
setFeedbackList(filterV);
setLoading(false);
},
}))
}), { name: 'feedbackStore'})
);
export default useFeedbackStore;

@ -7,6 +7,6 @@ export const useFormStore = create(
setFormValues: (values) => set((state) => ({ formValues: { ...state.formValues, ...values } })),
formValuesToSub: {},
setFormValuesToSub: (values) => set((state) => ({ formValuesToSub: { ...state.formValuesToSub, ...values } })),
}))
}), { name: 'formStore' })
);
export default useFormStore;

@ -129,7 +129,7 @@ const useInvoiceStore = create(
setLoading(false);
},
}))
}), { name: 'invoiceStore'})
);
export default useInvoiceStore;

@ -48,6 +48,6 @@ export const useNoticeStore = create(
setNoticeUnRead(noticeUnRead);
},
}))
}), { name: 'noticeStore' })
);
export default useNoticeStore;

@ -286,24 +286,30 @@ export const useProductsStore = create(
return mergedList
},
deleteQuotation: (quotaionId) => {
deleteQuotationById: async(quotaionId) => {
const { editingProduct, quotationList, agencyProducts } = get()
const productTypeId = editingProduct.info.product_type_id;
const newList = quotationList.filter(q => {
return q.id != quotaionId
})
deleteQuotationAction(quotaionId)
set({
agencyProducts: {
...agencyProducts,
[productTypeId]: [{
...editingProduct,
quotation: newList
}]
},
quotationList: newList
})
const { result, success } = await deleteQuotationAction(quotaionId)
if (success) {
set({
agencyProducts: {
...agencyProducts,
[productTypeId]: [{
...editingProduct,
quotation: newList
}]
},
quotationList: newList
})
return Promise.resolve(result)
} else {
return Promise.reject(result)
}
},
// side effects
@ -339,6 +345,6 @@ export const useProductsStore = create(
const res = await getAgencyProductExtrasAction(param);
// todo:
},
}))
}), { name: 'productStore' })
);
export default useProductsStore;

@ -64,6 +64,6 @@ export const useReportStore = create(
setCommendScoresData(errcode === 0 ? Result : {});
// setLoading(false);
},
}))
}), { name: 'reportStore'})
);
export default useReportStore;

@ -1,4 +1,5 @@
import { create } from 'zustand'
import { devtools } from 'zustand/middleware'
import { fetchJSON, postForm } from '@/utils/request'
import { HT_HOST } from "@/config"
import { prepareUrl } from '@/utils/commons'
@ -34,7 +35,7 @@ export const fetchAttachList = async (reservationId) => {
return errcode !== 0 ? {} : result
}
const useReservationStore = create((set, get) => ({
const useReservationStore = create(devtools((set, get) => ({
cityList: [],
@ -265,6 +266,6 @@ const useReservationStore = create((set, get) => ({
}
})
}
}))
}), { name: 'reservationStore' }))
export default useReservationStore

@ -236,7 +236,6 @@ function RoleList() {
showSizeChanger: true,
showTotal: (total) => { return t('Total') + `${total}` }
}}
onChange={(pagination) => { onSearchClick(pagination.current) }}
columns={roleListColumns} dataSource={roleAllList}
/>
</Col>

@ -242,14 +242,14 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
const [isQuotationModalOpen, setQuotationModalOpen] = useState(false)
const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false)
const { modal } = App.useApp();
const { modal, notification } = App.useApp();
const [quotationForm] = Form.useForm()
const [batchSetupForm] = Form.useForm()
const datePresets = useDatePresets()
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotation] =
useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotation])
const [quotationList, newEmptyQuotation, appendQuotationList, saveOrUpdateQuotation, deleteQuotationById] =
useProductsStore((state) => [state.quotationList, state.newEmptyQuotation, state.appendQuotationList, state.saveOrUpdateQuotation, state.deleteQuotationById])
const triggerChange = (changedValue) => {
onChange?.(
@ -284,6 +284,26 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
setBatchSetupModalOpen(false)
}
const onDeleteQuotation = (quotationId) => {
modal.confirm({
title: '请确认',
icon: <ExclamationCircleFilled />,
content: '你要删除这条价格吗?',
onOk() {
deleteQuotationById(quotationId)
.catch(ex => {
console.info(ex.message)
notification.error({
message: 'Notification',
description: ex.message,
placement: 'top',
duration: 4,
})
})
},
})
}
const quotationColumns = [
{ title: t('products:adultPrice'), dataIndex: 'adult_cost', width: '4rem' },
{ title: t('products:childrenPrice'), dataIndex: 'child_cost', width: '4rem' },
@ -317,16 +337,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => {
return (
<Space>
<Button type='link' onClick={() => onQuotationSeleted(quotation)}>{t('Edit')}</Button>
<Button type='link' danger onClick={() => {
modal.confirm({
title: '请确认',
icon: <ExclamationCircleFilled />,
content: '你要删除这条价格吗?',
onOk() {
deleteQuotation(quotation.id)
},
})
}}>{t('Delete')}</Button>
<Button type='link' danger onClick={() => onDeleteQuotation(quotation.id)}>{t('Delete')}</Button>
</Space>
)
},

Loading…
Cancel
Save