Commit a9c60907 authored by 彭俊龙's avatar 彭俊龙

fix: 自定义导出单据模板

parent 0a982f46
/*
* @Author: ZengJing
* @Date: 2024-02-04 10:01:59
* @LastEditTime: 2024-02-04 10:10:35
* @LastEditors: ZengJing
* @Description:
* @FilePath: \xform\src\core\Account\components\ExportTemplate\index.js
*/
import Receipt from './receipt'
export {
Receipt
}
\ No newline at end of file
/*
* @Author: ZengJing
* @Date: 2024-02-04 09:39:21
* @LastEditTime: 2024-02-04 17:27:27
* @LastEditors: ZengJing
* @Description:
* @FilePath: \xform\src\core\Account\components\ExportTemplate\Receipt.js
*/
import React, { useState, useImperativeHandle, forwardRef, useMemo, useRef } from 'react';
import styles from './receipt.less';
import moment from 'moment';
const Receipt = props => {
moment.locale('zh-cn');
const { dataList, title } = props;
const arr = ['坐标', '地址', '图片'];
const dataSource =
dataList?.length > 0
? dataList.map((x, index) => {
return {
id: x.id,
webRow: x.webRow.filter((v, i) => {
if (!arr.some(n => v.shape.includes(n))) {
return v;
}
}),
};
})
: null;
const columnCount = dataSource?.length > 0 ? dataSource[0].webRow.length + 1 : 0;
const footRows = ['记账', '保管', '验收', '提货人', '制单'];
const splitOddNumber = oddNumber => {
if (oddNumber % 2 !== 1) {
[oddNumber / 2, oddNumber / 2];
}
const firstNumber = Math.floor(oddNumber / 2);
const secondNumber = firstNumber + 1;
return [firstNumber, secondNumber];
};
return (
<>
<div className={styles.content}>
<table>
<tr>
<th colSpan={columnCount} className={styles.headerTxt}>
<span>{title}</span>
</th>
</tr>
<tr>
<th colSpan={splitOddNumber(columnCount)[0]} className={styles.headerLeft}>
单位:
</th>
<th colSpan={splitOddNumber(columnCount)[1]} className={styles.headerRight}>
日期:{moment().format('LL')}
</th>
</tr>
<tr>
<th>序号</th>
{dataSource?.length > 0 ? dataSource[0].webRow.map((x, index) => <th>{x.fieldName}</th>) : null}
</tr>
{dataSource?.length > 0
? dataSource.map((x, index) => (
<tr>
<td>{index + 1}</td>
{x.webRow.map((v, i) => (
<td>{v.fieldValue}</td>
))}
</tr>
))
: null}
<tr>
<td>合计</td>
{dataSource?.length > 0 ? dataSource[0].webRow.map((x, index) => <td></td>) : null}
</tr>
<tr>
{dataSource?.length > 0
? dataSource[0].webRow.map((x, i) => {
if (footRows.length >= i + 1) {
return <td>{footRows[i]}</td>;
} else {
return <td></td>;
}
})
: null}
<td></td>
</tr>
</table>
</div>
</>
);
};
export default Receipt;
.content{
width: auto;
height: auto;
}
table {
border-collapse: collapse; /* 合并单元格边框 */
width: 100%;
}
th, td {
border-bottom: 1px solid #ddd; /* 添加底部边框 */
padding: 8px;
text-align: center;
font-size: 13px;
}
.headerLeft{
text-align: left !important;
font-weight: bold;
}
.headerRight{
text-align: right !important;
font-weight: bold;
}
.headerTxt{
padding: 5px;
text-align: center;
font-size: 13px;
border: none !important;
span{
border-bottom: 1px solid gray;
font-weight: bold;
width: auto;
}
}
\ No newline at end of file
......@@ -18,7 +18,7 @@ const SearchGroup = forwardRef((props, ref) => {
}))
const { accountName, config, notUse, checkName, btnsClick, keys } = props
const { enableBatchOperation, enableImportExport, enablePrint, enableQuickSearch, enableTimeFilter, parent, accountFieids } = config
const { enableBatchOperation, enableImportExport, exportTemplateName, enablePrint, enableQuickSearch, enableTimeFilter, parent, accountFieids } = config
const [form] = Form.useForm()
const [dateArray, setDateArray] = useState([])
const [formatterStr, setFormatterStr] = useState('YYYY-MM-DD HH:mm:ss')
......@@ -265,7 +265,21 @@ const SearchGroup = forwardRef((props, ref) => {
</Button>
),
key: '导出全字段数据',
}
},
exportTemplateName ? {
label: (
<Button
style={{ width: '100%', textAlign: 'left' }}
size='middle'
type='text'
onClick={() => btnsClick({ type: '导出单据' })}
icon={<ExportOutlined />}
>
导出单据
</Button>
),
key: '导出单据',
}: null
]
const onSearch = e => {
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment