|
|
@@ -137,6 +137,23 @@
|
|
|
</el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="属性类型" v-if="produceType == 2">
|
|
|
+ <el-select
|
|
|
+ size="mini"
|
|
|
+ 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"
|
|
|
@@ -235,13 +252,13 @@
|
|
|
<el-button plain @click="cancel">取消</el-button>
|
|
|
<!-- <el-button type="primary" @click="confirm">确定</el-button> -->
|
|
|
</div>
|
|
|
- <CreateOrder
|
|
|
+ <!-- <CreateOrder
|
|
|
ref="createDialog"
|
|
|
name="createDialog1"
|
|
|
:is-add="false"
|
|
|
v-if="orderShow"
|
|
|
@refresh="refresh"
|
|
|
- ></CreateOrder>
|
|
|
+ ></CreateOrder> -->
|
|
|
</ele-modal>
|
|
|
|
|
|
<stockDetailDialog ref="stockDetailDialog" />
|
|
|
@@ -261,12 +278,12 @@
|
|
|
import stockDetailDialog from '../../productionPlan/components/stockDetailDialog.vue';
|
|
|
import currentDetailDialog from '../../productionPlan/components/currentDetailDialog.vue';
|
|
|
import purchaseDialog from '@/views/productionPlan/components/purchaseDialog.vue';
|
|
|
- import CreateOrder from './create-order.vue';
|
|
|
+ // import CreateOrder from './create-order.vue';
|
|
|
// import { findBomCategoryByCategoryId } from '@/api/productionPlan/index';
|
|
|
// import CreateOrder from '../components/create-order.vue';
|
|
|
export default {
|
|
|
components: {
|
|
|
- CreateOrder,
|
|
|
+ // CreateOrder,
|
|
|
stockDetailDialog,
|
|
|
currentDetailDialog,
|
|
|
purchaseDialog
|
|
|
@@ -440,7 +457,8 @@
|
|
|
bomIdList: [],
|
|
|
requiredFormingNum: 0,
|
|
|
formInline: {
|
|
|
- finalState: 0
|
|
|
+ finalState: 0,
|
|
|
+ attributeType: 2
|
|
|
},
|
|
|
finalStateList: [
|
|
|
{
|
|
|
@@ -487,7 +505,21 @@
|
|
|
bomCode: '',
|
|
|
produceType: 1,
|
|
|
selection: [],
|
|
|
- orderShow: false
|
|
|
+ orderShow: false,
|
|
|
+ attributeList: [
|
|
|
+ {
|
|
|
+ value: 'all',
|
|
|
+ label: '全部'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 2,
|
|
|
+ label: '采购件'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 3,
|
|
|
+ label: '外协件'
|
|
|
+ }
|
|
|
+ ]
|
|
|
};
|
|
|
},
|
|
|
watch: {
|
|
|
@@ -604,8 +636,7 @@
|
|
|
let bomMap = {
|
|
|
1: 'PBOM',
|
|
|
2: 'MBOM',
|
|
|
- 3: 'ABOM',
|
|
|
- 4: 'EBOM'
|
|
|
+ 3: 'ABOM'
|
|
|
};
|
|
|
res.map((el) => {
|
|
|
el.bomName = bomMap[el.bomType];
|
|
|
@@ -622,8 +653,17 @@
|
|
|
}
|
|
|
});
|
|
|
let list = Object.values(obj);
|
|
|
+ if (list.length == 0) return;
|
|
|
this.bomListType = list;
|
|
|
- await this.bomTypeChange(list[0].id);
|
|
|
+ let bomObj = res.find(
|
|
|
+ (item) => item.bomId == this.orderInfo.bomCategoryId
|
|
|
+ );
|
|
|
+ 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);
|
|
|
@@ -631,7 +671,7 @@
|
|
|
}
|
|
|
},
|
|
|
// 选择BOM类型
|
|
|
- async bomTypeChange(e) {
|
|
|
+ async bomTypeChange(e, type) {
|
|
|
this.formInline.bomType = e;
|
|
|
this.bomCode = '';
|
|
|
let data = this.bomListType.find((el) => el.id === e);
|
|
|
@@ -642,7 +682,14 @@
|
|
|
name: data.name
|
|
|
};
|
|
|
});
|
|
|
- await this.bomVChange(data.bomList[0].bomId);
|
|
|
+ let idx = 0;
|
|
|
+ if (type == 'init') {
|
|
|
+ idx = data.bomList.findIndex(
|
|
|
+ (item) => item.bomId == this.orderInfo.bomCategoryId
|
|
|
+ );
|
|
|
+ }
|
|
|
+ const index = idx != -1 ? idx : 0;
|
|
|
+ await this.bomVChange(data.bomList[index].bomId);
|
|
|
},
|
|
|
// 选择BOM版本
|
|
|
async bomVChange(e) {
|
|
|
@@ -650,17 +697,72 @@
|
|
|
let data = this.bomListV.find((el) => el.bomId === e);
|
|
|
if (!data) return;
|
|
|
this.bomCode = data.code;
|
|
|
- await this.getMaterialData(data);
|
|
|
+ await this.getMaterialData(data, this.formInline.attributeType);
|
|
|
+ },
|
|
|
+
|
|
|
+ // 查询采购价跟外协件两个类型数据
|
|
|
+ async dataMerging() {
|
|
|
+ let params1 = {
|
|
|
+ salesOrderId: this.salesOrderId,
|
|
|
+ bomVersionId: this.formInline.bomId,
|
|
|
+ produceType: 2
|
|
|
+ };
|
|
|
+ let params2 = {
|
|
|
+ salesOrderId: this.salesOrderId,
|
|
|
+ bomVersionId: this.formInline.bomId,
|
|
|
+ produceType: 3
|
|
|
+ };
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ // 直接调用接口函数,因为其返回Promise,无需额外包装
|
|
|
+ let p1 = findMaterialInfoSalesorder(params1);
|
|
|
+ let p2 = findMaterialInfoSalesorder(params2);
|
|
|
+ // 使用Promise.all并行执行多个Promise
|
|
|
+ let results = await Promise.all([p1, p2]);
|
|
|
+ this.loading = false;
|
|
|
+ console.log(results, 'results');
|
|
|
+ // 这里可以继续对results做后续处理,比如解构等
|
|
|
+ const [result1, result2] = results;
|
|
|
+ // 示例:可以接着处理result1和result2,比如合并数据等
|
|
|
+ const mergeData = this.handleMergedData(result1, result2);
|
|
|
+ console.log(mergeData, 'mergeData');
|
|
|
+ this.resultProcess(mergeData);
|
|
|
+ } catch (error) {
|
|
|
+ this.loading = false;
|
|
|
+ console.error('接口请求出错:', error);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ handleMergedData(result1, result2) {
|
|
|
+ // 处理合并后的数据逻辑
|
|
|
+ return [...result1, ...result2];
|
|
|
+ },
|
|
|
+ // 切换属性
|
|
|
+ async attributeChange(e) {
|
|
|
+ if (e == 'all') {
|
|
|
+ this.dataMerging();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ let data = this.bomListV.find(
|
|
|
+ (el) => el.bomId === this.formInline.bomId
|
|
|
+ );
|
|
|
+ if (!data) return;
|
|
|
+ await this.getMaterialData(data, e);
|
|
|
},
|
|
|
// 获取物料数据信息
|
|
|
- async getMaterialData(data) {
|
|
|
+ async getMaterialData(data, attributeType) {
|
|
|
+ if (attributeType == 'all') {
|
|
|
+ this.dataMerging();
|
|
|
+ return;
|
|
|
+ }
|
|
|
let params = {};
|
|
|
let api = null;
|
|
|
if (this.source == 'list') {
|
|
|
+ let produceType =
|
|
|
+ this.produceType == 1 ? 1 : attributeType == 2 ? 2 : 3;
|
|
|
params = {
|
|
|
salesOrderId: this.salesOrderId,
|
|
|
bomVersionId: data.bomId,
|
|
|
- produceType: this.produceType
|
|
|
+ produceType: produceType
|
|
|
};
|
|
|
api = findMaterialInfoSalesorder;
|
|
|
} else {
|
|
|
@@ -671,9 +773,18 @@
|
|
|
requiredFormingNum: this.orderInfo.contractNum
|
|
|
};
|
|
|
}
|
|
|
-
|
|
|
- // let api = this.source == 'list' ? findMaterialInfoSalesorder : findMaterialInfoByCategory;
|
|
|
- const result = await api(params);
|
|
|
+ this.loading = true;
|
|
|
+ try {
|
|
|
+ const result = await api(params);
|
|
|
+ // 结果数据处理
|
|
|
+ this.resultProcess(result);
|
|
|
+ this.loading = false;
|
|
|
+ } catch (err) {
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 结果数据处理
|
|
|
+ resultProcess(result) {
|
|
|
result.map((item) => {
|
|
|
item.batchNo = this.orderInfo.batchNo;
|
|
|
item.productCode = this.orderInfo.productCode;
|
|
|
@@ -685,7 +796,8 @@
|
|
|
: '';
|
|
|
});
|
|
|
this.datasourceAllList = result;
|
|
|
- this.finalChange(0);
|
|
|
+ this.finalChange(this.formInline.finalState);
|
|
|
+
|
|
|
},
|
|
|
// 选择状态
|
|
|
finalChange(e) {
|
|
|
@@ -796,7 +908,8 @@
|
|
|
},
|
|
|
clearData() {
|
|
|
this.formInline = {
|
|
|
- finalState: 0
|
|
|
+ finalState: 0,
|
|
|
+ attributeType: 2
|
|
|
};
|
|
|
this.bomListV = [];
|
|
|
this.bomListType = [];
|