|
|
@@ -19,6 +19,7 @@
|
|
|
v-if="processSubmitDialogFlag"
|
|
|
ref="processSubmitDialogRef"
|
|
|
@reload="savExit"
|
|
|
+ :callBack="processCallBack"
|
|
|
></process-submit-dialog>
|
|
|
<div slot="footer" class="footer">
|
|
|
<el-button
|
|
|
@@ -103,7 +104,9 @@ export default {
|
|
|
isAftertypeThree: false,
|
|
|
watchInterval: null,
|
|
|
|
|
|
- processSubmitDialogFlag: false
|
|
|
+ processSubmitDialogFlag: false,
|
|
|
+ // 保存处理后的参数,用于流程提交
|
|
|
+ processedData: null
|
|
|
};
|
|
|
},
|
|
|
created() {
|
|
|
@@ -164,55 +167,183 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
+ // 流程对话框的回调函数
|
|
|
+ async processCallBack() {
|
|
|
+ try {
|
|
|
+ if (!this.processedData) {
|
|
|
+ this.$message.error('未获取到提交数据');
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 调用提交接口
|
|
|
+ const businessId = await demandSubmit(this.processedData);
|
|
|
+ if (!businessId) {
|
|
|
+ this.$message.error('提交失败,未获取到业务ID');
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 获取详情
|
|
|
+ const detailRes = await getSalesDemandById(businessId);
|
|
|
+ if (!detailRes) {
|
|
|
+ this.$message.error('获取详情失败');
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新流程对话框的表单数据
|
|
|
+ this.$refs.processSubmitDialogRef.form.businessId = businessId;
|
|
|
+ this.$refs.processSubmitDialogRef.form.variables = {
|
|
|
+ businessCode: detailRes.code,
|
|
|
+ businessName: detailRes.name,
|
|
|
+ businessType: '质量问题反馈'
|
|
|
+ };
|
|
|
+
|
|
|
+ return 0; // 返回0表示成功
|
|
|
+ } catch (error) {
|
|
|
+ this.$message.error('提交失败:' + (error.message || '未知错误'));
|
|
|
+ return 1; // 返回1表示失败
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
async submit() {
|
|
|
try {
|
|
|
this.loading = true;
|
|
|
- const pData = await this.handleParameter();
|
|
|
- if (!pData) return;
|
|
|
+
|
|
|
+ const isValid = await this.validateForm();
|
|
|
+ if (!isValid) {
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
const currentAftertype =
|
|
|
this.$refs.infoRef?.form?.aftertype || this.form.aftertype;
|
|
|
- const submitParams = {
|
|
|
- ...pData,
|
|
|
- submitSource: this.type === 'add' ? 1 : 2
|
|
|
- };
|
|
|
|
|
|
if (currentAftertype === '3') {
|
|
|
- // 类型为3时,直接调用接口并打开流程对话框
|
|
|
- const businessId = await demandSubmit(submitParams);
|
|
|
- if (!businessId) {
|
|
|
- console.log('未获取到id');
|
|
|
- return;
|
|
|
- }
|
|
|
- const detailRes = await getSalesDemandById(businessId);
|
|
|
- if (!detailRes) {
|
|
|
- this.$message.error('获取详情失败');
|
|
|
+ const pData = await this.getParameterData();
|
|
|
+ if (!pData) {
|
|
|
+ this.loading = false;
|
|
|
return;
|
|
|
}
|
|
|
- const processParams = {
|
|
|
- businessId: businessId,
|
|
|
- businessKey: 'after_sale_quality_issues_feedback',
|
|
|
- formCreateUserId: getCurrentUser().id,
|
|
|
- variables: {
|
|
|
- businessCode: detailRes.code,
|
|
|
- businessName: detailRes.name,
|
|
|
- businessType: '质量问题反馈'
|
|
|
- }
|
|
|
+ this.processedData = {
|
|
|
+ ...pData,
|
|
|
+ submitSource: this.type === 'add' ? 1 : 2
|
|
|
};
|
|
|
this.processSubmitDialogFlag = true;
|
|
|
this.$nextTick(() => {
|
|
|
+ const processParams = {
|
|
|
+ businessKey: 'after_sale_quality_issues_feedback',
|
|
|
+ formCreateUserId: getCurrentUser().id
|
|
|
+ };
|
|
|
this.$refs.processSubmitDialogRef.init(processParams);
|
|
|
});
|
|
|
+ this.loading = false; // 新增:正常流程结束后重置
|
|
|
} else {
|
|
|
- // 类型不为3时,仅打开弹框,由弹框内操作触发提交
|
|
|
- this.$refs.submitRef.open(submitParams, this.type); // 传递完整参数
|
|
|
+ const pData = await this.getParameterData();
|
|
|
+ if (!pData) {
|
|
|
+ this.loading = false;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.$refs.submitRef.open(pData, this.type);
|
|
|
+ this.loading = false; // 新增:正常流程结束后重置
|
|
|
}
|
|
|
} catch (error) {
|
|
|
this.$message.error('提交失败:' + (error.message || '未知错误'));
|
|
|
- } finally {
|
|
|
this.loading = false;
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ // 只验证表单,不处理数据
|
|
|
+ async validateForm() {
|
|
|
+ try {
|
|
|
+ let data = this.$refs.infoRef.getValue();
|
|
|
+
|
|
|
+ if (!data.contactInfoVOS?.length) {
|
|
|
+ this.$message.warning('联系人信息至少有1条');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 验证表单
|
|
|
+ await this.$refs.infoRef.getValidate();
|
|
|
+ return true;
|
|
|
+ } catch (err) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ // 只获取参数数据,不进行保存操作
|
|
|
+ async getParameterData() {
|
|
|
+ try {
|
|
|
+ let data = this.$refs.infoRef.getValue();
|
|
|
+ let sparePartsData = (this.$refs.infoRef.getSpareInfoData() || []).map(
|
|
|
+ (item) => ({
|
|
|
+ ...item,
|
|
|
+ typeId: item.typeId,
|
|
|
+ code: item.code,
|
|
|
+ name: item.name,
|
|
|
+ feeType: item.feeType,
|
|
|
+ modelType: item.categoryModel,
|
|
|
+ specification: item.specification,
|
|
|
+ content: item.content,
|
|
|
+ totalCount: item.totalCount,
|
|
|
+ measureUnit: item.measureUnit,
|
|
|
+ singlePrice: item.singlePrice,
|
|
|
+ settlementPrice: item.settlementPrice
|
|
|
+ })
|
|
|
+ );
|
|
|
+
|
|
|
+ let expectedTime = data.expectedTime
|
|
|
+ ? this.formatDate(data.expectedTime)
|
|
|
+ : '';
|
|
|
+ let pData = {
|
|
|
+ ...this.form,
|
|
|
+ name: data.name,
|
|
|
+ faultLevel: data.faultLevel,
|
|
|
+ expectedTime: expectedTime,
|
|
|
+ contactId: data.contractInfo.id,
|
|
|
+ contactCode: data.contractInfo.code,
|
|
|
+ contactName: data.contractInfo.name,
|
|
|
+ orderCode: data.orderCode,
|
|
|
+ orderId: data.orderId,
|
|
|
+ contactAddress: data.contactAddress,
|
|
|
+ productDetail: data.tableList.map((item) => {
|
|
|
+ item['produceTime'] = item['produceTime'] || null;
|
|
|
+ return item;
|
|
|
+ }),
|
|
|
+ contactInfoVOS: data.contactInfoVOS,
|
|
|
+
|
|
|
+ associationType: data.associationType,
|
|
|
+ afterSalesType: data.aftertype,
|
|
|
+ isFee: data.charge,
|
|
|
+ isPieCar: data.car,
|
|
|
+ pieCarType: data.pietype,
|
|
|
+ isWithAccessories: data.part,
|
|
|
+ costListVOS: sparePartsData,
|
|
|
+ salespersonId: data.salespersonId,
|
|
|
+ salespersonName: data.salespersonName,
|
|
|
+ involveDeptId: data.involveDeptId,
|
|
|
+ involveDeptName: data.involveDeptName,
|
|
|
+ remark: data.remark,
|
|
|
+ isOutsource: data.isOutsource,
|
|
|
+ isCreatePurchaseOrder: data.isCreatePurchaseOrder,
|
|
|
+ supplierId: data.supplierId,
|
|
|
+ supplierName: data.supplierName,
|
|
|
+ supplierCode: data.supplierCode
|
|
|
+ };
|
|
|
+
|
|
|
+ if (pData.associationType == '2' && pData.productDetail.length == 0) {
|
|
|
+ delete pData.productDetail;
|
|
|
+ pData.faultDetailList = data.faultDetailList;
|
|
|
+ }
|
|
|
+ if (pData.associationType == '3' && pData.productDetail.length == 0) {
|
|
|
+ delete pData.productDetail;
|
|
|
+ pData.faultDetailList = data.faultDetailList;
|
|
|
+ }
|
|
|
+ return pData;
|
|
|
+ } catch (err) {
|
|
|
+ this.$message.error('获取参数失败');
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
async dispatch() {
|
|
|
let pData = await this.handleParameter();
|
|
|
if (!pData) {
|
|
|
@@ -238,6 +369,7 @@ export default {
|
|
|
this.addRepairNotesDialog = false;
|
|
|
this.form = {};
|
|
|
this.isAftertypeThree = false;
|
|
|
+ this.processedData = null;
|
|
|
this.stopWatchingAftertype();
|
|
|
if (this.$refs.infoRef) {
|
|
|
this.$refs.infoRef.catch();
|
|
|
@@ -262,7 +394,7 @@ export default {
|
|
|
return dateString;
|
|
|
}
|
|
|
},
|
|
|
- // 提取公共参数
|
|
|
+ // 提取公共参数(包含保存操作的完整流程)
|
|
|
async handleParameter() {
|
|
|
let data = this.$refs.infoRef.getValue();
|
|
|
console.log('提交前的data:', data.salespersonId, data.salespersonName);
|