Browse Source

短句配置分类逻辑优化

master
xueyinfei 4 weeks ago
parent
commit
cbf1df4c15
  1. 15
      vue-fastapi-backend/module_admin/dao/sscf_dao.py
  2. 2
      vue-fastapi-backend/module_admin/service/sscf_service.py
  3. 126
      vue-fastapi-frontend/src/views/dataint/sscf/index.vue
  4. 2
      vue-fastapi-frontend/src/views/meta/metaInfo/index.vue

15
vue-fastapi-backend/module_admin/dao/sscf_dao.py

@ -5,6 +5,7 @@ from sqlalchemy import desc, delete, func, select, update
from sqlalchemy.ext.asyncio import AsyncSession
from module_admin.entity.vo.user_vo import CurrentUserModel
from module_admin.entity.vo.dataint_vo import SscfPageObject, TreeOperateModel, SaveSscfModel
from module_admin.entity.do.data_ast_content_do import DataAstContent
from module_admin.entity.do.dataint_do import SysSscf, SysDassetTree
from sqlalchemy import select, text, cast, Integer, and_, or_, outerjoin, func, join
from utils.page_util import PageUtil
@ -17,12 +18,16 @@ class SscfDao:
@classmethod
async def get_sscf_list(cls, db: AsyncSession, sscf_query: SscfPageObject):
parent_conditions = []
if sscf_query.dasset_id:
for pid in sscf_query.dasset_id.split(','):
parent_conditions.append(func.FIND_IN_SET(str(pid), SysSscf.dasset_id) > 0)
query = (
select(SysSscf).where(
SysSscf.keyword.like(f'%{sscf_query.keyword}%') if sscf_query.keyword else True,
SysSscf.type.like(f'%{sscf_query.type}%') if sscf_query.type else True,
SysSscf.dasset_id.in_(sscf_query.dasset_id.split(',')) if sscf_query.dasset_id else True,
SysSscf.status == sscf_query.status if sscf_query.status else True
SysSscf.status == sscf_query.status if sscf_query.status else True,
or_(*parent_conditions) if parent_conditions else True
).distinct()
)
query_result = await PageUtil.paginate(db, query, sscf_query.page_num, sscf_query.page_size, True)
@ -87,9 +92,10 @@ class SscfDao:
result = (
(
await db.execute(
select(SysDassetTree).where(SysDassetTree.dasset_code == name).distinct()
select(DataAstContent.content_onum).where(DataAstContent.content_name.in_(name.split(","))
).distinct()
)
).scalars().first()
).scalars().all()
)
return result
@ -122,4 +128,3 @@ class SscfDao:
@classmethod
async def delete_dasset_tree(cls, db: AsyncSession, onum: str):
await db.execute(delete(SysDassetTree).where(SysDassetTree.onum == onum))

2
vue-fastapi-backend/module_admin/service/sscf_service.py

@ -199,7 +199,7 @@ class SscfService:
})
continue
sscf = SaveSscfModel()
sscf.dasset_id = dasset.onum,
sscf.dasset_id = ",".join(map(str, dasset))
sscf.keyword = row['keyword']
sscf.algorithm = row['algorithm']
sscf.order = 'True' if row['order'] == '' else 'False'

126
vue-fastapi-frontend/src/views/dataint/sscf/index.vue

