feat(wms/menu): 添加异常钢卷导出功能并优化菜单导出功能
1. 新增单行/多行异常钢卷导出按钮,带权限控制 2. 优化菜单导出Excel,新增路由地址和完整路由地址列
This commit is contained in:
@@ -617,12 +617,30 @@ export default {
|
||||
};
|
||||
|
||||
// 递归展平为一维数组,缩进体现层级
|
||||
const flattenTree = (nodes, level = 0, result = []) => {
|
||||
const flattenTree = (nodes, level = 0, parentPath = '', result = []) => {
|
||||
nodes.forEach(node => {
|
||||
const prefix = '\u3000'.repeat(level); // 全角空格缩进
|
||||
const ownPath = node.path || '';
|
||||
// 计算完整路由地址(仅菜单类型 C 有效)
|
||||
let fullPath = '';
|
||||
if (node.menuType === 'C') {
|
||||
if (node.isFrame === '0') {
|
||||
// 外链:完整路由就是自身路径
|
||||
fullPath = ownPath;
|
||||
} else {
|
||||
// 内部路由:父路径 + 自身路径
|
||||
const parent = parentPath ? (parentPath.endsWith('/') ? parentPath : parentPath + '/') : '';
|
||||
fullPath = '/' + parent + ownPath;
|
||||
}
|
||||
}
|
||||
// 目录(M)的路径作为子节点的父路径
|
||||
const currentParentPath = node.menuType === 'M' ? ownPath : parentPath;
|
||||
|
||||
result.push({
|
||||
menuName: prefix + node.menuName,
|
||||
menuType: menuTypeMap[node.menuType] || node.menuType,
|
||||
path: ownPath,
|
||||
fullPath: fullPath,
|
||||
icon: node.icon || '',
|
||||
orderNum: node.orderNum,
|
||||
perms: node.perms || '',
|
||||
@@ -631,7 +649,7 @@ export default {
|
||||
createTime: node.createTime || ''
|
||||
});
|
||||
if (node.children && node.children.length > 0) {
|
||||
flattenTree(node.children, level + 1, result);
|
||||
flattenTree(node.children, level + 1, currentParentPath, result);
|
||||
}
|
||||
});
|
||||
return result;
|
||||
@@ -647,19 +665,21 @@ export default {
|
||||
|
||||
// 构建 Excel 数据
|
||||
const wsData = [
|
||||
['菜单名称', '菜单类型', '图标', '排序', '权限标识', '组件路径', '状态', '创建时间'],
|
||||
['菜单名称', '菜单类型', '路由地址', '完整路由地址', '图标', '排序', '权限标识', '组件路径', '状态', '创建时间'],
|
||||
...flatData.map(item => [
|
||||
item.menuName, item.menuType, item.icon,
|
||||
item.orderNum, item.perms, item.component,
|
||||
item.status, item.createTime
|
||||
item.menuName, item.menuType, item.path,
|
||||
item.fullPath, item.icon, item.orderNum,
|
||||
item.perms, item.component, item.status,
|
||||
item.createTime
|
||||
])
|
||||
];
|
||||
|
||||
const ws = XLSX.utils.aoa_to_sheet(wsData);
|
||||
ws['!cols'] = [
|
||||
{ wch: 30 }, { wch: 10 }, { wch: 12 },
|
||||
{ wch: 8 }, { wch: 25 }, { wch: 30 },
|
||||
{ wch: 8 }, { wch: 20 }
|
||||
{ wch: 30 }, { wch: 10 }, { wch: 22 },
|
||||
{ wch: 30 }, { wch: 12 }, { wch: 8 },
|
||||
{ wch: 25 }, { wch: 30 }, { wch: 8 },
|
||||
{ wch: 20 }
|
||||
];
|
||||
|
||||
const wb = XLSX.utils.book_new();
|
||||
|
||||
@@ -135,6 +135,14 @@
|
||||
<el-button type="info" plain icon="el-icon-download" size="mini" @click="handleExportAllProps">导出全部</el-button>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="1.5" v-hasPermi="['wms.export.abnormalCoil']">
|
||||
<el-button icon="el-icon-download" size="mini" @click="handleAbnormalExportSingle">单行异常导出</el-button>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="1.5" v-hasPermi="['wms.export.abnormalCoil']">
|
||||
<el-button icon="el-icon-download" size="mini" @click="handleAbnormalExportMulti">多行异常导出</el-button>
|
||||
</el-col>
|
||||
|
||||
<el-col :span="1.5" v-if="showOrderBy">
|
||||
<el-checkbox v-model="queryParams.orderBy" v-loading="loading" @change="getList"
|
||||
label="orderBy">按实际库区排序</el-checkbox>
|
||||
@@ -2336,6 +2344,24 @@ export default {
|
||||
}, 'coil.xlsx')
|
||||
}
|
||||
},
|
||||
/** 单行异常导出 — 每个钢卷一行,附带异常信息 */
|
||||
handleAbnormalExportSingle() {
|
||||
const { orderBy, ...query } = this.queryParams;
|
||||
query.selectType = query.itemType;
|
||||
this.download('wms/materialCoil/exportAbnormal', {
|
||||
...query,
|
||||
abnormalExportCount: 1,
|
||||
}, `abnormalCoil_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
/** 多行异常导出 — 每个异常记录一行,附带异常信息 */
|
||||
handleAbnormalExportMulti() {
|
||||
const { orderBy, ...query } = this.queryParams;
|
||||
query.selectType = query.itemType;
|
||||
this.download('wms/materialCoil/exportAbnormal', {
|
||||
...query,
|
||||
abnormalExportCount: 0,
|
||||
}, `abnormalCoil_${new Date().getTime()}.xlsx`)
|
||||
},
|
||||
async handleNewExportProps(row) {
|
||||
this.loading = true
|
||||
let coilIds = ''
|
||||
|
||||
Reference in New Issue
Block a user