元数据标准
Showing
3 changed files
with
743 additions
and
326 deletions
| ... | @@ -273,3 +273,37 @@ export const getStandardCodeDetail = (guid) => request({ | ... | @@ -273,3 +273,37 @@ export const getStandardCodeDetail = (guid) => request({ |
| 273 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/detail?guid=${guid}`, | 273 | url: `${import.meta.env.VITE_APP_STANDARD_URL}/standard-code/detail?guid=${guid}`, |
| 274 | method: 'get', | 274 | method: 'get', |
| 275 | }) | 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 | }) | ||
| ... | \ 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> |
| ... | @@ -9,11 +9,14 @@ import { Search } from '@element-plus/icons-vue' | ... | @@ -9,11 +9,14 @@ import { Search } from '@element-plus/icons-vue' |
| 9 | import Tree from '@/components/Tree/index.vue' | 9 | import Tree from '@/components/Tree/index.vue' |
| 10 | import Table from '@/components/Table/index.vue' | 10 | import Table from '@/components/Table/index.vue' |
| 11 | import Drawer from '@/components/Drawer/index.vue' | 11 | import Drawer from '@/components/Drawer/index.vue' |
| 12 | // import DictFileds from './dictFileds.vue' | 12 | import DictFileds from './components/dictFileds.vue' |
| 13 | import useCatchStore from "@/store/modules/catch"; | 13 | import useCatchStore from "@/store/modules/catch"; |
| 14 | import { download } from '@/utils/common' | 14 | import { download } from '@/utils/common' |
| 15 | import { getParamsList } from '@/api/modules/dataAsset' | 15 | import { getParamsList } from '@/api/modules/dataAsset' |
| 16 | import { getStandardCodeList, saveStandardCode, updateStandardCode, getStandardCodeDetail } from '@/api/modules/dataMetaService' | 16 | import { getStandardCodeList, saveStandardCode, |
| 17 | updateStandardCode, getStandardCodeDetail, | ||
| 18 | deleteStandardCode, getStandardCodeStandard | ||
| 19 | } from '@/api/modules/dataMetaService' | ||
| 17 | import { | 20 | import { |
| 18 | addDictionary, | 21 | addDictionary, |
| 19 | deleteDictionary, | 22 | deleteDictionary, |
| ... | @@ -71,13 +74,16 @@ const treeInfo = ref({ | ... | @@ -71,13 +74,16 @@ const treeInfo = ref({ |
| 71 | props: { | 74 | props: { |
| 72 | label: "label", | 75 | label: "label", |
| 73 | value: "value", | 76 | value: "value", |
| 77 | isLeaf: "isLeaf", | ||
| 74 | }, | 78 | }, |
| 79 | lazy: true, | ||
| 75 | nodeKey: 'value', | 80 | nodeKey: 'value', |
| 76 | expandedKey: ['01'], | 81 | expandedKey: ['01'], |
| 77 | currentNodeKey: '01', | 82 | currentNodeKey: '01', |
| 78 | data: [], | 83 | data: [], |
| 79 | expandOnNodeClick: false, | 84 | expandOnNodeClick: false, |
| 80 | loading: false | 85 | loading: false, |
| 86 | currentObj: {} | ||
| 81 | }); | 87 | }); |
| 82 | 88 | ||
| 83 | const standardOptions = ref([]) | 89 | const standardOptions = ref([]) |
| ... | @@ -106,7 +112,8 @@ const tableInfo: any = ref({ | ... | @@ -106,7 +112,8 @@ const tableInfo: any = ref({ |
| 106 | { label: '代码名称', field: 'codeName', width: 140 }, | 112 | { label: '代码名称', field: 'codeName', width: 140 }, |
| 107 | { label: '标准号', field: 'standard', width: 140 }, | 113 | { label: '标准号', field: 'standard', width: 140 }, |
| 108 | { label: '标准名称', field: 'standardName', width: 140 }, | 114 | { label: '标准名称', field: 'standardName', width: 140 }, |
| 109 | { label: '启用状态', field: 'bizState', type: 'switch', activeText: '启用', inactiveText: '停用', activeValue: 1, inactiveValue: 0, switchWidth: 56, width: 100, align: 'center' }, | 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' }, | ||
| 110 | { label: '创建时间', field: 'createTime', width: 140 } | 117 | { label: '创建时间', field: 'createTime', width: 140 } |
| 111 | ], | 118 | ], |
| 112 | data: [], | 119 | data: [], |
| ... | @@ -260,7 +267,7 @@ const formItems: any = ref([ | ... | @@ -260,7 +267,7 @@ const formItems: any = ref([ |
| 260 | { | 267 | { |
| 261 | label: '发布单位', | 268 | label: '发布单位', |
| 262 | type: 'select', | 269 | type: 'select', |
| 263 | placeholder: '请输入', | 270 | placeholder: '请选择', |
| 264 | field: 'publishingUnitCode', | 271 | field: 'publishingUnitCode', |
| 265 | default: '', | 272 | default: '', |
| 266 | options: publishingUnitCodeOptions, | 273 | options: publishingUnitCodeOptions, |
| ... | @@ -287,7 +294,7 @@ const formItems: any = ref([ | ... | @@ -287,7 +294,7 @@ const formItems: any = ref([ |
| 287 | }, | 294 | }, |
| 288 | { | 295 | { |
| 289 | label: '代码类型', | 296 | label: '代码类型', |
| 290 | type: 'select', | 297 | type: 'radio-panel', |
| 291 | placeholder: '请选择', | 298 | placeholder: '请选择', |
| 292 | field: 'typeCode', | 299 | field: 'typeCode', |
| 293 | default: '1', | 300 | default: '1', |
| ... | @@ -332,57 +339,19 @@ const formItems: any = ref([ | ... | @@ -332,57 +339,19 @@ const formItems: any = ref([ |
| 332 | field: 'hierarchy', | 339 | field: 'hierarchy', |
| 333 | default: '', | 340 | default: '', |
| 334 | clearable: true, | 341 | clearable: true, |
| 335 | required: true | 342 | visible: true |
| 336 | } | 343 | } |
| 337 | ]) | 344 | ]) |
| 338 | const formRules: any = ref({ | 345 | const formRules: any = ref({ |
| 339 | chName: [ | 346 | standardTypeCode: { required: true, message: '请选择标准类型' }, |
| 340 | { | 347 | codeName: { required: true, message: '请输入代码名称' }, |
| 341 | required: true, | 348 | standard: { required: true, message: '请输入标准号' }, |
| 342 | message: "请填写中文名", | 349 | standardName: { required: true, message: '请输入标准名称' }, |
| 343 | trigger: "blur", | 350 | publishingUnitCode: { required: true, message: '请选择发布单位' }, |
| 344 | }, | 351 | orderNum: { required: true, message: '请输入排序' }, |
| 345 | ], | 352 | typeCode: { required: true, message: '请选择代码类型' }, |
| 346 | enName: [ | 353 | codeFields: { required: true, message: '请选择编码字段' }, |
| 347 | { | 354 | codeFieldName: { required: true, message: '请选择编码名称' } |
| 348 | required: true, | ||
| 349 | message: "请填写英文名", | ||
| 350 | trigger: "blur", | ||
| 351 | }, | ||
| 352 | ], | ||
| 353 | orderNum: [{ | ||
| 354 | validator: (rule: any, value: any, callback: any) => { | ||
| 355 | if (value === 0) { | ||
| 356 | callback(); | ||
| 357 | return; | ||
| 358 | } | ||
| 359 | if (!value) { | ||
| 360 | callback(new Error('请填写排序')); | ||
| 361 | return; | ||
| 362 | } | ||
| 363 | const r = /(^[0-9]([0-9]*)$|^[0-9]$)/; // 正整数(可以以0打头) | ||
| 364 | if (value && !r.test(value)) { | ||
| 365 | callback(new Error('请填写大于或等于零整数')); | ||
| 366 | return; | ||
| 367 | } | ||
| 368 | callback(); | ||
| 369 | }, | ||
| 370 | trigger: "blur", | ||
| 371 | }], | ||
| 372 | codeColumn: [ | ||
| 373 | { | ||
| 374 | required: true, | ||
| 375 | message: "请填写编码字段", | ||
| 376 | trigger: "blur", | ||
| 377 | }, | ||
| 378 | ], | ||
| 379 | codeName: [ | ||
| 380 | { | ||
| 381 | required: true, | ||
| 382 | message: "请填写编码名称", | ||
| 383 | trigger: "blur", | ||
| 384 | }, | ||
| 385 | ], | ||
| 386 | }) | 355 | }) |
| 387 | const formInfo = ref({ | 356 | const formInfo = ref({ |
| 388 | type: 'form', | 357 | type: 'form', |
| ... | @@ -477,7 +446,7 @@ const formTable = ref({ | ... | @@ -477,7 +446,7 @@ const formTable = ref({ |
| 477 | col: 'float-right', | 446 | col: 'float-right', |
| 478 | visible: true, | 447 | visible: true, |
| 479 | btns: [ | 448 | btns: [ |
| 480 | { label: "新增行", value: "add-row", type: 'primary', plain: true }, | 449 | { label: "新增行", value: "add-row", type: 'primary' }, |
| 481 | { label: "批量删除", value: "remove_batch" }, | 450 | { label: "批量删除", value: "remove_batch" }, |
| 482 | ] | 451 | ] |
| 483 | }, | 452 | }, |
| ... | @@ -708,79 +677,27 @@ const getCodeRuleData = () => { | ... | @@ -708,79 +677,27 @@ const getCodeRuleData = () => { |
| 708 | 677 | ||
| 709 | const treePromise = ref(); | 678 | const treePromise = ref(); |
| 710 | 679 | ||
| 711 | // 获取数据字典树形数据 | ||
| 712 | // const getTreeData = (needClick = false, currData = {}) => { | ||
| 713 | // const params = { | ||
| 714 | // paramCode: '标准类型' | ||
| 715 | // } | ||
| 716 | // treeInfo.value.loading = true | ||
| 717 | // treePromise.value = getDictionaryTree(params).then((res: any) => { | ||
| 718 | // treePromise.value = null; | ||
| 719 | // if (res.code == proxy.$passCode) { | ||
| 720 | // const data = res.data ?? [] | ||
| 721 | // const treeList = data.filter(item => item.children && item.children.length) | ||
| 722 | // treeData.value = treeList | ||
| 723 | // treeInfo.value.data = treeList | ||
| 724 | // if (treeList.length) { | ||
| 725 | // dictType.value = dictType.value == -1 ? Number(treeList[0].dictionaryType) : dictType.value; | ||
| 726 | // expandedKey.value = expandedKey.value.length == 0 ? [treeList[0].guid] : expandedKey.value; | ||
| 727 | // if (!needClick && !cacheStore.getCatch('dictionaryGuid')) { | ||
| 728 | // currentNodeKey.value = currentNodeKey.value == '' ? treeList[0].guid : currentNodeKey.value | ||
| 729 | // nextTick(() => { | ||
| 730 | // treeInfo.value.currentNodeKey = currentNodeKey.value | ||
| 731 | // treeInfo.value.expandedKey = expandedKey.value | ||
| 732 | // }) | ||
| 733 | // } else { | ||
| 734 | // nextTick(() => { | ||
| 735 | // treeInfo.value.expandedKey = expandedKey.value; | ||
| 736 | // }); | ||
| 737 | // } | ||
| 738 | // getFirstPageData() | ||
| 739 | // } else {//处理数据被删除完成,表格没刷新的情况。 | ||
| 740 | // tableInfo.value.data = []; | ||
| 741 | // tableInfo.value.page.rows = 0; | ||
| 742 | // } | ||
| 743 | // } else { | ||
| 744 | // ElMessage({ | ||
| 745 | // type: 'error', | ||
| 746 | // message: res.msg, | ||
| 747 | // }) | ||
| 748 | // } | ||
| 749 | // treeInfo.value.loading = false; | ||
| 750 | // if (needClick) { | ||
| 751 | // nextTick(() => { | ||
| 752 | // nodeClick(currData); | ||
| 753 | // }); | ||
| 754 | // } | ||
| 755 | // }).catch(() => { | ||
| 756 | // treeInfo.value.loading = false | ||
| 757 | // }) | ||
| 758 | // } | ||
| 759 | const getTreeData = (needClick = false, currData = {}) => { | 680 | const getTreeData = (needClick = false, currData = {}) => { |
| 760 | getParamsList({ dictType: '标准类型'}).then((res:any) => { | 681 | getParamsList({ dictType: '标准类型'}).then((res:any) => { |
| 761 | if (res.code === proxy.$passCode) { | 682 | if (res.code === proxy.$passCode) { |
| 762 | const data = res.data || [] | 683 | const data = res.data || [] |
| 684 | data.forEach(item => { | ||
| 685 | item.treeLevel = 1 | ||
| 686 | }) | ||
| 763 | treeInfo.value.data = data | 687 | treeInfo.value.data = data |
| 764 | standardOptions.value = data | 688 | standardOptions.value = data |
| 765 | // 默认展开第一个 | 689 | // 默认展开第一个 |
| 766 | if (data.length === 0) return | 690 | if (data.length === 0) return |
| 767 | let params = { | 691 | let params = { |
| 768 | pageIndex: 1, | 692 | pageIndex: 1, |
| 769 | pageSize: -1, | 693 | pageSize: 50, |
| 770 | standardTypeCode: data[0].value, | 694 | standardTypeCode: data[0].value, |
| 771 | // codeName: '标准类型' | 695 | // codeName: '标准类型' |
| 772 | } | 696 | } |
| 773 | getStandardCodeList(params).then((res:any) => { | 697 | getStandardCodeList(params).then((res:any) => { |
| 774 | if (res.code === proxy.$passCode) { | 698 | if (res.code === proxy.$passCode) { |
| 775 | let data = res.data | 699 | let data = res.data |
| 776 | let list = res.data.records || [] | 700 | tableInfo.value.data = data.records |
| 777 | list = list.map(item => { | ||
| 778 | item.label = item.codeName | ||
| 779 | item.value = item.guid | ||
| 780 | return item | ||
| 781 | }) | ||
| 782 | treeInfo.value.data[0].children = list | ||
| 783 | tableInfo.value.data = list | ||
| 784 | tableInfo.value.page.limit = data.pageSize | 701 | tableInfo.value.page.limit = data.pageSize |
| 785 | tableInfo.value.page.curr = data.pageIndex | 702 | tableInfo.value.page.curr = data.pageIndex |
| 786 | tableInfo.value.page.rows = data.totalRows | 703 | tableInfo.value.page.rows = data.totalRows |
| ... | @@ -797,11 +714,17 @@ const getFirstPageData = () => { | ... | @@ -797,11 +714,17 @@ const getFirstPageData = () => { |
| 797 | 714 | ||
| 798 | const toSearch = (val: any, clear: boolean = false) => { | 715 | const toSearch = (val: any, clear: boolean = false) => { |
| 799 | let params: any = Object.keys(val).length ? { ...val } : {} | 716 | let params: any = Object.keys(val).length ? { ...val } : {} |
| 717 | let { currentNodeKey, currentObj } = treeInfo.value | ||
| 718 | console.log('currentObj', currentObj) | ||
| 800 | params.pageIndex = page.value.curr; | 719 | params.pageIndex = page.value.curr; |
| 801 | params.pageSize = page.value.limit; | 720 | params.pageSize = page.value.limit; |
| 802 | params.standardTypeCode = treeInfo.value.currentNodeKey | 721 | params.codeName = tableSearchInput.value |
| 803 | // params.dictionaryType = dictType.value | 722 | if (currentObj.treeLevel === 1) { |
| 804 | // params.name = tableSearchInput.value | 723 | params.standardTypeCode = currentNodeKey |
| 724 | } else if (currentObj.treeLevel === 2) { | ||
| 725 | params.standardTypeCode = currentObj.standardTypeCode | ||
| 726 | params.standardName = currentObj.value | ||
| 727 | } | ||
| 805 | getTableData(params); | 728 | getTableData(params); |
| 806 | }; | 729 | }; |
| 807 | 730 | ||
| ... | @@ -1066,62 +989,11 @@ const tableBtnClick = (scope, btn) => { | ... | @@ -1066,62 +989,11 @@ const tableBtnClick = (scope, btn) => { |
| 1066 | formTable.value.tableInfo.loading = false | 989 | formTable.value.tableInfo.loading = false |
| 1067 | drawerInfo.value.loading = false; | 990 | drawerInfo.value.loading = false; |
| 1068 | }) | 991 | }) |
| 1069 | } else if (type == 'remove') { | ||
| 1070 | const rowIndex = scope.$index | ||
| 1071 | if (formItems.value.length == 2) { | ||
| 1072 | uploadTableData.value.splice(rowIndex, 1) | ||
| 1073 | } else { | ||
| 1074 | if (row.guid !== undefined) { | ||
| 1075 | formTable.value.tableInfo.loading = true | ||
| 1076 | checkDelete().then((res: any) => { | ||
| 1077 | if (res) { | ||
| 1078 | ElMessageBox.confirm("数据字典有数据, 确定是否继续删除?", "提示", { | ||
| 1079 | confirmButtonText: "确定", | ||
| 1080 | cancelButtonText: "取消", | ||
| 1081 | type: 'warning', | ||
| 1082 | }).then(() => { | ||
| 1083 | formTableData.value.splice(rowIndex, 1) | ||
| 1084 | }) | ||
| 1085 | } else { | ||
| 1086 | formTableData.value.splice(rowIndex, 1) | ||
| 1087 | } | ||
| 1088 | formTable.value.tableInfo.loading = false | ||
| 1089 | }).catch(xhr => { | ||
| 1090 | ElMessage({ | ||
| 1091 | type: 'error', | ||
| 1092 | message: xhr | ||
| 1093 | }) | ||
| 1094 | formTable.value.tableInfo.loading = false | ||
| 1095 | }) | ||
| 1096 | } else { | ||
| 1097 | formTableData.value.splice(rowIndex, 1) | ||
| 1098 | } | ||
| 1099 | } | ||
| 1100 | } else if (type == "delete") { | 992 | } else if (type == "delete") { |
| 1101 | currTableData.value = row; | 993 | currTableData.value = row; |
| 1102 | tableInfo.value.loading = true | 994 | tableInfo.value.loading = true |
| 1103 | checkDelete().then((res: any) => { | ||
| 1104 | if (res.used) { | ||
| 1105 | ElMessage({ | ||
| 1106 | type: 'error', | ||
| 1107 | message: '数据字典被引用,请解除引用关系后再删除' | ||
| 1108 | }) | ||
| 1109 | } else { | ||
| 1110 | const unused = res.data.filter(item => item.have.length > 0) | ||
| 1111 | if (unused.length) { | ||
| 1112 | open("数据字典有数据, 确定是否继续删除?", "warning"); | ||
| 1113 | } else { | ||
| 1114 | open("此操作将永久删除, 是否继续?", "warning"); | 995 | open("此操作将永久删除, 是否继续?", "warning"); |
| 1115 | } | ||
| 1116 | } | ||
| 1117 | tableInfo.value.loading = false | ||
| 1118 | }).catch(xhr => { | ||
| 1119 | ElMessage({ | ||
| 1120 | type: 'error', | ||
| 1121 | message: xhr | ||
| 1122 | }) | ||
| 1123 | tableInfo.value.loading = false | 996 | tableInfo.value.loading = false |
| 1124 | }) | ||
| 1125 | } | 997 | } |
| 1126 | }; | 998 | }; |
| 1127 | 999 | ||
| ... | @@ -1183,9 +1055,9 @@ const open = (msg, type, isBatch = false) => { | ... | @@ -1183,9 +1055,9 @@ const open = (msg, type, isBatch = false) => { |
| 1183 | guids = selectRowData.value | 1055 | guids = selectRowData.value |
| 1184 | } | 1056 | } |
| 1185 | tableInfo.value.loading = true | 1057 | tableInfo.value.loading = true |
| 1186 | deleteDictionary(guids).then((res: any) => { | 1058 | deleteStandardCode(guids).then((res: any) => { |
| 1187 | if (res.code == proxy.$passCode) { | 1059 | if (res.code == proxy.$passCode) { |
| 1188 | getTreeData(); | 1060 | getFirstPageData() |
| 1189 | ElMessage({ | 1061 | ElMessage({ |
| 1190 | type: "success", | 1062 | type: "success", |
| 1191 | message: "删除成功", | 1063 | message: "删除成功", |
| ... | @@ -1363,28 +1235,8 @@ const batching = (type) => { | ... | @@ -1363,28 +1235,8 @@ const batching = (type) => { |
| 1363 | return | 1235 | return |
| 1364 | } | 1236 | } |
| 1365 | tableInfo.value.loading = true | 1237 | tableInfo.value.loading = true |
| 1366 | checkDelete().then((res: any) => { | ||
| 1367 | if (res.used) { | ||
| 1368 | ElMessage({ | ||
| 1369 | type: 'error', | ||
| 1370 | message: '数据字典被引用,请解除引用关系后再删除' | ||
| 1371 | }) | ||
| 1372 | } else { | ||
| 1373 | const unused = res.data.filter(item => !item.have || item.have.length == 0) | ||
| 1374 | if (unused.length) { | ||
| 1375 | open("数据字典有数据, 确定是否继续删除?", "warning", true); | ||
| 1376 | } else { | ||
| 1377 | open("此操作将永久删除, 是否继续?", "warning", true); | 1238 | open("此操作将永久删除, 是否继续?", "warning", true); |
| 1378 | } | ||
| 1379 | } | ||
| 1380 | tableInfo.value.loading = false | 1239 | tableInfo.value.loading = false |
| 1381 | }).catch(xhr => { | ||
| 1382 | ElMessage({ | ||
| 1383 | type: 'error', | ||
| 1384 | message: xhr | ||
| 1385 | }) | ||
| 1386 | tableInfo.value.loading = false | ||
| 1387 | }) | ||
| 1388 | } | 1240 | } |
| 1389 | }; | 1241 | }; |
| 1390 | 1242 | ||
| ... | @@ -1392,25 +1244,19 @@ const nodeClick = (data) => { | ... | @@ -1392,25 +1244,19 @@ const nodeClick = (data) => { |
| 1392 | console.log('treeNodeClick', data) | 1244 | console.log('treeNodeClick', data) |
| 1393 | drawerInfo.value.visible = false | 1245 | drawerInfo.value.visible = false |
| 1394 | const changeCont = () => { | 1246 | const changeCont = () => { |
| 1395 | // dictGuid.value = data.guid | ||
| 1396 | // const info = { | ||
| 1397 | // type: 'dictionary', | ||
| 1398 | // dictionaryGuid: dictGuid.value | ||
| 1399 | // } | ||
| 1400 | // cacheStore.setCatch('uploadSetting', info) | ||
| 1401 | // if (data.type == 1) { | ||
| 1402 | // showFiledsPage.value = false | ||
| 1403 | // dictType.value = Number(data.dictionaryType) | ||
| 1404 | // } else { | ||
| 1405 | // showFiledsPage.value = true | ||
| 1406 | // nextTick(() => { | ||
| 1407 | // dictFiledsRef.value.dictionaryGuid = dictGuid.value | ||
| 1408 | // dictFiledsRef.value.getFirstPageData() | ||
| 1409 | // }) | ||
| 1410 | // } | ||
| 1411 | nextTick(() => { | 1247 | nextTick(() => { |
| 1412 | treeInfo.value.currentNodeKey = data.value | 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 | ||
| 1413 | getFirstPageData() | 1258 | getFirstPageData() |
| 1259 | } | ||
| 1414 | }) | 1260 | }) |
| 1415 | } | 1261 | } |
| 1416 | if (showFiledsPage.value) { | 1262 | if (showFiledsPage.value) { |
| ... | @@ -1436,6 +1282,48 @@ const nodeClick = (data) => { | ... | @@ -1436,6 +1282,48 @@ const nodeClick = (data) => { |
| 1436 | changeCont() | 1282 | changeCont() |
| 1437 | } | 1283 | } |
| 1438 | } | 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 | } | ||
| 1439 | 1327 | ||
| 1440 | // 设置详情信息 | 1328 | // 设置详情信息 |
| 1441 | const setDetailInfo = () => { | 1329 | const setDetailInfo = () => { |
| ... | @@ -1468,62 +1356,21 @@ const setDetailInfo = () => { | ... | @@ -1468,62 +1356,21 @@ const setDetailInfo = () => { |
| 1468 | drawerInfo.value.visible = true | 1356 | drawerInfo.value.visible = true |
| 1469 | } | 1357 | } |
| 1470 | 1358 | ||
| 1471 | const checkParamsData = () => { | ||
| 1472 | let addJsonArray: any = [], upJsonArray: any = [], jsonArray: any = [], pass = true | ||
| 1473 | let passArr = uploadTableData.value | ||
| 1474 | passArr.map((item, index) => { | ||
| 1475 | const obj = JSON.parse(JSON.stringify(item)) | ||
| 1476 | delete obj.STATE | ||
| 1477 | delete obj.STATUS | ||
| 1478 | delete obj.NOTES | ||
| 1479 | delete obj.ROWID | ||
| 1480 | for (var i in obj) { | ||
| 1481 | if (obj[i] == '') { | ||
| 1482 | pass = false | ||
| 1483 | } | ||
| 1484 | } | ||
| 1485 | if (obj.guid !== undefined) { | ||
| 1486 | upJsonArray.push(obj) | ||
| 1487 | } else { | ||
| 1488 | addJsonArray.push(obj) | ||
| 1489 | } | ||
| 1490 | obj.index = index | ||
| 1491 | jsonArray.push(obj) | ||
| 1492 | }) | ||
| 1493 | return { pass, addJsonArray, upJsonArray, jsonArray } | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | const saveData = async (params) => { | 1359 | const saveData = async (params) => { |
| 1497 | // const passInfo = await checkParamsData() | 1360 | // const passInfo = await checkParamsData() |
| 1498 | console.log('params', params) | 1361 | console.log('params', params) |
| 1499 | saveStandardCode(params).then((res:any) => { | 1362 | let request = drawerInfo.value.type === 'add' ? saveStandardCode : updateStandardCode |
| 1363 | request(params).then((res:any) => { | ||
| 1500 | if (res.code === proxy.$passCode) { | 1364 | if (res.code === proxy.$passCode) { |
| 1501 | ElMessage.success('操作成功') | 1365 | ElMessage.success('操作成功') |
| 1366 | getTreeData() | ||
| 1367 | drawerInfo.value.visible = false | ||
| 1502 | } | 1368 | } |
| 1369 | }).finally(() => { | ||
| 1370 | drawerInfo.value.footer.btns.map((item: any) => item.disabled = true) | ||
| 1503 | }) | 1371 | }) |
| 1504 | } | 1372 | } |
| 1505 | 1373 | ||
| 1506 | const addColumn = (info: any = null) => { | ||
| 1507 | const fields = uploadTableFields.value | ||
| 1508 | const existIndex = fields.findIndex(item => item.field == 'NOTES') | ||
| 1509 | if (info) { | ||
| 1510 | if (existIndex == -1) { | ||
| 1511 | fields.push({ | ||
| 1512 | label: '备注', | ||
| 1513 | field: 'NOTES', | ||
| 1514 | width: 276 | ||
| 1515 | }) | ||
| 1516 | } | ||
| 1517 | for (var d in info) { | ||
| 1518 | uploadTableData.value[d].NOTES = info[d].join(',') | ||
| 1519 | } | ||
| 1520 | } else { | ||
| 1521 | if (existIndex > -1) { | ||
| 1522 | fields.splice(existIndex, 1) | ||
| 1523 | } | ||
| 1524 | } | ||
| 1525 | } | ||
| 1526 | |||
| 1527 | const scrollTable = (rowInfo) => { | 1374 | const scrollTable = (rowInfo) => { |
| 1528 | nextTick(() => { | 1375 | nextTick(() => { |
| 1529 | const drawerBody = document.getElementsByClassName('el-drawer__body')[0]; | 1376 | const drawerBody = document.getElementsByClassName('el-drawer__body')[0]; |
| ... | @@ -1546,7 +1393,11 @@ const drawerBtnClick = (btn, info) => { | ... | @@ -1546,7 +1393,11 @@ const drawerBtnClick = (btn, info) => { |
| 1546 | console.log('table', formTable.value) | 1393 | console.log('table', formTable.value) |
| 1547 | let params = { | 1394 | let params = { |
| 1548 | standardCodeFields: formTable.value.tableInfo.data.map(item => { | 1395 | standardCodeFields: formTable.value.tableInfo.data.map(item => { |
| 1549 | let obj = { fieldName: item.fieldName } | 1396 | let obj = { |
| 1397 | fieldName: item.fieldName, | ||
| 1398 | guid: item.guid || null, | ||
| 1399 | standardGuid: item.standardGuid || null | ||
| 1400 | } | ||
| 1550 | return obj | 1401 | return obj |
| 1551 | }), | 1402 | }), |
| 1552 | ...info | 1403 | ...info |
| ... | @@ -1554,7 +1405,11 @@ const drawerBtnClick = (btn, info) => { | ... | @@ -1554,7 +1405,11 @@ const drawerBtnClick = (btn, info) => { |
| 1554 | if (params.typeCode === '1') { | 1405 | if (params.typeCode === '1') { |
| 1555 | delete params.hierarchy | 1406 | delete params.hierarchy |
| 1556 | } | 1407 | } |
| 1408 | if (drawerInfo.value.type === 'edit') { | ||
| 1409 | params.guid = currTableData.value.guid | ||
| 1410 | } | ||
| 1557 | if (btn.value == 'submit' || btn.value == 'saveAndAdd') { | 1411 | if (btn.value == 'submit' || btn.value == 'saveAndAdd') { |
| 1412 | drawerInfo.value.footer.btns.map((item: any) => item.disabled = true) | ||
| 1558 | saveData(params) | 1413 | saveData(params) |
| 1559 | } else { | 1414 | } else { |
| 1560 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) | 1415 | drawerInfo.value.footer.btns.map((item: any) => delete item.disabled) |
| ... | @@ -1564,60 +1419,6 @@ const drawerBtnClick = (btn, info) => { | ... | @@ -1564,60 +1419,6 @@ const drawerBtnClick = (btn, info) => { |
| 1564 | } | 1419 | } |
| 1565 | } | 1420 | } |
| 1566 | 1421 | ||
| 1567 | const getTableFiled = () => { | ||
| 1568 | const guid = currTableData.value.guid; | ||
| 1569 | fieldTableInfo.value.tableInfo.loading = true; | ||
| 1570 | drawerInfo.value.container.contents = contents.value['field'] | ||
| 1571 | getDictionaryFileds(guid).then((res: any) => { | ||
| 1572 | fieldTableInfo.value.tableInfo.loading = false; | ||
| 1573 | if (res.code == proxy.$passCode) { | ||
| 1574 | const data = res.data ?? {} | ||
| 1575 | currTableData.value.detailInfo = data | ||
| 1576 | setUploadDataInfo(data) | ||
| 1577 | } else { | ||
| 1578 | ElMessage({ | ||
| 1579 | type: 'error', | ||
| 1580 | message: res.msg, | ||
| 1581 | }) | ||
| 1582 | } | ||
| 1583 | }).catch(() => { | ||
| 1584 | fieldTableInfo.value.tableInfo.loading = false; | ||
| 1585 | }) | ||
| 1586 | } | ||
| 1587 | |||
| 1588 | const getDictionaryDataDetail = (params) => { | ||
| 1589 | uploadTableInfo.value.loading = true | ||
| 1590 | getDictionaryFileds(params).then((res: any) => { | ||
| 1591 | if (res.code == proxy.$passCode) { | ||
| 1592 | const data = res.data ?? {} | ||
| 1593 | setContents(data) | ||
| 1594 | } else { | ||
| 1595 | ElMessage({ | ||
| 1596 | type: 'error', | ||
| 1597 | message: res.msg, | ||
| 1598 | }) | ||
| 1599 | } | ||
| 1600 | uploadTableInfo.value.loading = false | ||
| 1601 | }).catch(xhr => { | ||
| 1602 | uploadTableInfo.value.loading = false | ||
| 1603 | }) | ||
| 1604 | } | ||
| 1605 | |||
| 1606 | // 设置添加数据面板信息 | ||
| 1607 | const setContents = async (info) => { | ||
| 1608 | formItems.value.splice(2) | ||
| 1609 | formItems.value.map(item => { | ||
| 1610 | item.default = fieldSheetInfo.value[item.field] | ||
| 1611 | item.disabled = true | ||
| 1612 | }) | ||
| 1613 | const fields = info.schemaDataVOS ?? [] | ||
| 1614 | await setUploadDataFields(fields) | ||
| 1615 | uploadTableData.value = [] | ||
| 1616 | uploadTableInfo.value.data = [] | ||
| 1617 | uploadInfo.value.tableInfo = uploadTableInfo.value | ||
| 1618 | drawerInfo.value.container.contents = contents.value['upload'] | ||
| 1619 | } | ||
| 1620 | |||
| 1621 | const radioGroupChange = async (val, info) => { | 1422 | const radioGroupChange = async (val, info) => { |
| 1622 | dictionaryType.value = Number(val) | 1423 | dictionaryType.value = Number(val) |
| 1623 | await setFormItems(info) | 1424 | await setFormItems(info) |
| ... | @@ -1647,25 +1448,25 @@ const setGroup = () => { | ... | @@ -1647,25 +1448,25 @@ const setGroup = () => { |
| 1647 | } | 1448 | } |
| 1648 | 1449 | ||
| 1649 | onActivated(() => { | 1450 | onActivated(() => { |
| 1650 | getCodeRuleData(); | 1451 | // getCodeRuleData(); |
| 1651 | let guid = cacheStore.getCatch('dictionaryGuid'); | 1452 | // let guid = cacheStore.getCatch('dictionaryGuid'); |
| 1652 | if (guid) { | 1453 | // if (guid) { |
| 1653 | nextTick(() => { | 1454 | // nextTick(() => { |
| 1654 | if (treePromise.value) { | 1455 | // if (treePromise.value) { |
| 1655 | treePromise.value.then(() => { | 1456 | // treePromise.value.then(() => { |
| 1656 | nodeClick({ guid: guid, dictionaryType: '1', type: 2 }); | 1457 | // nodeClick({ guid: guid, dictionaryType: '1', type: 2 }); |
| 1657 | cacheStore.setCatch('dictionaryGuid', null); | 1458 | // cacheStore.setCatch('dictionaryGuid', null); |
| 1658 | }); | 1459 | // }); |
| 1659 | } else { | 1460 | // } else { |
| 1660 | nodeClick({ guid: guid, type: 1 }); | 1461 | // nodeClick({ guid: guid, type: 1 }); |
| 1661 | cacheStore.setCatch('dictionaryGuid', null); | 1462 | // cacheStore.setCatch('dictionaryGuid', null); |
| 1662 | } | 1463 | // } |
| 1663 | }); | 1464 | // }); |
| 1664 | } | 1465 | // } |
| 1665 | }) | 1466 | }) |
| 1666 | 1467 | ||
| 1667 | onBeforeMount(() => { | 1468 | onBeforeMount(() => { |
| 1668 | getDataType() | 1469 | // getDataType() |
| 1669 | getTreeData() | 1470 | getTreeData() |
| 1670 | getParamsList({ dictType: '发布单位' }).then((res:any) => { | 1471 | getParamsList({ dictType: '发布单位' }).then((res:any) => { |
| 1671 | if (res.code === proxy.$passCode) { | 1472 | if (res.code === proxy.$passCode) { |
| ... | @@ -1695,16 +1496,16 @@ onMounted(() => { | ... | @@ -1695,16 +1496,16 @@ onMounted(() => { |
| 1695 | <div class="container_wrap full flex"> | 1496 | <div class="container_wrap full flex"> |
| 1696 | <div class="aside_wrap"> | 1497 | <div class="aside_wrap"> |
| 1697 | <div class="aside_title">数据字典列表</div> | 1498 | <div class="aside_title">数据字典列表</div> |
| 1698 | <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" /> | 1499 | <Tree ref="dictTreeRef" :treeInfo="treeInfo" @nodeClick="nodeClick" @loadNode="loadTreeNode"/> |
| 1699 | </div> | 1500 | </div> |
| 1700 | <!-- <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> --> | 1501 | <DictFileds ref="dictFiledsRef" v-if="showFiledsPage" @exportData="exportData" /> |
| 1701 | <div class="main_wrap"> | 1502 | <div class="main_wrap" v-else> |
| 1702 | <div class="table_tool_wrap"> | 1503 | <div class="table_tool_wrap"> |
| 1703 | <div class="tools_btns"> | 1504 | <div class="tools_btns"> |
| 1704 | <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button> | 1505 | <el-button type="primary" @click="loadDrawer" v-preReClick>新建</el-button> |
| 1705 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> | 1506 | <el-button @click="batching('delete')" v-preReClick>批量删除</el-button> |
| 1706 | </div> | 1507 | </div> |
| 1707 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入字典中/英文名搜索" | 1508 | <el-input class="table_search_input" v-model.trim="tableSearchInput" placeholder="请输入代码名称搜索" |
| 1708 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> | 1509 | :suffix-icon="Search" clearable @change="val => getFirstPageData()" /> |
| 1709 | </div> | 1510 | </div> |
| 1710 | <div class="table_panel_wrap full"> | 1511 | <div class="table_panel_wrap full"> | ... | ... |
-
Please register or sign in to post a comment