@ -14,7 +14,7 @@
<div class="head-container">
<el-tree
:data="dassetOptions"
:props="{ label: 'dassetName', children: 'children' }"
:props="{ label: 'contentName', children: 'children' }"
:expand-on-click-node="false"
:filter-node-method="filterNode"
ref="deptTreeRef"
@ -25,15 +25,7 @@
>
<template #default="{ data }">
<div class="custom-tree-node" @mouseenter="data.show = true" @mouseleave="data.show = false">
<span>{{ data.dassetName }}</span>
<div v-if="data.parentCode === '0' && data.show">
<el-link :underline="false" style="font-size: 16px;margin: 5px" type="primary" icon="Plus" @click="handleAddTree(data)"></el-link>
<el-link :underline="false" style="font-size: 16px;margin: 5px" type="success" icon="Edit" @click="handleEditTree(data)"></el-link>
</div>
<div v-if="data.parentCode !== '0' && data.show">
<el-link :underline="false" style="font-size: 16px;margin: 5px" type="success" icon="Edit" @click="handleEditTree(data)"></el-link>
<el-link :underline="false" style="font-size: 16px;margin: 5px" type="danger" icon="Delete" @click="handleDeleteTree(data)"></el-link>
</div>
<span>{{ data.contentName }}</span>
</div>
</template>
</el-tree>
@ -163,9 +155,20 @@
:rules="rules"
label-width="125px">
<el-form-item label="归属资产名:" prop="dassetId">
<el-select v-model="currentForm.dassetId" style="width: 100%;" clearable>
<el-option v-for="item in dassetList" :key="item.onum" :value="item.onum" :label="item.dassetName"></el-option>
</el-select>
<el-tree-select
v-model="currentForm.dassetId"
:data="dassetOptions"
multiple
default-expand-all
check-on-click-node
check-strictly
:props="{
label: 'contentName', //
value: 'contentOnum', //
children: 'children' //
}"
@change="changeDassetId"
style="width: 100%;" clearable />
</el-form-item>
<el-form-item label="关键词:" prop="keyword">
<el-input
@ -315,6 +318,7 @@ import { ref, nextTick, computed, watch, reactive, onMounted } from 'vue'
import { getSscfList, saveSscf, deleteSscf, get_dasset_tree, saveDassetTreeNode } from "@/api/dataint/sscf"
import * as XLSX from "xlsx";
import {getToken} from "../../../utils/auth.js";
import {getDirectoryTree} from "../../../api/dataAsset/directory.js";
const { proxy } = getCurrentInstance();
@ -329,7 +333,7 @@ const queryParams = ref({
})
const currentForm = ref({
operate: 'ADD',
dassetId:'',
dassetId:[],
status:'1',
keyword:'',
algorithm:'包含',
@ -398,19 +402,7 @@ const handleFileSuccess = (response, file, fileList) => {
}
getList();
}
function handleAddTree(){
showTreeDialog.value = true
currentTreeNode.value = {
operate: 'ADD',
dassetCode: '',
dassetName: ''
}
}
function handleEditTree(data){
currentTreeNode.value = data
currentTreeNode.value.operate = 'UPDATE'
showTreeDialog.value = true
}
function handleSaveTree(){
let param = {
operate: currentTreeNode.value.operate,
@ -424,17 +416,7 @@ function handleSaveTree(){
get_tree_data()
})
}
function handleDeleteTree(data){
let param = {
onum: data.onum,
dassetCode: data.dassetCode,
operate: 'DELETE'
}
saveDassetTreeNode(param).then(res=>{
proxy.$modal.msgSuccess("操作成功")
get_tree_data()
})
}
function handleQuery(){
queryParams.value.pageNum = 1;
getList()
@ -445,13 +427,17 @@ function getList(){
total.value = res.data.total
})
}
function changeDassetId(){
console.log(dassetOptions.value)
console.log(currentForm.value.dassetId)
}
/** 节点单击事件 */
function handleNodeClick(data) {
queryParams.value.dassetId = getAllChildOnums(data).join(',');
handleQuery();
}
const getAllChildOnums = (node) => {
const onums = [node.onum]; // onum
const onums = [node.contentOnum]; // onum
if (node.children && node.children.length > 0) {
node.children.forEach(childNode => {
onums.push(...getAllChildOnums(childNode)); //
@ -475,7 +461,7 @@ function handleAdd(){
showDialog.value = true
currentForm.value ={
operate: 'ADD',
dassetId:'',
dassetId:[1],
status:'1',
keyword:'',
algorithm:'包含',
@ -503,7 +489,9 @@ function changeStatus(row){
function handleSave(){
proxy.$refs.formRef.validate(valid => {
if (valid) {
saveSscf(currentForm.value).then(res=>{
let data = currentForm.value;
data.dassetId = data.dassetId.join(',')
saveSscf(data).then(res=>{
proxy.$modal.msgSuccess("操作成功");
showDialog.value = false
getList()
@ -557,23 +545,51 @@ function handleExport(){
function handleSelection(val){
multSelection.value= val
}
function cleanTreeData(nodes) {
if (!nodes || nodes.length === 0) return;
nodes.forEach(node => {
//
if (node.children?.length > 0) {
cleanTreeData(node.children);
}
//
if (node.children) {
node.children = node.children.filter(child =>
Boolean(child.contentName) //
);
}
});
}
function get_tree_data(){
get_dasset_tree().then(res=>{
let treeList = res.data
if(treeList.length > 0){
let children = []
dassetOptions.value = []
for (let i = 0; i < treeList.length; i++) {
if (treeList[i].dassetCode === "root"){
dassetOptions.value.push(treeList[i])
}else {
children.push(treeList[i])
}
}
dassetOptions.value[0].children = children
dassetList.value = children
getDirectoryTree({pageSize: 999}).then(res => {
dassetOptions.value = []
let array = res.rows;
if(array.length >0 && array[0].children && array[0].children.length>0){
array[0].children = array[0].children.filter(child =>
Boolean(child.contentName !== '我的收藏') //
);
}
cleanTreeData(array)
dassetOptions.value = array
})
// get_dasset_tree().then(res=>{
// let treeList = res.data
// if(treeList.length > 0){
// let children = []
// dassetOptions.value = []
// for (let i = 0; i < treeList.length; i++) {
// if (treeList[i].dassetCode === "root"){
// dassetOptions.value.push(treeList[i])
// }else {
// children.push(treeList[i])
// }
// }
// dassetOptions.value[0].children = children
// dassetList.value = children
// }
// })
}
/** 通过条件过滤节点 */
const filterNode = (value, data) => {

2
vue-fastapi-frontend/src/views/meta/metaInfo/index.vue

@ -132,7 +132,7 @@
<el-table-column label="模式名称" align="center" prop="mdlName"></el-table-column>
<el-table-column label="对象英文名" width="170" align="center" prop="tabEngName" >
<template #default="scope">
<el-link type="primary" @click="showColumnDialog(scope.row)" :underline="false">{{ scope.row.tabEngName }}</el-link>
<el-button style="white-space: normal; word-break: break-word; width: 100%;" link type="primary" @click="showColumnDialog(scope.row)" :underline="false">{{ scope.row.tabEngName }}</el-button>
</template>
</el-table-column>
<el-table-column label="对象中文名" width="100" align="center" prop="tabCnName"></el-table-column>

Loading…
Cancel
Save