|
@@ -0,0 +1,256 @@
|
|
|
|
|
+<template>
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <ele-pro-table
|
|
|
|
|
+ v-if="
|
|
|
|
|
+ statisticsType == 1 &&
|
|
|
|
|
+ localDetails[0] &&
|
|
|
|
|
+ localDetails[0].statisticsValues
|
|
|
|
|
+ "
|
|
|
|
|
+ ref="table"
|
|
|
|
|
+ :columns="typeOneColumns"
|
|
|
|
|
+ :datasource="localDetails[0].statisticsValues"
|
|
|
|
|
+ cacheKey="mes-statistics-type-2511041946"
|
|
|
|
|
+ :needPage="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template
|
|
|
|
|
+ v-for="(item, index) in localDetails[0].statisticsValues[0]"
|
|
|
|
|
+ v-slot:[`column_${index}`]="{ row }"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div :key="`column_${index}`">
|
|
|
|
|
+ {{ `column_${index}` }}
|
|
|
|
|
+
|
|
|
|
|
+ <el-input
|
|
|
|
|
+ v-model="row.value"
|
|
|
|
|
+ :placeholder="`请输入${row.title}`"
|
|
|
|
|
+ ></el-input>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ele-pro-table>
|
|
|
|
|
+ <ele-pro-table
|
|
|
|
|
+ v-if="
|
|
|
|
|
+ statisticsType == 2 &&
|
|
|
|
|
+ localDetails[1] &&
|
|
|
|
|
+ localDetails[1].statisticsValues
|
|
|
|
|
+ "
|
|
|
|
|
+ ref="table"
|
|
|
|
|
+ :columns="typeTwoColumns"
|
|
|
|
|
+ :datasource="localDetails[1].statisticsValues"
|
|
|
|
|
+ cacheKey="mes-statistics-type-2511041946"
|
|
|
|
|
+ :needPage="false"
|
|
|
|
|
+ >
|
|
|
|
|
+ <template
|
|
|
|
|
+ v-for="(item, index) in localDetails[0].statisticsValues[0]"
|
|
|
|
|
+ v-slot:[`column_${index}`]="{ row }"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div :key="`column_${index}`"> {{ `column_${index}` }}</div>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ </ele-pro-table>
|
|
|
|
|
+ </div>
|
|
|
|
|
+</template>
|
|
|
|
|
+
|
|
|
|
|
+<script>
|
|
|
|
|
+ import {
|
|
|
|
|
+ getAllRoutingTaskList,
|
|
|
|
|
+ getPickAndFeed
|
|
|
|
|
+ } from '@/api/producetaskrecordrulesrecord/index';
|
|
|
|
|
+
|
|
|
|
|
+ export default {
|
|
|
|
|
+ props: {
|
|
|
|
|
+ details: {
|
|
|
|
|
+ type: Array,
|
|
|
|
|
+ default: () => []
|
|
|
|
|
+ },
|
|
|
|
|
+ statisticsType: {
|
|
|
|
|
+ type: String,
|
|
|
|
|
+ default: '1' // 1-成品统计,2-物料统计,3-工序统计
|
|
|
|
|
+ },
|
|
|
|
|
+ // 工艺路线id 必填
|
|
|
|
|
+ routingId: {
|
|
|
|
|
+ type: [String, Number],
|
|
|
|
|
+ required: true
|
|
|
|
|
+ },
|
|
|
|
|
+ // workOrderId 工单id 必填
|
|
|
|
|
+ workOrderId: {
|
|
|
|
|
+ type: [String, Number],
|
|
|
|
|
+ required: true
|
|
|
|
|
+ },
|
|
|
|
|
+ // produceTaskId 工序id
|
|
|
|
|
+ produceTaskId: {
|
|
|
|
|
+ type: [String, Number],
|
|
|
|
|
+ required: true
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ watch: {
|
|
|
|
|
+ details: {
|
|
|
|
|
+ deep: true,
|
|
|
|
|
+ immediate: true,
|
|
|
|
|
+ handler(val) {
|
|
|
|
|
+ // const details = JSON.parse(JSON.stringify(val));
|
|
|
|
|
+ this.buildDetials(val);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ computed: {
|
|
|
|
|
+ // 成品统计表头
|
|
|
|
|
+ typeOneColumns() {
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.localDetails.length > 0 &&
|
|
|
|
|
+ this.localDetails[0].statisticsValues &&
|
|
|
|
|
+ this.localDetails[0].statisticsType == 1
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return this.localDetails[0].statisticsValues[0].map((item, index) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.title,
|
|
|
|
|
+ slot: `column_${index}`,
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 物料统计表头
|
|
|
|
|
+ typeTwoColumns() {
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.localDetails.length > 1 &&
|
|
|
|
|
+ this.localDetails[1].statisticsValues &&
|
|
|
|
|
+ this.localDetails[1].statisticsType == 2
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return this.localDetails[1].statisticsValues[0].map((item, index) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.title,
|
|
|
|
|
+ slot: `column_${index}`,
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ // 工序统计表头
|
|
|
|
|
+ typeThreeColumns() {
|
|
|
|
|
+ if (
|
|
|
|
|
+ this.localDetails.length > 2 &&
|
|
|
|
|
+ this.localDetails[2].statisticsValues &&
|
|
|
|
|
+ this.localDetails[2].statisticsType == 3
|
|
|
|
|
+ ) {
|
|
|
|
|
+ return this.localDetails[2].statisticsValues[0].map((item, index) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ label: item.title,
|
|
|
|
|
+ slot: `column_${index}`,
|
|
|
|
|
+ align: 'center'
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return [];
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ },
|
|
|
|
|
+ data() {
|
|
|
|
|
+ return {
|
|
|
|
|
+ localDetails: []
|
|
|
|
|
+ };
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
|
|
+ methods: {
|
|
|
|
|
+ // 通知父组件数据变更
|
|
|
|
|
+ emitChange() {
|
|
|
|
|
+ this.$emit('update:details', this.localDetails);
|
|
|
|
|
+ },
|
|
|
|
|
+ // 构建统计数据
|
|
|
|
|
+ async buildDetials(detials) {
|
|
|
|
|
+ if (detials.length === 0) {
|
|
|
|
|
+ this.localDetails = [];
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 已构建过统计数据
|
|
|
|
|
+ if (detials[0].statisticsValues) {
|
|
|
|
|
+ return (this.localDetails = JSON.parse(JSON.stringify(detials)));
|
|
|
|
|
+ }
|
|
|
|
|
+ // 构建统计数据
|
|
|
|
|
+ const list = JSON.parse(JSON.stringify(detials));
|
|
|
|
|
+
|
|
|
|
|
+ const ruleId = list.map((i) => i.ruleId)[0];
|
|
|
|
|
+
|
|
|
|
|
+ // 工序任务列表
|
|
|
|
|
+ const routingTaskList = await getAllRoutingTaskList({
|
|
|
|
|
+ routingId: this.routingId
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ // 物料获取
|
|
|
|
|
+ const pickAndFeed = await getPickAndFeed({
|
|
|
|
|
+ workOrderId: this.workOrderId,
|
|
|
|
|
+ produceTaskId: this.produceTaskId
|
|
|
|
|
+ });
|
|
|
|
|
+ console.log('routingTaskList 工序数据', routingTaskList);
|
|
|
|
|
+ console.log('物料数据 pickAndFeed', pickAndFeed);
|
|
|
|
|
+
|
|
|
|
|
+ this.localDetails = [
|
|
|
|
|
+ {
|
|
|
|
|
+ ruleId,
|
|
|
|
|
+ statisticsType: 1,
|
|
|
|
|
+ statisticsValues: [
|
|
|
|
|
+ list
|
|
|
|
|
+ .filter((i) => i.statisticsType == 1)
|
|
|
|
|
+ .map((i) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ title: i.paramValue,
|
|
|
|
|
+ value: '',
|
|
|
|
|
+ formula: i.formula,
|
|
|
|
|
+ unit: ''
|
|
|
|
|
+ };
|
|
|
|
|
+ })
|
|
|
|
|
+ ]
|
|
|
|
|
+ },
|
|
|
|
|
+ // 物料统计
|
|
|
|
|
+ {
|
|
|
|
|
+ ruleId,
|
|
|
|
|
+ statisticsType: 2,
|
|
|
|
|
+ statisticsValues: pickAndFeed.map((pick) => {
|
|
|
|
|
+ const data = list
|
|
|
|
|
+ .filter((i) => i.statisticsType == 2)
|
|
|
|
|
+ .map((i) => {
|
|
|
|
|
+ return {
|
|
|
|
|
+ title: i.paramValue,
|
|
|
|
|
+ value: '',
|
|
|
|
|
+ formula: i.formula,
|
|
|
|
|
+ unit: ''
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ data.unshift({
|
|
|
|
|
+ title: '物料编码',
|
|
|
|
|
+ value: pick.categoryCode,
|
|
|
|
|
+ formula: '',
|
|
|
|
|
+ unit: '',
|
|
|
|
|
+ // 仅展示不计算和输入
|
|
|
|
|
+ isOnlyShow: true
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ data.unshift({
|
|
|
|
|
+ title: '物料名称',
|
|
|
|
|
+ value: pick.categoryName,
|
|
|
|
|
+ formula: '',
|
|
|
|
|
+ unit: '',
|
|
|
|
|
+ // 仅展示不计算和输入
|
|
|
|
|
+ isOnlyShow: true
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
|
|
+ return data;
|
|
|
|
|
+ })
|
|
|
|
|
+ },
|
|
|
|
|
+ // 工序统计
|
|
|
|
|
+ {
|
|
|
|
|
+ ruleId,
|
|
|
|
|
+ statisticsType: 3,
|
|
|
|
|
+ statisticsValues: []
|
|
|
|
|
+ }
|
|
|
|
|
+ ];
|
|
|
|
|
+ console.log('this.localDetails', this.localDetails);
|
|
|
|
|
+
|
|
|
|
|
+ // 通知父组件数据变更
|
|
|
|
|
+ this.emitChange();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+</script>
|