123
This commit is contained in:
92
cdTMP/src/api/system/dict.js
Normal file
92
cdTMP/src/api/system/dict.js
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
import { request } from "@/api/request"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
/**
|
||||||
|
* 请求dict全部数据
|
||||||
|
* @returns dict全部数据
|
||||||
|
*/
|
||||||
|
getDictIndex(params = {}) {
|
||||||
|
return request({
|
||||||
|
url: `system/dataDict/index`,
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 切换字典状态
|
||||||
|
* @returns 切换成功或失败标志
|
||||||
|
*/
|
||||||
|
changeStatus(data = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/changeStatus",
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 获取字典详情列表
|
||||||
|
* @returns 字典详情列表
|
||||||
|
*/
|
||||||
|
getDictItemAll(params = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/dictItemAll",
|
||||||
|
method: "get",
|
||||||
|
params
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 数字运算操作
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
numberOperation(data = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/numberOperation",
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 切换字典item状态
|
||||||
|
* @returns 切换成功或失败标志
|
||||||
|
*/
|
||||||
|
changeItemStatus(data = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/changeItemStatus",
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 添加字典Item数据
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
saveDictItem(data = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/saveitem",
|
||||||
|
method: "post",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 更新dictItem数据
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
updateDictItemData(id, data = {}) {
|
||||||
|
return request({
|
||||||
|
url: "system/dataDict/update/" + id,
|
||||||
|
method: "put",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 真实删除
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
realDeleteItem(data) {
|
||||||
|
return request({
|
||||||
|
url: "system/dictType/realDeleteItem",
|
||||||
|
method: "delete",
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -473,7 +473,7 @@ const requestHandle = async () => {
|
|||||||
tableData.value = response
|
tableData.value = response
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
console.error(`ma-crud error:crud.api not is Function.`)
|
console.error(`ma-crud error:crud.api 不是一个 Function.`)
|
||||||
}
|
}
|
||||||
isFunction(options.value.afterRequest) && options.value.afterRequest(tableData.value)
|
isFunction(options.value.afterRequest) && options.value.afterRequest(tableData.value)
|
||||||
loading.value = false
|
loading.value = false
|
||||||
|
|||||||
28
cdTMP/src/router/routes/modules/datamanage.js
Normal file
28
cdTMP/src/router/routes/modules/datamanage.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import { DEFAULT_LAYOUT } from "../base"
|
||||||
|
|
||||||
|
const DATAMANAGE = {
|
||||||
|
path: "/datamanage",
|
||||||
|
name: "Datamanage",
|
||||||
|
component: DEFAULT_LAYOUT, // () => import("@/layout/default-layout.vue")
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
icon: "icon-storage",
|
||||||
|
order: 99,
|
||||||
|
locale: "数据管理"
|
||||||
|
},
|
||||||
|
children: [
|
||||||
|
{
|
||||||
|
path: "dictmanage",
|
||||||
|
name: "Dictmanage",
|
||||||
|
component: () => import("@/views/datamanage/dictmanage/index.vue"),
|
||||||
|
meta: {
|
||||||
|
requiresAuth: true,
|
||||||
|
roles: ["*"],
|
||||||
|
locale: "字典管理",
|
||||||
|
icon: "icon-book"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export default DATAMANAGE
|
||||||
@@ -26,7 +26,6 @@ const useTreeDataStore = defineStore("treeDataStore", {
|
|||||||
},
|
},
|
||||||
// 新增删除dut后更新树状显示
|
// 新增删除dut后更新树状显示
|
||||||
async updateDutTreeData(data, projrctId) {
|
async updateDutTreeData(data, projrctId) {
|
||||||
console.log(data);
|
|
||||||
let temp = data.key.split("-")
|
let temp = data.key.split("-")
|
||||||
temp.pop(-1)
|
temp.pop(-1)
|
||||||
let roundKey = temp[0]
|
let roundKey = temp[0]
|
||||||
|
|||||||
144
cdTMP/src/views/datamanage/dictmanage/dataList.vue
Normal file
144
cdTMP/src/views/datamanage/dictmanage/dataList.vue
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<template>
|
||||||
|
<a-modal v-model:visible="visible" fullscreen :footer="false">
|
||||||
|
<template #title>维护数据字典 →【{{ currentRow.name }}】</template>
|
||||||
|
<!-- crud组件 -->
|
||||||
|
<div class="lg:w-full w-full lg:ml-4 mt-5 lg:mt-0">
|
||||||
|
<ma-crud :options="crudOptions" :columns="columns" ref="crudRef">
|
||||||
|
<!-- 排序列 -->
|
||||||
|
<template #sort="{ record }">
|
||||||
|
<a-input-number
|
||||||
|
:default-value="record.sort"
|
||||||
|
mode="button"
|
||||||
|
@change="changeSort($event, record.id)"
|
||||||
|
:min="0"
|
||||||
|
:max="1000"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<!-- 状态列 -->
|
||||||
|
<template #status="{ record }">
|
||||||
|
<a-switch
|
||||||
|
:checked-value="1"
|
||||||
|
unchecked-value="2"
|
||||||
|
@change="changeStatus($event, record.id)"
|
||||||
|
:default-checked="record.status == 1"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</ma-crud>
|
||||||
|
</div>
|
||||||
|
</a-modal>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup>
|
||||||
|
import { ref, nextTick } from "vue"
|
||||||
|
import dictApi from "@/api/system/dict"
|
||||||
|
import { Message } from "@arco-design/web-vue"
|
||||||
|
|
||||||
|
const crudRef = ref()
|
||||||
|
const visible = ref(false)
|
||||||
|
const currentRow = ref({ id: undefined, name: undefined })
|
||||||
|
|
||||||
|
// 改变dictItem的sort字段
|
||||||
|
const changeSort = async (value, id) => {
|
||||||
|
const response = await dictApi.numberOperation({ id, numberName: "sort", numberValue: value })
|
||||||
|
if (response.success) {
|
||||||
|
Message.success(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 改变dictItem状态
|
||||||
|
const changeStatus = async (status, id) => {
|
||||||
|
const response = await dictApi.changeItemStatus({ id, status })
|
||||||
|
if (response.success) {
|
||||||
|
Message.success(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开a-modal事件
|
||||||
|
const open = (row) => {
|
||||||
|
currentRow.value = row
|
||||||
|
// 调用固定方法请求数据
|
||||||
|
crudRef.value.requestParams = { id: currentRow.value.id }
|
||||||
|
crudRef.value.requestData()
|
||||||
|
visible.value = true
|
||||||
|
}
|
||||||
|
// crudOptions
|
||||||
|
const crudOptions = ref({
|
||||||
|
autoRequest: false,
|
||||||
|
api: dictApi.getDictItemAll,
|
||||||
|
showIndex: false,
|
||||||
|
rowSelection: { showCheckedAll: true },
|
||||||
|
operationColumn: true,
|
||||||
|
operationWidth: 160,
|
||||||
|
operationColumnAlign:'center',
|
||||||
|
beforeAdd: (form) => {
|
||||||
|
form.id = currentRow.value?.id
|
||||||
|
},
|
||||||
|
add: { show: true, api: dictApi.saveDictItem },
|
||||||
|
edit: { show: true, api: dictApi.updateDictItemData },
|
||||||
|
delete: { show: true, api: dictApi.realDeleteItem },
|
||||||
|
})
|
||||||
|
// crudColumns
|
||||||
|
const columns = ref([
|
||||||
|
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
|
||||||
|
{
|
||||||
|
title: "字典标签",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "title",
|
||||||
|
search: true,
|
||||||
|
width: 220,
|
||||||
|
commonRules: [{ required: true, message: "字典标签必填" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "字典键值",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "key",
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
search: true,
|
||||||
|
width: 220,
|
||||||
|
commonRules: [{ required: true, message: "字典键值必填" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "排序",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "sort",
|
||||||
|
formType: "input-number",
|
||||||
|
addDefaultValue: 1,
|
||||||
|
width: 180,
|
||||||
|
min: 0,
|
||||||
|
max: 1000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "状态",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "status",
|
||||||
|
search: true,
|
||||||
|
addDefaultValue: "1",
|
||||||
|
formType: "radio",
|
||||||
|
dict: { name: "data_status", props: { label: "title", value: "key" } },
|
||||||
|
addDefaultValue: "1",
|
||||||
|
width: 180
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "备注",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "remark",
|
||||||
|
hide: true,
|
||||||
|
formType: "textarea"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "更新时间",
|
||||||
|
align: "center",
|
||||||
|
dataIndex: "update_datetime",
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
search: true,
|
||||||
|
formType: "range",
|
||||||
|
width: 180
|
||||||
|
}
|
||||||
|
])
|
||||||
|
|
||||||
|
// 暴露自己的open方法
|
||||||
|
defineExpose({ open })
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
114
cdTMP/src/views/datamanage/dictmanage/index.vue
Normal file
114
cdTMP/src/views/datamanage/dictmanage/index.vue
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<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组件 -->
|
||||||
|
<ma-crud :options="crudOptions" :columns="crudColumns">
|
||||||
|
<!-- 字典标识列 -->
|
||||||
|
<template #code="{ record }">
|
||||||
|
<a-tooltip content="点击查看字典数据">
|
||||||
|
<a-link @click="openDictList(record)">
|
||||||
|
{{ record.code }}
|
||||||
|
</a-link>
|
||||||
|
</a-tooltip>
|
||||||
|
</template>
|
||||||
|
<!-- 状态列 -->
|
||||||
|
<template #status="{ record }">
|
||||||
|
<a-switch
|
||||||
|
:checked-value="1"
|
||||||
|
unchecked-value="2"
|
||||||
|
@change="changeStatus($event, record.id)"
|
||||||
|
:default-checked="record.status == 1"
|
||||||
|
>
|
||||||
|
</a-switch>
|
||||||
|
</template>
|
||||||
|
<template #operationBeforeExtend="{ record }">
|
||||||
|
<a-link @click="openDictList(record)"><icon-list /> 字典数据</a-link>
|
||||||
|
</template>
|
||||||
|
</ma-crud>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<data-list ref="datalist"></data-list>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="jsx">
|
||||||
|
import { ref } from "vue"
|
||||||
|
import dictApi from "@/api/system/dict"
|
||||||
|
import { Message } from "@arco-design/web-vue"
|
||||||
|
import DataList from "./dataList.vue"
|
||||||
|
|
||||||
|
const crudRef = ref()
|
||||||
|
const datalist = ref()
|
||||||
|
|
||||||
|
// 打开datalist页面
|
||||||
|
const openDictList = async (row) => {
|
||||||
|
datalist.value.open(row)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 点击切换status
|
||||||
|
const changeStatus = async (status, id) => {
|
||||||
|
const response = await dictApi.changeStatus({ id, status })
|
||||||
|
if (response.success) {
|
||||||
|
Message.success(response.message)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const crudOptions = ref({
|
||||||
|
api: dictApi.getDictIndex,
|
||||||
|
showIndex: false,
|
||||||
|
operationColumnAlign: "center",
|
||||||
|
rowSelection: { showCheckedAll: true },
|
||||||
|
searchColNumber: 4,
|
||||||
|
tablePagination: false,
|
||||||
|
operationColumn: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
const crudColumns = ref([
|
||||||
|
{ title: "ID", dataIndex: "id", addDisplay: false, editDisplay: false, width: 50, hide: true },
|
||||||
|
{
|
||||||
|
title: "字典备注",
|
||||||
|
dataIndex: "remark",
|
||||||
|
search: true,
|
||||||
|
width: 220,
|
||||||
|
align: "center",
|
||||||
|
commonRules: [{ required: true, message: "字典备注必填" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "字典标识",
|
||||||
|
dataIndex: "code",
|
||||||
|
search: true,
|
||||||
|
width: 260,
|
||||||
|
align: "center",
|
||||||
|
commonRules: [{ required: true, message: "字典标识必填" }]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "状态",
|
||||||
|
dataIndex: "status",
|
||||||
|
search: true,
|
||||||
|
formType: "radio",
|
||||||
|
align: "center",
|
||||||
|
dict: { name: "data_status", props: { label: "title", value: "key" } },
|
||||||
|
addDefaultValue: "1",
|
||||||
|
width: 180
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "字典名称",
|
||||||
|
dataIndex: "name",
|
||||||
|
hide: true,
|
||||||
|
formType: "textarea",
|
||||||
|
align: "center"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: "更新时间",
|
||||||
|
dataIndex: "update_datetime",
|
||||||
|
addDisplay: false,
|
||||||
|
editDisplay: false,
|
||||||
|
align: "center",
|
||||||
|
search: true,
|
||||||
|
formType: "range",
|
||||||
|
width: 180
|
||||||
|
}
|
||||||
|
])
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="less" scoped></style>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup lang="jsx">
|
||||||
import { ref } from "vue"
|
import { ref } from "vue"
|
||||||
import { useRoute, useRouter } from "vue-router"
|
import { useRoute, useRouter } from "vue-router"
|
||||||
import dutApi from "@/api/project/dut"
|
import dutApi from "@/api/project/dut"
|
||||||
@@ -123,7 +123,7 @@ const crudColumns = ref([
|
|||||||
translation: true,
|
translation: true,
|
||||||
tagColors: { XQ: "blue", SO: "green", SJ: "orangered", XY: "pinkpurple" }
|
tagColors: { XQ: "blue", SO: "green", SJ: "orangered", XY: "pinkpurple" }
|
||||||
},
|
},
|
||||||
control: (value) => {
|
control: (value, data) => {
|
||||||
if (value === "SO") {
|
if (value === "SO") {
|
||||||
return {
|
return {
|
||||||
black_line: { display: true },
|
black_line: { display: true },
|
||||||
@@ -135,6 +135,8 @@ const crudColumns = ref([
|
|||||||
comment_line: { display: true }
|
comment_line: { display: true }
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// 其他数据清除
|
||||||
|
|
||||||
return {
|
return {
|
||||||
black_line: { display: false },
|
black_line: { display: false },
|
||||||
pure_code_line: { display: false },
|
pure_code_line: { display: false },
|
||||||
@@ -160,41 +162,74 @@ const crudColumns = ref([
|
|||||||
title: "空行",
|
title: "空行",
|
||||||
hide: true,
|
hide: true,
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "black_line"
|
dataIndex: "black_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "纯注释",
|
title: "纯注释",
|
||||||
hide: true,
|
hide: true,
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "pure_code_line"
|
dataIndex: "pure_code_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "混合行",
|
title: "混合行",
|
||||||
hide: true,
|
hide: true,
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "mix_line"
|
dataIndex: "mix_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "总注释",
|
title: "总注释",
|
||||||
hide: true,
|
hide: true,
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "total_comment_line"
|
dataIndex: "total_comment_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "总代码",
|
title: "总代码",
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "total_code_line"
|
dataIndex: "total_code_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "总行数",
|
title: "总行数",
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "total_line"
|
dataIndex: "total_line",
|
||||||
|
formType: "input-number"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: "注释率",
|
title: "注释率 %",
|
||||||
align: "center",
|
align: "center",
|
||||||
dataIndex: "comment_line",
|
dataIndex: "comment_line",
|
||||||
commonRules: [{ required: true, message: "注释率必填" }]
|
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()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ const crudColumns = ref([
|
|||||||
{
|
{
|
||||||
title: "测试级别",
|
title: "测试级别",
|
||||||
dataIndex: "test_level",
|
dataIndex: "test_level",
|
||||||
commonRules: [{ required: true, message: "请至少选择一个" }],
|
commonRules: [{ required: true, message: "请至少选择一个测试级别" }],
|
||||||
addDefaultValue: ["6"],
|
addDefaultValue: ["6"],
|
||||||
hide: true,
|
hide: true,
|
||||||
formType: "checkbox",
|
formType: "checkbox",
|
||||||
@@ -227,9 +227,10 @@ const crudColumns = ref([
|
|||||||
{
|
{
|
||||||
title: "平台类型",
|
title: "平台类型",
|
||||||
dataIndex: "plant_type",
|
dataIndex: "plant_type",
|
||||||
addDefaultValue: "4",
|
commonRules: [{ required: true, message: "请至少选择一个平台类型" }],
|
||||||
|
addDefaultValue: ["3"],
|
||||||
hide: true,
|
hide: true,
|
||||||
formType: "radio",
|
formType: "checkbox",
|
||||||
dict: { name: "plant_type", props: { label: "title", value: "key" } }
|
dict: { name: "plant_type", props: { label: "title", value: "key" } }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user