97 lines
5.0 KiB
Python
97 lines
5.0 KiB
Python
# -*- 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 '</el-tabs>' in l)
|
|
pane_end = next(i for i in range(tabs_end - 1, start, -1) if '</el-tab-pane>' in lines[i])
|
|
print(f'pane: {start+1}..{pane_end+1}')
|
|
|
|
ROW = ''' <li v-for="item in {LIST}" :key="item.id" class="doc-file">
|
|
<i class="el-icon-document doc-file-icon" />
|
|
<div class="doc-file-main">
|
|
<div class="doc-file-name cp" @click="fileClick(item)">{TITLE}</div>
|
|
<div class="doc-file-meta">{{{{ item.addedBy }}}} · {{{{ item.addedDate ? dayjs(item.addedDate).format("YYYY-MM-DD HH:mm") : "" }}}}</div>
|
|
</div>
|
|
<div class="doc-file-acts">
|
|
<el-button type="text" size="mini" @click="fileClick(item)">查看</el-button>
|
|
<el-button type="text" size="mini" @click="downFiles(item)">下载</el-button>
|
|
</div>
|
|
</li>
|
|
<li v-if="{LIST}.length === 0" class="doc-empty">{EMPTY}</li>'''
|
|
|
|
def section(title, count, body, warn='', footer=''):
|
|
return f''' <section class="doc-sec">
|
|
<header class="doc-sec-hd">
|
|
<span class="doc-sec-title">{title}</span>
|
|
<span class="doc-count">{count}</span>
|
|
</header>
|
|
{warn}{body}{footer}
|
|
</section>
|
|
'''
|
|
|
|
def doclist(listname, empty, title_expr='{{ item.title }}'):
|
|
return ''' <ul class="doc-list">
|
|
''' + ROW.replace('{LIST}', listname).replace('{TITLE}', title_expr).replace('{EMPTY}', empty) + '''
|
|
</ul>'''
|
|
|
|
UPLOADS = ''' <div class="doc-sec-ft">
|
|
<uploads
|
|
:form="uploadForm"
|
|
:upload-show="{SHOW}"
|
|
object-type="{TYPE}"
|
|
:object-id="currentInfo.id"
|
|
@fetchLogo="fetchBlockFile($event, '{TYPE}')"
|
|
@handleBeforeUpload="handleBeforeUpload"
|
|
/>
|
|
</div>'''
|
|
|
|
parts = []
|
|
# 1 测试用例/模版
|
|
parts.append(section(
|
|
'测试用例 / 测试报告模版',
|
|
'{{ testCaseFiles.length + testReportFiles.length }} 份',
|
|
' <div class="doc-group">测试用例</div>\n' + doclist('testCaseFiles', '暂无附件')
|
|
+ '\n <div class="doc-group">测试报告模版</div>\n' + doclist('testReportFiles', '暂无附件')
|
|
))
|
|
# 2 提交测试报告(卡点+上传)
|
|
parts.append(section(
|
|
'提交测试报告', '{{ testReportSubmitFiles.length }} 份',
|
|
doclist('testReportSubmitFiles', '暂无附件'),
|
|
warn=''' <div v-if="currentInfo.codeReviewStatus !== 'pass'" class="doc-warn">
|
|
<i class="el-icon-warning-outline" /> 代码审查未通过,不可提交
|
|
</div>
|
|
''',
|
|
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 }}<span v-if="parseRound(item.extra)" class="doc-round">第{{ parseRound(item.extra) }}轮</span>')
|
|
))
|
|
# 5 工作日志
|
|
parts.append(section('工作日志', '{{ aiWorkLogFiles.length }} 份',
|
|
doclist('aiWorkLogFiles', '暂无附件(由 AI 框架上传)')))
|
|
# 6 AI项目文档更新记录
|
|
parts.append(section('AI 项目文档更新记录', '{{ aiDocUpdateFiles.length }} 份',
|
|
doclist('aiDocUpdateFiles', '暂无附件(由 AI 框架上传)')))
|
|
|
|
inner = (' <!-- CHG-063:六类文档区块归集到此 tab;CHG-068:视觉重设计(分节+文件行+计数徽章) -->\n'
|
|
' <div class="req-docs">\n'
|
|
+ ''.join(parts) +
|
|
' </div>\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)), '行')
|