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:
2026-06-02 18:44:44 +08:00
parent a75589018f
commit 9db84336bc
12 changed files with 514 additions and 70 deletions

View File

@@ -7,3 +7,7 @@ export const addRfq = (data) => request({ url: baseUrl, method: 'post', data })
export const updateRfq = (data) => request({ url: baseUrl, method: 'put', data })
export const publishRfq = (rfqId, supplierIds) => request({ url: baseUrl + '/publish/' + rfqId, method: 'put', data: supplierIds })
export const delRfq = (ids) => request({ url: baseUrl + '/' + ids, method: 'delete' })
// 关联甲方报价
export const getClientQuoteOptions = () => request({ url: baseUrl + '/client-quote-options', method: 'get' })
export const createRfqFromQuote = (clientQuoteId) => request({ url: baseUrl + '/create-from-quote/' + clientQuoteId, method: 'post' })

View File

@@ -78,12 +78,6 @@
</template>
</el-table-column>
<el-table-column label="客户名称" prop="clientName" min-width="140" show-overflow-tooltip />
<el-table-column label="关联询价" min-width="150">
<template slot-scope="s">
<div style="font-weight:600;color:#303133">{{ s.row.rfqNo || '-' }}</div>
<div style="font-size:12px;color:#909399;margin-top:2px" v-if="s.row.rfqTitle">{{ s.row.rfqTitle }}</div>
</template>
</el-table-column>
<el-table-column label="总金额" width="130" align="right">
<template slot-scope="s">
<strong style="color:#409EFF;font-size:15px">¥{{ s.row.totalAmount | money }}</strong>
@@ -103,11 +97,12 @@
</el-table-column>
<el-table-column label="创建人" prop="createBy" width="100" align="center" />
<el-table-column label="创建时间" prop="createTime" width="160" align="center" />
<el-table-column label="操作" align="center" width="210" fixed="right">
<el-table-column label="操作" align="center" width="280" fixed="right">
<template slot-scope="s">
<el-button size="mini" type="text" icon="el-icon-view" @click="handleView(s.row)">详情</el-button>
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(s.row)">编辑</el-button>
<el-button size="mini" type="text" icon="el-icon-document-copy" @click="handleQuickCreate(s.row)">快速新建</el-button>
<el-button size="mini" type="text" icon="el-icon-s-promotion" style="color:#67C23A" @click="handleCreateRfq(s.row)">生成RFQ</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" style="color:#f56c6c"
@click="handleDelete(s.row)" v-if="s.row.status==='draft'">删除</el-button>
</template>
@@ -126,16 +121,8 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="关联询价单">
<el-select v-model="form.rfqId" placeholder="选择关联RFQ(可选)" filterable clearable style="width:100%" @change="onRfqSelect">
<el-option v-for="r in rfqOptions" :key="r.rfqId"
:label="r.rfqNo + ' · ' + r.rfqTitle" :value="r.rfqId">
<div style="display:flex;justify-content:space-between">
<span style="font-weight:600">{{ r.rfqNo }}</span>
<span style="color:#909399;font-size:12px;margin-left:8px">{{ r.rfqTitle }}</span>
</div>
</el-option>
</el-select>
<el-form-item label=" ">
<span style="color:#909399;font-size:12px">RFQ 通过生成RFQ按钮创建自动关联此报价单</span>
</el-form-item>
</el-col>
</el-row>
@@ -300,7 +287,10 @@
</el-descriptions-item>
<el-descriptions-item label="币种">{{ detailData.currency || 'CNY' }}</el-descriptions-item>
<el-descriptions-item label="有效期">{{ detailData.validityDate | dateFmt }}</el-descriptions-item>
<el-descriptions-item label="关联询价">{{ detailData.rfqNo || '-' }}</el-descriptions-item>
<el-descriptions-item label="RFQ数量">
<span v-if="detailRfqList.length > 0" style="color:#409eff;font-weight:600">{{ detailRfqList.length }} </span>
<span v-else style="color:#c0c4cc">-</span>
</el-descriptions-item>
<el-descriptions-item label="总金额" :span="3">
<strong style="color:#409EFF;font-size:18px">¥{{ detailData.totalAmount | money }}</strong>
</el-descriptions-item>
@@ -326,6 +316,33 @@
</el-table-column>
<el-table-column label="交期(天)" prop="deliveryDays" width="80" align="center" />
</el-table>
<!-- 关联的RFQ列表 -->
<div style="margin-top:20px">
<div class="section-title" style="margin-bottom:12px">
已生成的采购计划RFQ
<el-button size="mini" type="success" icon="el-icon-s-promotion" style="margin-left:12px"
@click="handleCreateRfq(detailData)">生成RFQ</el-button>
</div>
<el-table :data="detailRfqList" v-loading="detailRfqLoading" border size="small">
<el-table-column label="RFQ编号" prop="rfqNo" width="150" />
<el-table-column label="标题" prop="rfqTitle" min-width="160" show-overflow-tooltip />
<el-table-column label="状态" width="90" align="center">
<template slot-scope="s">
<el-tag :type="rfqStatusType(s.row.status)" size="small">{{ rfqStatusLabel(s.row.status) }}</el-tag>
</template>
</el-table-column>
<el-table-column label="创建时间" prop="createTime" width="160" align="center" />
<el-table-column label="操作" width="80" align="center">
<template slot-scope="s">
<el-button type="text" size="small" @click="viewRfqDetail(s.row)">查看</el-button>
</template>
</el-table-column>
</el-table>
<div v-if="!detailRfqLoading && detailRfqList.length === 0" style="text-align:center;padding:16px;color:#c0c4cc;font-size:13px">
暂未生成采购计划点击上方生成RFQ按钮创建
</div>
</div>
</div>
<div slot="footer">
<el-button @click="detailOpen = false">关闭</el-button>
@@ -339,7 +356,7 @@
<script>
import { listClientQuote, getClientQuote, addClientQuote, updateClientQuote, delClientQuote,
getClientQuoteStatistics, quickCreateFromQuote } from "@/api/bid/clientquote";
import { listRfq } from "@/api/bid/rfq";
import { listRfq, createRfqFromQuote } from "@/api/bid/rfq";
import { listMaterial } from "@/api/bid/material";
export default {
@@ -365,7 +382,6 @@ export default {
dialogOpen: false,
dialogTitle: "",
saving: false,
rfqOptions: [],
materialCache: [],
form: { items: [], currency: "CNY", status: "draft" },
rules: {
@@ -373,7 +389,9 @@ export default {
},
// 详情
detailOpen: false,
detailData: null
detailData: null,
detailRfqList: [],
detailRfqLoading: false
};
},
computed: {
@@ -384,7 +402,6 @@ export default {
created() {
this.getList();
this.getStats();
listRfq({ pageSize: 200 }).then(r => { this.rfqOptions = r.rows || []; });
},
methods: {
// ===== 列表 =====
@@ -418,7 +435,7 @@ export default {
// ===== 新建 =====
handleAdd() {
this.form = { items: [], currency: "CNY", status: "draft", clientName: "", rfqId: null, validityDate: "", remark: "" };
this.form = { items: [], currency: "CNY", status: "draft", clientName: "", validityDate: "", remark: "" };
this.dialogTitle = "新建甲方报价单";
this.dialogOpen = true;
},
@@ -430,9 +447,6 @@ export default {
this.form = {
quoteId: data.quoteId,
clientName: data.clientName,
rfqId: data.rfqId,
rfqNo: data.rfqNo,
rfqTitle: data.rfqTitle,
status: data.status,
validityDate: data.validityDate,
currency: data.currency,
@@ -465,6 +479,7 @@ export default {
this.detailData = r.data || {};
if (!this.detailData.items) this.detailData.items = [];
this.detailOpen = true;
this.loadRfqForDetail(row.quoteId);
});
},
editFromDetail() {
@@ -491,9 +506,6 @@ export default {
this.form = {
quoteId: res.data.quoteId,
clientName: res.data.clientName,
rfqId: res.data.rfqId,
rfqNo: res.data.rfqNo,
rfqTitle: res.data.rfqTitle,
status: res.data.status,
validityDate: res.data.validityDate,
currency: res.data.currency,
@@ -506,17 +518,37 @@ export default {
}).catch(() => {});
},
// ===== 生成RFQ =====
handleCreateRfq(row) {
this.$modal.confirm("确认基于报价单【" + row.quoteNo + "】生成采购询价RFQ").then(() => {
return createRfqFromQuote(row.quoteId);
}).then(res => {
this.detailOpen = false;
this.$modal.msgSuccess("RFQ已创建");
this.$router.push({ path: '/bid/rfq', query: { rfqId: res.data.rfqId, rfqNo: res.data.rfqNo, action: 'edit' } });
}).catch(() => {});
},
// ===== 删除 =====
handleDelete(row) {
this.$modal.confirm("确认删除报价单【" + row.quoteNo + "】?").then(() => delClientQuote(row.quoteId))
.then(() => { this.$modal.msgSuccess("删除成功"); this.getList(); this.getStats(); });
},
// ===== RFQ选择 =====
onRfqSelect(rfqId) {
const rfq = this.rfqOptions.find(r => r.rfqId === rfqId);
if (rfq) { this.form.rfqNo = rfq.rfqNo; this.form.rfqTitle = rfq.rfqTitle; }
// ===== RFQ列表(详情弹窗中展示) =====
loadRfqForDetail(quoteId) {
this.detailRfqLoading = true;
listRfq({ clientQuoteId: quoteId, pageSize: 50 }).then(r => {
this.detailRfqList = r.rows || [];
this.detailRfqLoading = false;
}).catch(() => { this.detailRfqLoading = false; });
},
viewRfqDetail(rfq) {
this.detailOpen = false;
this.$router.push({ path: '/bid/rfq', query: { rfqId: rfq.rfqId, rfqNo: rfq.rfqNo, action: 'edit' } });
},
rfqStatusType(s) { return { draft:"info", published:"warning", closed:"", completed:"success" }[s] || ""; },
rfqStatusLabel(s) { return { draft:"草稿", published:"已发布", closed:"已关闭", completed:"已完成" }[s] || s; },
// ===== 物料搜索 =====
queryMaterialSearch(query, cb) {

View File

@@ -77,7 +77,7 @@ export default {
this.$router.push({ path: "/bid/comparison/detail", query: { rfqId: row.rfqId } });
},
goRfqDetail(row) {
this.$router.push({ path: "/procurement/rfq/detail", query: { rfqId: row.rfqId } });
this.$router.push({ path: '/bid/rfq', query: { rfqId: row.rfqId, rfqNo: row.rfqNo, action: 'edit' } });
},
statusType(s) {
const m = { draft: "info", open: "primary", closed: "success", cancelled: "danger" };

View File

@@ -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;

View File

@@ -27,9 +27,20 @@
</el-col>
</el-row>
<el-table v-loading="loading" :data="list">
<el-table v-loading="loading" :data="list" border stripe>
<el-table-column label="RFQ编号" prop="rfqNo" width="150" />
<el-table-column label="标题" prop="rfqTitle" :show-overflow-tooltip="true" />
<el-table-column label="标题" prop="rfqTitle" min-width="160" show-overflow-tooltip />
<el-table-column label="关联甲方报价" width="180">
<template slot-scope="scope">
<div v-if="scope.row.clientQuoteNo">
<el-tag size="small" type="info" style="cursor:pointer" @click="viewClientQuote(scope.row)">
{{ scope.row.clientQuoteNo }}
</el-tag>
<div style="font-size:12px;color:#909399;margin-top:2px">{{ scope.row.clientName || '' }}</div>
</div>
<span v-else style="color:#c0c4cc">-</span>
</template>
</el-table-column>
<el-table-column label="截止日期" prop="deadline" width="160" />
<el-table-column label="状态" width="100">
<template slot-scope="scope">
@@ -37,7 +48,7 @@
</template>
</el-table-column>
<el-table-column label="创建时间" prop="createTime" width="160" />
<el-table-column label="操作" align="center" width="200">
<el-table-column label="操作" align="center" width="200" fixed="right">
<template slot-scope="scope">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-if="scope.row.status==='draft'">编辑</el-button>
<el-button size="mini" type="text" icon="el-icon-s-promotion" @click="handlePublish(scope.row)" v-if="scope.row.status==='draft'">发布</el-button>
@@ -50,7 +61,7 @@
<!-- Create/Edit Dialog -->
<el-dialog :title="title" :visible.sync="open" width="900px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form ref="form" :model="form" :rules="rules" label-width="110px">
<el-row>
<el-col :span="12">
<el-form-item label="RFQ标题" prop="rfqTitle">
@@ -63,9 +74,22 @@
</el-form-item>
</el-col>
</el-row>
<el-form-item label="交货地址" prop="deliveryAddr">
<el-input v-model="form.deliveryAddr" placeholder="请输入交货地址" />
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="关联甲方报价">
<el-select v-model="form.clientQuoteId" placeholder="选择甲方报价(可选)" filterable clearable style="width:100%"
@change="onClientQuoteSelect">
<el-option v-for="q in clientQuoteOptions" :key="q.quoteId"
:label="q.quoteNo + ' - ' + q.clientName" :value="q.quoteId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="交货地址" prop="deliveryAddr">
<el-input v-model="form.deliveryAddr" placeholder="请输入交货地址" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">物料明细</el-divider>
<el-table :data="form.items || []" border size="small">
@@ -94,6 +118,11 @@
<el-input-number v-model="scope.row.expectedPrice" :min="0" :precision="2" size="small" style="width:110px" />
</template>
</el-table-column>
<el-table-column label="参考来源" width="100">
<template slot-scope="scope">
<span v-if="scope.row._fromClient" style="color:#409eff;font-size:12px">甲方报价</span>
</template>
</el-table-column>
<el-table-column label="操作" width="60" align="center">
<template slot-scope="scope">
<el-button type="text" icon="el-icon-delete" @click="removeItem(scope.$index)" style="color:#f56c6c" />
@@ -127,8 +156,10 @@
</template>
<script>
import { listRfq, getRfq, addRfq, updateRfq, publishRfq, delRfq } from "@/api/bid/rfq";
import { listRfq, getRfq, addRfq, updateRfq, publishRfq, delRfq, getClientQuoteOptions, createRfqFromQuote } from "@/api/bid/rfq";
import { listSupplier } from "@/api/bid/supplier";
import { getClientQuote } from "@/api/bid/clientquote";
export default {
name: "Rfq",
data() {
@@ -136,12 +167,30 @@ export default {
loading: false, total: 0, list: [],
open: false, title: "",
publishOpen: false, publishRfqId: null, selectedSuppliers: [], supplierOptions: [],
clientQuoteOptions: [],
queryParams: { pageNum: 1, pageSize: 10, rfqNo: null, rfqTitle: null, status: null },
form: { items: [] },
rules: { rfqTitle: [{ required: true, message: "标题不能为空", trigger: "blur" }] }
};
},
created() { this.getList(); this.loadSuppliers(); },
created() {
this.getList();
this.loadSuppliers();
this.loadClientQuoteOptions();
// 接收外部传入参数生成RFQ后自动打开编辑弹窗
this.$nextTick(() => {
const rfqId = this.$route.query.rfqId;
const rfqNo = this.$route.query.rfqNo;
const action = this.$route.query.action;
if (rfqNo) {
this.queryParams.rfqNo = rfqNo;
this.handleQuery();
}
if (rfqId && action === 'edit') {
this.handleUpdate({ rfqId: Number(rfqId) });
}
});
},
methods: {
getList() {
this.loading = true;
@@ -150,16 +199,23 @@ export default {
loadSuppliers() {
listSupplier({ pageSize: 100 }).then(r => { this.supplierOptions = r.rows || []; });
},
loadClientQuoteOptions() {
getClientQuoteOptions().then(r => { this.clientQuoteOptions = r.data || []; });
},
handleQuery() { this.queryParams.pageNum = 1; this.getList(); },
resetQuery() { this.resetForm("queryForm"); this.handleQuery(); },
handleAdd() {
this.form = { items: [], status: "draft" };
this.form = { items: [], status: "draft", clientQuoteId: null };
this.open = true; this.title = "新建报价请求";
},
handleUpdate(row) {
getRfq(row.rfqId).then(r => { this.form = r.data; this.open = true; this.title = "编辑报价请求"; });
getRfq(row.rfqId).then(r => {
this.form = r.data || {};
if (!this.form.items) this.form.items = [];
this.open = true; this.title = "编辑报价请求";
});
},
handleView(row) { this.$router.push({ path: "/procurement/rfq/detail", query: { rfqId: row.rfqId } }); },
handleView(row) { this.handleUpdate(row); },
handlePublish(row) { this.publishRfqId = row.rfqId; this.selectedSuppliers = []; this.publishOpen = true; },
doPublish() {
publishRfq(this.publishRfqId, this.selectedSuppliers).then(() => {
@@ -178,6 +234,35 @@ export default {
action(this.form).then(() => { this.$modal.msgSuccess("保存成功"); this.open = false; this.getList(); });
});
},
/** 选中甲方报价后自动填充物料 */
onClientQuoteSelect(quoteId) {
if (!quoteId) return;
getClientQuote(quoteId).then(r => {
const quote = r.data || {};
const items = (quote.items || []).map(item => ({
materialId: item.materialId,
materialName: item.materialName,
spec: item.spec || item.modelNo || '',
unit: item.unit || '件',
quantity: item.quantity || 1,
expectedPrice: item.unitPrice || null,
_fromClient: true
}));
if (items.length > 0) {
this.form.items = items;
if (!this.form.rfqTitle) {
this.form.rfqTitle = "采购需求: " + (quote.clientName || '') + " - " + (quote.quoteNo || '');
}
this.$message.success(`已加载 ${items.length} 项物料`);
}
});
},
/** 查看关联的甲方报价 */
viewClientQuote(row) {
if (row.clientQuoteId) {
this.$router.push({ path: '/quotemgr/clientquote/detail', query: { quoteId: row.clientQuoteId } });
}
},
statusType(s) { return { draft:"info", published:"warning", closed:"", completed:"success" }[s] || ""; },
statusLabel(s) { return { draft:"草稿", published:"已发布", closed:"已关闭", completed:"已完成" }[s] || s; }
}