refactor(wms/report): 重构报表页面,提取公共组件和逻辑
将多个报表页面的公共逻辑提取到模板组件中,包括: 1. 创建out.vue和loss.vue作为基础模板 2. 重构zha.vue、zinc.vue等页面使用模板组件 3. 统一处理规格解析逻辑,添加宽度和厚度显示列 4. 优化仓库选择和查询参数处理
This commit is contained in:
@@ -67,14 +67,16 @@
|
|||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
<!-- <el-table-column label="逻辑库位" align="center" prop="warehouseName" /> -->
|
<!-- <el-table-column label="逻辑库位" align="center" prop="warehouseName" /> -->
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70"/>
|
||||||
|
<el-table-column label="重量(吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度(米)" align="center" prop="length" />
|
||||||
<!-- <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip /> -->
|
<!-- <el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip /> -->
|
||||||
<el-table-column label="发货时间" align="center" prop="exportTime" />
|
<el-table-column label="发货时间" align="center" prop="exportTime" />
|
||||||
<!-- <el-table-column label="出库状态" align="center" prop="status">
|
<!-- <el-table-column label="出库状态" align="center" prop="status">
|
||||||
@@ -187,7 +189,15 @@ export default {
|
|||||||
listCoilWithIds({
|
listCoilWithIds({
|
||||||
...this.queryParams
|
...this.queryParams
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.list = res.rows
|
this.list = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -74,12 +74,14 @@
|
|||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70"/>
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
@@ -208,7 +210,15 @@ export default {
|
|||||||
...this.queryParams,
|
...this.queryParams,
|
||||||
coilIds: coilIds,
|
coilIds: coilIds,
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
this.list = res.rows
|
this.list = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
377
klp-ui/src/views/wms/report/template/day.vue
Normal file
377
klp-ui/src/views/wms/report/template/day.vue
Normal file
@@ -0,0 +1,377 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container" v-loading="loading">
|
||||||
|
<el-row>
|
||||||
|
<el-form label-width="80px" inline>
|
||||||
|
<el-form-item label="日期" prop="date">
|
||||||
|
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="date" value-format="yyyy-MM-dd"
|
||||||
|
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||||
|
<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="currentCoilNo">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="逻辑库位" prop="warehouseIds">
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称" prop="itemName">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="规格" prop="itemSpecification">
|
||||||
|
<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="itemMaterial">
|
||||||
|
<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="itemManufacturer">
|
||||||
|
<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>
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
||||||
|
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
||||||
|
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-descriptions title="统计信息" :column="3" border>
|
||||||
|
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<!-- 成品率 -->
|
||||||
|
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||||
|
<!-- 异常率 -->
|
||||||
|
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<!-- 异常统计 -->
|
||||||
|
<el-descriptions title="异常统计" :column="4" border>
|
||||||
|
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
||||||
|
}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-descriptions title="明细信息" :column="3" border>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="投入钢卷" name="loss">
|
||||||
|
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
||||||
|
<el-table-column label="产品类型" align="center" width="250">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="产出钢卷" name="output">
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<!-- 0在库,1已出库 -->
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
|
</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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'DayTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
actionTypes: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
actionQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { },
|
||||||
|
},
|
||||||
|
baseQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
warehouseOptions: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
||||||
|
data() {
|
||||||
|
// 工具函数:个位数补零
|
||||||
|
const addZero = (num) => num.toString().padStart(2, '0')
|
||||||
|
|
||||||
|
// 获取当前日期(默认选中当天)
|
||||||
|
const now = new Date()
|
||||||
|
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}-${addZero(now.getDate())}`
|
||||||
|
|
||||||
|
// 生成指定日期的 00:00:00 和 23:59:59 时间字符串
|
||||||
|
const getDayTimeRange = (dateStr) => {
|
||||||
|
return {
|
||||||
|
start: `${dateStr} 00:00:00`,
|
||||||
|
end: `${dateStr} 23:59:59`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const { start, end } = getDayTimeRange(currentDate)
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab: 'loss',
|
||||||
|
list: [],
|
||||||
|
lossList: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
// date: currentDate, // 绑定日期选择器的默认值(当天)
|
||||||
|
byCreateTimeStart: start, // 默认当天0点
|
||||||
|
byCreateTimeEnd: end, // 默认当天23:59:59
|
||||||
|
selectType: 'product',
|
||||||
|
enterCoilNo: '',
|
||||||
|
currentCoilNo: '',
|
||||||
|
warehouseId: '',
|
||||||
|
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
||||||
|
itemSpecification: '',
|
||||||
|
itemMaterial: '',
|
||||||
|
itemManufacturer: '',
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
'2019583656787259393',
|
||||||
|
'2019583325311414274',
|
||||||
|
'2019583429955104769',
|
||||||
|
'2019583137616310273',
|
||||||
|
],
|
||||||
|
getDayTimeRange // 挂载时间范围生成函数
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
warehouseOptions: {
|
||||||
|
handler(newVal, oldVal) {
|
||||||
|
if (newVal !== oldVal) {
|
||||||
|
this.warehouseIds = newVal.map(item => item.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
summary() {
|
||||||
|
return calcSummary(this.list, this.lossList)
|
||||||
|
},
|
||||||
|
abSummary() {
|
||||||
|
return calcAbSummary(this.list)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 日期变更处理:更新开始/结束时间
|
||||||
|
handleDateChange(date) {
|
||||||
|
if (!date) return
|
||||||
|
const { start, end } = this.getDayTimeRange(date)
|
||||||
|
this.queryParams.byCreateTimeStart = start
|
||||||
|
this.queryParams.byCreateTimeEnd = end
|
||||||
|
// 日期变更后自动查询
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
// 统一查询入口(兼容回车和按钮点击)
|
||||||
|
handleQuery() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
},
|
||||||
|
// 核心查询逻辑
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
Promise.all([
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'raw_material',
|
||||||
|
itemType: 'raw_material',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'product',
|
||||||
|
itemType: 'product',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
]).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
|
// 按照createTime 降序排序
|
||||||
|
this.list = list.sort(
|
||||||
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
).map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getLossList() {
|
||||||
|
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)
|
||||||
|
const coilIds = actions.map(item => item.coilId).join(',')
|
||||||
|
console.log(coilIds)
|
||||||
|
if (!coilIds) {
|
||||||
|
this.$message({
|
||||||
|
message: '暂无数据',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
this.lossList = []
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listCoilWithIds({
|
||||||
|
...this.queryParams,
|
||||||
|
byCreateTimeStart: undefined,
|
||||||
|
byCreateTimeEnd: undefined,
|
||||||
|
coilIds: coilIds,
|
||||||
|
}).then(res => {
|
||||||
|
this.lossList = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 导出
|
||||||
|
exportData() {
|
||||||
|
if (this.list.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.list.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
exportLossData() {
|
||||||
|
if (this.lossList.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.lossList.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
252
klp-ui/src/views/wms/report/template/loss.vue
Normal file
252
klp-ui/src/views/wms/report/template/loss.vue
Normal file
@@ -0,0 +1,252 @@
|
|||||||
|
<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>
|
||||||
|
</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>
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70"/>
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<!-- <el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column> -->
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</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'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'LossTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect,
|
||||||
|
},
|
||||||
|
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 {
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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: {
|
||||||
|
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)
|
||||||
|
const coilIds = actions.map(item => item.coilId).join(',')
|
||||||
|
if (!coilIds) {
|
||||||
|
this.$message({
|
||||||
|
message: '暂无数据',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
this.list = []
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listCoilWithIds({
|
||||||
|
...this.queryParams,
|
||||||
|
byCreateTimeStart: undefined,
|
||||||
|
byCreateTimeEnd: undefined,
|
||||||
|
coilIds: coilIds,
|
||||||
|
}).then(res => {
|
||||||
|
this.list = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
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('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@@ -108,12 +108,14 @@
|
|||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
@@ -259,8 +261,24 @@ export default {
|
|||||||
listCoilWithIds({ ...this.queryParams, coilIds: lossIds.join(',') || '' }),
|
listCoilWithIds({ ...this.queryParams, coilIds: lossIds.join(',') || '' }),
|
||||||
listCoilWithIds({ ...this.queryParams, coilIds: outIds.join(',') || '' }),
|
listCoilWithIds({ ...this.queryParams, coilIds: outIds.join(',') || '' }),
|
||||||
]);
|
]);
|
||||||
this.lossList = lossRes.rows;
|
this.lossList = lossRes.rows.map(item => {
|
||||||
this.outList = outRes.rows;
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.outList = outRes.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
});
|
||||||
this.loading = false;
|
this.loading = false;
|
||||||
},
|
},
|
||||||
// 导出
|
// 导出
|
||||||
|
|||||||
407
klp-ui/src/views/wms/report/template/month.vue
Normal file
407
klp-ui/src/views/wms/report/template/month.vue
Normal file
@@ -0,0 +1,407 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container" v-loading="loading">
|
||||||
|
<el-row>
|
||||||
|
<el-form label-width="80px" inline>
|
||||||
|
<el-form-item label="日期" prop="date">
|
||||||
|
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="month" value-format="yyyy-MM"
|
||||||
|
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||||
|
<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="currentCoilNo">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="逻辑库位" prop="warehouseIds">
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称" prop="itemName">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="规格" prop="itemSpecification">
|
||||||
|
<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="itemMaterial">
|
||||||
|
<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="itemManufacturer">
|
||||||
|
<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>
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
||||||
|
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-descriptions title="统计信息" :column="3" border>
|
||||||
|
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<!-- 成品率 -->
|
||||||
|
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||||
|
<!-- 异常率 -->
|
||||||
|
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<!-- 异常统计 -->
|
||||||
|
<el-descriptions title="异常统计" :column="4" border>
|
||||||
|
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
||||||
|
}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-descriptions title="明细信息" :column="3" border>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="投入钢卷" name="loss">
|
||||||
|
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
||||||
|
<el-table-column label="产品类型" align="center" width="250">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="产出钢卷" name="output">
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<!-- 0在库,1已出库 -->
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
|
</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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'MonthTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
actionTypes: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
actionQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { },
|
||||||
|
},
|
||||||
|
baseQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
warehouseOptions: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
||||||
|
data() {
|
||||||
|
// 工具函数:个位数补零
|
||||||
|
const addZero = (num) => num.toString().padStart(2, '0')
|
||||||
|
|
||||||
|
// 获取当前日期(默认选中当天)
|
||||||
|
const now = new Date()
|
||||||
|
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成指定日期/月份的时间范围字符串
|
||||||
|
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
||||||
|
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
||||||
|
*/
|
||||||
|
const getDayTimeRange = (dateStr) => {
|
||||||
|
// 先校验输入格式是否合法
|
||||||
|
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
||||||
|
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
||||||
|
|
||||||
|
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
||||||
|
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
||||||
|
}
|
||||||
|
|
||||||
|
let startDate, endDate;
|
||||||
|
|
||||||
|
if (monthPattern.test(dateStr)) {
|
||||||
|
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
||||||
|
const [year, month] = dateStr.split('-').map(Number);
|
||||||
|
// 月份是0基的(0=1月,1=2月...),所以要减1
|
||||||
|
// 第一天:yyyy-MM-01
|
||||||
|
startDate = `${dateStr}-01`;
|
||||||
|
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
||||||
|
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
||||||
|
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
||||||
|
} else {
|
||||||
|
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
||||||
|
startDate = dateStr;
|
||||||
|
endDate = dateStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接时间部分
|
||||||
|
return {
|
||||||
|
start: `${startDate} 00:00:00`,
|
||||||
|
end: `${endDate} 23:59:59`
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const { start, end } = getDayTimeRange(currentDate)
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab: 'loss',
|
||||||
|
list: [],
|
||||||
|
lossList: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
date: currentDate, // 绑定日期选择器的默认值(当天)
|
||||||
|
byCreateTimeStart: start, // 默认当天0点
|
||||||
|
byCreateTimeEnd: end, // 默认当天23:59:59
|
||||||
|
selectType: 'product',
|
||||||
|
enterCoilNo: '',
|
||||||
|
currentCoilNo: '',
|
||||||
|
warehouseId: '',
|
||||||
|
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
||||||
|
itemSpecification: '',
|
||||||
|
itemMaterial: '',
|
||||||
|
itemManufacturer: '',
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
'2019583656787259393',
|
||||||
|
'2019583325311414274',
|
||||||
|
'2019583429955104769',
|
||||||
|
'2019583137616310273',
|
||||||
|
],
|
||||||
|
getDayTimeRange // 挂载时间范围生成函数
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
warehouseOptions: {
|
||||||
|
handler(newVal, oldVal) {
|
||||||
|
if (newVal !== oldVal) {
|
||||||
|
this.warehouseIds = newVal.map(item => item.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
summary() {
|
||||||
|
return calcSummary(this.list, this.lossList)
|
||||||
|
},
|
||||||
|
abSummary() {
|
||||||
|
return calcAbSummary(this.list)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 日期变更处理:更新开始/结束时间
|
||||||
|
handleDateChange(date) {
|
||||||
|
if (!date) return
|
||||||
|
const { start, end } = this.getDayTimeRange(date)
|
||||||
|
this.queryParams.byCreateTimeStart = start
|
||||||
|
this.queryParams.byCreateTimeEnd = end
|
||||||
|
// 日期变更后自动查询
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
// 统一查询入口(兼容回车和按钮点击)
|
||||||
|
handleQuery() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
},
|
||||||
|
// 核心查询逻辑
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
Promise.all([
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'raw_material',
|
||||||
|
itemType: 'raw_material',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'product',
|
||||||
|
itemType: 'product',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
]).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
|
// 按照createTime 降序排序
|
||||||
|
this.list = list.sort(
|
||||||
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
).map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getLossList() {
|
||||||
|
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)
|
||||||
|
const coilIds = actions.map(item => item.coilId).join(',')
|
||||||
|
console.log(coilIds)
|
||||||
|
if (!coilIds) {
|
||||||
|
this.$message({
|
||||||
|
message: '暂无数据',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
this.lossList = []
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listCoilWithIds({
|
||||||
|
...this.queryParams,
|
||||||
|
byCreateTimeStart: undefined,
|
||||||
|
byCreateTimeEnd: undefined,
|
||||||
|
coilIds: coilIds,
|
||||||
|
}).then(res => {
|
||||||
|
this.lossList = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 导出
|
||||||
|
exportData() {
|
||||||
|
if (this.list.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.list.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
exportLossData() {
|
||||||
|
if (this.lossList.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.lossList.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
248
klp-ui/src/views/wms/report/template/out.vue
Normal file
248
klp-ui/src/views/wms/report/template/out.vue
Normal file
@@ -0,0 +1,248 @@
|
|||||||
|
<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-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</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 prop="endTime">
|
||||||
|
<el-button type="primary" @click="getList">查询</el-button>
|
||||||
|
<el-button type="primary" @click="exportData">导出</el-button>
|
||||||
|
</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>
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<!-- 0在库,1已出库 -->
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { listCoilWithIds } from "@/api/wms/coil";
|
||||||
|
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";
|
||||||
|
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'OutTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
baseQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
warehouseOptions: {
|
||||||
|
type: Array,
|
||||||
|
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 {
|
||||||
|
list: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
// status: 1,
|
||||||
|
byCreateTimeStart: startTime,
|
||||||
|
byCreateTimeEnd: endTime,
|
||||||
|
enterCoilNo: '',
|
||||||
|
currentCoilNo: '',
|
||||||
|
warehouseId: '',
|
||||||
|
productName: '',
|
||||||
|
itemSpecification: '',
|
||||||
|
itemMaterial: '',
|
||||||
|
itemManufacturer: '',
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
'2019583656787259393',
|
||||||
|
'2019583325311414274',
|
||||||
|
'2019583429955104769',
|
||||||
|
'2019583137616310273',
|
||||||
|
],
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
warehouseOptions: {
|
||||||
|
handler(newVal, oldVal) {
|
||||||
|
if (newVal !== oldVal) {
|
||||||
|
this.warehouseIds = newVal.map(item => item.value)
|
||||||
|
this.getList()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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: {
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
Promise.all([
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'raw_material',
|
||||||
|
itemType: 'raw_material',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'product',
|
||||||
|
itemType: 'product',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
]).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
|
// 按照createTime 降序排序
|
||||||
|
this.list = list.sort(
|
||||||
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
).map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
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`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
391
klp-ui/src/views/wms/report/template/team.vue
Normal file
391
klp-ui/src/views/wms/report/template/team.vue
Normal file
@@ -0,0 +1,391 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container" v-loading="loading">
|
||||||
|
<el-row>
|
||||||
|
<el-form label-width="80px" inline>
|
||||||
|
<el-form-item label="开始日期">
|
||||||
|
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart" type="date"
|
||||||
|
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="结束日期">
|
||||||
|
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd" type="date"
|
||||||
|
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="班组">
|
||||||
|
<el-select v-model="queryParams.team" placeholder="请选择班组" style="width: 200px;">
|
||||||
|
<el-option label="甲" value="甲" />
|
||||||
|
<el-option label="乙" value="乙" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入场钢卷号">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.enterCoilNo" placeholder="请输入入场钢卷号" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="当前钢卷号">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="逻辑库位">
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="规格">
|
||||||
|
<memo-input style="width: 200px;" v-model="queryParams.itemSpecification" storageKey="coilSpec"
|
||||||
|
placeholder="请选择规格" clearable @keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="材质">
|
||||||
|
<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="厂家">
|
||||||
|
<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>
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
||||||
|
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-descriptions title="统计信息" :column="3" border>
|
||||||
|
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-descriptions title="异常统计" :column="4" border>
|
||||||
|
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
||||||
|
}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-descriptions title="班组统计信息" :column="3" border>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-table :data="teamSummary" border>
|
||||||
|
<el-table-column label="班组" align="center" prop="team" />
|
||||||
|
<el-table-column label="产出数量" align="center" prop="outCount" />
|
||||||
|
<el-table-column label="产出总重" align="center" prop="outWeight" />
|
||||||
|
</el-table>
|
||||||
|
|
||||||
|
<el-descriptions title="明细信息" :column="3" border>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="投入钢卷" name="loss">
|
||||||
|
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="250">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="产出钢卷" name="output">
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="班组" align="center" prop="team" />
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</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 { calcSummary, calcAbSummary, calcTeamSummary } from "@/views/wms/report/js/calc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'TeamTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
actionTypes: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
},
|
||||||
|
actionQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { }
|
||||||
|
},
|
||||||
|
baseQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { }
|
||||||
|
},
|
||||||
|
warehouseOptions: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
||||||
|
data() {
|
||||||
|
const addZero = (num) => num.toString().padStart(2, '0');
|
||||||
|
const now = new Date();
|
||||||
|
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}-${addZero(now.getDate())}`;
|
||||||
|
|
||||||
|
const getDayTimeRange = (dateStr) => {
|
||||||
|
return {
|
||||||
|
start: `${dateStr} 00:00:00`,
|
||||||
|
end: `${dateStr} 23:59:59`
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const { start, end } = getDayTimeRange(currentDate);
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab: 'loss',
|
||||||
|
list: [],
|
||||||
|
lossList: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
date: currentDate,
|
||||||
|
byCreateTimeStart: start,
|
||||||
|
byCreateTimeEnd: end,
|
||||||
|
selectType: 'product',
|
||||||
|
enterCoilNo: '',
|
||||||
|
currentCoilNo: '',
|
||||||
|
warehouseId: '',
|
||||||
|
itemName: '',
|
||||||
|
itemSpecification: '',
|
||||||
|
itemMaterial: '',
|
||||||
|
itemManufacturer: '',
|
||||||
|
team: ''
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
'2019583656787259393',
|
||||||
|
'2019583325311414274',
|
||||||
|
'2019583429955104769',
|
||||||
|
'2019583137616310273'
|
||||||
|
],
|
||||||
|
getDayTimeRange
|
||||||
|
};
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
warehouseOptions: {
|
||||||
|
handler(newVal) {
|
||||||
|
if (newVal) {
|
||||||
|
this.warehouseIds = newVal.map(item => item.value);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
summary() {
|
||||||
|
return calcSummary(this.list, this.lossList);
|
||||||
|
},
|
||||||
|
abSummary() {
|
||||||
|
return calcAbSummary(this.list);
|
||||||
|
},
|
||||||
|
teamSummary() {
|
||||||
|
const teamOutSummary = calcTeamSummary(this.list);
|
||||||
|
const allTeams = [...new Set(Object.keys(teamOutSummary))];
|
||||||
|
|
||||||
|
return allTeams.map(team => {
|
||||||
|
const outData = teamOutSummary[team] || { count: 0, weight: 0 };
|
||||||
|
const formatWeight = function (weight) {
|
||||||
|
return Number(weight || 0).toFixed(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
return {
|
||||||
|
team: team,
|
||||||
|
outCount: outData.count,
|
||||||
|
outWeight: formatWeight(outData.weight)
|
||||||
|
};
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
handleQuery() {
|
||||||
|
this.getList();
|
||||||
|
this.getLossList();
|
||||||
|
},
|
||||||
|
getList() {
|
||||||
|
this.loading = true;
|
||||||
|
Promise.all([
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'raw_material',
|
||||||
|
itemType: 'raw_material',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams
|
||||||
|
}),
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'product',
|
||||||
|
itemType: 'product',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams
|
||||||
|
})
|
||||||
|
]).then(resList => {
|
||||||
|
const list = resList.flatMap(res => res.rows);
|
||||||
|
this.list = list.sort((a, b) => new Date(b.createTime) - new Date(a.createTime)).map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
}).catch(err => {
|
||||||
|
console.error('查询失败:', err);
|
||||||
|
this.loading = false;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async getLossList() {
|
||||||
|
this.loading = true;
|
||||||
|
try {
|
||||||
|
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);
|
||||||
|
const coilIds = actions.map(item => item.coilId).join(',');
|
||||||
|
|
||||||
|
if (!coilIds) {
|
||||||
|
this.$message({
|
||||||
|
message: '暂无数据',
|
||||||
|
type: 'warning'
|
||||||
|
});
|
||||||
|
this.lossList = [];
|
||||||
|
this.loading = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const res = await listCoilWithIds({
|
||||||
|
...this.queryParams,
|
||||||
|
byCreateTimeStart: undefined,
|
||||||
|
byCreateTimeEnd: undefined,
|
||||||
|
coilIds: coilIds
|
||||||
|
});
|
||||||
|
this.lossList = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.loading = false;
|
||||||
|
} catch (err) {
|
||||||
|
console.error('查询失败:', err);
|
||||||
|
this.loading = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
exportData() {
|
||||||
|
if (this.list.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.list.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`);
|
||||||
|
},
|
||||||
|
exportLossData() {
|
||||||
|
if (this.lossList.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.lossList.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getList();
|
||||||
|
this.getLossList();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
386
klp-ui/src/views/wms/report/template/year.vue
Normal file
386
klp-ui/src/views/wms/report/template/year.vue
Normal file
@@ -0,0 +1,386 @@
|
|||||||
|
<template>
|
||||||
|
<div class="app-container" v-loading="loading">
|
||||||
|
<el-row>
|
||||||
|
<el-form label-width="80px" inline>
|
||||||
|
<el-form-item label="日期" prop="date">
|
||||||
|
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="year" value-format="yyyy"
|
||||||
|
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
||||||
|
<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="currentCoilNo">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="逻辑库位" prop="warehouseIds">
|
||||||
|
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
||||||
|
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="产品名称" prop="itemName">
|
||||||
|
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
||||||
|
@keyup.enter.native="handleQuery" />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="规格" prop="itemSpecification">
|
||||||
|
<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="itemMaterial">
|
||||||
|
<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="itemManufacturer">
|
||||||
|
<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>
|
||||||
|
<el-button type="primary" @click="handleQuery">查询</el-button>
|
||||||
|
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
||||||
|
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-descriptions title="统计信息" :column="3" border>
|
||||||
|
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
||||||
|
|
||||||
|
<!-- 成品率 -->
|
||||||
|
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
||||||
|
<!-- 异常率 -->
|
||||||
|
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<!-- 异常统计 -->
|
||||||
|
<el-descriptions title="异常统计" :column="4" border>
|
||||||
|
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
||||||
|
}}</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
|
||||||
|
<el-descriptions title="明细信息" :column="3" border>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-tabs v-model="activeTab">
|
||||||
|
<el-tab-pane label="投入钢卷" name="loss">
|
||||||
|
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
||||||
|
<el-table-column label="产品类型" align="center" width="250">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
<el-tab-pane label="产出钢卷" name="output">
|
||||||
|
<el-table :data="list" border height="calc(100vh - 320px)">
|
||||||
|
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="创建时间" align="center" prop="createTime" />
|
||||||
|
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
||||||
|
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
||||||
|
<el-table-column label="产品类型" align="center" width="150">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
||||||
|
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="宽度(米)" align="center" prop="computedWidth" width="70" />
|
||||||
|
<el-table-column label="厚度(米)" align="center" prop="computedThickness" width="70" />
|
||||||
|
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
||||||
|
<el-table-column label="长度 (米)" align="center" prop="length" />
|
||||||
|
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
||||||
|
<el-table-column label="出库状态" align="center" prop="status">
|
||||||
|
<!-- 0在库,1已出库 -->
|
||||||
|
<template slot-scope="scope">
|
||||||
|
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="更新人" align="center" prop="updateByName" />
|
||||||
|
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
||||||
|
</el-table>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
|
||||||
|
</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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'YearTemplate',
|
||||||
|
components: {
|
||||||
|
ProductInfo,
|
||||||
|
RawMaterialInfo,
|
||||||
|
CoilNo,
|
||||||
|
MemoInput,
|
||||||
|
MutiSelect,
|
||||||
|
WarehouseSelect,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
actionTypes: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
actionQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => { },
|
||||||
|
},
|
||||||
|
baseQueryParams: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({})
|
||||||
|
},
|
||||||
|
warehouseOptions: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
||||||
|
data() {
|
||||||
|
// 获取当前日期(默认选中当天)
|
||||||
|
const now = new Date()
|
||||||
|
const currentDate = `${now.getFullYear()}`
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 生成指定年份的时间范围字符串
|
||||||
|
* @param {string} dateStr - 必须为 yyyy 格式(如 "2026")
|
||||||
|
* @returns {object} 包含start(当年第一天)和end(当年最后一天)的时间对象
|
||||||
|
* @throws {Error} 输入格式错误时抛出异常
|
||||||
|
*/
|
||||||
|
const getDayTimeRange = (dateStr) => {
|
||||||
|
// 校验输入格式:必须是4位数字的yyyy格式
|
||||||
|
const yearPattern = /^\d{4}$/;
|
||||||
|
if (!yearPattern.test(dateStr)) {
|
||||||
|
throw new Error('输入格式错误,请传入 yyyy 格式的字符串(如 "2026")');
|
||||||
|
}
|
||||||
|
|
||||||
|
// 拼接当年第一天和最后一天的完整日期+时间
|
||||||
|
return {
|
||||||
|
start: `${dateStr}-01-01 00:00:00`, // 年-01-01 0点
|
||||||
|
end: `${dateStr}-12-31 23:59:59` // 年-12-31 23点59分59秒
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const { start, end } = getDayTimeRange(currentDate)
|
||||||
|
|
||||||
|
return {
|
||||||
|
activeTab: 'loss',
|
||||||
|
list: [],
|
||||||
|
lossList: [],
|
||||||
|
queryParams: {
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 9999,
|
||||||
|
date: currentDate, // 绑定日期选择器的默认值(当天)
|
||||||
|
byCreateTimeStart: start, // 默认当天0点
|
||||||
|
byCreateTimeEnd: end, // 默认当天23:59:59
|
||||||
|
selectType: 'product',
|
||||||
|
enterCoilNo: '',
|
||||||
|
currentCoilNo: '',
|
||||||
|
warehouseId: '',
|
||||||
|
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
||||||
|
itemSpecification: '',
|
||||||
|
itemMaterial: '',
|
||||||
|
itemManufacturer: '',
|
||||||
|
},
|
||||||
|
loading: false,
|
||||||
|
warehouseIds: [
|
||||||
|
'1988150099140866050',
|
||||||
|
'1988150263284953089',
|
||||||
|
'1988150545175736322',
|
||||||
|
'1988150150521090049',
|
||||||
|
'2019583656787259393',
|
||||||
|
'2019583325311414274',
|
||||||
|
'2019583429955104769',
|
||||||
|
'2019583137616310273',
|
||||||
|
],
|
||||||
|
getDayTimeRange // 挂载时间范围生成函数
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
warehouseOptions: {
|
||||||
|
handler(newVal, oldVal) {
|
||||||
|
if (newVal !== oldVal) {
|
||||||
|
this.warehouseIds = newVal.map(item => item.value)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
summary() {
|
||||||
|
return calcSummary(this.list, this.lossList)
|
||||||
|
},
|
||||||
|
abSummary() {
|
||||||
|
return calcAbSummary(this.list)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
// 日期变更处理:更新开始/结束时间
|
||||||
|
handleDateChange(date) {
|
||||||
|
if (!date) return
|
||||||
|
const { start, end } = this.getDayTimeRange(date)
|
||||||
|
this.queryParams.byCreateTimeStart = start
|
||||||
|
this.queryParams.byCreateTimeEnd = end
|
||||||
|
// 日期变更后自动查询
|
||||||
|
this.handleQuery()
|
||||||
|
},
|
||||||
|
// 统一查询入口(兼容回车和按钮点击)
|
||||||
|
handleQuery() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
},
|
||||||
|
// 核心查询逻辑
|
||||||
|
getList() {
|
||||||
|
this.loading = true
|
||||||
|
Promise.all([
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'raw_material',
|
||||||
|
itemType: 'raw_material',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
listCoilWithIds({
|
||||||
|
selectType: 'product',
|
||||||
|
itemType: 'product',
|
||||||
|
warehouseIds: this.warehouseIds.join(','),
|
||||||
|
...this.queryParams,
|
||||||
|
...this.baseQueryParams,
|
||||||
|
}),
|
||||||
|
]).then((resList) => {
|
||||||
|
console.log(resList)
|
||||||
|
const list = resList.flatMap(res => res.rows)
|
||||||
|
// 按照createTime 降序排序
|
||||||
|
this.list = list.sort(
|
||||||
|
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
||||||
|
).map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async getLossList() {
|
||||||
|
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)
|
||||||
|
const coilIds = actions.map(item => item.coilId).join(',')
|
||||||
|
console.log(coilIds)
|
||||||
|
if (!coilIds) {
|
||||||
|
this.$message({
|
||||||
|
message: '暂无数据',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
this.lossList = []
|
||||||
|
this.loading = false
|
||||||
|
return
|
||||||
|
}
|
||||||
|
listCoilWithIds({
|
||||||
|
...this.queryParams,
|
||||||
|
byCreateTimeStart: undefined,
|
||||||
|
byCreateTimeEnd: undefined,
|
||||||
|
coilIds: coilIds,
|
||||||
|
}).then(res => {
|
||||||
|
this.lossList = res.rows.map(item => {
|
||||||
|
// 计算宽度和厚度,将规格按照*分割,*前的是厚度,*后的是宽度
|
||||||
|
const [thickness, width] = item.specification.split('*')
|
||||||
|
return {
|
||||||
|
...item,
|
||||||
|
computedThickness: parseFloat(thickness),
|
||||||
|
computedWidth: parseFloat(width),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
this.loading = false
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 导出
|
||||||
|
exportData() {
|
||||||
|
if (this.list.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.list.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
exportLossData() {
|
||||||
|
if (this.lossList.length === 0) {
|
||||||
|
this.$message.warning('暂无数据可导出')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.download('wms/materialCoil/export', {
|
||||||
|
coilIds: this.lossList.map(item => item.coilId).join(',')
|
||||||
|
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.getList()
|
||||||
|
this.getLossList()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped></style>
|
||||||
@@ -1,166 +1,23 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<OutTemplate
|
||||||
<el-row>
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-form label-width="80px" inline>
|
:warehouseOptions="warehouseOptions"
|
||||||
<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-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</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 prop="endTime">
|
|
||||||
<el-button type="primary" @click="getList">查询</el-button>
|
|
||||||
<el-button type="primary" @click="exportData">导出</el-button>
|
|
||||||
</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>
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import OutTemplate from "@/views/wms/report/template/out.vue";
|
||||||
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";
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'ZhaTemplate',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
OutTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
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 {
|
return {
|
||||||
list: [],
|
baseQueryParams: {
|
||||||
queryParams: {
|
createBy: 'suanzhakuguan',
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 9999,
|
|
||||||
// status: 1,
|
|
||||||
byCreateTimeStart: startTime,
|
|
||||||
byCreateTimeEnd: endTime,
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
productName: '',
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150099140866050',
|
|
||||||
'1988150263284953089',
|
|
||||||
'1988150545175736322',
|
|
||||||
'1988150150521090049',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
{ label: '镀锌原料库', value: '1988150263284953089' },
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
@@ -171,97 +28,7 @@ export default {
|
|||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ label: '废品库', value: '2019583429955104769' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ label: '退货库', value: '2019583137616310273' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150099140866050': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150099140866050'
|
|
||||||
},
|
|
||||||
'1988150263284953089': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150263284953089'
|
|
||||||
},
|
|
||||||
'1988150545175736322': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150545175736322'
|
|
||||||
},
|
|
||||||
'1988150150521090049': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150150521090049'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
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: {
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId]
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
})
|
|
||||||
).then((resList) => {
|
|
||||||
console.log(resList)
|
|
||||||
const list = resList.flatMap(res => res.rows)
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,215 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<DayTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="date" value-format="yyyy-MM-dd"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<!-- 异常统计 -->
|
|
||||||
<el-descriptions title="异常统计" :column="4" border>
|
|
||||||
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
|
||||||
}}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import DayTemplate from '@/views/wms/report/template/day.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'LossReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
DayTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}-${addZero(now.getDate())}`
|
|
||||||
|
|
||||||
// 生成指定日期的 00:00:00 和 23:59:59 时间字符串
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
return {
|
|
||||||
start: `${dateStr} 00:00:00`,
|
|
||||||
end: `${dateStr} 23:59:59`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [11, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'suanzhakuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'suanzhakuguan',
|
||||||
// date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150099140866050',
|
|
||||||
'1988150263284953089',
|
|
||||||
'1988150545175736322',
|
|
||||||
'1988150150521090049',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
{ label: '镀锌原料库', value: '1988150263284953089' },
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
@@ -220,166 +34,7 @@ export default {
|
|||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ label: '废品库', value: '2019583429955104769' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ label: '退货库', value: '2019583137616310273' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150099140866050': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150099140866050'
|
|
||||||
},
|
|
||||||
'1988150263284953089': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150263284953089'
|
|
||||||
},
|
|
||||||
'1988150545175736322': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150545175736322'
|
|
||||||
},
|
|
||||||
'1988150150521090049': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150150521090049'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': { // 修正原代码的ID错误
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
},
|
|
||||||
abSummary() {
|
|
||||||
return calcAbSummary(this.list)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 11, // 酸轧工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'suanzhakuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.lossList = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,239 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<MonthTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="month" value-format="yyyy-MM"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import MonthTemplate from '@/views/wms/report/template/month.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'MonthReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
MonthTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定日期/月份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
|
||||||
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 先校验输入格式是否合法
|
|
||||||
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
|
||||||
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
|
||||||
|
|
||||||
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
|
||||||
}
|
|
||||||
|
|
||||||
let startDate, endDate;
|
|
||||||
|
|
||||||
if (monthPattern.test(dateStr)) {
|
|
||||||
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
|
||||||
const [year, month] = dateStr.split('-').map(Number);
|
|
||||||
// 月份是0基的(0=1月,1=2月...),所以要减1
|
|
||||||
// 第一天:yyyy-MM-01
|
|
||||||
startDate = `${dateStr}-01`;
|
|
||||||
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
|
||||||
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
|
||||||
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
|
||||||
} else {
|
|
||||||
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
|
||||||
startDate = dateStr;
|
|
||||||
endDate = dateStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接时间部分
|
|
||||||
return {
|
|
||||||
start: `${startDate} 00:00:00`,
|
|
||||||
end: `${endDate} 23:59:59`
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [11, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'suanzhakuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'suanzhakuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150099140866050',
|
|
||||||
'1988150263284953089',
|
|
||||||
'1988150545175736322',
|
|
||||||
'1988150150521090049',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
{ label: '镀锌原料库', value: '1988150263284953089' },
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
@@ -244,163 +34,7 @@ export default {
|
|||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ label: '废品库', value: '2019583429955104769' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ label: '退货库', value: '2019583137616310273' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150099140866050': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150099140866050'
|
|
||||||
},
|
|
||||||
'1988150263284953089': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150263284953089'
|
|
||||||
},
|
|
||||||
'1988150545175736322': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150545175736322'
|
|
||||||
},
|
|
||||||
'1988150150521090049': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150150521090049'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': { // 修正原代码的ID错误
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 11, // 酸轧工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'suanzhakuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.lossList = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,260 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<TeamTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="开始日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart" type="date"
|
:warehouseOptions="warehouseOptions"
|
||||||
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="结束日期" prop="date">
|
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd" type="date"
|
|
||||||
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="班组" prop="team">
|
|
||||||
<el-select v-model="queryParams.team" placeholder="请选择班组" style="width: 200px;">
|
|
||||||
<el-option label="甲" value="甲" />
|
|
||||||
<el-option label="乙" value="乙" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- <el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item> -->
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<!-- <el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item> -->
|
|
||||||
<!-- <el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item> -->
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<!-- <el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item> -->
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="班组统计信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-table :data="teamSummary" border>
|
|
||||||
<el-table-column label="班组" align="center" prop="team" />
|
|
||||||
<el-table-column label="产出数量" align="center" prop="outCount" />
|
|
||||||
<el-table-column label="产出总重" align="center" prop="outWeight" />
|
|
||||||
<!-- <el-table-column label="消耗数量" align="center" prop="lossCount" />
|
|
||||||
<el-table-column label="消耗总重" align="center" prop="lossWeight" />
|
|
||||||
<el-table-column label="成品率" align="center" prop="passRate" /> -->
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<!-- <el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane> -->
|
|
||||||
<!-- <el-tab-pane label="产出钢卷" name="output"> -->
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="班组" align="center" prop="team" />
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
<!-- </el-tab-pane> -->
|
|
||||||
<!-- </el-tabs> -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import TeamTemplate from '@/views/wms/report/template/team.vue'
|
||||||
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 { calcSummary, calcAbSummary, calcTeamSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'TeamReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
TeamTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定日期/月份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
|
||||||
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 先校验输入格式是否合法
|
|
||||||
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
|
||||||
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
|
||||||
|
|
||||||
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
|
||||||
}
|
|
||||||
|
|
||||||
let startDate, endDate;
|
|
||||||
|
|
||||||
if (monthPattern.test(dateStr)) {
|
|
||||||
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
|
||||||
const [year, month] = dateStr.split('-').map(Number);
|
|
||||||
// 月份是0基的(0=1月,1=2月...),所以要减1
|
|
||||||
// 第一天:yyyy-MM-01
|
|
||||||
startDate = `${dateStr}-01`;
|
|
||||||
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
|
||||||
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
|
||||||
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
|
||||||
} else {
|
|
||||||
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
|
||||||
startDate = dateStr;
|
|
||||||
endDate = dateStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接时间部分
|
|
||||||
return {
|
|
||||||
start: `${startDate} 00:00:00`,
|
|
||||||
end: `${endDate} 23:59:59`
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [11, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'suanzhakuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'suanzhakuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150099140866050',
|
|
||||||
'1988150263284953089',
|
|
||||||
'1988150545175736322',
|
|
||||||
'1988150150521090049',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
{ label: '镀锌原料库', value: '1988150263284953089' },
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
@@ -265,197 +34,7 @@ export default {
|
|||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ label: '废品库', value: '2019583429955104769' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ label: '退货库', value: '2019583137616310273' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150099140866050': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150099140866050'
|
|
||||||
},
|
|
||||||
'1988150263284953089': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150263284953089'
|
|
||||||
},
|
|
||||||
'1988150545175736322': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150545175736322'
|
|
||||||
},
|
|
||||||
'1988150150521090049': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150150521090049'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': { // 修正原代码的ID错误
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
},
|
|
||||||
// 合并两个汇总结果并转换为目标数组的方法
|
|
||||||
teamSummary() {
|
|
||||||
const teamOutSummary = calcTeamSummary(this.list);
|
|
||||||
// const teamLossSummary = calcTeamSummary(this.lossList);
|
|
||||||
|
|
||||||
const allTeams = [...new Set([
|
|
||||||
...Object.keys(teamOutSummary),
|
|
||||||
// ...Object.keys(teamLossSummary)
|
|
||||||
])];
|
|
||||||
|
|
||||||
const result = allTeams.map(team => {
|
|
||||||
const outData = teamOutSummary[team] || { count: 0, weight: 0 };
|
|
||||||
// const lossData = teamLossSummary[team] || { count: 0, weight: 0 };
|
|
||||||
|
|
||||||
// 核心修复:先确保是有效数字,再保留两位小数
|
|
||||||
const formatWeight = (weight) => {
|
|
||||||
// 步骤1:转数字,非数字则置为0;步骤2:保留两位小数
|
|
||||||
return Number(weight || 0).toFixed(2);
|
|
||||||
// 如果需要返回数字类型(而非字符串),用这行:
|
|
||||||
// return Number(Number(weight || 0).toFixed(2));
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
team: team,
|
|
||||||
outCount: outData.count,
|
|
||||||
outWeight: formatWeight(outData.weight), // 格式化出库重量
|
|
||||||
// lossCount: lossData.count,
|
|
||||||
// lossWeight: formatWeight(lossData.weight), // 格式化损耗重量
|
|
||||||
// passRate: (outData.weight / lossData.weight * 100).toFixed(2) + '%' , // 计算成品率
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
// this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 11, // 酸轧工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'suanzhakuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.lossList = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,223 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<YearTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="year" value-format="yyyy"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import YearTemplate from '@/views/wms/report/template/year.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'YearReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
YearTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定年份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 必须为 yyyy 格式(如 "2026")
|
|
||||||
* @returns {object} 包含start(当年第一天)和end(当年最后一天)的时间对象
|
|
||||||
* @throws {Error} 输入格式错误时抛出异常
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 校验输入格式:必须是4位数字的yyyy格式
|
|
||||||
const yearPattern = /^\d{4}$/;
|
|
||||||
if (!yearPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy 格式的字符串(如 "2026")');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接当年第一天和最后一天的完整日期+时间
|
|
||||||
return {
|
|
||||||
start: `${dateStr}-01-01 00:00:00`, // 年-01-01 0点
|
|
||||||
end: `${dateStr}-12-31 23:59:59` // 年-12-31 23点59分59秒
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
console.log(currentDate)
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [11, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'suanzhakuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'suanzhakuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150099140866050',
|
|
||||||
'1988150263284953089',
|
|
||||||
'1988150545175736322',
|
|
||||||
'1988150150521090049',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
{ label: '酸连轧成品库', value: '1988150099140866050' },
|
||||||
{ label: '镀锌原料库', value: '1988150263284953089' },
|
{ label: '镀锌原料库', value: '1988150263284953089' },
|
||||||
@@ -228,163 +34,7 @@ export default {
|
|||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ label: '废品库', value: '2019583429955104769' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ label: '退货库', value: '2019583137616310273' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150099140866050': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150099140866050'
|
|
||||||
},
|
|
||||||
'1988150263284953089': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150263284953089'
|
|
||||||
},
|
|
||||||
'1988150545175736322': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150545175736322'
|
|
||||||
},
|
|
||||||
'1988150150521090049': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '1988150150521090049'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': { // 修正原代码的ID错误
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'suanzhakuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 11, // 酸轧工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'suanzhakuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.lossList = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,241 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<LossTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="开始时间" prop="startTime">
|
></LossTemplate>
|
||||||
<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>
|
|
||||||
</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>
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<!-- <el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column> -->
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import LossTemplate from '@/views/wms/report/template/loss.vue'
|
||||||
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'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
name: 'LossReport',
|
||||||
ProductInfo,
|
components: {
|
||||||
RawMaterialInfo,
|
LossTemplate,
|
||||||
CoilNo,
|
},
|
||||||
MemoInput,
|
data() {
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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 {
|
return {
|
||||||
totalCount,
|
actionTypes: [11, 120],
|
||||||
totalWeight: totalWeight.toFixed(2),
|
actionQueryParams: {
|
||||||
avgWeight,
|
updateBy: 'suanzhakuguan'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
remoteMethod(query) {
|
|
||||||
listDeliveryPlan({ planName: query, pageNum: 1, pageSize: 5, planType: 1 }).then(res => {
|
|
||||||
this.planList = res.rows
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 11, // 酸轧工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'suanzhakuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.list = res.rows
|
|
||||||
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('')
|
|
||||||
}
|
}
|
||||||
}
|
</script>
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,251 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<OutTemplate
|
||||||
<el-row>
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-form label-width="80px" inline>
|
:warehouseOptions="warehouseOptions"
|
||||||
<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-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</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 prop="endTime">
|
|
||||||
<el-button type="primary" @click="getList">查询</el-button>
|
|
||||||
<el-button type="primary" @click="exportData">导出</el-button>
|
|
||||||
</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>
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import OutTemplate from "@/views/wms/report/template/out.vue";
|
||||||
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";
|
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'ZhaTemplate',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
OutTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
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 {
|
return {
|
||||||
list: [],
|
baseQueryParams: {
|
||||||
queryParams: {
|
createBy: 'duxinkuguan',
|
||||||
pageNum: 1,
|
|
||||||
pageSize: 9999,
|
|
||||||
// status: 1,
|
|
||||||
byCreateTimeStart: startTime,
|
|
||||||
byCreateTimeEnd: endTime,
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
productName: '',
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150323162836993',
|
|
||||||
'1988150487185289217',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ value: '1988150323162836993', label: '镀锌成品库' },
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
{ label: '技术部', value: '2019583656787259393' },
|
{ value: '2019583656787259393', label: '技术部' },
|
||||||
{ label: '小钢卷库', value: '2019583325311414274' },
|
{ value: '2019583325311414274', label: '小钢卷库' },
|
||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ value: '2019583429955104769', label: '废品库' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ value: '2019583137616310273', label: '退货库' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150323162836993': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150323162836993'
|
|
||||||
},
|
|
||||||
'1988150487185289217': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150487185289217'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
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: {
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all([
|
|
||||||
...this.warehouseIds.map(warehouseId => listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
...this.warehouseQueryMap[warehouseId],
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
// dataType: 1,
|
|
||||||
}))
|
|
||||||
]).then((resList) => {
|
|
||||||
console.log(resList)
|
|
||||||
const list = resList.flatMap(res => res.rows)
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
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()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,371 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<DayTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="date" value-format="yyyy-MM-dd"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<!-- 异常统计 -->
|
|
||||||
<el-descriptions title="异常统计" :column="4" border>
|
|
||||||
<el-descriptions-item v-for="item in abSummary" :key="item.label" :label="item.label">{{ item.value
|
|
||||||
}}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import DayTemplate from '@/views/wms/report/template/day.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'LossReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
DayTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}-${addZero(now.getDate())}`
|
|
||||||
|
|
||||||
// 生成指定日期的 00:00:00 和 23:59:59 时间字符串
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
return {
|
|
||||||
start: `${dateStr} 00:00:00`,
|
|
||||||
end: `${dateStr} 23:59:59`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [501, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'duxinkuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'duxinkuguan',
|
||||||
// date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150323162836993',
|
|
||||||
'1988150487185289217',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ value: '1988150323162836993', label: '镀锌成品库' },
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
{ label: '技术部', value: '2019583656787259393' },
|
{ value: '2019583656787259393', label: '技术部' },
|
||||||
{ label: '小钢卷库', value: '2019583325311414274' },
|
{ value: '2019583325311414274', label: '小钢卷库' },
|
||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ value: '2019583429955104769', label: '废品库' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ value: '2019583137616310273', label: '退货库' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150323162836993': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150323162836993'
|
|
||||||
},
|
|
||||||
'1988150487185289217': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150487185289217'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
},
|
|
||||||
abSummary() {
|
|
||||||
return calcAbSummary(this.list)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 501, // 镀锌工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'duxinkuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,392 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<MonthTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="month" value-format="yyyy-MM"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import MonthTemplate from '@/views/wms/report/template/month.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'MonthReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
MonthTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定日期/月份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
|
||||||
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 先校验输入格式是否合法
|
|
||||||
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
|
||||||
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
|
||||||
|
|
||||||
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
|
||||||
}
|
|
||||||
|
|
||||||
let startDate, endDate;
|
|
||||||
|
|
||||||
if (monthPattern.test(dateStr)) {
|
|
||||||
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
|
||||||
const [year, month] = dateStr.split('-').map(Number);
|
|
||||||
// 月份是0基的(0=1月,1=2月...),所以要减1
|
|
||||||
// 第一天:yyyy-MM-01
|
|
||||||
startDate = `${dateStr}-01`;
|
|
||||||
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
|
||||||
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
|
||||||
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
|
||||||
} else {
|
|
||||||
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
|
||||||
startDate = dateStr;
|
|
||||||
endDate = dateStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接时间部分
|
|
||||||
return {
|
|
||||||
start: `${startDate} 00:00:00`,
|
|
||||||
end: `${endDate} 23:59:59`
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [501, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'duxinkuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'duxinkuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150323162836993',
|
|
||||||
'1988150487185289217',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ value: '1988150323162836993', label: '镀锌成品库' },
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
{ label: '技术部', value: '2019583656787259393' },
|
{ value: '2019583656787259393', label: '技术部' },
|
||||||
{ label: '小钢卷库', value: '2019583325311414274' },
|
{ value: '2019583325311414274', label: '小钢卷库' },
|
||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ value: '2019583429955104769', label: '废品库' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ value: '2019583137616310273', label: '退货库' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150323162836993': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150323162836993'
|
|
||||||
},
|
|
||||||
'1988150487185289217': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150487185289217'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 501, // 镀锌工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'duxinkuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,448 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<TeamTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="开始日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeStart" type="date"
|
:warehouseOptions="warehouseOptions"
|
||||||
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="结束日期" prop="date">
|
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.byCreateTimeEnd" type="date"
|
|
||||||
value-format="yyyy-MM-dd HH:mm:ss" placeholder="选择日期"></el-date-picker>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="team">
|
|
||||||
<el-select v-model="queryParams.team" placeholder="请选择班组" style="width: 200px;">
|
|
||||||
<el-option label="甲" value="甲" />
|
|
||||||
<el-option label="乙" value="乙" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="当前钢卷号" prop="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- <el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item> -->
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<!-- <el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item> -->
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<!-- <el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item> -->
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="班组统计信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-table :data="teamSummary" border>
|
|
||||||
<el-table-column label="班组" align="center" prop="team" />
|
|
||||||
<el-table-column label="产出数量" align="center" prop="outCount" />
|
|
||||||
<el-table-column label="产出总重" align="center" prop="outWeight" />
|
|
||||||
<!-- <el-table-column label="消耗数量" align="center" prop="lossCount" />
|
|
||||||
<el-table-column label="消耗总重" align="center" prop="lossWeight" />
|
|
||||||
<el-table-column label="成品率" align="center" prop="passRate" /> -->
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<!-- <el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane> -->
|
|
||||||
<!-- <el-tab-pane label="产出钢卷" name="output"> -->
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="班组" align="center" prop="team" />
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
<!-- </el-tab-pane> -->
|
|
||||||
<!-- </el-tabs> -->
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import TeamTemplate from '@/views/wms/report/template/team.vue'
|
||||||
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 { calcSummary, calcAbSummary, calcTeamSummary } from "@/views/wms/report/js/calc.js";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'TeamReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
TeamTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}-${addZero(now.getMonth() + 1)}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定日期/月份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 支持格式:yyyy-MM(月份) 或 yyyy-MM-dd(具体日期)
|
|
||||||
* @returns {object} 包含start(开始时间)和end(结束时间)的对象
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 先校验输入格式是否合法
|
|
||||||
const monthPattern = /^\d{4}-\d{2}$/; // yyyy-MM 正则
|
|
||||||
const dayPattern = /^\d{4}-\d{2}-\d{2}$/; // yyyy-MM-dd 正则
|
|
||||||
|
|
||||||
if (!monthPattern.test(dateStr) && !dayPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy-MM 或 yyyy-MM-dd 格式的字符串');
|
|
||||||
}
|
|
||||||
|
|
||||||
let startDate, endDate;
|
|
||||||
|
|
||||||
if (monthPattern.test(dateStr)) {
|
|
||||||
// 处理 yyyy-MM 格式:获取本月第一天和最后一天
|
|
||||||
const [year, month] = dateStr.split('-').map(Number);
|
|
||||||
// 月份是0基的(0=1月,1=2月...),所以要减1
|
|
||||||
// 第一天:yyyy-MM-01
|
|
||||||
startDate = `${dateStr}-01`;
|
|
||||||
// 最后一天:通过 new Date(year, month, 0) 计算(month是原始月份,比如2代表2月,传2则取3月0日=2月最后一天)
|
|
||||||
const lastDayOfMonth = new Date(year, month, 0).getDate();
|
|
||||||
endDate = `${dateStr}-${lastDayOfMonth.toString().padStart(2, '0')}`;
|
|
||||||
} else {
|
|
||||||
// 处理 yyyy-MM-dd 格式:直接使用传入的日期
|
|
||||||
startDate = dateStr;
|
|
||||||
endDate = dateStr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接时间部分
|
|
||||||
return {
|
|
||||||
start: `${startDate} 00:00:00`,
|
|
||||||
end: `${endDate} 23:59:59`
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [501, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'duxinkuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'duxinkuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150323162836993',
|
|
||||||
'1988150487185289217',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ value: '1988150323162836993', label: '镀锌成品库' },
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
{ label: '技术部', value: '2019583656787259393' },
|
{ value: '2019583656787259393', label: '技术部' },
|
||||||
{ label: '小钢卷库', value: '2019583325311414274' },
|
{ value: '2019583325311414274', label: '小钢卷库' },
|
||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ value: '2019583429955104769', label: '废品库' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ value: '2019583137616310273', label: '退货库' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150323162836993': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150323162836993'
|
|
||||||
},
|
|
||||||
'1988150487185289217': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150487185289217'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
},
|
|
||||||
// 合并两个汇总结果并转换为目标数组的方法
|
|
||||||
teamSummary() {
|
|
||||||
const teamOutSummary = calcTeamSummary(this.list);
|
|
||||||
// const teamLossSummary = calcTeamSummary(this.lossList);
|
|
||||||
|
|
||||||
const allTeams = [...new Set([
|
|
||||||
...Object.keys(teamOutSummary),
|
|
||||||
// ...Object.keys(teamLossSummary)
|
|
||||||
])];
|
|
||||||
|
|
||||||
const result = allTeams.map(team => {
|
|
||||||
const outData = teamOutSummary[team] || { count: 0, weight: 0 };
|
|
||||||
// const lossData = teamLossSummary[team] || { count: 0, weight: 0 };
|
|
||||||
|
|
||||||
// 核心修复:先确保是有效数字,再保留两位小数
|
|
||||||
const formatWeight = (weight) => {
|
|
||||||
// 步骤1:转数字,非数字则置为0;步骤2:保留两位小数
|
|
||||||
return Number(weight || 0).toFixed(2);
|
|
||||||
// 如果需要返回数字类型(而非字符串),用这行:
|
|
||||||
// return Number(Number(weight || 0).toFixed(2));
|
|
||||||
};
|
|
||||||
|
|
||||||
return {
|
|
||||||
team: team,
|
|
||||||
outCount: outData.count,
|
|
||||||
outWeight: formatWeight(outData.weight), // 格式化出库重量
|
|
||||||
// lossCount: lossData.count,
|
|
||||||
// lossWeight: formatWeight(lossData.weight),
|
|
||||||
// passRate: (outData.weight / lossData.weight * 100).toFixed(2) + '%', // 计算成品率
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
// this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 501, // 镀锌工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'duxinkuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,374 +1,38 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<YearTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="日期" prop="date">
|
:baseQueryParams="baseQueryParams"
|
||||||
<el-date-picker style="width: 200px;" v-model="queryParams.date" type="year" value-format="yyyy"
|
:warehouseOptions="warehouseOptions"
|
||||||
placeholder="选择日期" @change="handleDateChange"></el-date-picker>
|
/>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="入场钢卷号" prop="enterCoilNo">
|
|
||||||
<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="currentCoilNo">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.currentCoilNo" placeholder="请输入当前钢卷号" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="逻辑库位" prop="warehouseIds">
|
|
||||||
<el-select v-model="warehouseIds" collapse-tags multiple placeholder="请选择逻辑库位" style="width: 200px;">
|
|
||||||
<el-option v-for="item in warehouseOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="产品名称" prop="itemName">
|
|
||||||
<el-input style="width: 200px;" v-model="queryParams.itemName" placeholder="请输入产品名称" clearable
|
|
||||||
@keyup.enter.native="handleQuery" />
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="规格" prop="itemSpecification">
|
|
||||||
<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="itemMaterial">
|
|
||||||
<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="itemManufacturer">
|
|
||||||
<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>
|
|
||||||
<el-button type="primary" @click="handleQuery">查询</el-button> <!-- 统一改为handleQuery -->
|
|
||||||
<el-button type="primary" @click="exportData">导出产出钢卷</el-button>
|
|
||||||
<el-button type="primary" @click="exportLossData">导出消耗钢卷</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-descriptions title="统计信息" :column="3" border>
|
|
||||||
<el-descriptions-item label="产出数量">{{ summary.outCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出总重">{{ summary.outTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="产出均重">{{ summary.outAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="消耗数量">{{ summary.lossCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗总重">{{ summary.lossTotalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="消耗均重">{{ summary.lossAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<el-descriptions-item label="合计数量">{{ summary.totalCount }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计总重">{{ summary.totalWeight }}t</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="合计均重">{{ summary.totalAvgWeight }}t</el-descriptions-item>
|
|
||||||
|
|
||||||
<!-- 成品率 -->
|
|
||||||
<el-descriptions-item label="成品率">{{ summary.passRate }}</el-descriptions-item>
|
|
||||||
<el-descriptions-item label="损耗率">{{ summary.lossRate }}</el-descriptions-item>
|
|
||||||
<!-- 异常率 -->
|
|
||||||
<el-descriptions-item label="异常率">{{ summary.abRate }}</el-descriptions-item>
|
|
||||||
</el-descriptions>
|
|
||||||
|
|
||||||
<el-descriptions title="明细信息" :column="3" border>
|
|
||||||
</el-descriptions>
|
|
||||||
<el-tabs v-model="activeTab">
|
|
||||||
<el-tab-pane label="投入钢卷" name="loss">
|
|
||||||
<el-table :data="lossList" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
<el-tab-pane label="产出钢卷" name="output">
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<el-table-column label="实际库区" align="center" prop="actualWarehouseName" />
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<!-- 0在库,1已出库 -->
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</el-tab-pane>
|
|
||||||
</el-tabs>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import YearTemplate from '@/views/wms/report/template/year.vue'
|
||||||
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 { calcSummary, calcAbSummary } from "@/views/wms/report/js/calc";
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
name: 'YearReport',
|
||||||
components: {
|
components: {
|
||||||
ProductInfo,
|
YearTemplate,
|
||||||
RawMaterialInfo,
|
|
||||||
CoilNo,
|
|
||||||
MemoInput,
|
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
},
|
||||||
dicts: ['product_coil_status', 'coil_material', 'coil_itemname', 'coil_manufacturer'],
|
|
||||||
data() {
|
data() {
|
||||||
// 工具函数:个位数补零
|
|
||||||
const addZero = (num) => num.toString().padStart(2, '0')
|
|
||||||
|
|
||||||
// 获取当前日期(默认选中当天)
|
|
||||||
const now = new Date()
|
|
||||||
const currentDate = `${now.getFullYear()}`
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成指定年份的时间范围字符串
|
|
||||||
* @param {string} dateStr - 必须为 yyyy 格式(如 "2026")
|
|
||||||
* @returns {object} 包含start(当年第一天)和end(当年最后一天)的时间对象
|
|
||||||
* @throws {Error} 输入格式错误时抛出异常
|
|
||||||
*/
|
|
||||||
const getDayTimeRange = (dateStr) => {
|
|
||||||
// 校验输入格式:必须是4位数字的yyyy格式
|
|
||||||
const yearPattern = /^\d{4}$/;
|
|
||||||
if (!yearPattern.test(dateStr)) {
|
|
||||||
throw new Error('输入格式错误,请传入 yyyy 格式的字符串(如 "2026")');
|
|
||||||
}
|
|
||||||
|
|
||||||
// 拼接当年第一天和最后一天的完整日期+时间
|
|
||||||
return {
|
|
||||||
start: `${dateStr}-01-01 00:00:00`, // 年-01-01 0点
|
|
||||||
end: `${dateStr}-12-31 23:59:59` // 年-12-31 23点59分59秒
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
const { start, end } = getDayTimeRange(currentDate)
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
activeTab: 'loss',
|
actionTypes: [501, 120],
|
||||||
list: [],
|
actionQueryParams: {
|
||||||
lossList: [],
|
updateBy: 'duxinkuguan'
|
||||||
queryParams: {
|
},
|
||||||
pageNum: 1,
|
baseQueryParams: {
|
||||||
pageSize: 9999,
|
createBy: 'duxinkuguan',
|
||||||
date: currentDate, // 绑定日期选择器的默认值(当天)
|
|
||||||
byCreateTimeStart: start, // 默认当天0点
|
|
||||||
byCreateTimeEnd: end, // 默认当天23:59:59
|
|
||||||
selectType: 'product',
|
|
||||||
enterCoilNo: '',
|
|
||||||
currentCoilNo: '',
|
|
||||||
warehouseId: '',
|
|
||||||
itemName: '', // 修正原代码的productName为itemName(和表单绑定一致)
|
|
||||||
itemSpecification: '',
|
|
||||||
itemMaterial: '',
|
|
||||||
itemManufacturer: '',
|
|
||||||
},
|
},
|
||||||
loading: false,
|
|
||||||
warehouseIds: [
|
|
||||||
'1988150323162836993',
|
|
||||||
'1988150487185289217',
|
|
||||||
'2019583656787259393',
|
|
||||||
'2019583325311414274',
|
|
||||||
'2019583429955104769',
|
|
||||||
'2019583137616310273',
|
|
||||||
],
|
|
||||||
warehouseOptions: [
|
warehouseOptions: [
|
||||||
{ value: '1988150323162836993', label: '镀锌成品库' },
|
{ value: '1988150323162836993', label: '镀锌成品库' },
|
||||||
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
{ value: '1988150487185289217', label: '镀锌纵剪分条原料库' },
|
||||||
{ label: '技术部', value: '2019583656787259393' },
|
{ value: '2019583656787259393', label: '技术部' },
|
||||||
{ label: '小钢卷库', value: '2019583325311414274' },
|
{ value: '2019583325311414274', label: '小钢卷库' },
|
||||||
{ label: '废品库', value: '2019583429955104769' },
|
{ value: '2019583429955104769', label: '废品库' },
|
||||||
{ label: '退货库', value: '2019583137616310273' },
|
{ value: '2019583137616310273', label: '退货库' },
|
||||||
],
|
],
|
||||||
warehouseQueryMap: {
|
|
||||||
'1988150323162836993': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150323162836993'
|
|
||||||
},
|
|
||||||
'1988150487185289217': {
|
|
||||||
selectType: 'raw_material',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '1988150487185289217'
|
|
||||||
},
|
|
||||||
'2019583656787259393': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583656787259393'
|
|
||||||
},
|
|
||||||
'2019583325311414274': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583325311414274'
|
|
||||||
},
|
|
||||||
'2019583429955104769': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583429955104769'
|
|
||||||
},
|
|
||||||
'2019583137616310273': {
|
|
||||||
selectType: 'product',
|
|
||||||
createBy: 'duxinkuguan',
|
|
||||||
warehouseId: '2019583137616310273'
|
|
||||||
},
|
|
||||||
},
|
|
||||||
getDayTimeRange // 挂载时间范围生成函数
|
|
||||||
}
|
}
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
summary() {
|
|
||||||
return calcSummary(this.list, this.lossList)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 日期变更处理:更新开始/结束时间
|
|
||||||
handleDateChange(date) {
|
|
||||||
if (!date) return
|
|
||||||
const { start, end } = this.getDayTimeRange(date)
|
|
||||||
this.queryParams.byCreateTimeStart = start
|
|
||||||
this.queryParams.byCreateTimeEnd = end
|
|
||||||
// 日期变更后自动查询
|
|
||||||
this.handleQuery()
|
|
||||||
},
|
|
||||||
// 统一查询入口(兼容回车和按钮点击)
|
|
||||||
handleQuery() {
|
|
||||||
this.getList()
|
|
||||||
},
|
|
||||||
// 核心查询逻辑
|
|
||||||
getList() {
|
|
||||||
this.loading = true
|
|
||||||
Promise.all(
|
|
||||||
this.warehouseIds.map(warehouseId => {
|
|
||||||
const params = this.warehouseQueryMap[warehouseId] || {} // 增加容错
|
|
||||||
return listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
...params
|
|
||||||
})
|
|
||||||
}),
|
|
||||||
).then((resList) => {
|
|
||||||
const list = resList.flatMap(res => res?.rows || []) // 增加容错
|
|
||||||
// 按照createTime 降序排序
|
|
||||||
this.list = list.sort(
|
|
||||||
(a, b) => new Date(b.createTime) - new Date(a.createTime)
|
|
||||||
)
|
|
||||||
this.loading = false
|
|
||||||
this.getLossList()
|
|
||||||
}).catch(err => { // 增加错误处理
|
|
||||||
console.error('查询失败:', err)
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getLossList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
actionType: 501, // 镀锌工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'duxinkuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.lossList = res.rows
|
|
||||||
this.loading = false
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 导出
|
|
||||||
exportData() {
|
|
||||||
if (this.list.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.list.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
exportLossData() {
|
|
||||||
if (this.lossList.length === 0) {
|
|
||||||
this.$message.warning('暂无数据可导出')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
this.download('wms/materialCoil/export', {
|
|
||||||
coilIds: this.lossList.map(item => item.coilId).join(',')
|
|
||||||
}, `materialCoil_${this.queryParams.date}_${new Date().getTime()}.xlsx`)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.getList()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,241 +1,25 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="app-container" v-loading="loading">
|
<LossTemplate
|
||||||
<el-row>
|
:actionTypes="actionTypes"
|
||||||
<el-form label-width="80px" inline>
|
:actionQueryParams="actionQueryParams"
|
||||||
<el-form-item label="开始时间" prop="startTime">
|
></LossTemplate>
|
||||||
<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>
|
|
||||||
</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>
|
|
||||||
<el-table :data="list" border height="calc(100vh - 320px)">
|
|
||||||
<el-table-column label="入场钢卷号" align="center" prop="enterCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.enterCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="当前钢卷号" align="center" prop="currentCoilNo">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<coil-no :coil-no="scope.row.currentCoilNo"></coil-no>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="创建时间" align="center" prop="createTime" />
|
|
||||||
<el-table-column label="逻辑库位" align="center" prop="warehouseName" />
|
|
||||||
<!-- <el-table-column label="实际库区" align="center" prop="actualWarehouseName" /> -->
|
|
||||||
<el-table-column label="产品类型" align="center" width="250">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
<ProductInfo v-if="scope.row.itemType == 'product'" :product="scope.row.product" />
|
|
||||||
<RawMaterialInfo v-else-if="scope.row.itemType === 'raw_material'" :material="scope.row.rawMaterial" />
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column label="重量 (吨)" align="center" prop="netWeight" />
|
|
||||||
<el-table-column label="长度 (米)" align="center" prop="length" />
|
|
||||||
<el-table-column label="备注" align="center" prop="remark" show-overflow-tooltip />
|
|
||||||
<!-- <el-table-column label="出库状态" align="center" prop="status">
|
|
||||||
<template slot-scope="scope">
|
|
||||||
{{ scope.row.status === 0 ? '在库' : '已出库' }}
|
|
||||||
</template>
|
|
||||||
</el-table-column> -->
|
|
||||||
<el-table-column label="更新人" align="center" prop="updateByName" />
|
|
||||||
<el-table-column label="更新时间" align="center" prop="updateTime" />
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import { listCoilWithIds } from "@/api/wms/coil";
|
import LossTemplate from '@/views/wms/report/template/loss.vue'
|
||||||
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'
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
name: 'LossReport',
|
||||||
ProductInfo,
|
components: {
|
||||||
RawMaterialInfo,
|
LossTemplate,
|
||||||
CoilNo,
|
},
|
||||||
MemoInput,
|
data() {
|
||||||
MutiSelect,
|
|
||||||
WarehouseSelect,
|
|
||||||
},
|
|
||||||
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 {
|
|
||||||
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,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
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 {
|
return {
|
||||||
totalCount,
|
actionTypes: [501, 120],
|
||||||
totalWeight: totalWeight.toFixed(2),
|
actionQueryParams: {
|
||||||
avgWeight,
|
updateBy: 'duxinkuguan'
|
||||||
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
remoteMethod(query) {
|
|
||||||
listDeliveryPlan({ planName: query, pageNum: 1, pageSize: 5, planType: 1 }).then(res => {
|
|
||||||
this.planList = res.rows
|
|
||||||
})
|
|
||||||
},
|
|
||||||
async getList() {
|
|
||||||
this.loading = true
|
|
||||||
const res1 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 501, // 镀锌工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
})
|
|
||||||
const res2 = await listPendingAction({
|
|
||||||
actionStatus: 2,
|
|
||||||
warehouseId: this.queryParams.planId,
|
|
||||||
// actionType: 401,
|
|
||||||
actionType: 120, // 分条工序
|
|
||||||
pageSize: 9999,
|
|
||||||
pageNum: 1,
|
|
||||||
startTime: this.queryParams.byCreateTimeStart,
|
|
||||||
endTime: this.queryParams.byCreateTimeEnd,
|
|
||||||
updateBy: 'duxinkuguan',
|
|
||||||
})
|
|
||||||
const actions = res1.rows.concat(res2.rows)
|
|
||||||
const coilIds = actions.map(item => item.coilId).join(',')
|
|
||||||
console.log(coilIds)
|
|
||||||
if (!coilIds) {
|
|
||||||
this.$message({
|
|
||||||
message: '暂无数据',
|
|
||||||
type: 'warning',
|
|
||||||
})
|
|
||||||
this.list = []
|
|
||||||
this.loading = false
|
|
||||||
return
|
|
||||||
}
|
|
||||||
listCoilWithIds({
|
|
||||||
...this.queryParams,
|
|
||||||
byCreateTimeStart: undefined,
|
|
||||||
byCreateTimeEnd: undefined,
|
|
||||||
coilIds: coilIds,
|
|
||||||
}).then(res => {
|
|
||||||
this.list = res.rows
|
|
||||||
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('')
|
|
||||||
}
|
}
|
||||||
}
|
</script>
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
Reference in New Issue
Block a user