|
@@ -420,8 +420,6 @@ export default {
|
|
async exportDocument(template) {
|
|
async exportDocument(template) {
|
|
try {
|
|
try {
|
|
const templateData = JSON.parse(template.data || "[]");
|
|
const templateData = JSON.parse(template.data || "[]");
|
|
-
|
|
|
|
- // 创建一个临时的容器来存放内容
|
|
|
|
const contentContainer = document.createElement("div");
|
|
const contentContainer = document.createElement("div");
|
|
contentContainer.className = "content";
|
|
contentContainer.className = "content";
|
|
|
|
|
|
@@ -433,6 +431,43 @@ export default {
|
|
// 创建临时div用于处理HTML内容
|
|
// 创建临时div用于处理HTML内容
|
|
const tempDiv = document.createElement("div");
|
|
const tempDiv = document.createElement("div");
|
|
tempDiv.innerHTML = item.content;
|
|
tempDiv.innerHTML = item.content;
|
|
|
|
+
|
|
|
|
+ // 合并嵌套的样式标签
|
|
|
|
+ const mergeStyleTags = (element) => {
|
|
|
|
+ const spans = element.getElementsByTagName('span');
|
|
|
|
+ for (let i = spans.length - 1; i >= 0; i--) {
|
|
|
|
+ const span = spans[i];
|
|
|
|
+ if (span.firstElementChild && span.firstElementChild.tagName === 'SPAN') {
|
|
|
|
+ const childSpan = span.firstElementChild;
|
|
|
|
+ // 合并样式
|
|
|
|
+ const parentStyle = span.getAttribute('style') || '';
|
|
|
|
+ const childStyle = childSpan.getAttribute('style') || '';
|
|
|
|
+
|
|
|
|
+ // 解析样式
|
|
|
|
+ const styleMap = {};
|
|
|
|
+ [...parentStyle.split(';'), ...childStyle.split(';')]
|
|
|
|
+ .filter(s => s.trim())
|
|
|
|
+ .forEach(s => {
|
|
|
|
+ const [key, value] = s.split(':').map(s => s.trim());
|
|
|
|
+ styleMap[key] = value;
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 创建新的样式字符串
|
|
|
|
+ const mergedStyle = Object.entries(styleMap)
|
|
|
|
+ .map(([key, value]) => `${key}: ${value}`)
|
|
|
|
+ .join('; ');
|
|
|
|
+
|
|
|
|
+ // 创建新的span元素
|
|
|
|
+ const newSpan = document.createElement('span');
|
|
|
|
+ newSpan.setAttribute('style', mergedStyle);
|
|
|
|
+ newSpan.innerHTML = childSpan.innerHTML;
|
|
|
|
+
|
|
|
|
+ // 替换原始嵌套标签
|
|
|
|
+ span.parentNode.replaceChild(newSpan, span);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+
|
|
// 处理所有表格
|
|
// 处理所有表格
|
|
tempDiv.querySelectorAll("table").forEach((table) => {
|
|
tempDiv.querySelectorAll("table").forEach((table) => {
|
|
// 检查表格及其单元格是否有任何边框
|
|
// 检查表格及其单元格是否有任何边框
|
|
@@ -466,9 +501,13 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ // 对整个内容进行样式合并
|
|
|
|
+ mergeStyleTags(tempDiv);
|
|
|
|
+
|
|
templateSection.innerHTML = tempDiv.innerHTML;
|
|
templateSection.innerHTML = tempDiv.innerHTML;
|
|
contentContainer.appendChild(templateSection);
|
|
contentContainer.appendChild(templateSection);
|
|
});
|
|
});
|
|
|
|
+
|
|
let contentData = `
|
|
let contentData = `
|
|
<!DOCTYPE html>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<html>
|
|
@@ -478,7 +517,12 @@ export default {
|
|
body {
|
|
body {
|
|
font-family: SimSun, serif;
|
|
font-family: SimSun, serif;
|
|
font-size: 12pt;
|
|
font-size: 12pt;
|
|
- line-height: 1.5;
|
|
|
|
|
|
+ line-height: 12pt !important; /* 设置固定行距为12磅 */
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /* 确保所有段落和文本容器都使用相同的行距 */
|
|
|
|
+ p, div, span, td, th {
|
|
|
|
+ line-height: 12pt !important;
|
|
}
|
|
}
|
|
|
|
|
|
/* 有边框的表格样式 */
|
|
/* 有边框的表格样式 */
|
|
@@ -490,6 +534,7 @@ export default {
|
|
table[data-code="active"] th {
|
|
table[data-code="active"] th {
|
|
border: 1px solid black;
|
|
border: 1px solid black;
|
|
padding: 8px;
|
|
padding: 8px;
|
|
|
|
+ line-height: 12pt !important;
|
|
}
|
|
}
|
|
|
|
|
|
/* 无边框的表格样式 */
|
|
/* 无边框的表格样式 */
|
|
@@ -502,10 +547,12 @@ export default {
|
|
table[data-code="noactive"] th {
|
|
table[data-code="noactive"] th {
|
|
border: none;
|
|
border: none;
|
|
padding: 8px;
|
|
padding: 8px;
|
|
|
|
+ line-height: 12pt !important;
|
|
}
|
|
}
|
|
|
|
|
|
.template-textarea {
|
|
.template-textarea {
|
|
page-break-after: always;
|
|
page-break-after: always;
|
|
|
|
+ line-height: 12pt !important;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|
|
</head>
|
|
</head>
|
|
@@ -773,7 +820,7 @@ export default {
|
|
formatRequestParams(locations) {
|
|
formatRequestParams(locations) {
|
|
const locationArray = Array.isArray(locations) ? locations : [locations];
|
|
const locationArray = Array.isArray(locations) ? locations : [locations];
|
|
|
|
|
|
- // 初始化请求参数对象
|
|
|
|
|
|
+ // 初始化求参数对象
|
|
const params = {
|
|
const params = {
|
|
/* project_id:'', */
|
|
/* project_id:'', */
|
|
template_location: [],
|
|
template_location: [],
|
|
@@ -881,7 +928,7 @@ export default {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
if (_this.docAttr.title == "") {
|
|
if (_this.docAttr.title == "") {
|
|
- _this.$message.error("请填写模版标题");
|
|
|
|
|
|
+ _this.$message.error("请填写模版题");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
_this.docAttr.links = JSON.stringify(_this.docAttr.linkProduct);
|
|
_this.docAttr.links = JSON.stringify(_this.docAttr.linkProduct);
|
|
@@ -960,7 +1007,7 @@ export default {
|
|
async replaceAll() {
|
|
async replaceAll() {
|
|
this.batchReplaceLoading = true;
|
|
this.batchReplaceLoading = true;
|
|
try {
|
|
try {
|
|
- // 收所有匹配
|
|
|
|
|
|
+ // 收所有配
|
|
const allLocations = this.matchResults.map((item) => {
|
|
const allLocations = this.matchResults.map((item) => {
|
|
return item.replace(/[\[\]【】]/g, "");
|
|
return item.replace(/[\[\]【】]/g, "");
|
|
});
|
|
});
|
|
@@ -1117,7 +1164,7 @@ export default {
|
|
// 先获取纯文本内容用于匹配
|
|
// 先获取纯文本内容用于匹配
|
|
const plainText = processNode(tempDiv);
|
|
const plainText = processNode(tempDiv);
|
|
|
|
|
|
- // 构建用于匹配分割标记��正则表达式
|
|
|
|
|
|
+ // 构建用于匹配分割标记的正则表达式
|
|
const splitRegex = new RegExp(
|
|
const splitRegex = new RegExp(
|
|
`(\\[|【)(.*?)(${searchCode})(.*?)(\\]|】)`,
|
|
`(\\[|【)(.*?)(${searchCode})(.*?)(\\]|】)`,
|
|
"g"
|
|
"g"
|
|
@@ -1239,7 +1286,7 @@ export default {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
|
|
|
|
- // 保持原���的图片和文本处理逻辑不变
|
|
|
|
|
|
+ // 保持原有的图片和文本处理逻辑不变
|
|
html = html.replace(
|
|
html = html.replace(
|
|
/\[图片:(.*?)\|style=(.*?)\|class=(.*?)\]/g,
|
|
/\[图片:(.*?)\|style=(.*?)\|class=(.*?)\]/g,
|
|
(match, src, style, className) => {
|
|
(match, src, style, className) => {
|
|
@@ -1279,7 +1326,7 @@ export default {
|
|
this.templateQueryForm.page = page;
|
|
this.templateQueryForm.page = page;
|
|
this.loadTemplateList();
|
|
this.loadTemplateList();
|
|
},
|
|
},
|
|
- // 加载模版���表
|
|
|
|
|
|
+ // 加载模版表
|
|
loadTemplateList() {
|
|
loadTemplateList() {
|
|
this.templateLoading = true;
|
|
this.templateLoading = true;
|
|
searchList(this.templateQueryForm)
|
|
searchList(this.templateQueryForm)
|
|
@@ -1328,7 +1375,7 @@ export default {
|
|
// 如果之前是全选状态,现在取消了某些选择
|
|
// 如果之前是全选状态,现在取消了某些选择
|
|
if (this.isAllSelected && selection.length < this.templateList.length) {
|
|
if (this.isAllSelected && selection.length < this.templateList.length) {
|
|
this.isAllSelected = false;
|
|
this.isAllSelected = false;
|
|
- // 保留其他页面的选择和已绑定的模版
|
|
|
|
|
|
+ // 保留其���页面的选择和已绑定的模版
|
|
const allSelectedIds = new Set(this.currentData.documentIds || []);
|
|
const allSelectedIds = new Set(this.currentData.documentIds || []);
|
|
this.selectedPageIds.forEach((pageIds, page) => {
|
|
this.selectedPageIds.forEach((pageIds, page) => {
|
|
if (page !== currentPage) {
|
|
if (page !== currentPage) {
|
|
@@ -1369,7 +1416,7 @@ export default {
|
|
.catch(() => {
|
|
.catch(() => {
|
|
// 仅选择当前页
|
|
// 仅选择当前页
|
|
this.selectCurrentPage(selection);
|
|
this.selectCurrentPage(selection);
|
|
- // 更���当前页的选择记录
|
|
|
|
|
|
+ // 更当前页的选择记录
|
|
this.selectedPageIds.set(
|
|
this.selectedPageIds.set(
|
|
currentPage,
|
|
currentPage,
|
|
new Set(selection.map((item) => item.id))
|
|
new Set(selection.map((item) => item.id))
|
|
@@ -1411,9 +1458,9 @@ export default {
|
|
// 仅选择当前页
|
|
// 仅选择当前页
|
|
selectCurrentPage(selection) {
|
|
selectCurrentPage(selection) {
|
|
this.isAllSelected = false;
|
|
this.isAllSelected = false;
|
|
- // 清除之前的选择
|
|
|
|
|
|
+ // 清除前的选择
|
|
this.selectedTemplateIds.clear();
|
|
this.selectedTemplateIds.clear();
|
|
- // ��加当前页选中项
|
|
|
|
|
|
+ // 加当前页选中项
|
|
selection.forEach((item) => {
|
|
selection.forEach((item) => {
|
|
this.selectedTemplateIds.add(item.id);
|
|
this.selectedTemplateIds.add(item.id);
|
|
});
|
|
});
|
|
@@ -1600,10 +1647,10 @@ export default {
|
|
})
|
|
})
|
|
.catch((error) => {
|
|
.catch((error) => {
|
|
console.error("获取模版位置信息失败:", error);
|
|
console.error("获取模版位置信息失败:", error);
|
|
- this.$message.error("获取模版位置信息失败");
|
|
|
|
|
|
+ this.$message.error("获取模版位置信��失败");
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- /* 产品分类名称 */
|
|
|
|
|
|
+ /* 产品类别名称 */
|
|
getCategoryTypeName(categoryId) {
|
|
getCategoryTypeName(categoryId) {
|
|
if (!categoryId) return "未分类";
|
|
if (!categoryId) return "未分类";
|
|
const product = this.productList.find((item) => item.id === categoryId);
|
|
const product = this.productList.find((item) => item.id === categoryId);
|