|
|
@@ -18,6 +18,8 @@
|
|
|
:rules="rules"
|
|
|
class="el-form-box"
|
|
|
label-width="120px"
|
|
|
+ v-loading="copyLoading"
|
|
|
+ element-loading-text="正在加载复制数据…"
|
|
|
>
|
|
|
<headerTitle title="订单信息"></headerTitle>
|
|
|
<el-row>
|
|
|
@@ -795,7 +797,8 @@
|
|
|
getPurchasePlanByContractIdAPI,
|
|
|
UpdateInformation,
|
|
|
getSupplierInfo,
|
|
|
- getByIdForEdit
|
|
|
+ getByIdForEdit,
|
|
|
+ getPurchaseOrderCopyInfo
|
|
|
} from '@/api/purchasingManage/purchaseOrder';
|
|
|
import { getplanDetail } from '@/api/purchasingManage/purchasePlanManage';
|
|
|
import { getpurchaseinquiry } from '@/api/purchasingManage/inquiryManage';
|
|
|
@@ -982,6 +985,8 @@
|
|
|
|
|
|
// 提交状态
|
|
|
loading: false,
|
|
|
+ // 复制/历史记录取数遮罩:数据回来(含物品清单分批入表)后才撤
|
|
|
+ copyLoading: false,
|
|
|
// 是否是修改
|
|
|
isUpdate: false,
|
|
|
businessId: '',
|
|
|
@@ -1187,70 +1192,23 @@
|
|
|
this.$refs.orderListDialogRef.open();
|
|
|
},
|
|
|
async changeHistoryOrder(item) {
|
|
|
- console.log('item~~~~', item)
|
|
|
- const data = await getpurchaseorderDetail(item.id);
|
|
|
- console.log('data~~~~', data);
|
|
|
- [
|
|
|
- 'id',
|
|
|
- 'orderId',
|
|
|
- 'createTime',
|
|
|
- 'createUserId',
|
|
|
- 'createUserName',
|
|
|
- 'createDept',
|
|
|
- 'orderNo',
|
|
|
- 'orderStatus',
|
|
|
- 'outboundStatus',
|
|
|
- 'payStatus',
|
|
|
- 'preOrderNo',
|
|
|
- 'progress',
|
|
|
- 'processInstanceId',
|
|
|
- 'orderBomList'
|
|
|
- ].forEach((key) => {
|
|
|
- delete data[key];
|
|
|
- data.productList.forEach((item) => {
|
|
|
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
|
|
|
- delete item[key];
|
|
|
- }
|
|
|
- });
|
|
|
- data.rawList.forEach((item) => {
|
|
|
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
|
|
|
- delete item[key];
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- data.outputList.forEach((item) => {
|
|
|
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
|
|
|
- delete item[key];
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- data.receiptPaymentList.forEach((item) => {
|
|
|
- if (['id', 'createTime', 'createUserId', 'orderId'].includes(key)) {
|
|
|
- delete item[key];
|
|
|
- }
|
|
|
- });
|
|
|
- });
|
|
|
-
|
|
|
- this.form = data;
|
|
|
- if (data) {
|
|
|
- // data.relationType = +data.relationType;
|
|
|
- this.$nextTick(() => {
|
|
|
- this.$store.commit('order/setAllcountAmount', data.totalAmount);
|
|
|
- this.$refs.inventoryTable &&
|
|
|
- this.$refs.inventoryTable.putTableValue(data.productList);
|
|
|
- this.$refs.rawDetailListRef &&
|
|
|
- this.$refs.rawDetailListRef.putTableValue(data.rawList); //原料
|
|
|
- this.$refs.outputDetailListRef &&
|
|
|
- this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
|
|
|
- this.getLinkInfo(data.partaId);
|
|
|
-
|
|
|
- this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
|
|
|
- this.getrequireUser(data.requireDeptId);
|
|
|
- if(data.purchaseDeptId) {
|
|
|
- this.getPurchaseUser(data.purchaseDeptId);
|
|
|
- }
|
|
|
- this.$store.commit('order/setContractId', data.contractId);
|
|
|
- });
|
|
|
+ this.copyLoading = true;
|
|
|
+ try {
|
|
|
+ const data = await getPurchaseOrderCopyInfo(item.id);
|
|
|
+ this.fillForm(data);
|
|
|
+ await this.waitCopyFillDone();
|
|
|
+ } catch (e) {
|
|
|
+ this.$message.error(e?.message || '历史订单数据加载失败');
|
|
|
+ } finally {
|
|
|
+ this.copyLoading = false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 回填后物品清单是分批入表的,等它落完再撤遮罩(15 秒兜底,避免异常时遮罩不消失)
|
|
|
+ async waitCopyFillDone() {
|
|
|
+ await this.$nextTick();
|
|
|
+ const deadline = Date.now() + 15000;
|
|
|
+ while (this.$refs?.inventoryTable?.tableBusy && Date.now() < deadline) {
|
|
|
+ await new Promise((resolve) => setTimeout(resolve, 100));
|
|
|
}
|
|
|
},
|
|
|
setIssueNumber(len) {
|
|
|
@@ -1963,6 +1921,12 @@
|
|
|
? await getByIdForEdit(id)
|
|
|
: await getpurchaseorderDetail(id);
|
|
|
this.loading = false;
|
|
|
+ this.fillForm(data);
|
|
|
+ },
|
|
|
+
|
|
|
+ //回填订单详情数据(修改、复制共用),保持原有回填顺序
|
|
|
+ fillForm(data) {
|
|
|
+ if (!data) return;
|
|
|
data.settlementDate = data.startSettlementDate ? [data.startSettlementDate, data.endSettlementDate] : [];
|
|
|
this.form = data;
|
|
|
console.log('data~~~~~~~000', data);
|
|
|
@@ -1976,7 +1940,6 @@
|
|
|
this.$refs.outputDetailListRef &&
|
|
|
this.$refs.outputDetailListRef.putTableValue(data.outputList); //产成品
|
|
|
this.getLinkInfo(data.partaId);
|
|
|
-
|
|
|
this.$refs.paymentCollectionPlanRef && this.$refs.paymentCollectionPlanRef.putTableValue(data);
|
|
|
this.getrequireUser(this.form.requireDeptId);
|
|
|
if(data.purchaseDeptId) {
|
|
|
@@ -2247,13 +2210,19 @@
|
|
|
},
|
|
|
//打开新增编辑弹框
|
|
|
async open(type, row, contactCategoryId) {
|
|
|
- this.title = type === 'add' ? '新增' : '修改';
|
|
|
+ this.title =
|
|
|
+ type === 'add' ? '新增' : type === 'copy' ? '复制' : '修改';
|
|
|
this.activeName = '1';
|
|
|
|
|
|
this.row = row;
|
|
|
+ // 重置提交对象,避免上一次打开(修改/复制)残留的 businessId 串单
|
|
|
+ this.businessId = '';
|
|
|
// 打开弹框前先清空缓存,避免残留上次数据
|
|
|
this.rawDetailListCache = [];
|
|
|
this.outputDetailListCache = [];
|
|
|
+ // 复制是异步取数:进分支就先开遮罩,避免弹窗先出一段时间的空壳
|
|
|
+ // 先复位,避免上一次异常中断残留的遮罩影响新增/修改
|
|
|
+ this.copyLoading = type === 'copy';
|
|
|
this.visible = true;
|
|
|
if (this.groupData.length == 0) {
|
|
|
await this.getGroupAll();
|
|
|
@@ -2282,6 +2251,18 @@
|
|
|
});
|
|
|
this.form.contractStartDate = formatDate(new Date(), 'yyyy-MM-dd');
|
|
|
this.form.isGeneratePaymentPlan = +this.isGenReceiptPlan;
|
|
|
+ } else if (type == 'copy') {
|
|
|
+ this.isUpdate = false;
|
|
|
+ try {
|
|
|
+ const data = await getPurchaseOrderCopyInfo(row.id);
|
|
|
+ this.fillForm(data);
|
|
|
+ await this.waitCopyFillDone();
|
|
|
+ } catch (e) {
|
|
|
+ this.visible = false;
|
|
|
+ this.$message.error(e?.message || '复制数据加载失败');
|
|
|
+ } finally {
|
|
|
+ this.copyLoading = false;
|
|
|
+ }
|
|
|
} else {
|
|
|
this.isUpdate = true;
|
|
|
await this.getpurchaseorderDetail(row.id, true);
|
|
|
@@ -2325,6 +2306,8 @@
|
|
|
//从合同页面新增订单
|
|
|
contractOpen(row) {
|
|
|
this.title = '新增';
|
|
|
+ // 重置提交对象,避免上一次打开(修改/复制)残留的 businessId 串单
|
|
|
+ this.businessId = '';
|
|
|
this.visible = true;
|
|
|
this.isUpdate = false;
|
|
|
this.form.relationType = 4;
|
|
|
@@ -2430,6 +2413,8 @@
|
|
|
|
|
|
if (!this.isUpdate) {
|
|
|
delete this.form.id;
|
|
|
+ // 新增/复制不提交订单编号,一律由后端按编码规则生成,避免空号或旧号落库
|
|
|
+ delete this.form.orderNo;
|
|
|
}
|
|
|
// if (!this.form.contractId) { //如果来源是合同 金额不变这个逻辑有问题 先注释
|
|
|
this.form.totalAmount = this.allcountAmount;
|