e7fc36f3 by xukangle

updata: 增加元数据模块

1 parent 8ad5d02b
......@@ -3,8 +3,8 @@ VITE_APP_TITLE = 数据资产管理系统
# 接口域名
# VITE_API_BASEURL = https://www.zgsjzc.com/api
# VITE_API_BASEURL = https://swzl-test.csbr.cn/api
VITE_API_BASEURL = http://localhost:9000
# VITE_API_BASEURL = http://10.4.82.1:28052/
# VITE_API_BASEURL = http://localhost:9000
VITE_API_BASEURL = http://10.4.82.1:28052/
# 平台用户 接口请地址
VITE_APP_USER_API_BASEURL = gateway-server
......@@ -13,6 +13,7 @@ VITE_APP_AUTH_URL = 'ms-daop-auth-service'
# 系统管理 接口地址
VITE_APP_API_BASEURL = ms-daop-zcgl-system-manager-service
# 文件上传请求地址
VITE_APP_ADD_FILE = ms-daop-import-data-service
# 调试工具,可设置 eruda 或 vconsole,如果不需要开启则留空
......@@ -29,8 +30,8 @@ VITE_APP_PLAN_BASEURL = ms-daop-jgjf-data-plan-service
VITE_APP_QUALITY_BASEURL = ms-daop-data-quality-service
#数据盘点接口地址ms-daop-zcgl-data-inventory
VITE_APP_CHECK_BASEURL = /mock
# VITE_APP_CHECK_BASEURL = ms-daop-zcgl-data-inventory
# VITE_APP_CHECK_BASEURL = /mock
VITE_APP_CHECK_BASEURL = ms-daop-zcgl-data-inventory
#门户接口
VITE_API_PORTALURL = https://swzl-test.zgsjzc.com/portal
......
......@@ -2,6 +2,159 @@ import request from "@/utils/request";
/**
* 数据字典
**/
// 编码规则流水号
export const getCoderuleList = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/code-rule/list`,
method: 'post',
data: params
})
// 获取数据类型的接口
export const getDataTypeList = (params) => request({
url: `${import.meta.env.VITE_APP_API_BASEURL}/data-dict/get-data-list`,
method: 'post',
data: params,
})
// 获取数据库列表
export const getDataBaseList = (params) => request({
url: `${import.meta.env.VITE_APP_API_BASEURL}/data-source/get-source-list`,
method: 'post',
data: params,
})
// 新增
export const addDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/add`,
method: 'post',
data: params
})
// 删除
export const deleteDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/del`,
method: 'delete',
data: params
})
// 删除数据字典前的校验
export const checkDeleteDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-del`,
method: 'delete',
data: params
})
// 编辑校验数据结构删除的条件
export const checkDeleteDictionaryScheme = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-del/dictionary-scheme`,
method: 'post',
data: params
})
// 分页查询
export const getDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/page-list`,
method: 'post',
data: params
})
// 查询数据字典启用状态的数据
export const getDictionaryAll = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/list-all`,
method: 'post',
params
})
// 修改
export const updateDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/update`,
method: 'put',
data: params
})
// 详情
export const getDictionaryDetail = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/detail/${params}`,
method: 'get'
})
// 查看数据字典数据
export const getDictionaryFileds = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/dictionary-data/${params}`,
method: 'get'
})
// 数据字典启用停用
export const updateDictionaryState = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/change-state`,
method: 'get',
params
})
// 检验是否存在
export const checkDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check-exist`,
method: 'get',
params
})
// 数据字典新增数据时生成编码规则
export const getDictionaryRuleData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/generate/code-rule/byGuid`,
method: 'get',
params
})
// 数据字典树形数据
export const getDictionaryTree = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/tree-list`,
method: 'post',
params
})
// 保存动态数据字典数据
export const saveDictionaryData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/save/dictionary-data`,
method: 'post',
data: params
})
// 更新数据字典数据
export const updateDictionaryData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/update/dictionary-data`,
method: 'post',
data: params
})
// 删除数据字典数据
export const deleteDictionaryData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/del/dictionary-data`,
method: 'delete',
data: params
})
// 导入数据字典
export const importDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/import/data-dictionary`,
method: 'post',
data: params
})
// 显示导入的数据字典数据
export const showDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/import/show/data-dictionary`,
method: 'post',
data: params,
headers: {
'Content-Type': 'multipart/form-data'
}
})
// 导出数据字典模板
export const exportDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/export/data-dictionary/schema`,
method: 'post',
data: params,
responseType: 'blob'
})
// 导出数据字典数据
export const exportDictionaryFileds = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/export/data-dictionary/data`,
method: 'post',
data: params,
responseType: 'blob'
})
// 验证数据是否符合标准
export const checkDictionaryData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/data-dictionary-general/check/dictionary-data`,
method: 'post',
data: params
})
/**
* 获取数据级别
* @param {Object}
* { paramCode: "DATA-CLASSIFY" }
......@@ -230,10 +383,10 @@ export const getCgDirFieldPageList = (data) => request({
/** 获取字典列表
* VITE_APP_PLAN_BASEURL 为环境变量 现在只是mock数据
*/
export const getDictionary = (params) => request({
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/data-dictionary-general/list-all?state=1`,
method: 'post'
})
// export const getDictionary = (params) => request({
// url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/data-dictionary-general/list-all?state=1`,
// method: 'post'
// })
......@@ -268,3 +421,8 @@ export const getDbDirTablePageList = (data) => request({
method: 'post',
data
})
......
......@@ -17,10 +17,11 @@ export const deleteMetaDataTask = (params) => request({
})
// 分页查询
export const getMetaDataTask = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/page-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-collect-task/page-list`,
method: 'post',
data: params
})
// 修改
export const updateMetaDataTask = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/update`,
......@@ -57,7 +58,7 @@ export const getMetaDataTaskLog = (params) => request({
method: 'post',
data: params
})
//
//
export const saveMetaReportAnalysis = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/lineage-analysis-report/add`,
method: 'post',
......@@ -65,34 +66,34 @@ export const saveMetaReportAnalysis = (params) => request({
})
/**
* 元数据-元数据查询
**/
**/
// 树形数据
export const getMetaTreeData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-tree-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-tree-list`,
method: 'post',
data: params
})
// 数据库汇总信息
export const getMetaDatabaseCollect = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-database-collect-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-database-collect-list`,
method: 'post',
data: params
})
// 库分页查询
export const getMetaDataBase = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-collect-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-collect-list`,
method: 'post',
data: params
})
// 表分页查询
export const getMetaDataSheet = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-detail-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-detail-list`,
method: 'post',
data: params
})
// 表字段查询
export const getMetaSheetField = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-table-field-list`,
url: `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-table/meta-table-field-list`,
method: 'post',
params
})
......@@ -114,7 +115,7 @@ export const getMetaChangeRecord = (params) => request({
method: 'post',
data: params
})
//
//
export const getMetacompareList = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/meta-change-compare-list/${params}`,
method: 'get',
......@@ -216,7 +217,7 @@ export const updateAnalysisRepor = (params) => request({
method: 'put',
data: params
})
/** 删除边 */
/** 删除边 */
export const delLineAge = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/lineage/del-edge?euid=${params}`,
method: 'delete',
......@@ -226,7 +227,7 @@ export const checkTableData = (params) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-table/check-table-data/${params}`,
method: 'get',
})
/**校验任务是否有数据库信息 */
/**校验任务是否有数据库信息 */
export const checkDatabaseIsExist = (dataSourceGuid) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/check-database-is-exist/${dataSourceGuid}`,
method: 'get',
......@@ -236,4 +237,4 @@ export const checkDatabaseIsExist = (dataSourceGuid) => request({
export const syncChangeDetail = (guid) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/task-change-record/sync-change-detail/${guid}`,
method: 'get',
})
\ No newline at end of file
})
......
......@@ -231,7 +231,28 @@ const routes: RouteRecordRaw[] = [
},
},
],
}
},
{
path: '/data-standards/data-dictionary',
component: Layout,
meta: {
title: '数据字典',
icon: 'sidebar-cooperation',
},
children: [
{
path: '',
name: 'dictionary',
component: () => import('@/views/data_standards/dictionary.vue'),
meta: {
title: '数据字典',
sidebar: false,
breadcrumb: false,
cache: true
},
},
],
},
]
export default routes
......
......@@ -58,6 +58,7 @@ const useUserStore = defineStore(
userName.value = res.data.userName
// userData.value = JSON.stringify(res.data.data);
currentTenantGuid.value = res.data.tenantInfoList && res.data.tenantInfoList.length ? res.data.tenantInfoList[0].guid : '';
localStorage.setItem('currentTenantGuid', currentTenantGuid.value);
let currentTenant = res.data.tenantInfoList?.[0];
return getSystemMenu({ tenantGuid: currentTenantGuid.value }).then((info: any) => {
if (info.code == '00000') {
......
......@@ -31,7 +31,7 @@ service.interceptors.request.use(
* 为每一次请求生成一个cancleToken
*/
const source = axios.CancelToken.source();
config.headers.tenant = '9e5b9d7bfd8c4f4f8079e05de19bf7e0'; //会员guid先写死
config.headers.tenant = localStorage.getItem('currentTenantGuid'); //会员guid先写死
config.cancelToken = source.token;
if (config.method === "postfile") {
config.method = "post";
......
......@@ -2,9 +2,86 @@
name: configureRules //标签管理
</route>
<script lang="ts" setup name="configureRules"></script>
<script lang="ts" setup name="configureRules">
import { TableColumnWidth } from '@/utils/enum';
const dataBasePage = ref({
limit: 10,
curr: 1,
sizes: [
{ label: "10", value: 10 },
{ label: "20", value: 20 },
{ label: "100", value: 100 },
{ label: "150", value: 150 },
{ label: "200", value: 200 },
],
});
const dataBaseTableInfo = ref({
id: "data-base-table",
multiple: false,
fixedSelection: true,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "数据源", field: "databaseChName", width: 140 },
{ label: "表名称", field: "tableChName", width: 180 },
{ label: "数据库表", field: "enName", width: 120 },
{
label: "新建方式", field: "foundMode", width: 140, getName: (scope) => {
let dataGrade = scope.row.foundMode;
return dataGrade == 1 ? '根据文件新建' : '已有表新建';
}
},
{
label: "状态", field: "state", type: 'tag', width: 180, getName: (scope) => {
let status = scope.row.state;
// 0 草稿中 1 已建表 2 已有默认表
return status == 0 ? '草稿中' : status == 1 ? '已建表' : '已有默认表';
}
},
{ label: "任务修改人", field: "damName", width: 120 },
{ label: "修改时间", field: "updateTime", width: TableColumnWidth.DATETIME },
{ label: "描述", field: "databaseName", width: 120, align: 'center' },
{
label: "规划数据资产", field: "isDataAsset", type: 'switch', activeText: '是', inactiveText: '否', activeValue: 'Y',
inactiveValue: 'N', switchWidth: 56, width: 120, align: 'center'
},
],
data: [],
page: {
type: "normal",
rows: 0,
...dataBasePage.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 300,
fixed: 'right',
btns: [
{
label: "配置业务规则", value: "edit", click: (scope) => {
console.log('编辑', scope);
// 路由跳转configure-rules
}
},
{
label: "编辑表结构", value: "copy", click: (scope) => {
console.log('复制', scope);
}
}
]
},
loading: false
});
</script>
<template>
<div>111</div>
<div class="table_panel_wrap">
<Table :tableInfo="dataBaseTableInfo" />
</div>
</template>
......
<route lang="yaml">
name: dictionary
</route>
<script lang="ts" setup name="dictionary">
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from "element-plus";
import { Search } from '@element-plus/icons-vue'
import Tree from '@/components/Tree/index.vue'
import Table from '@/components/Table/index.vue'
import Drawer from '@/components/Drawer/index.vue'
import DictFileds from './dictFileds.vue'
import useCatchStore from "@/store/modules/catch";
import { download } from '@/utils/common'
import {
addDictionary,
deleteDictionary,
getDictionary,
updateDictionary,
getDictionaryTree,
getDictionaryDetail,
exportDictionary,
showDictionary,
getDataBaseList,
getDataTypeList,
getCoderuleList,
saveDictionaryData,
getDictionaryFileds,
updateDictionaryState,
getDictionaryRuleData,
exportDictionaryFileds,
checkDeleteDictionary,
checkDeleteDictionaryScheme,
checkDictionaryData
} from '@/api/modules/dataInventory';
const { proxy } = getCurrentInstance() as any;
const cacheStore = useCatchStore()
// 禁用字段
const forbidFields = [
'guid',
'sharding_flag',
'create_user_id',
'create_user_name',
'update_user_id',
'update_user_name',
'create_time',
'update_time',
'is_deleted'
]
const showFiledsPage = ref(false)
const dictFiledsRef = ref()
const dataTypeList = ref([])
const dataBaseList = ref([])
const codeRuleList = ref([])
const dictTreeRef = ref()
const dictType = ref(-1)
const dictGuid = ref('')
const expandedKey: any = ref([])
const currentNodeKey = ref('')
const showLoading = ref(true)
const treeData = ref([])
const treeInfo = ref({
id: "data-pickup-tree",
filter: true,
queryValue: "",
queryPlaceholder: "输入字典名称搜索",
props: {
label: "name",
value: "guid",
},
nodeKey: 'guid',
expandedKey: [],
currentNodeKey: '',
data: [],
expandOnNodeClick: false,
loading: false
});
const tableSearchInput = ref('')
const currTableData: any = ref<Object>({});
const page = ref({
limit: 50,
curr: 1,
sizes: [
{ label: "10", value: 10 },
{ label: "50", value: 50 },
{ label: "100", value: 100 },
{ label: "150", value: 150 },
{ label: "200", value: 200 },
],
});
const selectRowData = ref([])
const tableInfo: any = ref({
id: 'data-source-table',
multiple: true,
fixedSelection: true,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "字典中文名", field: "chName", type: 'text_btn', class: 'drawer-detail-cell', width: 120, value: 'detail', columClass: 'text_btn' },
{ label: "字典英文名", field: "enName", width: 120 },
{ label: "字典类型", field: "dictionaryType", type: 'filter', width: 120 },
{ label: "排序", field: "orderNum", type: 'filter', width: 56, align: 'center' },
{ label: '状态', field: 'state', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' },
{ label: "编码规则", field: "codeRuleName", width: 120 },
{ label: "修改人", field: "updateUserName", width: 140 },
{ label: "修改时间", field: "updateTime", width: 180, },
],
data: [],
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 92, //不要刚好90.缩小浏览器会因为小数点的差距而换行,
fixed: 'right',
btns: [
{ label: "编辑", value: "edit" },
{ label: "删除", value: "delete" },
],
},
loading: false
})
const dictionaryType = ref(1)
const orginOptions = [
{ label: 'code', value: 'code' },
{ label: 'name', value: 'name' },
]
const orginItems = [
// {
// label: '数据库名称',
// type: 'select',
// placeholder: '请选择',
// field: 'databaseNameZh',
// options: [],
// clearable: true,
// required: true,
// visible: true,
// },
{
label: '字典中文名',
type: 'input',
maxlength: 50,
placeholder: '请输入',
field: 'chName',
clearable: true,
required: true,
disabled: false
}, {
label: '字典英文名',
type: 'input',
maxlength: 50,
placeholder: '请输入',
field: 'enName',
clearable: true,
required: true,
disabled: false
}, {
label: '排序',
type: 'input',
placeholder: '请输入',
field: 'orderNum',
maxlength: 6,
clearable: true,
required: true,
visible: true,
}, {
label: '字典类型',
type: 'radio-panel',
placeholder: '',
field: 'dictionaryType',
default: 1,
options: [
{ label: '列表结构', value: 1 },
{ label: '层级结构', value: 2 },
{ label: '螺旋结构', value: 3 },
{ label: '通用结构', value: 4 },
],
children: [
{
label: '编码字段',
type: 'select',
placeholder: '请输入',
field: 'codeColumn',
default: '',
options: [],
clearable: true,
required: true
}, {
label: '编码名称',
type: 'select',
placeholder: '请输入',
field: 'codeName',
default: '',
options: [],
clearable: true,
required: true
}, {
label: '顶级节点值',
type: 'input',
placeholder: '请输入',
field: 'topNodeValue',
clearable: true,
required: true,
visible: false
}, {
label: '路径',
type: 'input',
placeholder: '请输入',
field: 'path',
clearable: true,
required: true,
block: true,
visible: false
}
],
clearable: true,
required: false,
block: true,
visible: true,
},
]
const formItems: any = ref([])
const formRules: any = ref({
chName: [
{
required: true,
message: "请填写中文名",
trigger: "blur",
},
],
enName: [
{
required: true,
message: "请填写英文名",
trigger: "blur",
},
],
orderNum: [{
validator: (rule: any, value: any, callback: any) => {
if (value === 0) {
callback();
return;
}
if (!value) {
callback(new Error('请填写排序'));
return;
}
const r = /(^[0-9]([0-9]*)$|^[0-9]$)/; // 正整数(可以以0打头)
if (value && !r.test(value)) {
callback(new Error('请填写大于或等于零整数'));
return;
}
callback();
},
trigger: "blur",
}],
codeColumn: [
{
required: true,
message: "请填写编码字段",
trigger: "blur",
},
],
codeName: [
{
required: true,
message: "请填写编码名称",
trigger: "blur",
},
],
})
const formInfo = ref({
type: 'form',
title: '',
col: 'span',
formInfo: {
id: 'add-dict-form',
col: 'col3',
readonly: false,
items: formItems.value,
rules: formRules.value
}
})
const orginData = [
{
ROWID: 'field_0',
fieldName: 'code',
description: '编码字段',
fieldType: 'varchar',
fieldLength: '10',
fieldPrecision: '',
// orderNum: '1',
codeRuleGuid: '',
STATUS: 'edit',
STATE: 'Running'
}, {
ROWID: 'field_1',
fieldName: 'name',
description: '编码名称',
fieldType: 'varchar',
fieldLength: '20',
fieldPrecision: '',
// orderNum: '2',
codeRuleGuid: '',
STATUS: 'edit',
STATE: 'Running'
}
]
const orginFields = [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "字段英文名", field: "fieldName", width: 140, },
{ label: "字段中文名", field: "description", width: 140, },
{ label: "字段类型", field: "fieldType", width: 100, },
{ label: "长度", field: "fieldLength", width: 80, },
{ label: "精度", field: "fieldPrecision", width: 80, },
// { label: "排序", field: "orderNum", width: 56, },
{ label: "编码规则", field: "codeRuleGuid", width: 140, },
]
const formTableData: any = ref([])
const formTableSelectRowData: any = ref([])
const editTableInfo = ref({
fieldName: {
label: '字段英文名',
type: 'input',
maxlength: 50,
placeholder: '',
field: 'fieldName',
default: '',
clearable: true,
required: true,
},
description: {
label: '字段中文名',
type: 'input',
maxlength: 50,
placeholder: '',
field: 'description',
default: '',
clearable: true,
required: true,
},
fieldType: {
label: '字段类型',
type: 'select',
placeholder: '',
field: 'fieldType',
default: '',
options: [],
clearable: true,
required: true
},
fieldLength: {
label: '长度',
type: 'input',
placeholder: '',
field: 'fieldLength',
default: '',
clearable: true,
required: true,
},
fieldPrecision: {
label: '精度',
type: 'input',
placeholder: '',
field: 'fieldPrecision',
default: '',
clearable: true,
required: true,
},
// orderNum: {
// label: '排序',
// type: 'input',
// placeholder: '',
// field: 'orderNum',
// default: '',
// maxlength: 6,
// clearable: true,
// required: true,
// },
codeRuleGuid: {
label: '编码规则',
type: 'select',
placeholder: '',
field: 'codeRuleGuid',
default: '',
options: [],
clearable: true,
required: true
}
})
const formTable = ref({
type: "table",
title: "定义表结构",
col: 'no-margin',
style: {
height: 'calc(100% - 234px)'
},
tableInfo: {
id: "role-authority-table",
multiple: true,
minHeight: 'unset',
maxHeight: '100%',
fields: [],
data: [],
showPage: false,
actionInfo: {
show: true,
label: "操作",
type: "btn",
width: 60,
fixed: 'right',
btns: [
{ label: "删除", value: "remove" },
]
},
editInfo: {},
readonly: false,
col: 'auto-height',
style: {
height: 'calc(100% - 40px)'
},
loading: false
},
tableTool: {
col: 'float-right',
visible: true,
btns: [
{ label: "新增行", value: "add-row", type: 'primary', plain: true },
{ label: "批量删除", value: "remove_batch" },
]
},
})
const fieldSheetInfo: any = ref({})
const uploadTableData: any = ref([])
const uploadSelectRowData: any = ref([])
const uploadTableFields: any = ref([])
const uploadTableInfo = ref({
id: "role-authority-table",
multiple: true,
// minHeight: 'unset',
// maxHeight: '100%',
fields: [],
data: [],
showPage: false,
actionInfo: {
label: "操作",
type: "btn",
width: 60,
btns: [
{ label: "删除", value: "remove" },
],
},
editInfo: {},
readonly: false,
loading: false
})
const uploadFiles: any = ref([])
const uploadInfo = ref({
type: 'upload',
title: '添加表数据',
col: 'row-reverse',
uploadInfo: {
id: 'upload-file-form',
action: '',
auto: false,
fileList: [],
accept: '.xlsx, .xls',
cover: true,
triggerBtn: {
label: '导入文件',
value: 'import_file',
icon: 'Upload',
plain: true,
},
toolBar: [
{ label: '下载模板', value: 'export_model', plain: true, icon: 'Download' },
]
// showList: false,
},
tableInfo: {},
tools: {
col: 'right',
visible: true,
btns: [
{ label: '树形显示', value: 'show_tree', type: 'primary', plain: true, visible: false },
{ label: '新增行', value: 'add_row', type: 'primary', plain: true },
{ label: '批量删除', value: 'remove_batch', plain: true },
]
}
})
const fieldTableInfo = ref({
type: 'field-table',
title: '表数据',
tableInfo: {
id: 'dict-field-table',
minHeight: 'unset',
maxHeight: '100%',
fields: [],
data: [],
loading: false,
showPage: false,
actionInfo: {
show: false
},
col: 'auto-height'
}
})
const contents = ref({
add: [
formInfo.value,
formTable.value,
],
upload: [
formInfo.value,
uploadInfo.value,
],
sheet: [
formInfo.value,
formTable.value,
],
field: [
formInfo.value,
fieldTableInfo.value,
]
})
const drawerRef = ref()
const drawerInfo: any = ref({
visible: false,
direction: "rtl",
modalClass: "",
modalClose: false,
modal: true,
size: 700,
header: {
title: "新增",
},
type: '',
container: {
contents: [],
},
footer: {
btns: [
{ type: 'default', label: '取消', value: 'cancel' },
{ type: 'primary', label: '保存', value: 'submit' },
{ type: 'primary', label: '查看数据', value: 'fileds', visible: false },
{ type: 'primary', label: '查看表结构', value: 'sheet', visible: false },
{ type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true },
]
},
})
const setFormItems = (row: any = null) => {
formItems.value = JSON.parse(JSON.stringify(orginItems))
formItems.value.map(item => {
if (item.field == 'databaseNameZh') {
item.options = dataBaseList.value
item.default = row ? row[item.field] : ''
} else if (item.field == 'dictionaryType') {
item.default = dictionaryType.value
// item.disabled = drawerInfo.value.type == 'add' ? false : true
item.disabled = true
item.children.map(child => {
child.options = orginOptions
if (child.field == 'codeColumn') {
child.default = row ? row[child.field] : 'code'
} else if (child.field == 'codeName') {
child.default = row ? row[child.field] : 'name'
} else {
child.default = row ? row[child.field] : ''
}
child.disabled = drawerInfo.value.type == 'detail' ? true : false
child.clearable = drawerInfo.value.type == 'detail' ? false : true
})
} else if (item.field == 'enName') {
item.default = row ? row[item.field] : ''
item.disabled = drawerInfo.value.type == 'add' ? false : true
item.clearable = drawerInfo.value.type == 'add' ? true : false
} else {
item.default = row ? row[item.field] : ''
item.disabled = drawerInfo.value.type == 'detail' ? true : false
item.clearable = drawerInfo.value.type == 'detail' ? false : true
}
})
formInfo.value.formInfo.readonly = drawerInfo.value.type == 'detail'
formInfo.value.formInfo.items = formItems.value
// for(var e in editTableInfo.value){
// const editItem = editTableInfo.value[e]
// if(editItem.field != 'description' && editItem.field != 'codeRuleGuid'){
// editItem.disabled = drawerInfo.value.type != 'add'
// }
// }
}
// 获取数据类型列表
const getDataType = (type) => {
let params = {
paramCode: type
}
getDataTypeList(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data
if (type == 'DATA_TYPE') {
data.map(item => {
item.label = item.paramName
item.value = item.paramValue
})
dataTypeList.value = data
editTableInfo.value['fieldType'].options = data
}
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
// 获取数据库列表
const getDataBase = () => {
const params = {
pageIndex: 1,
connectStatus: '1'
}
getDataBaseList(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? []
data.map(item => {
item.label = item.databaseNameZh
item.value = item.guid
})
dataBaseList.value = data
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
// 获取编码规则列表
const getCodeRuleData = () => {
let params = {}
getCoderuleList(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data
data.map(item => {
item.label = item.ruleName
item.value = item.guid
})
codeRuleList.value = data
editTableInfo.value['codeRuleGuid'].options = data
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
const treePromise = ref();
// 获取数据字典树形数据
const getTreeData = (needClick = false, currData = {}) => {
const params = {
paramCode: 'data_structure_code'
}
treeInfo.value.loading = true
treePromise.value = getDictionaryTree(params).then((res: any) => {
treePromise.value = null;
if (res.code == proxy.$passCode) {
const data = res.data ?? []
const treeList = data.filter(item => item.children && item.children.length)
treeData.value = treeList
treeInfo.value.data = treeList
if (treeList.length) {
dictType.value = dictType.value == -1 ? Number(treeList[0].dictionaryType) : dictType.value;
expandedKey.value = expandedKey.value.length == 0 ? [treeList[0].guid] : expandedKey.value;
if (!needClick && !cacheStore.getCatch('dictionaryGuid')) {
currentNodeKey.value = currentNodeKey.value == '' ? treeList[0].guid : currentNodeKey.value
nextTick(() => {
treeInfo.value.currentNodeKey = currentNodeKey.value
treeInfo.value.expandedKey = expandedKey.value
})
} else {
nextTick(() => {
treeInfo.value.expandedKey = expandedKey.value;
});
}
getFirstPageData()
}
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
treeInfo.value.loading = false;
if (needClick) {
nextTick(() => {
nodeClick(currData);
});
}
}).catch(() => {
treeInfo.value.loading = false
})
}
const getFirstPageData = () => {
page.value.curr = 1;
toSearch({})
}
const toSearch = (val: any, clear: boolean = false) => {
let params: any = Object.keys(val).length ? { ...val } : {}
params.pageIndex = page.value.curr;
params.pageSize = page.value.limit;
params.dictionaryType = dictType.value
params.name = tableSearchInput.value
getTableData(params);
};
const getTableData = (params) => {
tableInfo.value.loading = true
getDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data || {}
tableInfo.value.data = data.records || []
tableInfo.value.page.limit = data.pageSize
tableInfo.value.page.curr = data.pageIndex
tableInfo.value.page.rows = data.totalRows
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
tableInfo.value.loading = false
}).catch(xhr => {
tableInfo.value.loading = false
})
};
const tableSelectionChange = (val, tId) => {
if (drawerInfo.value.visible) {
if (formItems.value.length == 2) {
uploadSelectRowData.value = val
} else {
formTableSelectRowData.value = val
}
} else {
selectRowData.value = val.map((item) => item.guid);
}
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
toSearch({});
};
const tableInputChange = (val, scope) => {
if (forbidFields.indexOf(val) > -1) {
ElMessage({
type: "error",
message: '该名称已存在,请填写其他名称',
});
return
}
setCodeOptions()
}
const setCodeOptions = () => {
let opts: any = []
formTableData.value.map(item => {
if (item.fieldName) {
const row = JSON.parse(JSON.stringify(item))
row.label = item.fieldName
row.value = item.fieldName
opts.push(row)
}
})
formItems.value.at(-1).children.map(child => {
if (child.type == 'select') {
child.options = opts
}
})
}
const toolBtnClick = (btn, data) => {
const type = btn.value
if (data) {
if (type.indexOf('add') > -1) {
if (formItems.value.length == 2) {
const params = {
guid: fieldSheetInfo.value.guid
}
uploadTableInfo.value.loading = true
getDictionaryRuleData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
let rowInfo: any = {}
uploadTableFields.value.map(item => {
rowInfo[item.field] = data[item.field] ?? ''
})
rowInfo.STATUS = 'edit'
rowInfo.STATE = 'Running'
rowInfo.ROWID = `upload_${uploadTableData.value.length}`
uploadTableData.value.push(rowInfo)
uploadTableInfo.value.data = uploadTableData.value
scrollTable(rowInfo)
} else {
ElMessage({
type: 'error',
message: res.msg
})
}
uploadTableInfo.value.loading = false
}).catch(() => {
uploadTableInfo.value.loading = false
})
} else {
const rowInfo = {
ROWID: `formData_${formTableData.value.length}`,
fieldName: '',
description: '',
fieldType: '',
fieldLength: '',
fieldPrecision: '',
orderNum: '',
codeRuleGuid: '',
STATUS: 'edit',
STATE: 'Running'
}
let list: any = formTableData.value
list.push(rowInfo)
formTable.value.tableInfo.data = list
scrollTable(rowInfo)
}
} else if (type.indexOf('remove') > -1) {
if (formItems.value.length == 2) {
if (uploadSelectRowData.value.length == 0) {
ElMessage({
type: "error",
message: '请选择需要删除的数据',
});
return
}
uploadSelectRowData.value.map(item => {
const existIndex = uploadTableData.value.findIndex(s => s.ROWID == item.ROWID)
existIndex > -1 && uploadTableData.value.splice(existIndex, 1)
})
} else {
if (formTableSelectRowData.value.length == 0) {
ElMessage({
type: "error",
message: '请选择需要删除的数据',
});
return
}
const removeRows = () => {
formTableSelectRowData.value.map(item => {
const existIndex = formTableData.value.findIndex(s => s.ROWID == item.ROWID)
existIndex > -1 && formTableData.value.splice(existIndex, 1)
})
}
if (drawerInfo.value.type == 'edit') {
const editRows = formTableSelectRowData.value.filter(item => item.guid !== undefined)
if (editRows.length) {
formTable.value.tableInfo.loading = true
checkDelete().then((res: any) => {
if (res) {
ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: 'warning',
}).then(() => {
removeRows()
})
} else {
removeRows()
}
formTable.value.tableInfo.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
formTable.value.tableInfo.loading = false
})
} else {
removeRows()
}
} else {
removeRows()
}
}
}
} else {
if (type == 'export_model') {
exportData('model')
} else if (type == 'import_file') {
importData()
}
}
}
const tableSwitchBeforeChange = (scope, field, callback) => {
const msg = '确定修改状态?'
ElMessageBox.confirm(
msg,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
const state = scope.row[field] == 1 ? 0 : 1
const result = tableSwitchChange(state, scope, field)
callback(result)
}).catch(() => {
callback(false)
})
}
const tableSwitchChange = (val, scope, field) => {
return new Promise((resolve, reject) => {
let params = {
guid: scope.row.guid,
dictionaryState: val
}
updateDictionaryState(params).then((res: any) => {
if (res.code == proxy.$passCode && res.data) {
getFirstPageData()
ElMessage({
type: "success",
message: '状态修改成功',
});
resolve(true)
} else {
ElMessage({
type: "error",
message: res.msg,
});
reject(false)
}
}).catch(() => {
reject(false)
})
})
}
const tableBtnClick = (scope, btn) => {
const type = btn.value;
const row = scope.row;
if (type == "edit" || type == 'detail') {
fieldTableInfo.value.tableInfo.fields = []
fieldTableInfo.value.tableInfo.data = []
drawerInfo.value.header.title = type == 'edit' ? "编辑数据字典" : "数据字典详情";
drawerInfo.value.modalClass = type == 'edit' ? '' : 'wrap_width_auto'
drawerInfo.value.type = type
drawerInfo.value.visible = true;
if (drawerInfo.value.type == 'detail') {
formTable.value.tableInfo.multiple = false
formTable.value.tableTool.visible = false
formTable.value.tableInfo.actionInfo.show = false
drawerInfo.value.footer.btns.at(1).visible = false
drawerInfo.value.footer.btns.at(-1).visible = false
drawerInfo.value.footer.btns.at(-2).visible = false
drawerInfo.value.footer.btns.at(-3).visible = true
} else {
formTable.value.tableInfo.multiple = true
formTable.value.tableInfo.actionInfo.show = true
formTable.value.tableTool.visible = true
drawerInfo.value.footer.btns.at(1).visible = true
drawerInfo.value.footer.btns.at(-1).visible = true
drawerInfo.value.footer.btns.at(-2).visible = false
drawerInfo.value.footer.btns.at(-3).visible = false
}
drawerInfo.value.loading = true;
formTable.value.tableInfo.loading = true
getDictionaryDetail(row.guid).then((res: any) => {
if (res.code == proxy.$passCode && res.data) {
let data = res.data
currTableData.value = data;
setDetailInfo()
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
formTable.value.tableInfo.loading = false
drawerInfo.value.loading = false;
}).catch(() => {
formTable.value.tableInfo.loading = false
drawerInfo.value.loading = false;
})
} else if (type == 'remove') {
const rowIndex = scope.$index
if (formItems.value.length == 2) {
uploadTableData.value.splice(rowIndex, 1)
} else {
if (row.guid !== undefined) {
formTable.value.tableInfo.loading = true
checkDelete().then((res: any) => {
if (res) {
ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: 'warning',
}).then(() => {
formTableData.value.splice(rowIndex, 1)
})
} else {
formTableData.value.splice(rowIndex, 1)
}
formTable.value.tableInfo.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
formTable.value.tableInfo.loading = false
})
} else {
formTableData.value.splice(rowIndex, 1)
}
}
} else if (type == "delete") {
currTableData.value = row;
tableInfo.value.loading = true
checkDelete().then((res: any) => {
if (res.used) {
ElMessage({
type: 'error',
message: '数据字典被引用,请解除引用关系后再删除'
})
} else {
const unused = res.data.filter(item => item.have.length > 0)
if (unused.length) {
open("数据字典有数据, 确定是否继续删除?", "warning");
} else {
open("此操作将永久删除, 是否继续?", "warning");
}
}
tableInfo.value.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
tableInfo.value.loading = false
})
}
};
const checkDelete = (isBatch: any = false) => {
if (drawerInfo.value.visible) {
return new Promise((resolve, reject) => {
let params: any = {
guid: currTableData.value.guid
}
checkDeleteDictionaryScheme(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data
resolve(data)
} else {
reject(res.msg)
}
}).catch((xhr: any) => {
reject(xhr.msg)
})
})
} else {
return new Promise((resolve, reject) => {
let guids = [currTableData.value.guid]
if (isBatch) {
guids = selectRowData.value
}
checkDeleteDictionary(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
if (data.used) {
resolve({
used: true,
data: data.used
})
} else {
resolve({
used: false,
data: data.unuse
})
}
} else {
reject(res.msg)
}
}).catch((xhr: any) => {
reject(xhr.msg)
})
})
}
}
const open = (msg, type, isBatch = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids = [currTableData.value.guid]
if (isBatch) {
guids = selectRowData.value
}
tableInfo.value.loading = true
deleteDictionary(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getTreeData();
ElMessage({
type: "success",
message: "删除成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
tableInfo.value.loading = false
}).catch(() => {
tableInfo.value.loading = false
});
});
};
const onUpload = (file, fileList) => {
uploadFiles.value = fileList
}
const uploadFile = (file) => {
importData(file)
}
const exportData = (type: any = null) => {
if (type == 'model') {
let params = {
guid: dictGuid.value
}
if (drawerInfo.value.type == 'add') {
params.guid = fieldSheetInfo.value.guid
}
exportDictionary(params).then((res: any) => {
download(res, '数据字典模板.xlsx', 'excel')
});
} else {
let params = {
guid: dictGuid.value
}
exportDictionaryFileds(params).then((res: any) => {
download(res, '字典数据.xlsx', 'excel')
});
}
}
const importData = (file: any = null) => {
let params = new FormData()
if (file) {
params.append("file", file.raw);
} else {
if (uploadFiles.value.length) {
uploadFiles.value.forEach((item: any, index: number) => {
params.append("file", item.raw);
});
}
}
params.append("dictionaryGuid", fieldSheetInfo.value.guid);
showDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
let data = res.data ?? []
setUploadDataInfo(data)
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
})
}
// 生成表头
const setUploadDataFields = (data) => {
let fields: any = [], editInfo: any = {}
data.map(item => {
let fieldItem: any = {
label: item.description, field: item.fieldName, width: 140
}
if (drawerInfo.value.type != 'detail') {
fieldItem.type = 'edit'
fieldItem.columClass = 'edit-colum'
editInfo[item.fieldName] = {
label: '',
type: 'input',
placeholder: '',
field: item.fieldName,
default: '',
disabled: item.codeRuleGuid ? true : false,
clearable: true,
}
}
fields.push(fieldItem)
})
uploadTableFields.value = fields
if (drawerInfo.value.type == 'detail') {
fieldTableInfo.value.tableInfo.fields = uploadTableFields.value
} else {
uploadTableInfo.value.fields = uploadTableFields.value
uploadTableInfo.value.editInfo = editInfo
}
}
// 生成表数据
const setUploadDataInfo = async (info) => {
let data = info
if (drawerInfo.value.type == 'detail') {
data = info.jsonArray ?? []
const fields = info.schemaDataVOS ?? []
setUploadDataFields(fields)
}
if (drawerInfo.value.type == 'detail') {
fieldTableInfo.value.tableInfo.data = data
drawerInfo.value.container.contents = contents.value['field']
} else {
// 设置表数据
data.map((item, i) => {
item.STATUS = 'edit'
item.STATE = 'Running'
item.ROWID = `upload_${i}`
})
uploadTableData.value = data
uploadTableInfo.value.data = uploadTableData.value
}
}
const loadDrawer = async () => {
drawerInfo.value.header.title = '新增数据字典'
drawerInfo.value.type = 'add'
drawerInfo.value.modalClass = '';
await setFormItems()
let fields = JSON.parse(JSON.stringify(orginFields))
fields.map((item: any) => {
if (!item.type || item.type != 'index') {
item.type = 'edit'
item.columClass = 'edit-colum'
}
})
formTable.value.tableInfo.fields = fields
formInfo.value.formInfo.items = formItems.value
formTableData.value = JSON.parse(JSON.stringify(orginData))
formTable.value.tableInfo.data = formTableData.value
formTable.value.tableInfo.editInfo = JSON.parse(JSON.stringify(editTableInfo.value))
formTable.value.tableInfo.readonly = false
formTable.value.tableInfo.multiple = true
formTable.value.tableInfo.actionInfo.show = true
formTable.value.tableTool.visible = true
drawerInfo.value.container.contents = contents.value['add']
drawerInfo.value.footer.btns.at(1).visible = true
drawerInfo.value.footer.btns.at(-1).visible = true
drawerInfo.value.footer.btns.at(-2).visible = false
drawerInfo.value.footer.btns.at(-3).visible = false
drawerInfo.value.visible = true
};
const batching = (type) => {
if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的数据',
})
return
}
tableInfo.value.loading = true
checkDelete().then((res: any) => {
if (res.used) {
ElMessage({
type: 'error',
message: '数据字典被引用,请解除引用关系后再删除'
})
} else {
const unused = res.data.filter(item => !item.have || item.have.length == 0)
if (unused.length) {
open("数据字典有数据, 确定是否继续删除?", "warning", true);
} else {
open("此操作将永久删除, 是否继续?", "warning", true);
}
}
tableInfo.value.loading = false
}).catch(xhr => {
ElMessage({
type: 'error',
message: xhr
})
tableInfo.value.loading = false
})
}
};
const nodeClick = (data) => {
drawerInfo.value.visible = false
const changeCont = () => {
dictGuid.value = data.guid
const info = {
type: 'dictionary',
dictionaryGuid: dictGuid.value
}
cacheStore.setCatch('uploadSetting', info)
if (data.type == 1) {
showFiledsPage.value = false
dictType.value = Number(data.dictionaryType)
} else {
showFiledsPage.value = true
nextTick(() => {
dictFiledsRef.value.dictionaryGuid = dictGuid.value
dictFiledsRef.value.getFirstPageData()
})
}
nextTick(() => {
treeInfo.value.currentNodeKey = dictGuid.value
})
}
if (showFiledsPage.value) {
const toChange = dictFiledsRef.value.checkSave()
if (!toChange) {
ElMessageBox.confirm(
'存在未保存的数据,切换后会丢失,是否确定切换',
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
}
).then(() => {
changeCont()
}).catch(() => {
treeInfo.value.currentNodeKey = dictGuid.value
})
} else {
changeCont()
}
} else {
changeCont()
}
}
// 设置详情信息
const setDetailInfo = () => {
const row = JSON.parse(JSON.stringify(currTableData.value))
dictionaryType.value = row.dictionaryType
setFormItems(row)
let fields = JSON.parse(JSON.stringify(orginFields))
let schemaVOS = row.schemaVOS ?? []
setGroup()
let list: any = []
schemaVOS.map((schema, s) => {
list.push({
label: schema.fieldName,
value: schema.fieldName
})
schema.STATUS = 'edit'
schema.STATE = 'Running'
schema.ROWID = `formData_${s}`
})
formItems.value.at(-1).children.map(child => {
if (child.type == 'select') {
child.options = list
child.default = row[child.field]
child.clearable = drawerInfo.value.type == 'detail' ? false : true
}
})
fields.map((item: any) => {
if (!item.type || item.type != 'index') {
item.type = 'edit'
item.columClass = 'edit-colum'
}
})
for (var key in editTableInfo.value) {
editTableInfo.value[key].clearable = drawerInfo.value.type == 'detail' ? false : true
}
let editInfo = JSON.parse(JSON.stringify(editTableInfo.value))
if (drawerInfo.value.type == 'edit') {
for (var e in editInfo) {
if (e == 'description' || e == 'fieldType' || e == 'fieldLength' || e == 'fieldPrecision') {
editInfo[e].disabled = true
}
}
}
formInfo.value.formInfo.items = formItems.value
formTableData.value = schemaVOS
formTable.value.tableInfo.fields = fields
formTable.value.tableInfo.data = formTableData.value
formTable.value.tableInfo.readonly = drawerInfo.value.type == 'detail'
formTable.value.tableInfo.editInfo = editInfo
drawerInfo.value.container.contents = contents.value['add']
drawerInfo.value.visible = true
}
const checkParamsData = () => {
let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true
let passArr = uploadTableData.value
passArr.map((item, index) => {
const obj = JSON.parse(JSON.stringify(item))
delete obj.STATE
delete obj.STATUS
delete obj.NOTES
delete obj.ROWID
for (var i in obj) {
if (obj[i] == '') {
pass = false
}
}
if (obj.guid !== undefined) {
upJsonArray.push(obj)
} else {
addJsonArray.push(obj)
}
obj.index = index
jsonArray.push(obj)
})
return { pass, addJsonArray, upJsonArray, jsonArray }
}
const saveData = async () => {
const passInfo = await checkParamsData()
const checkParams = {
dictionaryGuid: fieldSheetInfo.value.guid,
addJsonArray: passInfo.jsonArray
}
checkDictionaryData(checkParams).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data
if (Object.keys(data).length) {
addColumn(data)
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
} else {
addColumn()
const params = {
dictionaryGuid: fieldSheetInfo.value.guid,
addJsonArray: passInfo.addJsonArray,
upJsonArray: passInfo.upJsonArray
}
saveDictionaryData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
showLoading.value = true
getTreeData();
ElMessage({
type: 'success',
message: '保存数据字典成功'
})
drawerInfo.value.visible = false;
} else {
ElMessage({
type: 'error',
message: res.msg,
})
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
})
}
} else {
ElMessage({
type: 'error',
message: res.msg,
})
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
})
}
const addColumn = (info: any = null) => {
const fields = uploadTableFields.value
const existIndex = fields.findIndex(item => item.field == 'NOTES')
if (info) {
if (existIndex == -1) {
fields.push({
label: '备注',
field: 'NOTES',
width: 276
})
}
for (var d in info) {
uploadTableData.value[d].NOTES = info[d].join(',')
}
} else {
if (existIndex > -1) {
fields.splice(existIndex, 1)
}
}
}
const scrollTable = (rowInfo) => {
nextTick(() => {
const drawerBody = document.getElementsByClassName('el-drawer__body')[0];
const tableListRef = drawerRef.value.getDrawerConRef("drawerTableRef");
if (!tableListRef) return;
//设置选中表格当前新增行。
tableListRef.setCurrentRow(rowInfo);
drawerBody.scrollTop = drawerBody.scrollHeight;
let table = tableListRef.layout.table.refs;
// 获取表格滚动元素
let tableScrollEle =
table.bodyWrapper.firstElementChild.firstElementChild;
// 设置表格滚动的位置
tableScrollEle.scrollTop = tableScrollEle.scrollHeight;
});
};
const drawerBtnClick = (btn, info) => {
if (btn.value == 'submit' || btn.value == 'saveAndAdd') {
drawerInfo.value.footer.btns.map((item: any) => item.disabled = true)
if (formItems.value.length == 2) {
if (drawerInfo.value.type == 'add') {
saveData()
}
} else {
if (drawerInfo.value.type == 'edit' && btn.value == 'saveAndAdd') {
nodeClick(currTableData.value)
drawerInfo.value.visible = false
return
}
let params = { ...info }
let dtos: any = []
if (formTableData.value.length == 0) {
ElMessage({
type: 'error',
message: '表结构至少需要一条数据',
})
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
return
}
formTableData.value.map((item, i) => {
const dto = { ...item }
delete dto.STATE
delete dto.STATUS
delete dto.ROWID
delete dto.NOTES
dto.orderNum = i
dtos.push(dto)
})
params.dataDictionarySchemaAddDTOS = dtos
if (drawerInfo.value.type == 'add') {
formTable.value.tableInfo.loading = true
addDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
ElMessage({
type: 'success',
message: '添加数据字典成功'
})
drawerInfo.value.visible = false;
getTreeData(btn.value == 'saveAndAdd', res.data || {});
} else {
ElMessage({
type: 'error',
message: res.msg,
})
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
formTable.value.tableInfo.loading = false
}).catch(() => {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
formTable.value.tableInfo.loading = false
})
} else {
params.guid = currTableData.value.guid
updateDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
if (btn.value == 'saveAndAdd') {
showLoading.value = false
drawerInfo.value.container.id = 'upload-table-form'
drawerInfo.value.footer.btns.at(-1).visible = false
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
getDictionaryDataDetail(currTableData.value.guid)
} else {
getTreeData();
ElMessage({
type: 'success',
message: '修改数据字典成功'
})
drawerInfo.value.visible = false;
}
} else {
ElMessage({
type: 'error',
message: res.msg,
})
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
})
}
}
} else if (btn.value == 'fileds') {
drawerInfo.value.footer.btns.at(-2).visible = true
drawerInfo.value.footer.btns.at(-3).visible = false
formItems.value.map(item => {
if (item.field != 'chName' && item.field != 'enName') {
item.visible = false
}
})
if (currTableData.value.detailInfo == null) {
getTableFiled()
} else {
drawerInfo.value.container.contents = contents.value['field']
}
} else if (btn.value == 'sheet') {
formItems.value.map(item => {
item.visible = true
})
drawerInfo.value.container.contents = contents.value['add']
drawerInfo.value.footer.btns.at(-2).visible = false
drawerInfo.value.footer.btns.at(-3).visible = true
} else {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
nextTick(() => {
drawerInfo.value.visible = false
})
}
}
const getTableFiled = () => {
const guid = currTableData.value.guid;
fieldTableInfo.value.tableInfo.loading = true;
drawerInfo.value.container.contents = contents.value['field']
getDictionaryFileds(guid).then((res: any) => {
fieldTableInfo.value.tableInfo.loading = false;
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
currTableData.value.detailInfo = data
setUploadDataInfo(data)
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
}).catch(() => {
fieldTableInfo.value.tableInfo.loading = false;
})
}
const getDictionaryDataDetail = (params) => {
uploadTableInfo.value.loading = true
getDictionaryFileds(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
setContents(data)
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
uploadTableInfo.value.loading = false
}).catch(xhr => {
uploadTableInfo.value.loading = false
})
}
// 设置添加数据面板信息
const setContents = async (info) => {
formItems.value.splice(2)
formItems.value.map(item => {
item.default = fieldSheetInfo.value[item.field]
item.disabled = true
})
const fields = info.schemaDataVOS ?? []
await setUploadDataFields(fields)
uploadTableData.value = []
uploadTableInfo.value.data = []
uploadInfo.value.tableInfo = uploadTableInfo.value
drawerInfo.value.container.contents = contents.value['upload']
}
const radioGroupChange = async (val, info) => {
dictionaryType.value = Number(val)
await setFormItems(info)
setGroup()
}
// 切换结构类型 设置选项显隐
const setGroup = () => {
let dictionaryOpts = formItems.value.at(-1).children
if (dictionaryType.value == 1) {
dictionaryOpts[2].visible = false
dictionaryOpts[3].visible = false
} else if (dictionaryType.value == 2) {
dictionaryOpts[2].visible = false
dictionaryOpts[3].block = false
dictionaryOpts[3].visible = true
} else if (dictionaryType.value == 3) {
dictionaryOpts[2].visible = true
dictionaryOpts[3].block = true
dictionaryOpts[3].visible = true
} else if (dictionaryType.value == 4) {
dictionaryOpts[2].visible = false
dictionaryOpts[3].block = true
dictionaryOpts[3].visible = true
}
formInfo.value.formInfo.items = formItems.value
}
onActivated(() => {
getCodeRuleData();
let guid = cacheStore.getCatch('dictionaryGuid');
if (guid) {
nextTick(() => {
if (treePromise.value) {
treePromise.value.then(() => {
nodeClick({ guid: guid, dictionaryType: '1', type: 2 });
cacheStore.setCatch('dictionaryGuid', null);
});
} else {
nodeClick({ guid: guid, type: 1 });
cacheStore.setCatch('dictionaryGuid', null);
}
});
}
})
onBeforeMount(() => {
getDataType('DATA_TYPE')
getTreeData()
})
onMounted(() => {
let dom = document.getElementById('main-app');
if (dom) {
dom.addEventListener('click', (event: any) => {
// 新建时不要处理。
if (drawerInfo.value.header.title == '数据字典详情' && !event.target?.classList?.contains('drawer-detail-cell')) {
if (drawerInfo.value.visible) {
drawerInfo.value.visible = false;
}
}
});
}
});
</script>
<template>
<div class="container_wrap full flex">
<div class="aside_wrap">
<div class="aside_title">数据字典列表</div>
<Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" />
</div>
<DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" />
<div class="main_wrap" v-else>
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button>
<el-button @click="batching('delete')" v-preReClick>批量删除</el-button>
</div>
<el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入字典中/英文名搜索"
:suffix-icon="Search" clearable @change="val => getFirstPageData()" />
</div>
<div class="table_panel_wrap full">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" @tableSwitchBeforeChange="tableSwitchBeforeChange" />
</div>
</div>
<Drawer ref="drawerRef" :drawerInfo="drawerInfo" @drawerBtnClick="drawerBtnClick"
@radioGroupChange="radioGroupChange" @drawerTableBtnClick="tableBtnClick"
@drawerTableSelectionChange="tableSelectionChange" @drawerTableToolBtnClick="toolBtnClick"
@drawerTableInputChange="tableInputChange" @drawerToolBtnClick="toolBtnClick" @onUpload="onUpload"
@uploadFile="uploadFile" @uploadBtnClick="toolBtnClick" />
</div>
</template>
<style lang="scss" scoped>
.container_wrap {
.aside_wrap {
width: 200px;
}
}
.tree_panel {
height: 100%;
padding-top: 0;
:deep(.el-tree) {
margin: 0;
height: calc(100% - 68px);
overflow: hidden auto;
}
}
</style>
......@@ -4,14 +4,14 @@
<script lang="ts" setup name="importFile">
import { ref } from "vue";
import { useRoute,useRouter } from "vue-router"
import { useRoute, useRouter } from "vue-router"
import useUserStore from "@/store/modules/user";
import { ElMessage, ElMessageBox } from "element-plus";
import Tabs from '@/components/Tabs/index.vue'
import Table from '@/components/Table/index.vue'
import Dialog from '@/components/Dialog/index.vue'
import useCatchStore from "@/store/modules/catch";
import { download, downFile,getDownloadUrl } from '@/utils/common'
import { download, downFile, getDownloadUrl } from '@/utils/common'
import {
addImportData,
deleteImportData,
......@@ -25,7 +25,7 @@ import { commonPageConfig } from '@/utils/enum';
const { proxy } = getCurrentInstance() as any;
const userStore = useUserStore()
const route = useRoute()
const route = useRoute()
const router = useRouter()
/** 2表示资产目录的。3是主数据; 4是元数据导入 */
const isfileImport = route.query.isfileImport
......@@ -39,21 +39,21 @@ const tabsActiveName = ref('')
const uploadSetting: any = ref({})
const importType = ref('')
const defaulttabs = [
{ label: '标准集导入', name: 'standard' },
{ label: '字段标准导入', name: 'field' },
{ label: '命名标准导入', name: 'naming' },
{ label: '数据字典导入', name: 'dictionary' },
// { label: '质量模型导入', name: 'qualityModelGroup' },
// { label: '质量规则导入', name: 'qualityRule' },
]
{ label: '标准集导入', name: 'standard' },
{ label: '字段标准导入', name: 'field' },
{ label: '命名标准导入', name: 'naming' },
{ label: '数据字典导入', name: 'dictionary' },
// { label: '质量模型导入', name: 'qualityModelGroup' },
// { label: '质量规则导入', name: 'qualityRule' },
]
const importTabs = [
{ label: '导入文件数据', name: 'importFile' },
// { label: '质量模型导入', name: 'qualityModelGroup' },
// { label: '质量规则导入', name: 'qualityRule' },
]
{ label: '导入文件数据', name: 'importFile' },
// { label: '质量模型导入', name: 'qualityModelGroup' },
// { label: '质量规则导入', name: 'qualityRule' },
]
const tabsInfo = ref({
activeName: '',
tabs: isfileImport?importTabs:defaulttabs
tabs: isfileImport ? importTabs : defaulttabs
})
const currTableData: any = ref<Object>({});
......@@ -217,27 +217,27 @@ const tableBtnClick = async (scope, btn) => {
currTableData.value = row;
if (type == "export_file") {
getImageContent(row.filePath).then((res: any) => {
if (res && !res.msg) {
let name = row.filePath;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
download(res, row.fileName, fileSuffix);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
if (res && !res.msg) {
let name = row.filePath;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
download(res, row.fileName, fileSuffix);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
//downFile(row.filePath, row.fileName)
} else if (type == 'export_abnormal_data') {
//downFile(row.errorFilePath, '')
getImageContent(row.errorFilePath).then((res: any) => {
if (res && !res.msg) {
let name = row.errorFilePath;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
let fileName = name ? name.substring(name.lastIndexOf('/') + 1) :''
download(res, fileName, fileSuffix);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
if (res && !res.msg) {
let name = row.errorFilePath;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
let fileName = name ? name.substring(name.lastIndexOf('/') + 1) : ''
download(res, fileName, fileSuffix);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
} else if (type == "delete") {
open("此操作将永久删除, 是否继续?", "warning");
}
......@@ -267,7 +267,7 @@ const batching = (type) => {
return
}
open("此操作将永久删除, 是否继续?", "warning", true);
} else if(type === 'importFile') {
} else if (type === 'importFile') {
if (isfileImport == '2' || isfileImport == '4') {
dialogInfo.value.header.title = '导入数据'
dialogInfo.value.type = 'upload'
......@@ -279,8 +279,8 @@ const batching = (type) => {
dialogInfo.value.visible = true
} else {
router.push({
name:"importData",
query:route.query
name: "importData",
query: route.query
})
}
}
......@@ -379,19 +379,19 @@ const importData = (info) => {
type: 'error',
message: '请填写数据源名称'
})
return;
return;
}
if (!info.databaseNameEn) {
ElMessage({
type: 'error',
message: '请填写数据库英文名'
})
return;
return;
}
uploadFiles.value.forEach((item: any, index: number) => {
params.append("uploadFile", item.raw);
});
paramUrl = `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/meta-collect-import?staffGuid=${userData.staffGuid}&databaseNameZh=${info.databaseNameZh}&databaseNameEn=${info.databaseNameEn}&isCover=${info.isCover}`
paramUrl = `${import.meta.env.VITE_APP_CHECK_BASEURL}/meta-collect-task/meta-collect-import?staffGuid=${userData.staffGuid}&databaseNameZh=${info.databaseNameZh}&databaseNameEn=${info.databaseNameEn}&isCover=${info.isCover}`
} else {
uploadFiles.value.forEach((item: any, index: number) => {
params.append("file", item.raw);
......@@ -455,7 +455,7 @@ const setUploadInfo = () => {
importType.value = '0034';
} else if (isfileImport == '4') {
importType.value = '0042';
} else {
} else {
importType.value = '0033';
}
}
......@@ -567,7 +567,7 @@ const setUploadInfo = () => {
uploadInfo.value.uploadInfo.extraParams = {}
} else if (tabsActiveName.value == 'importFile' && isfileImport == '4') { //元数据导入
uploadSteps.value = [
{
{
title: '1、导入前请先录入以下内容',
type: 'group',
formItems: [{
......@@ -643,12 +643,12 @@ const setUploadInfo = () => {
onActivated(() => {
uploadSetting.value = cacheStore.getCatch('uploadSetting') ?? {}
if(isfileImport) {
if (isfileImport) {
tabsActiveName.value = 'importFile'
} else {
} else {
tabsActiveName.value = uploadSetting.value?.type || 'standard'
}
//getDictList()
setUploadInfo()
})
......@@ -660,8 +660,10 @@ onActivated(() => {
<Tabs v-if="!isfileImport" :tabs-info="tabsInfo" @tabChange="tabsChange" />
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'" v-preReClick>批量导入</el-button>
<el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'" v-preReClick>文件导入</el-button>
<el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'"
v-preReClick>批量导入</el-button>
<el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'"
v-preReClick>文件导入</el-button>
<el-button @click="batching('delete')" v-preReClick>批量删除</el-button>
<el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button>
</div>
......@@ -736,4 +738,4 @@ onActivated(() => {
height: calc(100% - 71px);
}
}
</style>
\ No newline at end of file
</style>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!