690cf593 by lihua

优化新增采集任务,数据源与导入重名的问题

1 parent f9f531ce
...@@ -267,7 +267,7 @@ const dialogInfo = ref({ ...@@ -267,7 +267,7 @@ const dialogInfo = ref({
267 footer: { 267 footer: {
268 btns: [ 268 btns: [
269 { type: "default", label: "取消", value: "cancel" }, 269 { type: "default", label: "取消", value: "cancel" },
270 { type: "primary", label: "确定", value: "submit" }, 270 { type: "primary", label: "确定", value: "submit", loading: false },
271 ], 271 ],
272 }, 272 },
273 }); 273 });
...@@ -403,11 +403,13 @@ const tableBtnClick = (scope, btn) => { ...@@ -403,11 +403,13 @@ const tableBtnClick = (scope, btn) => {
403 }) 403 })
404 } else if (type == "edit") { 404 } else if (type == "edit") {
405 dialogInfo.value.header.title = '编辑采集任务'; 405 dialogInfo.value.header.title = '编辑采集任务';
406 dialogInfo.value.type = type 406 dialogInfo.value.type = type;
407 oldOriginValue.value = {};
407 setDetailInfo(scope.row); 408 setDetailInfo(scope.row);
408 formInfo.value.formInfo.items[6].default = ''; 409 formInfo.value.formInfo.items[6].default = '';
409 formRules.value.collectTaskName = [required('请填写采集任务名称'), checkExistName(checkedInfo.value, checkMetaDataTask, currTableData.value, 'collectTaskName')]; 410 formRules.value.collectTaskName = [required('请填写采集任务名称'), checkExistName(checkedInfo.value, checkMetaDataTask, currTableData.value, 'collectTaskName')];
410 dialogInfo.value.contents[0].formInfo.rules = formRules.value; 411 dialogInfo.value.contents[0].formInfo.rules = formRules.value;
412 formItems.value[2].disabled = true;
411 } else if (type == "delete") { 413 } else if (type == "delete") {
412 proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => { 414 proxy.$openMessageBox("此操作将永久删除, 是否继续?", () => {
413 let guids = [currTableData.value.guid] 415 let guids = [currTableData.value.guid]
...@@ -451,6 +453,7 @@ const tableBtnClick = (scope, btn) => { ...@@ -451,6 +453,7 @@ const tableBtnClick = (scope, btn) => {
451 453
452 const loadDrawer = () => { 454 const loadDrawer = () => {
453 collectType.value = 1 455 collectType.value = 1
456 oldOriginValue.value = {};
454 setFormItems() 457 setFormItems()
455 setGroup() 458 setGroup()
456 formInfo.value.formInfo.items[5].default = '0 00 00 01 * ? ' 459 formInfo.value.formInfo.items[5].default = '0 00 00 01 * ? '
...@@ -461,6 +464,7 @@ const loadDrawer = () => { ...@@ -461,6 +464,7 @@ const loadDrawer = () => {
461 checkedInfo.value = {}; 464 checkedInfo.value = {};
462 formItems.value[0].default = '1'; 465 formItems.value[0].default = '1';
463 formItems.value[0].disabled = false; 466 formItems.value[0].disabled = false;
467 formItems.value[2].disabled = false;
464 }; 468 };
465 469
466 const setDetailInfo = (row) => { 470 const setDetailInfo = (row) => {
...@@ -502,30 +506,7 @@ const scheduleChange = (val, rowValue) => { ...@@ -502,30 +506,7 @@ const scheduleChange = (val, rowValue) => {
502 const databaseNameEn = ref<any>('') 506 const databaseNameEn = ref<any>('')
503 const selectChange = (val, row, info) => { 507 const selectChange = (val, row, info) => {
504 // dataSourceList.value 508 // dataSourceList.value
505 console.log(val, row, info) 509 // console.log(val, row, info)
506
507 let data: any = dataSourceList.value.find((item: any) => item.guid == val)
508 if (data) {
509 databaseNameEn.value = data.databaseNameEn
510 checkDataSource({
511 databaseNameEn: databaseNameEn.value,
512 }).then((res: any) => {
513 if (res.code == proxy.$passCode) {
514 if (res.data) {
515 proxy.$ElMessage({
516 type: 'warning',
517 message: '已存在导入数据源,请确认是否覆盖!',
518 })
519 }
520 } else {
521 proxy.$ElMessage({
522 type: 'error',
523 message: res.msg,
524 })
525 }
526 })
527 }
528
529 } 510 }
530 511
531 // 切换结构类型 设置选项显隐 512 // 切换结构类型 设置选项显隐
...@@ -552,22 +533,53 @@ const dialogBtnClick = (btn, info) => { ...@@ -552,22 +533,53 @@ const dialogBtnClick = (btn, info) => {
552 // params.taskState = 1; 533 // params.taskState = 1;
553 params.databaseNameEn = databaseNameEn.value 534 params.databaseNameEn = databaseNameEn.value
554 if (dialogInfo.value.type == 'add') { 535 if (dialogInfo.value.type == 'add') {
555 params.taskState = 1; 536 let addTask = () => {
556 addMetaDataTask(params).then((res: any) => { 537 params.taskState = 1;
557 if (res.code == proxy.$passCode) { 538 dialogInfo.value.footer.btns[1].loading = true;
558 page.value.curr = 1; 539 addMetaDataTask(params).then((res: any) => {
559 getTableData(); 540 dialogInfo.value.footer.btns[1].loading = false;
560 proxy.$ElMessage({ 541 if (res.code == proxy.$passCode) {
561 type: 'success', 542 page.value.curr = 1;
562 message: '添加采集任务成功' 543 getTableData();
563 }) 544 proxy.$ElMessage({
564 dialogInfo.value.visible = false; 545 type: 'success',
565 } else { 546 message: '添加采集任务成功'
566 proxy.$ElMessage.error(res.msg); 547 })
567 } 548 dialogInfo.value.visible = false;
568 }) 549 } else {
550 proxy.$ElMessage.error(res.msg);
551 }
552 })
553 }
554 let data: any = dataSourceList.value.find((item: any) => item.guid == params.dataSourceGuid)
555 if (data) {
556 dialogInfo.value.footer.btns[1].loading = true;
557 databaseNameEn.value = data.databaseNameEn;
558 checkDataSource({
559 databaseNameEn: databaseNameEn.value,
560 }).then((res: any) => {
561 dialogInfo.value.footer.btns[1].loading = false;
562 if (res.code == proxy.$passCode) {
563 if (!res.data) {
564 proxy.$openMessageBox('该数据源在导入数据源中已存在,确定覆盖吗?', () => {
565 addTask();
566 }, () => {
567 proxy.$ElMessage.info("已取消");
568 });
569 } else {
570 addTask();
571 }
572 } else {
573 proxy.$ElMessage({
574 type: 'error',
575 message: res.msg,
576 })
577 }
578 })
579 } else {
580 addTask();
581 }
569 } else { 582 } else {
570 params.guid = currTableData.value.guid
571 updateMetaDataTask(params).then((res: any) => { 583 updateMetaDataTask(params).then((res: any) => {
572 if (res.code == proxy.$passCode) { 584 if (res.code == proxy.$passCode) {
573 getTableData(); 585 getTableData();
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!