实现项目列表重新分析交互
This commit is contained in:
@@ -120,6 +120,8 @@
|
|||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
icon="el-icon-refresh"
|
icon="el-icon-refresh"
|
||||||
|
:loading="reAnalyzeLoadingMap[String(scope.row.projectId)]"
|
||||||
|
:disabled="reAnalyzeLoadingMap[String(scope.row.projectId)]"
|
||||||
@click="handleReAnalyze(scope.row)"
|
@click="handleReAnalyze(scope.row)"
|
||||||
>
|
>
|
||||||
重新分析
|
重新分析
|
||||||
@@ -185,6 +187,10 @@ export default {
|
|||||||
pageSize: 10,
|
pageSize: 10,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
reAnalyzeLoadingMap: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getStatusColor(status) {
|
getStatusColor(status) {
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
:data-list="projectList"
|
:data-list="projectList"
|
||||||
:total="total"
|
:total="total"
|
||||||
:page-params="queryParams"
|
:page-params="queryParams"
|
||||||
|
:re-analyze-loading-map="reAnalyzeLoadingMap"
|
||||||
@pagination="handlePagination"
|
@pagination="handlePagination"
|
||||||
@enter="handleEnter"
|
@enter="handleEnter"
|
||||||
@view-result="handleViewResult"
|
@view-result="handleViewResult"
|
||||||
@@ -61,7 +62,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {getStatusCounts, listProject} from '@/api/ccdiProject'
|
import {getStatusCounts, listProject, rebuildProjectTags} from '@/api/ccdiProject'
|
||||||
import SearchBar from './components/SearchBar'
|
import SearchBar from './components/SearchBar'
|
||||||
import ProjectTable from './components/ProjectTable'
|
import ProjectTable from './components/ProjectTable'
|
||||||
import QuickEntry from './components/QuickEntry'
|
import QuickEntry from './components/QuickEntry'
|
||||||
@@ -113,6 +114,8 @@ export default {
|
|||||||
// 归档确认弹窗
|
// 归档确认弹窗
|
||||||
archiveDialogVisible: false,
|
archiveDialogVisible: false,
|
||||||
currentArchiveProject: null,
|
currentArchiveProject: null,
|
||||||
|
// 重新分析按钮提交态
|
||||||
|
reAnalyzeLoadingMap: {},
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
@@ -242,9 +245,22 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
/** 重新分析 */
|
/** 重新分析 */
|
||||||
handleReAnalyze(row) {
|
async handleReAnalyze(row) {
|
||||||
console.log("重新分析:", row);
|
const projectKey = String(row.projectId)
|
||||||
this.$modal.msgSuccess("正在重新分析项目: " + row.projectName);
|
if (this.reAnalyzeLoadingMap[projectKey]) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
this.$set(this.reAnalyzeLoadingMap, projectKey, true)
|
||||||
|
try {
|
||||||
|
await rebuildProjectTags({ projectId: row.projectId })
|
||||||
|
this.$modal.msgSuccess("已开始重新分析")
|
||||||
|
this.getList()
|
||||||
|
} catch (error) {
|
||||||
|
const message = error && error.message ? error.message : "重新分析失败,请稍后重试"
|
||||||
|
this.$modal.msgError(message)
|
||||||
|
} finally {
|
||||||
|
this.$set(this.reAnalyzeLoadingMap, projectKey, false)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
/** 归档项目 */
|
/** 归档项目 */
|
||||||
handleArchive(row) {
|
handleArchive(row) {
|
||||||
|
|||||||
42
ruoyi-ui/tests/unit/project-list-reanalyze-flow.test.js
Normal file
42
ruoyi-ui/tests/unit/project-list-reanalyze-flow.test.js
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
const assert = require("assert");
|
||||||
|
const fs = require("fs");
|
||||||
|
const path = require("path");
|
||||||
|
|
||||||
|
const pagePath = path.resolve(__dirname, "../../src/views/ccdiProject/index.vue");
|
||||||
|
const tablePath = path.resolve(__dirname, "../../src/views/ccdiProject/components/ProjectTable.vue");
|
||||||
|
const pageSource = fs.readFileSync(pagePath, "utf8");
|
||||||
|
const tableSource = fs.readFileSync(tablePath, "utf8");
|
||||||
|
|
||||||
|
assert(
|
||||||
|
pageSource.includes("rebuildProjectTags({ projectId: row.projectId })"),
|
||||||
|
"重新分析应调用真实重打标接口"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
pageSource.includes('this.$modal.msgSuccess("已开始重新分析")') ||
|
||||||
|
pageSource.includes("this.$modal.msgSuccess('已开始重新分析')"),
|
||||||
|
"重新分析成功提示应统一为已开始重新分析"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
/finally\s*\([\s\S]*?this\.getList\(/.test(pageSource) || pageSource.includes("this.getList()"),
|
||||||
|
"重新分析成功后应刷新列表"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
tableSource.includes(':loading="reAnalyzeLoadingMap[String(scope.row.projectId)]"') ||
|
||||||
|
tableSource.includes(':loading="reAnalyzeLoadingMap[scope.row.projectId]"'),
|
||||||
|
"表格中的重新分析按钮应支持提交态"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
pageSource.includes("重新分析失败,请稍后重试"),
|
||||||
|
"重新分析失败时应有统一兜底提示"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert(
|
||||||
|
pageSource.includes("error.message"),
|
||||||
|
"有明确业务异常时应优先透传后端返回文案"
|
||||||
|
);
|
||||||
|
|
||||||
|
console.log("project-list-reanalyze-flow test passed");
|
||||||
Reference in New Issue
Block a user