Browse Source

代码关系图谱

master
si@aidatagov.com 2 months ago
parent
commit
cfad534fb9
  1. 15
      vue-fastapi-backend/module_admin/controller/datastd_controller.py
  2. 2
      vue-fastapi-backend/module_admin/dao/datastd_dao.py
  3. 43
      vue-fastapi-backend/module_admin/service/datastd_service.py
  4. 66
      vue-fastapi-frontend/src/views/datastd/stdcode/codeMap.vue
  5. 4
      vue-fastapi-frontend/src/views/datastd/stdcode/index.vue

15
vue-fastapi-backend/module_admin/controller/datastd_controller.py

@ -527,7 +527,7 @@ async def change_std_main_onum(
# 标准代码映射图谱
@datastdController.get(
'/stdcode/code/mapstdlist/{id}', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('datastd:stdcode:code:list'))]
'/stdcode/code/mapstdlistOld/{id}', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('datastd:stdcode:code:list'))]
)
async def get_code_std_map_list(
request: Request,
@ -537,3 +537,16 @@ async def get_code_std_map_list(
code_page_query_result = await DataStdService.get_code_std_map_list_services(query_db, id)
logger.info('获取列配置列表成功')
return ResponseUtil.success(data=code_page_query_result)
@datastdController.get(
'/stdcode/code/mapstdlist/{id}', response_model=PageResponseModel, dependencies=[Depends(CheckUserInterfaceAuth('datastd:stdcode:code:list'))]
)
async def get_code_map_list(
request: Request,
id: str,
query_db: AsyncSession = Depends(get_db),
):
code_page_query_result = await DataStdService.get_code_map_list(query_db, id)
logger.info('获取列配置列表成功')
return ResponseUtil.success(data=code_page_query_result)

2
vue-fastapi-backend/module_admin/dao/datastd_dao.py

@ -106,9 +106,11 @@ class DataStdDao:
select(DataStdCode)
.where(
DataStdCode.code_name == query_object.code_name if query_object.code_name else True,
DataStdCode.id == query_object.id if query_object.id else True,
DataStdCode.code_status == query_object.code_status if query_object.code_status else True,
DataStdCode.sys_id == query_object.sys_id if query_object.sys_id else True,
DataStdCode.code_type == query_object.code_type if query_object.code_type else True,
DataStdCode.code_map_id == query_object.code_map_id if query_object.code_map_id else True,
DataStdCode.parent_id == query_object.parent_id if query_object.parent_id else True,
DataStdCode.class_id == query_object.class_id if query_object.class_id else True
)

43
vue-fastapi-backend/module_admin/service/datastd_service.py

@ -1028,3 +1028,46 @@ class DataStdService:
"tableData": table_data,
"children": children
}
@classmethod
async def get_code_map_list(cls, query_db: AsyncSession, id: str):
check_model = DataStdCodeModel()
stdCode=await DataStdDao.get_std_code_by_id(query_db, id)
code_type="公司级"
if stdCode.code_type=='sys':
if stdCode.code_map_id:
check_model.id=stdCode.code_map_id
else:
check_model.id="no"
else:
check_model.code_map_id = id
code_type="系统级"
main_list = await DataStdDao.get_data_code_list_by_info(query_db, check_model)
if not main_list:
return { "children": []} # 如果 A 表没有数据,返回空结构
table_data = [] # 存储表格数据
children = [] # 存储图谱数据
for main in main_list:
# 组织图谱数据(A 表作为父节点)
node = {
"id": f"node_{main.id}", # 使用 get() 方法访问字段
"name": main.code_name, # 使用 get() 方法访问字段
"label": main.code_num, # 使用 get() 方法访问字段
"rate": 1.0,
"status": "B",
# "currency": main.get('stdNum'), # 使用 get() 方法访问字段
"variableValue": code_type,
"variableUp": True,
"children": [],
}
children.append(node)
return {
"tableData": table_data,
"children": children
}

66
vue-fastapi-frontend/src/views/datastd/stdcode/codeMap.vue

@ -1,5 +1,11 @@
<template>
<el-form :model="form" ref="formRef" label-width="120px" >
<el-tabs v-model="activeName" style="margin-top: 8px">
<el-tab-pane label="图谱" name="1">
<treeNodeg6 ref="treeGraph" :mockData="mockData" />
</el-tab-pane>
<el-tab-pane label="表格" name="2">
<el-form :model="form" ref="formRef" label-width="120px" >
<div class="form-container">
<el-row :gutter="20">
<!-- 代码归属 -->
@ -20,24 +26,7 @@
</div>
<!-- 查询表单 -->
<!-- <div class="query-form-container">
<el-form :model="queryParams" ref="queryRef" :inline="true">
<el-form-item label="代码值/名称" prop="codeNum">
<el-input
v-model="queryParams.codeNum"
placeholder="请输入标准代码编号"
clearable
style="width: 220px"
/>
</el-form-item>
<el-form-item>
<el-button type="primary" @click="handleQuery">搜索</el-button>
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
</div> -->
</el-form>
@ -116,12 +105,13 @@
</el-table-column>
</el-table>
</el-tab-pane>
</el-tabs>
</template>
<script setup>
import { ref, reactive, onMounted, toRefs } from 'vue';
import { listStdCodemap,getStdCode} from "@/api/datastd/std"; //
import { listStdCodemap,getStdCode,getStdCodeMap} from "@/api/datastd/std"; //
import treeNodeg6 from "./treeNodeg6.vue";
const { proxy } = getCurrentInstance();
const { std_code_status } = proxy.useDict("std_code_status");
@ -134,6 +124,7 @@ const props = defineProps({
});
const queryParams = ref({
codeNum: '',
parentId: props.codeId,
@ -159,7 +150,7 @@ const form = ref({
codeMapNum: '',
sysId: undefined
});
const activeName = ref("1"); //
const tableData = ref([]);
const selections = ref([]);
const loading = ref(false);
@ -222,16 +213,41 @@ const resetQuery = () => {
defineExpose({
selections
});
const treeGraph = ref(null);
const mockData = ref({
id: "g1",
name: "",
count: 123456,
label: "",
rate: 1.0,
status: "G",
variableValue: "代码",
variableUp: true,
children:[]
});
onMounted(() => {
getStdCode(props.codeId).then(response => {
nextTick(() => {
getStdCode(props.codeId).then(response => {
form.value = response.data;
queryParams.value.codeType=form.value.codeType
mockData.value.variableValue=form.value.codeType == "sys"?"系统级":"公司级"
mockData.value.name=form.value.codeName
mockData.value.label=form.value.codeNum
getStdCodeMap(form.value.id).then(response => {
mockData.value.children = response.data.children;
tableData.value = response.data.tableData;
if (treeGraph.value) {
treeGraph.value.refreshGraph();
}
});
getList();
});
// getcompanyList()
});
});
</script>

4
vue-fastapi-frontend/src/views/datastd/stdcode/index.vue

@ -105,7 +105,7 @@
/>
</template>
</el-table-column>
<el-table-column label="引用情况" align="center" >
<!-- <el-table-column label="引用情况" align="center" >
<template #default="scope">
<el-link
type="primary"
@ -116,7 +116,7 @@
查看
</el-link>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="代码关系" align="center" >
<template #default="scope">

Loading…
Cancel
Save