提交修改问题

This commit is contained in:
2024-04-19 18:53:52 +08:00
parent 65fede2ec4
commit a2f08641b9
7 changed files with 82 additions and 101 deletions

View File

@@ -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"
}
])
</script>

View File

@@ -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

View File

@@ -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", // 操作列居中

View File

@@ -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 () {

View File

@@ -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 },
// 处理添加后函数

View File

@@ -2,41 +2,7 @@
<div class="ma-content-block lg:flex justify-between p-4">
<div class="lg:w-full w-full lg:ml-4 mt-5 lg:mt-0">
<!-- CRUD组件 -->
<ma-crud :options="crudOptions" :columns="crudColumns" ref="crudRef">
<template #total_code_line="{ record }">
<template v-if="record.total_code_line">
<a-statistic
:animation-duration="1000"
:value="parseInt(record.total_code_line)"
animation
:value-style="{ color: '#0fbf60' }"
></a-statistic>
</template>
</template>
<template #total_line="{ record }">
<template v-if="record.total_line">
<a-statistic
:animation-duration="1000"
:value="parseInt(record.total_line)"
animation
:value-style="{ color: 'orange' }"
></a-statistic>
</template>
</template>
<template #comment_line="{ record }">
<template v-if="record.comment_line">
<a-statistic
:animation-duration="1000"
:precision="2"
:value="parseFloat(record.comment_line)"
animation
:value-style="{ color: 'lightblue' }"
>
<template #suffix> % </template>
</a-statistic>
</template>
</template>
</ma-crud>
<ma-crud :options="crudOptions" :columns="crudColumns" ref="crudRef"></ma-crud>
</div>
</div>
</template>
@@ -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 (
<a-statistic
animation-duration={parseInt(1000)}
precision={2}
animation
value-style={{ color: "lightblue" }}
value={parseFloat(record.total_comment_line / record.total_code_line)}
value={(parseFloat(record.comment_line) + parseFloat(record.mix_line)) / sum_line}
></a-statistic>
)
}
},
// 注意这个是个创新点
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()
}
}
])

View File

@@ -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: "执行状态必填" }]
}
]
}