|
|
@@ -12,32 +12,39 @@
|
|
|
<div v-loading="loading">
|
|
|
<el-form label-width="80px" :model="planInfo" class="plan_form">
|
|
|
<el-row :gutter="20" type="flex" style="flex-wrap: wrap">
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="名称:">
|
|
|
<el-input readonly v-model="planInfo.productName"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="计划编号:">
|
|
|
<el-input readonly v-model="planInfo.code"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="规格:">
|
|
|
<el-input readonly v-model="planInfo.specification"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="型号:">
|
|
|
<el-input readonly v-model="planInfo.model"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ </el-row>
|
|
|
+ <el-row>
|
|
|
+ <el-col :span="6">
|
|
|
+ <el-form-item label="编码:">
|
|
|
+ <el-input readonly v-model="planInfo.productCode"></el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="牌号:">
|
|
|
<el-input readonly v-model="planInfo.brandNo"></el-input>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
- <el-col :span="8">
|
|
|
+ <el-col :span="6">
|
|
|
<el-form-item label="计划数量:">
|
|
|
<el-input readonly v-model="planInfo.productNum"></el-input>
|
|
|
</el-form-item>
|
|
|
@@ -109,9 +116,9 @@
|
|
|
>
|
|
|
<el-option
|
|
|
v-for="item in bomListType"
|
|
|
- :key="item.id"
|
|
|
+ :key="item.bomType"
|
|
|
:label="item.bomName"
|
|
|
- :value="item.id"
|
|
|
+ :value="item.bomType"
|
|
|
>
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
@@ -197,81 +204,6 @@
|
|
|
</el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
-
|
|
|
- <!-- <el-form
|
|
|
- :inline="true"
|
|
|
- :model="formInline"
|
|
|
- class="demo-form-inline"
|
|
|
- >
|
|
|
- <el-form-item label="BOM类型">
|
|
|
- <el-select
|
|
|
- size="medium"
|
|
|
- v-model="formInline.bomType"
|
|
|
- placeholder="BOM类型"
|
|
|
- class="select-type"
|
|
|
- @change="bomTypeChange"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in bomListType"
|
|
|
- :key="item.id"
|
|
|
- :label="item.bomName"
|
|
|
- :value="item.id"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="BOM版本">
|
|
|
- <el-select
|
|
|
- class="select-type"
|
|
|
- size="medium"
|
|
|
- v-model="formInline.bomId"
|
|
|
- placeholder="BOM版本"
|
|
|
- @change="bomVChange"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in bomListV"
|
|
|
- :key="item.bomId"
|
|
|
- :label="item.versions"
|
|
|
- :value="item.bomId"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="属性类型" v-if="produceType == 2">
|
|
|
- <el-select
|
|
|
- size="medium"
|
|
|
- v-model="formInline.attributeType"
|
|
|
- placeholder="属性类型"
|
|
|
- class="select-type"
|
|
|
- @change="attributeChange"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in attributeList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- <el-form-item label="最终状态">
|
|
|
- <el-select
|
|
|
- class="select-type"
|
|
|
- size="medium"
|
|
|
- v-model="formInline.finalState"
|
|
|
- placeholder="最终状态"
|
|
|
- @change="finalChange"
|
|
|
- >
|
|
|
- <el-option
|
|
|
- v-for="item in finalStateList"
|
|
|
- :key="item.value"
|
|
|
- :label="item.label"
|
|
|
- :value="item.value"
|
|
|
- >
|
|
|
- </el-option>
|
|
|
- </el-select>
|
|
|
- </el-form-item>
|
|
|
- </el-form> -->
|
|
|
</template>
|
|
|
<template v-slot:inventoryQuantity="{ row }">
|
|
|
<el-link
|
|
|
@@ -387,7 +319,10 @@
|
|
|
<script>
|
|
|
import {
|
|
|
findMaterialInfoByPlanId,
|
|
|
- findBomCategoryByCategoryId
|
|
|
+ findBomCategoryByCategoryId,
|
|
|
+ findBomCategoryByCategoryIdV2,
|
|
|
+ bomVersionList,
|
|
|
+ listBomType
|
|
|
} from '@/api/productionPlan/index.js';
|
|
|
import factoryAdd from './factoryAdd';
|
|
|
import stockDetailDialog from './stockDetailDialog.vue';
|
|
|
@@ -469,6 +404,13 @@
|
|
|
showOverflowTooltip: true,
|
|
|
align: 'center'
|
|
|
},
|
|
|
+ {
|
|
|
+ prop: 'unit',
|
|
|
+ label: '单位',
|
|
|
+ showOverflowTooltip: true,
|
|
|
+ align: 'center',
|
|
|
+ width: 60
|
|
|
+ },
|
|
|
{
|
|
|
prop: 'totalUnshippedQuantity',
|
|
|
label: '未发总数',
|
|
|
@@ -692,24 +634,58 @@
|
|
|
// 选择BOM类型
|
|
|
async bomTypeChange(e, type) {
|
|
|
this.formInline.bomType = e;
|
|
|
- let data = this.bomListType.find((el) => el.id === e);
|
|
|
- if (!data) return;
|
|
|
- this.bomListV = data.bomList;
|
|
|
- let idx = 0;
|
|
|
+ const params = {
|
|
|
+ categoryId: this.planInfo.categoryId,
|
|
|
+ bomType: e,
|
|
|
+ isTemp: 0
|
|
|
+ };
|
|
|
+ const res = await bomVersionList(params);
|
|
|
+ if (!res || res.length == 0) {
|
|
|
+ this.bomListV = [];
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let list = [];
|
|
|
+ console.log(res,'res -01')
|
|
|
+ res.forEach((el) => {
|
|
|
+ if (el.status != 1) return;
|
|
|
+ let obj = {
|
|
|
+ bomId: el.id,
|
|
|
+ id: el.id,
|
|
|
+ versions: `V${el.versions}.0`
|
|
|
+ };
|
|
|
+ list.push(obj);
|
|
|
+ });
|
|
|
+ this.bomListV = list;
|
|
|
+ console.log(this.planInfo, '11111111111111');
|
|
|
if (type == 'init') {
|
|
|
- idx = data.bomList.findIndex(
|
|
|
- (item) => item.bomId == this.planInfo.bomCategoryId
|
|
|
- );
|
|
|
+ let obj = list.find((el) => el.bomId == this.planInfo.bomCategoryId);
|
|
|
+ let id = obj ? obj.bomId : list[0].bomId;
|
|
|
+ this.formInline.bomId = id;
|
|
|
+ this.bomVChange(id);
|
|
|
+ } else {
|
|
|
+ let id = list[0].bomId;
|
|
|
+ this.formInline.bomId = id;
|
|
|
+ this.bomVChange(id);
|
|
|
}
|
|
|
- const index = idx != -1 ? idx : 0;
|
|
|
- await this.bomVChange(data.bomList[index].bomId);
|
|
|
+ // let data = this.bomListType.find((el) => el.id === e);
|
|
|
+ // if (!data) return;
|
|
|
+ // this.bomListV = data.bomList;
|
|
|
+ // let idx = 0;
|
|
|
+ // if (type == 'init') {
|
|
|
+ // idx = data.bomList.findIndex(
|
|
|
+ // (item) => item.bomId == this.planInfo.bomCategoryId
|
|
|
+ // );
|
|
|
+ // }
|
|
|
+ // const index = idx != -1 ? idx : 0;
|
|
|
+ // await this.bomVChange(data.bomList[index].bomId);
|
|
|
},
|
|
|
// 选择BOM版本
|
|
|
async bomVChange(e) {
|
|
|
- this.formInline.bomId = e;
|
|
|
- let data = this.bomListV.find((el) => el.bomId === e);
|
|
|
- if (!data) return;
|
|
|
- await this.getMaterialData(data, this.formInline.attributeType);
|
|
|
+ // return
|
|
|
+ // let bomData = list.find((el) => el.bomId == e);
|
|
|
+ // if (!bomData) return;
|
|
|
+ // let data = this.bomListV.find((el) => el.bomId === e);
|
|
|
+ this.getMaterialData({ bomId: e }, this.formInline.attributeType);
|
|
|
},
|
|
|
// 查询采购价跟外协件两个类型数据
|
|
|
async dataMerging() {
|
|
|
@@ -792,7 +768,7 @@
|
|
|
}
|
|
|
let first = result[0];
|
|
|
this.baseCount = first.baseCount;
|
|
|
- this.baseUnit = first.unit;
|
|
|
+ this.baseUnit = first.measuringUnit;
|
|
|
result.forEach((item) => {
|
|
|
item.batchNo = this.planInfo.batchNo;
|
|
|
item.salesCode = this.planInfo.salesCode;
|
|
|
@@ -881,56 +857,86 @@
|
|
|
},
|
|
|
// 获取bom 数据
|
|
|
async getBomData(data) {
|
|
|
- this.loading = true;
|
|
|
+ // this.loading = true;
|
|
|
try {
|
|
|
this.planId = data.id;
|
|
|
- const res = await findBomCategoryByCategoryId(
|
|
|
- data.categoryId,
|
|
|
- this.produceType
|
|
|
- );
|
|
|
- this.loading = false;
|
|
|
- if (!res || res.length == 0) {
|
|
|
- this.bomListD = [];
|
|
|
- this.datasourceList = [];
|
|
|
- return;
|
|
|
- }
|
|
|
- let obj = {};
|
|
|
+ let params = { categoryId: data.categoryId };
|
|
|
+ const res = await listBomType(params);
|
|
|
+ if (!res || res.length === 0) return;
|
|
|
+ console.log(res, 'res 333');
|
|
|
let bomMap = {
|
|
|
1: 'PBOM',
|
|
|
2: 'MBOM',
|
|
|
3: 'ABOM'
|
|
|
};
|
|
|
- if (this.produceType == 1) {
|
|
|
- delete bomMap[1];
|
|
|
- }
|
|
|
- let result = res.filter((item) => item.bomType != 1);
|
|
|
- result.map((el) => {
|
|
|
- el.bomName = bomMap[el.bomType];
|
|
|
- let OBMINFO = {
|
|
|
- bomId: el.bomId,
|
|
|
- bomType: el.type,
|
|
|
- versions: `V${el.versions}.0`
|
|
|
+ let list = res.map((item) => {
|
|
|
+ return {
|
|
|
+ bomType: item.bomType,
|
|
|
+ id: item.id,
|
|
|
+ bomId: item.id,
|
|
|
+ bomName: bomMap[item.bomType]
|
|
|
};
|
|
|
- if (obj[el.bomType]) {
|
|
|
- obj[el.bomType].bomList.unshift(OBMINFO);
|
|
|
- } else {
|
|
|
- obj[el.bomType] = { ...el, bomList: [OBMINFO] };
|
|
|
- }
|
|
|
});
|
|
|
- let list = Object.values(obj);
|
|
|
- if (list.length == 0) return;
|
|
|
+ let bom = list.find((el) => el.bomType == data.produceType);
|
|
|
+ let bomType = bom ? bom.bomType : list[0].bomType;
|
|
|
this.bomListType = list;
|
|
|
- let bomObj = res.find(
|
|
|
- (item) => item.bomId == this.planInfo.bomCategoryId
|
|
|
- );
|
|
|
- console.log(bomObj, 'bomObj');
|
|
|
- let idx = 0;
|
|
|
- if (bomObj && bomObj.bomId) {
|
|
|
- idx = list.findIndex((item) => item.bomType == bomObj.bomType);
|
|
|
- }
|
|
|
- const index = idx != -1 ? idx : 0;
|
|
|
- await this.bomTypeChange(list[index].id, 'init');
|
|
|
- this.loading = false;
|
|
|
+ this.formInline.bomType = bomType;
|
|
|
+ this.bomTypeChange(bomType, 'init');
|
|
|
+ // console.log(res, 'res 333');
|
|
|
+ // const params = {
|
|
|
+ // categoryId: data.categoryId,
|
|
|
+ // bomType: data.produceType,
|
|
|
+ // isTemp: 0
|
|
|
+ // };
|
|
|
+ // const res = bomVersionList(params);
|
|
|
+ return;
|
|
|
+ // const res = await findBomCategoryByCategoryIdV2(
|
|
|
+ // data.bomCategoryId,
|
|
|
+ // this.produceType
|
|
|
+ // );
|
|
|
+ // this.loading = false;
|
|
|
+ // if (!res || res.length == 0) {
|
|
|
+ // this.bomListD = [];
|
|
|
+ // this.datasourceList = [];
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // let obj = {};
|
|
|
+ // let bomMap = {
|
|
|
+ // 1: 'PBOM',
|
|
|
+ // 2: 'MBOM',
|
|
|
+ // 3: 'ABOM'
|
|
|
+ // };
|
|
|
+ // if (this.produceType == 1) {
|
|
|
+ // delete bomMap[1];
|
|
|
+ // }
|
|
|
+ // let result = res.filter((item) => item.bomType != 1);
|
|
|
+ // result.map((el) => {
|
|
|
+ // el.bomName = bomMap[el.bomType];
|
|
|
+ // let OBMINFO = {
|
|
|
+ // bomId: el.bomId,
|
|
|
+ // bomType: el.type,
|
|
|
+ // versions: `V${el.versions}.0`
|
|
|
+ // };
|
|
|
+ // if (obj[el.bomType]) {
|
|
|
+ // obj[el.bomType].bomList.unshift(OBMINFO);
|
|
|
+ // } else {
|
|
|
+ // obj[el.bomType] = { ...el, bomList: [OBMINFO] };
|
|
|
+ // }
|
|
|
+ // });
|
|
|
+ // let list = Object.values(obj);
|
|
|
+ // if (list.length == 0) return;
|
|
|
+ // this.bomListType = list;
|
|
|
+ // let bomObj = res.find(
|
|
|
+ // (item) => item.bomId == this.planInfo.bomCategoryId
|
|
|
+ // );
|
|
|
+ // console.log(bomObj, 'bomObj');
|
|
|
+ // let idx = 0;
|
|
|
+ // if (bomObj && bomObj.bomId) {
|
|
|
+ // idx = list.findIndex((item) => item.bomType == bomObj.bomType);
|
|
|
+ // }
|
|
|
+ // const index = idx != -1 ? idx : 0;
|
|
|
+ // await this.bomTypeChange(list[index].id, 'init');
|
|
|
+ // this.loading = false;
|
|
|
} catch (err) {
|
|
|
this.$message.error(err.message);
|
|
|
this.loading = false;
|