feat(crmQuoteInfo): 集成审批功能并优化报价单管理

- 在报价单编辑页集成审批按钮、审批记录和提交验证组件
- 支持提交报价单同时发起审批流程,新增接口quoteSubmitAndFlowStart
- 将付款方式改为下拉选择,使用字典数据payment_method
- 供货方联系人选择改用supplierList,并调整事件处理逻辑
- 报价物料管理增加标准物料标识materialFlag,优化相关字段命名展示
- 报价明细表格隐藏技术ID,展示物料编号与名称字段
- 列表页调整部分列的显示与字段对应,实现更直观显示
- 实现查看详情权限控制,仅非草稿状态允许查看
- 统一处理流程状态字典,支持审批模式禁用表单输入
- 优化导出模板功能,修复文件保存逻辑中的类型兼容问题
- 代码结构及命名优化,重构部分回调函数及表单数据初始化逻辑
dev
zangch@mesnac.com 3 weeks ago
parent ce3d79cd86
commit ceb1b5273b

@ -1,6 +1,6 @@
import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CrmQuoteInfoVO, CrmQuoteInfoForm, CrmQuoteInfoQuery } from '@/api/oa/crm/crmQuoteInfo/types';
import { CrmQuoteInfoForm, CrmQuoteInfoQuery, CrmQuoteInfoVO } from '@/api/oa/crm/crmQuoteInfo/types';
/**
*
@ -67,13 +67,13 @@ export const delCrmQuoteInfo = (quoteId: string | number | Array<string | number
* @param query
* @returns {*}
*/
export function getCrmQuoteInfoList (query) {
return request({
url: '/oa/crm/crmQuoteInfo/getCrmQuoteInfoList',
method: 'get',
params: query
});
};
export function getCrmQuoteInfoList(query) {
return request({
url: '/oa/crm/crmQuoteInfo/getCrmQuoteInfoList',
method: 'get',
params: query
});
}
/**
*
@ -109,14 +109,14 @@ export const exportQuoteTemplate = (quoteId: string | number) => {
});
};
//
// /**
// * 测试用
// */
// export const exportQuoteTemplate = (quoteId: string | number) => {
// return request({
// url: '/oa/crm/crmQuoteInfo/testExport' ,
// method: 'get',
// responseType: 'blob'
// });
// };
/**
*
* @param data
*/
export const quoteSubmitAndFlowStart = (data: CrmQuoteInfoForm): AxiosPromise<CrmQuoteInfoVO> => {
return request({
url: '/oa/crm/crmQuoteInfo/quoteSubmitAndFlowStart',
method: 'post',
data: data
});
};

