From 596dcbd5b05977c75a31cc54e11fe95a54422d58 Mon Sep 17 00:00:00 2001 From: Jimmy Liow Date: Tue, 10 Sep 2024 10:48:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E5=90=88=E5=90=8C?= =?UTF-8?q?=E5=A4=87=E6=B3=A8=E8=A1=A8=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../products/Detail/ContractRemarksModal.jsx | 93 +++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/views/products/Detail/ContractRemarksModal.jsx diff --git a/src/views/products/Detail/ContractRemarksModal.jsx b/src/views/products/Detail/ContractRemarksModal.jsx new file mode 100644 index 0000000..a9037cc --- /dev/null +++ b/src/views/products/Detail/ContractRemarksModal.jsx @@ -0,0 +1,93 @@ +import { useState } from 'react' +import { Form, Modal, Input, Button, Flex, App } from 'antd' +import { useTranslation } from 'react-i18next' +import useProductsStore from '@/stores/Products/Index' +import { useProductsTypesMapVal } from '@/hooks/useProductsSets' +import RequireAuth from '@/components/RequireAuth' +import { PERM_PRODUCTS_OFFER_PUT } from '@/config' + +export const ContractRemarksModal = () => { + const { t } = useTranslation() + + const { notification } = App.useApp() + const productsTypesMapVal = useProductsTypesMapVal() + const [getRemarkList, saveOrUpdateRemark] = useProductsStore((state) => [ + state.getRemarkList, state.saveOrUpdateRemark + ]) + + const [isRemarksModalOpen, setRemarksModalOpen] = useState(false) + const [remarksForm] = Form.useForm() + + const onRemarksFinish = () => { + const remarkList = remarksForm.getFieldsValue().remarkList + saveOrUpdateRemark(remarkList) + .then(() => { + notification.info({ + message: 'Notification', + description: '合同备注保存成功', + placement: 'top', + }) + }) + .catch(ex => { + notification.error({ + message: 'Notification', + description: ex.message, + placement: 'top', + }) + }) + } + + const handleContractRemarks = () => { + getRemarkList() + .then(list => { + remarksForm.setFieldsValue({remarkList:list}) + }) + + setRemarksModalOpen(true) + } + + const getFieldLabel = (field) => { + const remarkList = remarksForm.getFieldsValue([['remarkList']]).remarkList + return productsTypesMapVal[remarkList[field.key].product_type_id]?.label + } + + return ( + <> + + + + + onRemarksFinish()} + onCancel={() => setRemarksModalOpen(false)} + destroyOnClose + forceRender + > +
+ + {(fields) => ( + + {fields.map((field) => ( + + + + ))} + + )} + +
+
+ + ); +}; +export default ContractRemarksModal