From a2f08641b941da4a7ded05969f963e98e241c1c2 Mon Sep 17 00:00:00 2001 From: ks3356143 <314298729@qq.com> Date: Fri, 19 Apr 2024 18:53:52 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cdTMP/src/layout/project-layout.vue | 30 ++--- cdTMP/src/store/project/treeData.js | 19 ++- cdTMP/src/views/project/case/index.vue | 2 +- .../src/views/project/design-demand/index.vue | 2 +- cdTMP/src/views/project/dut/index.vue | 2 +- cdTMP/src/views/project/round/index.vue | 120 +++++++----------- cdTMP/src/views/project/testDemand/index.vue | 8 +- 7 files changed, 82 insertions(+), 101 deletions(-) diff --git a/cdTMP/src/layout/project-layout.vue b/cdTMP/src/layout/project-layout.vue index 1d37d2e..0b2aad4 100644 --- a/cdTMP/src/layout/project-layout.vue +++ b/cdTMP/src/layout/project-layout.vue @@ -239,7 +239,7 @@ const handleSoDutCancel = () => { // so_dut弹窗ref对象 const soDutFormRef = ref() onMounted(async () => { - treeDataStore.initTreeData(projectId.value) + await treeDataStore.initTreeData(projectId.value) // 检查是否存在第一轮的源代码dut /// 主动后端请求 const res = await dutApi.getSoExists({ id: projectId.value }) @@ -613,32 +613,22 @@ const soDutColumn = ref([ { title: "空行", dataIndex: "black_line", - formType: "input-number" + formType: "input" }, { - title: "纯注释?", - dataIndex: "pure_code_line", - formType: "input-number" + title: "纯注释", + dataIndex: "comment_line", + formType: "input" }, { - title: "混合行?", + title: "混合行", dataIndex: "mix_line", - formType: "input-number" + formType: "input" }, { - title: "总注释", - dataIndex: "total_comment_line", - formType: "input-number" - }, - { - title: "总代码", - dataIndex: "total_code_line", - formType: "input-number" - }, - { - title: "总行数", - dataIndex: "total_line", - formType: "input-number" + title: "纯代码", + dataIndex: "code_line", + formType: "input" } ]) diff --git a/cdTMP/src/store/project/treeData.js b/cdTMP/src/store/project/treeData.js index fff57b1..96876a7 100644 --- a/cdTMP/src/store/project/treeData.js +++ b/cdTMP/src/store/project/treeData.js @@ -13,11 +13,28 @@ const useTreeDataStore = defineStore("treeDataStore", { actions: { // 不能使用箭头函数,无法绑定this async initTreeData(projectId) { - // 获取localStorage的treeData数据 + // 先判断储存的pid是否存在 + const pid = localStorage.getItem("pid") + // 如果不存在,则请求后台树状数据 + if (!pid) { + const roundData = await projectApi.getRoundInfo(projectId) + this.treeData = roundData.data + this.originTreeData = roundData.data + } + // 如果存在,但是项目变为了其他 + if (pid && pid !== projectId) { + const roundData = await projectApi.getRoundInfo(projectId) + this.treeData = roundData.data + this.originTreeData = roundData.data + } + // 每次进入工作区存一个localStorage项目ID + localStorage.setItem("pid", projectId) + // 获取localStorage的treeData数据-F5刷新问题解决 if (localStorage.getItem("tree_local_data")) { this.treeData = JSON.parse(localStorage.getItem("tree_local_data")) this.originTreeData = JSON.parse(localStorage.getItem("tree_local_data")) } + /// 如果没有tree_local_data则请求后台数据 if (this.treeData.length === 0) { const roundData = await projectApi.getRoundInfo(projectId) this.treeData = roundData.data diff --git a/cdTMP/src/views/project/case/index.vue b/cdTMP/src/views/project/case/index.vue index 0a87349..5079c32 100644 --- a/cdTMP/src/views/project/case/index.vue +++ b/cdTMP/src/views/project/case/index.vue @@ -54,7 +54,7 @@ const related_reload = () => { const crudOptions = ref({ api: problemApi.getProblemList, - add: { show: true, api: problemApi.save }, + add: { show: true, api: problemApi.save, text: "新增问题单" }, edit: { show: true, api: problemApi.update }, delete: { show: true, api: problemApi.delete }, operationColumnAlign: "center", // 操作列居中 diff --git a/cdTMP/src/views/project/design-demand/index.vue b/cdTMP/src/views/project/design-demand/index.vue index d830596..514f426 100644 --- a/cdTMP/src/views/project/design-demand/index.vue +++ b/cdTMP/src/views/project/design-demand/index.vue @@ -150,7 +150,7 @@ const showType = (record) => { // crud组件 const crudOptions = ref({ api: testDemandApi.getTestDemandList, - add: { show: true, api: testDemandApi.save }, + add: { show: true, api: testDemandApi.save, text: "新增测试项" }, edit: { show: true, api: testDemandApi.update }, delete: { show: true, api: testDemandApi.delete }, beforeOpenAdd: function () { diff --git a/cdTMP/src/views/project/dut/index.vue b/cdTMP/src/views/project/dut/index.vue index 11b6b9c..27209ac 100644 --- a/cdTMP/src/views/project/dut/index.vue +++ b/cdTMP/src/views/project/dut/index.vue @@ -45,7 +45,7 @@ const showType = (record) => { // crud组件 const crudOptions = ref({ api: designDemandApi.getDesignDemandList, - add: { show: true, api: designDemandApi.save }, + add: { show: true, api: designDemandApi.save, text: "新增设计需求" }, edit: { show: true, api: designDemandApi.editDesignDemand }, delete: { show: true, api: designDemandApi.delete }, // 处理添加后函数 diff --git a/cdTMP/src/views/project/round/index.vue b/cdTMP/src/views/project/round/index.vue index 00fdfba..bde9742 100644 --- a/cdTMP/src/views/project/round/index.vue +++ b/cdTMP/src/views/project/round/index.vue @@ -2,41 +2,7 @@
- - - - - +
@@ -143,23 +109,23 @@ const crudColumns = ref([ if (value === "SO") { return { black_line: { display: true }, - pure_code_line: { display: true }, + code_line: { display: true }, mix_line: { display: true }, - total_comment_line: { display: true }, + comment_line: { display: true }, total_code_line: { display: true }, total_line: { display: true }, - comment_line: { display: true } + comment_percent: { display: true } } } else { // 其他数据清除 return { black_line: { display: false }, - pure_code_line: { display: false }, + code_line: { display: false }, mix_line: { display: false }, - total_comment_line: { display: false }, + comment_line: { display: false }, total_code_line: { display: false }, total_line: { display: false }, - comment_line: { display: false } + comment_percent: { display: false } } } } @@ -213,72 +179,78 @@ const crudColumns = ref([ formType: "input-number" }, { - title: "纯注释?", + title: "纯代码行", hide: true, align: "center", - dataIndex: "pure_code_line", + dataIndex: "code_line", formType: "input-number" }, { - title: "混合行?", + title: "纯注释行", + hide: true, + align: "center", + dataIndex: "comment_line", + formType: "input-number" + }, + { + title: "混合行", hide: true, align: "center", dataIndex: "mix_line", formType: "input-number" }, - { - title: "总注释", - hide: true, - align: "center", - dataIndex: "total_comment_line", - formType: "input-number" - }, - { - title: "总代码", - hide: true, - align: "center", - dataIndex: "total_code_line", - formType: "input-number" - }, - { - title: "总行数", - hide: true, - align: "center", - dataIndex: "total_line", - formType: "input-number" - }, { title: "注释率 %", align: "center", - dataIndex: "comment_line", + dataIndex: "comment_percent", hide: true, addDisabled: true, editDisabled: true, customRender: ({ record }) => { - if (record.total_comment_line && record.total_code_line) { - if (isNaN(parseFloat(record.total_comment_line)) || isNaN(parseFloat(record.total_code_line))) { + const sum_line = + parseFloat(record.comment_line) + + parseFloat(record.mix_line) + + parseFloat(record.black_line) + + parseFloat(record.code_line) + if (record.comment_line && record.mix_line && record.black_line && record.code_line) { + if ( + isNaN(parseFloat(record.comment_line)) || + isNaN(parseFloat(record.mix_line)) || + isNaN(parseFloat(record.black_line)) || + isNaN(parseFloat(record.code_line)) + ) { return "数值错误" } - if (parseFloat(record.total_comment_line) <= 0 || parseFloat(record.total_code_line) <= 0) { + if ( + parseFloat(record.comment_line) <= 0 || + parseFloat(record.mix_line) <= 0 || + parseFloat(record.black_line) <= 0 || + parseFloat(record.code_line) <= 0 + ) { return "不能为负数" } - if (parseFloat(record.total_comment_line) >= parseFloat(record.total_code_line)) { - return "注释大于总行" - } return ( ) } }, // 注意这个是个创新点 control(value, data) { - data.comment_line = (data.total_comment_line / data.total_code_line).toFixed(2).toString() + data.comment_percent = ( + (parseFloat(data.comment_line) + parseFloat(data.mix_line)) / + (parseFloat(data.comment_line) + + parseFloat(data.mix_line) + + parseFloat(data.black_line) + + parseFloat(data.code_line)) + ) + .toFixed(2) + .toString() } } ]) diff --git a/cdTMP/src/views/project/testDemand/index.vue b/cdTMP/src/views/project/testDemand/index.vue index ffbcbc6..1670c15 100644 --- a/cdTMP/src/views/project/testDemand/index.vue +++ b/cdTMP/src/views/project/testDemand/index.vue @@ -42,7 +42,7 @@ const showType = (record) => { // crud设置 const crudOptions = ref({ api: caseApi.getCaseList, - add: { show: true, api: caseApi.save }, + add: { show: true, api: caseApi.save, text: "新增用例" }, edit: { show: true, api: caseApi.update }, delete: { show: true, api: caseApi.delete }, // 处理新增删除后树状图显示 @@ -237,13 +237,15 @@ const crudColumns = ref([ title: "是否通过", dataIndex: "passed", formType: "radio", - dict: { name: "passType", props: { label: "title", value: "key" } } + dict: { name: "passType", props: { label: "title", value: "key" } }, + commonRules: [{ required: true, message: "是否通过必填" }] }, { title: "执行状态", dataIndex: "status", formType: "radio", - dict: { name: "execType", props: { label: "title", value: "key" } } + dict: { name: "execType", props: { label: "title", value: "key" } }, + commonRules: [{ required: true, message: "执行状态必填" }] } ] }