提交
This commit is contained in:
1 parent
70bdd820ce
commit
bede140d12
988 files changed
+692310
-775910
No files matched your search
@@ -773,18 +773,22 @@
|
||||
</el-dialog>
|
||||
<!-- 生成合同对话框 -->
|
||||
<el-dialog
|
||||
:title="isPreviewMode ? '预览合同' : '编辑合同'"
|
||||
v-model="generateContractDialog.visible"
|
||||
width="1200px"
|
||||
align-center
|
||||
append-to-body
|
||||
class="dialog-form-layout"
|
||||
class="dialog-form-layout generate-print-dialog"
|
||||
modal-class="order-module-dialog-mask"
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<p v-if="!isPreviewMode" class="generate-contract-edit-hint">
|
||||
编辑模式:鼠标移入表格后,列/行边界会出现绿色调整条,按住拖动即可调列宽或行高;工具栏可合并拆分、插删行列、对齐与换行。调整后请点「保存模板」。
|
||||
</p>
|
||||
<template #header>
|
||||
<div class="generate-print-dialog-header">
|
||||
<span class="generate-print-dialog-title">{{ isPreviewMode ? '预览合同' : '编辑合同' }}</span>
|
||||
<p v-if="!isPreviewMode" class="generate-print-dialog-edit-hint">
|
||||
编辑模式:鼠标移入表格后,列/行边界会出现绿色调整条,按住拖动即可调列宽或行高;工具栏可合并拆分、插删行列、对齐与换行。调整后请点「保存模板」。
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
<TinyMceEditor
|
||||
v-model="contractContent"
|
||||
:height="600"
|
||||
@@ -803,6 +807,12 @@
|
||||
<el-button class="btn-ghost" @click="handleSaveTemplate">
|
||||
<el-icon><DocumentChecked /></el-icon>保存模板
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="toggleRedSeal">
|
||||
<el-icon>
|
||||
<component :is="showRedSeal ? Hide : Stamp" />
|
||||
</el-icon>
|
||||
{{ showRedSeal ? '隐藏红章' : '显示红章' }}
|
||||
</el-button>
|
||||
<el-button class="btn-ghost" @click="handlePrintContract">
|
||||
<el-icon><Printer /></el-icon>打印
|
||||
</el-button>
|
||||
@@ -842,10 +852,12 @@ import {
|
||||
DocumentChecked,
|
||||
Download,
|
||||
Edit,
|
||||
Hide,
|
||||
InfoFilled,
|
||||
Plus,
|
||||
Printer,
|
||||
Promotion,
|
||||
Stamp,
|
||||
Upload,
|
||||
VideoPlay,
|
||||
View,
|
||||
@@ -939,6 +951,8 @@ const generateContractDialog = reactive({
|
||||
});
|
||||
const contractContent = ref('');
|
||||
const isPreviewMode = ref(false);
|
||||
/** 打印弹窗内红章显隐(仅本次弹窗有效,打开时默认显示) */
|
||||
const showRedSeal = ref(true);
|
||||
const pdfGenerating = ref(false);
|
||||
const currentContractId = ref<string | number>();
|
||||
|
||||
@@ -1309,8 +1323,9 @@ const handleDetailPrint = async () => {
|
||||
console.error('替换占位符失败,使用原始内容:', replaceError);
|
||||
}
|
||||
|
||||
// 先设置内容,再打开对话框
|
||||
// 先设置内容,再打开对话框(每次打开默认显示红章)
|
||||
contractContent.value = htmlContent;
|
||||
showRedSeal.value = true;
|
||||
|
||||
// 关闭加载提示
|
||||
$modal.closeLoading();
|
||||
@@ -2551,6 +2566,80 @@ const replaceDynamicFields = (template: string, contractData: ContractVO): strin
|
||||
return result;
|
||||
};
|
||||
|
||||
const SEAL_IMG_RE = /<img[^>]*alt=["']印章["'][^>]*>/gi;
|
||||
|
||||
const getSupplierCodeFromContractNo = (contractNo?: string): string => {
|
||||
if (!contractNo) return 'SX';
|
||||
const match = contractNo.match(/^([A-Z]+)\/X-JT/);
|
||||
return match?.[1] || 'SX';
|
||||
};
|
||||
|
||||
const resolveSealImageByCompanyName = (companyName: string | undefined, supplierCode: string): string => {
|
||||
if (!companyName) return '';
|
||||
if (companyName.includes('云栋') || companyName.includes('安徽云栋化工有限公司')) {
|
||||
return '/src/assets/images/yd.png';
|
||||
}
|
||||
if (companyName.includes('山峡') || companyName.includes('安庆市山峡化工有限公司')) {
|
||||
return supplierCode === 'SX' ? '/src/assets/images/yz.png' : '/src/assets/images/yd.png';
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
const buildSealHtml = (companyName: string | undefined, supplierCode: string): string => {
|
||||
const sealSrc = resolveSealImageByCompanyName(companyName, supplierCode);
|
||||
if (!sealSrc) return '';
|
||||
return `<img src="${sealSrc}" alt="印章" style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 140px; height: 140px; opacity: 0.85; z-index: 10;" />`;
|
||||
};
|
||||
|
||||
const stripSealImages = (html: string): string => html.replace(SEAL_IMG_RE, '');
|
||||
|
||||
const injectSealImages = (html: string, contractData: ContractVO): string => {
|
||||
let result = stripSealImages(html);
|
||||
const supplierCode = getSupplierCodeFromContractNo(contractData.contractNo);
|
||||
const partyASeal = buildSealHtml(contractData.partyA, supplierCode);
|
||||
const partyBSeal = buildSealHtml(contractData.partyB, supplierCode);
|
||||
|
||||
if (/<!--\s*印章图片[^>]*-->/.test(result)) {
|
||||
let sealCommentIndex = 0;
|
||||
return result.replace(/<!--\s*印章图片[^>]*-->/g, (match) => {
|
||||
sealCommentIndex += 1;
|
||||
if (sealCommentIndex === 1) return `${match}\n ${partyASeal}`;
|
||||
if (sealCommentIndex === 2) return `${match}\n ${partyBSeal}`;
|
||||
return match;
|
||||
});
|
||||
}
|
||||
|
||||
const escapeRegExp = (value: string) => value.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||||
if (partyASeal && contractData.partyA) {
|
||||
const escaped = escapeRegExp(contractData.partyA);
|
||||
result = result.replace(
|
||||
new RegExp(`(<div[^>]*>单位名称(章):\\s*${escaped}</div>)`),
|
||||
`${partyASeal}\n $1`
|
||||
);
|
||||
}
|
||||
if (partyBSeal && contractData.partyB) {
|
||||
const escaped = escapeRegExp(contractData.partyB);
|
||||
result = result.replace(
|
||||
new RegExp(`(<div[^>]*>单位名称(章):\\s*${escaped}</div>)`),
|
||||
`${partyBSeal}\n $1`
|
||||
);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
/** 切换红章显示/隐藏(同步影响编辑器、打印、PDF) */
|
||||
const toggleRedSeal = () => {
|
||||
if (showRedSeal.value) {
|
||||
contractContent.value = stripSealImages(contractContent.value);
|
||||
showRedSeal.value = false;
|
||||
return;
|
||||
}
|
||||
if (detailContract.value) {
|
||||
contractContent.value = injectSealImages(contractContent.value, detailContract.value);
|
||||
}
|
||||
showRedSeal.value = true;
|
||||
};
|
||||
|
||||
/** 切换预览/编辑模式 */
|
||||
const togglePreviewMode = () => {
|
||||
isPreviewMode.value = !isPreviewMode.value;
|
||||
@@ -2970,15 +3059,33 @@ onMounted(async () => {
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.generate-contract-edit-hint {
|
||||
margin: 0 0 12px;
|
||||
padding: 8px 12px;
|
||||
.generate-print-dialog-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
width: 100%;
|
||||
min-height: 24px;
|
||||
padding-right: 28px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.generate-print-dialog-title {
|
||||
flex-shrink: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
line-height: 24px;
|
||||
color: var(--el-text-color-primary);
|
||||
}
|
||||
|
||||
.generate-print-dialog-edit-hint {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
font-size: 12px;
|
||||
line-height: 1.5;
|
||||
color: #047857;
|
||||
background: #ecfdf5;
|
||||
border: 1px solid #a7f3d0;
|
||||
border-radius: 8px;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
color: #ef4444;
|
||||
}
|
||||
|
||||
.parties-section {
|
||||
|
||||
@@ -470,7 +470,12 @@
|
||||
</template>
|
||||
|
||||
<!-- 产品选择器 -->
|
||||
<ProductSelector :visible="productSelectorVisible" @update:visible="productSelectorVisible = $event" @confirm="handleProductSelected" />
|
||||
<ProductSelector
|
||||
:visible="productSelectorVisible"
|
||||
:supplier-id="form.supplierId"
|
||||
@update:visible="productSelectorVisible = $event"
|
||||
@confirm="handleProductSelected"
|
||||
/>
|
||||
|
||||
<!-- 客户选择器 -->
|
||||
<CustomerSelector :visible="customerSelectorVisible" @update:visible="customerSelectorVisible = $event" @confirm="handleCustomerConfirm" />
|
||||
@@ -540,6 +545,7 @@ import ProductSelector from './ProductSelector.vue'
|
||||
import CustomerSelector from '@/components/CustomerSelector.vue'
|
||||
import ContactSelector from '@/components/ContactSelector.vue'
|
||||
import QuoteSelector from '@/components/QuoteSelector.vue'
|
||||
import { removeProductsNotAllowedByHazard } from '@/utils/crm-supplier-hazard'
|
||||
import ApprovalDialog from './ApprovalDialog.vue'
|
||||
import { getContactByCustomerId } from '@/api/crm/customer'
|
||||
import type { CustomerVO, ContactVO } from '@/api/crm/customer/types'
|
||||
@@ -882,6 +888,8 @@ const loadContractDetail = async (id: number | string) => {
|
||||
form.value.products = contractData.products.map((product: any) => ({
|
||||
...product,
|
||||
productModel: product.model || '',
|
||||
isToxic: Number(product.isToxic || 0),
|
||||
isExplosive: Number(product.isExplosive || 0),
|
||||
priceTiers: (product.priceTiers || []).map((t: any) => {
|
||||
let ids: string[] = []
|
||||
if (Array.isArray(t.letterOssIds) && t.letterOssIds.length) {
|
||||
@@ -1241,6 +1249,20 @@ const handleSupplierChange = async (supplierId: number | undefined) => {
|
||||
|
||||
updateContractNoBySupplier(supplier.supplierCode)
|
||||
rebuildContractName()
|
||||
|
||||
const allowToxic = Number((supplier as any).allowToxic || 0)
|
||||
const allowExplosive = Number((supplier as any).allowExplosive || 0)
|
||||
const { kept, removedNames } = removeProductsNotAllowedByHazard(
|
||||
form.value.products || [],
|
||||
allowToxic,
|
||||
allowExplosive
|
||||
)
|
||||
form.value.products = kept
|
||||
if (removedNames.length) {
|
||||
$modal.msgWarning(`当前主体不支持以下产品,已自动移除:${removedNames.join('、')}`)
|
||||
form.value.products.forEach((p) => calculateProductAmount(p))
|
||||
calculateTotalAmount()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1457,6 +1479,10 @@ const handleSignDateChange = (val: string | null) => {
|
||||
|
||||
/** 添加产品 */
|
||||
const handleAddProduct = () => {
|
||||
if (!form.value.supplierId) {
|
||||
$modal.msgWarning('请先选择交易主体')
|
||||
return
|
||||
}
|
||||
productSelectorVisible.value = true
|
||||
}
|
||||
|
||||
@@ -1480,6 +1506,8 @@ const handleProductSelected = (products: any[]) => {
|
||||
deliveryMethod: '',
|
||||
description: product.description || '',
|
||||
remark: '',
|
||||
isToxic: Number(product.isToxic || 0),
|
||||
isExplosive: Number(product.isExplosive || 0),
|
||||
priceTiers: isFw ? [] : undefined
|
||||
})
|
||||
})
|
||||
|
||||
@@ -155,7 +155,8 @@ interface ProductCategoryVO {
|
||||
|
||||
// 定义组件属性
|
||||
interface Props {
|
||||
visible: boolean;
|
||||
visible: boolean
|
||||
supplierId?: string | number
|
||||
}
|
||||
|
||||
const props = defineProps<Props>();
|
||||
@@ -216,7 +217,8 @@ const getList = async () => {
|
||||
pageSize: queryParams.value.pageSize,
|
||||
keyword: queryParams.value.productName,
|
||||
categoryId: queryParams.value.categoryId,
|
||||
status: queryParams.value.status
|
||||
status: queryParams.value.status,
|
||||
supplierId: props.supplierId != null && props.supplierId !== '' ? String(props.supplierId) : undefined
|
||||
});
|
||||
const data = (res as any)?.data || res || {};
|
||||
productList.value = data.list || data.rows || [];
|
||||
|
||||
Reference in new issue
Block a user