feat(order): 新增订单提交审批功能并优化保存草稿逻辑

- 修改新增按钮点击事件以支持传参- 添加订单详情标题显示项目名称及版本号- 实现保存草稿和提交审批双按钮操作
- 增加折扣校验逻辑,防止折扣大于100%
- 引入合同和流程类型选择组件
- 优化订单提交逻辑,区分保存与提交状态
- 移除未实现的用户与合作伙伴选择提示
dev_1.0.0
chenhao 2025-11-17 09:34:15 +08:00
parent 1edda375a8
commit b128535cfc
2 changed files with 78 additions and 30 deletions

View File

@ -276,7 +276,6 @@
<div v-if="uniqueContractVersions.length > 0">
<div v-if="currentContractBakFile"
style="display: flex; justify-content: space-between; padding: 5px 20px;">
<h3>历史订单记录</h3>
<span class="file-view"
@click="previewFile(currentContractBakFile.filePath, currentContractBakFile.fileName)">
{{ form.projectName + 'Rev.' + activeContractVersionTab }}
@ -352,15 +351,19 @@
</el-tabs>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm" v-if="!isOrderApprovedOrInReview"> </el-button>
<el-button type="primary" @click="saveDraft" v-if="!isOrderApprovedOrInReview"> </el-button>
<el-button type="success" @click="submitForApproval" v-if="!isOrderApprovedOrInReview"></el-button>
<el-button @click="cancel"> </el-button>
</div>
<input type="hidden" v-model="form.processType" />
<input type="hidden" v-model="form.processTemplate" />
</el-dialog>
<select-agent :visible.sync="selectAgentVisible" @agent-selected="handleAgentSelected"/>
<select-customer :visible.sync="selectCustomerVisible" @customer-selected="handleCustomerSelected"/>
<select-partner :visible.sync="selectPartnerVisible" @partner-selected="handlePartnerSelected"/>
<select-user :visible.sync="selectUserVisible" @user-selected="handleUserSelected"/>
<select-project :visible.sync="selectProjectVisible" @project-selected="handleProjectSelected"/>
<select-commit-type :visible.sync="selectCommitTypeVisible" :order-channel="form.orderChannel" @commit-type-selected="handleCommitTypeSelected"/>
</div>
</template>
@ -381,6 +384,7 @@ import SelectCustomer from "@/views/system/customer/selectCustomer.vue";
import SelectPartner from "@/views/system/partner/selectPartner.vue";
import SelectUser from "@/views/system/user/selectUser.vue";
import SelectProject from "@/views/project/info/SelectProject.vue";
import SelectCommitType from "./SelectCommitType.vue";
export default {
name: "OrderDetail",
@ -391,6 +395,7 @@ export default {
SelectUser,
ProductConfig,
SelectProject,
SelectCommitType,
},
props: {
visible: {
@ -428,6 +433,7 @@ export default {
selectPartnerVisible: false,
selectUserVisible: false,
selectProjectVisible: false,
selectCommitTypeVisible: false,
isProjectSelected: false,
canUpdate: false, // canUpdate
uploadFinalFile: false, // uploadFinalFile
@ -623,7 +629,7 @@ export default {
getOrder(this.orderId).then(response => {
this.form = {...response.data.projectOrderInfo};
this.title=this.form.projectName+"Rev."+this.form.versionCode
this.isProjectSelected = true;
//
if (!this.form.versionCode) {
@ -705,6 +711,7 @@ export default {
});
this.activeContractVersionTab = currentVersion;
// ID
console.log(this.projectId)
if (this.projectId) {
getProject(this.projectId).then(response => {
this.handleProjectSelected(response.data.project);
@ -776,27 +783,73 @@ export default {
this.isProjectSelected = false;
this.resetForm("form");
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
const action = this.isEdit ? updateOrder : addOrder;
action(this.form).then(response => {
this.msgSuccess(this.isEdit ? "修改成功" : "新增成功");
if (!this.isEdit) {
this.form.id = response.data.id; // Assuming backend returns the new order ID in response.data.id
this.isEdit = true; // Mark as edit mode
this.title = "修改订单"; // Change title
this.activeTab = 'contract'; // Switch to contract tab
this.$emit('success'); // Refresh parent list
} else {
this.handleClose();
this.$emit('success');
}
});
/** 提交数据到后端 */
_performSubmit() {
const action = this.isEdit ? updateOrder : addOrder;
action(this.form).then(response => {
this.msgSuccess(this.form.orderStatus === '0' ? "保存成功" : "提交成功");
if (!this.isEdit && this.form.orderStatus === '0') {
// If it was a new draft, update the form to allow file uploads etc.
this.form.id = response.data.id;
this.isEdit = true;
this.title = "修改订单";
this.activeTab = 'contract';
this.$emit('success');
} else {
this.handleClose();
this.$emit('success');
}
});
},
/** 保存草稿 */
saveDraft() {
if (!this.form.projectCode) {
this.msgError("项目编号为必填");
return;
}
const checkDiscount = (list) => {
if (!list) return true;
return list.every(item => item.discount === null || item.discount === undefined || item.discount <= 1);
};
const allDiscountsValid = checkDiscount(this.form.softwareProjectProductInfoList) &&
checkDiscount(this.form.hardwareProjectProductInfoList) &&
checkDiscount(this.form.maintenanceProjectProductInfoList);
if (!allDiscountsValid) {
this.msgError("折扣不能大于100%");
return;
}
this.form.orderStatus = '0';
this._performSubmit();
},
/** 提交审批 */
submitForApproval() {
const contractFiles = this.currentContractFiles;
const hasBusinessApprovalFile = contractFiles && contractFiles.length > 0 && contractFiles[0].id !== -1;
if (!hasBusinessApprovalFile) {
this.msgError("请补充商务审批文件");
return;
}
this.$refs["form"].validate(valid => {
if (valid) {
this.selectCommitTypeVisible = true;
} else {
this.msgError("请完善表单");
}
});
},
/** 处理合同和流程类型选择 */
handleCommitTypeSelected(data) {
this.form.processTemplate = data.processTemplate;
this.form.processType = data.processType;
this.form.orderStatus = '1';
this._performSubmit();
},
/** BG改变事件 */
handleBgChange(value) {
this.form.industryType = null;
@ -909,14 +962,6 @@ export default {
this.selectProjectVisible = false;
},
/** 选择用户按钮操作 */
handleSelectUser() {
this.msgWarning("选择用户功能待实现");
},
/** 选择合作伙伴按钮操作 */
handleSelectPartner() {
this.msgWarning("选择合作伙伴功能待实现");
},
formatApproveStatus(status) {
const statusMap = {

View File

@ -54,7 +54,7 @@
<!-- 操作按钮 -->
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd" v-hasPermi="['project:order:add']"></el-button>
<el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd()" v-hasPermi="['project:order:add']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete" v-hasPermi="['project:order:remove']"></el-button>
@ -248,7 +248,10 @@ export default {
/** 新增按钮操作 */
handleAdd(projectId = null) {
this.currentOrderId = null;
console.log("projectId:", projectId)
if (projectId) {
this.currentProjectIdForOrder = projectId; // Store projectId
}
this.open = true;
this.title = "添加订单";
},