feat(bid): 新增基于甲方报价快速创建RFQ功能
本次提交完成以下核心变更: 1. 新增RFQ编号自动生成逻辑,添加selectNextRfqNo方法获取月度递增的RFQ编号 2. 在biz_rfq表新增client_quote_id关联字段,添加索引并完善实体类映射 3. 实现基于甲方报价复制物料快速创建RFQ的业务逻辑,包括事务处理和明细复制 4. 新增RFQ列表页关联甲方报价展示,支持点击跳转查看甲方报价详情 5. 在RFQ编辑页新增甲方报价选择器,选中后自动填充对应物料和标题 6. 优化甲方报价单页面,新增生成RFQ按钮和已生成RFQ列表展示 7. 调整RFQ详情页,新增编辑模式支持草稿状态修改 8. 修复路由跳转路径,统一RFQ相关页面路由到/bid/rfq路径组
This commit is contained in:
@@ -2,12 +2,21 @@
|
||||
<div class="app-container">
|
||||
<div class="page-actions">
|
||||
<el-button icon="el-icon-back" size="small" @click="$router.back()">返回</el-button>
|
||||
<el-button type="primary" icon="el-icon-download" size="small" :loading="pdfLoading" @click="exportPdf">导出 PDF</el-button>
|
||||
<template v-if="!isEditing">
|
||||
<el-button type="primary" icon="el-icon-edit" size="small" @click="startEdit"
|
||||
v-if="rfq && rfq.status === 'draft'" :disabled="loading">编辑</el-button>
|
||||
<el-button type="warning" icon="el-icon-download" size="small"
|
||||
:loading="pdfLoading" @click="exportPdf">导出 PDF</el-button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-button @click="cancelEdit">取消</el-button>
|
||||
<el-button type="primary" icon="el-icon-check" :loading="saving" @click="handleSave">保存</el-button>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<div v-loading="loading">
|
||||
<!-- ===================== 查看模式 ===================== -->
|
||||
<div v-if="!isEditing" v-loading="loading">
|
||||
<div v-if="rfq" id="rfq-pdf-area" class="pdf-area">
|
||||
<!-- PDF Header -->
|
||||
<div class="pdf-header">
|
||||
<img :src="logoSrc" class="pdf-logo" />
|
||||
<div class="pdf-header-text">
|
||||
@@ -18,7 +27,6 @@
|
||||
</div>
|
||||
<div class="pdf-divider"></div>
|
||||
|
||||
<!-- Meta info -->
|
||||
<table class="pdf-meta-table">
|
||||
<tr>
|
||||
<td class="meta-label">RFQ编号</td><td class="meta-val">{{ rfq.rfqNo }}</td>
|
||||
@@ -30,14 +38,21 @@
|
||||
<td class="meta-val"><el-tag :type="statusType(rfq.status)" size="small">{{ statusLabel(rfq.status) }}</el-tag></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="meta-label">交货地址</td><td class="meta-val" colspan="3">{{ rfq.deliveryAddr }}</td>
|
||||
<td class="meta-label">交货地址</td><td class="meta-val" colspan="3">{{ rfq.deliveryAddr || '-' }}</td>
|
||||
</tr>
|
||||
<tr v-if="rfq.clientQuoteNo">
|
||||
<td class="meta-label">关联甲方报价</td>
|
||||
<td class="meta-val" colspan="3">
|
||||
<el-button type="text" size="small" @click="viewClientQuote">
|
||||
{{ rfq.clientQuoteNo }} - {{ rfq.clientName || '' }}
|
||||
</el-button>
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="rfq.remark">
|
||||
<td class="meta-label">备注</td><td class="meta-val" colspan="3">{{ rfq.remark }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<!-- Items -->
|
||||
<div class="pdf-section-title">物料明细</div>
|
||||
<table class="pdf-items-table">
|
||||
<thead>
|
||||
@@ -47,15 +62,14 @@
|
||||
<tr v-for="(item, i) in rfq.items" :key="i">
|
||||
<td>{{ i + 1 }}</td>
|
||||
<td>{{ item.materialName }}</td>
|
||||
<td>{{ item.spec }}</td>
|
||||
<td>{{ item.spec || '-' }}</td>
|
||||
<td>{{ item.unit }}</td>
|
||||
<td>{{ item.quantity }}</td>
|
||||
<td>{{ item.expectedPrice || '-' }}</td>
|
||||
<td>{{ item.expectedPrice != null ? '¥' + item.expectedPrice : '-' }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<!-- Quotations section -->
|
||||
<div v-if="quotations.length > 0">
|
||||
<div class="pdf-section-title" style="margin-top:24px">收到报价汇总</div>
|
||||
<table class="pdf-items-table">
|
||||
@@ -78,11 +92,111 @@
|
||||
<div class="pdf-footer">生成时间:{{ new Date().toLocaleString('zh-CN') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ===================== 编辑模式 ===================== -->
|
||||
<div v-else v-loading="loading">
|
||||
<el-card shadow="never" class="edit-card">
|
||||
<div slot="header"><strong>基本信息</strong></div>
|
||||
<el-form ref="editForm" :model="editForm" :rules="editRules" label-width="110px" size="small">
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="RFQ编号">
|
||||
<el-input :value="editForm.rfqNo" disabled />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="状态">
|
||||
<el-tag :type="statusType(editForm.status)" size="small">{{ statusLabel(editForm.status) }}</el-tag>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="RFQ标题" prop="rfqTitle">
|
||||
<el-input v-model="editForm.rfqTitle" placeholder="请输入标题" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12">
|
||||
<el-form-item label="截止日期" prop="deadline">
|
||||
<el-date-picker v-model="editForm.deadline" type="datetime" placeholder="选择截止日期"
|
||||
value-format="yyyy-MM-dd HH:mm:ss" style="width:100%" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="交货地址">
|
||||
<el-input v-model="editForm.deliveryAddr" placeholder="请输入交货地址" />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="12" v-if="editForm.clientQuoteNo">
|
||||
<el-form-item label="关联甲方报价">
|
||||
<el-button type="text" size="small" @click="viewClientQuote">
|
||||
{{ editForm.clientQuoteNo }} - {{ editForm.clientName || '' }}
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-form-item label="备注">
|
||||
<el-input v-model="editForm.remark" type="textarea" :rows="2" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
|
||||
<el-card shadow="never" class="edit-card" style="margin-top:12px">
|
||||
<div slot="header">
|
||||
<strong>物料明细</strong>
|
||||
<el-button style="float:right" type="primary" size="mini" icon="el-icon-plus" @click="addEditItem">添加行</el-button>
|
||||
</div>
|
||||
<el-table :data="editForm.items" border size="small">
|
||||
<el-table-column type="index" width="46" label="#" />
|
||||
<el-table-column label="物料名称" min-width="160">
|
||||
<template slot-scope="s">
|
||||
<el-input v-model="s.row.materialName" size="mini" placeholder="物料名称" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="规格型号" min-width="130">
|
||||
<template slot-scope="s">
|
||||
<el-input v-model="s.row.spec" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" width="80">
|
||||
<template slot-scope="s">
|
||||
<el-input v-model="s.row.unit" size="mini" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="数量" width="110">
|
||||
<template slot-scope="s">
|
||||
<el-input-number v-model="s.row.quantity" :min="0" :precision="2" size="small" style="width:100%" controls-position="right" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="预期单价" width="130">
|
||||
<template slot-scope="s">
|
||||
<el-input-number v-model="s.row.expectedPrice" :min="0" :precision="2" size="small" style="width:100%" controls-position="right" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="参考来源" width="90" align="center">
|
||||
<template slot-scope="s">
|
||||
<span v-if="s.row._fromClient" style="color:#409eff;font-size:12px">甲方报价</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="60" align="center">
|
||||
<template slot-scope="s">
|
||||
<el-button type="text" icon="el-icon-delete" style="color:#f56c6c" @click="removeEditItem(s.$index)" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<div v-if="!editForm.items || editForm.items.length === 0"
|
||||
style="text-align:center;padding:20px;color:#c0c4cc;font-size:13px">
|
||||
暂无物料,点击上方「添加行」按钮添加
|
||||
</div>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { getRfq } from "@/api/bid/rfq";
|
||||
import { getRfq, updateRfq } from "@/api/bid/rfq";
|
||||
import { listQuotation } from "@/api/bid/quotation";
|
||||
import logoImg from "@/assets/logo/logo.png";
|
||||
import html2canvas from "html2canvas";
|
||||
@@ -92,26 +206,109 @@ export default {
|
||||
name: "RfqDetail",
|
||||
data() {
|
||||
return {
|
||||
loading: false, pdfLoading: false,
|
||||
loading: false, saving: false, pdfLoading: false,
|
||||
rfq: null, quotations: [],
|
||||
isEditing: false,
|
||||
editForm: { items: [] },
|
||||
editRules: {
|
||||
rfqTitle: [{ required: true, message: "标题不能为空", trigger: "blur" }]
|
||||
},
|
||||
logoSrc: logoImg
|
||||
};
|
||||
},
|
||||
created() {
|
||||
const rfqId = this.$route.query.rfqId;
|
||||
if (rfqId) this.loadDetail(rfqId);
|
||||
const editMode = this.$route.query.edit === '1';
|
||||
if (rfqId) {
|
||||
this.loadDetail(rfqId, editMode);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadDetail(rfqId) {
|
||||
loadDetail(rfqId, editMode) {
|
||||
this.loading = true;
|
||||
getRfq(rfqId).then(r => {
|
||||
this.rfq = r.data;
|
||||
if (editMode && this.rfq && this.rfq.status === 'draft') {
|
||||
this.isEditing = true;
|
||||
this.initEditForm();
|
||||
}
|
||||
this.loading = false;
|
||||
});
|
||||
}).catch(() => { this.loading = false; });
|
||||
listQuotation({ rfqId, pageSize: 50 }).then(r => {
|
||||
this.quotations = r.rows || [];
|
||||
});
|
||||
},
|
||||
|
||||
// ---- 编辑模式 ----
|
||||
initEditForm() {
|
||||
this.editForm = {
|
||||
rfqId: this.rfq.rfqId,
|
||||
rfqNo: this.rfq.rfqNo,
|
||||
rfqTitle: this.rfq.rfqTitle,
|
||||
deadline: this.rfq.deadline,
|
||||
deliveryAddr: this.rfq.deliveryAddr || '',
|
||||
clientQuoteId: this.rfq.clientQuoteId,
|
||||
clientQuoteNo: this.rfq.clientQuoteNo,
|
||||
clientName: this.rfq.clientName,
|
||||
remark: this.rfq.remark || '',
|
||||
status: this.rfq.status,
|
||||
items: (this.rfq.items || []).map(item => ({ ...item }))
|
||||
};
|
||||
},
|
||||
|
||||
startEdit() {
|
||||
if (this.rfq.status !== 'draft') {
|
||||
this.$message.warning('只有草稿状态的RFQ可以编辑');
|
||||
return;
|
||||
}
|
||||
this.initEditForm();
|
||||
this.isEditing = true;
|
||||
},
|
||||
|
||||
cancelEdit() {
|
||||
this.isEditing = false;
|
||||
this.editForm = { items: [] };
|
||||
},
|
||||
|
||||
handleSave() {
|
||||
this.$refs.editForm.validate(valid => {
|
||||
if (!valid) return;
|
||||
this.saving = true;
|
||||
updateRfq(this.editForm).then(() => {
|
||||
this.$modal.msgSuccess("保存成功");
|
||||
this.isEditing = false;
|
||||
// 重新加载数据刷新视图
|
||||
return getRfq(this.editForm.rfqId);
|
||||
}).then(r => {
|
||||
this.rfq = r.data;
|
||||
this.quotations = [];
|
||||
listQuotation({ rfqId: this.editForm.rfqId, pageSize: 50 }).then(res => {
|
||||
this.quotations = res.rows || [];
|
||||
});
|
||||
}).catch(() => {}).finally(() => { this.saving = false; });
|
||||
});
|
||||
},
|
||||
|
||||
addEditItem() {
|
||||
if (!this.editForm.items) this.editForm.items = [];
|
||||
this.editForm.items.push({
|
||||
materialName: '', spec: '', unit: '', quantity: 1, expectedPrice: null
|
||||
});
|
||||
},
|
||||
|
||||
removeEditItem(idx) {
|
||||
this.editForm.items.splice(idx, 1);
|
||||
},
|
||||
|
||||
// ---- 关联跳转 ----
|
||||
viewClientQuote() {
|
||||
const quoteId = this.rfq ? this.rfq.clientQuoteId : this.editForm.clientQuoteId;
|
||||
if (quoteId) {
|
||||
this.$router.push({ path: '/quotemgr/clientquote/detail', query: { quoteId } });
|
||||
}
|
||||
},
|
||||
|
||||
// ---- PDF导出 ----
|
||||
async exportPdf() {
|
||||
this.pdfLoading = true;
|
||||
try {
|
||||
@@ -134,6 +331,7 @@ export default {
|
||||
this.pdfLoading = false;
|
||||
}
|
||||
},
|
||||
|
||||
statusType(s) { return { draft:"info", published:"warning", closed:"", completed:"success" }[s] || ""; },
|
||||
statusLabel(s) { return { draft:"草稿", published:"已发布", closed:"已关闭", completed:"已完成" }[s] || s; },
|
||||
qStatusType(s) { return { draft:"info", submitted:"warning", accepted:"success", rejected:"danger" }[s] || ""; },
|
||||
@@ -148,6 +346,7 @@ export default {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
}
|
||||
.edit-card ::v-deep .el-card__body { padding: 20px; }
|
||||
.pdf-area {
|
||||
padding: 28px;
|
||||
background: #fff;
|
||||
|
||||
Reference in New Issue
Block a user