|
|
|
|
@ -1,17 +1,27 @@
|
|
|
|
|
<template>
|
|
|
|
|
<div style="padding: 0 20px;">
|
|
|
|
|
<lx-header icon="md-apps" style="margin-bottom: 10px; border: 0px; margin-top: 15px" text="新增支付表格">
|
|
|
|
|
<lx-header icon="md-apps" style="margin-bottom: 10px; border: 0px; margin-top: 15px" :text="headerTitle">
|
|
|
|
|
</lx-header>
|
|
|
|
|
|
|
|
|
|
<div class="content-wrapper">
|
|
|
|
|
<!-- 左侧面板 -->
|
|
|
|
|
<div class="left-panel">
|
|
|
|
|
<!-- 表格名称输入区 -->
|
|
|
|
|
<div class="form-name-container">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="formName"
|
|
|
|
|
placeholder="请输入表格名称"
|
|
|
|
|
clearable
|
|
|
|
|
style="width: 100%"
|
|
|
|
|
></el-input>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- 预览区 -->
|
|
|
|
|
<div>
|
|
|
|
|
<div class="panel-header">
|
|
|
|
|
<h5 class="panel-title">预览区</h5>
|
|
|
|
|
<div class="action-buttons">
|
|
|
|
|
<el-button size="small" @click="handleRefresh">刷新</el-button>
|
|
|
|
|
<el-button size="small" @click="showPreviewModal = true">放大</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="preview-container" v-if="formatType === 'html'" v-html="previewContent"></div>
|
|
|
|
|
@ -136,20 +146,60 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-drawer>
|
|
|
|
|
|
|
|
|
|
<!-- 预览模态窗口 -->
|
|
|
|
|
<el-dialog
|
|
|
|
|
title="预览"
|
|
|
|
|
:visible.sync="showPreviewModal"
|
|
|
|
|
width="80%"
|
|
|
|
|
:fullscreen="true"
|
|
|
|
|
:modal-append-to-body="true"
|
|
|
|
|
:append-to-body="true"
|
|
|
|
|
custom-class="preview-modal"
|
|
|
|
|
>
|
|
|
|
|
<div class="modal-preview-container" v-if="formatType === 'html'" v-html="previewContent"></div>
|
|
|
|
|
<div class="modal-preview-container" v-else>
|
|
|
|
|
<iframe
|
|
|
|
|
v-if="docxUrl"
|
|
|
|
|
:src="docxUrl"
|
|
|
|
|
frameborder="0"
|
|
|
|
|
style="width: 100%; height: 100%;"
|
|
|
|
|
></iframe>
|
|
|
|
|
<div v-else class="no-preview">
|
|
|
|
|
请上传文档进行预览
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import mammoth from 'mammoth';
|
|
|
|
|
import { saveContractForm, getContractFormDetail } from '@/api/businessConfig/businessConfig';
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: 'AddPayForm',
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
formId: null, // 表单ID,用于编辑模式
|
|
|
|
|
isEditMode: false, // 是否为编辑模式
|
|
|
|
|
formName: '', // 添加表格名称字段
|
|
|
|
|
formatType: 'html',
|
|
|
|
|
codeContent: '',
|
|
|
|
|
previewContent: '', // 预览内容
|
|
|
|
|
showEditDrawer: false,
|
|
|
|
|
showPreviewModal: false, // 添加预览模态窗口控制变量
|
|
|
|
|
currentTemplateIndex: 0,
|
|
|
|
|
editForm: {
|
|
|
|
|
name: '',
|
|
|
|
|
label: '',
|
|
|
|
|
type: 'text',
|
|
|
|
|
options: '',
|
|
|
|
|
},
|
|
|
|
|
fieldList: [],
|
|
|
|
|
fieldMetadata: {},
|
|
|
|
|
docxUrl: null,
|
|
|
|
|
templateFile: null,
|
|
|
|
|
templates: [
|
|
|
|
|
{
|
|
|
|
|
name: '资金划拨审批单',
|
|
|
|
|
@ -160,14 +210,14 @@ export default {
|
|
|
|
|
<table style="width: 100%; border-collapse: collapse; font-family: SimSun, serif;">
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; width: 25%;">项目名称:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; width: 25%;">{{projectName}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; text-align: right;" colspan="2">本次为第<span style="display: inline-block; width: 30px; border-bottom: 1px solid #000; text-align: center;">{{paymentTimes}}</span>次付款</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; width: 25%;">\${projectName}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; text-align: right;" colspan="2">本次为第<span style="display: inline-block; width: 30px; border-bottom: 1px solid #000; text-align: center;">\${paymentTimes}</span>次付款</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">承包商/供货商:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{contractor}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${contractor}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">合同服务时间:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{serviceTime}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${serviceTime}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; background-color: #f5f5f5; border: 1px solid #000;" colspan="2">付款情形</td>
|
|
|
|
|
@ -177,61 +227,64 @@ export default {
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000; width: 10%;">A</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">合同金额</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{contractAmount}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{contractRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${contractAmount}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${contractRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">B</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">审计金额</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{auditAmount}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{auditRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${auditAmount}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${auditRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">C</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">前期累计已付款</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{previousPayment}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{previousPaymentRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${previousPayment}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${previousPaymentRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">D</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">本期拟款</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{currentPayment}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{currentPaymentRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${currentPayment}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${currentPaymentRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr style="background-color: #f5f5f5;">
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">E</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">本期应付款</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{currentDuePayment}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${currentDuePayment}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">
|
|
|
|
|
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
|
|
|
|
<label style="margin-right: 10px;"><input type="checkbox"> 预付款</label>
|
|
|
|
|
<label style="margin-right: 10px;"><input type="checkbox"> 进度款</label>
|
|
|
|
|
<label><input type="checkbox"> 结算款</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="display: flex; justify-content: flex-start;">
|
|
|
|
|
<label style="margin-right: 20px;"><input type="checkbox"> 质保金</label>
|
|
|
|
|
<label><input type="checkbox"> <span style="text-decoration: underline;"> </span>(其他)</label>
|
|
|
|
|
<div style="display: none;">
|
|
|
|
|
<div style="display: flex; justify-content: space-between; margin-bottom: 8px;">
|
|
|
|
|
<label style="margin-right: 10px;"><input type="checkbox"> 预付款</label>
|
|
|
|
|
<label style="margin-right: 10px;"><input type="checkbox"> 进度款</label>
|
|
|
|
|
<label><input type="checkbox"> 结算款</label>
|
|
|
|
|
</div>
|
|
|
|
|
<div style="display: flex; justify-content: flex-start;">
|
|
|
|
|
<label style="margin-right: 20px;"><input type="checkbox"> 质保金</label>
|
|
|
|
|
<label><input type="checkbox"> <span style="text-decoration: underline;"> </span>(其他)</label>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>\${paymentType}</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">F</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">累计支付</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{totalPaid}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{totalPaidRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${totalPaid}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${totalPaidRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">G</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">累计拟款</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{totalPlanned}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{totalPlannedRemark}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${totalPlanned}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${totalPlannedRemark}</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; text-align: center; border: 1px solid #000;">H</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">质保金</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">{{warranty}}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">\${warranty}</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000;">
|
|
|
|
|
<span style="text-decoration: underline;"> </span>%,质保期<span style="text-decoration: underline;"> </span>年,需审计的以审计价为计费依据。
|
|
|
|
|
<span style="text-decoration: underline;">\${percent}</span>%,质保期<span style="text-decoration: underline;">\${zbYear}</span>年,需审计的以审计价为计费依据。
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
@ -240,15 +293,32 @@ export default {
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; height: 100px; vertical-align: top;">
|
|
|
|
|
<div>业务科室:</div>
|
|
|
|
|
<div style="margin-top: 60px;">经办人:</div>
|
|
|
|
|
<div> \${department}</div>
|
|
|
|
|
<div style="margin-top: 20px;">经办人:</div>
|
|
|
|
|
<div> \${handler}</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;">
|
|
|
|
|
<div>业务科室负责人:</div>
|
|
|
|
|
<div> \${departmentHead}</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;" colspan="2">
|
|
|
|
|
<div>业务科室分管领导:</div>
|
|
|
|
|
<div> \${departmentLeader}</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;">业务科室负责人:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;" colspan="2">业务科室分管领导:</td>
|
|
|
|
|
</tr>
|
|
|
|
|
<tr>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; height: 100px; vertical-align: top;">财务审计科:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;">财务审计科分管领导:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;" colspan="2">单位负责人:</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; height: 100px; vertical-align: top;">
|
|
|
|
|
<div>财务审计科:</div>
|
|
|
|
|
<div> \${financeDepartment}</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;">
|
|
|
|
|
<div>财务审计科分管领导:</div>
|
|
|
|
|
<div> \${financeLeader}</div>
|
|
|
|
|
</td>
|
|
|
|
|
<td style="padding: 8px 12px; font-size: 16px; line-height: 1.5; border: 1px solid #000; vertical-align: top;" colspan="2">
|
|
|
|
|
<div>单位负责人:</div>
|
|
|
|
|
<div> \${unitLeader}</div>
|
|
|
|
|
</td>
|
|
|
|
|
</tr>
|
|
|
|
|
</table>
|
|
|
|
|
</div>
|
|
|
|
|
@ -771,26 +841,26 @@ export default {
|
|
|
|
|
</div>`
|
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
editForm: {
|
|
|
|
|
name: '测试字段',
|
|
|
|
|
label: '测试标签',
|
|
|
|
|
type: 'text',
|
|
|
|
|
options: '',
|
|
|
|
|
required: false,
|
|
|
|
|
placeholder: ''
|
|
|
|
|
},
|
|
|
|
|
fieldList: [],
|
|
|
|
|
previewContent: '',
|
|
|
|
|
fieldMetadata: {},
|
|
|
|
|
docxContent: '',
|
|
|
|
|
docxUrl: ''
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {
|
|
|
|
|
this.loadTemplate(this.currentTemplateIndex);
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.handleRefresh();
|
|
|
|
|
});
|
|
|
|
|
computed: {
|
|
|
|
|
headerTitle() {
|
|
|
|
|
return this.isEditMode ? '编辑支付表格' : '新增支付表格'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
// 从URL中获取ID参数
|
|
|
|
|
const id = this.$route.query.id
|
|
|
|
|
if (id) {
|
|
|
|
|
this.formId = id
|
|
|
|
|
this.isEditMode = true
|
|
|
|
|
this.fetchFormData(id)
|
|
|
|
|
} else {
|
|
|
|
|
// 新增模式,使用默认模板
|
|
|
|
|
this.initializeNewForm()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
currentTemplateIndex: {
|
|
|
|
|
@ -829,7 +899,8 @@ export default {
|
|
|
|
|
handleRefresh() {
|
|
|
|
|
let processedContent = this.codeContent;
|
|
|
|
|
|
|
|
|
|
const variableRegex = /\{\{([^}]+)\}\}/g;
|
|
|
|
|
// 修改正则表达式以匹配 ${xxx} 格式的占位变量
|
|
|
|
|
const variableRegex = /\${([^}]+)}/g;
|
|
|
|
|
const matches = this.codeContent.matchAll(variableRegex);
|
|
|
|
|
const variables = new Set();
|
|
|
|
|
|
|
|
|
|
@ -839,7 +910,11 @@ export default {
|
|
|
|
|
|
|
|
|
|
this.updateFieldMetadata(Array.from(variables));
|
|
|
|
|
|
|
|
|
|
processedContent = processedContent.replace(/\{\{[^}]+\}\}/g, '');
|
|
|
|
|
// 移除占位变量,保留其他内容用于预览
|
|
|
|
|
processedContent = processedContent.replace(/\${[^}]+}/g, '');
|
|
|
|
|
|
|
|
|
|
// 移除所有 display:none 样式,使隐藏内容可见
|
|
|
|
|
processedContent = processedContent.replace(/display:\s*none/g, 'display: block');
|
|
|
|
|
|
|
|
|
|
this.previewContent = processedContent;
|
|
|
|
|
},
|
|
|
|
|
@ -938,9 +1013,40 @@ export default {
|
|
|
|
|
handleCancel() {
|
|
|
|
|
this.$router.back();
|
|
|
|
|
},
|
|
|
|
|
handleSave() {
|
|
|
|
|
this.$message.success('保存成功');
|
|
|
|
|
this.$router.push('/business-config/pay-form');
|
|
|
|
|
async handleSave() {
|
|
|
|
|
if (!this.formName) {
|
|
|
|
|
this.$message.error('请输入表格名称')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const params = {
|
|
|
|
|
name: this.formName,
|
|
|
|
|
type: this.formatType === 'html' ? 1 : 2,
|
|
|
|
|
template: this.formatType === 'html' ? this.codeContent : null,
|
|
|
|
|
// 其他必要字段
|
|
|
|
|
link_type: 1, // 假设默认值
|
|
|
|
|
status: 1, // 假设默认启用
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 如果是编辑模式,添加ID
|
|
|
|
|
if (this.isEditMode) {
|
|
|
|
|
params.id = this.formId
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const res = await saveContractForm(params)
|
|
|
|
|
if (res.errcode !== undefined) {
|
|
|
|
|
this.$message.error(res.errmsg || '保存失败')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.$message.success('保存成功')
|
|
|
|
|
// 保存成功后返回列表页
|
|
|
|
|
this.$router.push('/businessConfig/payFormConfig')
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('保存失败:', error)
|
|
|
|
|
this.$message.error('保存失败')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
updateFieldMetadata(variables) {
|
|
|
|
|
const updatedMetadata = {};
|
|
|
|
|
@ -980,8 +1086,8 @@ export default {
|
|
|
|
|
console.log('尝试只打开抽屉');
|
|
|
|
|
},
|
|
|
|
|
extractVariables(text) {
|
|
|
|
|
// 使用更宽松的正则表达式匹配占位变量
|
|
|
|
|
const regex = /\{\{([^}]+)\}\}/g;
|
|
|
|
|
// 修改正则表达式以匹配 ${xxx} 格式的占位变量
|
|
|
|
|
const regex = /\${([^}]+)}/g;
|
|
|
|
|
const matches = text.matchAll(regex);
|
|
|
|
|
const variables = new Set();
|
|
|
|
|
|
|
|
|
|
@ -998,6 +1104,55 @@ export default {
|
|
|
|
|
console.log('提取到的变量:', Array.from(variables));
|
|
|
|
|
|
|
|
|
|
return Array.from(variables);
|
|
|
|
|
},
|
|
|
|
|
// 获取表单数据
|
|
|
|
|
async fetchFormData(id) {
|
|
|
|
|
try {
|
|
|
|
|
const res = await getContractFormDetail(id)
|
|
|
|
|
if (res.errcode !== undefined) {
|
|
|
|
|
this.$message.error(res.errmsg || '获取表单数据失败')
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 填充表单数据
|
|
|
|
|
const formData = res
|
|
|
|
|
this.formName = formData.name || ''
|
|
|
|
|
this.formatType = formData.type == 1 ? 'html' : 'docx'
|
|
|
|
|
|
|
|
|
|
// 设置代码内容和字段元数据
|
|
|
|
|
if (this.formatType === 'html') {
|
|
|
|
|
this.codeContent = formData.template || ''
|
|
|
|
|
// 提取变量,更新字段元数据
|
|
|
|
|
this.extractAndUpdateFields()
|
|
|
|
|
} else if (this.formatType === 'docx' && formData.template_url) {
|
|
|
|
|
this.docxUrl = formData.template_url
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新预览内容
|
|
|
|
|
this.handleRefresh()
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error('获取表单数据失败:', error)
|
|
|
|
|
this.$message.error('获取表单数据失败')
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 初始化新建表单
|
|
|
|
|
initializeNewForm() {
|
|
|
|
|
// 使用第一个模板作为默认内容
|
|
|
|
|
if (this.templates.length > 0) {
|
|
|
|
|
this.codeContent = this.templates[0].content
|
|
|
|
|
this.formName = this.templates[0].name
|
|
|
|
|
// 提取变量,更新字段元数据
|
|
|
|
|
this.extractAndUpdateFields()
|
|
|
|
|
// 更新预览内容
|
|
|
|
|
this.handleRefresh()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 提取变量并更新字段列表
|
|
|
|
|
extractAndUpdateFields() {
|
|
|
|
|
const variables = this.extractVariables(this.codeContent)
|
|
|
|
|
this.updateFieldMetadata(variables)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 在组件销毁时释放URL
|
|
|
|
|
@ -1016,6 +1171,7 @@ export default {
|
|
|
|
|
margin: 0 -20px;
|
|
|
|
|
padding: 0 20px;
|
|
|
|
|
margin-bottom: 60px;
|
|
|
|
|
overflow-y: auto; // 添加垂直滚动
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.left-panel {
|
|
|
|
|
@ -1024,6 +1180,28 @@ export default {
|
|
|
|
|
padding-right: 20px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
overflow-y: auto; // 添加垂直滚动
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.form-name-container {
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
padding: 10px;
|
|
|
|
|
background: #fff;
|
|
|
|
|
border: 1px solid #e4e7ed;
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
|
|
|
|
:deep(.el-input__inner) {
|
|
|
|
|
height: 40px;
|
|
|
|
|
line-height: 40px;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
border-color: #c0c4cc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
|
border-color: #409EFF;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.right-panel {
|
|
|
|
|
@ -1214,6 +1392,39 @@ export default {
|
|
|
|
|
margin-bottom: 20px;
|
|
|
|
|
background: white;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.preview-modal {
|
|
|
|
|
:deep(.el-dialog__body) {
|
|
|
|
|
padding: 0;
|
|
|
|
|
height: calc(100vh - 54px);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.modal-preview-container {
|
|
|
|
|
height: 100%;
|
|
|
|
|
overflow-y: auto;
|
|
|
|
|
padding: 20px;
|
|
|
|
|
background: white;
|
|
|
|
|
|
|
|
|
|
:deep(table) {
|
|
|
|
|
width: 100%;
|
|
|
|
|
border-collapse: collapse;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
:deep(td) {
|
|
|
|
|
border: 1px solid #000;
|
|
|
|
|
padding: 8px 12px;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.no-preview {
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
align-items: center;
|
|
|
|
|
height: 100%;
|
|
|
|
|
color: #909399;
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
</style>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|