From ce39764f08fb5adf3df278c0c3a708a375e36f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=99=E6=99=AF=E5=AD=A6?= <5412262+sun_jing_xue@user.noreply.gitee.com> Date: Tue, 29 Jul 2025 16:18:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=93=81=E7=B1=BB=E9=A1=B9?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=90=8D=E7=A7=B0=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/ContactsInfoFormModal.tsx | 102 ++++++++++++----- .../supplierAdmissionStatistics.tsx | 12 +- .../components/CreateModal.tsx | 51 +++++++-- .../components/ViewModal.tsx | 11 +- .../components/ViewModal.tsx | 53 +++++---- .../components/ViewModal.tsx | 30 ++++- .../components/CreateModal.tsx | 105 ++++++++++++------ .../components/DivisionModal.tsx | 20 ++-- .../components/ViewModal.tsx | 50 ++++++--- .../components/ViewModal.tsx | 52 ++++++--- .../components/CategoryAddModal.tsx | 46 ++++++-- .../components/SupplierListModal.tsx | 23 +++- .../category/CategoryLibraryManage/index.tsx | 36 ++++-- .../components/ViewModal.tsx | 64 ++--------- .../category/CategoryLibraryReview/index.tsx | 15 ++- .../components/SupplierAddModal.tsx | 15 ++- .../category/SupplierEntryManage/index.tsx | 17 ++- .../components/ViewModal.tsx | 13 ++- .../category/SupplierEntryReview/index.tsx | 16 ++- .../components/CreateBlacklistModal.tsx | 7 +- .../components/SupplierSelectModal.tsx | 2 + .../components/ViewBlacklistModal.tsx | 51 ++++++--- .../blacklistManage/index.tsx | 2 +- .../components/CreateBlacklistModal.tsx | 5 +- 24 files changed, 541 insertions(+), 257 deletions(-) diff --git a/src/components/CompanyInfo/component/ContactsInfoFormModal.tsx b/src/components/CompanyInfo/component/ContactsInfoFormModal.tsx index f92731d..6ce3ba2 100644 --- a/src/components/CompanyInfo/component/ContactsInfoFormModal.tsx +++ b/src/components/CompanyInfo/component/ContactsInfoFormModal.tsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Modal, Form, Input, message, Row, Col, Descriptions, Tree } from 'antd'; +import { Modal, Form, Input, message, Row, Col, Descriptions, Tree, Spin } from 'antd'; //接口 import { coscoSupplierUserView, coscoSupplierUserAdd, coscoSupplierUserEdit, categoryTree } from '../services'; @@ -17,11 +17,36 @@ interface viewDataData { contactsEmail?: string; categoryName?: string; categoryNameList?: string[]; + coscoSupplierUserCategoryList: coscoSupplierUserCategory[] +} +interface coscoSupplierUserCategory { + categoryName: string; + categoryId: string; + supplierUserId: string; } interface SupplierUserCategory { categoryId: string; supplierUserId?: string; - } +} + +interface CategoryNode { + key: string; + title: string; + children?: CategoryNode[]; +} + +function flattenTree( + tree: CategoryNode[], + map: Record = {} +): Record { + tree.forEach((node) => { + map[node.key] = node.title; + if (node.children) flattenTree(node.children, map); + }); + return map; +} + + const InvoiceFormModal: React.FC = ({ visible, onOk, @@ -33,11 +58,12 @@ const InvoiceFormModal: React.FC = ({ // 新增与修改 const [form] = Form.useForm(); //查看 - const [viewData, setViewData] = useState({}); + const [viewData, setViewData] = useState(); //品类选择 const [checkedKeys, setCheckedKeys] = useState([]); //品类选择渲染数据 const [categoriesTreeData, setCategoriesTreeData] = useState([]); + const [treeLoading, setTreeLoading] = useState(true); //提交防抖 const [submitting, setSubmitting] = useState(false); useEffect(() => { @@ -56,22 +82,25 @@ const InvoiceFormModal: React.FC = ({ setCheckedKeys( (fields.coscoSupplierUserCategoryList || []).map( - (item: SupplierUserCategory) => item.categoryId + (item: SupplierUserCategory) => item.categoryId ) - ); + ); setViewData(fields); } }); } else { form.resetFields(); - setCheckedKeys([]); + setCheckedKeys([]); } + setTreeLoading(true); categoryTree().then((res) => { const { code, data } = res; if (code == 200) { setCategoriesTreeData(data) } - }) + }).finally(() => { + setTreeLoading(false); + }); } }, [visible, initialValues]); //品类选择数据中字段转换 @@ -112,8 +141,16 @@ const InvoiceFormModal: React.FC = ({ const leafKeys = findLeafKeys(convertTreeData(categoriesTreeData)); const onlyLeafChecked = keys.filter(key => leafKeys.includes(String(key))); + // 平铺tree获取id=>title映射 + const keyTitleMap = flattenTree(convertTreeData(categoriesTreeData)); + // 拼 categoryItem 数组 + const coscoSupplierUserCategoryList = onlyLeafChecked.map((id) => ({ + categoryId: id, + categoryName: keyTitleMap[id] || '', + })); + setCheckedKeys(keys); // UI 显示用,还是全量 - form.setFieldsValue({ categoryIdList: onlyLeafChecked }); // 只存叶子到表单 + form.setFieldsValue({ categoryIdList: onlyLeafChecked, coscoSupplierUserCategoryList }); // 只存叶子到表单 }; // 提交 const handleFinish = async () => { @@ -126,7 +163,6 @@ const InvoiceFormModal: React.FC = ({ supplierId: userId, }; console.log(payload); - if (!values.id) { coscoSupplierUserAdd(payload).then((res) => { if (res.code == 200) { @@ -167,12 +203,12 @@ const InvoiceFormModal: React.FC = ({ size="middle" labelStyle={{ width: 160 }} > - {viewData.contactsName} - {viewData.contactsPhone} - {viewData.contactsEmail} + {viewData?.contactsName} + {viewData?.contactsPhone} + {viewData?.contactsEmail} - {viewData.categoryNameList && viewData.categoryNameList.map((item) => { - return
{item}
+ {viewData?.coscoSupplierUserCategoryList && viewData.coscoSupplierUserCategoryList.map((item) => { + return
{item.categoryName}
})}
@@ -202,24 +238,32 @@ const InvoiceFormModal: React.FC = ({ + + + - + {treeLoading ? ( +
+ +
+ ) : ( + )}
diff --git a/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx b/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx index 87f6b08..2042056 100644 --- a/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx +++ b/src/pages/dataStatistics/supplierAdmissionStatistics/supplierAdmissionStatistics.tsx @@ -136,8 +136,8 @@ const SupplierAnnualStatistics: React.FC = () => { }, { title: intl.formatMessage({ id: 'dataStatistics.common.accessUnit' }), - dataIndex: 'accessUnit', - key: 'accessUnit', + dataIndex: 'orgName', + key: 'orgName', width: 180, ellipsis: { showTitle: false, @@ -150,14 +150,14 @@ const SupplierAnnualStatistics: React.FC = () => { }, { title: intl.formatMessage({ id: 'dataStatistics.common.accessDept' }), - dataIndex: 'accessDept', - key: 'accessDept', + dataIndex: 'deptName', + key: 'deptName', width: 120, }, { title: intl.formatMessage({ id: 'dataStatistics.common.accessYear' }), - dataIndex: 'accessYear', - key: 'accessYear', + dataIndex: 'updateYear', + key: 'updateYear', width: 100, render: (year: string) => intl.formatMessage({ id: 'dataStatistics.common.yearFormat' }, { year }), diff --git a/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx b/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx index 97b0bd0..30a851f 100644 --- a/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx +++ b/src/pages/supplier/admission/SupplierCategoryEntry/components/CreateModal.tsx @@ -1,11 +1,26 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Form, Button, Tree, message, Input } from 'antd'; +import { Modal, Form, Button, Tree, message, Input, Spin } from 'antd'; //组件 import SupplierSelector from './SupplierSelector'; import AccessDepartmentSelect from '@/components/AccessDepartmentSelect'; // 请求 import { categoryTree, add } from '../services'; +interface CategoryNode { + key: string; + title: string; + children?: CategoryNode[]; +} +function flattenTree( + tree: CategoryNode[], + map: Record = {} +): Record { + tree.forEach((node) => { + map[node.key] = node.title; + if (node.children) flattenTree(node.children, map); + }); + return map; +} // 主体 const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ visible, onCancel }) => { @@ -21,6 +36,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi //品类选择渲染数据 const [categoriesTreeData, setCategoriesTreeData] = useState([]); //提交防抖 + const [treeLoading, setTreeLoading] = useState(true); const [submitting, setSubmitting] = useState(false); //品类选择数据中字段转换 const convertTreeData = (data: any) => { @@ -60,11 +76,17 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi const leafKeys = findLeafKeys(convertTreeData(categoriesTreeData)); const onlyLeafChecked = keys.filter(key => leafKeys.includes(String(key))); - console.log(onlyLeafChecked, 'onlyLeafChecked', leafKeys, keys); + // 平铺tree获取id=>title映射 + const keyTitleMap = flattenTree(convertTreeData(categoriesTreeData)); + // 拼 categoryItem 数组 + const coscoAccessCategoryList = onlyLeafChecked.map((id) => ({ + categoryId: id, + categoryName: keyTitleMap[id] || '', + })); setCheckedKeys(keys); // UI 显示用,还是全量 - form.setFieldsValue({ categoryIds: onlyLeafChecked }); // 只存叶子到表单 + form.setFieldsValue({ categoryIds: onlyLeafChecked, coscoAccessCategoryList }); // 只存叶子到表单 // ============================== // 增加自动拼标题的逻辑 @@ -123,6 +145,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi }; categoryIds: string[]; supplierIds: string[]; + coscoAccessCategoryList: { categoryName: string; categoryId: string; }[]; } = { coscoAccessWork: { accessWorkName: '', @@ -130,7 +153,8 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi orgId: '', }, categoryIds: [], - supplierIds: [], + coscoAccessCategoryList: [], + supplierIds: [], }; //标题名称 finalPayload.coscoAccessWork.accessWorkName = values.accessWorkName; @@ -139,7 +163,8 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi //准入单位 finalPayload.coscoAccessWork.orgId = values.orgId; //品类选择 - finalPayload.categoryIds = values.categoryIds; + finalPayload.coscoAccessCategoryList = values.coscoAccessCategoryList; + // finalPayload.categoryIds = values.categoryIds; //选择供应商 if (values.supplier.length != 0) { values.supplier.forEach((item: { id: string }) => { @@ -168,12 +193,15 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi //初始化 useEffect(() => { if (visible) { + setTreeLoading(true); categoryTree().then((res) => { const { code, data } = res; if (code == 200) { setCategoriesTreeData(data) } - }) + }).finally(() => { + setTreeLoading(false); + }); } }, [visible, form]); return ( @@ -230,12 +258,19 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi {`${form.getFieldValue('supplier') ? form.getFieldValue('supplier')[0].supplierType === 'ovs' ? form.getFieldValue('supplier')[0].nameEn : form.getFieldValue('supplier')[0].name : ''}`} - + + + + {treeLoading ? ( +
+ +
+ ) : ( void; }> = ({ vi padding: 8, borderRadius: 4, }} - /> + />)}
diff --git a/src/pages/supplier/admission/SupplierCategoryEntry/components/ViewModal.tsx b/src/pages/supplier/admission/SupplierCategoryEntry/components/ViewModal.tsx index 7f04edd..04ec023 100644 --- a/src/pages/supplier/admission/SupplierCategoryEntry/components/ViewModal.tsx +++ b/src/pages/supplier/admission/SupplierCategoryEntry/components/ViewModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Descriptions } from 'antd'; +import { Modal, Descriptions, Spin } from 'antd'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; import { coscoAccessWorkCategory } from '../services' @@ -34,21 +34,26 @@ const ViewModal: React.FC<{ //渲染数据 const [data, setData] = useState(null); const supplierDetailModal = useSupplierDetailModal(); + const [loading, setLoading] = useState(false); //初始化 useEffect(() => { if (record.id) { + setLoading(true); coscoAccessWorkCategory(record.id).then((res) => { const { code, data } = res; if (code == 200) { setData(data) } - }) + }).finally(() => setLoading(false)); + } else { + setData(null); } }, [record]) return ( + {data && ( {data.coscoAccessWork.deptName} @@ -69,7 +74,7 @@ const ViewModal: React.FC<{ {data.coscoAccessWork.approveStatusText} - )} + )} ); }; diff --git a/src/pages/supplier/admission/SupplierCategoryEntryReview/components/ViewModal.tsx b/src/pages/supplier/admission/SupplierCategoryEntryReview/components/ViewModal.tsx index 8029af8..6ee71ad 100644 --- a/src/pages/supplier/admission/SupplierCategoryEntryReview/components/ViewModal.tsx +++ b/src/pages/supplier/admission/SupplierCategoryEntryReview/components/ViewModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Descriptions } from 'antd'; +import { Modal, Descriptions, Spin } from 'antd'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; import { coscoAccessWorkCategory } from '../services' @@ -34,43 +34,48 @@ const ViewModal: React.FC<{ //渲染数据 const [data, setData] = useState(null); const supplierDetailModal = useSupplierDetailModal(); + const [loading, setLoading] = useState(false); //初始化 useEffect(() => { if (record.id) { + setLoading(true); coscoAccessWorkCategory(record.id).then((res) => { const { code, data } = res; if (code == 200) { setData(data) } - }) + }).finally(() => setLoading(false)); + } else { + setData(null); } }, [record]) return ( - {data && ( - - {data.coscoAccessWork.deptName} - - {data.coscoAccessSupplierList.map((item) => { - return ( -
supplierDetailModal?.(item.supplierId)} >{item.supplierName}
- ) - })} -
- - {data.coscoAccessCategoryList.map((item) => { - return ( -
{item.categoryName}
- ) - })} -
- - {data.coscoAccessWork.approveStatusText} -
- )} -
+ + {data && ( + + {data.coscoAccessWork.deptName} + + {data.coscoAccessSupplierList.map((item) => { + return ( +
supplierDetailModal?.(item.supplierId)} >{item.supplierName}
+ ) + })} +
+ + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })} +
+ + {data.coscoAccessWork.approveStatusText} +
+ )}
+ ); }; diff --git a/src/pages/supplier/admission/SupplierEntryReview/components/ViewModal.tsx b/src/pages/supplier/admission/SupplierEntryReview/components/ViewModal.tsx index 06bf517..03f24be 100644 --- a/src/pages/supplier/admission/SupplierEntryReview/components/ViewModal.tsx +++ b/src/pages/supplier/admission/SupplierEntryReview/components/ViewModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Descriptions } from 'antd'; +import { Modal, Descriptions, Spin } from 'antd'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; import { coscoAccessWork } from '../services' @@ -50,20 +50,26 @@ const ViewModal: React.FC<{ //渲染数据 const [data, setData] = useState(null); const supplierDetailModal = useSupplierDetailModal(); + const [loading, setLoading] = useState(false); + //初始化 useEffect(() => { if (record) { + setLoading(true); coscoAccessWork(record).then((res) => { const { code, data } = res; if (code == 200) { setData(data) } - }) + }).finally(() => setLoading(false)); + } else { + setData(null); } }, [record]) return ( + {data && ( {data.coscoAccessWork.deptName} @@ -77,6 +83,13 @@ const ViewModal: React.FC<{ {data.coscoAccessWork.accessType === 'scattered' && ( <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })} +
{data.coscoAccessWork.accessDesc} {data.coscoAccessWorkAttachments.fileName} @@ -84,12 +97,21 @@ const ViewModal: React.FC<{ )} {data.coscoAccessWork.accessType === 'offline' && ( + <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })} +
{data.coscoAccessWorkAttachments.fileName} + + )} - {data.coscoAccessWork.accessType === 'online' && ( <> @@ -113,7 +135,7 @@ const ViewModal: React.FC<{ )}
- )} + )}
); }; diff --git a/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx b/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx index a2501e8..ee80d66 100644 --- a/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx +++ b/src/pages/supplier/admission/admissionManagement/components/CreateModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Form, Button, Tree, message, DatePicker, Radio, Upload, Input } from 'antd'; +import { Modal, Form, Button, Tree, message, DatePicker, Radio, Upload, Input, Spin } from 'antd'; import { UploadOutlined } from '@ant-design/icons'; import type { UploadFile } from 'antd/es/upload/interface'; //组件 @@ -25,6 +25,23 @@ interface ReviewerSelectorData { selected: Reviewer[]; leader: Reviewer | null; } + +interface CategoryNode { + key: string; + title: string; + children?: CategoryNode[]; +} + +function flattenTree( + tree: CategoryNode[], + map: Record = {} +): Record { + tree.forEach((node) => { + map[node.key] = node.title; + if (node.children) flattenTree(node.children, map); + }); + return map; +} // 主体 const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ visible, onCancel }) => { @@ -47,6 +64,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi const [reviewerModalVisible, setReviewerModalVisible] = useState(false); const [divisionModalVisible, setDivisionModalVisible] = useState(false); //提交防抖 + const [treeLoading, setTreeLoading] = useState(true); const [submitting, setSubmitting] = useState(false); //品类选择渲染数据 const [categoriesTreeData, setCategoriesTreeData] = useState([]); @@ -88,8 +106,16 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi const leafKeys = findLeafKeys(convertTreeData(categoriesTreeData)); const onlyLeafChecked = keys.filter(key => leafKeys.includes(String(key))); + // 平铺tree获取id=>title映射 + const keyTitleMap = flattenTree(convertTreeData(categoriesTreeData)); + // 拼 categoryItem 数组 + const coscoAccessCategoryList = onlyLeafChecked.map((id) => ({ + categoryId: id, + categoryName: keyTitleMap[id] || '', + })); + setCheckedKeys(keys); // UI 显示用,还是全量 - form.setFieldsValue({ categoryIds: onlyLeafChecked }); // 只存叶子到表单 + form.setFieldsValue({ categoryIds: onlyLeafChecked, coscoAccessCategoryList }); // 只存叶子到表单 }; // 选择准入方式 const onMethodChange = (e: any) => { @@ -157,6 +183,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi categoryIds: string[]; supplierIds: string[]; coscoAccessUserls: { userId: string; deptId: string; isLeader: number }[]; + coscoAccessCategoryList: { categoryName: string; categoryId: string; }[]; coscoAccessItems: { itemName: string; reviewBy: string[] }[]; coscoAccessWorkAttachments: any; attachmentsType: any; @@ -173,11 +200,12 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi categoryIds: [], supplierIds: [], coscoAccessUserls: [], + coscoAccessCategoryList: [], coscoAccessItems: [], coscoAccessWorkAttachments: {}, attachmentsType: {}, }; - + //标题名称 finalPayload.coscoAccessWork.accessWorkName = values.accessWorkName; //准入方式 @@ -189,7 +217,8 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi // 准入说明 finalPayload.coscoAccessWork.accessDesc = values.accessDesc; //品类选择 - finalPayload.categoryIds = values.categoryIds; + finalPayload.coscoAccessCategoryList = values.coscoAccessCategoryList; + // finalPayload.categoryIds = values.categoryIds; //选择供应商 values.supplier.forEach((item: { id: string }) => { finalPayload.supplierIds.push(item.id) @@ -218,35 +247,38 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi }); } else { // 供应商符合性审查 - if(values.supplierCompliance) { + if (values.supplierCompliance) { finalPayload.coscoAccessWorkAttachments = values.supplierCompliance[0].response; finalPayload.coscoAccessWorkAttachments.fileUrl = values.supplierCompliance[0].response.url; } } const res = await add(finalPayload); if (res?.success) { - message.success('创建成功'); - form.resetFields(); - setCheckedKeys([]); - setSelectedReviewers({ selected: [], leader: null, }); - setAdmissionMethod('online'); - onCancel(); + message.success('创建成功'); + form.resetFields(); + setCheckedKeys([]); + setSelectedReviewers({ selected: [], leader: null, }); + setAdmissionMethod('online'); + onCancel(); } else { - message.error('创建失败'); + message.error('创建失败'); } } finally { - setSubmitting(false); // 无论成功失败都解锁 + setSubmitting(false); // 无论成功失败都解锁 } }; //初始化 useEffect(() => { if (visible) { + setTreeLoading(true); categoryTree().then((res) => { const { code, data } = res; if (code == 200) { setCategoriesTreeData(data) } - }) + }).finally(() => { + setTreeLoading(false); + }); form.setFieldsValue({ method: 'online' }); } }, [visible, form]); @@ -291,7 +323,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi name="deptId" rules={[{ required: true, message: '请选择准入部门' }]} > - +
@@ -308,27 +340,34 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi 零星采购/应急采购/个人供应商 - + + + - + {treeLoading ? ( +
+ +
+ ) : ( + )}
void; }> = ({ vi label="评审分工" name="division" rules={[ - { + { required: true, validator: (_, value) => { if (!value || !Array.isArray(value) || value.length === 0) { @@ -495,7 +534,7 @@ const CreateModal: React.FC<{ visible: boolean; onCancel: () => void; }> = ({ vi )} - diff --git a/src/pages/supplier/admission/admissionManagement/components/DivisionModal.tsx b/src/pages/supplier/admission/admissionManagement/components/DivisionModal.tsx index afb32d2..b81f04f 100644 --- a/src/pages/supplier/admission/admissionManagement/components/DivisionModal.tsx +++ b/src/pages/supplier/admission/admissionManagement/components/DivisionModal.tsx @@ -66,13 +66,19 @@ const DivisionModal: React.FC<{ }; //全部评审项 多选 const handleReviewerCheckAllColumn = (reviewerKey: string, checked: boolean) => { - const newData = data.map(row => ({ - ...row, - reviewerChecks: { - ...row.reviewerChecks, - [reviewerKey]: checked, - }, - })); + const newData = data.map(row => { + const reviewerChecks = { ...row.reviewerChecks }; + if (checked) { + reviewerChecks[reviewerKey] = true; + } else { + // 取消全选时,彻底移除这个key + delete reviewerChecks[reviewerKey]; + } + return { + ...row, + reviewerChecks, + }; + }); setData(newData); }; diff --git a/src/pages/supplier/admission/admissionManagement/components/ViewModal.tsx b/src/pages/supplier/admission/admissionManagement/components/ViewModal.tsx index 88e4d9a7..06d47d7 100644 --- a/src/pages/supplier/admission/admissionManagement/components/ViewModal.tsx +++ b/src/pages/supplier/admission/admissionManagement/components/ViewModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Descriptions } from 'antd'; +import { Modal, Descriptions, Spin } from 'antd'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; import { coscoAccessWork } from '../services' @@ -49,24 +49,31 @@ const ViewModal: React.FC<{ }> = ({ visible, record = {}, onCancel }) => { //渲染数据 const [data, setData] = useState(null); - const supplierDetailModal = useSupplierDetailModal(); - + const supplierDetailModal = useSupplierDetailModal(); + const [loading, setLoading] = useState(false); + //初始化 useEffect(() => { if (record.id) { - coscoAccessWork(record.id).then((res) => { - const { code, data } = res; - if (code == 200) { - setData(data) - } - }) + setLoading(true); + coscoAccessWork(record.id) + .then((res) => { + const { code, data } = res; + if (code == 200) { + setData(data); + } + }) + .finally(() => setLoading(false)); + } else { + setData(null); } - }, [record]) + }, [record]); return ( + {data && ( - + {data.coscoAccessWork.deptName} {data.coscoAccessSupplierList.map((item) => { @@ -79,6 +86,13 @@ const ViewModal: React.FC<{ {data.coscoAccessWork.accessType === 'scattered' && ( <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })} +
{data.coscoAccessWork.accessDesc} {data.coscoAccessWorkAttachments.fileName} @@ -86,9 +100,18 @@ const ViewModal: React.FC<{ )} {data.coscoAccessWork.accessType === 'offline' && ( - - {data.coscoAccessWorkAttachments.fileName} + <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })}
+ + {data.coscoAccessWorkAttachments.fileName} + + )} @@ -116,6 +139,7 @@ const ViewModal: React.FC<{
)} +
); }; diff --git a/src/pages/supplier/admission/admissionReviewManagement/components/ViewModal.tsx b/src/pages/supplier/admission/admissionReviewManagement/components/ViewModal.tsx index 9da2e90..eeb3c21 100644 --- a/src/pages/supplier/admission/admissionReviewManagement/components/ViewModal.tsx +++ b/src/pages/supplier/admission/admissionReviewManagement/components/ViewModal.tsx @@ -1,5 +1,5 @@ import React, { useState, useEffect } from 'react'; -import { Modal, Descriptions } from 'antd'; +import { Modal, Descriptions, Spin } from 'antd'; import { coscoAccessWork } from '../services' import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; @@ -50,22 +50,30 @@ const ViewModal: React.FC<{ //渲染数据 const [data, setData] = useState(null); const supplierDetailModal = useSupplierDetailModal(); + const [loading, setLoading] = useState(false); + //初始化 - useEffect(() => { - if (record.id) { - coscoAccessWork(record.id).then((res) => { - const { code, data } = res; - if (code == 200) { - setData(data) - } - }) - } - }, [record]) + useEffect(() => { + if (record.id) { + setLoading(true); + coscoAccessWork(record.id) + .then((res) => { + const { code, data } = res; + if (code == 200) { + setData(data); + } + }) + .finally(() => setLoading(false)); + } else { + setData(null); + } + }, [record]); return ( + {data && ( - + {data.coscoAccessWork.deptName} @@ -79,6 +87,13 @@ const ViewModal: React.FC<{ {data.coscoAccessWork.accessType === 'scattered' && ( <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })} +
{data.coscoAccessWork.accessDesc} {data.coscoAccessWorkAttachments.fileName} @@ -86,9 +101,17 @@ const ViewModal: React.FC<{ )} {data.coscoAccessWork.accessType === 'offline' && ( - - {data.coscoAccessWorkAttachments.fileName} + <> + + {data.coscoAccessCategoryList.map((item) => { + return ( +
{item.categoryName}
+ ) + })}
+ + {data.coscoAccessWorkAttachments.fileName} + )} @@ -116,6 +139,7 @@ const ViewModal: React.FC<{
)} +
); }; diff --git a/src/pages/supplier/category/CategoryLibraryManage/components/CategoryAddModal.tsx b/src/pages/supplier/category/CategoryLibraryManage/components/CategoryAddModal.tsx index 03f6c6f..05b140d 100644 --- a/src/pages/supplier/category/CategoryLibraryManage/components/CategoryAddModal.tsx +++ b/src/pages/supplier/category/CategoryLibraryManage/components/CategoryAddModal.tsx @@ -4,14 +4,27 @@ import { UploadOutlined } from '@ant-design/icons'; import { categoryTree, uploadFile, library, libraryData } from '../services'; import type { UploadFile } from 'antd/es/upload/interface'; import AccessDepartmentSelect from '@/components/AccessDepartmentSelect'; -import { getAllAreaList } from '@/servers/api/register'; +import { getDictList } from '@/servers/api/dicts'; +import type { DictItem } from '@/servers/api/dicts'; const { Option } = Select; const approveTypeOptions = [ { label: '是', value: 'online' }, { label: '否', value: 'offline' }, ]; - +function collectSelectedNodes(nodes: TreeNodeType[], checkedKeys: string[]): { id: string; categoryName: string; categoryType:string }[] { + const result: { id: string; categoryName: string; categoryType:string; lockType:number }[] = []; + function dfs(list: TreeNodeType[]) { + list.forEach(node => { + if (checkedKeys.includes(node.key)) { + result.push({ id: node.key, categoryName: node.categoryName, lockType: 0, categoryType: node.children?.length === 0? '1': '0' }); + } + if (node.children && node.children.length) dfs(node.children); + }); + } + dfs(nodes); + return result; +} // TS 类型定义 interface TreeNodeType { id: string; @@ -68,7 +81,7 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => const [treeData, setTreeData] = useState([]); const [loading, setLoading] = useState(false); // 区域全球 - const [regionOptions, setRegionOptions] = useState([]); + const [regionOptions, setRegionOptions] = useState([]); const [expandedKeys, setExpandedKeys] = useState([]); //供应商符合性审查 const [fileList, setFileList] = useState[]>([]); @@ -125,7 +138,7 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => } }) .finally(() => setLoading(false)); - } + } }; // 清空选项 @@ -136,16 +149,27 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => form.resetFields(); } init(visible) - getAllAreaList().then(res => { + + getDictList('area').then(res => { if (res.code === 200) { + console.log(res.data); + setRegionOptions(res.data); } }); + + }, [visible, form]); const handleTreeCheck = (checkedKeysValue: any) => { setCheckedKeys(checkedKeysValue); form.setFieldsValue({ categoryKeys: checkedKeysValue }); + + // 新增:存储 [{id, title}] + const selectedList = collectSelectedNodes(treeData, checkedKeysValue); + form.setFieldsValue({ coscoAccessCategoryList: selectedList }); + + if (hasFuelCategory(checkedKeysValue, treeData)) { setAreaRequired(true); form.validateFields(['area']); @@ -173,14 +197,15 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => const handleOk = async () => { try { const values = await form.validateFields(); - const allCheckedKeys = collectCheckedWithParents(treeData, checkedKeys); + // const allCheckedKeys = collectCheckedWithParents(treeData, checkedKeys); const submitData = { name: values.name, termOfValidity: values.termOfValidity.format('YYYY-MM-DD'), approveType: values.approveType, deptId: values.deptId, area: values.area, - categoryIds: allCheckedKeys.map(id => ({ id, lockType: 0 })), + // categoryIds: allCheckedKeys.map(id => ({ id, lockType: 0 })), + categoryIds: values.coscoAccessCategoryList, } as libraryData if (values.attachments && values.attachments.length != 0) { @@ -247,6 +272,9 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => >
+ + + = ({ visible, onCancel, onSuccess }) => @@ -365,7 +393,7 @@ const CategoryAddModal: React.FC = ({ visible, onCancel, onSuccess }) => ); }} -
+ diff --git a/src/pages/supplier/category/CategoryLibraryManage/components/SupplierListModal.tsx b/src/pages/supplier/category/CategoryLibraryManage/components/SupplierListModal.tsx index 2e1f5ba..0ce5771 100644 --- a/src/pages/supplier/category/CategoryLibraryManage/components/SupplierListModal.tsx +++ b/src/pages/supplier/category/CategoryLibraryManage/components/SupplierListModal.tsx @@ -1,8 +1,9 @@ import React, { useEffect, useState } from 'react'; -import { Modal, Table, Button, Descriptions, Spin, Tooltip } from 'antd'; +import { Modal, Table, Button, Descriptions, Spin, Tooltip } from 'antd'; import { getSupplierPage, detail } from "../services"; import type { ColumnsType } from 'antd/es/table'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; +import { getDictList } from '@/servers/api/dicts' // 供应商类型 interface Supplier { @@ -37,14 +38,15 @@ const SupplierListModal: React.FC<{ const [categoryInfo, setCategoryInfo] = useState({}); // loading const [loading, setLoading] = useState(false); + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); // 分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0, }); - const supplierDetailModal = useSupplierDetailModal(); - + const supplierDetailModal = useSupplierDetailModal(); + // 拉数据 const fetchSuppliers = async (page = 1, pageSize = 10) => { @@ -75,6 +77,15 @@ const SupplierListModal: React.FC<{ useEffect(() => { if (visible) { + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); // fetchSuppliers(pagination.current, pagination.pageSize); fetchCategoryInfo(); } @@ -88,7 +99,7 @@ const SupplierListModal: React.FC<{ // 列表列 const columns: ColumnsType = [ - { title: '序号', dataIndex: 'id', align: 'center', width: 60, render: (t: any, r: any, i: number) => (pagination.current - 1) * pagination.pageSize + i + 1 }, + { title: '序号', dataIndex: 'id', align: 'center', width: 80, render: (t: any, r: any, i: number) => (pagination.current - 1) * pagination.pageSize + i + 1 }, { title: "供应商名称", dataIndex: "name", align: "left", width: 360, @@ -101,7 +112,7 @@ const SupplierListModal: React.FC<{ ) } }, - { title: '境内/境外', dataIndex: 'supplierCategory', align: 'center', render: (r: any,) => ({`${r.supplierCategory === 'dvs'? '境内企业':'境外企业'}`}) }, + { title: '境内/境外', dataIndex: 'supplierCategory', align: 'center', render: (r: any,) => ({`${r.supplierCategory === 'dvs' ? '境内企业' : '境外企业'}`}) }, { title: '统一社会信用代码', dataIndex: 'unifiedSocialCreditCode', align: 'center' }, ]; @@ -137,7 +148,7 @@ const SupplierListModal: React.FC<{ {categoryInfo?.deptName || '-'} - {categoryInfo?.area || '-'} + {categoryInfo?.area ? areaMap[categoryInfo.area] || categoryInfo?.area : '-'} {categoryInfo?.categoryName || '-'} diff --git a/src/pages/supplier/category/CategoryLibraryManage/index.tsx b/src/pages/supplier/category/CategoryLibraryManage/index.tsx index 73d17e4..bfdde1b 100644 --- a/src/pages/supplier/category/CategoryLibraryManage/index.tsx +++ b/src/pages/supplier/category/CategoryLibraryManage/index.tsx @@ -13,6 +13,7 @@ import LockManagerModal from './components/LockManagerModal'; import AccessDepartmentSelect from "@/components/AccessDepartmentSelect" //接口 import { getPage } from './services'; +import { getDictList } from '@/servers/api/dicts'; //统一列表分页 import tableProps from '@/utils/tableProps' @@ -37,6 +38,7 @@ const CategoryLibraryManage: React.FC = () => { const [loading, setLoading] = useState(false); // 分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); // 新增弹窗 const [addVisible, setAddVisible] = useState(false); @@ -77,6 +79,15 @@ const CategoryLibraryManage: React.FC = () => { // 初始化 useEffect(() => { + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); getList(); }, []); @@ -114,6 +125,7 @@ const CategoryLibraryManage: React.FC = () => { key: 'area', align: 'center', ellipsis: true, + render: (code: string) => areaMap[code] || code }, { title: '创建单位', @@ -158,16 +170,16 @@ const CategoryLibraryManage: React.FC = () => { align: 'center', render: (record: any) => ( <> - - { - setCurrentStoreId(record.id); - setLockModalVisible(true); - }} - > - 解锁/锁定 - - + + { + setCurrentStoreId(record.id); + setLockModalVisible(true); + }} + > + 解锁/锁定 + + ), @@ -211,9 +223,9 @@ const CategoryLibraryManage: React.FC = () => { columns={columns} dataSource={data} loading={loading} - pagination={{...tableProps.pagination, total: pagination.total }} + pagination={{ ...tableProps.pagination, total: pagination.total }} onChange={(pagination) => { - getList( pagination.current!, pagination.pageSize!) + getList(pagination.current!, pagination.pageSize!) }} style={{ flex: 1, minHeight: 0 }} scroll={{ y: 'calc(100vh - 350px)' }} diff --git a/src/pages/supplier/category/CategoryLibraryReview/components/ViewModal.tsx b/src/pages/supplier/category/CategoryLibraryReview/components/ViewModal.tsx index 7a7f88d..d3ce864 100644 --- a/src/pages/supplier/category/CategoryLibraryReview/components/ViewModal.tsx +++ b/src/pages/supplier/category/CategoryLibraryReview/components/ViewModal.tsx @@ -1,7 +1,6 @@ import React, { useEffect, useState } from 'react'; -import { Modal, Button, Descriptions, Tree } from 'antd'; -import { detail, treeList } from "../services"; -import type { DataNode } from 'antd/es/tree'; +import { Modal, Button, Descriptions } from 'antd'; +import { detail } from "../services"; // 基本信息类型 interface CategoryInfo { name?: string; @@ -10,16 +9,11 @@ interface CategoryInfo { structure?: string; termOfValidity?: string; deptId?: string; + deptName?: string; + categoryName?: string; area?: string; } -interface LockNode extends DataNode { - key: string; - title: string; - categoryLibraryId: string; - categoryId: string; - lockType: string; - children?: LockNode[]; -} + const ViewModal: React.FC<{ visible: boolean; storeId: string; @@ -28,35 +22,12 @@ const ViewModal: React.FC<{ // 已勾选的供应商 id // 品类库基本信息 const [categoryInfo, setCategoryInfo] = useState({}); - const [treeData, setTreeData] = useState([]); - const [expandedKeys, setExpandedKeys] = useState([]); - const [autoExpandParent, setAutoExpandParent] = useState(true); + // 拉取基本信息 const fetchCategoryInfo = async () => { if (!storeId) return; const res = await detail({ id: storeId }); if (res.code === 200 && res.data) setCategoryInfo(res.data); - - // const treeRes = await treeList({ categoryLibraryId: storeId }); - // if (treeRes.code === 200 && treeRes.data) { - - - // // categoryIds - // const formatted = formatData(res.data) - // // setTreeData(); - // } - - - }; - const formatData = (list: any[]): LockNode[] => { - return list.map(item => ({ - key: item.categoryId, - title: item.categoryName, - categoryId: item.categoryId, - categoryLibraryId: item.categoryLibraryId, - lockType: item.lockType ? item.lockType : '0', - children: item.categoryList ? formatData(item.categoryList) : [], - })); }; useEffect(() => { if (visible) { @@ -93,7 +64,7 @@ const ViewModal: React.FC<{ {categoryInfo?.termOfValidity || '-'} - {categoryInfo?.deptId || '-'} + {categoryInfo?.deptName || '-'} {categoryInfo?.area || '-'} @@ -101,27 +72,8 @@ const ViewModal: React.FC<{ - { - setExpandedKeys(keys as string[]); - setAutoExpandParent(false); - }} - /> - - - - + {categoryInfo?.categoryName || '-'} - - - - - - diff --git a/src/pages/supplier/category/CategoryLibraryReview/index.tsx b/src/pages/supplier/category/CategoryLibraryReview/index.tsx index cde61e2..2c612b7 100644 --- a/src/pages/supplier/category/CategoryLibraryReview/index.tsx +++ b/src/pages/supplier/category/CategoryLibraryReview/index.tsx @@ -44,6 +44,7 @@ const CategoryLibraryManage: React.FC = () => { // 分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); // + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); const [enterpriseType, setEnterpriseType] = useState(); // 新增弹窗 const [addVisible, setAddVisible] = useState(false); @@ -98,6 +99,15 @@ const CategoryLibraryManage: React.FC = () => { setEnterpriseType(res.data) } }) + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); getList(); }, []); @@ -132,6 +142,7 @@ const CategoryLibraryManage: React.FC = () => { key: 'area', align: 'center', ellipsis: true, + render: (code: string) => areaMap[code] || code }, { title: '创建单位', @@ -167,7 +178,7 @@ const CategoryLibraryManage: React.FC = () => { render: (record: any) => { const showSubmit = record.approveStatus === 0; return showSubmit ? ( - handleApproval(record.id)}> + handleApproval(record.id)}> 提交审批 ) : ( @@ -234,7 +245,7 @@ const CategoryLibraryManage: React.FC = () => { columns={columns} dataSource={data} loading={loading} - pagination={{...tableProps.pagination, total: pagination.total }} + pagination={{ ...tableProps.pagination, total: pagination.total }} onChange={(pagination) => { getList(pagination.current!, pagination.pageSize!) }} diff --git a/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx b/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx index 92680f3..8fddcda 100644 --- a/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx +++ b/src/pages/supplier/category/SupplierEntryManage/components/SupplierAddModal.tsx @@ -94,7 +94,7 @@ const SupplierAddModal: React.FC<{ fetchSuppliers(pagination.current, pagination.pageSize, res.data.suppliers || []); }; const [enterpriseTypeMap, setEnterpriseTypeMap] = useState<{ [code: string]: string }>({}); - + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); useEffect(() => { if (visible) { getDictList('enterprise_type').then((res: any) => { @@ -104,9 +104,20 @@ const SupplierAddModal: React.FC<{ data.forEach((item: { code: string, dicName: string }) => { map[item.code] = item.dicName; }); + console.log(map,'map'); + setEnterpriseTypeMap(map); } }) + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); fetchCategoryInfo(); } // eslint-disable-next-line @@ -277,7 +288,7 @@ const SupplierAddModal: React.FC<{ {categoryInfo?.deptName || '-'} - {categoryInfo?.area || '-'} + {categoryInfo?.area ? areaMap[categoryInfo.area] || categoryInfo?.area : '-'} {categoryInfo?.categoryName || '-'} diff --git a/src/pages/supplier/category/SupplierEntryManage/index.tsx b/src/pages/supplier/category/SupplierEntryManage/index.tsx index 727545f..20b7d5a 100644 --- a/src/pages/supplier/category/SupplierEntryManage/index.tsx +++ b/src/pages/supplier/category/SupplierEntryManage/index.tsx @@ -12,6 +12,7 @@ import LockManagerModal from './components/LockManagerModal'; import AccessDepartmentSelect from "@/components/AccessDepartmentSelect" // 接口 import { getPage } from './services'; +import { getDictList } from '@/servers/api/dicts' //统一列表分页 import tableProps from '@/utils/tableProps' @@ -46,6 +47,8 @@ const SupplierEntryManage: React.FC = () => { const [supplierListVisible, setSupplierListVisible] = useState(false); // 解锁与锁定 const [lockModalVisible, setLockModalVisible] = useState(false); + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); + // 获取列表 const getList = async (pageNo: number = 1, pageSize: number = 10) => { setLoading(true); @@ -76,6 +79,15 @@ const SupplierEntryManage: React.FC = () => { // 初始化 useEffect(() => { + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); getList(); }, []); @@ -113,6 +125,7 @@ const SupplierEntryManage: React.FC = () => { key: 'area', align: 'center', ellipsis: true, + render: (code: string) => areaMap[code] || code }, { title: '创建单位', @@ -151,7 +164,7 @@ const SupplierEntryManage: React.FC = () => { )} {record.approveStatus !== 1 && ( - + 添加供应商 )} @@ -192,7 +205,7 @@ const SupplierEntryManage: React.FC = () => { columns={columns} dataSource={data} loading={loading} - pagination={{...tableProps.pagination, total: pagination.total }} + pagination={{ ...tableProps.pagination, total: pagination.total }} onChange={(pagination) => { getList(pagination.current!, pagination.pageSize!) }} diff --git a/src/pages/supplier/category/SupplierEntryReview/components/ViewModal.tsx b/src/pages/supplier/category/SupplierEntryReview/components/ViewModal.tsx index aa78b9a..ae05132 100644 --- a/src/pages/supplier/category/SupplierEntryReview/components/ViewModal.tsx +++ b/src/pages/supplier/category/SupplierEntryReview/components/ViewModal.tsx @@ -4,6 +4,7 @@ import { detail } from "../services"; import type { DataNode } from 'antd/es/tree'; import type { ColumnsType } from 'antd/es/table'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; +import { getDictList } from '@/servers/api/dicts' // 基本信息类型 interface CategoryInfo { @@ -54,6 +55,7 @@ const ViewModal: React.FC<{ // const [expandedKeys, setExpandedKeys] = useState([]); // const [autoExpandParent, setAutoExpandParent] = useState(true); const supplierDetailModal = useSupplierDetailModal(); + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); // 拉取基本信息 const fetchCategoryInfo = async () => { @@ -74,6 +76,15 @@ const ViewModal: React.FC<{ }; useEffect(() => { if (visible) { + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); fetchCategoryInfo(); } }, [visible, storeId]); @@ -133,7 +144,7 @@ const ViewModal: React.FC<{ {categoryInfo?.deptName || '-'} - {categoryInfo?.area || '-'} + {categoryInfo?.area ? areaMap[categoryInfo.area] || categoryInfo?.area : '-'} diff --git a/src/pages/supplier/category/SupplierEntryReview/index.tsx b/src/pages/supplier/category/SupplierEntryReview/index.tsx index 1796e10..5921988 100644 --- a/src/pages/supplier/category/SupplierEntryReview/index.tsx +++ b/src/pages/supplier/category/SupplierEntryReview/index.tsx @@ -11,6 +11,7 @@ import moment from 'moment'; import AccessStatusSelect from '@/components/CommonSelect/AccessStatusSelect'; import AccessDepartmentSelect from "@/components/AccessDepartmentSelect" //接口 +import { getDictList } from '@/servers/api/dicts' import { getPage, approval } from './services'; //统一列表分页 import tableProps from '@/utils/tableProps' @@ -40,6 +41,7 @@ const CategoryLibraryManage: React.FC = () => { const [loading, setLoading] = useState(false); // 分页 const [pagination, setPagination] = useState({ current: 1, pageSize: 10, total: 0 }); + const [areaMap, setAreaMap] = useState<{ [code: string]: string }>({}); // 新增弹窗 const [addVisible, setAddVisible] = useState(false); @@ -89,6 +91,15 @@ const CategoryLibraryManage: React.FC = () => { // 初始化 useEffect(() => { + getDictList('area').then(res => { + if (res.code === 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setAreaMap(map); + } + }); getList(); }, []); @@ -111,12 +122,13 @@ const CategoryLibraryManage: React.FC = () => { ellipsis: true, }, { - title: '地域', + title: '区域', dataIndex: 'area', key: 'area', align: 'center', width: 160, ellipsis: true, + render: (code: string) => areaMap[code] || code }, { title: '入库供应商', @@ -222,7 +234,7 @@ const CategoryLibraryManage: React.FC = () => { columns={columns} dataSource={data} loading={loading} - pagination={{...tableProps.pagination, total: pagination.total }} + pagination={{ ...tableProps.pagination, total: pagination.total }} onChange={(pagination) => { getList(pagination.current!, pagination.pageSize!) }} diff --git a/src/pages/supplier/supplierBlacklist/blacklistManage/components/CreateBlacklistModal.tsx b/src/pages/supplier/supplierBlacklist/blacklistManage/components/CreateBlacklistModal.tsx index f924ce5..2a46271 100644 --- a/src/pages/supplier/supplierBlacklist/blacklistManage/components/CreateBlacklistModal.tsx +++ b/src/pages/supplier/supplierBlacklist/blacklistManage/components/CreateBlacklistModal.tsx @@ -68,7 +68,7 @@ const CreateBlacklistModal: React.FC = ({ } = { ...values, backlistType: '0', - supplierIds: suppliers.map((item) => item.supplierId), + supplierIds: suppliers.map((item) => item.id), } const res = await blacklist(payload); if (res?.success) { @@ -104,9 +104,10 @@ const CreateBlacklistModal: React.FC = ({ supplierDetailModal?.(record.id)}>{name} ) } }, - { title: "准入部门", dataIndex: "unit", align: "center" }, - { title: "准入时间", dataIndex: "accessTime", align: "center" }, + // { title: "准入部门", dataIndex: "unit", align: "center" }, + // { title: "准入时间", dataIndex: "accessTime", align: "center" }, { title: "准入品类", dataIndex: "categoryName", align: "center" }, + { title: "统一社会信用代码/税号", dataIndex: "unifiedCode", align: "center" }, { title: "操作", dataIndex: "option", diff --git a/src/pages/supplier/supplierBlacklist/blacklistManage/components/SupplierSelectModal.tsx b/src/pages/supplier/supplierBlacklist/blacklistManage/components/SupplierSelectModal.tsx index b95ab1a..a8a1bab 100644 --- a/src/pages/supplier/supplierBlacklist/blacklistManage/components/SupplierSelectModal.tsx +++ b/src/pages/supplier/supplierBlacklist/blacklistManage/components/SupplierSelectModal.tsx @@ -91,6 +91,8 @@ const SupplierSelectModal: React.FC = ({ }; const handleOk = () => { + console.log(rightData,'rightData'); + onOk(rightData); }; diff --git a/src/pages/supplier/supplierBlacklist/blacklistManage/components/ViewBlacklistModal.tsx b/src/pages/supplier/supplierBlacklist/blacklistManage/components/ViewBlacklistModal.tsx index 8339b29..aba6748 100644 --- a/src/pages/supplier/supplierBlacklist/blacklistManage/components/ViewBlacklistModal.tsx +++ b/src/pages/supplier/supplierBlacklist/blacklistManage/components/ViewBlacklistModal.tsx @@ -1,20 +1,21 @@ import React, { useEffect, useState } from "react"; import { Modal, Button, Table, Descriptions, Spin, message, Tooltip } from "antd"; -import {viewBlacklist } from "../services"; // 假设的接口 +import { viewBlacklist } from "../services"; // 假设的接口 import type { ColumnsType } from 'antd/es/table'; import { useSupplierDetailModal } from '@/components/SupplierDetailModalContext/SupplierDetailModalContext'; +import { getDictList } from '@/servers/api/dicts'; interface Supplier { - id: number; // 作为 rowKey 用于唯一标识 - supplierName: string; // 供应商名称 - unit: string; // 准入部门 - accessTime: string; // 准入时间 - categoryName: string; // 准入品类 - lastEval: string; // 最近一次评价 - lastEvalDate: string; // 评价时间 - supplierId: string; - categoryId: string; - } + id: number; // 作为 rowKey 用于唯一标识 + supplierName: string; // 供应商名称 + unit: string; // 准入部门 + accessTime: string; // 准入时间 + categoryName: string; // 准入品类 + lastEval: string; // 最近一次评价 + lastEvalDate: string; // 评价时间 + supplierId: string; + categoryId: string; +} interface DetailData { deptName: string; timelimitType: string; @@ -36,11 +37,12 @@ const ViewBlacklistModal: React.FC = ({ const [detail, setDetail] = useState(null); const [suppliers, setSuppliers] = useState([]); const supplierDetailModal = useSupplierDetailModal(); + const [timelimitMap, setTimelimitMap] = useState<{ [code: string]: string }>({}); const fetchData = async () => { setLoading(true); try { - const { code, data } = await viewBlacklist(recordId) + const { code, data } = await viewBlacklist(recordId) if (code == 200) { setDetail(data); } else { @@ -61,11 +63,21 @@ const ViewBlacklistModal: React.FC = ({ useEffect(() => { if (visible && recordId) { + getDictList('blacklist_deadline').then((res) => { + const { code, data } = res; + if (code == 200) { + const map: { [code: string]: string } = {}; + res.data.forEach((item: { code: string, dicName: string }) => { + map[item.code] = item.dicName; + }); + setTimelimitMap(map); + } + }) fetchData(); } }, [visible, recordId]); - const columns:ColumnsType = [ + const columns: ColumnsType = [ { title: "供应商名称", dataIndex: "supplierName", align: "left", width: 200, @@ -79,9 +91,11 @@ const ViewBlacklistModal: React.FC = ({ } }, - { title: "准入部门", dataIndex: "deptName", align: "center" }, - { title: "准入时间", dataIndex: "evaluateTime", align: "center" }, - { title: "准入品类", dataIndex: "categoryName", align: "center", width: 180, + // { title: "准入部门", dataIndex: "deptName", align: "center" }, + // { title: "准入时间", dataIndex: "evaluateTime", align: "center" }, + { title: "统一社会信用代码/税号", dataIndex: "unifiedCode", align: "center" }, + { + title: "准入品类", dataIndex: "categoryName", align: "center", width: 180, ellipsis: true, render: (dom, record) => { return ( @@ -89,7 +103,8 @@ const ViewBlacklistModal: React.FC = ({ {record.categoryName} ) - } }, + } + }, ]; return ( @@ -111,7 +126,7 @@ const ViewBlacklistModal: React.FC = ({ bordered style={{ marginBottom: 24 }} > - {detail.timelimitType} + {timelimitMap[detail.timelimitType] || '' } {detail.blacklistReason} )} diff --git a/src/pages/supplier/supplierBlacklist/blacklistManage/index.tsx b/src/pages/supplier/supplierBlacklist/blacklistManage/index.tsx index 8a1b8a0..dfb0a77 100644 --- a/src/pages/supplier/supplierBlacklist/blacklistManage/index.tsx +++ b/src/pages/supplier/supplierBlacklist/blacklistManage/index.tsx @@ -178,7 +178,7 @@ const blacklistManage: React.FC = () => { onCancel={() => setCreateVisible(false)} onOk={() => { setCreateVisible(false) - handleSearch + handleSearch() }} /> = ({ orgId: string; }, supplierIdList: string[], - coscoSupplierexitSupplierCategoryList: { supplierId: string; categoryId: string; }[]; + coscoSupplierexitSupplierCategoryList: { supplierId: string; categoryId: string; categoryName: string; }[]; } = { coscoSupplierexit: {...values}, supplierIdList: suppliers.map((item) => item.supplierId), - coscoSupplierexitSupplierCategoryList: suppliers.map((item) => ({ supplierId: item.supplierId, categoryId: item.categoryId })) + coscoSupplierexitSupplierCategoryList: suppliers.map((item) => ({ supplierId: item.supplierId, categoryId: item.categoryId, categoryName: item.categoryName })) } + const res = await add(payload); if (res?.success) { message.success("提交成功");