@ -14,6 +14,11 @@ export interface CrmQuoteMaterialVO {
*/
itemNo: number;
/**
* 1 2
*/
materialFlag: string;
/**
* /
*/
@ -34,6 +39,21 @@ export interface CrmQuoteMaterialVO {
*/
relationMaterialId: string | number;
/**
* SAP
*/
materialCode: string;
/**
* SAP
*/
materialName: string;
/**
*
*/
saleMaterialName: string;
/**
*
*/
@ -97,6 +117,11 @@ export interface CrmQuoteMaterialForm extends BaseEntity {
*/
itemNo?: number;
/**
* 1 2
*/
materialFlag?: string;
/**
* /
*/
@ -117,6 +142,21 @@ export interface CrmQuoteMaterialForm extends BaseEntity {
*/
relationMaterialId?: string | number;
/**
* SAP
*/
materialCode?: string;
/**
* SAP
*/
materialName?: string;
/**
*
*/
saleMaterialName?: string;
/**
*
*/
@ -166,6 +206,11 @@ export interface CrmQuoteMaterialForm extends BaseEntity {
export interface CrmQuoteMaterialQuery extends PageQuery {
/**
* 1 2
*/
materialFlag?: string;
/**
* ID
*/

@ -1,5 +1,17 @@
<template>
<div class="p-2">
<el-card shadow="never">
<approvalButton
@submitForm="submitForm"
@approvalVerifyOpen="approvalVerifyOpen"
@handleApprovalRecord="handleApprovalRecord"
:buttonLoading="buttonLoading"
:id="form.quoteId as any"
:status="approvalStatus"
:pageType="pageTypeForButton"
:mode="false"
/>
</el-card>
<el-card shadow="never">
<!-- 统一表单包裹所有分区便于整体验证 -->
<el-form ref="quoteFormRef" :model="form" :rules="rules" label-width="120px" :disabled="isView">
@ -72,7 +84,9 @@
</el-col>
<el-col :span="12">
<el-form-item label="付款方式" prop="paymentMethod">
<el-input v-model="form.paymentMethod" placeholder="请输入付款方式" />
<el-select v-model="form.paymentMethod" placeholder="请选择付款方式">
<el-option v-for="dict in payment_method" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
@ -98,7 +112,12 @@
<el-col :span="12" v-if="false">
<el-form-item label="客户联系人" prop="customerContactId">
<el-select v-model="form.customerContactId" filterable placeholder="请选择客户联系人" @change="onCustomerContactChanged">
<el-option v-for="c in customerContactList" :key="c.contactId" :label="c.contactName + ' - ' + (c.phoneNumber||'')" :value="c.contactId" />
<el-option
v-for="c in customerContactList"
:key="c.contactId"
:label="c.contactName + ' - ' + (c.phoneNumber || '')"
:value="c.contactId"
/>
</el-select>
</el-form-item>
<!-- 客户方联系电话与邮箱随选择带出可编辑 -->
@ -112,8 +131,8 @@
<!-- 原供货方信息块已迁移到供货方信息分区保留以便后续恢复 -->
<el-col :span="12" v-if="false">
<el-form-item label="供货方联系人" prop="supplierContactId">
<el-select v-model="form.supplierContactId" filterable placeholder="请选择供货方联系人" @change="onSupplierContactChanged">
<el-option v-for="c in supplierContactList" :key="c.contactId" :label="c.contactName + ' - ' + (c.phoneNumber||'')" :value="c.contactId" />
<el-select v-model="form.supplierContactId" filterable placeholder="请选择供货方联系人" @change="onSupplierChanged">
<el-option v-for="c in supplierList" :key="c.supplierId" :label="c.supplierName" :value="c.supplierId" />
</el-select>
</el-form-item>
<!-- 供货方联系电话与邮箱随选择带出可编辑 -->
@ -139,156 +158,196 @@
</el-form-item>
</el-col>
</el-row>
<!-- 报价物料编辑对话框 -->
<el-dialog :title="materialDialog.title" v-model="materialDialog.visible" width="800px" append-to-body>
<el-form ref="materialFormRef" :model="materialForm" :rules="materialRules" label-width="120px">
<!-- 报价物料编辑对话框 -->
<el-dialog :title="materialDialog.title" v-model="materialDialog.visible" width="800px" append-to-body>
<el-form ref="materialFormRef" :model="materialForm" :rules="materialRules" label-width="120px">
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="标准物料标识" prop="materialFlag">
<el-radio-group v-model="materialForm.materialFlag">
<el-radio v-for="dict in material_flag" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="materialForm.productName" placeholder="请输入产品名称">
<template #suffix>
<el-icon style="cursor: pointer" v-if="materialForm.materialFlag === '1'" @click="openSaleMaterialSelect">
<Search />
</el-icon>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格描述" prop="specificationDescription">
<el-input v-model="materialForm.specificationDescription" placeholder="请输入规格描述" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" prop="amount">
<el-input-number
v-model="materialForm.amount"
placeholder="请输入数量"
style="width: 100%"
@change="calculateSubtotal"
:precision="2"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料单位" prop="unitId">
<el-select v-model="materialForm.unitId" placeholder="请选择物料单位">
<el-option v-for="item in unitInfoList" :key="item.unitId" :label="item.unitName" :value="item.unitId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="税率(%)" prop="taxRate">
<el-input-number
v-model="materialForm.taxRate"
placeholder="请输入税率"
style="width: 100%"
@change="calculateBeforePrice"
:precision="2"
:min="0"
:max="100"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="未税单价" prop="beforePrice">
<el-input-number
v-model="materialForm.beforePrice"
placeholder="自动计算"
style="width: 100%"
:precision="2"
:controls="false"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="含税单价" prop="includingPrice">
<el-input-number
v-model="materialForm.includingPrice"
placeholder="请输入含税单价"
style="width: 100%"
:precision="2"
@change="calculateBeforePrice"
/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="小计" prop="subtotal">
<el-input-number
v-model="materialForm.subtotal"
placeholder="自动计算"
style="width: 100%"
readonly
:precision="2"
:controls="false"
disabled
/>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="materialForm.remark" type="textarea" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitMaterialForm"> </el-button>
<el-button @click="cancelMaterial"> </el-button>
</div>
</template>
</el-dialog>
<!-- 销售物料选择 -->
<SaleMaterialSelect ref="saleMaterialSelectRef" :multiple="false" @confirm-call-back="saleMaterialSelectCallBack" />
<!-- 对齐合同编辑页单卡片内分区展示 -->
<el-divider content-position="left">客户方信息</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划标识" prop="planFlag">
<el-radio-group v-model="materialForm.planFlag">
<el-radio v-for="dict in plan_flag" :key="dict.value" :value="dict.value">{{ dict.label }}</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="产品名称" prop="productName">
<el-input v-model="materialForm.productName" placeholder="请输入产品名称">
<template #suffix>
<el-icon style="cursor: pointer" v-if="materialForm.planFlag === '1'" @click="openSaleMaterialSelect">
<Search />
</el-icon>
</template>
</el-input>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="规格描述" prop="specificationDescription">
<el-input v-model="materialForm.specificationDescription" placeholder="请输入规格描述" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="数量" prop="amount">
<el-input-number v-model="materialForm.amount" placeholder="请输入数量" style="width: 100%" @change="calculateSubtotal" :precision="2" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="物料单位" prop="unitId">
<el-select v-model="materialForm.unitId" placeholder="请选择物料单位">
<el-option v-for="item in unitInfoList" :key="item.unitId" :label="item.unitName" :value="item.unitId" />
<el-form-item label="客户联系人" prop="customerContactId">
<el-select v-model="form.customerContactId" filterable placeholder="请选择客户联系人" @change="onCustomerContactChanged">
<el-option
v-for="c in customerContactList"
:key="c.contactId"
:label="c.contactName + ' - ' + (c.phoneNumber || '')"
:value="c.contactId"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="税率(%)" prop="taxRate">
<el-input-number v-model="materialForm.taxRate" placeholder="请输入税率" style="width: 100%" @change="calculateBeforePrice" :precision="2" :min="0" :max="100" />
<el-form-item label="客户联系电话" prop="customerContactPhone">
<el-input v-model="form.customerContactPhone" placeholder="客户联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="未税单价" prop="beforePrice">
<el-input-number v-model="materialForm.beforePrice" placeholder="自动计算" style="width: 100%" :precision="2" :controls="false" disabled />
<el-form-item label="客户邮箱" prop="customerContactEmail">
<el-input v-model="form.customerContactEmail" placeholder="客户邮箱" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">供货方信息</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划标识" prop="supplierPlanFlag">
<el-radio-group v-model="supplierPlanFlag" @change="onSupplierPlanFlagChanged">
<el-radio value="1">计划内</el-radio>
<el-radio value="2">计划外</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" v-if="supplierPlanFlag === '1'">
<el-form-item label="供应商" prop="supplierContactId">
<el-select v-model="form.supplierContactId" filterable placeholder="请选择供应商" @change="onSupplierChanged">
<el-option v-for="s in supplierList" :key="s.supplierId" :label="s.supplierName" :value="s.supplierId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="含税单价" prop="includingPrice">
<el-input-number v-model="materialForm.includingPrice" placeholder="请输入含税单价" style="width: 100%" :precision="2" @change="calculateBeforePrice" />
<el-form-item label="供货方联系人" prop="supplierContactName">
<el-input v-model="form.supplierContactName" placeholder="供货方联系人" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="小计" prop="subtotal">
<el-input-number v-model="materialForm.subtotal" placeholder="自动计算" style="width: 100%" readonly :precision="2" :controls="false" disabled />
<el-form-item label="供货方联系电话" prop="supplierContactPhone">
<el-input v-model="form.supplierContactPhone" placeholder="供货方联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供货方邮箱" prop="supplierContactEmail">
<el-input v-model="form.supplierContactEmail" placeholder="供货方邮箱" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">附件与备注</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="附件">
<el-button type="primary" plain icon="Upload" @click="handleFile" :disabled="isView">上传附件</el-button>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="materialForm.remark" type="textarea" placeholder="请输入备注" />
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button type="primary" @click="submitMaterialForm"> </el-button>
<el-button @click="cancelMaterial"> </el-button>
</div>
</template>
</el-dialog>
<!-- 销售物料选择 -->
<SaleMaterialSelect ref="saleMaterialSelectRef" :multiple="false" @confirm-call-back="saleMaterialSelectCallBack" />
<!-- 对齐合同编辑页单卡片内分区展示 -->
<el-divider content-position="left">客户方信息</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="客户联系人" prop="customerContactId">
<el-select v-model="form.customerContactId" filterable placeholder="请选择客户联系人" @change="onCustomerContactChanged">
<el-option v-for="c in customerContactList" :key="c.contactId" :label="c.contactName + ' - ' + (c.phoneNumber||'')" :value="c.contactId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户联系电话" prop="customerContactPhone">
<el-input v-model="form.customerContactPhone" placeholder="客户联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="客户邮箱" prop="customerContactEmail">
<el-input v-model="form.customerContactEmail" placeholder="客户邮箱" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">供货方信息</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="计划标识" prop="supplierPlanFlag">
<el-radio-group v-model="supplierPlanFlag" @change="onSupplierPlanFlagChanged">
<el-radio value="1">计划内</el-radio>
<el-radio value="2">计划外</el-radio>
</el-radio-group>
</el-form-item>
</el-col>
<el-col :span="12" v-if="supplierPlanFlag === '1'">
<el-form-item label="供应商" prop="supplierContactId">
<el-select v-model="form.supplierContactId" filterable placeholder="请选择供应商" @change="onSupplierChanged">
<el-option v-for="s in supplierList" :key="s.supplierId" :label="s.supplierName" :value="s.supplierId" />
</el-select>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供货方联系人" prop="supplierContactName">
<el-input v-model="form.supplierContactName" placeholder="供货方联系人" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供货方联系电话" prop="supplierContactPhone">
<el-input v-model="form.supplierContactPhone" placeholder="供货方联系电话" />
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="供货方邮箱" prop="supplierContactEmail">
<el-input v-model="form.supplierContactEmail" placeholder="供货方邮箱" />
</el-form-item>
</el-col>
</el-row>
<el-divider content-position="left">附件与备注</el-divider>
<el-row :gutter="20">
<el-col :span="12">
<el-form-item label="附件">
<el-button type="primary" plain icon="Upload" @click="handleFile" :disabled="isView">上传附件</el-button>
</el-form-item>
</el-col>
</el-row>
<el-row :gutter="20">
<el-col :span="24">
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
</el-form>
<!-- 报价物料管理 -->
<!-- 报价物料管理仅展示业务字段不展示技术ID -->
<el-divider content-position="left">报价明细</el-divider>
<el-row :gutter="10" class="mb-3" v-if="!isView">
<el-col :span="1.5">
@ -298,14 +357,15 @@
<el-table :data="materialRows" border show-summary :summary-method="getSummary">
<el-table-column label="产品名称" align="center" prop="productName" min-width="160" />
<el-table-column label="规格描述" align="center" prop="specificationDescription" min-width="160" />
<el-table-column label="物料ID" align="center" prop="materialId" width="120" />
<el-table-column label="销售物料ID" align="center" prop="relationMaterialId" width="140" />
<el-table-column label="物料编号" align="center" prop="materialCode" width="140" />
<el-table-column label="物料名称" align="center" prop="materialName" width="160" />
<el-table-column label="销售物料名称" align="center" prop="saleMaterialName" width="160" />
<el-table-column label="数量" align="center" prop="amount" width="120">
<template #default="scope">
{{ scope.row.amount ? Number(scope.row.amount).toFixed(2) : '0.00' }}
</template>
</el-table-column>
<el-table-column label="单位ID" align="center" prop="unitId" width="120" />
<el-table-column label="单位" align="center" prop="unitName" width="120" />
<el-table-column label="未税单价" align="center" prop="beforePrice" width="140">
<template #default="scope">
{{ scope.row.beforePrice ? Number(scope.row.beforePrice).toFixed(2) : '0.00' }}
@ -336,11 +396,13 @@
</el-table>
<div style="margin-top: 16px; padding-top: 12px; border-top: 1px solid #ebeef5; text-align: right">
<span style="margin-right: 20px; font-weight: bold; font-size: 14px">含税总价<span style="color: #f56c6c">{{ totalIncludingTax.toFixed(2) }}</span></span>
<el-button v-if="!isView" type="primary" :loading="buttonLoading" @click="submitForm"> </el-button>
<el-button @click="goBack"> </el-button>
<span style="margin-right: 20px; font-weight: bold; font-size: 14px">
含税总价<span style="color: #f56c6c">{{ totalIncludingTax.toFixed(2) }}</span>
</span>
</div>
</el-card>
<ApprovalRecord ref="approvalRecordRef" />
<SubmitVerify ref="submitVerifyRef" @submit-callback="submitCallback" />
<!-- 附件上传对话框 -->
<el-dialog v-model="dialog.visible" :title="dialog.title" width="500px" append-to-body>
<el-form label-width="80px">
@ -357,11 +419,12 @@
</template>
</el-dialog>
</div>

</template>
<script setup lang="ts">
import { useRoute, useRouter } from 'vue-router';
import { getCrmQuoteInfo, addCrmQuoteInfo, updateCrmQuoteInfo, recalcQuoteTotals } from '@/api/oa/crm/crmQuoteInfo';
import { addCrmQuoteInfo, getCrmQuoteInfo, quoteSubmitAndFlowStart, updateCrmQuoteInfo } from '@/api/oa/crm/crmQuoteInfo';
import { CrmQuoteInfoForm } from '@/api/oa/crm/crmQuoteInfo/types';
import type { CrmQuoteMaterialForm } from '@/api/oa/crm/crmQuoteMaterial/types';
import { getBaseMaterialInfoList } from '@/api/oa/base/materialInfo';
@ -370,15 +433,21 @@ import { getCrmSupplierInfoList } from '@/api/oa/crm/crmSupplierInfo';
import { getRuleGenerateCode } from '@/api/system/codeRule';
import { getBaseUnitInfoList } from '@/api/oa/base/unitInfo';
import SaleMaterialSelect from '@/components/SaleMaterialSelect/index.vue';
import ApprovalButton from '@/components/Process/approvalButton.vue';
import ApprovalRecord from '@/components/Process/approvalRecord.vue';
import SubmitVerify from '@/components/Process/submitVerify.vue';
import { FlowCodeEnum } from '@/enums/OAEnum';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { business_direction, currency_type, quote_category, contract_type, plan_flag } = toRefs<any>(proxy?.useDict('business_direction', 'currency_type', 'quote_category', 'contract_type', 'plan_flag'));
const { business_direction, currency_type, quote_category, contract_type, material_flag, wf_business_status, payment_method } = toRefs<any>(
proxy?.useDict('business_direction', 'currency_type', 'quote_category', 'contract_type', 'material_flag', 'wf_business_status', 'payment_method')
);
const router = useRouter();
const route = useRoute();
// type=view
const isView = computed(() => route.query.type === 'view');
// /type
const isView = computed(() => route.query.type === 'view' || route.query.type === 'approval');
const buttonLoading = ref(false);
const quoteFormRef = ref<ElFormInstance>();
@ -431,17 +500,44 @@ const getUnitInfoListSelect = async () => {
unitInfoList.value = res.data || [];
};
const approvalRecordRef = ref<InstanceType<typeof ApprovalRecord>>();
const submitVerifyRef = ref<InstanceType<typeof SubmitVerify>>();
const normalizeFlowStatus = (status?: string) => {
if (!status) return 'draft';
const dictList = wf_business_status.value || [];
const match = dictList.find((item: any) => item?.value === status || item?.label === status);
return match?.value || status;
};
const approvalStatus = computed(() => normalizeFlowStatus((form as any).flowStatus as any));
const pageTypeForButton = computed(() => {
const taskId = route.query.taskId as any;
const type = route.query.type as string | undefined;
if (taskId) {
return 'approval';
}
if (type) {
return type;
}
return (form.quoteId ? 'update' : 'add') as string;
});
//
const materialDialog = reactive({ visible: false, title: '' });
const materialFormRef = ref<ElFormInstance>();
const initMaterialFormData: CrmQuoteMaterialForm & { planFlag?: string } = {
const initMaterialFormData: CrmQuoteMaterialForm & { materialFlag?: string } = {
quoteMaterialId: undefined,
planFlag: '2', // 12
materialFlag: '2', // 1 2
quoteId: undefined,
productName: undefined,
specificationDescription: undefined,
materialId: undefined,
relationMaterialId: undefined,
materialCode: undefined,
materialName: undefined,
saleMaterialName: undefined,
amount: undefined,
unitId: undefined,
unitName: undefined,
@ -452,7 +548,7 @@ const initMaterialFormData: CrmQuoteMaterialForm & { planFlag?: string } = {
remark: undefined,
activeFlag: '1'
};
const materialForm = ref<CrmQuoteMaterialForm & { planFlag?: string }>({ ...initMaterialFormData });
const materialForm = ref<CrmQuoteMaterialForm & { materialFlag?: string }>({ ...initMaterialFormData });
const materialRules = {
productName: [{ required: true, message: '产品名称不能为空', trigger: 'blur' }],
amount: [{ required: true, message: '数量不能为空', trigger: 'blur' }],
@ -466,8 +562,13 @@ const saleMaterialSelectCallBack = (data: any) => {
const m = list[0];
materialForm.value.materialId = m.materialId;
materialForm.value.relationMaterialId = m.relationMaterialId;
materialForm.value.materialCode = m.materialCode;
materialForm.value.materialName = m.materialName;
materialForm.value.saleMaterialName = m.saleMaterialName;
materialForm.value.productName = m.saleMaterialName || m.materialName;
if (m.unitName) materialForm.value.unitName = m.unitName;
if (m.unitName) {
materialForm.value.unitName = m.unitName;
}
}
};
const resetMaterialForm = () => {
@ -502,9 +603,11 @@ const handleAddMaterial = () => {
materialDialog.visible = true;
materialDialog.title = '新增报价物料';
};
const handleEditMaterial = (row: CrmQuoteMaterialForm) => {
const handleEditMaterial = (row: CrmQuoteMaterialForm & { materialFlag?: string }) => {
resetMaterialForm();
materialForm.value = { ...(row as any), planFlag: (row as any).materialId ? '1' : '2' };
// 使 materialFlagID/
const flag = (row as any).materialFlag ?? ((row as any).materialId ? '1' : '2');
materialForm.value = { ...(row as any), materialFlag: flag };
materialDialog.visible = true;
materialDialog.title = '编辑报价物料';
};
@ -536,7 +639,7 @@ const submitMaterialForm = () => {
//
const materialRows = ref<CrmQuoteMaterialForm[]>([]);
const totalIncludingTax = computed(() => {
return materialRows.value.reduce((sum, r) => sum + (Number(r.subtotal || 0)), 0);
return materialRows.value.reduce((sum, r) => sum + Number(r.subtotal || 0), 0);
});
//
const getSummary = (param: any) => {
@ -561,6 +664,9 @@ const addMaterialRow = () => {
//
materialRows.value.push({
materialId: undefined,
materialCode: '',
materialName: '',
saleMaterialName: '',
unitId: undefined,
unitName: '',
productName: '',
@ -575,12 +681,12 @@ const addMaterialRow = () => {
};
const removeRow = (idx: number) => materialRows.value.splice(idx, 1);
//
const toNum = (v: any) => (v === '' || v === null || v === undefined) ? undefined : (Number.isFinite(Number(v)) ? Number(v) : undefined);
const toNum = (v: any) => (v === '' || v === null || v === undefined ? undefined : Number.isFinite(Number(v)) ? Number(v) : undefined);
const round2 = (n: number) => Math.round(n * 100) / 100;
//
const calcIncluding = (before: number, rate: number) => round2(before * (1 + rate / 100));
const calcBefore = (including: number, rate: number) => round2(including / (1 + rate / 100));
const calcRate = (including: number, before: number) => round2(((including / before) - 1) * 100);
const calcRate = (including: number, before: number) => round2((including / before - 1) * 100);
// ×+
const updateSubtotal = (row: any) => {
const amount = toNum(row.amount) ?? 0;
@ -592,7 +698,7 @@ const updateSubtotal = (row: any) => {
inc = calcIncluding(before, rate);
row.includingPrice = inc; //
}
row.subtotal = (inc !== undefined) ? round2((inc as number) * amount) : 0;
row.subtotal = inc !== undefined ? round2((inc as number) * amount) : 0;
};
//
const onAmountChange = (row: any, val: number) => {
@ -697,13 +803,11 @@ const submitOss = () => {
const cancel = () => {
dialog.visible = false;
};
const submitForm = () => {
const submitForm = (status: string, mode: boolean) => {
quoteFormRef.value?.validate(async (valid: boolean) => {
if (!valid) return;
buttonLoading.value = true;
try {
// itemsBo
const payload: any = {
...form,
itemsBo: materialRows.value.map((r, idx) => ({
@ -712,20 +816,56 @@ const submitForm = () => {
subtotal: Number(r.subtotal || 0)
}))
};
if (!form.quoteId) {
await addCrmQuoteInfo(payload);
if (status === 'draft') {
payload.quoteStatus = '1';
payload.flowStatus = 'draft';
if (!form.quoteId) {
await addCrmQuoteInfo(payload);
} else {
await updateCrmQuoteInfo(payload);
}
proxy?.$modal.msgSuccess('暂存成功');
} else {
await updateCrmQuoteInfo(payload);
payload.flowCode = FlowCodeEnum.QUOTE_CODE; //OACQ
payload.variables = {
quoteId: form.quoteId,
quoteName: form.quoteName,
quoteCode: form.quoteCode,
totalPrice: totalIncludingTax.value
};
payload.bizExt = {
businessTitle: '报价单审批',
businessCode: form.quoteCode
};
payload.quoteStatus = '2';
payload.flowStatus = 'waiting';
const res = await quoteSubmitAndFlowStart(payload);
if (res?.data) {
Object.assign(form, res.data as any);
}
proxy?.$modal.msgSuccess('已提交并发起流程');
}
proxy?.$modal.msgSuccess('保存成功');
router.back();
proxy?.$tab.closePage(route as any);
router.go(-1);
} finally {
buttonLoading.value = false;
}
});
};
const approvalVerifyOpen = async () => {
await submitVerifyRef.value?.openDialog(route.query.taskId as any);
};
const goBack = () => router.back();
const handleApprovalRecord = () => {
if (form.quoteId) {
approvalRecordRef.value?.init(form.quoteId as any);
}
};
const submitCallback = async () => {
await proxy?.$tab.closePage(route as any);
router.go(-1);
};
onMounted(async () => {
//
@ -776,13 +916,16 @@ onMounted(async () => {
itemNo: r.itemNo,
materialId: r.materialId,
relationMaterialId: r.relationMaterialId,
materialCode: r.materialCode,
materialName: r.materialName,
saleMaterialName: r.saleMaterialName,
unitId: r.unitId,
unitName: r.unitName,
productName: r.productName,
specificationDescription: r.specificationDescription,
amount: Number(r.amount ?? 0),
beforePrice: Number(r.beforePrice ?? 0),
taxRate: Number(r.taxRate ?? (form.taxRate ?? 0)),
taxRate: Number(r.taxRate ?? form.taxRate ?? 0),
includingPrice: Number(r.includingPrice ?? 0),
subtotal: Number(r.subtotal ?? 0),
remark: r.remark

@ -3,17 +3,17 @@
<transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
<div v-show="showSearch" class="mb-[10px]">
<el-card shadow="hover">
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width='100px'>
<el-form ref="queryFormRef" :model="queryParams" :inline="true" label-width="100px">
<el-form-item label="报价单号" prop="quoteCode">
<el-input v-model="queryParams.quoteCode" placeholder="请输入报价单号" clearable @keyup.enter="handleQuery" />
</el-form-item>
<el-form-item label="报价单名称" prop="quoteName">
<el-input v-model="queryParams.quoteName" placeholder="请输入报价单名称" clearable @keyup.enter="handleQuery" />
</el-form-item>
<!-- <el-form-item label="报价轮次" prop="quoteRound">
<!-- <el-form-item label="报价轮次" prop="quoteRound">
<el-input v-model="queryParams.quoteRound" placeholder="请输入报价轮次" clearable @keyup.enter="handleQuery" />
</el-form-item>-->
<!-- <el-form-item label="报价大类" prop="quoteCategory">
<!-- <el-form-item label="报价大类" prop="quoteCategory">
<el-select v-model="queryParams.quoteCategory" placeholder="请选择报价大类" clearable >
<el-option v-for="dict in quote_category" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
@ -28,10 +28,10 @@
<el-option v-for="dict in business_direction" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
</el-form-item>-->
<!-- <el-form-item label="部门" prop="quoteDeptId">
<!-- <el-form-item label="部门" prop="quoteDeptId">
<el-input v-model="queryParams.quoteDeptId" placeholder="请输入部门" clearable @keyup.enter="handleQuery" />
</el-form-item>-->
<!-- <el-form-item label="报价日期" prop="quoteDate">
<!-- <el-form-item label="报价日期" prop="quoteDate">
<el-date-picker clearable
v-model="queryParams.quoteDate"
type="date"
@ -61,15 +61,15 @@
<el-form-item label="交货期" prop="deliveryPeriod">
<el-input v-model="queryParams.deliveryPeriod" placeholder="请输入交货期" clearable @keyup.enter="handleQuery" />
</el-form-item>-->
<!-- <el-form-item label="交付/交货方式" prop="deliveryMethod">
<!-- <el-form-item label="交付/交货方式" prop="deliveryMethod">
<el-input v-model="queryParams.deliveryMethod" placeholder="请输入交付/交货方式" clearable @keyup.enter="handleQuery" />
</el-form-item>-->
<!-- <el-form-item label="付款方式" prop="paymentMethod">
<el-select v-model="queryParams.paymentMethod" placeholder="请选择付款方式" clearable >
<el-option v-for="dict in payment_method" :key="dict.value" :label="dict.label" :value="dict.value"/>
<!-- <el-form-item label="付款方式" prop="paymentMethod">
<el-select v-model="queryParams.paymentMethod" placeholder="请选择付款方式" clearable>
<el-option v-for="dict in payment_method" :key="dict.value" :label="dict.label" :value="dict.value" />
</el-select>
</el-form-item>-->
<!-- <el-form-item label="币种" prop="currencyType">
</el-form-item> -->
<!-- <el-form-item label="币种" prop="currencyType">
<el-select v-model="queryParams.currencyType" placeholder="请选择币种" clearable >
<el-option v-for="dict in currency_type" :key="dict.value" :label="dict.label" :value="dict.value"/>
</el-select>
@ -151,16 +151,28 @@
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['oa/crm:crmQuoteInfo:add']"></el-button>
</el-col>
<el-col :span="1.5">
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/crm:crmQuoteInfo:edit']"></el-button>
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['oa/crm:crmQuoteInfo:edit']"
>修改</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/crm:crmQuoteInfo:remove']"></el-button>
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['oa/crm:crmQuoteInfo:remove']"
>删除</el-button
>
</el-col>
<el-col :span="1.5">
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['oa/crm:crmQuoteInfo:export']"></el-button>
</el-col>
<el-col :span="1.8">
<el-button type="primary" plain icon="Document" :disabled="single" @click="handleExportTemplate()" v-hasPermi="['oa/crm:crmQuoteInfo:exportTemplate']"></el-button>
<el-button
type="primary"
plain
icon="Document"
:disabled="single"
@click="handleExportTemplate()"
v-hasPermi="['oa/crm:crmQuoteInfo:export']"
>模板导出</el-button
>
</el-col>
<right-toolbar v-model:showSearch="showSearch" :columns="columns" :search="true" @queryTable="getList"></right-toolbar>
</el-row>
@ -168,26 +180,26 @@
<el-table v-loading="loading" border :data="crmQuoteInfoList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="序号" align="center" type="index" width="50" v-if="columns[0].visible"/>
<el-table-column label="报价单号" align="center" prop="quoteCode" v-if="columns[1].visible"/>
<el-table-column label="报价单名称" align="center" prop="quoteName" v-if="columns[2].visible"/>
<el-table-column label="报价轮次" align="center" prop="quoteRound" v-if="columns[3].visible"/>
<el-table-column label="序号" align="center" type="index" width="50" v-if="columns[0].visible" />
<el-table-column label="报价单号" align="center" prop="quoteCode" v-if="columns[1].visible" />
<el-table-column label="报价单名称" align="center" prop="quoteName" v-if="columns[2].visible" />
<el-table-column label="报价轮次" align="center" prop="quoteRound" v-if="columns[3].visible" />
<el-table-column label="报价大类" align="center" prop="quoteCategory" v-if="columns[4].visible">
<template #default="scope">
<dict-tag :options="quote_category" :value="scope.row.quoteCategory"/>
<dict-tag :options="quote_category" :value="scope.row.quoteCategory" />
</template>
</el-table-column>
<el-table-column label="报价类型" align="center" prop="quoteType" v-if="columns[5].visible">
<template #default="scope">
<dict-tag :options="contract_type" :value="scope.row.quoteType"/>
<dict-tag :options="contract_type" :value="scope.row.quoteType" />
</template>
</el-table-column>
<el-table-column label="业务方向" align="center" prop="businessDirection" v-if="columns[6].visible">
<template #default="scope">
<dict-tag :options="business_direction" :value="scope.row.businessDirection"/>
<dict-tag :options="business_direction" :value="scope.row.businessDirection" />
</template>
</el-table-column>
<el-table-column label="部门" align="center" prop="quoteDeptId" v-if="columns[7].visible"/>
<el-table-column label="部门" align="center" prop="deptName" v-if="columns[7].visible" />
<el-table-column label="报价日期" align="center" prop="quoteDate" width="180" v-if="columns[8].visible">
<template #default="scope">
<span>{{ parseTime(scope.row.quoteDate, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
@ -198,83 +210,87 @@
<span>{{ parseTime(scope.row.validFrom, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="报价有效期" align="center" prop="validDays" v-if="columns[10].visible"/>
<el-table-column label="报价有效期" align="center" prop="validDays" v-if="columns[10].visible" />
<el-table-column label="报价有效期止" align="center" prop="validTo" width="180" v-if="columns[11].visible">
<template #default="scope">
<span>{{ parseTime(scope.row.validTo, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="交货期" align="center" prop="deliveryPeriod" v-if="columns[12].visible"/>
<el-table-column label="交付/交货方式" align="center" prop="deliveryMethod" v-if="columns[13].visible"/>
<el-table-column label="交货期" align="center" prop="deliveryPeriod" v-if="columns[12].visible" />
<el-table-column label="交付/交货方式" align="center" prop="deliveryMethod" v-if="columns[13].visible" />
<el-table-column label="付款方式" align="center" prop="paymentMethod" v-if="columns[14].visible">
<template #default="scope">
<dict-tag :options="payment_method" :value="scope.row.paymentMethod"/>
<dict-tag :options="payment_method" :value="scope.row.paymentMethod" />
</template>
</el-table-column>
<el-table-column label="币种" align="center" prop="currencyType" v-if="columns[15].visible">
<template #default="scope">
<dict-tag :options="currency_type" :value="scope.row.currencyType"/>
<dict-tag :options="currency_type" :value="scope.row.currencyType" />
</template>
</el-table-column>
<el-table-column label="含税信息" align="center" prop="taxIncludedInfo" v-if="columns[16].visible"/>
<el-table-column label="税率(默认按明细可覆盖)" align="center" prop="taxRate" v-if="columns[17].visible"/>
<el-table-column label="总报价" align="center" prop="totalPrice" v-if="columns[18].visible"/>
<el-table-column label="未税总价" align="center" prop="totalBeforeTax" v-if="columns[19].visible"/>
<el-table-column label="税额" align="center" prop="totalTax" v-if="columns[20].visible"/>
<el-table-column label="含税总价" align="center" prop="totalIncludingTax" v-if="columns[21].visible"/>
<el-table-column label="客户方联系人ID" align="center" prop="customerContactId" v-if="columns[22].visible"/>
<el-table-column label="客户方联系人" align="center" prop="customerContactName" v-if="columns[23].visible"/>
<el-table-column label="客户方联系电话" align="center" prop="customerContactPhone" v-if="columns[24].visible"/>
<el-table-column label="客户方电子邮箱" align="center" prop="customerContactEmail" v-if="columns[25].visible"/>
<el-table-column label="供货方ID" align="center" prop="supplierContactId" v-if="columns[26].visible"/>
<el-table-column label="供货方联系人" align="center" prop="supplierContactName" v-if="columns[27].visible"/>
<el-table-column label="供货方联系电话" align="center" prop="supplierContactPhone" v-if="columns[28].visible"/>
<el-table-column label="供货方电子邮箱" align="center" prop="supplierContactEmail" v-if="columns[29].visible"/>
<el-table-column label="项目ID(可选)" align="center" prop="projectId" v-if="columns[30].visible"/>
<el-table-column label="打印模板ID(可选)" align="center" prop="templateId" v-if="columns[31].visible"/>
<el-table-column label="附件ID" align="center" prop="ossId" v-if="columns[32].visible"/>
<el-table-column label="含税信息" align="center" prop="taxIncludedInfo" v-if="columns[16].visible" />
<el-table-column label="税率(默认按明细可覆盖)" align="center" prop="taxRate" v-if="columns[17].visible" />
<el-table-column label="总报价" align="center" prop="totalPrice" v-if="columns[18].visible" />
<el-table-column label="未税总价" align="center" prop="totalBeforeTax" v-if="columns[19].visible" />
<el-table-column label="税额" align="center" prop="totalTax" v-if="columns[20].visible" />
<el-table-column label="含税总价" align="center" prop="totalIncludingTax" v-if="columns[21].visible" />
<el-table-column label="客户名称" align="center" prop="customerName" v-if="columns[22].visible" />
<el-table-column label="客户方联系人" align="center" prop="customerContactName" v-if="columns[23].visible" />
<el-table-column label="客户方联系电话" align="center" prop="customerContactPhone" v-if="columns[24].visible" />
<el-table-column label="客户方电子邮箱" align="center" prop="customerContactEmail" v-if="columns[25].visible" />
<el-table-column label="供应商名称" align="center" prop="supplierName" v-if="columns[26].visible" />
<el-table-column label="供货方联系人" align="center" prop="supplierContactName" v-if="columns[27].visible" />
<el-table-column label="供货方联系电话" align="center" prop="supplierContactPhone" v-if="columns[28].visible" />
<el-table-column label="供货方电子邮箱" align="center" prop="supplierContactEmail" v-if="columns[29].visible" />
<el-table-column label="项目ID(可选)" align="center" prop="projectId" v-if="columns[30].visible" />
<el-table-column label="打印模板ID(可选)" align="center" prop="templateId" v-if="columns[31].visible" />
<el-table-column label="附件ID" align="center" prop="ossId" v-if="columns[32].visible" />
<el-table-column label="报价单状态" align="center" prop="quoteStatus" v-if="columns[33].visible">
<template #default="scope">
<dict-tag :options="quote_status" :value="scope.row.quoteStatus"/>
<dict-tag :options="quote_status" :value="scope.row.quoteStatus" />
</template>
</el-table-column>
<el-table-column label="流程状态" align="center" prop="flowStatus" v-if="columns[34].visible">
<template #default="scope">
<dict-tag :options="flow_status" :value="scope.row.flowStatus"/>
<dict-tag :options="wf_business_status" :value="scope.row.flowStatus" />
</template>
</el-table-column>
<el-table-column label="备注" align="center" prop="remark" v-if="columns[35].visible"/>
<el-table-column label="创建人" align="center" prop="createName" v-if="columns[36].visible"/>
<el-table-column label="备注" align="center" prop="remark" v-if="columns[35].visible" />
<el-table-column label="创建人" align="center" prop="createName" v-if="columns[36].visible" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180" v-if="columns[37].visible">
<template #default="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}:{s}') }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="150" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="查看" placement="top">
<el-button link type="info" icon="DocumentChecked" @click="handleView(scope.row)"></el-button>
</el-tooltip>
<el-tooltip content="修改" placement="top">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/crm:crmQuoteInfo:edit']"></el-button>
</el-tooltip>
<el-tooltip content="审批记录(预留)" placement="top">
<el-button link type="info" icon="View"></el-button>
</el-tooltip>
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['oa/crm:crmQuoteInfo:remove']"></el-button>
</el-tooltip>
<el-tooltip content="模板导出" placement="top">
<el-button link type="warning" icon="Document" @click="handleExportTemplate(scope.row)" v-hasPermi="['oa/crm:crmQuoteInfo:exportTemplate']"></el-button>
</el-tooltip>
</template>
</el-table-column>
<el-table-column label="操作" align="center" fixed="right" width="150" class-name="small-padding fixed-width">
<template #default="scope">
<el-tooltip content="查看详情" placement="top" v-if="canViewDetail(scope.row)">
<el-button link type="info" icon="DocumentChecked" @click="handleView(scope.row)"></el-button>
</el-tooltip>
<el-tooltip content="修改" placement="top" v-if="scope.row.quoteStatus === '1'">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['oa/crm:crmQuoteInfo:edit']"></el-button>
</el-tooltip>
<!-- 审批记录统一通过编辑页顶部组件查看这里暂不展示 -->
<el-tooltip content="删除" placement="top">
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['oa/crm:crmQuoteInfo:remove']"></el-button>
</el-tooltip>
<el-tooltip content="模板导出" placement="top">
<el-button
link
type="warning"
icon="Document"
@click="handleExportTemplate(scope.row)"
v-hasPermi="['oa/crm:crmQuoteInfo:exportTemplate']"
></el-button>
</el-tooltip>
</template>
</el-table-column>
</el-table>
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
</el-card>
<!-- 添加或修改报价单信息对话框 -->
<!-- <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<!-- <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
<el-form ref="crmQuoteInfoFormRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="报价单号" prop="quoteCode">
<el-input v-model="form.quoteCode" placeholder="请输入报价单号" />
@ -457,8 +473,8 @@
<script setup name="CrmQuoteInfo" lang="ts">
import { useRoute, useRouter } from 'vue-router';
import { listCrmQuoteInfo, getCrmQuoteInfo, delCrmQuoteInfo, addCrmQuoteInfo, updateCrmQuoteInfo, exportQuoteTemplate } from '@/api/oa/crm/crmQuoteInfo';
import { CrmQuoteInfoVO, CrmQuoteInfoQuery, CrmQuoteInfoForm } from '@/api/oa/crm/crmQuoteInfo/types';
import { addCrmQuoteInfo, delCrmQuoteInfo, exportQuoteTemplate, listCrmQuoteInfo, updateCrmQuoteInfo } from '@/api/oa/crm/crmQuoteInfo';
import { CrmQuoteInfoForm, CrmQuoteInfoQuery, CrmQuoteInfoVO } from '@/api/oa/crm/crmQuoteInfo/types';
import { getCrmCustomerContactList } from '@/api/oa/crm/customerContact';
import FileSaver from 'file-saver';
import { blobValidate } from '@/utils/ruoyi';
@ -466,7 +482,9 @@ import { blobValidate } from '@/utils/ruoyi';
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const router = useRouter();
const route = useRoute();
const { business_direction, currency_type, quote_category, payment_method, quote_status, flow_status, contract_type } = toRefs<any>(proxy?.useDict('business_direction', 'currency_type', 'quote_category', 'payment_method', 'quote_status', 'flow_status', 'contract_type'));
const { business_direction, currency_type, quote_category, payment_method, quote_status, wf_business_status, contract_type } = toRefs<any>(
proxy?.useDict('business_direction', 'currency_type', 'quote_category', 'payment_method', 'quote_status', 'wf_business_status', 'contract_type')
);
const crmQuoteInfoList = ref<CrmQuoteInfoVO[]>([]);
const buttonLoading = ref(false);
@ -491,10 +509,10 @@ const columns = ref<FieldOption[]>([
{ key: 1, label: `报价单号`, visible: true },
{ key: 2, label: `报价单名称`, visible: true },
{ key: 3, label: `报价轮次`, visible: false },
{ key: 4, label: `报价大类`, visible: false },
{ key: 5, label: `报价类型`, visible: false },
{ key: 6, label: `业务方向`, visible: false },
{ key: 7, label: `部门`, visible: false },
{ key: 4, label: `报价大类`, visible: true },
{ key: 5, label: `报价类型`, visible: true },
{ key: 6, label: `业务方向`, visible: true },
{ key: 7, label: `部门`, visible: true },
{ key: 8, label: `报价日期`, visible: true },
{ key: 9, label: `报价有效期起`, visible: true },
{ key: 10, label: `报价有效期`, visible: false },
@ -505,26 +523,26 @@ const columns = ref<FieldOption[]>([
{ key: 15, label: `币种`, visible: false },
{ key: 16, label: `含税信息`, visible: false },
{ key: 17, label: `税率(默认按明细可覆盖)`, visible: false },
{ key: 18, label: `总报价`, visible: false },
{ key: 18, label: `总报价`, visible: true },
{ key: 19, label: `未税总价`, visible: false },
{ key: 20, label: `税额`, visible: false },
{ key: 21, label: `含税总价`, visible: true },
{ key: 22, label: `客户方联系人ID`, visible: false },
{ key: 22, label: `客户名称`, visible: true },
{ key: 23, label: `客户方联系人`, visible: false },
{ key: 24, label: `客户方联系电话`, visible: false },
{ key: 25, label: `客户方电子邮箱`, visible: false },
{ key: 26, label: `货方ID`, visible: false },
{ key: 26, label: `应商名称`, visible: false },
{ key: 27, label: `供货方联系人`, visible: false },
{ key: 28, label: `供货方联系电话`, visible: false },
{ key: 29, label: `供货方电子邮箱`, visible: false },
{ key: 30, label: `项目ID(可选)`, visible: false },
{ key: 31, label: `打印模板ID(可选)`, visible: false },
{ key: 32, label: `附件ID`, visible: false },
{ key: 33, label: `报价单状态`, visible: false },
{ key: 34, label: `流程状态`, visible: false },
{ key: 33, label: `报价单状态`, visible: true },
{ key: 34, label: `流程状态`, visible: true },
{ key: 35, label: `备注`, visible: true },
{ key: 36, label: `创建人`, visible: true },
{ key: 37, label: `创建时间`, visible: true },
{ key: 37, label: `创建时间`, visible: true }
//
]);
@ -565,10 +583,10 @@ const initFormData: CrmQuoteInfoForm = {
quoteStatus: undefined,
flowStatus: undefined,
remark: undefined,
createName: undefined,
}
createName: undefined
};
const data = reactive<PageData<CrmQuoteInfoForm, CrmQuoteInfoQuery>>({
form: {...initFormData},
form: { ...initFormData },
queryParams: {
pageNum: 1,
pageSize: 10,
@ -607,13 +625,10 @@ const data = reactive<PageData<CrmQuoteInfoForm, CrmQuoteInfoQuery>>({
quoteStatus: undefined,
flowStatus: undefined,
createName: undefined,
params: {
}
params: {}
},
rules: {
quoteId: [
{ required: true, message: "报价ID不能为空", trigger: "blur" }
],
quoteId: [{ required: true, message: '报价ID不能为空', trigger: 'blur' }]
}
});
@ -626,38 +641,38 @@ const getList = async () => {
crmQuoteInfoList.value = res.rows;
total.value = res.total;
loading.value = false;
}
};
/** 取消按钮 */
const cancel = () => {
reset();
dialog.visible = false;
}
};
/** 表单重置 */
const reset = () => {
form.value = {...initFormData};
form.value = { ...initFormData };
crmQuoteInfoFormRef.value?.resetFields();
}
};
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNum = 1;
getList();
}
};
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value?.resetFields();
handleQuery();
}
};
/** 多选框选中数据 */
const handleSelectionChange = (selection: CrmQuoteInfoVO[]) => {
ids.value = selection.map(item => item.quoteId);
ids.value = selection.map((item) => item.quoteId);
single.value = selection.length != 1;
multiple.value = !selection.length;
}
};
/** 新增按钮操作(改为路由跳转到编辑页) */
const handleAdd = () => {
@ -666,7 +681,7 @@ const handleAdd = () => {
path: '/oa/crm/crmQuoteInfo/edit',
query: { type: 'add' }
});
}
};
/** 修改按钮操作(改为路由跳转到编辑页) */
const handleUpdate = (row?: CrmQuoteInfoVO) => {
@ -676,7 +691,7 @@ const handleUpdate = (row?: CrmQuoteInfoVO) => {
path: '/oa/crm/crmQuoteInfo/edit',
query: { id: _quoteId, type: 'update' }
});
}
};
/** 查看按钮操作(查看模式只读) */
const handleView = (row?: CrmQuoteInfoVO) => {
@ -686,7 +701,12 @@ const handleView = (row?: CrmQuoteInfoVO) => {
path: '/oa/crm/crmQuoteInfo/edit',
query: { id: _quoteId, type: 'view' }
});
}
};
/** 判断是否可以查看详情:仅非草稿状态可进入查看页 */
const canViewDetail = (row: CrmQuoteInfoVO) => {
return row.quoteStatus !== '1';
};
/** 提交按钮 */
const submitForm = () => {
@ -694,32 +714,36 @@ const submitForm = () => {
if (valid) {
buttonLoading.value = true;
if (form.value.quoteId) {
await updateCrmQuoteInfo(form.value).finally(() => buttonLoading.value = false);
await updateCrmQuoteInfo(form.value).finally(() => (buttonLoading.value = false));
} else {
await addCrmQuoteInfo(form.value).finally(() => buttonLoading.value = false);
await addCrmQuoteInfo(form.value).finally(() => (buttonLoading.value = false));
}
proxy?.$modal.msgSuccess("操作成功");
proxy?.$modal.msgSuccess('操作成功');
dialog.visible = false;
await getList();
}
});
}
};
/** 删除按钮操作 */
const handleDelete = async (row?: CrmQuoteInfoVO) => {
const _quoteIds = row?.quoteId || ids.value;
await proxy?.$modal.confirm('是否确认删除报价单信息编号为"' + _quoteIds + '"的数据项?').finally(() => loading.value = false);
await proxy?.$modal.confirm('是否确认删除报价单信息编号为"' + _quoteIds + '"的数据项?').finally(() => (loading.value = false));
await delCrmQuoteInfo(_quoteIds);
proxy?.$modal.msgSuccess("删除成功");
proxy?.$modal.msgSuccess('删除成功');
await getList();
}
};
/** 导出按钮操作 */
const handleExport = () => {
proxy?.download('oa/crm/crmQuoteInfo/export', {
...queryParams.value
}, `crmQuoteInfo_${new Date().getTime()}.xlsx`)
}
proxy?.download(
'oa/crm/crmQuoteInfo/export',
{
...queryParams.value
},
`crmQuoteInfo_${new Date().getTime()}.xlsx`
);
};
/** 模板导出支持选中或行内按钮GET Blob 下载) */
const handleExportTemplate = async (row?: CrmQuoteInfoVO) => {
@ -729,12 +753,13 @@ const handleExportTemplate = async (row?: CrmQuoteInfoVO) => {
return;
}
try {
const resp: Blob = await exportQuoteTemplate(_quoteId);
const resp = await exportQuoteTemplate(_quoteId);
// JSON
if (blobValidate(resp)) {
FileSaver.saveAs(resp, `报价单_${new Date().getTime()}.xlsx`);
if (blobValidate(resp as any)) {
const blob = resp as any;
FileSaver.saveAs(blob as Blob, `报价单_${new Date().getTime()}.xlsx`);
} else {
const resText = await resp.text();
const resText = await (resp as any).text();
const rspObj = JSON.parse(resText);
proxy?.$modal.msgError(rspObj.msg || '导出失败');
}
@ -742,13 +767,13 @@ const handleExportTemplate = async (row?: CrmQuoteInfoVO) => {
console.error(e);
proxy?.$modal.msgError('导出失败,请联系管理员');
}
}
};
let crmCustomerContactList = ref([]);
const getCustomerContactList = async () => {
const res = await getCrmCustomerContactList(null);
crmCustomerContactList.value = res.data;
}
};
onMounted(() => {
getCustomerContactList();
getList();

Loading…
Cancel
Save