From 313fe64475957651898ebbb0f70fca67da02412f Mon Sep 17 00:00:00 2001 From: RISE Date: Thu, 22 Jan 2026 13:38:10 +0800 Subject: [PATCH] add fiel --- scripts/add-table-column-control.js | 224 +++++++++ src/components/RightToolbar/index.vue | 21 +- .../TableColumnControl/INTEGRATION_GUIDE.md | 272 ++++++++++ .../TableColumnControl/QUICK_START.md | 293 +++++++++++ src/components/TableColumnControl/README.md | 69 ++- src/components/TableColumnControl/index.vue | 470 ++++++++++++++---- src/composables/useTableColumnControl.ts | 160 ++++++ src/layout/navMenu/subItem.vue | 2 +- src/utils/tableColumnControlHelper.ts | 157 ++++++ src/views/basic/basicclass/index.vue | 199 ++++++-- src/views/basic/basicstudent/index.vue | 263 ++++++---- src/views/basic/basicstudentavatar/index.vue | 158 +++++- src/views/stuwork/activityawards/form.vue | 3 - src/views/stuwork/activityawards/index.vue | 179 +++++-- src/views/stuwork/activityinfo/form.vue | 1 - src/views/stuwork/activityinfo/index.vue | 172 +++++-- src/views/stuwork/activityinfosub/index.vue | 181 +++++-- .../stuwork/activityinfosubsignup/index.vue | 195 ++++++-- src/views/stuwork/assessmentcategory/form.vue | 1 - .../stuwork/assessmentcategory/index.vue | 155 +++++- src/views/stuwork/assessmentpoint/form.vue | 2 - src/views/stuwork/assessmentpoint/index.vue | 169 +++++-- src/views/stuwork/classactivity/form.vue | 3 - src/views/stuwork/classactivity/index.vue | 213 +++++--- .../stuwork/classassessmentsettle/detail.vue | 1 - .../stuwork/classassessmentsettle/form.vue | 3 - .../stuwork/classassessmentsettle/index.vue | 156 +++++- src/views/stuwork/classattendance/index.vue | 215 +++++--- src/views/stuwork/classcheckdaily/detail.vue | 1 - src/views/stuwork/classcheckdaily/form.vue | 3 - src/views/stuwork/classcheckdaily/index.vue | 184 +++++-- .../stuwork/classconstruction/fileList.vue | 1 - src/views/stuwork/classconstruction/index.vue | 171 +++++-- src/views/stuwork/classfeelog/form.vue | 4 - src/views/stuwork/classfeelog/index.vue | 218 +++++--- src/views/stuwork/classhonor/belong.vue | 2 - src/views/stuwork/classhonor/form.vue | 1 - src/views/stuwork/classhonor/index.vue | 290 +++++++---- .../stuwork/classhygienedaily/detail.vue | 1 - src/views/stuwork/classhygienedaily/form.vue | 2 - src/views/stuwork/classhygienedaily/index.vue | 169 +++++-- .../classhygienedailyanalysis/detail.vue | 1 - .../classhygienedailyanalysis/form.vue | 4 - .../classhygienedailyanalysis/index.vue | 211 ++++++-- src/views/stuwork/classleaveapply/detail.vue | 5 - src/views/stuwork/classleaveapply/form.vue | 5 - src/views/stuwork/classleaveapply/index.vue | 278 ++++++----- .../stuwork/classmasterevaluation/detail.vue | 1 - .../stuwork/classmasterevaluation/form.vue | 4 - .../stuwork/classmasterevaluation/index.vue | 270 +++++++--- .../classmasterevaluationappeal/index.vue | 212 +++++--- .../stuwork/classmasterresume/detail.vue | 1 - src/views/stuwork/classmasterresume/form.vue | 3 - src/views/stuwork/classmasterresume/index.vue | 164 ++++-- src/views/stuwork/classpaper/detail.vue | 2 - src/views/stuwork/classpaper/form.vue | 1 - src/views/stuwork/classpaper/index.vue | 287 ++++++++--- src/views/stuwork/classplan/index.vue | 257 +++++++--- src/views/stuwork/classpublicity/belong.vue | 2 - src/views/stuwork/classpublicity/form.vue | 1 - src/views/stuwork/classpublicity/index.vue | 280 ++++++++--- src/views/stuwork/classroombase/arrange.vue | 3 - src/views/stuwork/classroombase/index.vue | 301 +++++++---- .../stuwork/classroomhygienedaily/detail.vue | 1 - .../stuwork/classroomhygienedaily/form.vue | 3 - .../stuwork/classroomhygienedaily/index.vue | 171 +++++-- .../classroomhygienedailyanalysis/index.vue | 211 ++++++-- .../classroomhygienemonthly/detail.vue | 1 - .../stuwork/classroomhygienemonthly/form.vue | 2 - .../stuwork/classroomhygienemonthly/index.vue | 426 ++++++++++++---- src/views/stuwork/classsafeedu/detail.vue | 2 - src/views/stuwork/classsafeedu/form.vue | 1 - src/views/stuwork/classsafeedu/index.vue | 206 +++++--- src/views/stuwork/classsummary/detail.vue | 3 - src/views/stuwork/classsummary/form.vue | 1 - src/views/stuwork/classsummary/index.vue | 268 ++++++---- src/views/stuwork/classtheme/index.vue | 236 +++++++-- src/views/stuwork/classtheme/init.vue | 4 - src/views/stuwork/classtheme/record.vue | 1 - .../stuwork/dormbuilding/emptyRoomDialog.vue | 1 - src/views/stuwork/dormbuilding/index.vue | 406 ++++++++++----- .../stuwork/dormbuildingmanger/index.vue | 196 +++++++- src/views/stuwork/dormhygienedaily/form.vue | 1 - src/views/stuwork/dormhygienedaily/index.vue | 227 +++++++-- src/views/stuwork/dormliveapply/form.vue | 2 - src/views/stuwork/dormliveapply/index.vue | 184 +++++-- src/views/stuwork/dormreform/index.vue | 238 ++++++--- src/views/stuwork/dormroom/form.vue | 3 - src/views/stuwork/dormroom/index.vue | 234 +++++++-- .../stuwork/dormroomstudent/dormabnormal.vue | 1 - src/views/stuwork/dormroomstudent/form.vue | 4 - src/views/stuwork/dormroomstudent/index.vue | 278 +++++++---- .../stuwork/dormroomstudent/transfer.vue | 2 - .../stuwork/dormroomstudentchange/index.vue | 284 +++++++---- src/views/stuwork/entrancerule/index.vue | 195 ++++++-- src/views/stuwork/pendingwork/index.vue | 235 +++++++-- src/views/stuwork/rewardclass/form.vue | 2 - src/views/stuwork/rewardclass/index.vue | 190 +++++-- src/views/stuwork/rewarddorm/form.vue | 2 - src/views/stuwork/rewarddorm/index.vue | 174 +++++-- src/views/stuwork/rewardrule/form.vue | 2 - src/views/stuwork/rewardrule/index.vue | 158 +++++- src/views/stuwork/rewardstudent/index.vue | 283 +++++++---- src/views/stuwork/stipendstu/examIndex.vue | 4 - src/views/stuwork/stipendstu/form.vue | 5 - src/views/stuwork/stipendtermbatch/form.vue | 5 - src/views/stuwork/stipendtermbatch/index.vue | 211 +++++--- src/views/stuwork/stuassociation/form.vue | 4 - src/views/stuwork/stuassociation/index.vue | 272 +++++++--- src/views/stuwork/stuassociation/member.vue | 1 - src/views/stuwork/stucare/form.vue | 3 - src/views/stuwork/stucare/index.vue | 287 +++++++---- src/views/stuwork/stucare/result.vue | 1 - src/views/stuwork/stuconduct/form.vue | 5 - src/views/stuwork/stuconduct/index.vue | 294 +++++++---- src/views/stuwork/stuconduct/indexTerm.vue | 4 - src/views/stuwork/stuconduct/indexYear.vue | 3 - .../stuwork/stuinnerleaveapplygroup/form.vue | 4 - .../stuwork/stuinnerleaveapplygroup/index.vue | 165 +++++- src/views/stuwork/stuleaveapply/form.vue | 4 - src/views/stuwork/stuleaveapply/index.vue | 397 +++++++++------ src/views/stuwork/stupunlish/form.vue | 6 - src/views/stuwork/stupunlish/index.vue | 304 +++++++---- src/views/stuwork/stutemleaveapply/form.vue | 3 - src/views/stuwork/stutemleaveapply/index.vue | 225 ++++++--- src/views/stuwork/stuturnover/form.vue | 6 - src/views/stuwork/stuturnover/index.vue | 293 +++++++---- src/views/stuwork/stuunion/form.vue | 2 - src/views/stuwork/stuunion/index.vue | 224 +++++++-- src/views/stuwork/stuunionleague/form.vue | 1 - src/views/stuwork/stuunionleague/index.vue | 245 ++++++--- .../stuwork/stuworkstudyalternate/form.vue | 1 - .../stuwork/stuworkstudyalternate/index.vue | 274 +++++++--- .../stuwork/stuworkstudyalternate/teacher.vue | 3 - src/views/stuwork/teachbuilding/index.vue | 179 ++++++- src/views/stuwork/teachclassroom/batch.vue | 1 - src/views/stuwork/teachclassroom/form.vue | 2 - src/views/stuwork/teachclassroom/index.vue | 170 ++++++- src/views/stuwork/tuitionfreestu/apply.vue | 5 - src/views/stuwork/tuitionfreestu/approve.vue | 3 - src/views/stuwork/tuitionfreestu/index.vue | 352 ++++++++----- src/views/stuwork/tuitionfreeterm/form.vue | 4 - src/views/stuwork/tuitionfreeterm/index.vue | 246 ++++++--- src/views/stuwork/waterdetail/form.vue | 2 - src/views/stuwork/waterdetail/index.vue | 300 +++++++---- src/views/stuwork/waterorder/form.vue | 4 - src/views/stuwork/waterorder/index.vue | 323 ++++++++---- src/views/stuwork/weekplan/detail.vue | 1 - src/views/stuwork/weekplan/form.vue | 2 - src/views/stuwork/weekplan/index.vue | 228 +++++++-- .../stuwork/workstudyattendance/index.vue | 277 +++++++---- 151 files changed, 13060 insertions(+), 4411 deletions(-) create mode 100644 scripts/add-table-column-control.js create mode 100644 src/components/TableColumnControl/INTEGRATION_GUIDE.md create mode 100644 src/components/TableColumnControl/QUICK_START.md create mode 100644 src/composables/useTableColumnControl.ts create mode 100644 src/utils/tableColumnControlHelper.ts diff --git a/scripts/add-table-column-control.js b/scripts/add-table-column-control.js new file mode 100644 index 0000000..b29da06 --- /dev/null +++ b/scripts/add-table-column-control.js @@ -0,0 +1,224 @@ +/** + * 批量添加 TableColumnControl 组件的脚本 + * 用于为 stuwork 文件夹下的所有页面添加列显隐控制功能 + */ + +const fs = require('fs') +const path = require('path') + +// 需要处理的目录 +const targetDir = path.join(__dirname, '../src/views/stuwork') + +// 获取所有 index.vue 文件 +function getAllIndexFiles(dir) { + const files = [] + const items = fs.readdirSync(dir, { withFileTypes: true }) + + for (const item of items) { + const fullPath = path.join(dir, item.name) + if (item.isDirectory()) { + const indexPath = path.join(fullPath, 'index.vue') + if (fs.existsSync(indexPath)) { + files.push(indexPath) + } + } + } + + return files +} + +// 检查文件是否已经包含 TableColumnControl +function hasTableColumnControl(content) { + return content.includes('TableColumnControl') || content.includes('table-column-control') +} + +// 提取表格列配置 +function extractTableColumns(content) { + const columns = [] + const columnRegex = /]+)>/g + let match + + while ((match = columnRegex.exec(content)) !== null) { + const attrs = match[1] + const propMatch = attrs.match(/prop=["']([^"']+)["']/) + const labelMatch = attrs.match(/label=["']([^"']+)["']/) + const typeMatch = attrs.match(/type=["']([^"']+)["']/) + const fixedMatch = attrs.match(/fixed=["']([^"']+)["']/) + + if (typeMatch && typeMatch[1] === 'index') { + // 序号列,跳过 + continue + } + + if (labelMatch && labelMatch[1] === '操作') { + // 操作列,标记为 alwaysShow + columns.push({ + prop: '操作', + label: '操作', + alwaysShow: true, + fixed: fixedMatch ? fixedMatch[1] : false + }) + continue + } + + if (propMatch && labelMatch) { + columns.push({ + prop: propMatch[1], + label: labelMatch[1], + alwaysShow: false, + fixed: fixedMatch ? fixedMatch[1] : false + }) + } + } + + return columns +} + +// 添加 TableColumnControl 导入 +function addImport(content) { + if (content.includes("import TableColumnControl")) { + return content + } + + // 查找 import 语句的位置 + const importRegex = /import\s+.*from\s+['"][^'"]+['"]/g + const lastImportMatch = [...content.matchAll(importRegex)].pop() + + if (lastImportMatch) { + const insertPos = lastImportMatch.index + lastImportMatch[0].length + const newImport = "\nimport TableColumnControl from '/@/components/TableColumnControl/index.vue'" + return content.slice(0, insertPos) + newImport + content.slice(insertPos) + } + + return content +} + +// 添加 useRoute 导入 +function addUseRouteImport(content) { + if (content.includes("import.*useRoute")) { + return content + } + + // 查找 vue-router 相关的导入 + const routerImportRegex = /import\s+.*from\s+['"]vue-router['"]/ + if (routerImportRegex.test(content)) { + // 如果已经有 vue-router 导入,添加 useRoute + return content.replace( + /import\s+([^}]+)\s+from\s+['"]vue-router['"]/, + (match, imports) => { + if (imports.includes('useRoute')) { + return match + } + return `import { ${imports.trim()}, useRoute } from 'vue-router'` + } + ) + } else { + // 如果没有 vue-router 导入,添加新的导入 + const importRegex = /import\s+.*from\s+['"]vue['"]/ + const vueImportMatch = content.match(importRegex) + if (vueImportMatch) { + const insertPos = vueImportMatch.index + vueImportMatch[0].length + return content.slice(0, insertPos) + "\nimport { useRoute } from 'vue-router'" + content.slice(insertPos) + } + } + + return content +} + +// 添加 Menu 图标导入 +function addMenuIconImport(content) { + if (content.includes('Menu') && content.includes('@element-plus/icons-vue')) { + return content + } + + // 查找 @element-plus/icons-vue 导入 + const iconImportRegex = /import\s+.*from\s+['"]@element-plus\/icons-vue['"]/ + const iconImportMatch = content.match(iconImportRegex) + + if (iconImportMatch) { + // 如果已经有图标导入,添加 Menu + return content.replace( + /import\s+{([^}]+)}\s+from\s+['"]@element-plus\/icons-vue['"]/, + (match, imports) => { + if (imports.includes('Menu')) { + return match + } + return `import { ${imports.trim()}, Menu } from '@element-plus/icons-vue'` + } + ) + } else { + // 如果没有图标导入,添加新的导入 + const importRegex = /import\s+.*from\s+['"][^'"]+['"]/ + const lastImportMatch = [...content.matchAll(importRegex)].pop() + if (lastImportMatch) { + const insertPos = lastImportMatch.index + lastImportMatch[0].length + return content.slice(0, insertPos) + "\nimport { Menu } from '@element-plus/icons-vue'" + content.slice(insertPos) + } + } + + return content +} + +// 主处理函数 +function processFile(filePath) { + console.log(`处理文件: ${filePath}`) + + let content = fs.readFileSync(filePath, 'utf-8') + + // 检查是否已经包含 TableColumnControl + if (hasTableColumnControl(content)) { + console.log(` 跳过: 已包含 TableColumnControl`) + return false + } + + // 检查是否有 el-table + if (!content.includes('
- + {