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 = 数据资产管理系统 ...@@ -4,6 +4,7 @@ VITE_APP_TITLE = 数据资产管理系统
4 # VITE_API_BASEURL = https://www.zgsjzc.com/api 4 # VITE_API_BASEURL = https://www.zgsjzc.com/api
5 # VITE_API_BASEURL = https://swzl-test.csbr.cn/api 5 # VITE_API_BASEURL = https://swzl-test.csbr.cn/api
6 VITE_API_BASEURL = http://192.168.6.20:28052/ 6 VITE_API_BASEURL = http://192.168.6.20:28052/
7 # VITE_API_BASEURL = http://192.168.6.20:8052/
7 8
8 VITE_IDASS_BASEURL = https://daop-test.zgsjzc.com/portalLogin 9 VITE_IDASS_BASEURL = https://daop-test.zgsjzc.com/portalLogin
9 10
...@@ -82,6 +83,9 @@ VITE_APP_ATTACHMENT_TEMPLATE = ms-daop-personel-service ...@@ -82,6 +83,9 @@ VITE_APP_ATTACHMENT_TEMPLATE = ms-daop-personel-service
82 #人员服务 83 #人员服务
83 VITE_APP_PERSONAL_URL = 'ms-daop-personel-service' 84 VITE_APP_PERSONAL_URL = 'ms-daop-personel-service'
84 85
86 #元数据标准
87 VITE_APP_STANDARD_URL = 'ms-daop-meta-standard-service'
88
85 #流通平台地址 89 #流通平台地址
86 VITE_APP_CIRCULATION = https://daop-lt-test.zgsjzc.com/ 90 VITE_APP_CIRCULATION = https://daop-lt-test.zgsjzc.com/
87 # 测试环境访问地址 91 # 测试环境访问地址
......
...@@ -110,6 +110,9 @@ VITE_API_ASSET_BASEURL = ms-swzl-data-dam-service ...@@ -110,6 +110,9 @@ VITE_API_ASSET_BASEURL = ms-swzl-data-dam-service
110 #数据同步接口地址 110 #数据同步接口地址
111 VITE_API_DATA_SYNC = ms-swzl-data-sync-service 111 VITE_API_DATA_SYNC = ms-swzl-data-sync-service
112 112
113 #元数据标准
114 VITE_APP_STANDARD_URL = 'ms-daop-meta-standard-service'
115
113 #消息接口 116 #消息接口
114 VITE_API_MESSAGE = ms-daop-message-service 117 VITE_API_MESSAGE = ms-daop-message-service
115 118
......
...@@ -248,4 +248,68 @@ export const syncChangeDetail = (guid) => request({ ...@@ -248,4 +248,68 @@ export const syncChangeDetail = (guid) => request({
248 export const delMetaDataSource = (databaseGuid) => request({ 248 export const delMetaDataSource = (databaseGuid) => request({
249 url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/del-by-database-guid?databaseGuid=${databaseGuid}`, 249 url: `${import.meta.env.VITE_APP_PLAN_BASEURL}/meta-collect-task/del-by-database-guid?databaseGuid=${databaseGuid}`,
250 method: 'delete', 250 method: 'delete',
251 })
252
253 /** 元数据-标准代码分页查询 */
254 export const getStandardCodeList = (params) => request({
255 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/page-list`,
256 method: 'post',
257 data: params
258 })
259 /** 元数据-标准代码新增 */
260 export const saveStandardCode = (params) => request({
261 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/save`,
262 method: 'post',
263 data: params
264 })
265 /** 元数据-标准代码修改 */
266 export const updateStandardCode = (params) => request({
267 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/update`,
268 method: 'put',
269 data: params
270 })
271 /** 元数据-标准代码详情 */
272 export const getStandardCodeDetail = (guid) => request({
273 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/detail?guid=${guid}`,
274 method: 'get',
275 })
276 /** 元数据-标准代码删除 */
277 export const deleteStandardCode = (params) => request({
278 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/delete`,
279 method: 'delete',
280 data: params
281 })
282 /** 元数据-查询标准列表 */
283 export const getStandardCodeStandard = (standardTypeCode) => request({
284 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-standard?standardTypeCode=${standardTypeCode}`,
285 method: 'get'
286 })
287 /** 元数据-查询代码列表 */
288 export const getStandardCodeDataList = (params) => request({
289 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/get-data`,
290 method: 'post',
291 data: params
292 })
293 /** 元数据-查询代码字段数据 */
294 export const getStandardCodeFields = (standardGuid) => request({
295 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/get-field?standardGuid=${standardGuid}`,
296 method: 'get'
297 })
298 /** 元数据-保存标准代码数据 */
299 export const saveStandardCodeFieldsData = (params) => request({
300 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/save-data`,
301 method: 'post',
302 data: params
303 })
304 /** 元数据-删除标准代码数据 */
305 export const deleteStandardCodeFieldsData = (params) => request({
306 url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/data/remove-data`,
307 method: 'post',
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
251 }) 315 })
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -156,6 +156,29 @@ const routes: RouteRecordRaw[] = [ ...@@ -156,6 +156,29 @@ const routes: RouteRecordRaw[] = [
156 } 156 }
157 ] 157 ]
158 }, 158 },
159 {
160 path: '/data-meta/reports',
161 component: Layout,
162 meta: {
163 title: '资源目录',
164 icon: 'ep:grid',
165 },
166 children: [
167 {
168 path: 'iframePage',
169 name: 'iframePage',
170 component: () => import('@/views/data_meta/budgetDataIndex.vue'),
171 meta: {
172 title: '',
173 sidebar: true,
174 breadcrumb: false,
175 cache: true,
176 reuse: true,
177 activeMenu: '/data-meta/reports/iframePage',
178 },
179 }
180 ]
181 },
159 { 182 {
160 path: '/data-meta/reports', 183 path: '/data-meta/reports',
161 component: Layout, 184 component: Layout,
...@@ -200,6 +223,54 @@ const routes: RouteRecordRaw[] = [ ...@@ -200,6 +223,54 @@ const routes: RouteRecordRaw[] = [
200 }, 223 },
201 } 224 }
202 ] 225 ]
226 },
227 {
228 path: '/data-meta/metadata-standard',
229 component: Layout,
230 meta: { title: '元数据标准', icon: 'ep:grid' },
231 children: [
232 {
233 path: '',
234 name: 'metadataStandard',
235 component: () => import('@/views/data_meta/standard.vue'),
236 meta: {
237 title: '元数据标准管理',
238 breadcrumb: false,
239 cache: true
240 }
241 },
242 {
243 path: 'standard-query',
244 name: 'metadataStandardQuery',
245 component: () => import('@/views/data_meta/standard-query.vue'),
246 meta: {
247 title: '元数据标准查询',
248 breadcrumb: false,
249 cache: true
250 }
251 },
252 {
253 path: 'standard-codetable',
254 name: 'metadataStandardCodetable',
255 component: () => import('@/views/data_meta/standard-codetable.vue'),
256 meta: {
257 title: '标准代码表',
258 breadcrumb: false,
259 cache: true
260 }
261 },
262 {
263 path: 'standard-import',
264 name: 'metadataStandardImport',
265 component: () => import('@/views/data_meta/standard-import.vue'),
266 meta: {
267 title: '标准代码导入',
268 breadcrumb: false,
269 cache: true,
270 activeMenu: '/data-meta/metadata-standard/standard-codetable'
271 }
272 }
273 ]
203 } 274 }
204 ] 275 ]
205 276
......
...@@ -1293,6 +1293,7 @@ const loadDrawer = async () => { ...@@ -1293,6 +1293,7 @@ const loadDrawer = async () => {
1293 drawerInfo.value.footer.btns.at(-2).visible = false 1293 drawerInfo.value.footer.btns.at(-2).visible = false
1294 drawerInfo.value.footer.btns.at(-3).visible = false 1294 drawerInfo.value.footer.btns.at(-3).visible = false
1295 drawerInfo.value.visible = true 1295 drawerInfo.value.visible = true
1296 console.log('table', formTable.value)
1296 }; 1297 };
1297 1298
1298 const batching = (type) => { 1299 const batching = (type) => {
......
1 <route lang="yaml">
2 name: dictFileds
3 </route>
4
5 <script lang="ts" setup name="dictFileds">
6 import { ref } from 'vue'
7 import router from '@/router'
8 import { ElMessage, ElMessageBox } from "element-plus";
9 import Table from '@/components/Table/index.vue'
10 // import Dialog from '@/components/Dialog/index.vue'
11 import useCatchStore from "@/store/modules/catch";
12 import { chunk } from '@/utils/common'
13 import { getStandardCodeDataList, getStandardCodeFields, saveStandardCodeFieldsData, deleteStandardCodeFieldsData } from '@/api/modules/dataMetaService'
14
15 import {
16 saveDictionaryData,
17 getDictionaryFileds,
18 deleteDictionaryData,
19 checkDictionaryData,
20 showDictionary,
21 getDictionaryRuleData
22 } from '@/api/modules/dataInventory';
23
24 const emits = defineEmits(["exportData"])
25 const { proxy } = getCurrentInstance() as any;
26
27 const cacheStore = useCatchStore()
28 const standardGuid = ref("")
29 const standardName = ref('')
30 const tableSearchInput = ref('')
31 const tableFields: any = ref([])
32 const orginData: any = ref([])
33 const currTableData: any = ref<Object>({});
34 const selectRowData = ref([])
35 const page = ref({
36 limit: 50,
37 curr: 1,
38 // sizes: [
39 // { label: "100", value: 100 },
40 // { label: "200", value: 200 },
41 // { label: "300", value: 300 },
42 // { label: "400", value: 400 },
43 // { label: "500", value: 500 },
44 // ],
45 });
46 const tableChunkData: any = ref([])
47 const tableData: any = ref([])
48 const tableInfo: any = ref({
49 id: 'data-fileds-table',
50 multiple: true,
51 fields: [],
52 data: [],
53 page: {
54 type: "count",
55 rows: 0,
56 ...page.value,
57 },
58 // showPage: false,
59 actionInfo: {
60 label: "操作",
61 type: "btn",
62 width: 92,
63 btns: (scope) => {
64 return [
65 { label: "编辑", value: "edit", visible: scope.row['STATE'] !== 'Running' },
66 { label: "删除", value: "remove", visible: scope.row['STATE'] !== 'Running' },
67 // { label: "保存", value: "save", visible: scope.row['STATE'] === 'Running' },
68 { label: "取消", value: "cancel", visible: scope.row['STATE'] === 'Running' },
69 ]
70 },
71 },
72 editInfo: {},
73 loading: false
74 })
75
76 const uploadFiles = ref([])
77 const uploadInfo = ref({
78 type: 'upload',
79 title: '',
80 col: '',
81 uploadInfo: {
82 id: 'upload-file-form',
83 type: 'panel',
84 action: '',
85 auto: false,
86 cover: true,
87 fileList: [],
88 accept: '.xlsx, .xls',
89 triggerBtn: {
90 label: '导入',
91 value: 'import_file',
92 icon: 'Upload',
93 },
94 tips: '当前支持xls、xlsx文件,默认使用第一个sheet'
95 },
96 })
97
98 const dialogInfo = ref({
99 visible: false,
100 size: 640,
101 direction: "column",
102 header: {
103 title: "新建",
104 },
105 type: '',
106 contents: [
107 uploadInfo.value
108 ],
109 footer: {
110 visible: true,
111 btns: [
112 { type: "default", label: "取消", value: "cancel" },
113 { type: "primary", label: "开始导入", value: "submit" },
114 ],
115 },
116 })
117
118
119 const getFirstPageData = () => {
120 toSearch({})
121 }
122
123 const toSearch = (val: any, clear: boolean = false) => {
124 let params = {
125 pageIndex: 1,
126 pageSize: -1,
127 standardGuid : standardGuid.value
128 }
129 getTableData(params);
130 };
131
132 const getTableData = (params) => {
133 tableInfo.value.loading = true
134 Promise.all([getStandardCodeFields(standardGuid.value), getStandardCodeDataList(params)]).then((resList:any) => {
135 console.log(resList)
136 let schemaDataVOS = resList[0].data || []
137 let jsonArray = resList[1].data.records || []
138 setUploadDataInfo({schemaDataVOS,jsonArray}, true)
139 }).finally(() => tableInfo.value.loading = false)
140 };
141
142 const tableSelectionChange = (val, tId) => {
143 selectRowData.value = val;
144 };
145
146 const tablePageChange = (info) => {
147 page.value.curr = Number(info.curr);
148 if (page.value.limit != Number(info.limit)) {
149 page.value.limit = Number(info.limit);
150 chunkData()
151 } else {
152 tableData.value = tableChunkData.value[page.value.curr - 1]
153 tableInfo.value.data = tableData.value
154 tableInfo.value.page.limit = page.value.limit
155 tableInfo.value.page.curr = page.value.curr
156 }
157 };
158
159 const toolBtnClick = (btn) => {
160 const type = btn.value
161 if (type == 'export') {
162 exportData()
163 } else if (type == 'import') {
164 const info = [
165 { standardGuid: standardGuid.value, standardName: standardName.value }
166 ]
167 cacheStore.setCatch('uploadSetting', info)
168 nextTick(() => {
169 router.push({
170 path: '/data-meta/metadata-standard/standard-import',
171 });
172 })
173 } else if (type == 'submit') {
174 saveData()
175 } else if (type == 'add_row') {
176 const params = {
177 guid: standardGuid.value
178 }
179 getDictionaryRuleData(params).then((res: any) => {
180 if (res.code == proxy.$passCode) {
181 const data = res.data ?? {}
182 let rowInfo: any = {}
183 tableFields.value.map(item => {
184 rowInfo[item.field] = data[item.field] ?? ''
185 })
186 rowInfo.guid = undefined;
187 rowInfo.STATE = 'Running'
188 rowInfo.STATUS = 'edit'
189 rowInfo.ROWID = `upload_${tableData.value.length}`
190 tableData.value.unshift(rowInfo)
191 orginData.value.unshift(rowInfo)
192 tableInfo.value.page.rows = tableData.value.length
193 // orginData.value.unshift(rowInfo)
194 // page.value.curr = 1
195 // chunkData()
196 } else {
197 ElMessage({
198 type: 'error',
199 message: res.msg
200 })
201 }
202 })
203 }
204 }
205
206 const tableBtnClick = (scope, btn) => {
207 const type = btn.value;
208 let row = scope.row;
209 currTableData.value = row;
210 if (type == "edit") {
211 row.STATE = 'Running'
212 row.STATUS = 'edit'
213 tableData.value[scope.$index] = row
214 } else if (type == 'save') {
215 saveData(scope)
216 } else if (type == 'cancel') {
217 if (row.guid != undefined) {
218 // row = orginData.value[(page.value.curr - 1) * page.value.limit + scope.$index]
219 row = JSON.parse(JSON.stringify(orginData.value[scope.$index]))
220 row.STATE = ''
221 row.STATUS = ''
222 tableData.value[scope.$index] = row
223 } else {
224 tableData.value.splice(scope.$index, 1)
225 orginData.value.splice(scope.$index, 1)
226 // orginData.value.splice((page.value.curr - 1) * page.value.limit + scope.$index, 1)
227 // if (scope.$index == 0) {
228 // page.value.curr = (page.value.curr - 1 > 1) ? page.value.curr - 1 : 1
229 // }
230 // chunkData()
231 }
232 tableInfo.value.page.rows = tableData.value.length
233 } else if (type == 'remove') {
234 open("是否确定删除所选数据?", "warning");
235 }
236 };
237
238 const onUpload = (file, fileList) => {
239 uploadFiles.value = fileList
240 }
241
242 const uploadBtnClick = (btn) => {
243 exportData('model')
244 }
245
246 const exportData = (type: any = null) => {
247 emits('exportData', type)
248 }
249
250 const importData = (file: any = null) => {
251 let params = new FormData()
252 if (file) {
253 params.append("file", file.raw);
254 } else {
255 if (uploadFiles.value.length) {
256 uploadFiles.value.forEach((item: any, index: number) => {
257 params.append("file", item.raw);
258 });
259 }
260 }
261
262 params.append("standardGuid", standardGuid.value);
263 showDictionary(params).then((res: any) => {
264 if (res.code == proxy.$passCode) {
265 dialogInfo.value.visible = false
266 let data = res.data ?? []
267 // data.map((item: any, i) => {
268 // item.index = tableData.value.length + i
269 // })
270 const tData = { jsonArray: data }
271 setUploadDataInfo(tData)
272 // saveData(null, tData)
273 } else {
274 ElMessage({
275 type: "error",
276 message: res.msg,
277 });
278 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
279 }
280 }).catch(() => {
281 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
282 });
283 }
284
285 const checkSave = () => {
286 const toSaveData = tableData.value.filter(item => item.STATE === 'Running')
287 return toSaveData.length == 0 ? true : false
288 }
289
290 const checkParamsData = (scope: any = null) => {
291 let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true
292 let passArr = scope ? [scope.row] : tableData.value
293 passArr.map((item, index) => {
294 const obj = JSON.parse(JSON.stringify(item))
295 delete obj.STATUS
296 delete obj.NOTES
297 delete obj.STATE
298 delete obj.ROWID
299 // if (item.STATE === 'Running') {
300 for (var i in obj) {
301 if (obj[i] == '') {
302 pass = false
303 }
304 }
305 // }
306 if (obj.guid !== undefined) {
307 upJsonArray.push(obj)
308 } else {
309 addJsonArray.push(obj)
310 }
311 if (scope) {
312 // obj.index = scope.$index
313 jsonArray.push(obj)
314 } else {
315 // obj.index = index
316 jsonArray.push(obj)
317 }
318 })
319 return { pass, addJsonArray, upJsonArray, jsonArray }
320 }
321
322 const loading = ref(false)
323 const saveData = async (scope: any = null, checkParamData: any = null) => {
324 let passInfo: any = {}
325 if (checkParamData) {
326 passInfo = checkParamData
327 } else {
328 passInfo = await checkParamsData(scope)
329 if (!passInfo.pass) {
330 ElMessage({
331 type: 'error',
332 message: '请填写所有数据项'
333 })
334 return
335 }
336 }
337 let params = passInfo.jsonArray.map(item => {
338 let standardCodeValue = {}
339 tableFields.value.forEach(fieldObj => {
340 standardCodeValue[fieldObj.field] = item[fieldObj.field]
341 })
342 let obj = {
343 standardGuid: standardGuid.value,
344 standardCodeValue,
345 guid: item.guid || null,
346 standardCodeId: item.standardCodeId || null,
347 parentId: item.parentId || null
348 }
349 return obj
350 })
351 loading.value = true
352 saveStandardCodeFieldsData(params).then((res: any) => {
353 if (res.code == proxy.$passCode) {
354 getFirstPageData();
355 ElMessage({
356 type: 'success',
357 message: '保存成功'
358 })
359 } else {
360 ElMessage({
361 type: 'error',
362 message: res.msg,
363 })
364 }
365 }).finally(() => loading.value = false)
366 }
367
368 const addColumn = (info: any = null) => {
369 const fields = tableFields.value
370 const existIndex = fields.findIndex(item => item.field == 'NOTES')
371 if (info) {
372 if (existIndex == -1) {
373 fields.push({
374 label: '备注',
375 field: 'NOTES',
376 width: 200
377 })
378 }
379 for (var d in info) {
380 tableData.value[d].NOTES = info[d].join(',')
381 }
382 } else {
383 if (existIndex > -1) {
384 fields.splice(existIndex, 1)
385 }
386 }
387 }
388
389 // 生成表头
390 const setUploadDataFields = (data) => {
391 let fields: any = [], editInfo: any = {}
392 data.map(item => {
393 let fieldItem: any = {
394 label: item.fieldName, field: item.fieldName, width: 140
395 }
396 fieldItem.type = 'edit'
397 fieldItem.columClass = 'edit-colum'
398 editInfo[item.fieldName] = {
399 label: '',
400 type: 'input',
401 placeholder: '',
402 maxlength: 50,
403 field: item.fieldName,
404 default: '',
405 disabled: item.codeRuleGuid ? true : false,
406 clearable: true,
407 }
408 fields.push(fieldItem)
409 })
410 tableFields.value = fields
411 tableInfo.value.fields = tableFields.value
412 tableInfo.value.editInfo = editInfo
413 }
414
415 // 生成表数据
416 const setUploadDataInfo = async (info, setField = false) => {
417 if (setField) {
418 const fields = info.schemaDataVOS ?? []
419 await setUploadDataFields(fields)
420 }
421 let data = info.jsonArray ?? []
422 // 设置表数据
423 // data.map((item, i) => {
424 // item.ROWID = `upload_${tableData.value.length + i}`
425 // })
426 data.forEach(item => {
427 Object.keys(item.standardCodeValue).forEach(key => {
428 item[key] = item.standardCodeValue[key]
429 })
430 })
431 if (setField) {
432 tableData.value = data
433 } else {
434 tableData.value = [...tableData.value, ...data]
435 }
436 orginData.value = JSON.parse(JSON.stringify(tableData.value))
437 tableInfo.value.data = tableData.value
438 tableInfo.value.page.rows = tableData.value.length
439 // if (setField) {
440 // orginData.value = data
441 // } else {
442 // orginData.value = [...orginData.value, ...data]
443 // }
444 // chunkData()
445 }
446
447 const chunkData = () => {
448 const data = orginData.value
449 tableChunkData.value = chunk(data, page.value.limit)
450 tableData.value = tableChunkData.value[page.value.curr - 1]
451 tableInfo.value.data = tableData.value
452 tableInfo.value.page.limit = page.value.limit
453 tableInfo.value.page.curr = page.value.curr
454 tableInfo.value.page.rows = orginData.value.length
455 }
456
457 const batching = (type) => {
458 if (type == 'delete') {
459 if (selectRowData.value.length == 0) {
460 ElMessage({
461 type: 'error',
462 message: '请选择需要删除的数据',
463 })
464 return
465 }
466 open("是否确定删除所选数据?", "warning", true);
467 }
468 };
469
470 const open = (msg, type, isBatch = false) => {
471 ElMessageBox.confirm(msg, "提示", {
472 confirmButtonText: "确定",
473 cancelButtonText: "取消",
474 type: type,
475 }).then(() => {
476 let guids: any = []
477 if (isBatch) {
478 const list = selectRowData.value.filter((item: any) => item.guid !== undefined)
479 if (list.length) {
480 guids = list.map((l: any) => l.guid)
481 }
482 const newRows = selectRowData.value.filter((item: any) => item.guid == undefined)
483 newRows.map((n: any, r) => {
484 const existIndex = tableData.value.findIndex(t => t.ROWID == n.ROWID)
485 if (existIndex > -1) {
486 tableData.value.splice(existIndex, 1)
487 orginData.value.splice(existIndex, 1)
488 }
489 // const existIndex = orginData.value.findIndex(t => t.id == n.id)
490 // existIndex > -1 && orginData.value.splice(existIndex, 1)
491 // if (r == newRows.length - 1) {
492 // page.value.curr = 1
493 // chunkData()
494 // }
495 })
496 tableInfo.value.page.rows = tableData.value.length
497 } else {
498 guids = [currTableData.value.guid]
499 }
500 if (guids.length) {
501 const params = {
502 guid: standardGuid.value,
503 delGuids: guids
504 }
505 // console.log(params)
506 // return
507 deleteStandardCodeFieldsData(guids).then((res: any) => {
508 if (res.code == proxy.$passCode) {
509 getFirstPageData();
510 ElMessage({
511 type: "success",
512 message: "删除成功",
513 });
514 } else {
515 ElMessage({
516 type: "error",
517 message: res.msg,
518 });
519 }
520 });
521 }
522 });
523 };
524
525 const dialogBtnClick = (btn, info) => {
526 if (btn.value == 'submit') {
527 // dialogInfo.value.footer.btns.map((item: any) => item.disabled = true)
528 importData()
529 } else if (btn.value == 'cancel') {
530 // dialogInfo.value.footer.btns.map((item: any) => delete item.disabled)
531 nextTick(() => {
532 dialogInfo.value.visible = false;
533 })
534 }
535 };
536
537 defineExpose({
538 standardGuid,
539 standardName,
540 getFirstPageData,
541 checkSave
542 });
543
544 </script>
545
546 <template>
547 <div class="container_wrap full flex">
548 <div class="main_wrap">
549 <div class="table_tool_wrap">
550 <div class="tools_btns">
551 <el-button type="primary" @click="toolBtnClick({ value: 'add_row' })" v-preReClick :disabled="loading">新增行</el-button>
552 <el-button type="primary" plain @click="toolBtnClick({ value: 'submit' })" v-preReClick :disabled="loading">保存数据</el-button>
553 <el-button @click="batching('delete')" v-preReClick :disabled="loading">批量删除</el-button>
554 <el-button @click="toolBtnClick({ value: 'import' })" v-preReClick :disabled="loading">导入数据</el-button>
555 <el-button @click="toolBtnClick({ value: 'export' })" v-preReClick :disabled="loading">导出数据</el-button>
556 </div>
557 <!-- <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="输入名称搜索" :suffix-icon="Search" clearable
558 @change="val => toSearch({})" /> -->
559 </div>
560 <div class="table_panel_wrap full">
561 <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
562 @tablePageChange="tablePageChange" />
563 </div>
564 </div>
565
566 <!-- <Dialog :dialogInfo="dialogInfo" @btnClick="dialogBtnClick" @onUpload="onUpload" @uploadBtnClick="uploadBtnClick" /> -->
567 </div>
568 </template>
569
570 <style lang="scss" scoped>
571 .container_wrap {
572 width: calc(100% - 200px);
573
574 .main_wrap {
575 width: 100%;
576
577 .table_panel_wrap {
578 height: calc(100% - 44px);
579 }
580 }
581 }
582 </style>
1 <route lang="yaml">
2 name: dictionary
3 </route>
4
5 <script lang="ts" setup name="dictionary">
6 import { ref } from 'vue'
7 import { ElMessage, ElMessageBox } from "element-plus";
8 import { Search } from '@element-plus/icons-vue'
9 import Tree from '@/components/Tree/index.vue'
10 import Table from '@/components/Table/index.vue'
11 import Drawer from '@/components/Drawer/index.vue'
12 import DictFileds from './components/dictFileds.vue'
13 import useCatchStore from "@/store/modules/catch";
14 import { download } from '@/utils/common'
15 import { getParamsList } from '@/api/modules/dataAsset'
16 import { getStandardCodeList, saveStandardCode,
17 updateStandardCode, getStandardCodeDetail,
18 deleteStandardCode, getStandardCodeStandard, exportStandardCodeData
19 } from '@/api/modules/dataMetaService'
20 import {
21 addDictionary,
22 deleteDictionary,
23 getDictionary,
24 updateDictionary,
25 getDictionaryTree,
26 getDictionaryDetail,
27 exportDictionary,
28 showDictionary,
29 getDataBaseList,
30 getCoderuleList,
31 saveDictionaryData,
32 getDictionaryFileds,
33 updateDictionaryState,
34 getDictionaryRuleData,
35 exportDictionaryFileds,
36 checkDeleteDictionary,
37 checkDeleteDictionaryScheme,
38 checkDictionaryData,
39 getNewDataTypeList
40 } from '@/api/modules/dataInventory';
41 import router from '@/router'
42
43 const { proxy } = getCurrentInstance() as any;
44
45 const cacheStore = useCatchStore()
46 // 禁用字段
47 const forbidFields = [
48 'guid',
49 'sharding_flag',
50 'create_user_id',
51 'create_user_name',
52 'update_user_id',
53 'update_user_name',
54 'create_time',
55 'update_time',
56 'is_deleted'
57 ]
58 const showFiledsPage = ref(false)
59 const dictFiledsRef = ref()
60 const dataTypeList = ref([])
61 const dataBaseList = ref([])
62 const codeRuleList = ref([])
63 const dictTreeRef = ref()
64 const dictType = ref(-1)
65 const dictGuid = ref('')
66 const expandedKey: any = ref([])
67 const currentNodeKey = ref('')
68 const showLoading = ref(true)
69 const treeData = ref([])
70 const treeInfo = ref({
71 id: "data-pickup-tree",
72 filter: true,
73 queryValue: "",
74 queryPlaceholder: "请输入关键字搜索",
75 props: {
76 label: "label",
77 value: "value",
78 isLeaf: "isLeaf",
79 },
80 lazy: true,
81 nodeKey: 'value',
82 expandedKey: ['01'],
83 currentNodeKey: '01',
84 data: [],
85 expandOnNodeClick: false,
86 loading: false,
87 currentObj: {}
88 });
89
90 const standardOptions = ref([])
91 const publishingUnitCodeOptions = ref([])
92
93 const tableSearchInput = ref('')
94 const currTableData: any = ref<Object>({});
95 const page = ref({
96 limit: 50,
97 curr: 1,
98 sizes: [
99 { label: "10", value: 10 },
100 { label: "50", value: 50 },
101 { label: "100", value: 100 },
102 { label: "150", value: 150 },
103 { label: "200", value: 200 },
104 ],
105 });
106 const selectRowData = ref([])
107 const selectedRowData = ref([])
108 const tableInfo: any = ref({
109 id: 'data-source-table',
110 multiple: true,
111 fixedSelection: true,
112 fields: [
113 { label: "序号", type: "index", width: 56, align: "center" },
114 { label: '代码名称', field: 'codeName', width: 140 },
115 { label: '标准号', field: 'standard', width: 140 },
116 { label: '标准名称', field: 'standardName', width: 140 },
117 // { label: '启用状态', field: 'bizState', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' },
118 { label: '启用状态', field: 'bizState', type: 'tag', width: 100, align: 'center' },
119 { label: '创建时间', field: 'createTime', width: 140 }
120 ],
121 data: [],
122 page: {
123 type: "normal",
124 rows: 0,
125 ...page.value,
126 },
127 actionInfo: {
128 label: "操作",
129 type: "btn",
130 width: 92, //不要刚好90.缩小浏览器会因为小数点的差距而换行,
131 fixed: 'right',
132 btns: [
133 { label: "编辑", value: "edit" },
134 { label: "删除", value: "delete" },
135 ],
136 },
137 loading: false
138 })
139
140 const dictionaryType = ref(1)
141 const orginOptions = [
142 { label: 'code', value: 'code' },
143 { label: 'name', value: 'name' },
144 ]
145 let codeOptions = ref([])
146 const orginItems = [
147 {
148 label: '标准类型',
149 type: 'select',
150 placeholder: '请选择',
151 field: 'standardTypeCode',
152 default: '',
153 options: standardOptions,
154 clearable: true,
155 required: true
156 }
157 , {
158 label: '字典英文名',
159 type: 'input',
160 maxlength: 20,
161 placeholder: '请输入',
162 field: 'enName',
163 clearable: true,
164 required: true,
165 disabled: false
166 }, {
167 label: '排序',
168 type: 'input',
169 placeholder: '请输入',
170 field: 'orderNum',
171 maxlength: 6,
172 clearable: true,
173 required: true,
174 visible: true,
175 }, {
176 label: '字典类型',
177 type: 'radio-panel',
178 placeholder: '',
179 field: 'dictionaryType',
180 default: 1,
181 options: [
182 { label: '列表结构', value: 1 },
183 { label: '层级结构', value: 2 }
184 ],
185 children: [
186 {
187 label: '编码字段',
188 type: 'select',
189 placeholder: '请输入',
190 field: 'codeColumn',
191 default: '',
192 options: [],
193 clearable: true,
194 required: true
195 }, {
196 label: '编码名称',
197 type: 'select',
198 placeholder: '请输入',
199 field: 'codeName',
200 default: '',
201 options: [],
202 clearable: true,
203 required: true
204 }, {
205 label: '顶级节点值',
206 type: 'input',
207 placeholder: '请输入',
208 field: 'topNodeValue',
209 clearable: true,
210 required: true,
211 visible: false
212 }, {
213 label: '路径',
214 type: 'input',
215 placeholder: '请输入',
216 field: 'path',
217 clearable: true,
218 required: true,
219 block: true,
220 visible: false
221 }
222 ],
223 clearable: true,
224 required: false,
225 block: true,
226 visible: true,
227 },
228 ]
229 const formItems: any = ref([
230 {
231 label: '标准类型',
232 type: 'select',
233 placeholder: '请选择',
234 field: 'standardTypeCode',
235 default: '',
236 options: standardOptions,
237 clearable: true,
238 required: true
239 },
240 {
241 label: '代码名称',
242 type: 'input',
243 placeholder: '请输入',
244 field: 'codeName',
245 default: '',
246 maxlength: 20,
247 clearable: true,
248 required: true
249 },
250 {
251 label: '标准号',
252 type: 'input',
253 placeholder: '请输入',
254 field: 'standard',
255 default: '',
256 maxlength: 50,
257 clearable: true,
258 required: true
259 },
260 {
261 label: '标准名称',
262 type: 'input',
263 placeholder: '请输入',
264 field: 'standardName',
265 default: '',
266 maxlength: 20,
267 clearable: true,
268 required: true
269 },
270 {
271 label: '发布单位',
272 type: 'select',
273 placeholder: '请选择',
274 field: 'publishingUnitCode',
275 default: '',
276 options: publishingUnitCodeOptions,
277 clearable: true,
278 required: true
279 },
280 {
281 label: '排序',
282 type: 'inputNumber',
283 placeholder: '请输入',
284 field: 'orderNum',
285 default: '',
286 maxlength: 2,
287 clearable: true,
288 required: true
289 },
290 {
291 label: '启用状态',
292 type: 'switch',
293 field: 'bizState',
294 default: 'Y',
295 activeValue: 'Y',
296 inactiveValue: 'N'
297 },
298 {
299 label: '代码类型',
300 type: 'radio-panel',
301 placeholder: '请选择',
302 field: 'typeCode',
303 default: '1',
304 options: [
305 { label: '列表结构', value: '1' },
306 { label: '层级结构', value: '2' }
307 ],
308 clearable: true,
309 required: true
310 },
311 {
312 label: '编码字段11',
313 type: 'select',
314 placeholder: '请选择',
315 field: 'codeFields',
316 default: [],
317 options: codeOptions,
318 clearable: true,
319 required: true,
320 multiple: true,
321 tagsTooltip: true,
322 filterable: true,
323 },
324 {
325 label: '编码名称',
326 type: 'select',
327 placeholder: '请选择',
328 field: 'codeFieldName',
329 default: '',
330 options: codeOptions,
331 clearable: true,
332 required: true
333 },
334 {
335 label: '层级结构',
336 type: 'input',
337 placeholder: '请输入',
338 field: 'hierarchy',
339 default: '',
340 clearable: true,
341 visible: true
342 }
343 ])
344 const formRules: any = ref({
345 standardTypeCode: { required: true, message: '请选择标准类型' },
346 codeName: { required: true, message: '请输入代码名称' },
347 standard: { required: true, message: '请输入标准号' },
348 standardName: { required: true, message: '请输入标准名称' },
349 publishingUnitCode: { required: true, message: '请选择发布单位' },
350 orderNum: { required: true, message: '请输入排序' },
351 typeCode: { required: true, message: '请选择代码类型' },
352 codeFields: { required: true, message: '请选择编码字段' },
353 codeFieldName: { required: true, message: '请选择编码名称' }
354 })
355 const formInfo = ref({
356 type: 'form',
357 title: '',
358 col: 'span',
359 formInfo: {
360 id: 'add-dict-form',
361 col: 'col2',
362 readonly: false,
363 items: formItems.value,
364 rules: formRules.value
365 }
366 })
367
368 const orginData = [
369 {
370 ROWID: 'field_0',
371 fieldName: 'code',
372 description: '编码字段',
373 fieldType: 'varchar',
374 fieldLength: '10',
375 fieldPrecision: '',
376 // orderNum: '1',
377 codeRuleGuid: '',
378 STATUS: 'edit',
379 STATE: 'Running'
380 }, {
381 ROWID: 'field_1',
382 fieldName: 'name',
383 description: '编码名称',
384 fieldType: 'varchar',
385 fieldLength: '20',
386 fieldPrecision: '',
387 // orderNum: '2',
388 codeRuleGuid: '',
389 STATUS: 'edit',
390 STATE: 'Running'
391 }
392 ]
393 const orginFields = [
394 { label: "序号", type: "index", width: 56, align: "center" },
395 { label: "字段名称", field: "fieldName", width: 140 }
396 ]
397 const formTableData: any = ref([])
398 const formTableSelectRowData: any = ref([])
399 const editTableInfo = ref({
400 fieldName: {
401 label: '字段名称',
402 type: 'input',
403 maxlength: 50,
404 placeholder: '',
405 field: 'fieldName',
406 default: '',
407 clearable: true,
408 required: true,
409 }
410 })
411 const formTable = ref({
412 type: "table",
413 title: "定义表结构",
414 col: 'no-margin',
415 style: {
416 height: 'calc(100% - 234px)'
417 },
418 tableInfo: {
419 id: "role-authority-table",
420 multiple: true,
421 minHeight: 'unset',
422 maxHeight: '100%',
423 fields: [],
424 data: [],
425 showPage: false,
426 actionInfo: {
427 show: true,
428 label: "操作",
429 type: "btn",
430 width: 60,
431 fixed: 'right',
432 btns: [
433 { label: "删除", value: "remove" },
434 ]
435 },
436 editInfo: {},
437 readonly: false,
438 col: 'auto-height',
439 style: {
440 height: 'calc(100% - 40px)'
441 },
442 loading: false
443 },
444 tableTool: {
445 col: 'float-right',
446 visible: true,
447 btns: [
448 { label: "新增行", value: "add-row", type: 'primary' },
449 { label: "批量删除", value: "remove_batch" },
450 ]
451 },
452 })
453
454 const fieldSheetInfo: any = ref({})
455 const uploadTableData: any = ref([])
456 const uploadSelectRowData: any = ref([])
457 const uploadTableFields: any = ref([])
458 const uploadTableInfo = ref({
459 id: "role-authority-table",
460 multiple: true,
461 // minHeight: 'unset',
462 // maxHeight: '100%',
463 fields: [],
464 data: [],
465 showPage: false,
466 actionInfo: {
467 label: "操作",
468 type: "btn",
469 width: 60,
470 btns: [
471 { label: "删除", value: "remove" },
472 ],
473 },
474 editInfo: {},
475 readonly: false,
476 loading: false
477 })
478 const uploadFiles: any = ref([])
479 const uploadInfo = ref({
480 type: 'upload',
481 title: '添加表数据',
482 col: 'row-reverse',
483 uploadInfo: {
484 id: 'upload-file-form',
485 action: '',
486 auto: false,
487 fileList: [],
488 accept: '.xlsx, .xls',
489 cover: true,
490 triggerBtn: {
491 label: '导入文件',
492 value: 'import_file',
493 icon: 'Upload',
494 plain: true,
495 },
496 toolBar: [
497 { label: '下载模板', value: 'export_model', plain: true, icon: 'Download' },
498 ]
499 // showList: false,
500 },
501 tableInfo: {},
502 tools: {
503 col: 'right',
504 visible: true,
505 btns: [
506 { label: '树形显示', value: 'show_tree', type: 'primary', plain: true, visible: false },
507 { label: '新增行', value: 'add_row', type: 'primary', plain: true },
508 { label: '批量删除', value: 'remove_batch', plain: true },
509 ]
510 }
511 })
512 const fieldTableInfo = ref({
513 type: 'field-table',
514 title: '表数据',
515 tableInfo: {
516 id: 'dict-field-table',
517 minHeight: 'unset',
518 maxHeight: '100%',
519 fields: [],
520 data: [],
521 loading: false,
522 showPage: false,
523 actionInfo: {
524 show: false
525 },
526 col: 'auto-height'
527 }
528 })
529
530 const contents = ref({
531 add: [
532 formInfo.value,
533 formTable.value,
534 ],
535 upload: [
536 formInfo.value,
537 uploadInfo.value,
538 ],
539 sheet: [
540 formInfo.value,
541 formTable.value,
542 ],
543 field: [
544 formInfo.value,
545 fieldTableInfo.value,
546 ]
547 })
548
549 const drawerRef = ref()
550 const drawerInfo: any = ref({
551 visible: false,
552 direction: "rtl",
553 modalClass: "",
554 modalClose: false,
555 modal: true,
556 size: 700,
557 header: {
558 title: "新增",
559 },
560 type: '',
561 container: {
562 contents: [],
563 },
564 footer: {
565 btns: [
566 { type: 'default', label: '取消', value: 'cancel' },
567 { type: 'primary', label: '保存', value: 'submit' },
568 { type: 'primary', label: '保存并添加数据', value: 'submit', visible: true },
569 ]
570 },
571 })
572
573 const setFormItems = (row: any = null) => {
574 formItems.value = JSON.parse(JSON.stringify(orginItems))
575 formItems.value.map(item => {
576 if (item.field == 'databaseNameZh') {
577 item.options = dataBaseList.value
578 item.default = row ? row[item.field] : ''
579 } else if (item.field == 'dictionaryType') {
580 item.default = dictionaryType.value
581 // item.disabled = drawerInfo.value.type == 'add' ? false : true
582 item.disabled = true
583 item.children.map(child => {
584 child.options = orginOptions
585 if (child.field == 'codeColumn') {
586 child.default = row ? row[child.field] : 'code'
587 } else if (child.field == 'codeName') {
588 child.default = row ? row[child.field] : 'name'
589 } else {
590 child.default = row ? row[child.field] : ''
591 }
592 child.disabled = drawerInfo.value.type == 'detail' ? true : false
593 child.clearable = drawerInfo.value.type == 'detail' ? false : true
594 })
595 } else if (item.field == 'enName') {
596 item.default = row ? row[item.field] : ''
597 item.disabled = drawerInfo.value.type == 'add' ? false : true
598 item.clearable = drawerInfo.value.type == 'add' ? true : false
599 } else {
600 item.default = row ? row[item.field] : ''
601 item.disabled = drawerInfo.value.type == 'detail' ? true : false
602 item.clearable = drawerInfo.value.type == 'detail' ? false : true
603 }
604 })
605 formInfo.value.formInfo.readonly = drawerInfo.value.type == 'detail'
606 formInfo.value.formInfo.items = formItems.value
607 // for(var e in editTableInfo.value){
608 // const editItem = editTableInfo.value[e]
609 // if(editItem.field != 'description' && editItem.field != 'codeRuleGuid'){
610 // editItem.disabled = drawerInfo.value.type != 'add'
611 // }
612 // }
613 }
614
615 // 获取数据类型列表
616 const getDataType = () => {
617 let params = {
618 dictType: "字段类型"
619 }
620 getNewDataTypeList(params).then((res: any) => {
621 if (res.code == proxy.$passCode) {
622 const data = res.data
623 editTableInfo.value['fieldType'].options = data
624 } else {
625 ElMessage({
626 type: 'error',
627 message: res.msg,
628 })
629 }
630 })
631 }
632
633 // 获取数据库列表
634 const getDataBase = () => {
635 const params = {
636 pageIndex: 1,
637 connectStatus: '1'
638 }
639 getDataBaseList(params).then((res: any) => {
640 if (res.code == proxy.$passCode) {
641 const data = res.data ?? []
642 data.map(item => {
643 item.label = item.databaseNameZh
644 item.value = item.guid
645 })
646 dataBaseList.value = data
647 } else {
648 ElMessage({
649 type: 'error',
650 message: res.msg,
651 })
652 }
653 })
654 }
655
656 // 获取编码规则列表
657 const getCodeRuleData = () => {
658 let params = {}
659 getCoderuleList(params).then((res: any) => {
660 if (res.code == proxy.$passCode) {
661 const data = res.data
662 data?.map(item => {
663 item.label = item.ruleName
664 item.value = item.guid
665 })
666 codeRuleList.value = data
667 editTableInfo.value['codeRuleGuid'].options = data
668 } else {
669 ElMessage({
670 type: 'error',
671 message: res.msg,
672 })
673 }
674 })
675 }
676
677 const treePromise = ref();
678
679 const getTreeData = (needClick = false, currData = {}) => {
680 getParamsList({ dictType: '标准类型'}).then((res:any) => {
681 if (res.code === proxy.$passCode) {
682 const data = res.data || []
683 data.forEach(item => {
684 item.treeLevel = 1
685 })
686 treeInfo.value.data = data
687 standardOptions.value = data
688 // 默认展开第一个
689 if (data.length === 0) return
690 let params = {
691 pageIndex: 1,
692 pageSize: 50,
693 standardTypeCode: data[0].value,
694 // codeName: '标准类型'
695 }
696 getStandardCodeList(params).then((res:any) => {
697 if (res.code === proxy.$passCode) {
698 let data = res.data
699 tableInfo.value.data = data.records
700 tableInfo.value.page.limit = data.pageSize
701 tableInfo.value.page.curr = data.pageIndex
702 tableInfo.value.page.rows = data.totalRows
703 }
704 })
705 }
706 })
707 }
708
709 const getFirstPageData = () => {
710 page.value.curr = 1;
711 toSearch({})
712 }
713
714 const toSearch = (val: any, clear: boolean = false) => {
715 let params: any = Object.keys(val).length ? { ...val } : {}
716 let { currentNodeKey, currentObj } = treeInfo.value
717 console.log('currentObj', currentObj)
718 params.pageIndex = page.value.curr;
719 params.pageSize = page.value.limit;
720 params.codeName = tableSearchInput.value
721 if (currentObj.treeLevel === 1) {
722 params.standardTypeCode = currentNodeKey
723 } else if (currentObj.treeLevel === 2) {
724 params.standardTypeCode = currentObj.standardTypeCode
725 params.standardName = currentObj.value
726 }
727 getTableData(params);
728 };
729
730 const getTableData = (params) => {
731 tableInfo.value.loading = true
732 getStandardCodeList(params).then((res:any) => {
733 if (res.code === proxy.$passCode) {
734 let data = res.data
735 let list = res.data.records || []
736 list = list.map(item => {
737 item.label = item.codeName
738 item.value = item.guid
739 return item
740 })
741 tableInfo.value.data = list
742 tableInfo.value.page.limit = data.pageSize
743 tableInfo.value.page.curr = data.pageIndex
744 tableInfo.value.page.rows = data.totalRows
745 }
746 tableInfo.value.loading = false
747 }).catch(xhr => {
748 tableInfo.value.loading = false
749 })
750 };
751
752 const tableSelectionChange = (val, tId) => {
753 if (drawerInfo.value.visible) {
754 if (formItems.value.length == 2) {
755 uploadSelectRowData.value = val
756 } else {
757 formTableSelectRowData.value = val
758 }
759 } else {
760 selectRowData.value = val.map((item) => item.guid);
761 selectedRowData.value = val
762 }
763 };
764
765 const tablePageChange = (info) => {
766 page.value.curr = Number(info.curr);
767 page.value.limit = Number(info.limit);
768 toSearch({});
769 };
770
771 const tableInputChange = (val, scope) => {
772 if (forbidFields.indexOf(val) > -1) {
773 ElMessage({
774 type: "error",
775 message: '该名称已存在,请填写其他名称',
776 });
777 return
778 }
779 setCodeOptions()
780 }
781
782 const setCodeOptions = () => {
783 let opts: any = []
784 formTableData.value.map(item => {
785 if (item.fieldName) {
786 const row = JSON.parse(JSON.stringify(item))
787 row.label = item.fieldName
788 row.value = item.fieldName
789 opts.push(row)
790 }
791 })
792 codeOptions.value = opts
793 }
794
795 const toolBtnClick = (btn, data) => {
796 const type = btn.value
797 if (data) {
798 if (type.indexOf('add') > -1) {
799 if (formItems.value.length == 2) {
800 const params = {
801 guid: fieldSheetInfo.value.guid
802 }
803 uploadTableInfo.value.loading = true
804 getDictionaryRuleData(params).then((res: any) => {
805 if (res.code == proxy.$passCode) {
806 const data = res.data ?? {}
807 let rowInfo: any = {}
808 uploadTableFields.value.map(item => {
809 rowInfo[item.field] = data[item.field] ?? ''
810 })
811 rowInfo.STATUS = 'edit'
812 rowInfo.STATE = 'Running'
813 rowInfo.ROWID = `upload_${uploadTableData.value.length}`
814 uploadTableData.value.push(rowInfo)
815 uploadTableInfo.value.data = uploadTableData.value
816 scrollTable(rowInfo)
817 } else {
818 ElMessage({
819 type: 'error',
820 message: res.msg
821 })
822 }
823 uploadTableInfo.value.loading = false
824 }).catch(() => {
825 uploadTableInfo.value.loading = false
826 })
827 } else {
828 const rowInfo = {
829 ROWID: `formData_${formTableData.value.length}`,
830 fieldName: '',
831 description: '',
832 fieldType: '',
833 fieldLength: '',
834 fieldPrecision: '',
835 orderNum: '',
836 codeRuleGuid: '',
837 STATUS: 'edit',
838 STATE: 'Running'
839 }
840 let list: any = formTableData.value
841 list.push(rowInfo)
842 formTable.value.tableInfo.data = list
843 scrollTable(rowInfo)
844 }
845 } else if (type.indexOf('remove') > -1) {
846 if (formItems.value.length == 2) {
847 if (uploadSelectRowData.value.length == 0) {
848 ElMessage({
849 type: "error",
850 message: '请选择需要删除的数据',
851 });
852 return
853 }
854 uploadSelectRowData.value.map(item => {
855 const existIndex = uploadTableData.value.findIndex(s => s.ROWID == item.ROWID)
856 existIndex > -1 && uploadTableData.value.splice(existIndex, 1)
857 })
858 } else {
859 if (formTableSelectRowData.value.length == 0) {
860 ElMessage({
861 type: "error",
862 message: '请选择需要删除的数据',
863 });
864 return
865 }
866 const removeRows = () => {
867 formTableSelectRowData.value.map(item => {
868 const existIndex = formTableData.value.findIndex(s => s.ROWID == item.ROWID)
869 existIndex > -1 && formTableData.value.splice(existIndex, 1)
870 })
871 }
872 if (drawerInfo.value.type == 'edit') {
873 const editRows = formTableSelectRowData.value.filter(item => item.guid !== undefined)
874 if (editRows.length) {
875 formTable.value.tableInfo.loading = true
876 checkDelete().then((res: any) => {
877 if (res) {
878 ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", {
879 confirmButtonText: "确定",
880 cancelButtonText: "取消",
881 type: 'warning',
882 }).then(() => {
883 removeRows()
884 })
885 } else {
886 removeRows()
887 }
888 formTable.value.tableInfo.loading = false
889 }).catch(xhr => {
890 ElMessage({
891 type: 'error',
892 message: xhr
893 })
894 formTable.value.tableInfo.loading = false
895 })
896 } else {
897 removeRows()
898 }
899 } else {
900 removeRows()
901 }
902 }
903 }
904 } else {
905 if (type == 'export_model') {
906 exportData('model')
907 } else if (type == 'import_file') {
908 importData()
909 }
910 }
911 }
912
913 const tableSwitchBeforeChange = (scope, field, callback) => {
914 const msg = '确定修改状态?'
915 ElMessageBox.confirm(
916 msg,
917 '提示',
918 {
919 confirmButtonText: '确定',
920 cancelButtonText: '取消',
921 type: 'warning',
922 }
923 ).then(() => {
924 const state = scope.row[field] == 1 ? 0 : 1
925 const result = tableSwitchChange(state, scope, field)
926 callback(result)
927 }).catch(() => {
928 callback(false)
929 })
930 }
931
932 const tableSwitchChange = (val, scope, field) => {
933 return new Promise((resolve, reject) => {
934 let params = {
935 guid: scope.row.guid,
936 dictionaryState: val
937 }
938 updateDictionaryState(params).then((res: any) => {
939 if (res.code == proxy.$passCode && res.data) {
940 getFirstPageData()
941 ElMessage({
942 type: "success",
943 message: '状态修改成功',
944 });
945 resolve(true)
946 } else {
947 ElMessage({
948 type: "error",
949 message: res.msg,
950 });
951 reject(false)
952 }
953 }).catch(() => {
954 reject(false)
955 })
956 })
957 }
958
959 const tableBtnClick = (scope, btn) => {
960 const type = btn.value;
961 const row = scope.row;
962 if (type == "edit" || type == 'detail') {
963 fieldTableInfo.value.tableInfo.fields = []
964 fieldTableInfo.value.tableInfo.data = []
965 drawerInfo.value.header.title = type == 'edit' ? "编辑标准代码" : "数据字典详情";
966 drawerInfo.value.modalClass = type == 'edit' ? '' : 'wrap_width_auto'
967 drawerInfo.value.type = type
968 drawerInfo.value.visible = true;
969 drawerInfo.value.loading = true;
970 formTable.value.tableInfo.loading = true
971 getStandardCodeDetail(row.guid).then((res: any) => {
972 if (res.code == proxy.$passCode && res.data) {
973 let data = res.data
974 currTableData.value = data;
975 setDetailInfo()
976 } else {
977 ElMessage({
978 type: "error",
979 message: res.msg,
980 });
981 }
982 formTable.value.tableInfo.loading = false
983 drawerInfo.value.loading = false;
984 }).catch(() => {
985 formTable.value.tableInfo.loading = false
986 drawerInfo.value.loading = false;
987 })
988 } else if (type == "delete") {
989 currTableData.value = row;
990 tableInfo.value.loading = true
991 open("此操作将永久删除, 是否继续?", "warning");
992 tableInfo.value.loading = false
993 }
994 };
995
996 const checkDelete = (isBatch: any = false) => {
997 if (drawerInfo.value.visible) {
998 return new Promise((resolve, reject) => {
999 let params: any = {
1000 guid: currTableData.value.guid
1001 }
1002 checkDeleteDictionaryScheme(params).then((res: any) => {
1003 if (res.code == proxy.$passCode) {
1004 const data = res.data
1005 resolve(data)
1006 } else {
1007 reject(res.msg)
1008 }
1009 }).catch((xhr: any) => {
1010 reject(xhr.msg)
1011 })
1012 })
1013 } else {
1014 return new Promise((resolve, reject) => {
1015 let guids = [currTableData.value.guid]
1016 if (isBatch) {
1017 guids = selectRowData.value
1018 }
1019 checkDeleteDictionary(guids).then((res: any) => {
1020 if (res.code == proxy.$passCode) {
1021 const data = res.data ?? {}
1022 if (data.used) {
1023 resolve({
1024 used: true,
1025 data: data.used
1026 })
1027 } else {
1028 resolve({
1029 used: false,
1030 data: data.unuse
1031 })
1032 }
1033 } else {
1034 reject(res.msg)
1035 }
1036 }).catch((xhr: any) => {
1037 reject(xhr.msg)
1038 })
1039 })
1040 }
1041 }
1042
1043 const open = (msg, type, isBatch = false) => {
1044 ElMessageBox.confirm(msg, "提示", {
1045 confirmButtonText: "确定",
1046 cancelButtonText: "取消",
1047 type: type,
1048 }).then(() => {
1049 let guids = [currTableData.value.guid]
1050 if (isBatch) {
1051 guids = selectRowData.value
1052 }
1053 tableInfo.value.loading = true
1054 deleteStandardCode(guids).then((res: any) => {
1055 if (res.code == proxy.$passCode) {
1056 getFirstPageData()
1057 ElMessage({
1058 type: "success",
1059 message: "删除成功",
1060 });
1061 } else {
1062 ElMessage({
1063 type: "error",
1064 message: res.msg,
1065 });
1066 }
1067 tableInfo.value.loading = false
1068 }).catch(() => {
1069 tableInfo.value.loading = false
1070 });
1071 });
1072 };
1073
1074 const onUpload = (file, fileList) => {
1075 uploadFiles.value = fileList
1076 }
1077
1078 const uploadFile = (file) => {
1079 importData(file)
1080 }
1081
1082 const exportData = (type: any = null) => {
1083 let body = [treeCurrentNodeKey.value]
1084 exportStandardCodeData(body).then((res:any) => {
1085 if (res && !res.msg) {
1086 download(res, '标准代码表.xlsx', 'excel')
1087 } else {
1088 res?.msg && ElMessage.error(res?.msg);
1089 }
1090 })
1091 return
1092 }
1093
1094 const importData = (file: any = null) => {
1095 let params = new FormData()
1096 if (file) {
1097 params.append("file", file.raw);
1098 } else {
1099 if (uploadFiles.value.length) {
1100 uploadFiles.value.forEach((item: any, index: number) => {
1101 params.append("file", item.raw);
1102 });
1103 }
1104 }
1105
1106 params.append("dictionaryGuid", fieldSheetInfo.value.guid);
1107 showDictionary(params).then((res: any) => {
1108 if (res.code == proxy.$passCode) {
1109 let data = res.data ?? []
1110 setUploadDataInfo(data)
1111 } else {
1112 ElMessage({
1113 type: "error",
1114 message: res.msg,
1115 });
1116 }
1117 })
1118 }
1119
1120 // 生成表头
1121 const setUploadDataFields = (data) => {
1122 let fields: any = [], editInfo: any = {}
1123 data.map(item => {
1124 let fieldItem: any = {
1125 label: item.description, field: item.fieldName, width: 140
1126 }
1127 if (drawerInfo.value.type != 'detail') {
1128 fieldItem.type = 'edit'
1129 fieldItem.columClass = 'edit-colum'
1130 editInfo[item.fieldName] = {
1131 label: '',
1132 type: 'input',
1133 placeholder: '',
1134 field: item.fieldName,
1135 default: '',
1136 disabled: item.codeRuleGuid ? true : false,
1137 clearable: true,
1138 }
1139 }
1140 fields.push(fieldItem)
1141 })
1142 uploadTableFields.value = fields
1143 if (drawerInfo.value.type == 'detail') {
1144 fieldTableInfo.value.tableInfo.fields = uploadTableFields.value
1145 } else {
1146 uploadTableInfo.value.fields = uploadTableFields.value
1147 uploadTableInfo.value.editInfo = editInfo
1148 }
1149 }
1150
1151 // 生成表数据
1152 const setUploadDataInfo = async (info) => {
1153 let data = info
1154 if (drawerInfo.value.type == 'detail') {
1155 data = info.jsonArray ?? []
1156 const fields = info.schemaDataVOS ?? []
1157 setUploadDataFields(fields)
1158 }
1159
1160 if (drawerInfo.value.type == 'detail') {
1161 fieldTableInfo.value.tableInfo.data = data
1162 drawerInfo.value.container.contents = contents.value['field']
1163 } else {
1164 // 设置表数据
1165 data.map((item, i) => {
1166 item.STATUS = 'edit'
1167 item.STATE = 'Running'
1168 item.ROWID = `upload_${i}`
1169 })
1170 uploadTableData.value = data
1171 uploadTableInfo.value.data = uploadTableData.value
1172 }
1173 }
1174
1175 const loadDrawer = async () => {
1176 drawerInfo.value.visible = true;
1177 drawerInfo.value.type = 'add';
1178 drawerInfo.value.header.title = '新增标准代码';
1179 drawerInfo.value.footer.visible = true;
1180 // drawerInfo.value.header.title = '新增数据字典'
1181 // drawerInfo.value.type = 'add'
1182 // drawerInfo.value.modalClass = '';
1183 // await setFormItems()
1184 let fields = JSON.parse(JSON.stringify(orginFields))
1185 fields.map((item: any) => {
1186 if (!item.type || item.type != 'index') {
1187 item.type = 'edit'
1188 item.columClass = 'edit-colum'
1189 }
1190 })
1191 formTable.value.tableInfo.fields = fields
1192 formInfo.value.formInfo.items = formItems.value
1193 formTableData.value = JSON.parse(JSON.stringify(orginData))
1194 formTable.value.tableInfo.data = formTableData.value
1195 formTable.value.tableInfo.editInfo = JSON.parse(JSON.stringify(editTableInfo.value))
1196 formTable.value.tableInfo.readonly = false
1197 formTable.value.tableInfo.multiple = true
1198 formTable.value.tableInfo.actionInfo.show = true
1199 formTable.value.tableTool.visible = true
1200 drawerInfo.value.container.contents = contents.value['add']
1201 drawerInfo.value.visible = true
1202 console.log('table', formTable.value)
1203 console.log('formInfo', formInfo)
1204 setCodeOptions()
1205 };
1206
1207 const treeCurrentNodeKey = ref('')
1208 const batching = (type) => {
1209 if (type == 'delete') {
1210 if (selectRowData.value.length == 0) {
1211 ElMessage({
1212 type: 'error',
1213 message: '请选择需要删除的数据',
1214 })
1215 return
1216 }
1217 tableInfo.value.loading = true
1218 open("此操作将永久删除, 是否继续?", "warning", true);
1219 tableInfo.value.loading = false
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 };
1242
1243 const nodeClick = (data) => {
1244 console.log('treeNodeClick', data)
1245 drawerInfo.value.visible = false
1246 const changeCont = () => {
1247 nextTick(() => {
1248 treeInfo.value.currentNodeKey = data.value
1249 treeInfo.value.currentObj = data
1250 if (data.isLeaf) {
1251 showFiledsPage.value = true
1252 nextTick(() => {
1253 dictFiledsRef.value.standardGuid = data.value
1254 dictFiledsRef.value.standardName = data.label
1255 treeCurrentNodeKey.value = data.value
1256 dictFiledsRef.value.getFirstPageData()
1257 })
1258 } else {
1259 showFiledsPage.value = false
1260 getFirstPageData()
1261 }
1262 })
1263 }
1264 if (showFiledsPage.value) {
1265 const toChange = dictFiledsRef.value.checkSave()
1266 if (!toChange) {
1267 ElMessageBox.confirm(
1268 '存在未保存的数据,切换后会丢失,是否确定切换',
1269 '提示',
1270 {
1271 confirmButtonText: '确定',
1272 cancelButtonText: '取消',
1273 type: 'warning',
1274 }
1275 ).then(() => {
1276 changeCont()
1277 }).catch(() => {
1278 treeInfo.value.currentNodeKey = dictGuid.value
1279 })
1280 } else {
1281 changeCont()
1282 }
1283 } else {
1284 changeCont()
1285 }
1286 }
1287 function loadTreeNode (node, resolve) {
1288 console.log('node', node)
1289 if (node.isLeaf) {
1290 return resolve([]);
1291 }
1292 if (node.level === 1) {
1293 let standardTypeCode = node.data.value
1294 getStandardCodeStandard(standardTypeCode).then((res:any) => {
1295 if (res.code === proxy.$passCode) {
1296 let data = res.data || []
1297 let uniqList = Array.from(new Set(data)).map(item => {
1298 return {
1299 label: item,
1300 value: item,
1301 treeLevel: 2,
1302 standardTypeCode
1303 }
1304 })
1305 resolve(uniqList)
1306 }
1307 })
1308 }
1309 if (node.level === 2) {
1310 let params = {
1311 pageIndex: 1,
1312 pageSize: -1,
1313 standardTypeCode: node.data.standardTypeCode,
1314 standardName: node.data.value
1315 }
1316 getStandardCodeList(params).then((res:any) => {
1317 if (res.code === proxy.$passCode) {
1318 const list = res.data.records || []
1319 list.forEach(item => {
1320 item.isLeaf = true
1321 item.label = item.codeName
1322 item.value = item.guid
1323 })
1324 resolve(list)
1325 }
1326 })
1327 }
1328 }
1329
1330 // 设置详情信息
1331 const setDetailInfo = () => {
1332 const row = JSON.parse(JSON.stringify(currTableData.value))
1333 formItems.value.forEach(item => {
1334 item.default = row[item.field] || ''
1335 })
1336 formInfo.value.formInfo.items = formItems.value
1337 formTableData.value = row.standardCodeFields.map(item => {
1338 item.STATUS = 'edit'
1339 return item
1340 })
1341
1342 let fields = JSON.parse(JSON.stringify(orginFields))
1343 fields.map((item: any) => {
1344 if (item.type != 'index') {
1345 item.type = 'edit'
1346 item.columClass = 'edit-colum'
1347 }
1348 })
1349 formTable.value.tableInfo.fields = fields
1350 formTable.value.tableInfo.data = formTableData.value
1351 formTable.value.tableInfo.editInfo = JSON.parse(JSON.stringify(editTableInfo.value))
1352 formTable.value.tableInfo.readonly = false
1353 formTable.value.tableInfo.multiple = true
1354 formTable.value.tableInfo.actionInfo.show = true
1355 formTable.value.tableTool.visible = true
1356 drawerInfo.value.container.contents = contents.value['add']
1357
1358 drawerInfo.value.visible = true
1359 setCodeOptions()
1360 }
1361
1362 const saveData = async (params) => {
1363 // const passInfo = await checkParamsData()
1364 console.log('params', params)
1365 let request = drawerInfo.value.type === 'add' ? saveStandardCode : updateStandardCode
1366 request(params).then((res:any) => {
1367 if (res.code === proxy.$passCode) {
1368 ElMessage.success('操作成功')
1369 getTreeData()
1370 drawerInfo.value.visible = false
1371 }
1372 }).finally(() => {
1373 drawerInfo.value.footer.btns.map((item: any) => item.disabled = false)
1374 })
1375 }
1376
1377 const scrollTable = (rowInfo) => {
1378 nextTick(() => {
1379 const drawerBody = document.getElementsByClassName('el-drawer__body')[0];
1380 const tableListRef = drawerRef.value.getDrawerConRef("drawerTableRef");
1381 if (!tableListRef) return;
1382 //设置选中表格当前新增行。
1383 tableListRef.setCurrentRow(rowInfo);
1384 drawerBody.scrollTop = drawerBody.scrollHeight;
1385 let table = tableListRef.layout.table.refs;
1386 // 获取表格滚动元素
1387 let tableScrollEle =
1388 table.bodyWrapper.firstElementChild.firstElementChild;
1389 // 设置表格滚动的位置
1390 tableScrollEle.scrollTop = tableScrollEle.scrollHeight;
1391 });
1392 };
1393
1394 const drawerBtnClick = (btn, info) => {
1395 console.log('btn', btn, info)
1396 console.log('table', formTable.value)
1397 let params = {
1398 standardCodeFields: formTable.value.tableInfo.data.map(item => {
1399 let obj = {
1400 fieldName: item.fieldName,
1401 guid: item.guid || null,
1402 standardGuid: item.standardGuid || null
1403 }
1404 return obj
1405 }),
1406 ...info
1407 }
1408 if (params.typeCode === '1') {
1409 delete params.hierarchy
1410 }
1411 if (drawerInfo.value.type === 'edit') {
1412 params.guid = currTableData.value.guid
1413 }
1414 if (btn.value == 'submit' || btn.value == 'saveAndAdd') {
1415 drawerInfo.value.footer.btns.map((item: any) => item.disabled = true)
1416 saveData(params)
1417 } else {
1418 drawerInfo.value.footer.btns.map((item: any) => delete item.disabled)
1419 nextTick(() => {
1420 drawerInfo.value.visible = false
1421 })
1422 }
1423 }
1424
1425 const radioGroupChange = async (val, info) => {
1426 dictionaryType.value = Number(val)
1427 await setFormItems(info)
1428 setGroup()
1429 }
1430
1431 // 切换结构类型 设置选项显隐
1432 const setGroup = () => {
1433 let dictionaryOpts = formItems.value.at(-1).children
1434 if (dictionaryType.value == 1) {
1435 dictionaryOpts[2].visible = false
1436 dictionaryOpts[3].visible = false
1437 } else if (dictionaryType.value == 2) {
1438 dictionaryOpts[2].visible = false
1439 dictionaryOpts[3].block = false
1440 dictionaryOpts[3].visible = true
1441 } else if (dictionaryType.value == 3) {
1442 dictionaryOpts[2].visible = true
1443 dictionaryOpts[3].block = true
1444 dictionaryOpts[3].visible = true
1445 } else if (dictionaryType.value == 4) {
1446 dictionaryOpts[2].visible = false
1447 dictionaryOpts[3].block = true
1448 dictionaryOpts[3].visible = true
1449 }
1450 formInfo.value.formInfo.items = formItems.value
1451 }
1452
1453 onActivated(() => {
1454 // getCodeRuleData();
1455 // let guid = cacheStore.getCatch('dictionaryGuid');
1456 // if (guid) {
1457 // nextTick(() => {
1458 // if (treePromise.value) {
1459 // treePromise.value.then(() => {
1460 // nodeClick({ guid: guid, dictionaryType: '1', type: 2 });
1461 // cacheStore.setCatch('dictionaryGuid', null);
1462 // });
1463 // } else {
1464 // nodeClick({ guid: guid, type: 1 });
1465 // cacheStore.setCatch('dictionaryGuid', null);
1466 // }
1467 // });
1468 // }
1469 })
1470
1471 onBeforeMount(() => {
1472 // getDataType()
1473 getTreeData()
1474 getParamsList({ dictType: '发布单位' }).then((res:any) => {
1475 if (res.code === proxy.$passCode) {
1476 const data = res.data || []
1477 publishingUnitCodeOptions.value = data
1478 }
1479 })
1480 })
1481
1482 onMounted(() => {
1483 let dom = document.getElementById('main-app');
1484 if (dom) {
1485 dom.addEventListener('click', (event: any) => {
1486 // 新建时不要处理。
1487 if (drawerInfo.value.header.title == '数据字典详情' && !event.target?.classList?.contains('drawer-detail-cell')) {
1488 if (drawerInfo.value.visible) {
1489 drawerInfo.value.visible = false;
1490 }
1491 }
1492 });
1493 }
1494 });
1495
1496 </script>
1497
1498 <template>
1499 <div class="container_wrap full flex">
1500 <div class="aside_wrap">
1501 <div class="aside_title">标准代码列表</div>
1502 <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" @loadNode="loadTreeNode"/>
1503 </div>
1504 <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" />
1505 <div class="main_wrap" v-else>
1506 <div class="table_tool_wrap">
1507 <div class="tools_btns">
1508 <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button>
1509 <el-button @click="batching('delete')" v-preReClick>批量删除</el-button>
1510 <el-button @click="batching('export')" v-preReClick>批量导入</el-button>
1511 </div>
1512 <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入代码名称搜索"
1513 :suffix-icon="Search" clearable @change="val => getFirstPageData()" />
1514 </div>
1515 <div class="table_panel_wrap full">
1516 <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tableSelectionChange="tableSelectionChange"
1517 @tablePageChange="tablePageChange" @tableSwitchBeforeChange="tableSwitchBeforeChange" />
1518 </div>
1519 </div>
1520 <Drawer ref="drawerRef" :drawerInfo="drawerInfo" @drawerBtnClick="drawerBtnClick"
1521 @radioGroupChange="radioGroupChange" @drawerTableBtnClick="tableBtnClick"
1522 @drawerTableSelectionChange="tableSelectionChange" @drawerTableToolBtnClick="toolBtnClick"
1523 @drawerTableInputChange="tableInputChange" @drawerToolBtnClick="toolBtnClick" @onUpload="onUpload"
1524 @uploadFile="uploadFile" @uploadBtnClick="toolBtnClick" />
1525 </div>
1526 </template>
1527
1528 <style lang="scss" scoped>
1529 .container_wrap {
1530 .aside_wrap {
1531 width: 200px;
1532 }
1533 }
1534
1535 .tree_panel {
1536 height: 100%;
1537 padding-top: 0;
1538
1539 :deep(.el-tree) {
1540 margin: 0;
1541 height: calc(100% - 68px);
1542 overflow: hidden auto;
1543 }
1544 }
1545 </style>
1 <route lang="yaml">
2 name: metadataStandardCodetable
3 </route>
4
5 <script lang="ts" setup name="metadataStandardCodetable">
6 import { ref, reactive } from 'vue';
7 import { ElMessage } from "element-plus";
8 import Tree from '@/components/Tree/index.vue';
9 import TableTools from '@/components/Tools/table_tools.vue';
10 import { Search } from '@element-plus/icons-vue'
11 import { useRouter, useRoute } from "vue-router";
12 import { TableColumnWidth } from '@/utils/enum';
13 import { commonPageConfig } from '@/components/PageNav/index';
14 import { getParamsList } from '@/api/modules/dataAsset'
15 import { getStandardCodeList, saveStandardCode, updateStandardCode } from '@/api/modules/dataMetaService'
16
17 const { proxy } = getCurrentInstance() as any;
18 const router = useRouter();
19
20 const treeInfo:any = reactive({
21 id: "data-pickup-tree",
22 filter: true,
23 queryValue: "",
24 queryPlaceholder: "请输入关键字搜索",
25 props: {
26 label: "label",
27 value: "value",
28 },
29 nodeKey: 'value',
30 expandedKey: ['01'],
31 currentNodeKey: '01',
32 expandOnNodeClick: false,
33 data: [],
34 loading: false
35 });
36 function nodeClick (data) {
37
38 }
39
40 /** 分页及搜索传参信息配置。 */
41 const tableSearchInput = ref('')
42 function getFirstPageData () {
43 page.value.curr = 1
44 toSearch({})
45 }
46 function toSearch (val: any, clear: boolean = false) {
47 let params: any = Object.keys(val).length ? { ...val } : {}
48 params.pageIndex = page.value.curr;
49 params.pageSize = page.value.limit;
50 params.name = tableSearchInput.value
51 getTableData(params);
52 }
53 const page = ref({
54 ...commonPageConfig,
55 collectTaskName: '',
56 dataSourceGuid: '',
57 taskState: null
58 });
59 const tableInfo = ref({
60 id: 'data-source-table',
61 fields: [
62 { label: '序号', type: 'index', width: TableColumnWidth.INDEX, align: 'center' },
63 { label: '代码名称', field: '1', width: 140 },
64 { label: '标准号', field: '2', width: 140 },
65 { label: '标准名称', field: '3', width: 140 },
66 { label: '启用状态', field: '4', width: 140 },
67 { label: '创建时间', field: '5', width: 140 }
68 ],
69 data: [],
70 page: {
71 type: 'normal',
72 rows: 0,
73 ...page.value
74 },
75 actionInfo: {
76 label: '操作',
77 type: 'btn',
78 width: 160,
79 btns: scope => {
80 let row = scope.row
81 return [
82 { label: '编辑', value: 'edit' },
83 { label: '删除', value: 'delete' },
84 ]
85 }
86 },
87 loading: false
88 })
89 function tableBtnClick (scope, btn) {
90
91 }
92 function tablePageChange (info) {
93 page.value.curr = Number(info.curr);
94 page.value.limit = Number(info.limit);
95 // getTableData();
96 }
97 function getTableData (params) {
98
99 }
100 function handleCreate () {
101 drawerInfo.value.visible = true;
102 drawerInfo.value.type = 'add';
103 drawerInfo.value.header.title = '新增标准代码';
104 drawerInfo.value.footer.visible = true;
105 }
106
107 // drawer form
108 const standardOptions = ref([])
109 const publishingUnitCodeOptions = ref([])
110 const formRef = ref()
111 const formItems: any = ref([
112 {
113 label: '标准类型',
114 type: 'select',
115 placeholder: '请选择',
116 field: 'standardTypeCode',
117 default: '',
118 options: standardOptions,
119 clearable: true,
120 required: true
121 },
122 {
123 label: '代码名称',
124 type: 'input',
125 placeholder: '请输入',
126 field: 'codeName',
127 default: '',
128 maxlength: 20,
129 clearable: true,
130 required: true
131 },
132 {
133 label: '标准号',
134 type: 'input',
135 placeholder: '请输入',
136 field: 'standard',
137 default: '',
138 maxlength: 50,
139 clearable: true,
140 required: true
141 },
142 {
143 label: '标准名称',
144 type: 'input',
145 placeholder: '请输入',
146 field: 'standardName',
147 default: '',
148 maxlength: 20,
149 clearable: true,
150 required: true
151 },
152 {
153 label: '发布单位',
154 type: 'select',
155 placeholder: '请输入',
156 field: 'publishingUnitCode',
157 default: '',
158 options: publishingUnitCodeOptions,
159 clearable: true,
160 required: true
161 },
162 {
163 label: '排序',
164 type: 'inputNumber',
165 placeholder: '请输入',
166 field: 'orderNum',
167 default: '',
168 maxlength: 2,
169 clearable: true,
170 required: true
171 },
172 {
173 label: '启用状态',
174 type: 'switch',
175 field: 'bizState',
176 default: false
177 },
178 {
179 label: '代码类型',
180 type: 'select',
181 placeholder: '请选择',
182 field: 'typeCode',
183 default: '1',
184 options: [
185 { label: '列表结构', value: '1' },
186 { label: '层级结构', value: '2' }
187 ],
188 clearable: true,
189 required: true
190 },
191 {
192 label: '编码字段',
193 type: 'select',
194 placeholder: '请选择',
195 field: 'codeFields',
196 default: [],
197 options: [
198 { label: 'code', value: 'code' },
199 { label: 'name', value: 'name' }
200 ],
201 clearable: true,
202 required: true,
203 multiple: true
204 },
205 {
206 label: '编码名称',
207 type: 'select',
208 placeholder: '请选择',
209 field: 'codeFieldName',
210 default: '',
211 options: [
212 { label: 'code', value: 'code' },
213 { label: 'name', value: 'name' }
214 ],
215 clearable: true,
216 required: true
217 },
218 {
219 label: '层级结构',
220 type: 'input',
221 placeholder: '请输入',
222 field: 'hierarchy',
223 default: '',
224 clearable: true,
225 required: true
226 }
227 ])
228 const formRules = ref({
229
230 })
231 const formInfo = ref({
232 type: 'form',
233 title: '',
234 col: 'span',
235 formInfo: {
236 id: 'add-dict-form',
237 col: 'col2',
238 items: formItems.value,
239 formRules: formRules.value
240 }
241 })
242 const formTable = reactive({
243 type: "table",
244 title: "定义表结构",
245 col: 'no-margin',
246 style: {
247 height: 'calc(100% - 234px)'
248 },
249 tableInfo: {
250 id: "role-authority-table",
251 multiple: true,
252 minHeight: 'unset',
253 maxHeight: '100%',
254 fields: [
255 { label: '序号', type: 'index', width: 56, align: 'center' },
256 { label: '字段名称', field: 'fieldName', width: 140, type: 'edit', customClass: 'edit-colum'}
257 ],
258 data: [{ fieldName: '1', index: 0}],
259 showPage: false,
260 actionInfo: {
261 show: true,
262 label: "操作",
263 type: "btn",
264 width: 60,
265 fixed: 'right',
266 btns: [{ label: "删除", value: "remove" }]
267 },
268 editInfo: {
269 fieldName: {
270 field: 'fieldName',
271 label: '字段名称',
272 type: 'input',
273 clearable: true,
274 maxlength: 20
275 }
276 },
277 readonly: false,
278 col: 'auto-height',
279 style: { height: 'calc(100% - 40px)'},
280 loading: false
281 },
282 tableTool: {
283 col: 'float-right',
284 visible: true,
285 btns: [
286 { label: "新增行", value: "tableAdd", type: 'primary' },
287 { label: "批量删除", value: "tableDelete" },
288 ]
289 },
290 })
291 // 新增drawer
292 const drawerInfo = ref({
293 visible: false,
294 direction: 'rtl',
295 size: 550,
296 header: {
297 title: '新增标准代码',
298 },
299 type: '',
300 container: {
301 contents: [formInfo.value, formTable],
302 },
303 footer: {
304 visible: true,
305 btns: [
306 { type: 'default', label: '取消', value: 'cancel' },
307 { type: 'primary', label: '保存', value: 'save' },
308 { type: 'primary', label: '保存并添加数据', value: 'saveAndAdd', visible: true }
309 ]
310 }
311 })
312 async function drawerBtnClick (btn, info) {
313
314 }
315 function drawerTableToolBtnClick (btn, data) {
316 console.log(btn, data)
317 if (btn.value === 'tableAdd') {
318 // 定义表结构新增行
319 let rowInfo = { fieldName: '' }
320 formTable.tableInfo.data.push(rowInfo)
321 }
322 }
323
324 onMounted(() => {
325 getParamsList({ dictType: '标准类型'}).then((res:any) => {
326 if (res.code === proxy.$passCode) {
327 const data = res.data || []
328 treeInfo.data = data
329 standardOptions.value = data
330 // 默认展开第一个
331 if (data.length === 0) return
332 let params = {
333 pageIndex: 1,
334 pageSize: 100,
335 standardTypeCode: data[0].value,
336 codeName: '标准类型'
337 }
338 getStandardCodeList(params)
339 }
340 })
341 getParamsList({ dictType: '发布单位' }).then((res:any) => {
342 if (res.code === proxy.$passCode) {
343 const data = res.data || []
344 publishingUnitCodeOptions.value = data
345 }
346 })
347 })
348 </script>
349
350 <template>
351 <div class="container_wrap full flex">
352 <div class="aside_wrap">
353 <div class="aside_title">标准代码列表</div>
354 <Tree :treeInfo="treeInfo" @nodeClick="nodeClick" />
355 </div>
356 <div class="main_wrap">
357 <div class="table_tool_wrap">
358 <div class="tools_btns">
359 <el-button type="primary" @click="handleCreate">新建</el-button>
360 <el-button>批量删除</el-button>
361 <el-button>批量导入</el-button>
362 </div>
363 <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="代码名称搜索"
364 :suffix-icon="Search" clearable @change="val => getFirstPageData()" />
365 </div>
366 <div class="table_panel_wrap">
367 <Table :tableInfo="tableInfo" @tableBtnClick="tableBtnClick" @tablePageChange="tablePageChange"
368 />
369 </div>
370 </div>
371 <Drawer
372 :drawerInfo="drawerInfo"
373 @drawerBtnClick="drawerBtnClick"
374 ref="drawerRef"
375 @drawerTableToolBtnClick="drawerTableToolBtnClick"
376 >
377 <!-- <Form ref="formRef"
378 :itemList="formItems"
379 formId="basic-info-form"
380 :rules="formRules"
381 /> -->
382 </Drawer>
383 </div>
384 </template>
385
386 <style scoped lang="scss">
387 .container_wrap {
388
389 .aside_wrap {
390 width: 200px;
391 }
392
393 .main_wrap {
394 padding: 10px 20px;
395
396
397 :deep(.el-tabs) {
398 height: 100%;
399
400 .el-tabs__header {
401 margin-bottom: 0;
402 }
403
404 .el-tabs__item {
405 height: 32px;
406 padding: 0px;
407 width: 144px;
408
409 &:last-child {
410 width: 130px;
411 }
412 }
413
414 .el-tabs__content {
415 height: calc(100% - 32px);
416 }
417
418 .el-tab-pane {
419 padding: 0px 16px;
420 height: 100%;
421 }
422 }
423 }
424
425 }
426
427 .tree_panel {
428 height: calc(100% - 36px);
429 padding-top: 0;
430
431 :deep(.el-tree) {
432 margin: 0;
433 overflow: hidden auto;
434 }
435 }
436
437 .table_tool_wrap {
438 display: flex;
439 flex-direction: column;
440
441 .el-input {
442 width: 230px;
443 height: 32px;
444 }
445
446 :deep(.el-input) {
447 .el-input__suffix-inner {
448 flex-direction: row-reverse;
449 -webkit-flex-direction: row-reverse;
450 display: flex;
451 }
452 }
453 }
454
455 .table_panel_wrap {
456 height: calc(100% - 44px);
457 }
458 </style>
...\ No newline at end of file ...\ No newline at end of file
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>
1 <template>
2 <div>元数据标准查询</div>
3 </template>
4
5 <script>
6 export default {
7 }
8 </script>
9
10 <style>
11 </style>
...\ No newline at end of file ...\ No newline at end of file
1 <template>
2 <div>元数据标准</div>
3 </template>
4
5 <script>
6 export default {
7 }
8 </script>
9
10 <style>
11 </style>
...\ No newline at end of file ...\ 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!