|
|
@@ -434,6 +434,7 @@
|
|
|
|
|
|
// 提交状态
|
|
|
loading: false,
|
|
|
+ saving: false,
|
|
|
// 是否是修改
|
|
|
isUpdate: false,
|
|
|
businessId: '',
|
|
|
@@ -774,8 +775,10 @@
|
|
|
);
|
|
|
this.$refs.palletTableRef &&
|
|
|
this.$refs.palletTableRef.putTableValue(data.trayList);
|
|
|
- this.$refs.replaceRef &&
|
|
|
+ if (this.$refs.replaceRef) {
|
|
|
+ this.$refs.replaceRef.restTable();
|
|
|
this.$refs.replaceRef.putTableValue(data.replaceList);
|
|
|
+ }
|
|
|
this.syncReplaceRelationIds();
|
|
|
});
|
|
|
}
|
|
|
@@ -1077,6 +1080,7 @@
|
|
|
this.title = '新增发货单';
|
|
|
this.visible = true;
|
|
|
this.isUpdate = false;
|
|
|
+ this.businessId = '';
|
|
|
this.saleOrderNeedProduce = '';
|
|
|
this.getInfo(row);
|
|
|
},
|
|
|
@@ -1127,10 +1131,18 @@
|
|
|
});
|
|
|
},
|
|
|
async save(type) {
|
|
|
+ if (this.saving || this.loading) return;
|
|
|
+ this.saving = true;
|
|
|
+ this.loading = true;
|
|
|
try {
|
|
|
+ if (!this.isUpdate && this.businessId) {
|
|
|
+ await this.getSendSaleOrderDetail(this.businessId);
|
|
|
+ await this.$nextTick();
|
|
|
+ this.isUpdate = true;
|
|
|
+ this.$message.warning('发货单已保存,请确认内容后重新提交');
|
|
|
+ return;
|
|
|
+ }
|
|
|
await this.getValidate();
|
|
|
- // 表单验证通过,执行保存操作
|
|
|
- this.loading = true;
|
|
|
|
|
|
if (!this.isUpdate) {
|
|
|
delete this.form.id;
|
|
|
@@ -1190,44 +1202,44 @@
|
|
|
// }
|
|
|
|
|
|
if (this.isUpdate) {
|
|
|
- UpdateSendInformation(commitData)
|
|
|
- .then((res) => {
|
|
|
- this.loading = false;
|
|
|
- if (type === 'sub') {
|
|
|
- return this.sendSubmit(res);
|
|
|
- }
|
|
|
- this.$message.success('修改成功');
|
|
|
- this.cancel();
|
|
|
- this.$emit('done');
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- this.loading = false;
|
|
|
- console.error('修改发货单失败', e);
|
|
|
- });
|
|
|
+ const res = await UpdateSendInformation(commitData);
|
|
|
+ if (type === 'sub') {
|
|
|
+ await this.sendSubmit(res);
|
|
|
+ } else {
|
|
|
+ this.$message.success('修改成功');
|
|
|
+ this.cancel();
|
|
|
+ this.$emit('done');
|
|
|
+ }
|
|
|
} else {
|
|
|
- addSendInformation(commitData)
|
|
|
- .then((res) => {
|
|
|
- this.loading = false;
|
|
|
- if (type === 'sub') {
|
|
|
- return this.sendSubmit(res);
|
|
|
- }
|
|
|
- this.$message.success('新增成功');
|
|
|
- this.cancel();
|
|
|
- this.$emit('done');
|
|
|
- })
|
|
|
- .catch((e) => {
|
|
|
- this.loading = false;
|
|
|
- console.error('新增发货单失败', e);
|
|
|
- });
|
|
|
+ const res = await addSendInformation(commitData);
|
|
|
+ // shortcut: 新增响应丢失时无法识别已落库单据,需服务端幂等标识兜底。
|
|
|
+ this.businessId = res;
|
|
|
+ if (type === 'sub') {
|
|
|
+ await this.getSendSaleOrderDetail(res);
|
|
|
+ await this.$nextTick();
|
|
|
+ this.isUpdate = true;
|
|
|
+ await this.sendSubmit(res);
|
|
|
+ } else {
|
|
|
+ this.$message.success('新增成功');
|
|
|
+ this.cancel();
|
|
|
+ this.$emit('done');
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
- console.log(error);
|
|
|
- // 表单验证未通过,不执行保存操作
|
|
|
+ if (error) {
|
|
|
+ console.error('保存发货单或准备审批失败', error);
|
|
|
+ if (this.businessId && !this.isUpdate) {
|
|
|
+ this.$message.error('发货单已保存,重新提交前请先恢复草稿');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } finally {
|
|
|
+ this.saving = false;
|
|
|
+ this.loading = false;
|
|
|
}
|
|
|
},
|
|
|
async sendSubmit(res) {
|
|
|
console.log('res~~~~~~', res, this.businessId);
|
|
|
- let paramsId = this.isReturnGoodsCreate ? res : this.businessId || res;
|
|
|
+ let paramsId = this.businessId || res;
|
|
|
console.log('paramsId~~~', paramsId);
|
|
|
const data = await getSendSaleOrderrecordDetailSplit(paramsId);
|
|
|
let storemanIds = '';
|