9d37357a by fanguang

Merge branch 'develop-fan' into develop

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