diff --git a/nladmin-ui/src/views/wms/st/inbill/index.vue b/nladmin-ui/src/views/wms/st/inbill/index.vue index c56a892b..7f2c3458 100644 --- a/nladmin-ui/src/views/wms/st/inbill/index.vue +++ b/nladmin-ui/src/views/wms/st/inbill/index.vue @@ -130,6 +130,18 @@ > 强制确认 + + 导出明细 + 1) { - this.$refs.table.clearSelection() - this.$refs.table.toggleRowSelection(val.pop()) - this.buttonChange(row) - } else if (val.length === 1) { - this.buttonChange(row) - } else { + if (val.length === 0) { this.handleCurrentChange(null) + return + } + // 记录最后勾选的行,供分配、强制确认等单条操作使用 + this.buttonChange(row) + if (val.length > 1) { + // 多选只用于批量导出明细,单条操作按钮置为不可用,避免误操作 + this.dis_flag = true + this.task_flag = true } }, onSelectAll() { - this.$refs.table.clearSelection() + // 允许全选,便于一次性导出当前页全部单据的明细 this.handleCurrentChange(null) }, buttonChange(currentRow) { @@ -375,7 +391,62 @@ export default { this.divShow = true }) }, + exportDetail() { + const selections = this.crud.selections || [] + if (!selections.length) { + this.crud.notify('请先勾选要导出的单据', CRUD.NOTIFICATION_TYPE.INFO) + return + } + this.exporting = true + const promises = selections.map(bill => { + return crudRawAssist.getIODtl({ 'iostorinv_id': bill.iostorinv_id }).then(res => { + const dtlList = res.data || [] + return dtlList.map(dtl => ({ ...dtl, stor_name: dtl.stor_name || bill.stor_name })) + }) + }) + Promise.all(promises).then(results => { + const allDtls = results.reduce((acc, cur) => acc.concat(cur), []) + if (allDtls.length === 0) { + this.crud.notify('未查询到明细数据', CRUD.NOTIFICATION_TYPE.INFO) + return + } + const total = exportRowsToExcel({ + columns: this.detailColumns(), + rows: allDtls, + sheetName: '入库明细', + fileName: '入库明细' + }) + this.crud.notify('导出成功,共 ' + total + ' 条明细', CRUD.NOTIFICATION_TYPE.SUCCESS) + }).catch(() => { + this.crud.notify('导出失败,请重试', CRUD.NOTIFICATION_TYPE.ERROR) + }).finally(() => { + this.exporting = false + }) + }, + detailColumns() { + return [ + { label: '单据号', prop: 'bill_code', width: 20 }, + { label: '仓库', prop: 'stor_name', width: 18 }, + { label: '行号', prop: 'seq_no', width: 8 }, + { label: '物料编码', prop: 'material_code', width: 20 }, + { label: '物料名称', prop: 'material_name', width: 28 }, + { label: '批次号', prop: 'pcsn', width: 18 }, + { label: '明细状态', prop: 'bill_status', width: 12, value: row => this.dict.label.io_bill_status[row.bill_status] || row.bill_status }, + { label: '计划数量', prop: 'plan_qty', width: 12 }, + { label: '已分配数量', prop: 'assign_qty', width: 12 }, + { label: '未分配数量', prop: 'unassign_qty', width: 12 }, + { label: '实际数量', prop: 'real_qty', width: 12 }, + { label: '单位', prop: 'qty_unit_name', width: 8 }, + { label: '载具类型', prop: 'vehicle_type', width: 14 }, + { label: '载具编号', prop: 'storagevehicle_code', width: 18 }, + { label: '来源单号', prop: 'source_bill_code', width: 20 }, + { label: '备注', prop: 'remark', width: 24 } + ] + }, querytable() { + if (this.$refs.table) { + this.$refs.table.clearSelection() + } this.onSelectAll() this.crud.toQuery() } diff --git a/nladmin-ui/src/views/wms/st/outbill/index.vue b/nladmin-ui/src/views/wms/st/outbill/index.vue index 21f23187..992e6b62 100644 --- a/nladmin-ui/src/views/wms/st/outbill/index.vue +++ b/nladmin-ui/src/views/wms/st/outbill/index.vue @@ -159,6 +159,17 @@ @click="printBill" >出库标签打印 + 导出明细 + 1) { - this.$refs.table.clearSelection() - this.$refs.table.toggleRowSelection(val.pop()) - this.buttonChange(row) - } else if (val.length === 1) { - this.buttonChange(row) - } else { + if (val.length === 0) { this.handleCurrentChange(null) + return + } + // 记录最后勾选的行,供分配、强制确认等单条操作使用 + this.buttonChange(row) + if (val.length > 1) { + // 多选只用于批量导出明细,单条操作按钮置为不可用,避免误操作 + this.dis_flag = true + this.confirm_flag = true } }, onSelectAll() { - this.$refs.table.clearSelection() + // 允许全选,便于一次性导出当前页全部单据的明细 this.handleCurrentChange(null) }, doPrint() { @@ -394,6 +409,59 @@ export default { this.fetchDetailsAndPrint(selections) }).catch(() => {}) }, + exportDetail() { + const selections = this.crud.selections || [] + if (!selections.length) { + this.crud.notify('请先勾选要导出的单据', CRUD.NOTIFICATION_TYPE.INFO) + return + } + this.exporting = true + const promises = selections.map(bill => { + return checkoutbill.getOutBillDtl({ 'iostorinv_id': bill.iostorinv_id }).then(res => { + const dtlList = res.data || [] + return dtlList.map(dtl => ({ ...dtl, stor_name: dtl.stor_name || bill.stor_name })) + }) + }) + Promise.all(promises).then(results => { + const allDtls = results.reduce((acc, cur) => acc.concat(cur), []) + if (allDtls.length === 0) { + this.crud.notify('未查询到明细数据', CRUD.NOTIFICATION_TYPE.INFO) + return + } + const total = exportRowsToExcel({ + columns: this.detailColumns(), + rows: allDtls, + sheetName: '出库明细', + fileName: '出库明细' + }) + this.crud.notify('导出成功,共 ' + total + ' 条明细', CRUD.NOTIFICATION_TYPE.SUCCESS) + }).catch(() => { + this.crud.notify('导出失败,请重试', CRUD.NOTIFICATION_TYPE.ERROR) + }).finally(() => { + this.exporting = false + }) + }, + detailColumns() { + return [ + { label: '单据号', prop: 'bill_code', width: 20 }, + { label: '仓库', prop: 'stor_name', width: 18 }, + { label: '行号', prop: 'seq_no', width: 8 }, + { label: '物料编码', prop: 'material_code', width: 20 }, + { label: '物料名称', prop: 'material_name', width: 28 }, + { label: '批次号', prop: 'pcsn', width: 18 }, + { label: '明细状态', prop: 'bill_status', width: 12, value: row => this.dict.label.io_bill_status[row.bill_status] || row.bill_status }, + { label: '计划数量', prop: 'plan_qty', width: 12 }, + { label: '已分配数量', prop: 'assign_qty', width: 12 }, + { label: '未分配数量', prop: 'unassign_qty', width: 12 }, + { label: '实际数量', prop: 'real_qty', width: 12 }, + { label: '单位', prop: 'qty_unit_name', width: 8 }, + { label: '载具类型', prop: 'vehicle_type', width: 14 }, + { label: '载具编号', prop: 'storagevehicle_code', width: 18 }, + { label: '用料位置', prop: 'source_load_port', width: 16 }, + { label: '来源单号', prop: 'source_bill_code', width: 20 }, + { label: '备注', prop: 'remark', width: 24 } + ] + }, fetchDetailsAndPrint(selections) { const promises = selections.map(bill => { return checkoutbill.getOutBillDtl({ 'iostorinv_id': bill.iostorinv_id }).then(res => { @@ -546,6 +614,9 @@ export default { }) }, querytable() { + if (this.$refs.table) { + this.$refs.table.clearSelection() + } this.onSelectAll() this.crud.toQuery() this.handleCurrentChange(null)