This commit is contained in:
ylj20011123 2025-10-10 18:37:24 +08:00
parent 77be21b87c
commit 27ce6e9675
7 changed files with 361 additions and 95 deletions

View File

@ -1,6 +1,6 @@
{
"name": "ant-design-pro",
"version": "4.5.71",
"version": "4.5.72",
"private": true,
"description": "An out-of-box UI solution for enterprise applications",
"scripts": {

View File

@ -573,7 +573,7 @@ const inventoryInformation: React.FC<{ currentUser: CurrentUser }> = (props) =>
return (
<Table.Summary fixed="bottom">
<Table.Summary.Row>
<Table.Summary.Cell index={0} colSpan={4}>
<Table.Summary.Cell index={0} colSpan={5}>
<div style={{ textAlign: 'center', fontWeight: 600 }}></div>
</Table.Summary.Cell>
<Table.Summary.Cell index={4}>

View File

@ -191,7 +191,11 @@ const ReturnGoodsTable = ({ showDetail, parentRow, onCencel, searchParams }: Det
const clonedTable = originalTable.cloneNode(true) as HTMLElement;
clonedTable.style.display = 'block';
// 遍历设置字体大小
// 🔧 移除测量行(解决间距问题)
const measureRows = clonedTable.querySelectorAll('.ant-table-measure-row');
measureRows.forEach(row => row.remove());
// 保持你原有的字体设置
const setFontSizeRecursively = (element: HTMLElement) => {
element.style.fontSize = '10px';
element.style.padding = '4px';
@ -201,7 +205,6 @@ const ReturnGoodsTable = ({ showDetail, parentRow, onCencel, searchParams }: Det
};
const tableCells = clonedTable.querySelectorAll('thead th, tbody td, tfoot td');
tableCells.forEach((cell) => setFontSizeRecursively(cell as HTMLElement));
console.log('clonedTableclonedTableclonedTableclonedTable', clonedTable);
// 获取克隆后的 HTML 内容
const clonedHTML = clonedTable.getElementsByClassName('ant-table')[0].innerHTML;
@ -209,16 +212,100 @@ const ReturnGoodsTable = ({ showDetail, parentRow, onCencel, searchParams }: Det
// 页眉(标题 + 描述)
let neckList: any = [
{ label: "退货单号", value: parentRow?.ACCEPT_CODE || '' },
{ label: "退货数量", value: currentModalDetail?.RETURN_COUNT || '' },
{ label: "退货金额", value: currentModalDetail?.RETURN_AMOUNT || '' },
{ label: "退货数量", value: parentRow?.OPERATE_COUNT || '' },
{ label: "退货金额", value: parentRow?.OPERATE_TAXAMOUNT || '' },
{ label: "申请人员", value: parentRow?.STAFF_NAME || '' },
{ label: "退货说明", value: parentRow?.PROINST_DESC || '' },
]
];
// 🔧 只添加这些:测量行隐藏 + 宽度自适应 + 水平居中
const fineBorderStyles = `
@media print {
/* 1. 隐藏测量行 */
.ant-table-measure-row {
display: none !important;
height: 0 !important;
}
// 调用统一打印方法
handleNewPrintAHJG(printName, `${parentRow?.DEPT_NAME || ''}自采退货单`, neckList, styles, clonedHTML, '');
}}>退</Button>
/* 2. 表格宽度自适应 + 水平居中 */
.handlePrintBox .tableBox {
width: auto !important;
max-width: 100% !important;
margin: 0 auto !important;
}
.handlePrintBox .tableBox table {
width: auto !important;
max-width: 100% !important;
table-layout: auto !important;
margin: 0 auto !important;
position: relative !important;
left: 50% !important;
transform: translateX(-50%) !important;
}
/* 3. 精细边框统一 - 使用1px避免过粗 */
.handlePrintBox .tableBox table {
border-collapse: separate !important;
border-spacing: 0 !important;
border: 1px solid #000 !important;
}
/* 精确控制每个边框 - 统一使用1px */
.handlePrintBox .tableBox .ant-table-thead tr th {
border: 1px solid #000 !important;
border-bottom: 1px solid #000 !important;
border-right: 1px solid #000 !important;
background-color: transparent !important;
margin: 0 !important;
padding: 4px !important;
}
.handlePrintBox .tableBox .ant-table-tbody tr td {
border: 1px solid #000 !important;
border-right: 1px solid #000 !important;
border-bottom: 1px solid #000 !important;
margin: 0 !important;
padding: 4px !important;
}
/* 边框连接处统一 - 都使用1px */
.handlePrintBox .tableBox .ant-table-thead tr:first-child th {
border-top: 1px solid #000 !important;
}
.handlePrintBox .tableBox .ant-table-thead tr th:first-child,
.handlePrintBox .tableBox .ant-table-tbody tr td:first-child {
border-left: 1px solid #000 !important;
}
.handlePrintBox .tableBox .ant-table-thead tr th:last-child,
.handlePrintBox .tableBox .ant-table-tbody tr td:last-child {
border-right: 1px solid #000 !important;
}
.handlePrintBox .tableBox .ant-table-tbody tr:last-child td {
border-bottom: 1px solid #000 !important;
}
/* 4. 页边距优化 */
@page {
margin: 10mm auto !important;
size: A4 landscape;
}
}
`;
// 合并样式
const combinedStyles = styles + fineBorderStyles;
// 调用原有打印方法
handleNewPrintAHJG(printName, `${parentRow?.DEPT_NAME || ''}自采退货单`, neckList, combinedStyles, clonedHTML, '');
console.log('parentRowparentRowparentRow', parentRow);
}}>
退
</Button>
</div>
<div style={{ width: "100%", display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: "24px", fontWeight: 500 }}>
@ -264,8 +351,8 @@ const ReturnGoodsTable = ({ showDetail, parentRow, onCencel, searchParams }: Det
contentStyle={{ fontWeight: "bolder" }} labelStyle={{ color: "#00000073" }}
>
<Descriptions.Item label="退货单号">{parentRow?.ACCEPT_CODE || ""}</Descriptions.Item>
<Descriptions.Item label="退货数量">{""}</Descriptions.Item>
<Descriptions.Item label="退货金额">{""}</Descriptions.Item>
<Descriptions.Item label="退货数量">{parentRow?.OPERATE_COUNT || ""}</Descriptions.Item>
<Descriptions.Item label="退货金额">{parentRow?.OPERATE_TAXAMOUNT || ""}</Descriptions.Item>
<Descriptions.Item label="申请人员">{parentRow?.STAFF_NAME || ""}</Descriptions.Item>
<Descriptions.Item label="退货说明">{parentRow?.PROINST_DESC || ""}</Descriptions.Item>

View File

@ -18,7 +18,10 @@ import { getBusniessBrandTree } from "../service";
import { initial } from "lodash";
import { ModalForm, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from "@ant-design/pro-form";
import { getList } from "../BusinessTrade/service";
import { handleAddUpdate, handleDelete } from "./service";
import { handleAddUpdate, handleDelete, handleGetBrandList } from "./service";
import { getList as handleGetTradeList } from '../BusinessTrade/service'
import { exportXlsxFromProColumnsExcelJS } from "@/utils/exportExcelFun";
import { formatTreeData } from "@/utils/format";
const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
@ -45,47 +48,61 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
const [exportData, setExportData] = useState<any>()
const [createModalVisible, handleModalVisible] = useState<boolean>(false); // 新建窗口的弹窗
const [treeSelectOption, setTreeSelectOption] = useState<any[]>(); // 可选择项
// 业态品牌
const [businessBrand, setBusinessBrand] = useState<any[]>(); // 业态品牌
// 所有业态最里层的数据
const [extractLeafIdsList, setExtractLeafIdsList] = useState<any[]>([]);
const columns: any = [
// {
// title: <div style={{ textAlign: 'center' }}>品牌图标</div>,
// dataIndex: 'BusinessTrade_ICO',
// align: 'right',
// hideInSearch: true,
// },
{
title: "图标",
dataIndex: 'BusinessTrade_ICO',
title: "品牌图标",
dataIndex: 'BRAND_INTRO',
width: 120,
align: 'center',
hideInSearch: true,
hideInDescriptions: true,
render: (_, record) => {
return record?.BusinessTrade_ICO || record?.Brand_ICO ? <img style={{ width: "90px", height: "90px", borderRadius: '50%' }} src={record?.BusinessTrade_ICO} /> :
<Avatar src={_} size={16} shape="square">{record.BusinessTrade_Name ? record.BusinessTrade_Name.substring(0, 1) : record?.Brand_Name ? record.Brand_Name.substring(0, 1) : ''}</Avatar>
return record?.BRAND_INTRO ? <img style={{ width: "90px", height: "90px", borderRadius: '50%' }} src={record?.BRAND_INTRO} /> :
<Avatar src={_} size={16} shape="square">{record.BRAND_NAME ? record.BRAND_NAME.substring(0, 1) : ''}</Avatar>
}
},
{
title: "品牌索引",
dataIndex: "BRAND_INDEX",
width: 120,
align: 'center',
hideInSearch: true,
ellipisis: true,
},
{
title: "品牌名称",
dataIndex: "BRAND_NAME",
width: 120,
align: 'center',
hideInSearch: true,
ellipisis: true,
},
{
title: "经营业态名称",
dataIndex: "BUSINESSTRADE_NAME",
width: 120,
align: 'center',
hideInSearch: true,
ellipisis: true,
},
{
title: "有效状态",
width: 120,
align: 'center',
dataIndex: "BrandState",
dataIndex: "BRAND_STATE",
valueType: "select",
fieldProps: {
options: [{ label: "有效", value: 1 }, { label: "无效", value: 0 }]
},
initialValue: 1,
},
{
title: <div style={{ textAlign: 'center' }}>/</div>,
dataIndex: 'BusinessTrade_Name',
align: 'center',
hideInSearch: true,
render: (_, record) => {
return record?.Brand_Name || record?.BusinessTrade_Name
}
},
{
title: '操作',
width: 120,
@ -93,7 +110,7 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
valueType: 'option',
align: 'center',
hideInDescriptions: true,
render: (_, record) => record?.Brand_ID ? [
render: (_, record) => record?.BRAND_ID ? [
<a
key="edit"
onClick={() => {
@ -105,7 +122,7 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
</a>,
<Popconfirm title="确认删除该品牌?" onConfirm={async () => {
const sucesse = await handleDelete({ BrandId: record.Brand_ID })
const sucesse = await handleDelete({ BrandId: record.BRAND_ID })
if (sucesse && actionRef.current) {
actionRef.current.reload()
}
@ -154,8 +171,10 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
}
useEffect(async () => {
const data: any = await getList({ BusinessTradeModelPID: -1, BusinessTradeState: 1 })
setTreeSelectOption([{ AUTOSTATISTICS_NAME: '默认', AUTOSTATISTICS_ID: -1, children: [...data.data] }])
// 拿到经营品牌数据
await handleGetBusinessTrade();
}, [])
const normalizeTreeChildren = (list: any[]): any[] => {
@ -181,6 +200,53 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
});
};
// 拿到经营业态的数据
const handleGetBusinessTrade = async () => {
const data: any = await handleGetTradeList({ BusinessTradeModelPID: -1, BusinessTradeState: 1 })
console.log('handleGetBusinessTradehandleGetBusinessTrade', data);
setBusinessBrand(data.data)
setExtractLeafIdsList(extractLeafIds(data.data))
setTreeSelectOption(markNonLeafDisabled([{ AUTOSTATISTICS_NAME: '默认', AUTOSTATISTICS_ID: -1, children: [...data.data] }]))
}
// 拿到全部最里层的 业态值
const extractLeafIds = (data: any) => {
const result: any = [];
const traverse = (list: any) => {
list.forEach((item: any) => {
if (!item.children || item.children.length === 0) {
// 没有 children就是最里层节点
result.push(item.AUTOSTATISTICS_ID);
} else {
// 有 children继续递归
traverse(item.children);
}
});
}
traverse(data);
return result;
}
// 不是没有children 都禁用
const markNonLeafDisabled = (list: any) => {
return list.map((node: any) => {
const hasChildren = Array.isArray(node.children) && node.children.length > 0;
// 复制原节点,添加 disabled 字段(只有非叶子节点 disabled
const newNode = {
...node,
// 如果你更喜欢使用 selectable 而不是 disabled可用: selectable: !hasChildren
disabled: hasChildren ? true : undefined,
};
if (hasChildren) {
newNode.children = markNonLeafDisabled(node.children);
}
return newNode;
});
}
return (
<div ref={(el) => {
// 打印报表
@ -233,8 +299,52 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
<div id='hiddenBox' style={{ position: 'fixed', zIndex: -1, top: 0, left: 0 }} />
<div style={{ backgroundColor: '#fff', display: 'flex' }}>
<ProCard
style={{ width: !collapsible ? "300px" : "60px" }}
className="pageTable-leftnav"
bodyStyle={{ padding: 0, paddingTop: 20, paddingLeft: 20, width: !collapsible ? "300px" : "60px" }}
extra={<MenuFoldOutlined onClick={() => {
setCollapsible(!collapsible);
}} />}
colSpan={!collapsible ? "300px" : "60px"}
title={!collapsible ? "请选择业态" : ""}
headerBordered
collapsed={collapsible}
>
{businessBrand && businessBrand.length > 0 ? <Tree
checkable
treeData={[{
AUTOSTATISTICS_NAME: '全部',
value: 0,
AUTOSTATISTICS_ID: '0-0',
children: businessBrand
}]}
blockNode
defaultExpandAll={true}
defaultExpandedKeys={['0-0']}
onCheck={(checkedKeys: React.Key[] | any, info) => {
let res: any = []
if (checkedKeys && checkedKeys.length > 0) {
if (extractLeafIdsList && extractLeafIdsList.length > 0) {
checkedKeys.forEach((item: any) => {
if (extractLeafIdsList.indexOf(item) > -1) {
res.push(item);
}
})
}
}
setSelectedId(res)
}}
fieldNames={{
title: "AUTOSTATISTICS_NAME",
key: "AUTOSTATISTICS_ID"
}}
/> : ''}
</ProCard>
<div style={{
width: '100%',
width: !collapsible ? 'calc(100% - 300px)' : 'calc(100% - 60px)',
paddingTop: 0,
paddingBottom: 0,
paddingRight: 0
@ -254,65 +364,106 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
headerTitle={<PageTitleBox props={props} />} // 列表表头
search={{ span: 6 }}
request={async (params) => {
if (!selectedId) {
return { data: [], success: true }
}
const req: any = {
ProvinceCode: currentUser?.ProvinceCode,
BrandState: 1
SearchParameter: {
BRAND_CATEGORY: 1000,
BRAND_INDUSTRYS: selectedId && selectedId.length > 0 ? selectedId.toString() : '',
BRAND_STATE: params.BRAND_STATE || "",
},
PageIndex: 1,
PageSize: 999999
}
setSearchParams(params)
const data = await getBusniessBrandTree(req)
const data = await handleGetBrandList(req)
console.log('handleGetBrandListhandleGetBrandList', data);
if (data && data.length > 0) {
let exportData: any = []
data.forEach((item: any) => {
exportData.push({
Business_Format: item.BusinessTrade_Name,
BusinessTrade_Name: ""
})
if (item.children && item.children.length > 0) {
item.children.forEach((subItem: any) => {
exportData.push({
Business_Format: item.BusinessTrade_Name,
BusinessTrade_Name: subItem.BusinessTrade_Name,
})
})
}
})
setExportData(exportData)
console.log('datadatadata', data);
let res: any = normalizeTreeChildren(data)
console.log(res, 'res');
let fieldData: any = []
return { data: res, success: true }
let enumList: any = ["BRAND_STATE",]
let newPrintData: any = formatTreeData(JSON.parse(JSON.stringify(data)), fieldData, enumList, [[{ label: "有效", value: 1 }, { label: "无效", value: 0 }]], [])
console.log('newPrintDatanewPrintData', newPrintData);
setReqDetailList(newPrintData)
return { data: data, success: true }
}
// const req: any = {
// ProvinceCode: currentUser?.ProvinceCode,
// BrandState: 1
// }
// setSearchParams(params)
// const data = await getBusniessBrandTree(req)
// if (data && data.length > 0) {
// let exportData: any = []
// data.forEach((item: any) => {
// exportData.push({
// Business_Format: item.BusinessTrade_Name,
// BusinessTrade_Name: ""
// })
// if (item.children && item.children.length > 0) {
// item.children.forEach((subItem: any) => {
// exportData.push({
// Business_Format: item.BusinessTrade_Name,
// BusinessTrade_Name: subItem.BusinessTrade_Name,
// })
// })
// }
// })
// setExportData(exportData)
// console.log('datadatadata', data);
// let res: any = normalizeTreeChildren(data)
// console.log(res, 'res');
// return { data: res, success: true }
// }
setReqDetailList([])
return { data: [], success: true }
}}
toolbar={{
actions: [
<span style={{ visibility: 'hidden' }}>
<ReactHTMLTableToExcel
buttonText={'导出excel'}
ref={downloadBtnRef}
table="table-to-xls-operatingBrand"
filename={`经营品牌列表`}
sheet="sheet1"
/>
</span>,
// <span style={{ visibility: 'hidden' }}>
// <ReactHTMLTableToExcel
// buttonText={'导出excel'}
// ref={downloadBtnRef}
// table="table-to-xls-operatingBrand"
// filename={`经营品牌列表`}
// sheet="sheet1"
// />
// </span>,
<Button
key="new"
type="primary"
onClick={(e) => {
if (exportData && exportData.length > 0) {
setShowLoading(true)
setTimeout(() => {
setShowExportTable(true)
setTimeout(() => {
exportTable(e)
}, 100)
}, 100)
if (reqDetailList && reqDetailList.length > 0) {
// 尝试一下 导出新方法
exportXlsxFromProColumnsExcelJS(columns.slice(0, columns.length - 1),
reqDetailList,
`经营品牌列表`,
{
// topTitle: `退货流程统计表`, // 顶部大标题
}
)
} else {
message.error('暂无数据可导出!')
}
// if (exportData && exportData.length > 0) {
// setShowLoading(true)
// setTimeout(() => {
// setShowExportTable(true)
// setTimeout(() => {
// exportTable(e)
// }, 100)
// }, 100)
// } else {
// message.error('暂无数据可导出!')
// }
}}
>
excel
@ -377,24 +528,24 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
<Form.Item
name="BRAND_INDUSTRY"
label="上级业态"
rules={[
{
required: true,
message: '请选择上级业态',
},
]}
rules={[{ required: true, message: '请选择上级业态' }]}
>
<TreeSelect
placeholder="请选择上级业态"
dropdownStyle={{ maxHeight: 300, overflow: 'auto' }}
treeDefaultExpandedKeys={currentRow ? [currentRow?.BRAND_INDUSTRY] : [-1]}
// treeDataSimpleMode
treeDefaultExpandAll
showArrow={false}
showSearch
treeData={treeSelectOption}
fieldNames={{
label: 'AUTOSTATISTICS_NAME',
value: 'AUTOSTATISTICS_ID'
value: 'AUTOSTATISTICS_ID',
}}
filterTreeNode={(input, node) =>
String(node.AUTOSTATISTICS_NAME)
.toLowerCase()
.includes(String(input).toLowerCase())
}
/>
</Form.Item>
<ProFormText
@ -432,7 +583,9 @@ const operatingBrand: React.FC<{ currentUser: CurrentUser }> = (props) => {
message: '请选择品牌类型',
},
]}
options={[{ label: '经营品牌', value: 1000 }, { label: '商城品牌', value: 2000 }]}
options={[{ label: '经营品牌', value: 1000 }]}
initialValue={1000}
// , { label: '商城品牌', value: 2000 }
/>
<ProFormSelect

View File

@ -23,3 +23,23 @@ export async function handleAddUpdate(params: any) {
data: params,
});
}
// 获取品牌表列表
export async function handleGetBrandList(params?: any) {
const data = await request(`/BaseInfo/GetBrandList`, {
method: 'POST',
data: params,
});
if (data.Result_Code !== 100) {
return {
data: [],
current: 1,
pageSize: 10,
total: 0,
success: false
}
}
return data.Result_Data.List
}

View File

@ -408,7 +408,7 @@ export const handleNewPrintAHJG = (printName: string, title: string, neckBox?: a
// styles 获取页面的样式
// tableDom 要打印显示的表格 直接dom元素拿进来(处理好的)
// footer 打印内容底部的自定义样式 需求不一样 样式也不一样 外面写好样式和标签直接传入
const printWindow = window.open('', '_blank', 'width=1400,height=800');
const printWindow = window.open('', '_blank', 'width=1600,height=900,scrollbars=yes');
if (printWindow) {
printWindow.document.open();
printWindow.document.write(`
@ -479,8 +479,9 @@ export const handleNewPrintAHJG = (printName: string, title: string, neckBox?: a
padding: 12px;
display: flex;
justify-content: center;
border-collapse: separate;
border-collapse: collapse; /* 改为collapse */
border-spacing: 0;
overflow-x: auto; /* 添加横向滚动 */
}
.handlePrintBox .tableBox .ant-table-thead tr th{
border: 2px solid #000;
@ -504,6 +505,11 @@ export const handleNewPrintAHJG = (printName: string, title: string, neckBox?: a
box-sizing: border-box;
padding-left: 5%;
}
.handlePrintBox .tableBox table {
transform: scale(0.9); /* 整体缩小10% */
transform-origin: top left;
page-break-inside: avoid;
}
.pro-table {
width: 100%;
border-collapse: collapse;

View File

@ -1,4 +1,4 @@
// 由 scripts/writeVersion.js 自动生成
export const VERSION = "4.5.71";
export const GIT_HASH = "83fe183";
export const BUILD_TIME = "2025-10-09T10:46:03.209Z";
export const VERSION = "4.5.72";
export const GIT_HASH = "77be21b";
export const BUILD_TIME = "2025-10-10T10:31:31.402Z";