c75437b7 by lxs

Merge branch 'release-test' of http://117.78.60.236:8000/csbr-daop/fe-data-asset…

…-management into release-test
2 parents 36d5d6ac ad0bf64f
......@@ -4,6 +4,7 @@ VITE_APP_TITLE = 数据资产管理系统
# VITE_API_BASEURL = https://www.zgsjzc.com/api
# VITE_API_BASEURL = https://swzl-test.csbr.cn/api
VITE_API_BASEURL = http://192.168.6.20:28052/
# VITE_API_BASEURL = http://192.168.6.20:8052/
VITE_IDASS_BASEURL = https://daop-test.zgsjzc.com/portalLogin
......@@ -82,6 +83,9 @@ VITE_APP_ATTACHMENT_TEMPLATE = ms-daop-personel-service
#人员服务
VITE_APP_PERSONAL_URL = 'ms-daop-personel-service'
#元数据标准
VITE_APP_STANDARD_URL = 'ms-daop-meta-standard-service'
#流通平台地址
VITE_APP_CIRCULATION = https://daop-lt-test.zgsjzc.com/
# 测试环境访问地址
......
......@@ -110,6 +110,9 @@ VITE_API_ASSET_BASEURL = ms-swzl-data-dam-service
#数据同步接口地址
VITE_API_DATA_SYNC = ms-swzl-data-sync-service
#元数据标准
VITE_APP_STANDARD_URL = 'ms-daop-meta-standard-service'
#消息接口
VITE_API_MESSAGE = ms-daop-message-service
......
......@@ -249,3 +249,67 @@ export const delMetaDataSource = (databaseGuid) => request({
url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/del-by-database-guid?databaseGuid=${databaseGuid}`,
method: 'delete',
})
/** 元数据-标准代码分页查询 */
export const getStandardCodeList = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/page-list`,
method: 'post',
data: params
})
/** 元数据-标准代码新增 */
export const saveStandardCode = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/save`,
method: 'post',
data: params
})
/** 元数据-标准代码修改 */
export const updateStandardCode = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/update`,
method: 'put',
data: params
})
/** 元数据-标准代码详情 */
export const getStandardCodeDetail = (guid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/detail?guid=${guid}`,
method: 'get',
})
/** 元数据-标准代码删除 */
export const deleteStandardCode = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/delete`,
method: 'delete',
data: params
})
/** 元数据-查询标准列表 */
export const getStandardCodeStandard = (standardTypeCode) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-standard?standardTypeCode=${standardTypeCode}`,
method: 'get'
})
/** 元数据-查询代码列表 */
export const getStandardCodeDataList = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/get-data`,
method: 'post',
data: params
})
/** 元数据-查询代码字段数据 */
export const getStandardCodeFields = (standardGuid) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-field?standardGuid=${standardGuid}`,
method: 'get'
})
/** 元数据-保存标准代码数据 */
export const saveStandardCodeFieldsData = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/save-data`,
method: 'post',
data: params
})
/** 元数据-删除标准代码数据 */
export const deleteStandardCodeFieldsData = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/remove-data`,
method: 'post',
data: params
})
/** 元数据-导出 */
export const exportStandardCodeData = (params) => request({
url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/data-export`,
method: 'post',
data: params
})
\ No newline at end of file
......
......@@ -180,6 +180,29 @@ const routes: RouteRecordRaw[] = [
]
},
{
path: '/data-meta/reports',
component: Layout,
meta: {
title: '资源目录',
icon: 'ep:grid',
},
children: [
{
path: 'iframePage',
name: 'iframePage',
component: () => import('@/views/data_meta/budgetDataIndex.vue'),
meta: {
title: '',
sidebar: true,
breadcrumb: false,
cache: true,
reuse: true,
activeMenu: '/data-meta/reports/iframePage',
},
}
]
},
{
path: '/data-meta/portraitMap',
component: Layout,
meta: {
......@@ -200,6 +223,54 @@ const routes: RouteRecordRaw[] = [
},
}
]
},
{
path: '/data-meta/metadata-standard',
component: Layout,
meta: { title: '元数据标准', icon: 'ep:grid' },
children: [
{
path: '',
name: 'metadataStandard',
component: () => import('@/views/data_meta/standard.vue'),
meta: {
title: '元数据标准管理',
breadcrumb: false,
cache: true
}
},
{
path: 'standard-query',
name: 'metadataStandardQuery',
component: () => import('@/views/data_meta/standard-query.vue'),
meta: {
title: '元数据标准查询',
breadcrumb: false,
cache: true
}
},
{
path: 'standard-codetable',
name: 'metadataStandardCodetable',
component: () => import('@/views/data_meta/standard-codetable.vue'),
meta: {
title: '标准代码表',
breadcrumb: false,
cache: true
}
},
{
path: 'standard-import',
name: 'metadataStandardImport',
component: () => import('@/views/data_meta/standard-import.vue'),
meta: {
title: '标准代码导入',
breadcrumb: false,
cache: true,
activeMenu: '/data-meta/metadata-standard/standard-codetable'
}
}
]
}
]
......
......@@ -1293,6 +1293,7 @@ const loadDrawer = async () => {
drawerInfo.value.footer.btns.at(-2).visible = false
drawerInfo.value.footer.btns.at(-3).visible = false
drawerInfo.value.visible = true
console.log('table', formTable.value)
};
const batching = (type) => {
......
<route lang="yaml">
name: dictFileds
</route>
<script lang="ts" setup name="dictFileds">
import { ref } from 'vue'
import router from '@/router'
import { ElMessage, ElMessageBox } from "element-plus";
import Table from '@/components/Table/index.vue'
// import Dialog from '@/components/Dialog/index.vue'
import useCatchStore from "@/store/modules/catch";
import { chunk } from '@/utils/common'
import { getStandardCodeDataList, getStandardCodeFields, saveStandardCodeFieldsData, deleteStandardCodeFieldsData } from '@/api/modules/dataMetaService'
import {
saveDictionaryData,
getDictionaryFileds,
deleteDictionaryData,
checkDictionaryData,
showDictionary,
getDictionaryRuleData
} from '@/api/modules/dataInventory';
const emits = defineEmits(["exportData"])
const { proxy } = getCurrentInstance() as any;
const cacheStore = useCatchStore()
const standardGuid = ref("")
const standardName = ref('')
const tableSearchInput = ref('')
const tableFields: any = ref([])
const orginData: any = ref([])
const currTableData: any = ref<Object>({});
const selectRowData = ref([])
const page = ref({
limit: 50,
curr: 1,
// sizes: [
// { label: "100", value: 100 },
// { label: "200", value: 200 },
// { label: "300", value: 300 },
// { label: "400", value: 400 },
// { label: "500", value: 500 },
// ],
});
const tableChunkData: any = ref([])
const tableData: any = ref([])
const tableInfo: any = ref({
id: 'data-fileds-table',
multiple: true,
fields: [],
data: [],
page: {
type: "count",
rows: 0,
...page.value,
},
// showPage: false,
actionInfo: {
label: "操作",
type: "btn",
width: 92,
btns: (scope) => {
return [
{ label: "编辑", value: "edit", visible: scope.row['STATE'] !== 'Running' },
{ label: "删除", value: "remove", visible: scope.row['STATE'] !== 'Running' },
// { label: "保存", value: "save", visible: scope.row['STATE'] === 'Running' },
{ label: "取消", value: "cancel", visible: scope.row['STATE'] === 'Running' },
]
},
},
editInfo: {},
loading: false
})
const uploadFiles = ref([])
const uploadInfo = ref({
type: 'upload',
title: '',
col: '',
uploadInfo: {
id: 'upload-file-form',
type: 'panel',
action: '',
auto: false,
cover: true,
fileList: [],
accept: '.xlsx, .xls',
triggerBtn: {
label: '导入',
value: 'import_file',
icon: 'Upload',
},
tips: '当前支持xls、xlsx文件,默认使用第一个sheet'
},
})
const dialogInfo = ref({
visible: false,
size: 640,
direction: "column",
header: {
title: "新建",
},
type: '',
contents: [
uploadInfo.value
],
footer: {
visible: true,
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", label: "开始导入", value: "submit" },
],
},
})
const getFirstPageData = () => {
toSearch({})
}
const toSearch = (val: any, clear: boolean = false) => {
let params = {
pageIndex: 1,
pageSize: -1,
standardGuid : standardGuid.value
}
getTableData(params);
};
const getTableData = (params) => {
tableInfo.value.loading = true
Promise.all([getStandardCodeFields(standardGuid.value), getStandardCodeDataList(params)]).then((resList:any) => {
console.log(resList)
let schemaDataVOS = resList[0].data || []
let jsonArray = resList[1].data.records || []
setUploadDataInfo({schemaDataVOS,jsonArray}, true)
}).finally(() => tableInfo.value.loading = false)
};
const tableSelectionChange = (val, tId) => {
selectRowData.value = val;
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
if (page.value.limit != Number(info.limit)) {
page.value.limit = Number(info.limit);
chunkData()
} else {
tableData.value = tableChunkData.value[page.value.curr - 1]
tableInfo.value.data = tableData.value
tableInfo.value.page.limit = page.value.limit
tableInfo.value.page.curr = page.value.curr
}
};
const toolBtnClick = (btn) => {
const type = btn.value
if (type == 'export') {
exportData()
} else if (type == 'import') {
const info = [
{ standardGuid: standardGuid.value, standardName: standardName.value }
]
cacheStore.setCatch('uploadSetting', info)
nextTick(() => {
router.push({
path: '/data-meta/metadata-standard/standard-import',
});
})
} else if (type == 'submit') {
saveData()
} else if (type == 'add_row') {
const params = {
guid: standardGuid.value
}
getDictionaryRuleData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? {}
let rowInfo: any = {}
tableFields.value.map(item => {
rowInfo[item.field] = data[item.field] ?? ''
})
rowInfo.guid = undefined;
rowInfo.STATE = 'Running'
rowInfo.STATUS = 'edit'
rowInfo.ROWID = `upload_${tableData.value.length}`
tableData.value.unshift(rowInfo)
orginData.value.unshift(rowInfo)
tableInfo.value.page.rows = tableData.value.length
// orginData.value.unshift(rowInfo)
// page.value.curr = 1
// chunkData()
} else {
ElMessage({
type: 'error',
message: res.msg
})
}
})
}
}
const tableBtnClick = (scope, btn) => {
const type = btn.value;
let row = scope.row;
currTableData.value = row;
if (type == "edit") {
row.STATE = 'Running'
row.STATUS = 'edit'
tableData.value[scope.$index] = row
} else if (type == 'save') {
saveData(scope)
} else if (type == 'cancel') {
if (row.guid != undefined) {
// row = orginData.value[(page.value.curr - 1) * page.value.limit + scope.$index]
row = JSON.parse(JSON.stringify(orginData.value[scope.$index]))
row.STATE = ''
row.STATUS = ''
tableData.value[scope.$index] = row
} else {
tableData.value.splice(scope.$index, 1)
orginData.value.splice(scope.$index, 1)
// orginData.value.splice((page.value.curr - 1) * page.value.limit + scope.$index, 1)
// if (scope.$index == 0) {
// page.value.curr = (page.value.curr - 1 > 1) ? page.value.curr - 1 : 1
// }
// chunkData()
}
tableInfo.value.page.rows = tableData.value.length
} else if (type == 'remove') {
open("是否确定删除所选数据?", "warning");
}
};
const onUpload = (file, fileList) => {
uploadFiles.value = fileList
}
const uploadBtnClick = (btn) => {
exportData('model')
}
const exportData = (type: any = null) => {
emits('exportData', type)
}
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("standardGuid", standardGuid.value);
showDictionary(params).then((res: any) => {
if (res.code == proxy.$passCode) {
dialogInfo.value.visible = false
let data = res.data ?? []
// data.map((item: any, i) => {
// item.index = tableData.value.length + i
// })
const tData = { jsonArray: data }
setUploadDataInfo(tData)
// saveData(null, tData)
} else {
ElMessage({
type: "error",
message: res.msg,
});
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
});
}
const checkSave = () => {
const toSaveData = tableData.value.filter(item => item.STATE === 'Running')
return toSaveData.length == 0 ? true : false
}
const checkParamsData = (scope: any = null) => {
let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true
let passArr = scope ? [scope.row] : tableData.value
passArr.map((item, index) => {
const obj = JSON.parse(JSON.stringify(item))
delete obj.STATUS
delete obj.NOTES
delete obj.STATE
delete obj.ROWID
// if (item.STATE === 'Running') {
for (var i in obj) {
if (obj[i] == '') {
pass = false
}
}
// }
if (obj.guid !== undefined) {
upJsonArray.push(obj)
} else {
addJsonArray.push(obj)
}
if (scope) {
// obj.index = scope.$index
jsonArray.push(obj)
} else {
// obj.index = index
jsonArray.push(obj)
}
})
return { pass, addJsonArray, upJsonArray, jsonArray }
}
const loading = ref(false)
const saveData = async (scope: any = null, checkParamData: any = null) => {
let passInfo: any = {}
if (checkParamData) {
passInfo = checkParamData
} else {
passInfo = await checkParamsData(scope)
if (!passInfo.pass) {
ElMessage({
type: 'error',
message: '请填写所有数据项'
})
return
}
}
let params = passInfo.jsonArray.map(item => {
let standardCodeValue = {}
tableFields.value.forEach(fieldObj => {
standardCodeValue[fieldObj.field] = item[fieldObj.field]
})
let obj = {
standardGuid: standardGuid.value,
standardCodeValue,
guid: item.guid || null,
standardCodeId: item.standardCodeId || null,
parentId: item.parentId || null
}
return obj
})
loading.value = true
saveStandardCodeFieldsData(params).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: 'success',
message: '保存成功'
})
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
}).finally(() => loading.value = false)
}
const addColumn = (info: any = null) => {
const fields = tableFields.value
const existIndex = fields.findIndex(item => item.field == 'NOTES')
if (info) {
if (existIndex == -1) {
fields.push({
label: '备注',
field: 'NOTES',
width: 200
})
}
for (var d in info) {
tableData.value[d].NOTES = info[d].join(',')
}
} else {
if (existIndex > -1) {
fields.splice(existIndex, 1)
}
}
}
// 生成表头
const setUploadDataFields = (data) => {
let fields: any = [], editInfo: any = {}
data.map(item => {
let fieldItem: any = {
label: item.fieldName, field: item.fieldName, width: 140
}
fieldItem.type = 'edit'
fieldItem.columClass = 'edit-colum'
editInfo[item.fieldName] = {
label: '',
type: 'input',
placeholder: '',
maxlength: 50,
field: item.fieldName,
default: '',
disabled: item.codeRuleGuid ? true : false,
clearable: true,
}
fields.push(fieldItem)
})
tableFields.value = fields
tableInfo.value.fields = tableFields.value
tableInfo.value.editInfo = editInfo
}
// 生成表数据
const setUploadDataInfo = async (info, setField = false) => {
if (setField) {
const fields = info.schemaDataVOS ?? []
await setUploadDataFields(fields)
}
let data = info.jsonArray ?? []
// 设置表数据
// data.map((item, i) => {
// item.ROWID = `upload_${tableData.value.length + i}`
// })
data.forEach(item => {
Object.keys(item.standardCodeValue).forEach(key => {
item[key] = item.standardCodeValue[key]
})
})
if (setField) {
tableData.value = data
} else {
tableData.value = [...tableData.value, ...data]
}
orginData.value = JSON.parse(JSON.stringify(tableData.value))
tableInfo.value.data = tableData.value
tableInfo.value.page.rows = tableData.value.length
// if (setField) {
// orginData.value = data
// } else {
// orginData.value = [...orginData.value, ...data]
// }
// chunkData()
}
const chunkData = () => {
const data = orginData.value
tableChunkData.value = chunk(data, page.value.limit)
tableData.value = tableChunkData.value[page.value.curr - 1]
tableInfo.value.data = tableData.value
tableInfo.value.page.limit = page.value.limit
tableInfo.value.page.curr = page.value.curr
tableInfo.value.page.rows = orginData.value.length
}
const batching = (type) => {
if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的数据',
})
return
}
open("是否确定删除所选数据?", "warning", true);
}
};
const open = (msg, type, isBatch = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids: any = []
if (isBatch) {
const list = selectRowData.value.filter((item: any) => item.guid !== undefined)
if (list.length) {
guids = list.map((l: any) => l.guid)
}
const newRows = selectRowData.value.filter((item: any) => item.guid == undefined)
newRows.map((n: any, r) => {
const existIndex = tableData.value.findIndex(t => t.ROWID == n.ROWID)
if (existIndex > -1) {
tableData.value.splice(existIndex, 1)
orginData.value.splice(existIndex, 1)
}
// const existIndex = orginData.value.findIndex(t => t.id == n.id)
// existIndex > -1 && orginData.value.splice(existIndex, 1)
// if (r == newRows.length - 1) {
// page.value.curr = 1
// chunkData()
// }
})
tableInfo.value.page.rows = tableData.value.length
} else {
guids = [currTableData.value.guid]
}
if (guids.length) {
const params = {
guid: standardGuid.value,
delGuids: guids
}
// console.log(params)
// return
deleteStandardCodeFieldsData(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: "success",
message: "删除成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
});
}
});
};
const dialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
// dialogInfo.value.footer.btns.map((item: any) => item.disabled = true)
importData()
} else if (btn.value == 'cancel') {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
nextTick(() => {
dialogInfo.value.visible = false;
})
}
};
defineExpose({
standardGuid,
standardName,
getFirstPageData,
checkSave
});
</script>
<template>
<div class="container_wrap full flex">
<div class="main_wrap">
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="toolBtnClick({ value: 'add_row' })" v-preReClick :disabled="loading">新增行</el-button>
<el-button type="primary" plain @click="toolBtnClick({ value: 'submit' })" v-preReClick :disabled="loading">保存数据</el-button>
<el-button @click="batching('delete')" v-preReClick :disabled="loading">批量删除</el-button>
<el-button @click="toolBtnClick({ value: 'import' })" v-preReClick :disabled="loading">导入数据</el-button>
<el-button @click="toolBtnClick({ value: 'export' })" v-preReClick :disabled="loading">导出数据</el-button>
</div>
<!-- <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="输入名称搜索" :suffix-icon="Search" clearable
@change="val => toSearch({})" /> -->
</div>
<div class="table_panel_wrap full">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" />
</div>
</div>
<!-- <Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick" /> -->
</div>
</template>
<style lang="scss" scoped>
.container_wrap {
width: calc(100% - 200px);
.main_wrap {
width: 100%;
.table_panel_wrap {
height: calc(100% - 44px);
}
}
}
</style>
<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 './components/dictFileds.vue'
import useCatchStore from "@/store/modules/catch";
import { download } from '@/utils/common'
import { getParamsList } from '@/api/modules/dataAsset'
import { getStandardCodeList, saveStandardCode,
updateStandardCode, getStandardCodeDetail,
deleteStandardCode, getStandardCodeStandard, exportStandardCodeData
} from '@/api/modules/dataMetaService'
import {
addDictionary,
deleteDictionary,
getDictionary,
updateDictionary,
getDictionaryTree,
getDictionaryDetail,
exportDictionary,
showDictionary,
getDataBaseList,
getCoderuleList,
saveDictionaryData,
getDictionaryFileds,
updateDictionaryState,
getDictionaryRuleData,
exportDictionaryFileds,
checkDeleteDictionary,
checkDeleteDictionaryScheme,
checkDictionaryData,
getNewDataTypeList
} from '@/api/modules/dataInventory';
import router from '@/router'
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: "label",
value: "value",
isLeaf: "isLeaf",
},
lazy: true,
nodeKey: 'value',
expandedKey: ['01'],
currentNodeKey: '01',
data: [],
expandOnNodeClick: false,
loading: false,
currentObj: {}
});
const standardOptions = ref([])
const publishingUnitCodeOptions = ref([])
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 selectedRowData = ref([])
const tableInfo: any = ref({
id: 'data-source-table',
multiple: true,
fixedSelection: true,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: '代码名称', field: 'codeName', width: 140 },
{ label: '标准号', field: 'standard', width: 140 },
{ label: '标准名称', field: 'standardName', width: 140 },
// { label: '启用状态', field: 'bizState', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' },
{ label: '启用状态', field: 'bizState', type: 'tag', width: 100, align: 'center' },
{ label: '创建时间', field: 'createTime', width: 140 }
],
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' },
]
let codeOptions = ref([])
const orginItems = [
{
label: '标准类型',
type: 'select',
placeholder: '请选择',
field: 'standardTypeCode',
default: '',
options: standardOptions,
clearable: true,
required: true
}
, {
label: '字典英文名',
type: 'input',
maxlength: 20,
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 }
],
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([
{
label: '标准类型',
type: 'select',
placeholder: '请选择',
field: 'standardTypeCode',
default: '',
options: standardOptions,
clearable: true,
required: true
},
{
label: '代码名称',
type: 'input',
placeholder: '请输入',
field: 'codeName',
default: '',
maxlength: 20,
clearable: true,
required: true
},
{
label: '标准号',
type: 'input',
placeholder: '请输入',
field: 'standard',
default: '',
maxlength: 50,
clearable: true,
required: true
},
{
label: '标准名称',
type: 'input',
placeholder: '请输入',
field: 'standardName',
default: '',
maxlength: 20,
clearable: true,
required: true
},
{
label: '发布单位',
type: 'select',
placeholder: '请选择',
field: 'publishingUnitCode',
default: '',
options: publishingUnitCodeOptions,
clearable: true,
required: true
},
{
label: '排序',
type: 'inputNumber',
placeholder: '请输入',
field: 'orderNum',
default: '',
maxlength: 2,
clearable: true,
required: true
},
{
label: '启用状态',
type: 'switch',
field: 'bizState',
default: 'Y',
activeValue: 'Y',
inactiveValue: 'N'
},
{
label: '代码类型',
type: 'radio-panel',
placeholder: '请选择',
field: 'typeCode',
default: '1',
options: [
{ label: '列表结构', value: '1' },
{ label: '层级结构', value: '2' }
],
clearable: true,
required: true
},
{
label: '编码字段11',
type: 'select',
placeholder: '请选择',
field: 'codeFields',
default: [],
options: codeOptions,
clearable: true,
required: true,
multiple: true,
tagsTooltip: true,
filterable: true,
},
{
label: '编码名称',
type: 'select',
placeholder: '请选择',
field: 'codeFieldName',
default: '',
options: codeOptions,
clearable: true,
required: true
},
{
label: '层级结构',
type: 'input',
placeholder: '请输入',
field: 'hierarchy',
default: '',
clearable: true,
visible: true
}
])
const formRules: any = ref({
standardTypeCode: { required: true, message: '请选择标准类型' },
codeName: { required: true, message: '请输入代码名称' },
standard: { required: true, message: '请输入标准号' },
standardName: { required: true, message: '请输入标准名称' },
publishingUnitCode: { required: true, message: '请选择发布单位' },
orderNum: { required: true, message: '请输入排序' },
typeCode: { required: true, message: '请选择代码类型' },
codeFields: { required: true, message: '请选择编码字段' },
codeFieldName: { required: true, message: '请选择编码名称' }
})
const formInfo = ref({
type: 'form',
title: '',
col: 'span',
formInfo: {
id: 'add-dict-form',
col: 'col2',
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 }
]
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,
}
})
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' },
{ 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: 'submit', 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 = () => {
let params = {
dictType: "字段类型"
}
getNewDataTypeList(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.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 = {}) => {
getParamsList({ dictType: '标准类型'}).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data || []
data.forEach(item => {
item.treeLevel = 1
})
treeInfo.value.data = data
standardOptions.value = data
// 默认展开第一个
if (data.length === 0) return
let params = {
pageIndex: 1,
pageSize: 50,
standardTypeCode: data[0].value,
// codeName: '标准类型'
}
getStandardCodeList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
let 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
}
})
}
})
}
const getFirstPageData = () => {
page.value.curr = 1;
toSearch({})
}
const toSearch = (val: any, clear: boolean = false) => {
let params: any = Object.keys(val).length ? { ...val } : {}
let { currentNodeKey, currentObj } = treeInfo.value
console.log('currentObj', currentObj)
params.pageIndex = page.value.curr;
params.pageSize = page.value.limit;
params.codeName = tableSearchInput.value
if (currentObj.treeLevel === 1) {
params.standardTypeCode = currentNodeKey
} else if (currentObj.treeLevel === 2) {
params.standardTypeCode = currentObj.standardTypeCode
params.standardName = currentObj.value
}
getTableData(params);
};
const getTableData = (params) => {
tableInfo.value.loading = true
getStandardCodeList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data
let list = res.data.records || []
list = list.map(item => {
item.label = item.codeName
item.value = item.guid
return item
})
tableInfo.value.data = list
tableInfo.value.page.limit = data.pageSize
tableInfo.value.page.curr = data.pageIndex
tableInfo.value.page.rows = data.totalRows
}
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);
selectedRowData.value = val
}
};
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)
}
})
codeOptions.value = 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;
drawerInfo.value.loading = true;
formTable.value.tableInfo.loading = true
getStandardCodeDetail(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 == "delete") {
currTableData.value = row;
tableInfo.value.loading = true
open("此操作将永久删除, 是否继续?", "warning");
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
deleteStandardCode(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData()
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) => {
let body = [treeCurrentNodeKey.value]
exportStandardCodeData(body).then((res:any) => {
if (res && !res.msg) {
download(res, '标准代码表.xlsx', 'excel')
} else {
res?.msg && ElMessage.error(res?.msg);
}
})
return
}
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.visible = true;
drawerInfo.value.type = 'add';
drawerInfo.value.header.title = '新增标准代码';
drawerInfo.value.footer.visible = true;
// 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.visible = true
console.log('table', formTable.value)
console.log('formInfo', formInfo)
setCodeOptions()
};
const treeCurrentNodeKey = ref('')
const batching = (type) => {
if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的数据',
})
return
}
tableInfo.value.loading = true
open("此操作将永久删除, 是否继续?", "warning", true);
tableInfo.value.loading = false
}
if (type == 'export') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择代码名称',
})
return
}
// console.log(selectedRowData)
let uploadSetting = selectedRowData.value.map(item => {
return {
standardName: item.codeName,
standardGuid: item.guid
}
})
cacheStore.setCatch('uploadSetting', uploadSetting)
router.push({
path: '/data-meta/metadata-standard/standard-import',
});
}
};
const nodeClick = (data) => {
console.log('treeNodeClick', data)
drawerInfo.value.visible = false
const changeCont = () => {
nextTick(() => {
treeInfo.value.currentNodeKey = data.value
treeInfo.value.currentObj = data
if (data.isLeaf) {
showFiledsPage.value = true
nextTick(() => {
dictFiledsRef.value.standardGuid = data.value
dictFiledsRef.value.standardName = data.label
treeCurrentNodeKey.value = data.value
dictFiledsRef.value.getFirstPageData()
})
} else {
showFiledsPage.value = false
getFirstPageData()
}
})
}
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()
}
}
function loadTreeNode (node, resolve) {
console.log('node', node)
if (node.isLeaf) {
return resolve([]);
}
if (node.level === 1) {
let standardTypeCode = node.data.value
getStandardCodeStandard(standardTypeCode).then((res:any) => {
if (res.code === proxy.$passCode) {
let data = res.data || []
let uniqList = Array.from(new Set(data)).map(item => {
return {
label: item,
value: item,
treeLevel: 2,
standardTypeCode
}
})
resolve(uniqList)
}
})
}
if (node.level === 2) {
let params = {
pageIndex: 1,
pageSize: -1,
standardTypeCode: node.data.standardTypeCode,
standardName: node.data.value
}
getStandardCodeList(params).then((res:any) => {
if (res.code === proxy.$passCode) {
const list = res.data.records || []
list.forEach(item => {
item.isLeaf = true
item.label = item.codeName
item.value = item.guid
})
resolve(list)
}
})
}
}
// 设置详情信息
const setDetailInfo = () => {
const row = JSON.parse(JSON.stringify(currTableData.value))
formItems.value.forEach(item => {
item.default = row[item.field] || ''
})
formInfo.value.formInfo.items = formItems.value
formTableData.value = row.standardCodeFields.map(item => {
item.STATUS = 'edit'
return item
})
let fields = JSON.parse(JSON.stringify(orginFields))
fields.map((item: any) => {
if (item.type != 'index') {
item.type = 'edit'
item.columClass = 'edit-colum'
}
})
formTable.value.tableInfo.fields = fields
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.visible = true
setCodeOptions()
}
const saveData = async (params) => {
// const passInfo = await checkParamsData()
console.log('params', params)
let request = drawerInfo.value.type === 'add' ? saveStandardCode : updateStandardCode
request(params).then((res:any) => {
if (res.code === proxy.$passCode) {
ElMessage.success('操作成功')
getTreeData()
drawerInfo.value.visible = false
}
}).finally(() => {
drawerInfo.value.footer.btns.map((item: any) => item.disabled = false)
})
}
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) => {
console.log('btn', btn, info)
console.log('table', formTable.value)
let params = {
standardCodeFields: formTable.value.tableInfo.data.map(item => {
let obj = {
fieldName: item.fieldName,
guid: item.guid || null,
standardGuid: item.standardGuid || null
}
return obj
}),
...info
}
if (params.typeCode === '1') {
delete params.hierarchy
}
if (drawerInfo.value.type === 'edit') {
params.guid = currTableData.value.guid
}
if (btn.value == 'submit' || btn.value == 'saveAndAdd') {
drawerInfo.value.footer.btns.map((item: any) => item.disabled = true)
saveData(params)
} else {
drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
nextTick(() => {
drawerInfo.value.visible = false
})
}
}
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()
getTreeData()
getParamsList({ dictType: '发布单位' }).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data || []
publishingUnitCodeOptions.value = data
}
})
})
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" @loadNode="loadTreeNode"/>
</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>
<el-button @click="batching('export')" 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>
<route lang="yaml">
name: metadataStandardCodetable
</route>
<script lang="ts" setup name="metadataStandardCodetable">
import { ref, reactive } from 'vue';
import { ElMessage } from "element-plus";
import Tree from '@/components/Tree/index.vue';
import TableTools from '@/components/Tools/table_tools.vue';
import { Search } from '@element-plus/icons-vue'
import { useRouter, useRoute } from "vue-router";
import { TableColumnWidth } from '@/utils/enum';
import { commonPageConfig } from '@/components/PageNav/index';
import { getParamsList } from '@/api/modules/dataAsset'
import { getStandardCodeList, saveStandardCode, updateStandardCode } from '@/api/modules/dataMetaService'
const { proxy } = getCurrentInstance() as any;
const router = useRouter();
const treeInfo:any = reactive({
id: "data-pickup-tree",
filter: true,
queryValue: "",
queryPlaceholder: "请输入关键字搜索",
props: {
label: "label",
value: "value",
},
nodeKey: 'value',
expandedKey: ['01'],
currentNodeKey: '01',
expandOnNodeClick: false,
data: [],
loading: false
});
function nodeClick (data) {
}
/** 分页及搜索传参信息配置。 */
const tableSearchInput = ref('')
function getFirstPageData () {
page.value.curr = 1
toSearch({})
}
function 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.name = tableSearchInput.value
getTableData(params);
}
const page = ref({
...commonPageConfig,
collectTaskName: '',
dataSourceGuid: '',
taskState: null
});
const tableInfo = ref({
id: 'data-source-table',
fields: [
{ label: '序号', type: 'index', width: TableColumnWidth.INDEX, align: 'center' },
{ label: '代码名称', field: '1', width: 140 },
{ label: '标准号', field: '2', width: 140 },
{ label: '标准名称', field: '3', width: 140 },
{ label: '启用状态', field: '4', width: 140 },
{ label: '创建时间', field: '5', width: 140 }
],
data: [],
page: {
type: 'normal',
rows: 0,
...page.value
},
actionInfo: {
label: '操作',
type: 'btn',
width: 160,
btns: scope => {
let row = scope.row
return [
{ label: '编辑', value: 'edit' },
{ label: '删除', value: 'delete' },
]
}
},
loading: false
})
function tableBtnClick (scope, btn) {
}
function tablePageChange (info) {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
// getTableData();
}
function getTableData (params) {
}
function handleCreate () {
drawerInfo.value.visible = true;
drawerInfo.value.type = 'add';
drawerInfo.value.header.title = '新增标准代码';
drawerInfo.value.footer.visible = true;
}
// drawer form
const standardOptions = ref([])
const publishingUnitCodeOptions = ref([])
const formRef = ref()
const formItems: any = ref([
{
label: '标准类型',
type: 'select',
placeholder: '请选择',
field: 'standardTypeCode',
default: '',
options: standardOptions,
clearable: true,
required: true
},
{
label: '代码名称',
type: 'input',
placeholder: '请输入',
field: 'codeName',
default: '',
maxlength: 20,
clearable: true,
required: true
},
{
label: '标准号',
type: 'input',
placeholder: '请输入',
field: 'standard',
default: '',
maxlength: 50,
clearable: true,
required: true
},
{
label: '标准名称',
type: 'input',
placeholder: '请输入',
field: 'standardName',
default: '',
maxlength: 20,
clearable: true,
required: true
},
{
label: '发布单位',
type: 'select',
placeholder: '请输入',
field: 'publishingUnitCode',
default: '',
options: publishingUnitCodeOptions,
clearable: true,
required: true
},
{
label: '排序',
type: 'inputNumber',
placeholder: '请输入',
field: 'orderNum',
default: '',
maxlength: 2,
clearable: true,
required: true
},
{
label: '启用状态',
type: 'switch',
field: 'bizState',
default: false
},
{
label: '代码类型',
type: 'select',
placeholder: '请选择',
field: 'typeCode',
default: '1',
options: [
{ label: '列表结构', value: '1' },
{ label: '层级结构', value: '2' }
],
clearable: true,
required: true
},
{
label: '编码字段',
type: 'select',
placeholder: '请选择',
field: 'codeFields',
default: [],
options: [
{ label: 'code', value: 'code' },
{ label: 'name', value: 'name' }
],
clearable: true,
required: true,
multiple: true
},
{
label: '编码名称',
type: 'select',
placeholder: '请选择',
field: 'codeFieldName',
default: '',
options: [
{ label: 'code', value: 'code' },
{ label: 'name', value: 'name' }
],
clearable: true,
required: true
},
{
label: '层级结构',
type: 'input',
placeholder: '请输入',
field: 'hierarchy',
default: '',
clearable: true,
required: true
}
])
const formRules = ref({
})
const formInfo = ref({
type: 'form',
title: '',
col: 'span',
formInfo: {
id: 'add-dict-form',
col: 'col2',
items: formItems.value,
formRules: formRules.value
}
})
const formTable = reactive({
type: "table",
title: "定义表结构",
col: 'no-margin',
style: {
height: 'calc(100% - 234px)'
},
tableInfo: {
id: "role-authority-table",
multiple: true,
minHeight: 'unset',
maxHeight: '100%',
fields: [
{ label: '序号', type: 'index', width: 56, align: 'center' },
{ label: '字段名称', field: 'fieldName', width: 140, type: 'edit', customClass: 'edit-colum'}
],
data: [{ fieldName: '1', index: 0}],
showPage: false,
actionInfo: {
show: true,
label: "操作",
type: "btn",
width: 60,
fixed: 'right',
btns: [{ label: "删除", value: "remove" }]
},
editInfo: {
fieldName: {
field: 'fieldName',
label: '字段名称',
type: 'input',
clearable: true,
maxlength: 20
}
},
readonly: false,
col: 'auto-height',
style: { height: 'calc(100% - 40px)'},
loading: false
},
tableTool: {
col: 'float-right',
visible: true,
btns: [
{ label: "新增行", value: "tableAdd", type: 'primary' },
{ label: "批量删除", value: "tableDelete" },
]
},
})
// 新增drawer
const drawerInfo = ref({
visible: false,
direction: 'rtl',
size: 550,
header: {
title: '新增标准代码',
},
type: '',
container: {
contents: [formInfo.value, formTable],
},
footer: {
visible: true,
btns: [
{ type: 'default', label: '取消', value: 'cancel' },
{ type: 'primary', label: '保存', value: 'save' },
{ type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true }
]
}
})
async function drawerBtnClick (btn, info) {
}
function drawerTableToolBtnClick (btn, data) {
console.log(btn, data)
if (btn.value === 'tableAdd') {
// 定义表结构新增行
let rowInfo = { fieldName: '' }
formTable.tableInfo.data.push(rowInfo)
}
}
onMounted(() => {
getParamsList({ dictType: '标准类型'}).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data || []
treeInfo.data = data
standardOptions.value = data
// 默认展开第一个
if (data.length === 0) return
let params = {
pageIndex: 1,
pageSize: 100,
standardTypeCode: data[0].value,
codeName: '标准类型'
}
getStandardCodeList(params)
}
})
getParamsList({ dictType: '发布单位' }).then((res:any) => {
if (res.code === proxy.$passCode) {
const data = res.data || []
publishingUnitCodeOptions.value = data
}
})
})
</script>
<template>
<div class="container_wrap full flex">
<div class="aside_wrap">
<div class="aside_title">标准代码列表</div>
<Tree :treeInfo="treeInfo" @nodeClick="nodeClick" />
</div>
<div class="main_wrap">
<div class="table_tool_wrap">
<div class="tools_btns">
<el-button type="primary" @click="handleCreate">新建</el-button>
<el-button>批量删除</el-button>
<el-button>批量导入</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">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tablePageChange="tablePageChange"
/>
</div>
</div>
<Drawer
:drawerInfo="drawerInfo"
@drawerBtnClick="drawerBtnClick"
ref="drawerRef"
@drawerTableToolBtnClick="drawerTableToolBtnClick"
>
<!-- <Form ref="formRef"
:itemList="formItems"
formId="basic-info-form"
:rules="formRules"
/> -->
</Drawer>
</div>
</template>
<style scoped lang="scss">
.container_wrap {
.aside_wrap {
width: 200px;
}
.main_wrap {
padding: 10px 20px;
:deep(.el-tabs) {
height: 100%;
.el-tabs__header {
margin-bottom: 0;
}
.el-tabs__item {
height: 32px;
padding: 0px;
width: 144px;
&:last-child {
width: 130px;
}
}
.el-tabs__content {
height: calc(100% - 32px);
}
.el-tab-pane {
padding: 0px 16px;
height: 100%;
}
}
}
}
.tree_panel {
height: calc(100% - 36px);
padding-top: 0;
:deep(.el-tree) {
margin: 0;
overflow: hidden auto;
}
}
.table_tool_wrap {
display: flex;
flex-direction: column;
.el-input {
width: 230px;
height: 32px;
}
:deep(.el-input) {
.el-input__suffix-inner {
flex-direction: row-reverse;
-webkit-flex-direction: row-reverse;
display: flex;
}
}
}
.table_panel_wrap {
height: calc(100% - 44px);
}
</style>
\ No newline at end of file
<route lang="yaml">
name: importFile
</route>
<script lang="ts" setup name="importFile">
import { ref } from "vue";
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, downFileByBob, downFile } from '@/utils/common'
import {
addImportData,
deleteImportData,
getImportData,
exportDictionary,
exportCollectTask,
// getImageContent
} from '@/api/modules/queryService';
import {
parseAndDecodeUrl,
getDownFileSignByUrl,
obsDownloadRequest
} from '@/api/modules/obsService';
import {
getDictionaryTree
} from '@/api/modules/dataInventory';
import { commonPageConfig } from '@/utils/enum';
const { proxy } = getCurrentInstance() as any;
const userStore = useUserStore()
const route = useRoute()
const router = useRouter()
/** 2表示资产目录的。3是主数据; 4是元数据导入 */
const isfileImport = route.query.isfileImport
const userData = JSON.parse(userStore.userData)
const cacheStore = useCatchStore()
const standardSetList = ref([])
const standardSetGuid = ref('')
const dictionaryList = ref([])
const dictionaryGuid = ref('')
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' },
]
const importTabs = [
{ label: '导入文件数据', name: 'importFile' },
// { label: '质量模型导入', name: 'qualityModelGroup' },
// { label: '质量规则导入', name: 'qualityRule' },
]
const tabsInfo = ref({
activeName: '',
tabs: isfileImport ? importTabs : defaulttabs
})
const currTableData: any = ref<Object>({});
const page = ref(commonPageConfig);
const selectRowData = ref([])
const tableInfo = ref({
id: 'data-source-table',
multiple: true,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
{ label: "文件名称", field: "fileName", width: 240, },
{ label: "状态", field: "importState", type: 'tag', width: 110, align: 'center' },
{ label: "导入结果", field: "importMessage", width: 280 },
{ label: "导入时间", field: "createTime", width: 180 },
],
data: [],
page: {
type: "normal",
rows: 0,
...page.value,
},
actionInfo: {
label: "操作",
type: "btn",
width: 220,
fixed: 'right',
btns: (scope) => {
const row = scope.row
let btnsArr = [
{ label: '下载文件', value: 'export_file' },
{ label: '删除', value: 'delete' }
]
if (row.importState != 0 && row.importState != 1) {
btnsArr.splice(1, 0, { label: '下载异常数据', value: 'export_abnormal_data' })
}
return btnsArr
},
},
loading: false
})
const uploadFiles = ref([])
const uploadSteps: any = ref([])
const uploadInfo = ref({
type: 'upload',
title: '',
col: '',
uploadInfo: {
id: 'upload-file-form',
type: 'panel',
steps: [],
extraParams: {dictionaryGuid: 'xx'},
},
})
const dialogInfo: any = ref({
visible: false,
size: 700,
direction: "column",
header: {
title: "新建",
},
type: 'upload',
contents: [
uploadInfo.value
],
footer: {
visible: true,
btns: [
{ type: "default", label: "取消", value: "cancel" },
{ type: "primary", loading: false, label: "开始导入", value: "submit" },
],
},
})
// // 获取所有数据字典
const getDictList = () => {
const params = {
paramCode: '数据字典类型'
}
getDictionaryTree(params).then((res: any) => {
if (res.code == proxy.$passCode) {
const data = res.data ?? []
const treeList = data.filter(item => item.children && item.children.length)
dictionaryList.value = treeList
} else {
ElMessage({
type: 'error',
message: res.msg,
})
}
})
}
const tabsChange = (name) => {
tabsActiveName.value = name
let info: any = {
type: name
}
if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') {
info.standardSetGuid = standardSetGuid.value
} else if (tabsActiveName.value == 'dictionary') {
info.dictionaryGuid = dictionaryGuid.value
} else if (tabsActiveName.value == 'importFile') {
}
cacheStore.setCatch('uploadSetting', info)
setUploadInfo()
}
const getFirstPageData = () => {
page.value.curr = 1
toSearch({})
console.log('store', cacheStore.getCatch('uploadSetting'))
}
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.staffGuid = userData.staffGuid;
params.importType = importType.value;
params.bizGuid = route.query.bizGuid || ''
getTableData(params);
};
const getTableData = (params) => {
tableInfo.value.loading = true
getImportData(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) => {
selectRowData.value = val.map(item => item.guid);
};
const tablePageChange = (info) => {
page.value.curr = Number(info.curr);
page.value.limit = Number(info.limit);
toSearch({});
};
const tableBtnClick = async (scope, btn) => {
const type = btn.value;
const row = scope.row;
currTableData.value = row;
if (type == "export_file") {
const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.filePath).fileName);
if (!refSignInfo?.data) {
refSignInfo?.msg && ElMessage.error(refSignInfo?.msg);
return;
}
obsDownloadRequest(refSignInfo?.data).then((res: any) => {
if (res && !res.msg) {
downFileByBob(res, row.fileName);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
//downFile(row.filePath, row.fileName)
} else if (type == 'export_abnormal_data') {
//downFile(row.errorFilePath, '')
const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.errorFilePath).fileName);
if (!refSignInfo?.data) {
refSignInfo?.msg && ElMessage.error(refSignInfo?.msg);
return;
}
obsDownloadRequest(refSignInfo?.data).then((res: any) => {
if (res && !res.msg) {
let name = row.errorFilePath;
let fileName = name ? name.substring(name.lastIndexOf('/') + 1) : ''
downFileByBob(res, fileName);
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
} else if (type == "delete") {
open("此操作将永久删除, 是否继续?", "warning");
}
};
const batching = (type) => {
if (type == 'import') {
dialogInfo.value.header.title = '导入数据'
dialogInfo.value.type = 'upload'
dialogInfo.value.size = 640
uploadFiles.value = []
// if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') {
// uploadSteps.value[0].selectInfo.options = standardSetList.value
// } else if (tabsActiveName.value == 'dictionary') {
// uploadSteps.value[0].cascaderInfo.options = dictionaryList.value
// }
uploadInfo.value.uploadInfo.steps = uploadSteps.value
const content: any = [uploadInfo.value]
dialogInfo.value.contents = content
dialogInfo.value.visible = true
} else if (type == 'delete') {
if (selectRowData.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择需要删除的数据',
})
return
}
open("此操作将永久删除, 是否继续?", "warning", true);
} else if (type === 'importFile') {
if (isfileImport == '2' || isfileImport == '4') {
dialogInfo.value.header.title = '导入数据'
dialogInfo.value.type = 'upload'
dialogInfo.value.size = isfileImport == '4' ? 600 : 500;
uploadFiles.value = []
uploadInfo.value.uploadInfo.steps = uploadSteps.value
const content: any = [uploadInfo.value]
dialogInfo.value.contents = content
dialogInfo.value.visible = true
} else {
router.push({
name: "importData",
query: route.query
})
}
}
};
const open = (msg, type, isBatch = false) => {
ElMessageBox.confirm(msg, "提示", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: type,
}).then(() => {
let guids = [currTableData.value.guid]
if (isBatch) {
guids = selectRowData.value
}
deleteImportData(guids).then((res: any) => {
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: "success",
message: "删除成功",
});
} else {
ElMessage({
type: "error",
message: res.msg,
});
}
});
});
};
const onUpload = (file, fileList) => {
uploadFiles.value = fileList
}
const uploadBtnClick = (btn) => {
exportData()
}
const cascaderChange = (val) => {
dictionaryGuid.value = val ? val.at(-1) : ''
}
const selectChange = (val) => {
standardSetGuid.value = val
}
const exportData = (ids: any = null) => {
if (tabsActiveName.value == 'standard') {
const fieldTemplate = "/files/set.xlsx";
downFile(fieldTemplate, '标准集模板.xlsx')
} else if (tabsActiveName.value == 'field') {
const fieldTemplate = "/files/field.xlsx";
downFile(fieldTemplate, '字段标准模板.xlsx')
} else if (tabsActiveName.value == 'naming') {
const namingTemplate = "/files/naming.xlsx";
downFile(namingTemplate, '命名标准模板.xlsx')
} else if (tabsActiveName.value == 'dictionary') {
const params = {
guid: dictionaryGuid.value
}
exportDictionary(params).then((res: any) => {
if (res && !res.msg) {
download(res, '数据字典模板.xlsx', 'excel');
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
} else if (tabsActiveName.value == 'importFile' && isfileImport == '4') {
exportCollectTask({
importTypes: [
"0042"
]
}).then((res: any) => {
if (res && !res.msg) {
download(res, '元数据模板.xlsx', 'excel');
} else {
res?.msg && ElMessage.error(res?.msg);
}
});
}
}
const importData = (info) => {
let params = new FormData()
if (uploadFiles.value.length == 0) {
ElMessage({
type: 'error',
message: '请选择上传文件'
})
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
return
}
let sheetPass = uploadSetting.value.every(item => item.value)
if (!sheetPass) {
ElMessage({ type: 'error', message: '请选择sheet页'})
return
}
let paramUrl = '';
uploadFiles.value.forEach((item: any, index: number) => {
params.append("file", item.raw);
});
let sheetMaps = {}
uploadSetting.value.forEach(item => {
sheetMaps[item.value] = item.standardGuid
})
sheetMaps = JSON.stringify(sheetMaps)
// console.log('sheetMaps', sheetMaps)
paramUrl = encodeURI(`${import.meta.env.VITE_APP_ADD_FILE}/import-data/import-batch-common?importType=${importType.value}&staffGuid=${userData.staffGuid}&tenantGuid=${userData.tenantGuid}&sheetMaps=${sheetMaps}`)
// if (info && Object.keys(info).length) {
// paramUrl += `&extendFields=${encodeURIComponent(JSON.stringify(info))}`
// }
dialogInfo.value.footer.btns[1].loading = true;
addImportData(paramUrl, params).then((res: any) => {
dialogInfo.value.footer.btns[1].loading = false;
if (res.code == proxy.$passCode) {
getFirstPageData();
ElMessage({
type: "success",
message: '导入成功',
});
dialogInfo.value.visible = false;
} else {
ElMessage({
type: "error",
message: res.msg,
});
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
}
}).catch(() => {
dialogInfo.value.footer.btns[1].loading = false;
})
}
const dialogBtnClick = (btn, info) => {
if (btn.value == 'submit') {
// dialogInfo.value.footer.btns.map((item: any) => item.disabled = true)
if (dialogInfo.value.type == 'upload') {
if (tabsActiveName.value == 'dictionary') {
importData({ bizGuid: dictionaryGuid.value })
} else {
importData(info)
}
}
} else if (btn.value == 'cancel') {
// dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
nextTick(() => {
dialogInfo.value.visible = false;
})
};
}
const setUploadInfo = () => {
importType.value = '0101'
tabsInfo.value.activeName = tabsActiveName.value
getFirstPageData()
uploadSteps.value = [
{
title: '1、选择准备好的文件导入',
type: 'btn_upload',
uploadInfo: {
action: '',
auto: false,
cover: true,
fileList: [],
accept: '.xlsx, .xls',
tips: '当前支持xls、xlsx文件,支持一个文件多个sheet批量导入'
}
}
]
}
onActivated(() => {
let list = cacheStore.getCatch('uploadSetting') || []
uploadSetting.value = list.map(item => {
item.value = null
return item
})
console.log('uploadSetting', uploadSetting.value)
setUploadInfo()
})
</script>
<template>
<div class="container_wrap">
<!-- <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 @click="batching('delete')" v-preReClick>批量删除</el-button>
<el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button>
</div>
<span class="tips_text">请及时刷新查看最终结果</span>
</div>
<div class="table_panel_wrap" :style="{ height: !isfileImport ? 'calc(100% - 71px)' : 'calc(100% - 44px)' }">
<Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
@tablePageChange="tablePageChange" />
</div>
<Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick"
@cascaderChange="cascaderChange" @selectChange="selectChange">
<div>
<div class="title" style="color:#333">2、导入前请先导入文件的sheet与标准做对应</div>
<el-form :label-width="120" style="margin-top:20px">
<el-form-item label="全局变量">
<span>选择sheet页</span>
</el-form-item>
<el-form-item v-for="item in uploadSetting" :key="item.standardGuid" :label="item.standardName" required >
<el-select v-model="item.value" placeholder="请选择" style="width:200px" clearable>
<el-option v-for="i in uploadSetting.length" :label="`Sheet${i}`" :value="`Sheet${i}`" :key="i"></el-option>
</el-select>
</el-form-item>
</el-form>
</div>
</Dialog>
</div>
</template>
<style lang="scss" scoped>
.container_wrap {
padding: 0;
:deep(.el-tabs) {
.el-tabs__header {
margin-bottom: 0;
}
.el-tabs__item {
height: 32px;
&:nth-child(2) {
padding-left: 16px;
}
&:last-child {
padding-right: 16px;
}
&::after {
content: '';
width: 100%;
height: 2px;
background-color: transparent;
position: absolute;
left: 0;
bottom: 0;
}
&.is-active {
&::after {
background-color: var(--el-color-primary);
}
}
}
.el-tabs__active-bar {
display: none;
}
}
.table_tool_wrap {
padding: 0 16px;
display: flex;
align-items: center;
.tips_text {
margin-left: 16px;
font-size: 14px;
color: #b2b2b2;
}
}
.table_panel_wrap {
padding: 0 16px;
height: calc(100% - 71px);
}
}
</style>
<template>
<div>元数据标准查询</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
\ No newline at end of file
<template>
<div>元数据标准</div>
</template>
<script>
export default {
}
</script>
<style>
</style>
\ No newline at end of file
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!