元数据标准
Showing
6 changed files
with
723 additions
and
9 deletions
| ... | @@ -365,6 +365,13 @@ export const deleteMetaStandardDataFields = (params) => request({ | ... | @@ -365,6 +365,13 @@ export const deleteMetaStandardDataFields = (params) => request({ |
| 365 | method: 'delete', | 365 | method: 'delete', |
| 366 | data: params | 366 | data: params |
| 367 | }) | 367 | }) |
| 368 | /** 元数据标准-导出 */ | ||
| 369 | export const exportMetaStandardData = (params) => request({ | ||
| 370 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/meta-standard/data/data-export`, | ||
| 371 | method: 'post', | ||
| 372 | data: params, | ||
| 373 | responseType: 'blob' | ||
| 374 | }) | ||
| 368 | /** 标准代码-树形表 */ | 375 | /** 标准代码-树形表 */ |
| 369 | export const getStandardCodeTree = () => request({ | 376 | export const getStandardCodeTree = () => request({ |
| 370 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/code-tree`, | 377 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/code-tree`, | ... | ... |
| ... | @@ -282,6 +282,17 @@ const routes: RouteRecordRaw[] = [ | ... | @@ -282,6 +282,17 @@ const routes: RouteRecordRaw[] = [ |
| 282 | cache: true, | 282 | cache: true, |
| 283 | activeMenu: '/data-meta/metadata-standard/standard-codetable' | 283 | activeMenu: '/data-meta/metadata-standard/standard-codetable' |
| 284 | } | 284 | } |
| 285 | }, | ||
| 286 | { | ||
| 287 | path: 'standard-meta-import', | ||
| 288 | name: 'standardMetaImport', | ||
| 289 | component: () => import('@/views/data_meta/standard-meta-import.vue'), | ||
| 290 | meta: { | ||
| 291 | title: '元数据标准导入', | ||
| 292 | breadcrumb: false, | ||
| 293 | cache: true, | ||
| 294 | activeMenu: '/data-meta/metadata-standard' | ||
| 295 | } | ||
| 285 | } | 296 | } |
| 286 | ] | 297 | ] |
| 287 | } | 298 | } | ... | ... |
| ... | @@ -7,7 +7,7 @@ | ... | @@ -7,7 +7,7 @@ |
| 7 | > | 7 | > |
| 8 | <el-form :model="form" :rules="formRules" ref="formEl" style="min-height: 200px;"> | 8 | <el-form :model="form" :rules="formRules" ref="formEl" style="min-height: 200px;"> |
| 9 | <el-row> | 9 | <el-row> |
| 10 | <el-col v-for="item,index in fields" :key="index" :span="12" style="padding-right:10px"> | 10 | <el-col v-for="item,index in fields" :key="index" :span="12" style="padding-right:10px;margin-bottom:10px;"> |
| 11 | <el-form-item :label="item.fileNameCodeName" :prop="item.fileNameCode"> | 11 | <el-form-item :label="item.fileNameCodeName" :prop="item.fileNameCode"> |
| 12 | <el-input | 12 | <el-input |
| 13 | v-if="item.inputTypeCode == '1' || item.inputTypeCode == '3'" | 13 | v-if="item.inputTypeCode == '1' || item.inputTypeCode == '3'" |
| ... | @@ -20,10 +20,17 @@ | ... | @@ -20,10 +20,17 @@ |
| 20 | filterable | 20 | filterable |
| 21 | clearable | 21 | clearable |
| 22 | placeholder="请选择" | 22 | placeholder="请选择" |
| 23 | size="small" | ||
| 23 | > | 24 | > |
| 24 | <el-option v-for="op in formOptions[item.fileNameCode]" :label="op.label" :value="op.value" :key="op.value"></el-option> | 25 | <el-option v-for="op in formOptions[item.fileNameCode]" :label="op.label" :value="op.value" :key="op.value"></el-option> |
| 25 | </el-select> | 26 | </el-select> |
| 26 | 27 | <el-tree-select | |
| 28 | v-else-if="item.inputTypeCode == '4'" | ||
| 29 | v-model="form[item.fileNameCode]" | ||
| 30 | :data="standardCodeTree" | ||
| 31 | :props="treeSelectProps" | ||
| 32 | placeholder="请选择" | ||
| 33 | /> | ||
| 27 | </el-form-item> | 34 | </el-form-item> |
| 28 | </el-col> | 35 | </el-col> |
| 29 | </el-row> | 36 | </el-row> |
| ... | @@ -39,7 +46,7 @@ | ... | @@ -39,7 +46,7 @@ |
| 39 | import { watch } from 'vue' | 46 | import { watch } from 'vue' |
| 40 | import { ElMessage } from "element-plus"; | 47 | import { ElMessage } from "element-plus"; |
| 41 | import { getParamsList } from '@/api/modules/dataAsset' | 48 | import { getParamsList } from '@/api/modules/dataAsset' |
| 42 | import { saveMetaStandardDataFields, getMetaStandardFieldDetail } from '@/api/modules/dataMetaService' | 49 | import { saveMetaStandardDataFields, getMetaStandardFieldDetail, getStandardCodeTree } from '@/api/modules/dataMetaService' |
| 43 | 50 | ||
| 44 | const { proxy } = getCurrentInstance() as any; | 51 | const { proxy } = getCurrentInstance() as any; |
| 45 | const props = defineProps({ | 52 | const props = defineProps({ |
| ... | @@ -152,6 +159,30 @@ function confirm () { | ... | @@ -152,6 +159,30 @@ function confirm () { |
| 152 | }) | 159 | }) |
| 153 | } | 160 | } |
| 154 | 161 | ||
| 162 | const standardCodeTree = ref([]) | ||
| 163 | const treeSelectProps = { | ||
| 164 | label: 'name', | ||
| 165 | value: 'guid', | ||
| 166 | isLeaf: 'isCode' | ||
| 167 | } | ||
| 168 | function getStandardCodeTreeList () { | ||
| 169 | getStandardCodeTree().then((res:any) => { | ||
| 170 | if (res.code === proxy.$passCode) { | ||
| 171 | const data = res.data | ||
| 172 | data.forEach(item => { | ||
| 173 | if (item.children) { | ||
| 174 | item.children.forEach(subItem => { | ||
| 175 | // 二级的标准名字作为key | ||
| 176 | subItem.guid = subItem.name | ||
| 177 | // subItem.value = subItem.name | ||
| 178 | }) | ||
| 179 | } | ||
| 180 | }) | ||
| 181 | standardCodeTree.value = data | ||
| 182 | } | ||
| 183 | }) | ||
| 184 | } | ||
| 185 | |||
| 155 | watch( | 186 | watch( |
| 156 | () => visible.value, | 187 | () => visible.value, |
| 157 | (v) => { | 188 | (v) => { |
| ... | @@ -159,6 +190,10 @@ watch( | ... | @@ -159,6 +190,10 @@ watch( |
| 159 | initForm() | 190 | initForm() |
| 160 | } | 191 | } |
| 161 | ) | 192 | ) |
| 193 | |||
| 194 | onBeforeMount(() => { | ||
| 195 | getStandardCodeTreeList() | ||
| 196 | }) | ||
| 162 | </script> | 197 | </script> |
| 163 | 198 | ||
| 164 | <style lang="scss"> | 199 | <style lang="scss"> | ... | ... |
| ... | @@ -16,7 +16,7 @@ import { getParamsList } from '@/api/modules/dataAsset' | ... | @@ -16,7 +16,7 @@ import { getParamsList } from '@/api/modules/dataAsset' |
| 16 | import { getStandardCodeList, saveStandardCode, | 16 | import { getStandardCodeList, saveStandardCode, |
| 17 | updateStandardCode, getStandardCodeDetail, | 17 | updateStandardCode, getStandardCodeDetail, |
| 18 | deleteStandardCode, getStandardCodeStandard, exportStandardCodeData, | 18 | deleteStandardCode, getStandardCodeStandard, exportStandardCodeData, |
| 19 | getStandardCodeDataList | 19 | getStandardCodeDataList, getStandardCodeTree |
| 20 | } from '@/api/modules/dataMetaService' | 20 | } from '@/api/modules/dataMetaService' |
| 21 | import { | 21 | import { |
| 22 | addDictionary, | 22 | addDictionary, |
| ... | @@ -1440,8 +1440,30 @@ const radioGroupChange = async (val, info) => { | ... | @@ -1440,8 +1440,30 @@ const radioGroupChange = async (val, info) => { |
| 1440 | } | 1440 | } |
| 1441 | } | 1441 | } |
| 1442 | 1442 | ||
| 1443 | function initTree () { | ||
| 1444 | Promise.all([getParamsList({ dictType: '标准类型'}), getStandardCodeTree()]).then((resList:any) => { | ||
| 1445 | let treeRoot = resList[0].data || [] | ||
| 1446 | let treeData = resList[1].data || [] | ||
| 1447 | console.log('treeRoot', treeRoot) | ||
| 1448 | console.log('treeData', treeData) | ||
| 1449 | let tree = treeRoot.map(item => { | ||
| 1450 | let obj:any = {} | ||
| 1451 | obj.treeLevel = 1 | ||
| 1452 | obj.guid = item.value | ||
| 1453 | obj.name = item.label | ||
| 1454 | let target = treeData.find(v => v.guid === item.value) | ||
| 1455 | obj.children = target ? target.children : null | ||
| 1456 | return obj | ||
| 1457 | }) | ||
| 1458 | // standardOptions.value = treeRoot | ||
| 1459 | // treeInfo.value.data = tree | ||
| 1460 | // nodeClick(tree[0]) | ||
| 1461 | }) | ||
| 1462 | } | ||
| 1463 | |||
| 1443 | onBeforeMount(() => { | 1464 | onBeforeMount(() => { |
| 1444 | // getDataType() | 1465 | // getDataType() |
| 1466 | // initTree() | ||
| 1445 | getTreeData().then(() => { | 1467 | getTreeData().then(() => { |
| 1446 | // 默认展开第一个 | 1468 | // 默认展开第一个 |
| 1447 | let data = treeInfo.value.data | 1469 | let data = treeInfo.value.data | ... | ... |
src/views/data_meta/standard-meta-import.vue
0 → 100644
| 1 | <route lang="yaml"> | ||
| 2 | name: standardMetaImport | ||
| 3 | </route> | ||
| 4 | |||
| 5 | <script lang="ts" setup name="standardMetaImport"> | ||
| 6 | import { ref } from "vue"; | ||
| 7 | import { useRoute, useRouter } from "vue-router" | ||
| 8 | import useUserStore from "@/store/modules/user"; | ||
| 9 | import { ElMessage, ElMessageBox } from "element-plus"; | ||
| 10 | import Tabs from '@/components/Tabs/index.vue' | ||
| 11 | import Table from '@/components/Table/index.vue' | ||
| 12 | import Dialog from '@/components/Dialog/index.vue' | ||
| 13 | import useCatchStore from "@/store/modules/catch"; | ||
| 14 | import { download, downFileByBob, downFile } from '@/utils/common' | ||
| 15 | import { | ||
| 16 | addImportData, | ||
| 17 | deleteImportData, | ||
| 18 | getImportData, | ||
| 19 | exportDictionary, | ||
| 20 | exportCollectTask, | ||
| 21 | // getImageContent | ||
| 22 | } from '@/api/modules/queryService'; | ||
| 23 | import { | ||
| 24 | parseAndDecodeUrl, | ||
| 25 | getDownFileSignByUrl, | ||
| 26 | obsDownloadRequest | ||
| 27 | } from '@/api/modules/obsService'; | ||
| 28 | import { | ||
| 29 | getDictionaryTree | ||
| 30 | } from '@/api/modules/dataInventory'; | ||
| 31 | import { commonPageConfig } from '@/utils/enum'; | ||
| 32 | import * as XLSX from 'xlsx'; | ||
| 33 | |||
| 34 | const { proxy } = getCurrentInstance() as any; | ||
| 35 | |||
| 36 | const userStore = useUserStore() | ||
| 37 | const route = useRoute() | ||
| 38 | const router = useRouter() | ||
| 39 | /** 2表示资产目录的。3是主数据; 4是元数据导入 */ | ||
| 40 | const isfileImport = route.query.isfileImport | ||
| 41 | const userData = JSON.parse(userStore.userData) | ||
| 42 | const cacheStore = useCatchStore() | ||
| 43 | const standardSetList = ref([]) | ||
| 44 | const standardSetGuid = ref('') | ||
| 45 | const dictionaryList = ref([]) | ||
| 46 | const dictionaryGuid = ref('') | ||
| 47 | const tabsActiveName = ref('') | ||
| 48 | const uploadSetting: any = ref([]) | ||
| 49 | const importType = ref('') | ||
| 50 | const defaulttabs = [ | ||
| 51 | // { label: '标准集导入', name: 'standard' }, | ||
| 52 | // { label: '字段标准导入', name: 'field' }, | ||
| 53 | // { label: '命名标准导入', name: 'naming' }, | ||
| 54 | { label: '数据字典导入', name: 'dictionary' }, | ||
| 55 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | ||
| 56 | // { label: '质量规则导入', name: 'qualityRule' }, | ||
| 57 | ] | ||
| 58 | const importTabs = [ | ||
| 59 | { label: '导入文件数据', name: 'importFile' }, | ||
| 60 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | ||
| 61 | // { label: '质量规则导入', name: 'qualityRule' }, | ||
| 62 | ] | ||
| 63 | const tabsInfo = ref({ | ||
| 64 | activeName: '', | ||
| 65 | tabs: isfileImport ? importTabs : defaulttabs | ||
| 66 | }) | ||
| 67 | |||
| 68 | const currTableData: any = ref<Object>({}); | ||
| 69 | const page = ref(commonPageConfig); | ||
| 70 | const selectRowData = ref([]) | ||
| 71 | const tableInfo = ref({ | ||
| 72 | id: 'data-source-table', | ||
| 73 | multiple: true, | ||
| 74 | fields: [ | ||
| 75 | { label: "序号", type: "index", width: 56, align: "center" }, | ||
| 76 | { label: "文件名称", field: "fileName", width: 240, }, | ||
| 77 | { label: "状态", field: "importState", type: 'tag', width: 110, align: 'center' }, | ||
| 78 | { label: "导入结果", field: "importMessage", width: 280 }, | ||
| 79 | { label: "导入时间", field: "createTime", width: 180 }, | ||
| 80 | ], | ||
| 81 | data: [], | ||
| 82 | page: { | ||
| 83 | type: "normal", | ||
| 84 | rows: 0, | ||
| 85 | ...page.value, | ||
| 86 | }, | ||
| 87 | actionInfo: { | ||
| 88 | label: "操作", | ||
| 89 | type: "btn", | ||
| 90 | width: 220, | ||
| 91 | fixed: 'right', | ||
| 92 | btns: (scope) => { | ||
| 93 | const row = scope.row | ||
| 94 | let btnsArr = [ | ||
| 95 | { label: '下载文件', value: 'export_file' }, | ||
| 96 | { label: '删除', value: 'delete' } | ||
| 97 | ] | ||
| 98 | if (row.importState != 0 && row.importState != 1) { | ||
| 99 | btnsArr.splice(1, 0, { label: '下载异常数据', value: 'export_abnormal_data' }) | ||
| 100 | } | ||
| 101 | return btnsArr | ||
| 102 | }, | ||
| 103 | }, | ||
| 104 | loading: false | ||
| 105 | }) | ||
| 106 | |||
| 107 | const uploadFiles = ref([]) | ||
| 108 | const uploadSteps: any = ref([]) | ||
| 109 | const uploadInfo = ref({ | ||
| 110 | type: 'upload', | ||
| 111 | title: '', | ||
| 112 | col: '', | ||
| 113 | uploadInfo: { | ||
| 114 | id: 'upload-file-form', | ||
| 115 | type: 'panel', | ||
| 116 | steps: [], | ||
| 117 | extraParams: {dictionaryGuid: 'xx'}, | ||
| 118 | }, | ||
| 119 | }) | ||
| 120 | |||
| 121 | const dialogInfo: any = ref({ | ||
| 122 | visible: false, | ||
| 123 | size: 560, | ||
| 124 | direction: "column", | ||
| 125 | header: { | ||
| 126 | title: "新建", | ||
| 127 | }, | ||
| 128 | type: 'upload', | ||
| 129 | contents: [ | ||
| 130 | uploadInfo.value | ||
| 131 | ], | ||
| 132 | footer: { | ||
| 133 | visible: true, | ||
| 134 | btns: [ | ||
| 135 | { type: "default", label: "取消", value: "cancel" }, | ||
| 136 | { type: "primary", loading: false, label: "开始导入", value: "submit" }, | ||
| 137 | ], | ||
| 138 | }, | ||
| 139 | }) | ||
| 140 | |||
| 141 | // // 获取所有数据字典 | ||
| 142 | const getDictList = () => { | ||
| 143 | const params = { | ||
| 144 | paramCode: '数据字典类型' | ||
| 145 | } | ||
| 146 | getDictionaryTree(params).then((res: any) => { | ||
| 147 | if (res.code == proxy.$passCode) { | ||
| 148 | const data = res.data ?? [] | ||
| 149 | const treeList = data.filter(item => item.children && item.children.length) | ||
| 150 | dictionaryList.value = treeList | ||
| 151 | } else { | ||
| 152 | ElMessage({ | ||
| 153 | type: 'error', | ||
| 154 | message: res.msg, | ||
| 155 | }) | ||
| 156 | } | ||
| 157 | }) | ||
| 158 | } | ||
| 159 | |||
| 160 | const tabsChange = (name) => { | ||
| 161 | tabsActiveName.value = name | ||
| 162 | let info: any = { | ||
| 163 | type: name | ||
| 164 | } | ||
| 165 | if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') { | ||
| 166 | info.standardSetGuid = standardSetGuid.value | ||
| 167 | } else if (tabsActiveName.value == 'dictionary') { | ||
| 168 | info.dictionaryGuid = dictionaryGuid.value | ||
| 169 | } else if (tabsActiveName.value == 'importFile') { | ||
| 170 | |||
| 171 | } | ||
| 172 | cacheStore.setCatch('uploadSetting', info) | ||
| 173 | setUploadInfo() | ||
| 174 | } | ||
| 175 | |||
| 176 | const getFirstPageData = () => { | ||
| 177 | page.value.curr = 1 | ||
| 178 | toSearch({}) | ||
| 179 | |||
| 180 | console.log('store', cacheStore.getCatch('uploadSetting')) | ||
| 181 | } | ||
| 182 | |||
| 183 | const toSearch = (val: any, clear: boolean = false) => { | ||
| 184 | let params: any = Object.keys(val).length ? { ...val } : {} | ||
| 185 | params.pageIndex = page.value.curr; | ||
| 186 | params.pageSize = page.value.limit; | ||
| 187 | params.staffGuid = userData.staffGuid; | ||
| 188 | params.importType = importType.value; | ||
| 189 | |||
| 190 | params.bizGuid = route.query.bizGuid || '' | ||
| 191 | getTableData(params); | ||
| 192 | }; | ||
| 193 | |||
| 194 | const getTableData = (params) => { | ||
| 195 | tableInfo.value.loading = true | ||
| 196 | getImportData(params).then((res: any) => { | ||
| 197 | if (res.code == proxy.$passCode) { | ||
| 198 | const data = res.data || {} | ||
| 199 | tableInfo.value.data = data.records || [] | ||
| 200 | tableInfo.value.page.limit = data.pageSize | ||
| 201 | tableInfo.value.page.curr = data.pageIndex | ||
| 202 | tableInfo.value.page.rows = data.totalRows | ||
| 203 | } else { | ||
| 204 | ElMessage({ | ||
| 205 | type: 'error', | ||
| 206 | message: res.msg, | ||
| 207 | }) | ||
| 208 | } | ||
| 209 | tableInfo.value.loading = false | ||
| 210 | }).catch(xhr => { | ||
| 211 | tableInfo.value.loading = false | ||
| 212 | }) | ||
| 213 | }; | ||
| 214 | |||
| 215 | const tableSelectionChange = (val) => { | ||
| 216 | selectRowData.value = val.map(item => item.guid); | ||
| 217 | }; | ||
| 218 | |||
| 219 | const tablePageChange = (info) => { | ||
| 220 | page.value.curr = Number(info.curr); | ||
| 221 | page.value.limit = Number(info.limit); | ||
| 222 | toSearch({}); | ||
| 223 | }; | ||
| 224 | |||
| 225 | const tableBtnClick = async (scope, btn) => { | ||
| 226 | const type = btn.value; | ||
| 227 | const row = scope.row; | ||
| 228 | currTableData.value = row; | ||
| 229 | if (type == "export_file") { | ||
| 230 | const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.filePath).fileName); | ||
| 231 | if (!refSignInfo?.data) { | ||
| 232 | refSignInfo?.msg && ElMessage.error(refSignInfo?.msg); | ||
| 233 | return; | ||
| 234 | } | ||
| 235 | obsDownloadRequest(refSignInfo?.data).then((res: any) => { | ||
| 236 | if (res && !res.msg) { | ||
| 237 | downFileByBob(res, row.fileName); | ||
| 238 | } else { | ||
| 239 | res?.msg && ElMessage.error(res?.msg); | ||
| 240 | } | ||
| 241 | }); | ||
| 242 | //downFile(row.filePath, row.fileName) | ||
| 243 | } else if (type == 'export_abnormal_data') { | ||
| 244 | //downFile(row.errorFilePath, '') | ||
| 245 | const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.errorFilePath).fileName); | ||
| 246 | if (!refSignInfo?.data) { | ||
| 247 | refSignInfo?.msg && ElMessage.error(refSignInfo?.msg); | ||
| 248 | return; | ||
| 249 | } | ||
| 250 | obsDownloadRequest(refSignInfo?.data).then((res: any) => { | ||
| 251 | if (res && !res.msg) { | ||
| 252 | let name = row.errorFilePath; | ||
| 253 | let fileName = name ? name.substring(name.lastIndexOf('/') + 1) : '' | ||
| 254 | downFileByBob(res, fileName); | ||
| 255 | } else { | ||
| 256 | res?.msg && ElMessage.error(res?.msg); | ||
| 257 | } | ||
| 258 | }); | ||
| 259 | } else if (type == "delete") { | ||
| 260 | open("此操作将永久删除, 是否继续?", "warning"); | ||
| 261 | } | ||
| 262 | }; | ||
| 263 | |||
| 264 | const batching = (type) => { | ||
| 265 | if (type == 'import') { | ||
| 266 | dialogInfo.value.header.title = '导入数据' | ||
| 267 | dialogInfo.value.type = 'upload' | ||
| 268 | dialogInfo.value.size = 560 | ||
| 269 | uploadFiles.value = [] | ||
| 270 | // if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') { | ||
| 271 | // uploadSteps.value[0].selectInfo.options = standardSetList.value | ||
| 272 | // } else if (tabsActiveName.value == 'dictionary') { | ||
| 273 | // uploadSteps.value[0].cascaderInfo.options = dictionaryList.value | ||
| 274 | // } | ||
| 275 | uploadInfo.value.uploadInfo.steps = uploadSteps.value | ||
| 276 | uploadSetting.value.forEach(item => item.value = '') | ||
| 277 | sheetNameList.value = [] | ||
| 278 | const content: any = [uploadInfo.value] | ||
| 279 | dialogInfo.value.contents = content | ||
| 280 | dialogInfo.value.visible = true | ||
| 281 | } else if (type == 'delete') { | ||
| 282 | if (selectRowData.value.length == 0) { | ||
| 283 | ElMessage({ | ||
| 284 | type: 'error', | ||
| 285 | message: '请选择需要删除的数据', | ||
| 286 | }) | ||
| 287 | return | ||
| 288 | } | ||
| 289 | open("此操作将永久删除, 是否继续?", "warning", true); | ||
| 290 | } else if (type === 'importFile') { | ||
| 291 | if (isfileImport == '2' || isfileImport == '4') { | ||
| 292 | dialogInfo.value.header.title = '导入数据' | ||
| 293 | dialogInfo.value.type = 'upload' | ||
| 294 | dialogInfo.value.size = isfileImport == '4' ? 560 : 560; | ||
| 295 | uploadFiles.value = [] | ||
| 296 | uploadInfo.value.uploadInfo.steps = uploadSteps.value | ||
| 297 | const content: any = [uploadInfo.value] | ||
| 298 | dialogInfo.value.contents = content | ||
| 299 | dialogInfo.value.visible = true | ||
| 300 | } else { | ||
| 301 | router.push({ | ||
| 302 | name: "importData", | ||
| 303 | query: route.query | ||
| 304 | }) | ||
| 305 | } | ||
| 306 | } | ||
| 307 | }; | ||
| 308 | |||
| 309 | const open = (msg, type, isBatch = false) => { | ||
| 310 | ElMessageBox.confirm(msg, "提示", { | ||
| 311 | confirmButtonText: "确定", | ||
| 312 | cancelButtonText: "取消", | ||
| 313 | type: type, | ||
| 314 | }).then(() => { | ||
| 315 | let guids = [currTableData.value.guid] | ||
| 316 | if (isBatch) { | ||
| 317 | guids = selectRowData.value | ||
| 318 | } | ||
| 319 | deleteImportData(guids).then((res: any) => { | ||
| 320 | if (res.code == proxy.$passCode) { | ||
| 321 | getFirstPageData(); | ||
| 322 | ElMessage({ | ||
| 323 | type: "success", | ||
| 324 | message: "删除成功", | ||
| 325 | }); | ||
| 326 | } else { | ||
| 327 | ElMessage({ | ||
| 328 | type: "error", | ||
| 329 | message: res.msg, | ||
| 330 | }); | ||
| 331 | } | ||
| 332 | }); | ||
| 333 | }); | ||
| 334 | }; | ||
| 335 | |||
| 336 | const sheetNameList = ref([]) | ||
| 337 | const onUpload = (file, fileList) => { | ||
| 338 | // console.log('file', file) | ||
| 339 | uploadFiles.value = fileList | ||
| 340 | const reader = new FileReader() | ||
| 341 | reader.onload = function (e) { | ||
| 342 | let data = new Uint8Array(e.target.result) | ||
| 343 | let wb = XLSX.read(data, { type: 'array', raw: false, cellDates: true }) | ||
| 344 | console.log('wb', wb) | ||
| 345 | sheetNameList.value = wb.SheetNames | ||
| 346 | } | ||
| 347 | reader.readAsArrayBuffer(file.raw) | ||
| 348 | } | ||
| 349 | |||
| 350 | const uploadBtnClick = (btn) => { | ||
| 351 | exportData() | ||
| 352 | } | ||
| 353 | |||
| 354 | const cascaderChange = (val) => { | ||
| 355 | dictionaryGuid.value = val ? val.at(-1) : '' | ||
| 356 | } | ||
| 357 | |||
| 358 | const selectChange = (val) => { | ||
| 359 | standardSetGuid.value = val | ||
| 360 | } | ||
| 361 | |||
| 362 | const exportData = (ids: any = null) => { | ||
| 363 | if (tabsActiveName.value == 'standard') { | ||
| 364 | const fieldTemplate = "/files/set.xlsx"; | ||
| 365 | downFile(fieldTemplate, '标准集模板.xlsx') | ||
| 366 | } else if (tabsActiveName.value == 'field') { | ||
| 367 | const fieldTemplate = "/files/field.xlsx"; | ||
| 368 | downFile(fieldTemplate, '字段标准模板.xlsx') | ||
| 369 | } else if (tabsActiveName.value == 'naming') { | ||
| 370 | const namingTemplate = "/files/naming.xlsx"; | ||
| 371 | downFile(namingTemplate, '命名标准模板.xlsx') | ||
| 372 | } else if (tabsActiveName.value == 'dictionary') { | ||
| 373 | const params = { | ||
| 374 | guid: dictionaryGuid.value | ||
| 375 | } | ||
| 376 | exportDictionary(params).then((res: any) => { | ||
| 377 | if (res && !res.msg) { | ||
| 378 | download(res, '数据字典模板.xlsx', 'excel'); | ||
| 379 | } else { | ||
| 380 | res?.msg && ElMessage.error(res?.msg); | ||
| 381 | } | ||
| 382 | }); | ||
| 383 | } else if (tabsActiveName.value == 'importFile' && isfileImport == '4') { | ||
| 384 | exportCollectTask({ | ||
| 385 | importTypes: [ | ||
| 386 | "0042" | ||
| 387 | ] | ||
| 388 | }).then((res: any) => { | ||
| 389 | if (res && !res.msg) { | ||
| 390 | download(res, '元数据模板.xlsx', 'excel'); | ||
| 391 | } else { | ||
| 392 | res?.msg && ElMessage.error(res?.msg); | ||
| 393 | } | ||
| 394 | }); | ||
| 395 | } | ||
| 396 | } | ||
| 397 | |||
| 398 | const importData = (info) => { | ||
| 399 | let params = new FormData() | ||
| 400 | if (uploadFiles.value.length == 0) { | ||
| 401 | ElMessage({ | ||
| 402 | type: 'error', | ||
| 403 | message: '请选择上传文件' | ||
| 404 | }) | ||
| 405 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 406 | return | ||
| 407 | } | ||
| 408 | let sheetPass = uploadSetting.value.every(item => item.value) | ||
| 409 | if (!sheetPass) { | ||
| 410 | ElMessage({ type: 'error', message: '请选择sheet页'}) | ||
| 411 | return | ||
| 412 | } | ||
| 413 | let paramUrl = ''; | ||
| 414 | uploadFiles.value.forEach((item: any, index: number) => { | ||
| 415 | params.append("file", item.raw); | ||
| 416 | }); | ||
| 417 | let sheetMaps = {} | ||
| 418 | uploadSetting.value.forEach(item => { | ||
| 419 | sheetMaps[item.value] = item.standardGuid | ||
| 420 | }) | ||
| 421 | sheetMaps = JSON.stringify(sheetMaps) | ||
| 422 | // console.log('sheetMaps', sheetMaps) | ||
| 423 | 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}`) | ||
| 424 | // if (info && Object.keys(info).length) { | ||
| 425 | // paramUrl += `&extendFields=${encodeURIComponent(JSON.stringify(info))}` | ||
| 426 | // } | ||
| 427 | dialogInfo.value.footer.btns[1].loading = true; | ||
| 428 | addImportData(paramUrl, params).then((res: any) => { | ||
| 429 | dialogInfo.value.footer.btns[1].loading = false; | ||
| 430 | if (res.code == proxy.$passCode) { | ||
| 431 | getFirstPageData(); | ||
| 432 | ElMessage({ | ||
| 433 | type: "success", | ||
| 434 | message: '导入成功', | ||
| 435 | }); | ||
| 436 | dialogInfo.value.visible = false; | ||
| 437 | } else { | ||
| 438 | ElMessage({ | ||
| 439 | type: "error", | ||
| 440 | message: res.msg, | ||
| 441 | }); | ||
| 442 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 443 | } | ||
| 444 | }).catch(() => { | ||
| 445 | dialogInfo.value.footer.btns[1].loading = false; | ||
| 446 | }) | ||
| 447 | } | ||
| 448 | |||
| 449 | const dialogBtnClick = (btn, info) => { | ||
| 450 | if (btn.value == 'submit') { | ||
| 451 | // dialogInfo.value.footer.btns.map((item: any) => item.disabled = true) | ||
| 452 | if (dialogInfo.value.type == 'upload') { | ||
| 453 | if (tabsActiveName.value == 'dictionary') { | ||
| 454 | importData({ bizGuid: dictionaryGuid.value }) | ||
| 455 | } else { | ||
| 456 | importData(info) | ||
| 457 | } | ||
| 458 | } | ||
| 459 | } else if (btn.value == 'cancel') { | ||
| 460 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 461 | nextTick(() => { | ||
| 462 | dialogInfo.value.visible = false; | ||
| 463 | }) | ||
| 464 | }; | ||
| 465 | } | ||
| 466 | |||
| 467 | const setUploadInfo = () => { | ||
| 468 | importType.value = '0102' | ||
| 469 | tabsInfo.value.activeName = tabsActiveName.value | ||
| 470 | getFirstPageData() | ||
| 471 | uploadSteps.value = [ | ||
| 472 | { | ||
| 473 | title: '1、选择准备好的文件导入', | ||
| 474 | type: 'btn_upload', | ||
| 475 | uploadInfo: { | ||
| 476 | action: '', | ||
| 477 | auto: false, | ||
| 478 | cover: true, | ||
| 479 | fileList: [], | ||
| 480 | accept: '.xlsx, .xls', | ||
| 481 | tips: '当前支持xls、xlsx文件,支持一个文件多个sheet批量导入' | ||
| 482 | } | ||
| 483 | } | ||
| 484 | ] | ||
| 485 | } | ||
| 486 | |||
| 487 | onActivated(() => { | ||
| 488 | let list = cacheStore.getCatch('uploadSetting') || [] | ||
| 489 | uploadSetting.value = list.map(item => { | ||
| 490 | item.value = null | ||
| 491 | return item | ||
| 492 | }) | ||
| 493 | console.log('uploadSetting', uploadSetting.value) | ||
| 494 | setUploadInfo() | ||
| 495 | }) | ||
| 496 | |||
| 497 | </script> | ||
| 498 | |||
| 499 | <template> | ||
| 500 | <div class="container_wrap"> | ||
| 501 | <!-- <Tabs v-if="!isfileImport" :tabs-info="tabsInfo" @tabChange="tabsChange" /> --> | ||
| 502 | <div class="table_tool_wrap"> | ||
| 503 | <div class="tools_btns"> | ||
| 504 | <el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'" | ||
| 505 | v-preReClick>批量导入</el-button> | ||
| 506 | <el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'" | ||
| 507 | v-preReClick>文件导入</el-button> | ||
| 508 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | ||
| 509 | <el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button> | ||
| 510 | </div> | ||
| 511 | <span class="tips_text">请及时刷新查看最终结果</span> | ||
| 512 | </div> | ||
| 513 | <div class="table_panel_wrap" :style="{ height: !isfileImport ? 'calc(100% - 71px)' : 'calc(100% - 44px)' }"> | ||
| 514 | <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange" | ||
| 515 | @tablePageChange="tablePageChange" /> | ||
| 516 | </div> | ||
| 517 | <Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick" | ||
| 518 | @cascaderChange="cascaderChange" @selectChange="selectChange"> | ||
| 519 | <div style="overflow: auto;"> | ||
| 520 | <div class="title" style="color:#333;margin:20px 0 10px">2、导入前请先导入文件的sheet与标准做对应</div> | ||
| 521 | <el-table :data="uploadSetting" border height="310"> | ||
| 522 | <el-table-column type="index" label="序号" width="55" align="center"/> | ||
| 523 | <el-table-column label="标准名称" prop="standardName"></el-table-column> | ||
| 524 | <el-table-column label="选择sheet页"> | ||
| 525 | <template #default="scope"> | ||
| 526 | <el-select v-model="scope.row.value" placeholder="请选择" style="width:200px" clearable> | ||
| 527 | <el-option v-for="item,i in sheetNameList" :label="item" :value="item" :key="i"></el-option> | ||
| 528 | </el-select> | ||
| 529 | </template> | ||
| 530 | </el-table-column> | ||
| 531 | </el-table> | ||
| 532 | </div> | ||
| 533 | </Dialog> | ||
| 534 | </div> | ||
| 535 | </template> | ||
| 536 | |||
| 537 | <style lang="scss" scoped> | ||
| 538 | .container_wrap { | ||
| 539 | padding: 0; | ||
| 540 | |||
| 541 | :deep(.el-tabs) { | ||
| 542 | |||
| 543 | .el-tabs__header { | ||
| 544 | margin-bottom: 0; | ||
| 545 | } | ||
| 546 | |||
| 547 | .el-tabs__item { | ||
| 548 | height: 32px; | ||
| 549 | |||
| 550 | &:nth-child(2) { | ||
| 551 | padding-left: 16px; | ||
| 552 | } | ||
| 553 | |||
| 554 | &:last-child { | ||
| 555 | padding-right: 16px; | ||
| 556 | } | ||
| 557 | |||
| 558 | &::after { | ||
| 559 | content: ''; | ||
| 560 | width: 100%; | ||
| 561 | height: 2px; | ||
| 562 | background-color: transparent; | ||
| 563 | position: absolute; | ||
| 564 | left: 0; | ||
| 565 | bottom: 0; | ||
| 566 | } | ||
| 567 | |||
| 568 | &.is-active { | ||
| 569 | &::after { | ||
| 570 | background-color: var(--el-color-primary); | ||
| 571 | } | ||
| 572 | } | ||
| 573 | } | ||
| 574 | |||
| 575 | .el-tabs__active-bar { | ||
| 576 | display: none; | ||
| 577 | } | ||
| 578 | } | ||
| 579 | |||
| 580 | .table_tool_wrap { | ||
| 581 | padding: 0 16px; | ||
| 582 | display: flex; | ||
| 583 | align-items: center; | ||
| 584 | |||
| 585 | .tips_text { | ||
| 586 | margin-left: 16px; | ||
| 587 | font-size: 14px; | ||
| 588 | color: #b2b2b2; | ||
| 589 | } | ||
| 590 | } | ||
| 591 | |||
| 592 | .table_panel_wrap { | ||
| 593 | padding: 0 16px; | ||
| 594 | height: calc(100% - 71px); | ||
| 595 | } | ||
| 596 | |||
| 597 | } | ||
| 598 | </style> | ||
| 599 | <style lang="scss"> | ||
| 600 | .upload_panel_wrap .upload_panel .file_panel .file_item .file_btn { | ||
| 601 | word-break: keep-all; | ||
| 602 | } | ||
| 603 | </style> |
| ... | @@ -15,7 +15,7 @@ import { download } from '@/utils/common' | ... | @@ -15,7 +15,7 @@ import { download } from '@/utils/common' |
| 15 | import { getParamsList } from '@/api/modules/dataAsset' | 15 | import { getParamsList } from '@/api/modules/dataAsset' |
| 16 | import { getMetaStandardTree, deleteMetaStandard, | 16 | import { getMetaStandardTree, deleteMetaStandard, |
| 17 | getMetaStandardDataList, getMetaStandardDataFields, | 17 | getMetaStandardDataList, getMetaStandardDataFields, |
| 18 | deleteMetaStandardDataFields | 18 | deleteMetaStandardDataFields, exportMetaStandardData |
| 19 | } from '@/api/modules/dataMetaService' | 19 | } from '@/api/modules/dataMetaService' |
| 20 | import router from '@/router' | 20 | import router from '@/router' |
| 21 | import { TableColumnWidth } from '@/utils/enum'; | 21 | import { TableColumnWidth } from '@/utils/enum'; |
| ... | @@ -52,8 +52,9 @@ const treeInfo = ref({ | ... | @@ -52,8 +52,9 @@ const treeInfo = ref({ |
| 52 | function nodeClick (data) { | 52 | function nodeClick (data) { |
| 53 | console.log('nodeData', data) | 53 | console.log('nodeData', data) |
| 54 | treeInfo.value.currentObj = data | 54 | treeInfo.value.currentObj = data |
| 55 | getFirstPageData() | 55 | if (data.level == 1) return |
| 56 | getTableFields() | 56 | getTableFields() |
| 57 | getFirstPageData() | ||
| 57 | } | 58 | } |
| 58 | function treeCustomClick (node, type) { | 59 | function treeCustomClick (node, type) { |
| 59 | console.log(node, type) | 60 | console.log(node, type) |
| ... | @@ -79,6 +80,7 @@ function getTree () { | ... | @@ -79,6 +80,7 @@ function getTree () { |
| 79 | let data = res.data || [] | 80 | let data = res.data || [] |
| 80 | data.forEach(item => { | 81 | data.forEach(item => { |
| 81 | item.showEdit = true | 82 | item.showEdit = true |
| 83 | item.level = 1 | ||
| 82 | }) | 84 | }) |
| 83 | treeInfo.value.data = data | 85 | treeInfo.value.data = data |
| 84 | treeInfo.value.expandedKey = [data[0].guid] | 86 | treeInfo.value.expandedKey = [data[0].guid] |
| ... | @@ -377,6 +379,40 @@ function openStandardFieldsDialog (type, data = {}) { | ... | @@ -377,6 +379,40 @@ function openStandardFieldsDialog (type, data = {}) { |
| 377 | standardFieldsDialog.visible = true | 379 | standardFieldsDialog.visible = true |
| 378 | } | 380 | } |
| 379 | 381 | ||
| 382 | function importData () { | ||
| 383 | let currentTreeObj:any = treeInfo.value.currentObj | ||
| 384 | console.log('currentTree', currentTreeObj) | ||
| 385 | let uploadSetting:any = [] | ||
| 386 | if (currentTreeObj.children) { | ||
| 387 | uploadSetting = currentTreeObj.children.map((item:any) => { | ||
| 388 | return { | ||
| 389 | standardName: item.standardName, | ||
| 390 | standardGuid: item.guid | ||
| 391 | } | ||
| 392 | }) | ||
| 393 | } else { | ||
| 394 | uploadSetting = [{ | ||
| 395 | standardName: currentTreeObj.standardName, | ||
| 396 | standardGuid: currentTreeObj.guid | ||
| 397 | }] | ||
| 398 | } | ||
| 399 | cacheStore.setCatch('uploadSetting', uploadSetting) | ||
| 400 | router.push({ | ||
| 401 | path: '/data-meta/metadata-standard/standard-meta-import', | ||
| 402 | }); | ||
| 403 | } | ||
| 404 | |||
| 405 | function exportData () { | ||
| 406 | let body = [treeInfo.value.currentObj.guid] | ||
| 407 | exportMetaStandardData(body).then((res:any) => { | ||
| 408 | if (res && !res.msg) { | ||
| 409 | download(res, '元数据标准表.xlsx', 'excel') | ||
| 410 | } else { | ||
| 411 | res?.msg && ElMessage.error(res?.msg); | ||
| 412 | } | ||
| 413 | }) | ||
| 414 | } | ||
| 415 | |||
| 380 | onBeforeMount(() => { | 416 | onBeforeMount(() => { |
| 381 | getTree() | 417 | getTree() |
| 382 | }) | 418 | }) |
| ... | @@ -401,9 +437,9 @@ onBeforeMount(() => { | ... | @@ -401,9 +437,9 @@ onBeforeMount(() => { |
| 401 | <div class="table_tool_wrap"> | 437 | <div class="table_tool_wrap"> |
| 402 | <div class="tools_btns"> | 438 | <div class="tools_btns"> |
| 403 | <el-button type="primary" @click="() => openStandardFieldsDialog('add')" v-preReClick>新建</el-button> | 439 | <el-button type="primary" @click="() => openStandardFieldsDialog('add')" v-preReClick>新建</el-button> |
| 404 | <el-button @click="batching('export')" v-preReClick>导入</el-button> | 440 | <el-button @click="importData" v-preReClick>导入</el-button> |
| 405 | <el-button @click="batching('delete')" v-preReClick>导出</el-button> | 441 | <el-button @click="exportData" v-preReClick>导出</el-button> |
| 406 | <el-button @click="batching('delete')" v-preReClick>查看</el-button> | 442 | <el-button @click="viewGraph" v-preReClick>查看</el-button> |
| 407 | </div> | 443 | </div> |
| 408 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入关键字搜索" | 444 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入关键字搜索" |
| 409 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | 445 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | ... | ... |
-
Please register or sign in to post a comment