Merge branch 'develop' of http://117.78.60.236:8000/csbr-daop/fe-data-asset-management into develop
Showing
5 changed files
with
655 additions
and
51 deletions
| ... | @@ -306,4 +306,10 @@ export const deleteStandardCodeFieldsData = (params) => request({ | ... | @@ -306,4 +306,10 @@ export const deleteStandardCodeFieldsData = (params) => request({ |
| 306 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/remove-data`, | 306 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/remove-data`, |
| 307 | method: 'post', | 307 | method: 'post', |
| 308 | data: params | 308 | data: params |
| 309 | }) | ||
| 310 | /** 元数据-导出 */ | ||
| 311 | export const exportStandardCodeData = (params) => request({ | ||
| 312 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/data-export`, | ||
| 313 | method: 'post', | ||
| 314 | data: params | ||
| 309 | }) | 315 | }) |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -213,6 +213,17 @@ const routes: RouteRecordRaw[] = [ | ... | @@ -213,6 +213,17 @@ const routes: RouteRecordRaw[] = [ |
| 213 | breadcrumb: false, | 213 | breadcrumb: false, |
| 214 | cache: true | 214 | cache: true |
| 215 | } | 215 | } |
| 216 | }, | ||
| 217 | { | ||
| 218 | path: 'standard-import', | ||
| 219 | name: 'metadataStandardImport', | ||
| 220 | component: () => import('@/views/data_meta/standard-import.vue'), | ||
| 221 | meta: { | ||
| 222 | title: '标准代码导入', | ||
| 223 | breadcrumb: false, | ||
| 224 | cache: true, | ||
| 225 | activeMenu: '/data-meta/metadata-standard/standard-codetable' | ||
| 226 | } | ||
| 216 | } | 227 | } |
| 217 | ] | 228 | ] |
| 218 | } | 229 | } | ... | ... |
| ... | @@ -26,6 +26,7 @@ const { proxy } = getCurrentInstance() as any; | ... | @@ -26,6 +26,7 @@ const { proxy } = getCurrentInstance() as any; |
| 26 | 26 | ||
| 27 | const cacheStore = useCatchStore() | 27 | const cacheStore = useCatchStore() |
| 28 | const standardGuid = ref("") | 28 | const standardGuid = ref("") |
| 29 | const standardName = ref('') | ||
| 29 | const tableSearchInput = ref('') | 30 | const tableSearchInput = ref('') |
| 30 | const tableFields: any = ref([]) | 31 | const tableFields: any = ref([]) |
| 31 | const orginData: any = ref([]) | 32 | const orginData: any = ref([]) |
| ... | @@ -156,19 +157,17 @@ const tablePageChange = (info) => { | ... | @@ -156,19 +157,17 @@ const tablePageChange = (info) => { |
| 156 | }; | 157 | }; |
| 157 | 158 | ||
| 158 | const toolBtnClick = (btn) => { | 159 | const toolBtnClick = (btn) => { |
| 159 | console.log('btnType', btn) | ||
| 160 | const type = btn.value | 160 | const type = btn.value |
| 161 | if (type == 'export') { | 161 | if (type == 'export') { |
| 162 | exportData() | 162 | exportData() |
| 163 | } else if (type == 'import') { | 163 | } else if (type == 'import') { |
| 164 | const info = { | 164 | const info = [ |
| 165 | type: 'dictionary', | 165 | { standardGuid: standardGuid.value, standardName: standardName.value } |
| 166 | standardGuid: standardGuid.value | 166 | ] |
| 167 | } | ||
| 168 | cacheStore.setCatch('uploadSetting', info) | 167 | cacheStore.setCatch('uploadSetting', info) |
| 169 | nextTick(() => { | 168 | nextTick(() => { |
| 170 | router.push({ | 169 | router.push({ |
| 171 | path: '/data-inventory/data-dictionary/import-file', | 170 | path: '/data-meta/metadata-standard/standard-import', |
| 172 | }); | 171 | }); |
| 173 | }) | 172 | }) |
| 174 | } else if (type == 'submit') { | 173 | } else if (type == 'submit') { |
| ... | @@ -537,6 +536,7 @@ const dialogBtnClick = (btn, info) => { | ... | @@ -537,6 +536,7 @@ const dialogBtnClick = (btn, info) => { |
| 537 | 536 | ||
| 538 | defineExpose({ | 537 | defineExpose({ |
| 539 | standardGuid, | 538 | standardGuid, |
| 539 | standardName, | ||
| 540 | getFirstPageData, | 540 | getFirstPageData, |
| 541 | checkSave | 541 | checkSave |
| 542 | }); | 542 | }); | ... | ... |
| ... | @@ -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 { getStandardCodeList, saveStandardCode, | 16 | import { getStandardCodeList, saveStandardCode, |
| 17 | updateStandardCode, getStandardCodeDetail, | 17 | updateStandardCode, getStandardCodeDetail, |
| 18 | deleteStandardCode, getStandardCodeStandard | 18 | deleteStandardCode, getStandardCodeStandard, exportStandardCodeData |
| 19 | } from '@/api/modules/dataMetaService' | 19 | } from '@/api/modules/dataMetaService' |
| 20 | import { | 20 | import { |
| 21 | addDictionary, | 21 | addDictionary, |
| ... | @@ -38,6 +38,7 @@ import { | ... | @@ -38,6 +38,7 @@ import { |
| 38 | checkDictionaryData, | 38 | checkDictionaryData, |
| 39 | getNewDataTypeList | 39 | getNewDataTypeList |
| 40 | } from '@/api/modules/dataInventory'; | 40 | } from '@/api/modules/dataInventory'; |
| 41 | import router from '@/router' | ||
| 41 | 42 | ||
| 42 | const { proxy } = getCurrentInstance() as any; | 43 | const { proxy } = getCurrentInstance() as any; |
| 43 | 44 | ||
| ... | @@ -103,6 +104,7 @@ const page = ref({ | ... | @@ -103,6 +104,7 @@ const page = ref({ |
| 103 | ], | 104 | ], |
| 104 | }); | 105 | }); |
| 105 | const selectRowData = ref([]) | 106 | const selectRowData = ref([]) |
| 107 | const selectedRowData = ref([]) | ||
| 106 | const tableInfo: any = ref({ | 108 | const tableInfo: any = ref({ |
| 107 | id: 'data-source-table', | 109 | id: 'data-source-table', |
| 108 | multiple: true, | 110 | multiple: true, |
| ... | @@ -140,6 +142,7 @@ const orginOptions = [ | ... | @@ -140,6 +142,7 @@ const orginOptions = [ |
| 140 | { label: 'code', value: 'code' }, | 142 | { label: 'code', value: 'code' }, |
| 141 | { label: 'name', value: 'name' }, | 143 | { label: 'name', value: 'name' }, |
| 142 | ] | 144 | ] |
| 145 | let codeOptions = ref([]) | ||
| 143 | const orginItems = [ | 146 | const orginItems = [ |
| 144 | { | 147 | { |
| 145 | label: '标准类型', | 148 | label: '标准类型', |
| ... | @@ -306,18 +309,17 @@ const formItems: any = ref([ | ... | @@ -306,18 +309,17 @@ const formItems: any = ref([ |
| 306 | required: true | 309 | required: true |
| 307 | }, | 310 | }, |
| 308 | { | 311 | { |
| 309 | label: '编码字段', | 312 | label: '编码字段11', |
| 310 | type: 'select', | 313 | type: 'select', |
| 311 | placeholder: '请选择', | 314 | placeholder: '请选择', |
| 312 | field: 'codeFields', | 315 | field: 'codeFields', |
| 313 | default: [], | 316 | default: [], |
| 314 | options: [ | 317 | options: codeOptions, |
| 315 | { label: 'code', value: 'code' }, | ||
| 316 | { label: 'name', value: 'name' } | ||
| 317 | ], | ||
| 318 | clearable: true, | 318 | clearable: true, |
| 319 | required: true, | 319 | required: true, |
| 320 | multiple: true | 320 | multiple: true, |
| 321 | tagsTooltip: true, | ||
| 322 | filterable: true, | ||
| 321 | }, | 323 | }, |
| 322 | { | 324 | { |
| 323 | label: '编码名称', | 325 | label: '编码名称', |
| ... | @@ -325,10 +327,7 @@ const formItems: any = ref([ | ... | @@ -325,10 +327,7 @@ const formItems: any = ref([ |
| 325 | placeholder: '请选择', | 327 | placeholder: '请选择', |
| 326 | field: 'codeFieldName', | 328 | field: 'codeFieldName', |
| 327 | default: '', | 329 | default: '', |
| 328 | options: [ | 330 | options: codeOptions, |
| 329 | { label: 'code', value: 'code' }, | ||
| 330 | { label: 'name', value: 'name' } | ||
| 331 | ], | ||
| 332 | clearable: true, | 331 | clearable: true, |
| 333 | required: true | 332 | required: true |
| 334 | }, | 333 | }, |
| ... | @@ -566,7 +565,7 @@ const drawerInfo: any = ref({ | ... | @@ -566,7 +565,7 @@ const drawerInfo: any = ref({ |
| 566 | btns: [ | 565 | btns: [ |
| 567 | { type: 'default', label: '取消', value: 'cancel' }, | 566 | { type: 'default', label: '取消', value: 'cancel' }, |
| 568 | { type: 'primary', label: '保存', value: 'submit' }, | 567 | { type: 'primary', label: '保存', value: 'submit' }, |
| 569 | { type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true }, | 568 | { type: 'primary', label: '保存并添加数据', value: 'submit', visible: true }, |
| 570 | ] | 569 | ] |
| 571 | }, | 570 | }, |
| 572 | }) | 571 | }) |
| ... | @@ -759,6 +758,7 @@ const tableSelectionChange = (val, tId) => { | ... | @@ -759,6 +758,7 @@ const tableSelectionChange = (val, tId) => { |
| 759 | } | 758 | } |
| 760 | } else { | 759 | } else { |
| 761 | selectRowData.value = val.map((item) => item.guid); | 760 | selectRowData.value = val.map((item) => item.guid); |
| 761 | selectedRowData.value = val | ||
| 762 | } | 762 | } |
| 763 | }; | 763 | }; |
| 764 | 764 | ||
| ... | @@ -789,11 +789,7 @@ const setCodeOptions = () => { | ... | @@ -789,11 +789,7 @@ const setCodeOptions = () => { |
| 789 | opts.push(row) | 789 | opts.push(row) |
| 790 | } | 790 | } |
| 791 | }) | 791 | }) |
| 792 | formItems.value.at(-1).children.map(child => { | 792 | codeOptions.value = opts |
| 793 | if (child.type == 'select') { | ||
| 794 | child.options = opts | ||
| 795 | } | ||
| 796 | }) | ||
| 797 | } | 793 | } |
| 798 | 794 | ||
| 799 | const toolBtnClick = (btn, data) => { | 795 | const toolBtnClick = (btn, data) => { |
| ... | @@ -1084,32 +1080,15 @@ const uploadFile = (file) => { | ... | @@ -1084,32 +1080,15 @@ const uploadFile = (file) => { |
| 1084 | } | 1080 | } |
| 1085 | 1081 | ||
| 1086 | const exportData = (type: any = null) => { | 1082 | const exportData = (type: any = null) => { |
| 1087 | if (type == 'model') { | 1083 | let body = [treeCurrentNodeKey.value] |
| 1088 | let params = { | 1084 | exportStandardCodeData(body).then((res:any) => { |
| 1089 | guid: dictGuid.value | 1085 | if (res && !res.msg) { |
| 1090 | } | 1086 | download(res, '标准代码表.xlsx', 'excel') |
| 1091 | if (drawerInfo.value.type == 'add') { | 1087 | } else { |
| 1092 | params.guid = fieldSheetInfo.value.guid | 1088 | res?.msg && ElMessage.error(res?.msg); |
| 1093 | } | ||
| 1094 | exportDictionary(params).then((res: any) => { | ||
| 1095 | if (res && !res.msg) { | ||
| 1096 | download(res, '数据字典模板.xlsx', 'excel') | ||
| 1097 | } else { | ||
| 1098 | res?.msg && ElMessage.error(res?.msg); | ||
| 1099 | } | ||
| 1100 | }); | ||
| 1101 | } else { | ||
| 1102 | let params = { | ||
| 1103 | guid: dictGuid.value | ||
| 1104 | } | 1089 | } |
| 1105 | exportDictionaryFileds(params).then((res: any) => { | 1090 | }) |
| 1106 | if (res && !res.msg) { | 1091 | return |
| 1107 | download(res, '字典数据.xlsx', 'excel'); | ||
| 1108 | } else { | ||
| 1109 | res?.msg && ElMessage.error(res?.msg); | ||
| 1110 | } | ||
| 1111 | }); | ||
| 1112 | } | ||
| 1113 | } | 1092 | } |
| 1114 | 1093 | ||
| 1115 | const importData = (file: any = null) => { | 1094 | const importData = (file: any = null) => { |
| ... | @@ -1222,9 +1201,10 @@ const loadDrawer = async () => { | ... | @@ -1222,9 +1201,10 @@ const loadDrawer = async () => { |
| 1222 | drawerInfo.value.visible = true | 1201 | drawerInfo.value.visible = true |
| 1223 | console.log('table', formTable.value) | 1202 | console.log('table', formTable.value) |
| 1224 | console.log('formInfo', formInfo) | 1203 | console.log('formInfo', formInfo) |
| 1225 | 1204 | setCodeOptions() | |
| 1226 | }; | 1205 | }; |
| 1227 | 1206 | ||
| 1207 | const treeCurrentNodeKey = ref('') | ||
| 1228 | const batching = (type) => { | 1208 | const batching = (type) => { |
| 1229 | if (type == 'delete') { | 1209 | if (type == 'delete') { |
| 1230 | if (selectRowData.value.length == 0) { | 1210 | if (selectRowData.value.length == 0) { |
| ... | @@ -1238,6 +1218,26 @@ const batching = (type) => { | ... | @@ -1238,6 +1218,26 @@ const batching = (type) => { |
| 1238 | open("此操作将永久删除, 是否继续?", "warning", true); | 1218 | open("此操作将永久删除, 是否继续?", "warning", true); |
| 1239 | tableInfo.value.loading = false | 1219 | tableInfo.value.loading = false |
| 1240 | } | 1220 | } |
| 1221 | if (type == 'export') { | ||
| 1222 | if (selectRowData.value.length == 0) { | ||
| 1223 | ElMessage({ | ||
| 1224 | type: 'error', | ||
| 1225 | message: '请选择代码名称', | ||
| 1226 | }) | ||
| 1227 | return | ||
| 1228 | } | ||
| 1229 | // console.log(selectedRowData) | ||
| 1230 | let uploadSetting = selectedRowData.value.map(item => { | ||
| 1231 | return { | ||
| 1232 | standardName: item.codeName, | ||
| 1233 | standardGuid: item.guid | ||
| 1234 | } | ||
| 1235 | }) | ||
| 1236 | cacheStore.setCatch('uploadSetting', uploadSetting) | ||
| 1237 | router.push({ | ||
| 1238 | path: '/data-meta/metadata-standard/standard-import', | ||
| 1239 | }); | ||
| 1240 | } | ||
| 1241 | }; | 1241 | }; |
| 1242 | 1242 | ||
| 1243 | const nodeClick = (data) => { | 1243 | const nodeClick = (data) => { |
| ... | @@ -1251,6 +1251,8 @@ const nodeClick = (data) => { | ... | @@ -1251,6 +1251,8 @@ const nodeClick = (data) => { |
| 1251 | showFiledsPage.value = true | 1251 | showFiledsPage.value = true |
| 1252 | nextTick(() => { | 1252 | nextTick(() => { |
| 1253 | dictFiledsRef.value.standardGuid = data.value | 1253 | dictFiledsRef.value.standardGuid = data.value |
| 1254 | dictFiledsRef.value.standardName = data.label | ||
| 1255 | treeCurrentNodeKey.value = data.value | ||
| 1254 | dictFiledsRef.value.getFirstPageData() | 1256 | dictFiledsRef.value.getFirstPageData() |
| 1255 | }) | 1257 | }) |
| 1256 | } else { | 1258 | } else { |
| ... | @@ -1354,6 +1356,7 @@ const setDetailInfo = () => { | ... | @@ -1354,6 +1356,7 @@ const setDetailInfo = () => { |
| 1354 | drawerInfo.value.container.contents = contents.value['add'] | 1356 | drawerInfo.value.container.contents = contents.value['add'] |
| 1355 | 1357 | ||
| 1356 | drawerInfo.value.visible = true | 1358 | drawerInfo.value.visible = true |
| 1359 | setCodeOptions() | ||
| 1357 | } | 1360 | } |
| 1358 | 1361 | ||
| 1359 | const saveData = async (params) => { | 1362 | const saveData = async (params) => { |
| ... | @@ -1367,7 +1370,7 @@ const saveData = async (params) => { | ... | @@ -1367,7 +1370,7 @@ const saveData = async (params) => { |
| 1367 | drawerInfo.value.visible = false | 1370 | drawerInfo.value.visible = false |
| 1368 | } | 1371 | } |
| 1369 | }).finally(() => { | 1372 | }).finally(() => { |
| 1370 | drawerInfo.value.footer.btns.map((item: any) => item.disabled = true) | 1373 | drawerInfo.value.footer.btns.map((item: any) => item.disabled = false) |
| 1371 | }) | 1374 | }) |
| 1372 | } | 1375 | } |
| 1373 | 1376 | ||
| ... | @@ -1495,7 +1498,7 @@ onMounted(() => { | ... | @@ -1495,7 +1498,7 @@ onMounted(() => { |
| 1495 | <template> | 1498 | <template> |
| 1496 | <div class="container_wrap full flex"> | 1499 | <div class="container_wrap full flex"> |
| 1497 | <div class="aside_wrap"> | 1500 | <div class="aside_wrap"> |
| 1498 | <div class="aside_title">数据字典列表</div> | 1501 | <div class="aside_title">标准代码列表</div> |
| 1499 | <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" @loadNode="loadTreeNode"/> | 1502 | <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" @loadNode="loadTreeNode"/> |
| 1500 | </div> | 1503 | </div> |
| 1501 | <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> | 1504 | <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> |
| ... | @@ -1504,6 +1507,7 @@ onMounted(() => { | ... | @@ -1504,6 +1507,7 @@ onMounted(() => { |
| 1504 | <div class="tools_btns"> | 1507 | <div class="tools_btns"> |
| 1505 | <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button> | 1508 | <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button> |
| 1506 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | 1509 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> |
| 1510 | <el-button @click="batching('export')" v-preReClick>批量导入</el-button> | ||
| 1507 | </div> | 1511 | </div> |
| 1508 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入代码名称搜索" | 1512 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入代码名称搜索" |
| 1509 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | 1513 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | ... | ... |
src/views/data_meta/standard-import.vue
0 → 100644
| 1 | <route lang="yaml"> | ||
| 2 | name: importFile | ||
| 3 | </route> | ||
| 4 | |||
| 5 | <script lang="ts" setup name="importFile"> | ||
| 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 | |||
| 33 | const { proxy } = getCurrentInstance() as any; | ||
| 34 | |||
| 35 | const userStore = useUserStore() | ||
| 36 | const route = useRoute() | ||
| 37 | const router = useRouter() | ||
| 38 | /** 2表示资产目录的。3是主数据; 4是元数据导入 */ | ||
| 39 | const isfileImport = route.query.isfileImport | ||
| 40 | const userData = JSON.parse(userStore.userData) | ||
| 41 | const cacheStore = useCatchStore() | ||
| 42 | const standardSetList = ref([]) | ||
| 43 | const standardSetGuid = ref('') | ||
| 44 | const dictionaryList = ref([]) | ||
| 45 | const dictionaryGuid = ref('') | ||
| 46 | const tabsActiveName = ref('') | ||
| 47 | const uploadSetting: any = ref([]) | ||
| 48 | const importType = ref('') | ||
| 49 | const defaulttabs = [ | ||
| 50 | // { label: '标准集导入', name: 'standard' }, | ||
| 51 | // { label: '字段标准导入', name: 'field' }, | ||
| 52 | // { label: '命名标准导入', name: 'naming' }, | ||
| 53 | { label: '数据字典导入', name: 'dictionary' }, | ||
| 54 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | ||
| 55 | // { label: '质量规则导入', name: 'qualityRule' }, | ||
| 56 | ] | ||
| 57 | const importTabs = [ | ||
| 58 | { label: '导入文件数据', name: 'importFile' }, | ||
| 59 | // { label: '质量模型导入', name: 'qualityModelGroup' }, | ||
| 60 | // { label: '质量规则导入', name: 'qualityRule' }, | ||
| 61 | ] | ||
| 62 | const tabsInfo = ref({ | ||
| 63 | activeName: '', | ||
| 64 | tabs: isfileImport ? importTabs : defaulttabs | ||
| 65 | }) | ||
| 66 | |||
| 67 | const currTableData: any = ref<Object>({}); | ||
| 68 | const page = ref(commonPageConfig); | ||
| 69 | const selectRowData = ref([]) | ||
| 70 | const tableInfo = ref({ | ||
| 71 | id: 'data-source-table', | ||
| 72 | multiple: true, | ||
| 73 | fields: [ | ||
| 74 | { label: "序号", type: "index", width: 56, align: "center" }, | ||
| 75 | { label: "文件名称", field: "fileName", width: 240, }, | ||
| 76 | { label: "状态", field: "importState", type: 'tag', width: 110, align: 'center' }, | ||
| 77 | { label: "导入结果", field: "importMessage", width: 280 }, | ||
| 78 | { label: "导入时间", field: "createTime", width: 180 }, | ||
| 79 | ], | ||
| 80 | data: [], | ||
| 81 | page: { | ||
| 82 | type: "normal", | ||
| 83 | rows: 0, | ||
| 84 | ...page.value, | ||
| 85 | }, | ||
| 86 | actionInfo: { | ||
| 87 | label: "操作", | ||
| 88 | type: "btn", | ||
| 89 | width: 220, | ||
| 90 | fixed: 'right', | ||
| 91 | btns: (scope) => { | ||
| 92 | const row = scope.row | ||
| 93 | let btnsArr = [ | ||
| 94 | { label: '下载文件', value: 'export_file' }, | ||
| 95 | { label: '删除', value: 'delete' } | ||
| 96 | ] | ||
| 97 | if (row.importState != 0 && row.importState != 1) { | ||
| 98 | btnsArr.splice(1, 0, { label: '下载异常数据', value: 'export_abnormal_data' }) | ||
| 99 | } | ||
| 100 | return btnsArr | ||
| 101 | }, | ||
| 102 | }, | ||
| 103 | loading: false | ||
| 104 | }) | ||
| 105 | |||
| 106 | const uploadFiles = ref([]) | ||
| 107 | const uploadSteps: any = ref([]) | ||
| 108 | const uploadInfo = ref({ | ||
| 109 | type: 'upload', | ||
| 110 | title: '', | ||
| 111 | col: '', | ||
| 112 | uploadInfo: { | ||
| 113 | id: 'upload-file-form', | ||
| 114 | type: 'panel', | ||
| 115 | steps: [], | ||
| 116 | extraParams: {dictionaryGuid: 'xx'}, | ||
| 117 | }, | ||
| 118 | }) | ||
| 119 | |||
| 120 | const dialogInfo: any = ref({ | ||
| 121 | visible: false, | ||
| 122 | size: 700, | ||
| 123 | direction: "column", | ||
| 124 | header: { | ||
| 125 | title: "新建", | ||
| 126 | }, | ||
| 127 | type: 'upload', | ||
| 128 | contents: [ | ||
| 129 | uploadInfo.value | ||
| 130 | ], | ||
| 131 | footer: { | ||
| 132 | visible: true, | ||
| 133 | btns: [ | ||
| 134 | { type: "default", label: "取消", value: "cancel" }, | ||
| 135 | { type: "primary", loading: false, label: "开始导入", value: "submit" }, | ||
| 136 | ], | ||
| 137 | }, | ||
| 138 | }) | ||
| 139 | |||
| 140 | // // 获取所有数据字典 | ||
| 141 | const getDictList = () => { | ||
| 142 | const params = { | ||
| 143 | paramCode: '数据字典类型' | ||
| 144 | } | ||
| 145 | getDictionaryTree(params).then((res: any) => { | ||
| 146 | if (res.code == proxy.$passCode) { | ||
| 147 | const data = res.data ?? [] | ||
| 148 | const treeList = data.filter(item => item.children && item.children.length) | ||
| 149 | dictionaryList.value = treeList | ||
| 150 | } else { | ||
| 151 | ElMessage({ | ||
| 152 | type: 'error', | ||
| 153 | message: res.msg, | ||
| 154 | }) | ||
| 155 | } | ||
| 156 | }) | ||
| 157 | } | ||
| 158 | |||
| 159 | const tabsChange = (name) => { | ||
| 160 | tabsActiveName.value = name | ||
| 161 | let info: any = { | ||
| 162 | type: name | ||
| 163 | } | ||
| 164 | if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') { | ||
| 165 | info.standardSetGuid = standardSetGuid.value | ||
| 166 | } else if (tabsActiveName.value == 'dictionary') { | ||
| 167 | info.dictionaryGuid = dictionaryGuid.value | ||
| 168 | } else if (tabsActiveName.value == 'importFile') { | ||
| 169 | |||
| 170 | } | ||
| 171 | cacheStore.setCatch('uploadSetting', info) | ||
| 172 | setUploadInfo() | ||
| 173 | } | ||
| 174 | |||
| 175 | const getFirstPageData = () => { | ||
| 176 | page.value.curr = 1 | ||
| 177 | toSearch({}) | ||
| 178 | |||
| 179 | console.log('store', cacheStore.getCatch('uploadSetting')) | ||
| 180 | } | ||
| 181 | |||
| 182 | const toSearch = (val: any, clear: boolean = false) => { | ||
| 183 | let params: any = Object.keys(val).length ? { ...val } : {} | ||
| 184 | params.pageIndex = page.value.curr; | ||
| 185 | params.pageSize = page.value.limit; | ||
| 186 | params.staffGuid = userData.staffGuid; | ||
| 187 | params.importType = importType.value; | ||
| 188 | |||
| 189 | params.bizGuid = route.query.bizGuid || '' | ||
| 190 | getTableData(params); | ||
| 191 | }; | ||
| 192 | |||
| 193 | const getTableData = (params) => { | ||
| 194 | tableInfo.value.loading = true | ||
| 195 | getImportData(params).then((res: any) => { | ||
| 196 | if (res.code == proxy.$passCode) { | ||
| 197 | const data = res.data || {} | ||
| 198 | tableInfo.value.data = data.records || [] | ||
| 199 | tableInfo.value.page.limit = data.pageSize | ||
| 200 | tableInfo.value.page.curr = data.pageIndex | ||
| 201 | tableInfo.value.page.rows = data.totalRows | ||
| 202 | } else { | ||
| 203 | ElMessage({ | ||
| 204 | type: 'error', | ||
| 205 | message: res.msg, | ||
| 206 | }) | ||
| 207 | } | ||
| 208 | tableInfo.value.loading = false | ||
| 209 | }).catch(xhr => { | ||
| 210 | tableInfo.value.loading = false | ||
| 211 | }) | ||
| 212 | }; | ||
| 213 | |||
| 214 | const tableSelectionChange = (val) => { | ||
| 215 | selectRowData.value = val.map(item => item.guid); | ||
| 216 | }; | ||
| 217 | |||
| 218 | const tablePageChange = (info) => { | ||
| 219 | page.value.curr = Number(info.curr); | ||
| 220 | page.value.limit = Number(info.limit); | ||
| 221 | toSearch({}); | ||
| 222 | }; | ||
| 223 | |||
| 224 | const tableBtnClick = async (scope, btn) => { | ||
| 225 | const type = btn.value; | ||
| 226 | const row = scope.row; | ||
| 227 | currTableData.value = row; | ||
| 228 | if (type == "export_file") { | ||
| 229 | const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.filePath).fileName); | ||
| 230 | if (!refSignInfo?.data) { | ||
| 231 | refSignInfo?.msg && ElMessage.error(refSignInfo?.msg); | ||
| 232 | return; | ||
| 233 | } | ||
| 234 | obsDownloadRequest(refSignInfo?.data).then((res: any) => { | ||
| 235 | if (res && !res.msg) { | ||
| 236 | downFileByBob(res, row.fileName); | ||
| 237 | } else { | ||
| 238 | res?.msg && ElMessage.error(res?.msg); | ||
| 239 | } | ||
| 240 | }); | ||
| 241 | //downFile(row.filePath, row.fileName) | ||
| 242 | } else if (type == 'export_abnormal_data') { | ||
| 243 | //downFile(row.errorFilePath, '') | ||
| 244 | const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(row.errorFilePath).fileName); | ||
| 245 | if (!refSignInfo?.data) { | ||
| 246 | refSignInfo?.msg && ElMessage.error(refSignInfo?.msg); | ||
| 247 | return; | ||
| 248 | } | ||
| 249 | obsDownloadRequest(refSignInfo?.data).then((res: any) => { | ||
| 250 | if (res && !res.msg) { | ||
| 251 | let name = row.errorFilePath; | ||
| 252 | let fileName = name ? name.substring(name.lastIndexOf('/') + 1) : '' | ||
| 253 | downFileByBob(res, fileName); | ||
| 254 | } else { | ||
| 255 | res?.msg && ElMessage.error(res?.msg); | ||
| 256 | } | ||
| 257 | }); | ||
| 258 | } else if (type == "delete") { | ||
| 259 | open("此操作将永久删除, 是否继续?", "warning"); | ||
| 260 | } | ||
| 261 | }; | ||
| 262 | |||
| 263 | const batching = (type) => { | ||
| 264 | if (type == 'import') { | ||
| 265 | dialogInfo.value.header.title = '导入数据' | ||
| 266 | dialogInfo.value.type = 'upload' | ||
| 267 | dialogInfo.value.size = 640 | ||
| 268 | uploadFiles.value = [] | ||
| 269 | // if (tabsActiveName.value == 'field' || tabsActiveName.value == 'naming') { | ||
| 270 | // uploadSteps.value[0].selectInfo.options = standardSetList.value | ||
| 271 | // } else if (tabsActiveName.value == 'dictionary') { | ||
| 272 | // uploadSteps.value[0].cascaderInfo.options = dictionaryList.value | ||
| 273 | // } | ||
| 274 | uploadInfo.value.uploadInfo.steps = uploadSteps.value | ||
| 275 | const content: any = [uploadInfo.value] | ||
| 276 | dialogInfo.value.contents = content | ||
| 277 | dialogInfo.value.visible = true | ||
| 278 | } else if (type == 'delete') { | ||
| 279 | if (selectRowData.value.length == 0) { | ||
| 280 | ElMessage({ | ||
| 281 | type: 'error', | ||
| 282 | message: '请选择需要删除的数据', | ||
| 283 | }) | ||
| 284 | return | ||
| 285 | } | ||
| 286 | open("此操作将永久删除, 是否继续?", "warning", true); | ||
| 287 | } else if (type === 'importFile') { | ||
| 288 | if (isfileImport == '2' || isfileImport == '4') { | ||
| 289 | dialogInfo.value.header.title = '导入数据' | ||
| 290 | dialogInfo.value.type = 'upload' | ||
| 291 | dialogInfo.value.size = isfileImport == '4' ? 600 : 500; | ||
| 292 | uploadFiles.value = [] | ||
| 293 | uploadInfo.value.uploadInfo.steps = uploadSteps.value | ||
| 294 | const content: any = [uploadInfo.value] | ||
| 295 | dialogInfo.value.contents = content | ||
| 296 | dialogInfo.value.visible = true | ||
| 297 | } else { | ||
| 298 | router.push({ | ||
| 299 | name: "importData", | ||
| 300 | query: route.query | ||
| 301 | }) | ||
| 302 | } | ||
| 303 | } | ||
| 304 | }; | ||
| 305 | |||
| 306 | const open = (msg, type, isBatch = false) => { | ||
| 307 | ElMessageBox.confirm(msg, "提示", { | ||
| 308 | confirmButtonText: "确定", | ||
| 309 | cancelButtonText: "取消", | ||
| 310 | type: type, | ||
| 311 | }).then(() => { | ||
| 312 | let guids = [currTableData.value.guid] | ||
| 313 | if (isBatch) { | ||
| 314 | guids = selectRowData.value | ||
| 315 | } | ||
| 316 | deleteImportData(guids).then((res: any) => { | ||
| 317 | if (res.code == proxy.$passCode) { | ||
| 318 | getFirstPageData(); | ||
| 319 | ElMessage({ | ||
| 320 | type: "success", | ||
| 321 | message: "删除成功", | ||
| 322 | }); | ||
| 323 | } else { | ||
| 324 | ElMessage({ | ||
| 325 | type: "error", | ||
| 326 | message: res.msg, | ||
| 327 | }); | ||
| 328 | } | ||
| 329 | }); | ||
| 330 | }); | ||
| 331 | }; | ||
| 332 | |||
| 333 | const onUpload = (file, fileList) => { | ||
| 334 | uploadFiles.value = fileList | ||
| 335 | } | ||
| 336 | |||
| 337 | const uploadBtnClick = (btn) => { | ||
| 338 | exportData() | ||
| 339 | } | ||
| 340 | |||
| 341 | const cascaderChange = (val) => { | ||
| 342 | dictionaryGuid.value = val ? val.at(-1) : '' | ||
| 343 | } | ||
| 344 | |||
| 345 | const selectChange = (val) => { | ||
| 346 | standardSetGuid.value = val | ||
| 347 | } | ||
| 348 | |||
| 349 | const exportData = (ids: any = null) => { | ||
| 350 | if (tabsActiveName.value == 'standard') { | ||
| 351 | const fieldTemplate = "/files/set.xlsx"; | ||
| 352 | downFile(fieldTemplate, '标准集模板.xlsx') | ||
| 353 | } else if (tabsActiveName.value == 'field') { | ||
| 354 | const fieldTemplate = "/files/field.xlsx"; | ||
| 355 | downFile(fieldTemplate, '字段标准模板.xlsx') | ||
| 356 | } else if (tabsActiveName.value == 'naming') { | ||
| 357 | const namingTemplate = "/files/naming.xlsx"; | ||
| 358 | downFile(namingTemplate, '命名标准模板.xlsx') | ||
| 359 | } else if (tabsActiveName.value == 'dictionary') { | ||
| 360 | const params = { | ||
| 361 | guid: dictionaryGuid.value | ||
| 362 | } | ||
| 363 | exportDictionary(params).then((res: any) => { | ||
| 364 | if (res && !res.msg) { | ||
| 365 | download(res, '数据字典模板.xlsx', 'excel'); | ||
| 366 | } else { | ||
| 367 | res?.msg && ElMessage.error(res?.msg); | ||
| 368 | } | ||
| 369 | }); | ||
| 370 | } else if (tabsActiveName.value == 'importFile' && isfileImport == '4') { | ||
| 371 | exportCollectTask({ | ||
| 372 | importTypes: [ | ||
| 373 | "0042" | ||
| 374 | ] | ||
| 375 | }).then((res: any) => { | ||
| 376 | if (res && !res.msg) { | ||
| 377 | download(res, '元数据模板.xlsx', 'excel'); | ||
| 378 | } else { | ||
| 379 | res?.msg && ElMessage.error(res?.msg); | ||
| 380 | } | ||
| 381 | }); | ||
| 382 | } | ||
| 383 | } | ||
| 384 | |||
| 385 | const importData = (info) => { | ||
| 386 | let params = new FormData() | ||
| 387 | if (uploadFiles.value.length == 0) { | ||
| 388 | ElMessage({ | ||
| 389 | type: 'error', | ||
| 390 | message: '请选择上传文件' | ||
| 391 | }) | ||
| 392 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 393 | return | ||
| 394 | } | ||
| 395 | let sheetPass = uploadSetting.value.every(item => item.value) | ||
| 396 | if (!sheetPass) { | ||
| 397 | ElMessage({ type: 'error', message: '请选择sheet页'}) | ||
| 398 | return | ||
| 399 | } | ||
| 400 | let paramUrl = ''; | ||
| 401 | uploadFiles.value.forEach((item: any, index: number) => { | ||
| 402 | params.append("file", item.raw); | ||
| 403 | }); | ||
| 404 | let sheetMaps = {} | ||
| 405 | uploadSetting.value.forEach(item => { | ||
| 406 | sheetMaps[item.value] = item.standardGuid | ||
| 407 | }) | ||
| 408 | sheetMaps = JSON.stringify(sheetMaps) | ||
| 409 | // console.log('sheetMaps', sheetMaps) | ||
| 410 | 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}`) | ||
| 411 | // if (info && Object.keys(info).length) { | ||
| 412 | // paramUrl += `&extendFields=${encodeURIComponent(JSON.stringify(info))}` | ||
| 413 | // } | ||
| 414 | dialogInfo.value.footer.btns[1].loading = true; | ||
| 415 | addImportData(paramUrl, params).then((res: any) => { | ||
| 416 | dialogInfo.value.footer.btns[1].loading = false; | ||
| 417 | if (res.code == proxy.$passCode) { | ||
| 418 | getFirstPageData(); | ||
| 419 | ElMessage({ | ||
| 420 | type: "success", | ||
| 421 | message: '导入成功', | ||
| 422 | }); | ||
| 423 | dialogInfo.value.visible = false; | ||
| 424 | } else { | ||
| 425 | ElMessage({ | ||
| 426 | type: "error", | ||
| 427 | message: res.msg, | ||
| 428 | }); | ||
| 429 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 430 | } | ||
| 431 | }).catch(() => { | ||
| 432 | dialogInfo.value.footer.btns[1].loading = false; | ||
| 433 | }) | ||
| 434 | } | ||
| 435 | |||
| 436 | const dialogBtnClick = (btn, info) => { | ||
| 437 | if (btn.value == 'submit') { | ||
| 438 | // dialogInfo.value.footer.btns.map((item: any) => item.disabled = true) | ||
| 439 | if (dialogInfo.value.type == 'upload') { | ||
| 440 | if (tabsActiveName.value == 'dictionary') { | ||
| 441 | importData({ bizGuid: dictionaryGuid.value }) | ||
| 442 | } else { | ||
| 443 | importData(info) | ||
| 444 | } | ||
| 445 | } | ||
| 446 | } else if (btn.value == 'cancel') { | ||
| 447 | // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled) | ||
| 448 | nextTick(() => { | ||
| 449 | dialogInfo.value.visible = false; | ||
| 450 | }) | ||
| 451 | }; | ||
| 452 | } | ||
| 453 | |||
| 454 | const setUploadInfo = () => { | ||
| 455 | importType.value = '0101' | ||
| 456 | tabsInfo.value.activeName = tabsActiveName.value | ||
| 457 | getFirstPageData() | ||
| 458 | uploadSteps.value = [ | ||
| 459 | { | ||
| 460 | title: '1、选择准备好的文件导入', | ||
| 461 | type: 'btn_upload', | ||
| 462 | uploadInfo: { | ||
| 463 | action: '', | ||
| 464 | auto: false, | ||
| 465 | cover: true, | ||
| 466 | fileList: [], | ||
| 467 | accept: '.xlsx, .xls', | ||
| 468 | tips: '当前支持xls、xlsx文件,支持一个文件多个sheet批量导入' | ||
| 469 | } | ||
| 470 | } | ||
| 471 | ] | ||
| 472 | } | ||
| 473 | |||
| 474 | onActivated(() => { | ||
| 475 | let list = cacheStore.getCatch('uploadSetting') || [] | ||
| 476 | uploadSetting.value = list.map(item => { | ||
| 477 | item.value = null | ||
| 478 | return item | ||
| 479 | }) | ||
| 480 | console.log('uploadSetting', uploadSetting.value) | ||
| 481 | setUploadInfo() | ||
| 482 | }) | ||
| 483 | |||
| 484 | </script> | ||
| 485 | |||
| 486 | <template> | ||
| 487 | <div class="container_wrap"> | ||
| 488 | <!-- <Tabs v-if="!isfileImport" :tabs-info="tabsInfo" @tabChange="tabsChange" /> --> | ||
| 489 | <div class="table_tool_wrap"> | ||
| 490 | <div class="tools_btns"> | ||
| 491 | <el-button type="primary" @click="batching('import')" v-if="tabsActiveName !== 'importFile'" | ||
| 492 | v-preReClick>批量导入</el-button> | ||
| 493 | <el-button type="primary" @click="batching('importFile')" v-if="tabsActiveName == 'importFile'" | ||
| 494 | v-preReClick>文件导入</el-button> | ||
| 495 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | ||
| 496 | <el-button @click="getFirstPageData" v-preReClick>刷新结果</el-button> | ||
| 497 | </div> | ||
| 498 | <span class="tips_text">请及时刷新查看最终结果</span> | ||
| 499 | </div> | ||
| 500 | <div class="table_panel_wrap" :style="{ height: !isfileImport ? 'calc(100% - 71px)' : 'calc(100% - 44px)' }"> | ||
| 501 | <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange" | ||
| 502 | @tablePageChange="tablePageChange" /> | ||
| 503 | </div> | ||
| 504 | <Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick" | ||
| 505 | @cascaderChange="cascaderChange" @selectChange="selectChange"> | ||
| 506 | <div> | ||
| 507 | <div class="title" style="color:#333">2、导入前请先导入文件的sheet与标准做对应</div> | ||
| 508 | <el-form :label-width="120" style="margin-top:20px"> | ||
| 509 | <el-form-item label="全局变量"> | ||
| 510 | <span>选择sheet页</span> | ||
| 511 | </el-form-item> | ||
| 512 | <el-form-item v-for="item in uploadSetting" :key="item.standardGuid" :label="item.standardName" required > | ||
| 513 | <el-select v-model="item.value" placeholder="请选择" style="width:200px" clearable> | ||
| 514 | <el-option v-for="i in uploadSetting.length" :label="`Sheet${i}`" :value="`Sheet${i}`" :key="i"></el-option> | ||
| 515 | </el-select> | ||
| 516 | </el-form-item> | ||
| 517 | </el-form> | ||
| 518 | </div> | ||
| 519 | </Dialog> | ||
| 520 | </div> | ||
| 521 | </template> | ||
| 522 | |||
| 523 | <style lang="scss" scoped> | ||
| 524 | .container_wrap { | ||
| 525 | padding: 0; | ||
| 526 | |||
| 527 | :deep(.el-tabs) { | ||
| 528 | |||
| 529 | .el-tabs__header { | ||
| 530 | margin-bottom: 0; | ||
| 531 | } | ||
| 532 | |||
| 533 | .el-tabs__item { | ||
| 534 | height: 32px; | ||
| 535 | |||
| 536 | &:nth-child(2) { | ||
| 537 | padding-left: 16px; | ||
| 538 | } | ||
| 539 | |||
| 540 | &:last-child { | ||
| 541 | padding-right: 16px; | ||
| 542 | } | ||
| 543 | |||
| 544 | &::after { | ||
| 545 | content: ''; | ||
| 546 | width: 100%; | ||
| 547 | height: 2px; | ||
| 548 | background-color: transparent; | ||
| 549 | position: absolute; | ||
| 550 | left: 0; | ||
| 551 | bottom: 0; | ||
| 552 | } | ||
| 553 | |||
| 554 | &.is-active { | ||
| 555 | &::after { | ||
| 556 | background-color: var(--el-color-primary); | ||
| 557 | } | ||
| 558 | } | ||
| 559 | } | ||
| 560 | |||
| 561 | .el-tabs__active-bar { | ||
| 562 | display: none; | ||
| 563 | } | ||
| 564 | } | ||
| 565 | |||
| 566 | .table_tool_wrap { | ||
| 567 | padding: 0 16px; | ||
| 568 | display: flex; | ||
| 569 | align-items: center; | ||
| 570 | |||
| 571 | .tips_text { | ||
| 572 | margin-left: 16px; | ||
| 573 | font-size: 14px; | ||
| 574 | color: #b2b2b2; | ||
| 575 | } | ||
| 576 | } | ||
| 577 | |||
| 578 | .table_panel_wrap { | ||
| 579 | padding: 0 16px; | ||
| 580 | height: calc(100% - 71px); | ||
| 581 | } | ||
| 582 | } | ||
| 583 | </style> |
-
Please register or sign in to post a comment