@lingxiteam/ebe-utils 0.3.9 → 0.3.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,7 @@
1
1
  import engineServices from '@/services/api/engine';
2
2
  import { messageApi } from '@/utils/messageApi';
3
3
  import { exportFileShowProgress } from './tool';
4
+ import { APPID } from '@/constants';
4
5
 
5
6
  const SERVICE_SOURCE = {
6
7
  // 服务来源
@@ -567,101 +568,106 @@ const exportPathMap: ExportPathMapType = {
567
568
  multiExport: engineServices.exportMultiServiceResultPath(),
568
569
  };
569
570
  const exportCustomData = (exportSheet: any = [], custFileName: any, selectedKeyMap: { [x: string]: any }, async: string) => {
570
- // 获取到的服务出参列表
571
- const selectedRowMap: any = {};
572
- messageApi.loading('正在导出中,请稍候...', 0);
573
- try {
574
- const columnsReq = Object.keys(selectedKeyMap).map(type => {
575
- if (!selectedKeyMap[type] || !selectedKeyMap[type]?.length) {
576
- return undefined;
577
- }
578
- // 获取不同类型服务的出参列表
579
- let req;
580
- if (type === SERVICE_SOURCE.QUERY) {
581
- // SQL类型
582
- req = engineServices
583
- .getSqlQueryColumnsList({
584
- serviceCodes: selectedKeyMap[type].join(','),
585
- })
586
- .then((res: any) => {
587
- const m: any = {};
588
- (res || []).forEach((c: any) => (m[c.serviceCode] = c.rowColumns));
589
- return m;
590
- });
591
- }
592
- if (type === SERVICE_SOURCE.OBJECT) {
593
- // 对象类型
594
- req = engineServices
595
- .queryBusiObjectRowColumnsList({
596
- busiObjectIds: selectedKeyMap[type].join(','),
597
- })
598
- .then((res: any) => {
599
- const m: any = {};
600
- (res || []).forEach((c: any) => (m[c.busiObjectId] = c.rowColumns));
601
- return m;
602
- });
603
- }
604
- if (type === SERVICE_SOURCE.STD) {
605
- // 编排类服务
606
- // @ts-ignore
607
- req = engineServices
608
- .queryServiceResponseColumnsList({
609
- serviceVersionIds: (selectedKeyMap[type] || []).join(','),
610
- appId: APPID,
611
- })
612
- .then((res: any) => {
613
- const m: any = {};
614
- (res || []).forEach((c: any) => (m[c.serviceVersionId] = getResponseAttr(c.response)));
615
- return m;
616
- });
617
- }
618
- if (req) {
619
- req?.then((r: any) => {
620
- selectedRowMap[type] = r;
571
+ return new Promise((resolve,reject)=>{
572
+ // 获取到的服务出参列表
573
+ const selectedRowMap: any = {};
574
+ messageApi.loading('正在导出中,请稍候...', 0);
575
+ try {
576
+ const columnsReq = Object.keys(selectedKeyMap).map(type => {
577
+ if (!selectedKeyMap[type] || !selectedKeyMap[type]?.length) {
578
+ return undefined;
579
+ }
580
+ // 获取不同类型服务的出参列表
581
+ let req;
582
+ if (type === SERVICE_SOURCE.QUERY) {
583
+ // SQL类型
584
+ req = engineServices
585
+ .getSqlQueryColumnsList({
586
+ serviceCodes: selectedKeyMap[type].join(','),
587
+ appId: APPID,
588
+ })
589
+ .then((res: any) => {
590
+ const m: any = {};
591
+ (res || []).forEach((c: any) => (m[c.serviceCode] = c.rowColumns));
592
+ return m;
621
593
  });
622
- }
623
- return req;
624
- });
625
- Promise.all(columnsReq).then(async () => {
626
- const sheetItemList = exportSheet;
627
- const serviceExecuteParams = sheetItemList.map((sheet: ExportItem) => {
628
- const { parameters, objValue, objType, custSheetName, source } = sheet;
629
- const resultList = (selectedRowMap[source] || {})[objValue] || [];
630
- const columns = getExportColumns(sheet, resultList);
631
- return {
632
- objValue,
633
- objType,
634
- parameters,
635
- sheetName: custSheetName,
636
- ...columns,
637
- };
594
+ }
595
+ if (type === SERVICE_SOURCE.OBJECT) {
596
+ // 对象类型
597
+ req = engineServices
598
+ .queryBusiObjectRowColumnsList({
599
+ busiObjectIds: selectedKeyMap[type].join(','),
600
+ })
601
+ .then((res: any) => {
602
+ const m: any = {};
603
+ (res || []).forEach((c: any) => (m[c.busiObjectId] = c.rowColumns));
604
+ return m;
605
+ });
606
+ }
607
+ if (type === SERVICE_SOURCE.STD) {
608
+ // 编排类服务
609
+ // @ts-ignore
610
+ req = engineServices
611
+ .queryServiceResponseColumnsList({
612
+ serviceVersionIds: (selectedKeyMap[type] || []).join(','),
613
+ })
614
+ .then((res: any) => {
615
+ const m: any = {};
616
+ (res || []).forEach((c: any) => (m[c.serviceVersionId] = getResponseAttr(c.response)));
617
+ return m;
618
+ });
619
+ }
620
+ if (req) {
621
+ req?.then((r: any) => {
622
+ selectedRowMap[type] = r;
638
623
  });
639
- const exportFileName = custFileName;
640
- const fileName = `${exportFileName}.xlsx`;
641
- const downloadIndex = `${fileName}_${Math.random()}`;
642
- await exportFileShowProgress?.({
643
- downloadIndex,
624
+ }
625
+ return req;
626
+ });
627
+ Promise.all(columnsReq).then(async () => {
628
+ const sheetItemList = exportSheet;
629
+ const serviceExecuteParams = sheetItemList.map((sheet: ExportItem) => {
630
+ const { parameters, objValue, objType, custSheetName, source } = sheet;
631
+ const resultList = (selectedRowMap[source] || {})[objValue] || [];
632
+ const columns = getExportColumns(sheet, resultList);
633
+ return {
634
+ objValue,
635
+ objType,
636
+ parameters,
637
+ sheetName: custSheetName,
638
+ ...columns,
639
+ };
640
+ });
641
+ const exportFileName = custFileName;
642
+ const fileName = `${exportFileName}.xlsx`;
643
+ const downloadIndex = `${fileName}_${Math.random()}`;
644
+ await exportFileShowProgress?.({
645
+ downloadIndex,
646
+ fileName,
647
+ methodType: 'POST',
648
+ fileOrigin: 'multiExport',
649
+ async,
650
+ params: {
651
+ serviceExecuteParams,
644
652
  fileName,
645
- methodType: 'POST',
646
- fileOrigin: 'multiExport',
647
- async,
648
- params: {
649
- serviceExecuteParams,
650
- fileName,
651
- },
652
- onSuccess: () => {
653
- messageApi.destroy();
654
- },
655
- onFail: () => {
656
- messageApi.destroy();
657
- messageApi.error('导出失败');
658
- },
659
- });
653
+ },
654
+ onSuccess: () => {
655
+ messageApi.destroy();
656
+ },
657
+ onFail: () => {
658
+ messageApi.destroy();
659
+ messageApi.error('导出失败');
660
+ },
660
661
  });
661
- } catch {
662
- messageApi.destroy();
663
- messageApi.error('导出失败');
664
- }
662
+ });
663
+ resolve(true);
664
+ } catch {
665
+ messageApi.destroy();
666
+ messageApi.error('导出失败');
667
+ reject()
668
+ }
669
+ })
670
+
665
671
  };
666
672
 
667
673
  export default exportCustomData;
@@ -921,14 +921,9 @@ const ImportBusiObjModal = forwardRef<ImportBusiObjModalHooks, ImportBusiObjModa
921
921
  <Button
922
922
  onClick={() => {
923
923
  const { fileCode } = params.custTpl || {};
924
- // @ts-ignore
925
- const downloadUrl = params.custTplUrl || (fileCode ? getAppFileUrlByFileCode(fileCode) : null);
926
- if (!downloadUrl) {
927
- return;
928
- }
929
- // 下载导入模板自定义名称无效处理
930
924
  const xhr = new XMLHttpRequest();
931
- xhr.open('GET', downloadUrl, true);
925
+ // 文件放到本地
926
+ xhr.open('GET', `${process.env.PUBLIC_PATH}appFile/${fileCode}.xlsx`, true);
932
927
  xhr.responseType = 'blob'; // 通过文件下载url拿到对应的blob对象
933
928
  xhr.onload = () => {
934
929
  if (xhr.status === 200) {
@@ -943,6 +938,8 @@ const ImportBusiObjModal = forwardRef<ImportBusiObjModalHooks, ImportBusiObjModa
943
938
  link.click();
944
939
  link.remove();
945
940
  window.URL?.revokeObjectURL(link.href);
941
+ }else{
942
+ console.log('文件不存在',fileCode)
946
943
  }
947
944
  };
948
945
  xhr.send();
@@ -57,7 +57,7 @@ export const defaultResponense: ResponseInterceptor = async (
57
57
  }
58
58
 
59
59
  // 如果内容为非json类型并没有配置指定响应内容类型时,根据content-type进行二次处理
60
- if (contentType !== 'application/json' && !options.responseType) {
60
+ if (contentType !== 'application/json') {
61
61
  // Blob解析
62
62
  if (url.indexOf('/app/file/download') !== -1 || [
63
63
  /^application\/octet-stream/,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingxiteam/ebe-utils",
3
- "version": "0.3.9",
3
+ "version": "0.3.11",
4
4
  "description": "",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -19,7 +19,7 @@
19
19
  "@babel/types": "^7.12.12",
20
20
  "cac": "^6.7.14",
21
21
  "fs-extra": "9.x",
22
- "@lingxiteam/ebe": "0.3.9"
22
+ "@lingxiteam/ebe": "0.3.11"
23
23
  },
24
24
  "publishConfig": {
25
25
  "access": "public"