From 2e535eedfbc942a2362ca571257680e48edce0b5 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 10 Sep 2024 10:47:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=AE=8C=E6=88=90=E5=90=88=E5=90=8C?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/locales/zh/products.json | 1 + src/stores/Products/Index.js | 68 ++++++++++++++++++- src/views/account/Management.jsx | 5 ++ src/views/products/Detail/Header.jsx | 2 + .../products/Detail/ProductInfoQuotation.jsx | 2 +- 5 files changed, 76 insertions(+), 2 deletions(-) diff --git a/public/locales/zh/products.json b/public/locales/zh/products.json index fbd6c94..a0ef6fa 100644 --- a/public/locales/zh/products.json +++ b/public/locales/zh/products.json @@ -1,5 +1,6 @@ { "ProductType": "项目类型", + "ContractRemarks": "合同备注", "type": { "Experience": "综费", "Car": "车费", diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 7e51280..61e49d1 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -137,6 +137,32 @@ export const deleteQuotationAction = async (id) => { return { errcode, result, success: errcode === 0 }; } +/** + * 获取合同备注 + */ +export const fetchRemarkList = async (params) => { + const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_memo_get`, params) + return { errcode, result, success: errcode === 0 } +} + +/** + * 获取合同备注 + */ +export const postRemarkList = async (params) => { + const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_memo_add`, params) + return { errcode, result, success: errcode === 0 } +} + +const defaultRemarkList = [ + {id: 0, "product_type_id": "6","Memo": ""}, + {id: 0, "product_type_id": "B","Memo": ""}, + {id: 0, "product_type_id": "J","Memo": ""}, + {id: 0, "product_type_id": "Q","Memo": ""}, + {id: 0, "product_type_id": "7","Memo": ""}, + {id: 0, "product_type_id": "R","Memo": ""}, + {id: 0, "product_type_id": "D","Memo": ""} +] + const initialState = { loading: false, searchValues: {}, // 客服首页: 搜索条件 @@ -148,7 +174,8 @@ const initialState = { quotationList: [], // 编辑页: 当前产品报价列表 editing: false, switchParams: {}, // 头部切换参数 -}; +} + export const useProductsStore = create( devtools((set, get) => ({ // 初始化状态 @@ -193,6 +220,45 @@ export const useProductsStore = create( reset: () => set(initialState), + getRemarkList: async() => { + const {switchParams} = get() + const { result, success } = await fetchRemarkList({ + travel_agency_id: switchParams.travel_agency_id, use_year: switchParams.use_year + }) + if (success) { + const mapRemarkList = defaultRemarkList.map(remark => { + const filterResult = result.filter(r => r.product_type_id === remark.product_type_id) + if (filterResult.length > 0) return filterResult[0] + else return remark + }) + + return Promise.resolve(mapRemarkList) + } else { + return Promise.resolve('获取合同备注失败') + } + }, + + saveOrUpdateRemark: async(remarkList) => { + const {switchParams} = get() + + const mapRemarkList = remarkList.map(remark => { + return { + id: remark.id, + travel_agency_id: switchParams.travel_agency_id, + use_year: switchParams.use_year, + product_type_id: remark.product_type_id, + Memo: remark.Memo, + } + }) + + const { result, success } = await postRemarkList(mapRemarkList) + if (success) { + return Promise.resolve(result) + } else { + return Promise.resolve('保存合同备注失败') + } + }, + newEmptyQuotation: () => ({ id: null, adult_cost: 0, diff --git a/src/views/account/Management.jsx b/src/views/account/Management.jsx index 2d337d6..7e51825 100644 --- a/src/views/account/Management.jsx +++ b/src/views/account/Management.jsx @@ -128,6 +128,11 @@ function Management() { const onAccountFinish = (values) => { saveOrUpdateAccount(values) .then(() => { + notification.info({ + message: 'Notification', + description: '账号保存成功', + placement: 'top', + }) setAccountModalOpen(false) handelAccountSearch() }) diff --git a/src/views/products/Detail/Header.jsx b/src/views/products/Detail/Header.jsx index ed1c218..03743b5 100644 --- a/src/views/products/Detail/Header.jsx +++ b/src/views/products/Detail/Header.jsx @@ -14,6 +14,7 @@ import dayjs from 'dayjs'; import VendorSelector from '@/components/VendorSelector'; import AuditStateSelector from '@/components/AuditStateSelector'; import NewProductModal from './NewProductModal'; +import ContractRemarksModal from './ContractRemarksModal' import AgencyContract from '../Print/AgencyContract_v0903'; import { saveAs } from "file-saver"; @@ -190,6 +191,7 @@ const Header = ({ refresh, ...props }) => { {t('products:auditStateAction.Rejected')} + {/* todo: export, 审核完成之后才能导出 */} diff --git a/src/views/products/Detail/ProductInfoQuotation.jsx b/src/views/products/Detail/ProductInfoQuotation.jsx index b7bf7c5..22a84eb 100644 --- a/src/views/products/Detail/ProductInfoQuotation.jsx +++ b/src/views/products/Detail/ProductInfoQuotation.jsx @@ -139,7 +139,7 @@ const ProductInfoQuotation = ({ editable, ...props }) => { const [isQuotationModalOpen, setQuotationModalOpen] = useState(false) const [isBatchSetupModalOpen, setBatchSetupModalOpen] = useState(false) - const { modal, notification } = App.useApp(); + const { modal, notification } = App.useApp() const [quotationForm] = Form.useForm() const [batchSetupForm] = Form.useForm()