2023-06-15 20:13:46 +08:00
|
|
|
<template>
|
|
|
|
|
<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组件 -->
|
2023-08-17 20:15:03 +08:00
|
|
|
<ma-crud :options="crudOptions" :columns="crudColumns" ref="crudRef">
|
2023-06-20 18:09:30 +08:00
|
|
|
<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>
|
2023-06-15 20:13:46 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
2023-08-17 15:33:05 +08:00
|
|
|
<script setup lang="jsx">
|
2023-06-15 20:13:46 +08:00
|
|
|
import { ref } from "vue"
|
|
|
|
|
import { useRoute, useRouter } from "vue-router"
|
2023-06-19 19:51:12 +08:00
|
|
|
import dutApi from "@/api/project/dut"
|
2023-08-15 17:15:52 +08:00
|
|
|
import { useTreeDataStore } from "@/store"
|
|
|
|
|
const treeDataStore = useTreeDataStore()
|
2023-06-15 20:13:46 +08:00
|
|
|
const route = useRoute()
|
2023-07-31 20:52:22 +08:00
|
|
|
const roundNumber = route.query.key.split("-")[0]
|
2023-08-15 17:15:52 +08:00
|
|
|
const projectId = ref(route.query.id)
|
2023-08-17 20:15:03 +08:00
|
|
|
const crudRef = ref()
|
2024-03-21 19:14:07 +08:00
|
|
|
|
|
|
|
|
let beiceType = [
|
|
|
|
|
{ label: "源代码", value: "SO" },
|
|
|
|
|
{ label: "设计说明", value: "SJ" },
|
|
|
|
|
{ label: "需求文档", value: "XQ" },
|
|
|
|
|
{ label: "通信协议", value: "XY" },
|
|
|
|
|
{ label: "研制总要求", value: "YZ" }
|
|
|
|
|
]
|
2023-06-15 20:13:46 +08:00
|
|
|
// crud组件
|
|
|
|
|
const crudOptions = ref({
|
2023-06-19 19:51:12 +08:00
|
|
|
api: dutApi.getDutList,
|
2023-08-15 17:15:52 +08:00
|
|
|
add: { show: true, api: dutApi.save, text: "新增被测件" },
|
|
|
|
|
// 处理添加后函数
|
2023-08-24 19:24:00 +08:00
|
|
|
beforeOpenAdd: function () {
|
2023-08-25 13:28:24 +08:00
|
|
|
let round_str = parseInt(route.query.key) + 1
|
|
|
|
|
crudRef.value.crudFormRef.actionTitle = `${route.query.ident}>第${round_str}轮>被测件-`
|
2023-08-24 19:24:00 +08:00
|
|
|
return true
|
|
|
|
|
},
|
|
|
|
|
beforeOpenEdit: function (record) {
|
2023-08-25 13:28:24 +08:00
|
|
|
let round_str = parseInt(route.query.key) + 1
|
|
|
|
|
crudRef.value.crudFormRef.actionTitle = `${route.query.ident}>第${round_str}轮>被测件[${record.name}]-`
|
2023-08-24 19:24:00 +08:00
|
|
|
return true
|
|
|
|
|
},
|
2023-08-15 17:15:52 +08:00
|
|
|
afterAdd: (res) => {
|
|
|
|
|
let id = projectId.value
|
|
|
|
|
treeDataStore.updateDutTreeData(res.data, id)
|
|
|
|
|
},
|
|
|
|
|
afterEdit: (res) => {
|
|
|
|
|
let id = projectId.value
|
|
|
|
|
treeDataStore.updateDutTreeData(res.data, id)
|
|
|
|
|
},
|
|
|
|
|
afterDelete: (res, record) => {
|
|
|
|
|
let id = projectId.value
|
|
|
|
|
treeDataStore.updateDutTreeData(record, id)
|
|
|
|
|
},
|
|
|
|
|
edit: { show: true, api: dutApi.update, text: "编辑被测件" },
|
2023-07-31 20:52:22 +08:00
|
|
|
delete: { show: true, api: dutApi.delete },
|
2023-06-15 20:13:46 +08:00
|
|
|
parameters: {
|
|
|
|
|
projectId: route.query.id,
|
2023-08-15 17:15:52 +08:00
|
|
|
round: roundNumber
|
2023-06-15 20:13:46 +08:00
|
|
|
},
|
2023-07-31 20:52:22 +08:00
|
|
|
operationWidth: 500,
|
2023-06-15 20:13:46 +08:00
|
|
|
showIndex: false,
|
|
|
|
|
rowSelection: { showCheckedAll: true },
|
|
|
|
|
searchColNumber: 3,
|
2023-07-25 20:03:06 +08:00
|
|
|
tablePagination: false,
|
2023-06-15 20:13:46 +08:00
|
|
|
operationColumn: true,
|
2023-06-20 18:09:30 +08:00
|
|
|
operationColumnAlign: "center",
|
2023-06-15 20:13:46 +08:00
|
|
|
formOption: {
|
2023-06-20 18:09:30 +08:00
|
|
|
viewType: "drawer",
|
2023-08-15 17:15:52 +08:00
|
|
|
width: 600
|
2023-06-15 20:13:46 +08:00
|
|
|
}
|
|
|
|
|
})
|
2023-06-20 18:09:30 +08:00
|
|
|
|
2023-06-15 20:13:46 +08:00
|
|
|
const crudColumns = ref([
|
|
|
|
|
{
|
|
|
|
|
title: "ID",
|
|
|
|
|
width: 50,
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
2023-06-15 20:13:46 +08:00
|
|
|
dataIndex: "id",
|
2023-06-20 18:09:30 +08:00
|
|
|
commonRules: [{ required: true, message: "ID是必填" }],
|
2023-06-15 20:13:46 +08:00
|
|
|
validateTrigger: "blur"
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "标识",
|
2023-06-19 19:51:12 +08:00
|
|
|
width: 150,
|
2023-08-21 19:57:49 +08:00
|
|
|
sortable: { sortDirections: ["ascend"] },
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
2023-06-15 20:13:46 +08:00
|
|
|
dataIndex: "ident",
|
|
|
|
|
search: true,
|
2023-08-17 20:15:03 +08:00
|
|
|
// 这里做的标识预填
|
|
|
|
|
addDefaultValue: route.query.ident + "-R" + (parseInt(route.query.key) + 1) + "-UT",
|
|
|
|
|
addDisabled: true,
|
|
|
|
|
editDisabled: true,
|
2023-06-15 20:13:46 +08:00
|
|
|
validateTrigger: "blur"
|
|
|
|
|
},
|
2023-06-20 18:09:30 +08:00
|
|
|
{
|
|
|
|
|
title: "被测类型",
|
|
|
|
|
align: "center",
|
|
|
|
|
dataIndex: "type",
|
|
|
|
|
search: true,
|
|
|
|
|
formType: "radio",
|
|
|
|
|
addDefaultValue: "SO",
|
|
|
|
|
dict: {
|
|
|
|
|
data: beiceType,
|
|
|
|
|
translation: true,
|
2024-03-21 19:14:07 +08:00
|
|
|
tagColors: { XQ: "blue", SO: "green", SJ: "orangered", XY: "pinkpurple", YZ: "red" }
|
2023-06-20 18:09:30 +08:00
|
|
|
},
|
2023-08-17 15:33:05 +08:00
|
|
|
control: (value, data) => {
|
2023-06-20 18:09:30 +08:00
|
|
|
if (value === "SO") {
|
|
|
|
|
return {
|
|
|
|
|
black_line: { display: true },
|
|
|
|
|
pure_code_line: { display: true },
|
|
|
|
|
mix_line: { display: true },
|
|
|
|
|
total_comment_line: { display: true },
|
|
|
|
|
total_code_line: { display: true },
|
|
|
|
|
total_line: { display: true },
|
|
|
|
|
comment_line: { display: true }
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2023-08-17 15:33:05 +08:00
|
|
|
// 其他数据清除
|
2023-06-20 18:09:30 +08:00
|
|
|
return {
|
|
|
|
|
black_line: { display: false },
|
|
|
|
|
pure_code_line: { display: false },
|
|
|
|
|
mix_line: { display: false },
|
|
|
|
|
total_comment_line: { display: false },
|
|
|
|
|
total_code_line: { display: false },
|
|
|
|
|
total_line: { display: false },
|
|
|
|
|
comment_line: { display: false }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
2023-06-15 20:13:46 +08:00
|
|
|
{
|
2023-06-19 19:51:12 +08:00
|
|
|
title: "被测件名",
|
|
|
|
|
width: 120,
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
2023-06-15 20:13:46 +08:00
|
|
|
dataIndex: "name",
|
|
|
|
|
search: true,
|
|
|
|
|
commonRules: [{ required: true, message: "需求名称是必填" }],
|
|
|
|
|
validateTrigger: "blur"
|
|
|
|
|
},
|
2023-08-21 19:57:49 +08:00
|
|
|
{
|
|
|
|
|
title: "版本",
|
|
|
|
|
align: "center",
|
|
|
|
|
dataIndex: "version",
|
|
|
|
|
search: true,
|
|
|
|
|
commonRules: [{ required: true, message: "版本必填" }],
|
|
|
|
|
validateTrigger: "blur"
|
|
|
|
|
},
|
2024-03-05 16:28:47 +08:00
|
|
|
{
|
|
|
|
|
title: "用户标识",
|
|
|
|
|
align: "center",
|
|
|
|
|
dataIndex: "ref",
|
|
|
|
|
search: true,
|
|
|
|
|
commonRules: [{ required: true, message: "用户标识或编号必填" }],
|
|
|
|
|
validateTrigger: "blur"
|
|
|
|
|
},
|
2023-08-21 19:57:49 +08:00
|
|
|
{
|
|
|
|
|
title: "单位",
|
|
|
|
|
align: "center",
|
|
|
|
|
dataIndex: "release_union",
|
|
|
|
|
search: true,
|
|
|
|
|
commonRules: [{ required: true, message: "单位必选" }],
|
|
|
|
|
formType: "select",
|
|
|
|
|
dict: { url: "system/contact/index", props: { label: "name", value: "name" }, translation: true }
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: "发布时间",
|
|
|
|
|
dataIndex: "release_date",
|
|
|
|
|
hide: true,
|
|
|
|
|
commonRules: [{ required: true, message: "时间必填" }],
|
|
|
|
|
formType: "date"
|
|
|
|
|
},
|
2023-06-15 20:13:46 +08:00
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "空行",
|
|
|
|
|
hide: true,
|
|
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "black_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-15 20:13:46 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "纯注释",
|
|
|
|
|
hide: true,
|
|
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "pure_code_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-19 19:51:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "混合行",
|
|
|
|
|
hide: true,
|
|
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "mix_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-19 19:51:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "总注释",
|
|
|
|
|
hide: true,
|
|
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "total_comment_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-19 19:51:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "总代码",
|
2023-08-21 19:57:49 +08:00
|
|
|
hide: true,
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "total_code_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-19 19:51:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-06-20 18:09:30 +08:00
|
|
|
title: "总行数",
|
2023-08-21 19:57:49 +08:00
|
|
|
hide: true,
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
2023-08-17 15:33:05 +08:00
|
|
|
dataIndex: "total_line",
|
|
|
|
|
formType: "input-number"
|
2023-06-19 19:51:12 +08:00
|
|
|
},
|
|
|
|
|
{
|
2023-08-17 15:33:05 +08:00
|
|
|
title: "注释率 %",
|
2023-06-20 18:09:30 +08:00
|
|
|
align: "center",
|
|
|
|
|
dataIndex: "comment_line",
|
2023-08-21 19:57:49 +08:00
|
|
|
hide: true,
|
2023-08-17 15:33:05 +08:00
|
|
|
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))) {
|
|
|
|
|
return "数值错误"
|
|
|
|
|
}
|
|
|
|
|
if (parseFloat(record.total_comment_line) <= 0 || parseFloat(record.total_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)}
|
|
|
|
|
></a-statistic>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 注意这个是个创新点
|
|
|
|
|
control(value, data) {
|
|
|
|
|
data.comment_line = (data.total_comment_line / data.total_code_line).toFixed(2).toString()
|
|
|
|
|
}
|
2023-06-20 18:09:30 +08:00
|
|
|
}
|
2023-06-15 20:13:46 +08:00
|
|
|
])
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped></style>
|