# -*- coding: utf-8 -*- """CHG-068:需求文档 tab 内容视觉重设计(分节+文件行+计数徽章)""" import io, sys sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8') path = 'src/views/product/storyinfo/components/product.vue' lines = open(path, encoding='utf-8').readlines() start = next(i for i, l in enumerate(lines) if '需求文档' in l and 'el-tab-pane' in l) tabs_end = next(i for i, l in enumerate(lines) if '' in l) pane_end = next(i for i in range(tabs_end - 1, start, -1) if '' in lines[i]) print(f'pane: {start+1}..{pane_end+1}') ROW = '''
  • {TITLE}
    {{{{ item.addedBy }}}} · {{{{ item.addedDate ? dayjs(item.addedDate).format("YYYY-MM-DD HH:mm") : "" }}}}
    查看 下载
  • {EMPTY}
  • ''' def section(title, count, body, warn='', footer=''): return f'''
    {title} {count}
    {warn}{body}{footer}
    ''' def doclist(listname, empty, title_expr='{{ item.title }}'): return ''' ''' UPLOADS = '''
    ''' parts = [] # 1 测试用例/模版 parts.append(section( '测试用例 / 测试报告模版', '{{ testCaseFiles.length + testReportFiles.length }} 份', '
    测试用例
    \n' + doclist('testCaseFiles', '暂无附件') + '\n
    测试报告模版
    \n' + doclist('testReportFiles', '暂无附件') )) # 2 提交测试报告(卡点+上传) parts.append(section( '提交测试报告', '{{ testReportSubmitFiles.length }} 份', doclist('testReportSubmitFiles', '暂无附件'), warn='''
    代码审查未通过,不可提交
    ''', footer='\n' + UPLOADS.replace('{SHOW}', "currentInfo.codeReviewStatus === 'pass'").replace('{TYPE}', 'testReportSubmit') )) # 3 其他测试文档(上传) parts.append(section( '其他测试文档', '{{ testOtherFiles.length }} 份', doclist('testOtherFiles', '暂无附件'), footer='\n' + UPLOADS.replace('{SHOW}', 'true').replace('{TYPE}', 'testOther') )) # 4 代码审查报告(轮次徽章) parts.append(section( '代码审查报告', '{{ aiCodeReviewFiles.length }} 份', doclist('aiCodeReviewFiles', '暂无附件(由 AI 框架上传)', '{{ item.title }}第{{ parseRound(item.extra) }}轮') )) # 5 工作日志 parts.append(section('工作日志', '{{ aiWorkLogFiles.length }} 份', doclist('aiWorkLogFiles', '暂无附件(由 AI 框架上传)'))) # 6 AI项目文档更新记录 parts.append(section('AI 项目文档更新记录', '{{ aiDocUpdateFiles.length }} 份', doclist('aiDocUpdateFiles', '暂无附件(由 AI 框架上传)'))) inner = (' \n' '
    \n' + ''.join(parts) + '
    \n') new_lines = lines[:start + 1] + [inner] + lines[pane_end:] open(path, 'w', encoding='utf-8', newline='').writelines(new_lines) print('tab 内容已替换:', pane_end - start, '行 →', inner.count(chr(10)), '行')