importEntity增加参数,添加xlsx依赖
This commit is contained in:
parent
d7c861845a
commit
52c46cf6fb
|
|
@ -3,10 +3,11 @@ import { EntityDict, Aspect, AspectWrapper } from 'oak-domain/lib/types';
|
|||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { Sheet2JSONOpts } from "xlsx";
|
||||
export declare class Port<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
||||
private aspectWrapper;
|
||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object): Promise<{
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object, s2jOpts?: Sheet2JSONOpts): Promise<{
|
||||
result: Awaited<ReturnType<AD["importEntity"]>>;
|
||||
opRecords?: import("oak-domain/lib/types").OpRecord<ED>[] | undefined;
|
||||
message?: string | null | undefined;
|
||||
|
|
|
|||
|
|
@ -5,12 +5,15 @@ export class Port extends Feature {
|
|||
super();
|
||||
this.aspectWrapper = aspectWrapper;
|
||||
}
|
||||
importEntity(entity, id, file, option) {
|
||||
importEntity(entity, id, file, option, s2jOpts) {
|
||||
const formData = new FormData();
|
||||
formData.set('entity', entity);
|
||||
formData.set('id', id);
|
||||
formData.set('file', file);
|
||||
formData.set('option', JSON.stringify(option));
|
||||
if (s2jOpts) {
|
||||
formData.set('s2jOpts', JSON.stringify(s2jOpts));
|
||||
}
|
||||
return this.aspectWrapper.exec('importEntity', formData);
|
||||
}
|
||||
exportEntity(entity, id, filter, properties) {
|
||||
|
|
|
|||
|
|
@ -3,10 +3,11 @@ import { EntityDict, Aspect, AspectWrapper } from 'oak-domain/lib/types';
|
|||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { Sheet2JSONOpts } from "xlsx";
|
||||
export declare class Port<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, AD extends CommonAspectDict<ED, Cxt> & Record<string, Aspect<ED, Cxt>>> extends Feature {
|
||||
private aspectWrapper;
|
||||
constructor(aspectWrapper: AspectWrapper<ED, Cxt, AD>);
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object): Promise<{
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object, s2jOpts?: Sheet2JSONOpts): Promise<{
|
||||
result: Awaited<ReturnType<AD["importEntity"]>>;
|
||||
opRecords?: import("oak-domain/lib/types").OpRecord<ED>[] | undefined;
|
||||
message?: string | null | undefined;
|
||||
|
|
|
|||
|
|
@ -8,12 +8,15 @@ class Port extends Feature_1.Feature {
|
|||
super();
|
||||
this.aspectWrapper = aspectWrapper;
|
||||
}
|
||||
importEntity(entity, id, file, option) {
|
||||
importEntity(entity, id, file, option, s2jOpts) {
|
||||
const formData = new FormData();
|
||||
formData.set('entity', entity);
|
||||
formData.set('id', id);
|
||||
formData.set('file', file);
|
||||
formData.set('option', JSON.stringify(option));
|
||||
if (s2jOpts) {
|
||||
formData.set('s2jOpts', JSON.stringify(s2jOpts));
|
||||
}
|
||||
return this.aspectWrapper.exec('importEntity', formData);
|
||||
}
|
||||
exportEntity(entity, id, filter, properties) {
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@
|
|||
"rimraf": "^5.0.5",
|
||||
"ts-node": "^10.9.1",
|
||||
"tslib": "^2.4.0",
|
||||
"typescript": "^5.2.2"
|
||||
"typescript": "^5.2.2",
|
||||
"xlsx": "^0.18.5"
|
||||
},
|
||||
"scripts": {
|
||||
"clean": "rimraf lib/* && rimraf es/*",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
|||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { Sheet2JSONOpts } from "xlsx";
|
||||
|
||||
export class Port<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
|
|
@ -17,12 +18,15 @@ export class Port<
|
|||
this.aspectWrapper = aspectWrapper;
|
||||
}
|
||||
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object) {
|
||||
importEntity<T extends keyof ED>(entity: T, id: string, file: File, option: Object, s2jOpts?: Sheet2JSONOpts,) {
|
||||
const formData = new FormData();
|
||||
formData.set('entity', entity as string);
|
||||
formData.set('id', id);
|
||||
formData.set('file', file);
|
||||
formData.set('option', JSON.stringify(option));
|
||||
if(s2jOpts){
|
||||
formData.set('s2jOpts', JSON.stringify(s2jOpts));
|
||||
}
|
||||
|
||||
return this.aspectWrapper.exec('importEntity', formData);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue