2026-03-18 15:41:09 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="app-container" v-loading="loading">
|
|
|
|
|
|
<el-row>
|
|
|
|
|
|
<el-form label-width="80px" inline>
|
|
|
|
|
|
<el-form-item label="开始时间" prop="startTime">
|
|
|
|
|
|
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart" type="datetime"
|
|
|
|
|
|
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择开始时间"></el-date-picker>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="结束时间" prop="endTime">
|
|
|
|
|
|
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd" type="datetime"
|
|
|
|
|
|
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择结束时间"></el-date-picker>
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="入场钢卷号" prop="endTime">
|
|
|
|
|
|
<el-input style="width: 200px; display: inline-block;" v-model="queryParams.enterCoilNo"
|
|
|
|
|
|
placeholder="请输入入场钢卷号" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="当前钢卷号" prop="endTime">
|
|
|
|
|
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
|
|
|
|
@keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="逻辑库位" prop="endTime">
|
|
|
|
|
|
<warehouse-select v-model="queryParams.warehouseId" placeholder="请选择仓库/库区/库位"
|
|
|
|
|
|
style="width: 100%; display: inline-block; width: 200px;" clearable />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="产品名称" prop="endTime">
|
|
|
|
|
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
|
|
|
|
@keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="规格" prop="endTime">
|
|
|
|
|
|
<memo-input style="width: 200px;" v-model="queryParams.itemSpecification" storageKey="coilSpec"
|
|
|
|
|
|
placeholder="请选择规格" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="材质" prop="endTime">
|
|
|
|
|
|
<muti-select style="width: 200px;" v-model="queryParams.itemMaterial" :options="dict.type.coil_material"
|
|
|
|
|
|
placeholder="请选择材质" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<el-form-item label="厂家" prop="endTime">
|
|
|
|
|
|
<muti-select style="width: 200px;" v-model="queryParams.itemManufacturer"
|
|
|
|
|
|
:options="dict.type.coil_manufacturer" placeholder="请选择厂家" clearable @keyup.enter.native="handleQuery" />
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
<!-- <el-form-item label="收货计划" prop="planId">
|
|
|
|
|
|
<el-select style="width: 200px;" v-model="queryParams.planId" placeholder="请输入计划名称搜索收货计划" filterable remote
|
|
|
|
|
|
:remote-method="remoteMethod">
|
|
|
|
|
|
<el-option v-for="item in planList" :key="item.planId" :label="item.planName" :value="item.planId" />
|
|
|
|
|
|
</el-select>
|
|
|
|
|
|
</el-form-item> -->
|
|
|
|
|
|
<el-form-item prop="endTime">
|
|
|
|
|
|
<el-button type="primary" @click="getList">查询</el-button>
|
|
|
|
|
|
<el-button type="primary" @click="exportData">导出</el-button>
|
2026-03-19 15:08:04 +08:00
|
|
|
|
<el-button type="primary" @click="settingVisible = true">列设置</el-button>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</el-form-item>
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions title="统计信息" :column="3" border>
|
|
|
|
|
|
<el-descriptions-item label="总钢卷数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
|
|
|
|
<el-descriptions-item label="均重">{{ summary.avgWeight }}t</el-descriptions-item>
|
|
|
|
|
|
</el-descriptions>
|
|
|
|
|
|
|
|
|
|
|
|
<el-descriptions title="明细信息" :column="3" border>
|
|
|
|
|
|
</el-descriptions>
|
2026-03-19 15:08:04 +08:00
|
|
|
|
<coil-table :columns="lossColumns" :data="list"></coil-table>
|
|
|
|
|
|
|
|
|
|
|
|
<el-dialog title="列设置" :visible.sync="settingVisible" width="50%">
|
|
|
|
|
|
<el-radio-group v-model="activeColumnConfig">
|
|
|
|
|
|
<el-radio-button label="coil-report-loss">消耗明细配置</el-radio-button>
|
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
|
<columns-setting :reportType="activeColumnConfig"></columns-setting>
|
|
|
|
|
|
</el-dialog>
|
2026-03-18 15:41:09 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import { listCoilWithIds } from "@/api/wms/coil";
|
|
|
|
|
|
import {
|
|
|
|
|
|
listPendingAction,
|
|
|
|
|
|
} from '@/api/wms/pendingAction';
|
|
|
|
|
|
import ProductInfo from "@/components/KLPService/Renderer/ProductInfo";
|
|
|
|
|
|
import RawMaterialInfo from "@/components/KLPService/Renderer/RawMaterialInfo";
|
|
|
|
|
|
import CoilNo from "@/components/KLPService/Renderer/CoilNo.vue";
|
|
|
|
|
|
import MemoInput from "@/components/MemoInput";
|
|
|
|
|
|
import MutiSelect from "@/components/MutiSelect";
|
|
|
|
|
|
import WarehouseSelect from "@/components/KLPService/WarehouseSelect";
|
|
|
|
|
|
import { listDeliveryPlan } from '@/api/wms/deliveryPlan'
|
2026-03-19 15:08:04 +08:00
|
|
|
|
import ColumnsSetting from "@/views/wms/report/components/setting/columns.vue";
|
|
|
|
|
|
import CoilTable from "@/views/wms/report/components/coilTable/index.vue";
|
2026-03-18 15:41:09 +08:00
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: 'LossTemplate',
|
|
|
|
|
|
components: {
|
|
|
|
|
|
ProductInfo,
|
|
|
|
|
|
RawMaterialInfo,
|
|
|
|
|
|
CoilNo,
|
|
|
|
|
|
MemoInput,
|
|
|
|
|
|
MutiSelect,
|
|
|
|
|
|
WarehouseSelect,
|
2026-03-19 15:08:04 +08:00
|
|
|
|
ColumnsSetting,
|
|
|
|
|
|
CoilTable,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
},
|
|
|
|
|
|
props: {
|
|
|
|
|
|
actionTypes: {
|
|
|
|
|
|
type: Array,
|
|
|
|
|
|
default: () => [],
|
|
|
|
|
|
},
|
|
|
|
|
|
actionQueryParams: {
|
|
|
|
|
|
type: Object,
|
|
|
|
|
|
default: () => {},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
|
|
|
|
data() {
|
|
|
|
|
|
// 工具函数:个位数补零,保证格式统一(比如 9 → 09,5 → 05)
|
|
|
|
|
|
const addZero = (num) => num.toString().padStart(2, '0')
|
|
|
|
|
|
|
|
|
|
|
|
const now = new Date() // 当前本地北京时间
|
|
|
|
|
|
// 核心:获取【昨天】的日期对象(自动处理跨月/跨年,无边界问题)
|
|
|
|
|
|
const yesterday = new Date(now)
|
|
|
|
|
|
yesterday.setDate(yesterday.getDate() - 1)
|
|
|
|
|
|
|
|
|
|
|
|
// 昨天的年、月、日(补零格式化)
|
|
|
|
|
|
const yesYear = yesterday.getFullYear()
|
|
|
|
|
|
const yesMonth = addZero(yesterday.getMonth() + 1)
|
|
|
|
|
|
const yesDay = addZero(yesterday.getDate())
|
|
|
|
|
|
|
|
|
|
|
|
// 今天的年、月、日(补零格式化)
|
|
|
|
|
|
const nowYear = now.getFullYear()
|
|
|
|
|
|
const nowMonth = addZero(now.getMonth() + 1)
|
|
|
|
|
|
const nowDay = addZero(now.getDate())
|
|
|
|
|
|
|
|
|
|
|
|
// ✅ 目标时间区间:昨天早上6点 至 今天早上6点
|
|
|
|
|
|
const startTime = `${yesYear}-${yesMonth}-${yesDay} 07:00:00`
|
|
|
|
|
|
const endTime = `${nowYear}-${nowMonth}-${nowDay} 07:00:00`
|
|
|
|
|
|
return {
|
2026-03-19 15:08:04 +08:00
|
|
|
|
activeColumnConfig: 'coil-report-loss',
|
|
|
|
|
|
settingVisible: false,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
list: [],
|
|
|
|
|
|
queryParams: {
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
// status: 1,
|
|
|
|
|
|
byCreateTimeStart: startTime,
|
|
|
|
|
|
byCreateTimeEnd: endTime,
|
|
|
|
|
|
selectType: 'raw_material',
|
|
|
|
|
|
enterCoilNo: '',
|
|
|
|
|
|
currentCoilNo: '',
|
|
|
|
|
|
warehouseId: '',
|
|
|
|
|
|
productName: '',
|
|
|
|
|
|
itemSpecification: '',
|
|
|
|
|
|
itemMaterial: '',
|
|
|
|
|
|
itemManufacturer: '',
|
|
|
|
|
|
planId: '',
|
|
|
|
|
|
},
|
|
|
|
|
|
planList: [],
|
|
|
|
|
|
loading: false,
|
2026-03-19 15:08:04 +08:00
|
|
|
|
|
|
|
|
|
|
lossColumns: [],
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
summary() {
|
|
|
|
|
|
// 总钢卷数量、总重、均重
|
|
|
|
|
|
const totalCount = this.list.length
|
|
|
|
|
|
const totalWeight = this.list.reduce((acc, cur) => acc + parseFloat(cur.netWeight), 0)
|
|
|
|
|
|
const avgWeight = totalCount > 0 ? (totalWeight / totalCount).toFixed(2) : 0
|
|
|
|
|
|
return {
|
|
|
|
|
|
totalCount,
|
|
|
|
|
|
totalWeight: totalWeight.toFixed(2),
|
|
|
|
|
|
avgWeight,
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
2026-03-19 15:08:04 +08:00
|
|
|
|
// 加载列设置
|
|
|
|
|
|
loadColumns() {
|
|
|
|
|
|
this.lossColumns = JSON.parse(localStorage.getItem('preference-tableColumns-coil-report-loss') || '[]') || []
|
|
|
|
|
|
},
|
|
|
|
|
|
// 统一查询入口
|
|
|
|
|
|
handleQuery() {
|
|
|
|
|
|
this.getList()
|
|
|
|
|
|
},
|
2026-03-18 15:41:09 +08:00
|
|
|
|
remoteMethod(query) {
|
|
|
|
|
|
listDeliveryPlan({ planName: query, pageNum: 1, pageSize: 5, planType: 1 }).then(res => {
|
|
|
|
|
|
this.planList = res.rows
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
async getList() {
|
|
|
|
|
|
this.loading = true
|
|
|
|
|
|
const resultList = await Promise.all(this.actionTypes.map(actionType => {
|
|
|
|
|
|
return listPendingAction({
|
|
|
|
|
|
actionStatus: 2,
|
|
|
|
|
|
warehouseId: this.queryParams.planId,
|
|
|
|
|
|
actionType,
|
|
|
|
|
|
pageSize: 9999,
|
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
|
startTime: this.queryParams.byCreateTimeStart,
|
|
|
|
|
|
endTime: this.queryParams.byCreateTimeEnd,
|
|
|
|
|
|
...this.actionQueryParams,
|
|
|
|
|
|
})
|
|
|
|
|
|
}))
|
|
|
|
|
|
const actions = resultList.flatMap(item => item.rows)
|
2026-03-19 15:08:04 +08:00
|
|
|
|
const actionIds = actions.map(item => item.actionId).join(',')
|
|
|
|
|
|
if (!actionIds) {
|
2026-03-18 15:41:09 +08:00
|
|
|
|
this.$message({
|
|
|
|
|
|
message: '暂无数据',
|
|
|
|
|
|
type: 'warning',
|
|
|
|
|
|
})
|
|
|
|
|
|
this.list = []
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
|
|
|
|
|
listCoilWithIds({
|
|
|
|
|
|
...this.queryParams,
|
|
|
|
|
|
byCreateTimeStart: undefined,
|
|
|
|
|
|
byCreateTimeEnd: undefined,
|
2026-03-19 15:08:04 +08:00
|
|
|
|
actionIds: actionIds,
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}).then(res => {
|
|
|
|
|
|
this.list = res.rows.map(item => {
|
|
|
|
|
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
2026-03-19 15:08:04 +08:00
|
|
|
|
const [thickness, width] = item.specification?.split('*') || [undefined, undefined]
|
2026-03-18 15:41:09 +08:00
|
|
|
|
return {
|
|
|
|
|
|
...item,
|
|
|
|
|
|
computedThickness: parseFloat(thickness),
|
|
|
|
|
|
computedWidth: parseFloat(width),
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
this.loading = false
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
// 导出
|
|
|
|
|
|
exportData() {
|
|
|
|
|
|
this.download('wms/materialCoil/export', {
|
|
|
|
|
|
coilIds: this.list.map(item => item.coilId).join(',')
|
|
|
|
|
|
}, `materialCoil_${new Date().getTime()}.xlsx`)
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.getList()
|
|
|
|
|
|
this.remoteMethod('')
|
2026-03-19 15:08:04 +08:00
|
|
|
|
this.loadColumns()
|
2026-03-18 15:41:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped></style>
|