|
@@ -143,35 +143,42 @@
|
|
:visible.sync="templateDialogVisible"
|
|
:visible.sync="templateDialogVisible"
|
|
width="50%"
|
|
width="50%"
|
|
append-to-body
|
|
append-to-body
|
|
|
|
+ :close-on-click-modal="false"
|
|
|
|
+ top="5%"
|
|
>
|
|
>
|
|
|
|
+ <div class="header_t">
|
|
|
|
+ <el-button type="primary" @click="confirmTemplateSelection">确 定</el-button>
|
|
|
|
+ <el-button @click="closeTemplateDialog">取 消</el-button>
|
|
|
|
+ </div>
|
|
<el-table
|
|
<el-table
|
|
- :data="templateList"
|
|
|
|
- style="width: 100%"
|
|
|
|
- @selection-change="handleTemplateSelect"
|
|
|
|
- @select-all="handleSelectAll"
|
|
|
|
ref="templateTable"
|
|
ref="templateTable"
|
|
- >
|
|
|
|
- <el-table-column type="selection" width="55"></el-table-column>
|
|
|
|
|
|
+ :data="templateList"
|
|
|
|
+ @selection-change="handleSelectionChange"
|
|
|
|
+ @select="handleSelect"
|
|
|
|
+ :max-height="600">
|
|
|
|
+ <el-table-column
|
|
|
|
+ type="selection"
|
|
|
|
+ width="55">
|
|
|
|
+ </el-table-column>
|
|
<el-table-column prop="id" label="ID" width="80" align="center" />
|
|
<el-table-column prop="id" label="ID" width="80" align="center" />
|
|
<el-table-column prop="title" label="模版名称" align="left" />
|
|
<el-table-column prop="title" label="模版名称" align="left" />
|
|
<el-table-column prop="create_time" label="创建时间" align="center" />
|
|
<el-table-column prop="create_time" label="创建时间" align="center" />
|
|
</el-table>
|
|
</el-table>
|
|
<div class="pagination-container">
|
|
<div class="pagination-container">
|
|
<el-pagination
|
|
<el-pagination
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
+ @current-change="handleTemplatePageChange"
|
|
:current-page="templateQueryForm.page"
|
|
:current-page="templateQueryForm.page"
|
|
|
|
+ :page-sizes="pageSizes"
|
|
:page-size="templateQueryForm.pageSize"
|
|
:page-size="templateQueryForm.pageSize"
|
|
- :total="templateTotal"
|
|
|
|
- background
|
|
|
|
- layout="prev, pager, next"
|
|
|
|
- @current-change="handleTemplatePageChange"
|
|
|
|
- >
|
|
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
|
+ :total="templateTotal">
|
|
</el-pagination>
|
|
</el-pagination>
|
|
</div>
|
|
</div>
|
|
<div class="dialog-footer" slot="footer">
|
|
<div class="dialog-footer" slot="footer">
|
|
- <el-button @click="templateDialogVisible = false">取 消</el-button>
|
|
|
|
- <el-button type="primary" @click="confirmTemplateSelection"
|
|
|
|
- >确 定</el-button
|
|
|
|
- >
|
|
|
|
|
|
+ <!-- <span style="float: left; line-height: 32px;">
|
|
|
|
+ 已选择 {{ getSelectedCount() }} 项
|
|
|
|
+ </span> -->
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
<el-dialog
|
|
<el-dialog
|
|
@@ -324,8 +331,9 @@ export default {
|
|
return {
|
|
return {
|
|
templateQueryForm: {
|
|
templateQueryForm: {
|
|
page: 1,
|
|
page: 1,
|
|
- pageSize: 10,
|
|
|
|
|
|
+ pageSize: 10, // 默认每页显示10条
|
|
},
|
|
},
|
|
|
|
+ pageSizes: [10, 20, 50, 100], // 每页显示条数选项
|
|
templateTotal: 0, // 模版总数
|
|
templateTotal: 0, // 模版总数
|
|
dialogVisible: false, //控制产品审核
|
|
dialogVisible: false, //控制产品审核
|
|
currentDataId: 0,
|
|
currentDataId: 0,
|
|
@@ -353,12 +361,13 @@ export default {
|
|
selectedBoundTemplates: [], // 新增:已选择的绑定模版
|
|
selectedBoundTemplates: [], // 新增:已选择的绑定模版
|
|
batchReplaceLoading: false, // 新增:批量替换loading状态
|
|
batchReplaceLoading: false, // 新增:批量替换loading状态
|
|
getstatusList: [], //状态列表
|
|
getstatusList: [], //状态列表
|
|
- customList: [], //客户列��
|
|
|
|
|
|
+ customList: [], //客户列表
|
|
productList: [], //产品列表
|
|
productList: [], //产品列表
|
|
currentPhaseList: [], //阶段列表
|
|
currentPhaseList: [], //阶段列表
|
|
- selectedTemplateIds: new Set(), // 新增: 用于存储所有已选择的模版ID
|
|
|
|
- isAllSelected: false, // 新增: 标记是否全选所有页
|
|
|
|
- selectedPageIds: new Map(), // 新增: 存储每页选中的ID
|
|
|
|
|
|
+ selectedTemplateIds: new Set(), // 存储所有选中的模板ID
|
|
|
|
+ selectedPageIds: new Map(), // 存储每页的选择状态
|
|
|
|
+ isAllSelected: false, // 是否全选
|
|
|
|
+ selectionCache: new Map(), // 添加选择缓存
|
|
};
|
|
};
|
|
},
|
|
},
|
|
mounted() {
|
|
mounted() {
|
|
@@ -444,7 +453,7 @@ export default {
|
|
page-break-inside: avoid !important;
|
|
page-break-inside: avoid !important;
|
|
}
|
|
}
|
|
|
|
|
|
- /* 表格单元格样式 */
|
|
|
|
|
|
+ /* 表格单元样 */
|
|
table[data-border="true"] td,
|
|
table[data-border="true"] td,
|
|
table[data-border="true"] th,
|
|
table[data-border="true"] th,
|
|
.table-with-border td,
|
|
.table-with-border td,
|
|
@@ -799,7 +808,7 @@ export default {
|
|
return hasCellBorder && !hasNoBorderMark;
|
|
return hasCellBorder && !hasNoBorderMark;
|
|
},
|
|
},
|
|
|
|
|
|
- // 添加处理分页的辅助方法
|
|
|
|
|
|
+ // 添加处理分��的辅助方法
|
|
addPageBreaks(content) {
|
|
addPageBreaks(content) {
|
|
// 查找需要分页的位置(可以根据实际需求调整)
|
|
// 查找需要分页的位置(可以根据实际需求调整)
|
|
const pageBreakMarkers = ["<h1", "<h2", "<!-- pagebreak -->"];
|
|
const pageBreakMarkers = ["<h1", "<h2", "<!-- pagebreak -->"];
|
|
@@ -925,7 +934,7 @@ export default {
|
|
// 生成表格样式
|
|
// 生成表格样式
|
|
generateTableStyles() {
|
|
generateTableStyles() {
|
|
return `
|
|
return `
|
|
- /* 原有表格样式保持不变 */
|
|
|
|
|
|
+ /* 原有表��样式保持不变 */
|
|
.table-with-border {
|
|
.table-with-border {
|
|
/* ... */
|
|
/* ... */
|
|
}
|
|
}
|
|
@@ -1425,7 +1434,7 @@ export default {
|
|
// 清理URL对象
|
|
// 清理URL对象
|
|
URL.revokeObjectURL(link.href);
|
|
URL.revokeObjectURL(link.href);
|
|
|
|
|
|
- this.$message.success("转换成功");
|
|
|
|
|
|
+ this.$message.success("转换��功");
|
|
} else {
|
|
} else {
|
|
throw new Error(res.data.message || "转换失败");
|
|
throw new Error(res.data.message || "转换失败");
|
|
}
|
|
}
|
|
@@ -1446,7 +1455,7 @@ export default {
|
|
const templateSection = document.createElement("div");
|
|
const templateSection = document.createElement("div");
|
|
templateSection.className = "template-textarea";
|
|
templateSection.className = "template-textarea";
|
|
|
|
|
|
- // 创��临时div用于处理HTML内容
|
|
|
|
|
|
+ // 创建临时div用于处理HTML内容
|
|
const tempDiv = document.createElement("div");
|
|
const tempDiv = document.createElement("div");
|
|
tempDiv.innerHTML = item.content;
|
|
tempDiv.innerHTML = item.content;
|
|
|
|
|
|
@@ -1771,7 +1780,7 @@ export default {
|
|
this.selTemplate(this.currentData); */
|
|
this.selTemplate(this.currentData); */
|
|
/* }); */
|
|
/* }); */
|
|
},
|
|
},
|
|
- // 新增:处理已绑定模版的选择
|
|
|
|
|
|
+ // 新增:处理已选定模版的选择
|
|
handleBoundTemplateSelect(selection) {
|
|
handleBoundTemplateSelect(selection) {
|
|
this.selectedBoundTemplates = selection;
|
|
this.selectedBoundTemplates = selection;
|
|
},
|
|
},
|
|
@@ -1852,7 +1861,7 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
- // 添加��的辅助方法来判断文档类型
|
|
|
|
|
|
+ // 添加的辅助方法来判断文档类型
|
|
getDocumentType(code) {
|
|
getDocumentType(code) {
|
|
if (code.includes("-RP-")) return "template_location";
|
|
if (code.includes("-RP-")) return "template_location";
|
|
if (code.includes("-IR-")) return "middle_layer_location";
|
|
if (code.includes("-IR-")) return "middle_layer_location";
|
|
@@ -2351,165 +2360,261 @@ export default {
|
|
/* 选择模版 */
|
|
/* 选择模版 */
|
|
selTemplate(row) {
|
|
selTemplate(row) {
|
|
this.currentData = row;
|
|
this.currentData = row;
|
|
- this.selectedTemplates = []; // 重置选择
|
|
|
|
- this.selectedTemplateIds = new Set(row.documentIds || []); // 初始化已绑定的模版ID
|
|
|
|
- this.templateQueryForm.page = 1; // 重置码
|
|
|
|
|
|
+
|
|
|
|
+ // 重置所有状态
|
|
|
|
+ this.selectedTemplateIds = new Set(row.documentIds || []);
|
|
|
|
+ this.selectedPageIds = new Map();
|
|
|
|
+ this.selectionCache = new Map();
|
|
|
|
+ this.isAllSelected = false;
|
|
|
|
+ this.templateQueryForm.page = 1;
|
|
|
|
+
|
|
|
|
+ // 加载模板列表
|
|
this.loadTemplateList();
|
|
this.loadTemplateList();
|
|
},
|
|
},
|
|
// 处理模版分页变化
|
|
// 处理模版分页变化
|
|
- handleTemplatePageChange(page) {
|
|
|
|
- // 保存当前页的选择状态
|
|
|
|
- const currentSelection = this.$refs.templateTable.selection;
|
|
|
|
- if (currentSelection.length > 0) {
|
|
|
|
- this.selectedPageIds.set(
|
|
|
|
- this.templateQueryForm.page,
|
|
|
|
- new Set(currentSelection.map((item) => item.id))
|
|
|
|
- );
|
|
|
|
- }
|
|
|
|
|
|
+ async handleTemplatePageChange(page) {
|
|
|
|
+ try {
|
|
|
|
+ // 保存当前页的选择状态
|
|
|
|
+ const currentPage = this.templateQueryForm.page;
|
|
|
|
+ const currentSelection = this.$refs.templateTable?.selection || [];
|
|
|
|
+
|
|
|
|
+ // 更新选择缓存
|
|
|
|
+ this.selectionCache.set(currentPage, new Set(currentSelection.map(row => row.id)));
|
|
|
|
+
|
|
|
|
+ // 更新全局选择状态
|
|
|
|
+ currentSelection.forEach(row => {
|
|
|
|
+ this.selectedTemplateIds.add(row.id);
|
|
|
|
+ });
|
|
|
|
|
|
- this.templateQueryForm.page = page;
|
|
|
|
- this.loadTemplateList();
|
|
|
|
|
|
+ // 更新页码
|
|
|
|
+ this.templateQueryForm.page = page;
|
|
|
|
+
|
|
|
|
+ // 加载新页面数据
|
|
|
|
+ await this.loadTemplateList();
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('页面切换失败:', error);
|
|
|
|
+ this.$message.error('页面切换失败');
|
|
|
|
+ }
|
|
},
|
|
},
|
|
// 加载模版表
|
|
// 加载模版表
|
|
- loadTemplateList() {
|
|
|
|
|
|
+ async loadTemplateList() {
|
|
this.templateLoading = true;
|
|
this.templateLoading = true;
|
|
- searchList(this.templateQueryForm)
|
|
|
|
- .then((res) => {
|
|
|
|
- if (res.status === 200) {
|
|
|
|
- this.templateList = res.data.dataList;
|
|
|
|
- this.templateTotal = res.data.totalRecord;
|
|
|
|
- this.templateDialogVisible = true;
|
|
|
|
|
|
+ try {
|
|
|
|
+ const res = await searchList(this.templateQueryForm);
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ this.templateList = res.data.dataList;
|
|
|
|
+ this.templateTotal = res.data.totalRecord;
|
|
|
|
+ this.templateDialogVisible = true;
|
|
|
|
|
|
|
|
+ // 等待 DOM 更新
|
|
|
|
+ await this.$nextTick();
|
|
|
|
+
|
|
|
|
+ if (this.$refs.templateTable) {
|
|
|
|
+ // 清除当前选择
|
|
|
|
+ this.$refs.templateTable.clearSelection();
|
|
|
|
+
|
|
// 恢复选中状态
|
|
// 恢复选中状态
|
|
- this.$nextTick(() => {
|
|
|
|
- const currentPage = this.templateQueryForm.page;
|
|
|
|
- const currentPageSelected = this.selectedPageIds.get(currentPage);
|
|
|
|
-
|
|
|
|
- this.templateList.forEach((row) => {
|
|
|
|
- const shouldSelect =
|
|
|
|
- this.isAllSelected ||
|
|
|
|
- (currentPageSelected && currentPageSelected.has(row.id)) ||
|
|
|
|
- this.selectedTemplateIds.has(row.id) ||
|
|
|
|
- (this.currentData.documentIds &&
|
|
|
|
- this.currentData.documentIds.includes(row.id));
|
|
|
|
-
|
|
|
|
- if (shouldSelect) {
|
|
|
|
- this.$refs.templateTable.toggleRowSelection(row, true);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
|
|
+ this.restoreSelectionState();
|
|
}
|
|
}
|
|
- })
|
|
|
|
- .finally(() => {
|
|
|
|
- this.templateLoading = false;
|
|
|
|
- });
|
|
|
|
|
|
+ }
|
|
|
|
+ } catch (error) {
|
|
|
|
+ console.error('加载模板列表失败:', error);
|
|
|
|
+ this.$message.error('加载模板列表失败');
|
|
|
|
+ } finally {
|
|
|
|
+ this.templateLoading = false;
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
- handleTemplateSelect(selection) {
|
|
|
|
|
|
+ // 添加新方法:恢复选择状态
|
|
|
|
+ restoreSelectionState() {
|
|
const currentPage = this.templateQueryForm.page;
|
|
const currentPage = this.templateQueryForm.page;
|
|
- const currentPageIds = selection.map((item) => item.id);
|
|
|
|
|
|
+
|
|
|
|
+ // 遍历当前页数据
|
|
|
|
+ this.templateList.forEach(row => {
|
|
|
|
+ // 检查是否在全局选中集合中
|
|
|
|
+ if (this.selectedTemplateIds.has(row.id)) {
|
|
|
|
+ this.$refs.templateTable.toggleRowSelection(row, true, false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
|
|
- // 更新当前页的选择状态
|
|
|
|
- if (currentPageIds.length > 0) {
|
|
|
|
- this.selectedPageIds.set(currentPage, new Set(currentPageIds));
|
|
|
|
- } else {
|
|
|
|
- this.selectedPageIds.delete(currentPage);
|
|
|
|
|
|
+ // 更新当前页的选择记录
|
|
|
|
+ const selectedRows = this.templateList.filter(row =>
|
|
|
|
+ this.selectedTemplateIds.has(row.id)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 更新选择缓存
|
|
|
|
+ this.selectionCache.set(currentPage, new Set(selectedRows.map(row => row.id)));
|
|
|
|
+
|
|
|
|
+ // 检查当前页是否全选
|
|
|
|
+ const isCurrentPageAllSelected = this.templateList.every(row =>
|
|
|
|
+ this.selectedTemplateIds.has(row.id)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 更新表头的全选框状态
|
|
|
|
+ if (this.$refs.templateTable.store) {
|
|
|
|
+ this.$refs.templateTable.store.states.isAllSelected = isCurrentPageAllSelected;
|
|
}
|
|
}
|
|
|
|
|
|
- // 如果之前是全选状态,现在取消了某些选择
|
|
|
|
- if (this.isAllSelected && selection.length < this.templateList.length) {
|
|
|
|
- this.isAllSelected = false;
|
|
|
|
- // 保留其页面的选择和已绑定的模版
|
|
|
|
- const allSelectedIds = new Set(this.currentData.documentIds || []);
|
|
|
|
- this.selectedPageIds.forEach((pageIds, page) => {
|
|
|
|
- if (page !== currentPage) {
|
|
|
|
- pageIds.forEach((id) => allSelectedIds.add(id));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- // 添加当前页选中的ID
|
|
|
|
- currentPageIds.forEach((id) => allSelectedIds.add(id));
|
|
|
|
- this.selectedTemplateIds = allSelectedIds;
|
|
|
|
- } else {
|
|
|
|
- // 正常选择模式,保留已绑定的模版
|
|
|
|
- const existingIds = new Set(this.currentData.documentIds || []);
|
|
|
|
- this.templateList.forEach((item) => {
|
|
|
|
- if (currentPageIds.includes(item.id)) {
|
|
|
|
- this.selectedTemplateIds.add(item.id);
|
|
|
|
- } else if (!existingIds.has(item.id)) {
|
|
|
|
- // 只删除非已绑定的模版
|
|
|
|
- this.selectedTemplateIds.delete(item.id);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
|
|
+ // 触发选择变化事件
|
|
|
|
+ this.handleSelectionChange(selectedRows);
|
|
},
|
|
},
|
|
|
|
|
|
- // 处理全选按点击
|
|
|
|
- handleSelectAll(selection) {
|
|
|
|
|
|
+ // 修改 handleSelectionChange 方法
|
|
|
|
+ handleSelectionChange(selection) {
|
|
|
|
+ if (!Array.isArray(selection)) {
|
|
|
|
+ console.warn('Invalid selection:', selection);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
const currentPage = this.templateQueryForm.page;
|
|
const currentPage = this.templateQueryForm.page;
|
|
|
|
+
|
|
|
|
+ // 更新选择缓存
|
|
|
|
+ this.selectionCache.set(currentPage, new Set(selection.map(row => row.id)));
|
|
|
|
+
|
|
|
|
+ // 更新全局选择状态
|
|
|
|
+ const currentPageIds = new Set(this.templateList.map(row => row.id));
|
|
|
|
+
|
|
|
|
+ // 移除当前页未选中的项
|
|
|
|
+ currentPageIds.forEach(id => {
|
|
|
|
+ if (!selection.some(row => row.id === id)) {
|
|
|
|
+ this.selectedTemplateIds.delete(id);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 添加当前页选中的项
|
|
|
|
+ selection.forEach(row => {
|
|
|
|
+ this.selectedTemplateIds.add(row.id);
|
|
|
|
+ });
|
|
|
|
|
|
- if (selection.length > 0) {
|
|
|
|
- this.$confirm("是否选择所有页的模版?", "提示", {
|
|
|
|
- confirmButtonText: "全部选择",
|
|
|
|
- cancelButtonText: "仅选择当前页",
|
|
|
|
- type: "info",
|
|
|
|
- })
|
|
|
|
- .then(() => {
|
|
|
|
- // 选择所有页
|
|
|
|
- this.selectAllPages();
|
|
|
|
- })
|
|
|
|
- .catch(() => {
|
|
|
|
- // 仅选择当前页
|
|
|
|
- this.selectCurrentPage(selection);
|
|
|
|
- // 更当前页的选择记录
|
|
|
|
- this.selectedPageIds.set(
|
|
|
|
- currentPage,
|
|
|
|
- new Set(selection.map((item) => item.id))
|
|
|
|
- );
|
|
|
|
- });
|
|
|
|
|
|
+ // 更新全选状态
|
|
|
|
+ this.isAllSelected = this.templateList.length > 0 &&
|
|
|
|
+ this.templateList.every(row => this.selectedTemplateIds.has(row.id));
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ handleSelect(selection, row) {
|
|
|
|
+ if (!row || typeof row.id === 'undefined') {
|
|
|
|
+ console.warn('Invalid row data:', row);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ const currentPage = this.templateQueryForm.page;
|
|
|
|
+ const isSelected = selection.some(item => item.id === row.id);
|
|
|
|
+
|
|
|
|
+ if (isSelected) {
|
|
|
|
+ this.selectedTemplateIds.add(row.id);
|
|
|
|
+ // 更新当前页选择记录
|
|
|
|
+ const currentPageSelected = this.selectedPageIds.get(currentPage) || new Set();
|
|
|
|
+ currentPageSelected.add(row.id);
|
|
|
|
+ this.selectedPageIds.set(currentPage, currentPageSelected);
|
|
} else {
|
|
} else {
|
|
- // 取消全选
|
|
|
|
|
|
+ this.selectedTemplateIds.delete(row.id);
|
|
|
|
+ // 更新当前页选择记录
|
|
|
|
+ const currentPageSelected = this.selectedPageIds.get(currentPage);
|
|
|
|
+ if (currentPageSelected) {
|
|
|
|
+ currentPageSelected.delete(row.id);
|
|
|
|
+ }
|
|
|
|
+ // 取消全选状态
|
|
this.isAllSelected = false;
|
|
this.isAllSelected = false;
|
|
- this.selectedTemplateIds.clear();
|
|
|
|
- this.selectedPageIds.clear();
|
|
|
|
- this.$refs.templateTable.clearSelection();
|
|
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- // 选择所有页
|
|
|
|
- async selectAllPages() {
|
|
|
|
- this.isAllSelected = true;
|
|
|
|
- this.selectedTemplateIds.clear();
|
|
|
|
|
|
+ // 修改加载方法
|
|
|
|
+ loadTemplateList() {
|
|
|
|
+ this.templateLoading = true;
|
|
|
|
+ searchList(this.templateQueryForm)
|
|
|
|
+ .then((res) => {
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ this.templateList = res.data.dataList;
|
|
|
|
+ this.templateTotal = res.data.totalRecord;
|
|
|
|
+ this.templateDialogVisible = true;
|
|
|
|
+
|
|
|
|
+ // 在数据加载完成后设置选中状态
|
|
|
|
+ this.$nextTick(() => {
|
|
|
|
+ if (this.$refs.templateTable) {
|
|
|
|
+ // 清除当前选择
|
|
|
|
+ this.$refs.templateTable.clearSelection();
|
|
|
|
+
|
|
|
|
+ // 遍历当前页数据,根据 selectedTemplateIds 设置选中状态
|
|
|
|
+ this.templateList.forEach(row => {
|
|
|
|
+ if (this.selectedTemplateIds.has(row.id)) {
|
|
|
|
+ this.$refs.templateTable.toggleRowSelection(row, true);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新当前页的选择记录
|
|
|
|
+ const currentPage = this.templateQueryForm.page;
|
|
|
|
+ const currentPageSelected = new Set(
|
|
|
|
+ this.templateList
|
|
|
|
+ .filter(row => this.selectedTemplateIds.has(row.id))
|
|
|
|
+ .map(row => row.id)
|
|
|
|
+ );
|
|
|
|
+ this.selectedPageIds.set(currentPage, currentPageSelected);
|
|
|
|
+
|
|
|
|
+ // 检查当前页是否全选
|
|
|
|
+ const isCurrentPageAllSelected = this.templateList.every(row =>
|
|
|
|
+ this.selectedTemplateIds.has(row.id)
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ // 更新表头的全选框状态
|
|
|
|
+ if (this.$refs.templateTable.store) {
|
|
|
|
+ this.$refs.templateTable.store.states.isAllSelected = isCurrentPageAllSelected;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 触发选择变化事件以更新UI
|
|
|
|
+ this.handleSelectionChange(
|
|
|
|
+ this.templateList.filter(row => this.selectedTemplateIds.has(row.id))
|
|
|
|
+ );
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ .catch(error => {
|
|
|
|
+ console.error('加载模板列表失败:', error);
|
|
|
|
+ this.$message.error('加载模板列表失败');
|
|
|
|
+ })
|
|
|
|
+ .finally(() => {
|
|
|
|
+ this.templateLoading = false;
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
|
|
- // 获取所有模版ID
|
|
|
|
|
|
+ // 修改选择所有页方法
|
|
|
|
+ async selectAllPages() {
|
|
try {
|
|
try {
|
|
|
|
+ this.isAllSelected = true;
|
|
const allTemplates = await this.getAllTemplates();
|
|
const allTemplates = await this.getAllTemplates();
|
|
- allTemplates.forEach((template) => {
|
|
|
|
|
|
+
|
|
|
|
+ // 清除之前的选择
|
|
|
|
+ this.selectedTemplateIds.clear();
|
|
|
|
+ this.selectedPageIds.clear();
|
|
|
|
+
|
|
|
|
+ // 添加所有模板ID到选择集合
|
|
|
|
+ allTemplates.forEach(template => {
|
|
this.selectedTemplateIds.add(template.id);
|
|
this.selectedTemplateIds.add(template.id);
|
|
});
|
|
});
|
|
|
|
|
|
- // 选中当前页显示的所有行
|
|
|
|
- this.templateList.forEach((row) => {
|
|
|
|
- this.$refs.templateTable.toggleRowSelection(row, true);
|
|
|
|
- });
|
|
|
|
|
|
+ // 更新当前页显示
|
|
|
|
+ if (this.$refs.templateTable) {
|
|
|
|
+ this.$refs.templateTable.clearSelection();
|
|
|
|
+ this.templateList.forEach(row => {
|
|
|
|
+ this.$refs.templateTable.toggleRowSelection(row, true);
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 更新当前页的选择记录
|
|
|
|
+ const currentPage = this.templateQueryForm.page;
|
|
|
|
+ this.selectedPageIds.set(
|
|
|
|
+ currentPage,
|
|
|
|
+ new Set(this.templateList.map(row => row.id))
|
|
|
|
+ );
|
|
|
|
|
|
this.$message.success(`已选择全部 ${this.templateTotal} 条数据`);
|
|
this.$message.success(`已选择全部 ${this.templateTotal} 条数据`);
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- console.error("获取所有模版失败:", error);
|
|
|
|
- this.$message.error("获取所有模版失败");
|
|
|
|
|
|
+ console.error('选择所有页失败:', error);
|
|
|
|
+ this.$message.error('选择所有页失败');
|
|
|
|
+ this.isAllSelected = false;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
|
|
- // 仅选择当前页
|
|
|
|
- selectCurrentPage(selection) {
|
|
|
|
- this.isAllSelected = false;
|
|
|
|
- // 清除前的选择
|
|
|
|
- this.selectedTemplateIds.clear();
|
|
|
|
- // 加当前页选中项
|
|
|
|
- selection.forEach((item) => {
|
|
|
|
- this.selectedTemplateIds.add(item.id);
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
-
|
|
|
|
// 获取有模版数据
|
|
// 获取有模版数据
|
|
async getAllTemplates() {
|
|
async getAllTemplates() {
|
|
const pageSize = 999; // 使用较大的页码一次性获取
|
|
const pageSize = 999; // 使用较大的页码一次性获取
|
|
@@ -2537,29 +2642,36 @@ export default {
|
|
this.$message.warning("请至少选择一个模版");
|
|
this.$message.warning("请至少选择一个模版");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- // 合并已有的文档ID和新选择的ID
|
|
|
|
- const allDocIds = new Set([
|
|
|
|
- ...(this.currentData.documentIds || []),
|
|
|
|
- ...this.selectedTemplateIds,
|
|
|
|
- ]);
|
|
|
|
|
|
+
|
|
|
|
+ // 转换Set为数组
|
|
|
|
+ const selectedIds = Array.from(this.selectedTemplateIds);
|
|
|
|
+
|
|
relate({
|
|
relate({
|
|
project_id: this.currentData.id,
|
|
project_id: this.currentData.id,
|
|
- doc_ids: JSON.stringify([...allDocIds]),
|
|
|
|
|
|
+ doc_ids: JSON.stringify(selectedIds),
|
|
}).then((res) => {
|
|
}).then((res) => {
|
|
- if (res.status !== 200) return;
|
|
|
|
- this.$message.success("模版关联成功");
|
|
|
|
- this.closeTemplateDialog();
|
|
|
|
- this.search();
|
|
|
|
|
|
+ if (res.status === 200) {
|
|
|
|
+ this.$message.success("模版关联成功");
|
|
|
|
+ this.closeTemplateDialog();
|
|
|
|
+ // 更新当前数据的documentIds
|
|
|
|
+ this.currentData.documentIds = selectedIds;
|
|
|
|
+ this.search();
|
|
|
|
+ }
|
|
});
|
|
});
|
|
},
|
|
},
|
|
|
|
|
|
// 关对话框
|
|
// 关对话框
|
|
closeTemplateDialog() {
|
|
closeTemplateDialog() {
|
|
this.templateDialogVisible = false;
|
|
this.templateDialogVisible = false;
|
|
|
|
+ // 清除所有缓存
|
|
this.selectedTemplateIds.clear();
|
|
this.selectedTemplateIds.clear();
|
|
this.selectedPageIds.clear();
|
|
this.selectedPageIds.clear();
|
|
|
|
+ this.selectionCache.clear();
|
|
this.isAllSelected = false;
|
|
this.isAllSelected = false;
|
|
- this.$refs.templateTable.clearSelection();
|
|
|
|
|
|
+
|
|
|
|
+ if (this.$refs.templateTable) {
|
|
|
|
+ this.$refs.templateTable.clearSelection();
|
|
|
|
+ }
|
|
},
|
|
},
|
|
|
|
|
|
// 输入项目
|
|
// 输入项目
|
|
@@ -2779,7 +2891,7 @@ export default {
|
|
this.pageTotal = res.data.totalPage;
|
|
this.pageTotal = res.data.totalPage;
|
|
} catch (err) {
|
|
} catch (err) {
|
|
console.error("搜索失败:", err);
|
|
console.error("搜索失败:", err);
|
|
- this.$message.error("获取项目列表失");
|
|
|
|
|
|
+ this.$message.error("获取项目列表失败");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
//修改分页
|
|
//修改分页
|
|
@@ -3051,7 +3163,7 @@ export default {
|
|
this.$message.success("导出成功");
|
|
this.$message.success("导出成功");
|
|
return res.data; // 返回结果,包含 file_path
|
|
return res.data; // 返回结果,包含 file_path
|
|
} catch (error) {
|
|
} catch (error) {
|
|
- console.error("导出PDF败:", error);
|
|
|
|
|
|
+ console.error("导出PDF失败:", error);
|
|
this.$alert("导出PDF时发生错误,请稍后重试。");
|
|
this.$alert("导出PDF时发生错误,请稍后重试。");
|
|
}
|
|
}
|
|
},
|
|
},
|
|
@@ -3106,6 +3218,28 @@ export default {
|
|
});
|
|
});
|
|
return tempDiv.innerHTML;
|
|
return tempDiv.innerHTML;
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ // 添加一个方法来显示选中数量
|
|
|
|
+ getSelectedCount() {
|
|
|
|
+ return this.selectedTemplateIds.size;
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+ // 添加处理每页条数变化的方法
|
|
|
|
+ handleSizeChange(val) {
|
|
|
|
+ // 保存当前的选择状态
|
|
|
|
+ const currentSelection = this.$refs.templateTable?.selection || [];
|
|
|
|
+ currentSelection.forEach(row => {
|
|
|
|
+ this.selectedTemplateIds.add(row.id);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ // 更新每页显示条数
|
|
|
|
+ this.templateQueryForm.pageSize = val;
|
|
|
|
+ // 重置为第一页
|
|
|
|
+ this.templateQueryForm.page = 1;
|
|
|
|
+
|
|
|
|
+ // 重新加载数据
|
|
|
|
+ this.loadTemplateList();
|
|
|
|
+ },
|
|
},
|
|
},
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -3168,4 +3302,13 @@ export default {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+.header_t{
|
|
|
|
+ margin: 10px 0;
|
|
|
|
+}
|
|
|
|
+/* 添加分页样式 */
|
|
|
|
+.pagination-container {
|
|
|
|
+ margin-top: 15px;
|
|
|
|
+ padding: 10px 0;
|
|
|
|
+ text-align: right;
|
|
|
|
+}
|
|
</style>
|
|
</style>
|