@farris/bef-vue
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -7,3 +7,13 @@ var __defProp = Object.defineProperty; | ||
}; | ||
import { HttpUtil, EntityPathNodeType, FieldType, App, HttpMethods, Repository, HttpClient, createEntitiesBySchema } from "@farris/devkit-vue"; | ||
import { HttpUtil, EntityPathNodeType, FieldType, App, EXCEPTION_HANDLER_TOKEN, HttpMethods, Repository, HttpClient, createEntitiesBySchema } from "@farris/devkit-vue"; | ||
var ContentType = /* @__PURE__ */ ((ContentType2) => { | ||
ContentType2[ContentType2["NONE"] = 0] = "NONE"; | ||
ContentType2[ContentType2["JSON"] = 1] = "JSON"; | ||
ContentType2[ContentType2["FORM"] = 2] = "FORM"; | ||
ContentType2[ContentType2["FORM_DATA"] = 3] = "FORM_DATA"; | ||
ContentType2[ContentType2["TEXT"] = 4] = "TEXT"; | ||
ContentType2[ContentType2["BLOB"] = 5] = "BLOB"; | ||
ContentType2[ContentType2["ARRAY_BUFFER"] = 6] = "ARRAY_BUFFER"; | ||
return ContentType2; | ||
})(ContentType || {}); | ||
class BefHttpUtil { | ||
@@ -104,2 +114,3 @@ /** | ||
let currentEntity; | ||
let parentChangeDetail; | ||
const pathNodes = entityChange.path.getNodes(); | ||
@@ -127,2 +138,3 @@ pathNodes.forEach((pathNode) => { | ||
} | ||
parentChangeDetail = currentChangeDetail.ChangeInfo; | ||
} else { | ||
@@ -136,3 +148,3 @@ if (!currentEntity || !currentChangeDetail) { | ||
const fieldValue = currentEntity[fieldName]; | ||
if (!fieldSchema || !fieldValue) { | ||
if (!fieldSchema) { | ||
throw new Error(`Field(name=${fieldName}) can not be found`); | ||
@@ -150,13 +162,27 @@ } | ||
} else if (fieldSchema.type === FieldType.Entity) { | ||
let associatedChangeDetail = currentChangeDetail.ChangeInfo[fieldName]; | ||
if (!associatedChangeDetail) { | ||
associatedChangeDetail = this.createEmptyChangeDetail(fieldName); | ||
currentChangeDetail[fieldName] = associatedChangeDetail; | ||
const entityFieldSchema = fieldSchema; | ||
const idKey = entityFieldSchema.entitySchema.getIdKey(); | ||
if (idKey) { | ||
let associatedChangeDetail = currentChangeDetail.ChangeInfo[fieldName]; | ||
if (!associatedChangeDetail) { | ||
associatedChangeDetail = {}; | ||
currentChangeDetail.ChangeInfo[fieldName] = associatedChangeDetail; | ||
} | ||
parentChangeDetail = associatedChangeDetail; | ||
} else { | ||
let unifiedChangeDetail = currentChangeDetail.ChangeInfo[fieldName]; | ||
if (!unifiedChangeDetail) { | ||
unifiedChangeDetail = this.createEmptyChangeDetail(); | ||
currentChangeDetail.ChangeInfo[fieldName] = unifiedChangeDetail; | ||
} | ||
parentChangeDetail = unifiedChangeDetail.ChangeInfo; | ||
} | ||
currentChangeDetails = null; | ||
currentEntities = null; | ||
currentChangeDetail = associatedChangeDetail; | ||
currentEntity = fieldValue; | ||
} else { | ||
currentChangeDetail.ChangeInfo[fieldName] = entityChange.newValue; | ||
if (!parentChangeDetail) { | ||
throw new Error(`Field(name=${fieldName}) can not be found`); | ||
} | ||
parentChangeDetail[fieldName] = entityChange.newValue; | ||
currentChangeDetails = null; | ||
@@ -166,2 +192,3 @@ currentEntities = null; | ||
currentEntity = null; | ||
parentChangeDetail = null; | ||
} | ||
@@ -177,6 +204,7 @@ } | ||
ChangeType: ChangeDetailType.Modify, | ||
ChangeInfo: { | ||
DataId: dataId | ||
} | ||
ChangeInfo: {} | ||
}; | ||
if (dataId) { | ||
changeDetail.ChangeInfo.DataId = dataId; | ||
} | ||
return changeDetail; | ||
@@ -258,9 +286,8 @@ } | ||
get formToken() { | ||
return this.params && this.params["formToken"] || null; | ||
return this.params && this.params["cvft"] || null; | ||
} | ||
get params() { | ||
if (this.rtfService && this.rtfService.hasOwnProperty("session") && typeof this.rtfService["session"]["getCommonVariable"] === "function") { | ||
return this.rtfService["session"]["getCommonVariable"](); | ||
} | ||
return null; | ||
const hash = window.location.hash; | ||
const params = this.parseQueryString(hash); | ||
return params; | ||
} | ||
@@ -293,2 +320,14 @@ getRuntimeFrameworkService() { | ||
} | ||
parseQueryString(queryString) { | ||
if (!queryString) { | ||
return {}; | ||
} | ||
const hashes = queryString.slice(queryString.indexOf("?") + 1).split("&"); | ||
return hashes.reduce((params, hash) => { | ||
const split = hash.indexOf("="); | ||
const key = hash.slice(0, split); | ||
const val = hash.slice(split + 1); | ||
return Object.assign(params, { [key]: decodeURIComponent(val) }); | ||
}, {}); | ||
} | ||
} | ||
@@ -342,4 +381,5 @@ class SessionHandlingStrategy { | ||
* 获取框架SessionId | ||
* TODO: 暂不支持runtimeContext | ||
*/ | ||
getFrameworkSessionId(runtimeContext) { | ||
getFrameworkSessionId() { | ||
return this.frameworkSessionId; | ||
@@ -444,5 +484,5 @@ } | ||
*/ | ||
handleRequestHeaders(headers) { | ||
handleRequestHeaders(headers, runtimeContext) { | ||
const frmSessionId = this.getFrameworkSessionId(); | ||
const beSessionId = this.getSessionIdFromStorage(); | ||
const beSessionId = this.getSessionIdFromStorage(runtimeContext); | ||
if (frmSessionId) { | ||
@@ -468,3 +508,3 @@ headers = BefHttpUtil.appendCafRuntimeCommonVariable(headers, frmSessionId); | ||
if (runtimeContext) { | ||
sessionId = this.getFrameworkSessionId(runtimeContext); | ||
sessionId = this.getFrameworkSessionId(); | ||
} | ||
@@ -518,3 +558,3 @@ const tabId = runtimeContext && runtimeContext.tabId; | ||
handleRequestHeaders(headers, runtimeContext) { | ||
const frmSessionId = this.getFrameworkSessionId(runtimeContext); | ||
const frmSessionId = this.getFrameworkSessionId(); | ||
const beSessionId = this.getSessionIdFromStorage(runtimeContext); | ||
@@ -545,3 +585,3 @@ const app = this.injector.get(App, void 0); | ||
if (runtimeContext) { | ||
sessionId = this.getFrameworkSessionId(runtimeContext); | ||
sessionId = this.getFrameworkSessionId(); | ||
} | ||
@@ -662,4 +702,4 @@ const tabId = runtimeContext && runtimeContext.tabId; | ||
*/ | ||
getBeSessionId() { | ||
return this.handlingStrategy.getSessionId(); | ||
getBeSessionId(runtimeContext) { | ||
return this.handlingStrategy.getSessionId(runtimeContext); | ||
} | ||
@@ -670,4 +710,4 @@ /** | ||
*/ | ||
setBeSessionId(sessionId) { | ||
this.handlingStrategy.setSessionId(sessionId); | ||
setBeSessionId(sessionId, runtimeContext) { | ||
this.handlingStrategy.setSessionId(sessionId, runtimeContext); | ||
} | ||
@@ -677,4 +717,4 @@ /** | ||
*/ | ||
clearBeSessionId() { | ||
this.handlingStrategy.clearSessionId(); | ||
clearBeSessionId(runtimeContext) { | ||
this.handlingStrategy.clearSessionId(runtimeContext); | ||
} | ||
@@ -684,4 +724,4 @@ /** | ||
*/ | ||
extendRequestHeaders(headers) { | ||
return this.handlingStrategy.handleRequestHeaders(headers); | ||
extendRequestHeaders(headers, runtimeContext) { | ||
return this.handlingStrategy.handleRequestHeaders(headers, runtimeContext); | ||
} | ||
@@ -730,3 +770,18 @@ /** | ||
*/ | ||
onError(error) { | ||
onError(error, selfHandError, ignoreError) { | ||
if (selfHandError) { | ||
return Promise.reject(error); | ||
} | ||
if (ignoreError) { | ||
return Promise.resolve(); | ||
} | ||
const injector = this.repository.viewModel.getInjector(); | ||
if (!injector) { | ||
return Promise.reject(error); | ||
} | ||
const exceptionHandler = injector.get(EXCEPTION_HANDLER_TOKEN); | ||
if (!exceptionHandler) { | ||
return Promise.reject(error); | ||
} | ||
exceptionHandler.handle(error); | ||
return Promise.reject(error); | ||
@@ -738,4 +793,10 @@ } | ||
extendHeaders(headers) { | ||
const sessionIdPromise = this.repository.sessionService.getBeSessionId().then(() => { | ||
headers = this.repository.sessionService.extendRequestHeaders(headers); | ||
const app = this.repository.viewModel.getInjector().get(App); | ||
const tabId = app.params.get("tabId"); | ||
const runtimeContext = {}; | ||
if (tabId) { | ||
runtimeContext.tabId = tabId; | ||
} | ||
const sessionIdPromise = this.repository.sessionService.getBeSessionId(runtimeContext).then(() => { | ||
headers = this.repository.sessionService.extendRequestHeaders(headers, runtimeContext); | ||
return headers; | ||
@@ -916,3 +977,7 @@ }); | ||
save() { | ||
return this.request(HttpMethods.PUT, this.baseUrl); | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody({}); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, this.baseUrl, requestConfig); | ||
} | ||
@@ -924,3 +989,7 @@ /** | ||
const url = `${this.baseUrl}/extension/delete/${id}`; | ||
return this.request(HttpMethods.PUT, url); | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody({}); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
@@ -969,3 +1038,6 @@ /** | ||
const url = `${this.baseUrl}/service/delete/${id}`; | ||
const requestConfig = {}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody({}); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
@@ -1006,19 +1078,195 @@ } | ||
const url = `${this.baseUrl}/service/cancel`; | ||
return this.request(HttpMethods.POST, url); | ||
const requestConfig = { | ||
headers: { "Content-Type": "application/json" } | ||
}; | ||
return this.request(HttpMethods.POST, url, requestConfig); | ||
} | ||
/** | ||
* 父节点分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
parentHierarchyCreateSibling(id) { | ||
const url = `${this.baseUrl}/service/parenthierarchycreatesibling`; | ||
const body = { | ||
dataId: id | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 父节点分级方式新增子级 | ||
* @param id | ||
* @returns | ||
*/ | ||
parentHierarchyCreateChildLayer(id) { | ||
const url = `${this.baseUrl}/service/parenthierarchycreatechildlayer`; | ||
const body = { | ||
dataId: id | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 子对象父节点分级方式新增同级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodeParentHierarchyCreateSibling(ids, nodes) { | ||
const url = `${this.baseUrl}/service/childnodeparenthierarchycreatesibling`; | ||
const body = { | ||
ids, | ||
nodes | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 子对象父节点分级方式新增子级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodeParentHierarchyCreateChildLayer(ids, nodes) { | ||
const url = `${this.baseUrl}/service/childnodeparenthierarchycreatechildlayer`; | ||
const body = { | ||
ids, | ||
nodes | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 分级码分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
pathHierarchyCreateSibling(id) { | ||
const url = `${this.baseUrl}/service/pathhierarchycreatesibling`; | ||
const body = { | ||
dataId: id | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 分级码分级方式新增子级 | ||
* @param id | ||
* @returns | ||
*/ | ||
pathHierarchyCreateChildLayer(id) { | ||
const url = `${this.baseUrl}/service/pathhierarchycreatechildlayer`; | ||
const body = { | ||
dataId: id | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 子对象分级码分级方式新增同级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodePathHierarchyCreateSibling(ids, nodes) { | ||
const url = `${this.baseUrl}/service/childnodepathhierarchycreatesibling`; | ||
const body = { | ||
ids, | ||
nodes | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 子对象分级码分级方式新增子级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodePathHierarchyCreateChildLayer(ids, nodes) { | ||
const url = `${this.baseUrl}/service/childnodepathhierarchycreatechildlayer`; | ||
const body = { | ||
ids, | ||
nodes | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 查询全部树信息 | ||
* @param id | ||
* @param virtualPropertyName | ||
* @param fullTreeType | ||
* @param loadType | ||
* @param filter | ||
* @returns | ||
*/ | ||
parentIDFullTreeQuery(id, virtualPropertyName, fullTreeType, loadType, filter) { | ||
const url = `${this.baseUrl}/service/parentidfulltreequery`; | ||
const entityFilter = this.buildEntityFilter(filter, [], 0, 0); | ||
const body = { | ||
dataId: id, | ||
isUsePagination: false, | ||
virtualPropertyName, | ||
pagination: {}, | ||
fullTreeType, | ||
loadType, | ||
filter: entityFilter | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 获取帮助数据 | ||
* @param labelId | ||
* @param nodeCode | ||
* @param queryParam | ||
* @returns | ||
*/ | ||
elementhelps(labelId, nodeCode, queryParam) { | ||
const url = `${this.baseUrl}/extension/elementhelps`; | ||
const body = { | ||
labelId, | ||
nodeCode, | ||
queryParam | ||
}; | ||
const bodyWithRequestInfo = this.proxyExtend.extendBody(body); | ||
const requestConfig = { | ||
body: bodyWithRequestInfo | ||
}; | ||
return this.request(HttpMethods.PUT, url, requestConfig); | ||
} | ||
/** | ||
* 发送请求 | ||
*/ | ||
request(method, url, requestConfigs = {}, ignoreHandlingChanges = false) { | ||
if (ignoreHandlingChanges !== true) { | ||
if (method === HttpMethods.POST || method === HttpMethods.PUT || method === HttpMethods.PATCH) { | ||
const body = requestConfigs.body || {}; | ||
requestConfigs.body = this.proxyExtend.extendBody(body); | ||
} | ||
} else { | ||
requestConfigs.body = requestConfigs.body || { | ||
dataChange: [], | ||
variableChange: null | ||
}; | ||
} | ||
request(method, url, requestConfigs = {}, ignoreHandlingChanges = false, selfHandError = false, ignoreError = false) { | ||
this.setContentType(requestConfigs); | ||
const resultPromise = this.proxyExtend.extendHeaders(requestConfigs.headers).then((headers) => { | ||
@@ -1032,2 +1280,4 @@ requestConfigs.headers = headers; | ||
return this.proxyExtend.onResponse(result); | ||
}).catch((error) => { | ||
return this.proxyExtend.onError(error, selfHandError, ignoreError); | ||
}); | ||
@@ -1037,2 +1287,45 @@ }); | ||
} | ||
setContentType(requestConfigs = {}) { | ||
if (requestConfigs.headers != null && (requestConfigs.headers["Content-Type"] != null || requestConfigs.headers["content-type"] != null)) { | ||
return; | ||
} | ||
const detectedContentType = this.detectContentType(requestConfigs); | ||
switch (detectedContentType) { | ||
case ContentType.NONE: | ||
break; | ||
case ContentType.JSON: | ||
requestConfigs.headers = Object.assign({}, requestConfigs.headers, { "Content-Type": "application/json" }); | ||
break; | ||
case ContentType.FORM: | ||
requestConfigs.headers = Object.assign({}, requestConfigs.headers, { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" }); | ||
break; | ||
case ContentType.TEXT: | ||
requestConfigs.headers = Object.assign({}, requestConfigs.headers, { "Content-Type": "text/plain" }); | ||
break; | ||
case ContentType.BLOB: | ||
const blob = requestConfigs.body; | ||
if (blob && blob.type) { | ||
requestConfigs.headers = Object.assign({}, requestConfigs.headers, { "Content-Type": blob.type }); | ||
} | ||
break; | ||
} | ||
} | ||
detectContentType(requestConfigs = {}) { | ||
const body = requestConfigs.body || null; | ||
if (body == null) { | ||
return ContentType.NONE; | ||
} else if (body instanceof URLSearchParams) { | ||
return ContentType.FORM; | ||
} else if (body instanceof FormData) { | ||
return ContentType.FORM_DATA; | ||
} else if (body instanceof Blob) { | ||
return ContentType.BLOB; | ||
} else if (body instanceof ArrayBuffer) { | ||
return ContentType.ARRAY_BUFFER; | ||
} else if (body && typeof body === "object") { | ||
return ContentType.JSON; | ||
} else { | ||
return ContentType.TEXT; | ||
} | ||
} | ||
/** | ||
@@ -1055,2 +1348,28 @@ * 将路径转换为url | ||
} | ||
buildEntityFilter(filter, sort, pageSize, pageIndex) { | ||
if (!filter && !sort && !pageSize && !pageIndex) { | ||
return null; | ||
} | ||
if (!filter) { | ||
filter = []; | ||
} | ||
if (!sort) { | ||
sort = []; | ||
} | ||
if (filter && filter.length > 0) { | ||
filter[filter.length - 1].Relation = 0; | ||
} | ||
const entityFilter = { | ||
FilterConditions: filter, | ||
SortConditions: sort, | ||
IsUsePagination: pageSize === 0 ? false : true, | ||
Pagination: { | ||
PageIndex: pageIndex, | ||
PageSize: pageSize, | ||
PageCount: 0, | ||
TotalCount: 0 | ||
} | ||
}; | ||
return entityFilter; | ||
} | ||
} | ||
@@ -1063,4 +1382,2 @@ class BefRepository extends Repository { | ||
super(viewModel); | ||
__publicField(this, "pageIndexValue", 1); | ||
__publicField(this, "pageSizeValue", 0); | ||
/** | ||
@@ -1089,26 +1406,2 @@ * 注入器 | ||
/** | ||
* 当前页码 | ||
*/ | ||
get pageIndex() { | ||
return this.pageIndexValue; | ||
} | ||
/** | ||
* 更新页码 | ||
*/ | ||
set pageIndex(pageIndex) { | ||
this.pageIndexValue = pageIndex; | ||
} | ||
/** | ||
* 获取分页大小 | ||
*/ | ||
get pageSize() { | ||
return this.pageSizeValue; | ||
} | ||
/** | ||
* 更新分页大小 | ||
*/ | ||
set pageSize(pageSize) { | ||
this.pageSizeValue = pageSize; | ||
} | ||
/** | ||
* 初始化 | ||
@@ -1155,7 +1448,4 @@ */ | ||
initPaginationInfo() { | ||
if (this.paginationInfo && Object.keys(this.paginationInfo).length > 0) { | ||
const typeName = this.entityType.name; | ||
const { pageSize = 0 } = this.paginationInfo[typeName] || {}; | ||
this.pageSize = pageSize; | ||
} | ||
const pagination = this.paginationInfo || {}; | ||
this.entityState.setEntityPagination(pagination); | ||
} | ||
@@ -1166,2 +1456,7 @@ /** | ||
getEntities(filters, sorts, pageSize, pageIndex) { | ||
const currentPagination = this.entityState.getPaginationByPath("/"); | ||
if (currentPagination) { | ||
pageIndex = typeof pageSize === "number" ? pageIndex : currentPagination.pageIndex || 1; | ||
pageSize = typeof pageSize === "number" ? pageSize : currentPagination.pageSize || 0; | ||
} | ||
const entityFilter = this.buildEntityFilter(filters, sorts, pageSize, pageIndex); | ||
@@ -1171,2 +1466,6 @@ const queryPromise = this.apiProxy.filter(entityFilter).then((returnValue) => { | ||
const entities = this.buildEntites(entityDatas); | ||
const serverPagination = returnValue.pagination; | ||
if (serverPagination) { | ||
this.entityState.setPaginationByPath("/", serverPagination); | ||
} | ||
return entities; | ||
@@ -1181,3 +1480,3 @@ }); | ||
const retrievePromise = this.apiProxy.extendRetrieve(id).then((returnValue) => { | ||
const entityData = returnValue; | ||
const entityData = returnValue || {}; | ||
const entity = this.buildEntity(entityData); | ||
@@ -1243,3 +1542,2 @@ return entity; | ||
const entities = createEntitiesBySchema(entitySchema, [entityData]); | ||
this.entityState.appendEntitesByPath(entityPath, entities); | ||
return entities.pop(); | ||
@@ -1373,2 +1671,77 @@ }); | ||
} | ||
class BefTreeRepository { | ||
constructor(repository) { | ||
__publicField(this, "befRepository"); | ||
this.repository = repository; | ||
this.befRepository = repository; | ||
} | ||
} | ||
class BefParentTreeRepository extends BefTreeRepository { | ||
constructor(repository) { | ||
super(repository); | ||
this.repository = repository; | ||
} | ||
/** | ||
* 父节点分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
addSibling(id) { | ||
const apiProxy = this.befRepository.apiProxy; | ||
return apiProxy.parentHierarchyCreateSibling(id).then((returnValue) => { | ||
const entity = this.repository.buildEntity(returnValue); | ||
this.befRepository.entityState.appendEntities([entity]); | ||
return entity; | ||
}); | ||
} | ||
/** | ||
* 父节点分级方式新增子级 | ||
* @param parentId | ||
* @returns | ||
*/ | ||
addChild(parentId) { | ||
const apiProxy = this.befRepository.apiProxy; | ||
return apiProxy.parentHierarchyCreateChildLayer(parentId).then((returnValue) => { | ||
const entity = this.repository.buildEntity(returnValue); | ||
this.befRepository.entityState.appendEntities([entity]); | ||
return entity; | ||
}); | ||
} | ||
} | ||
class BefPathTreeRepository extends BefTreeRepository { | ||
constructor(repository) { | ||
super(repository); | ||
this.repository = repository; | ||
} | ||
/** | ||
* 分级码分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
addSibling(id) { | ||
const apiProxy = this.befRepository.apiProxy; | ||
return apiProxy.pathHierarchyCreateSibling(id).then((returnValue) => { | ||
const entity = this.repository.buildEntity(returnValue); | ||
this.befRepository.entityState.appendEntities([entity]); | ||
return entity; | ||
}); | ||
} | ||
/** | ||
* 分级码分级方式新增子级 | ||
* @param parentId | ||
* @returns | ||
*/ | ||
addChild(parentId) { | ||
const apiProxy = this.befRepository.apiProxy; | ||
return apiProxy.pathHierarchyCreateChildLayer(parentId).then((returnValue) => { | ||
const entity = this.repository.buildEntity(returnValue); | ||
this.befRepository.entityState.appendEntities([entity]); | ||
return entity; | ||
}); | ||
} | ||
} | ||
const befProviders = [ | ||
{ provide: BefParentTreeRepository, useClass: BefParentTreeRepository, deps: [Repository] }, | ||
{ provide: BefParentTreeRepository, useClass: BefParentTreeRepository, deps: [Repository] } | ||
]; | ||
export { | ||
@@ -1379,2 +1752,4 @@ BefChangeDetailBuilder, | ||
BefHttpUtil, | ||
BefParentTreeRepository, | ||
BefPathTreeRepository, | ||
BefProxy, | ||
@@ -1386,8 +1761,11 @@ BefProxyExtend, | ||
BefSessionService, | ||
BefTreeRepository, | ||
BefUnifiedSessionHandlingStrategy, | ||
ChangeDetailType, | ||
ContentType, | ||
FrameworkSessionService, | ||
RequestInfoUtil, | ||
SessionHandlingStrategy, | ||
SessionStorageStrategy | ||
SessionStorageStrategy, | ||
befProviders | ||
}; |
{ | ||
"name": "@farris/bef-vue", | ||
"private": false, | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"license": "Apache-2.0", | ||
"description": "", | ||
"type": "commonjs", | ||
"type": "module", | ||
"keywords": [ | ||
@@ -9,0 +9,0 @@ "farris", |
@@ -37,3 +37,3 @@ import { HttpHeaders, Entity } from '@farris/devkit-vue'; | ||
*/ | ||
onError(error: any): Promise<any>; | ||
onError(error: any, selfHandError: boolean, ignoreError: boolean): Promise<any>; | ||
/** | ||
@@ -40,0 +40,0 @@ * 扩展Headers |
@@ -63,3 +63,3 @@ import { HttpMethod, HttpRequestConfig, HttpClient } from '@farris/devkit-vue'; | ||
*/ | ||
createByPath(fpath: string, defaultValues: Array<any>): Promise<ResponseInfo>; | ||
createByPath(fpath: string, defaultValues?: Array<any>): Promise<ResponseInfo>; | ||
/** | ||
@@ -115,5 +115,77 @@ * 批量新增从表或从从表数据 | ||
/** | ||
* 父节点分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
parentHierarchyCreateSibling(id: string): Promise<any>; | ||
/** | ||
* 父节点分级方式新增子级 | ||
* @param id | ||
* @returns | ||
*/ | ||
parentHierarchyCreateChildLayer(id: string): Promise<any>; | ||
/** | ||
* 子对象父节点分级方式新增同级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodeParentHierarchyCreateSibling(ids: string[], nodes: string[]): Promise<any>; | ||
/** | ||
* 子对象父节点分级方式新增子级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodeParentHierarchyCreateChildLayer(ids: string[], nodes: string[]): Promise<any>; | ||
/** | ||
* 分级码分级方式新增同级 | ||
* @param id | ||
* @returns | ||
*/ | ||
pathHierarchyCreateSibling(id: string): Promise<any>; | ||
/** | ||
* 分级码分级方式新增子级 | ||
* @param id | ||
* @returns | ||
*/ | ||
pathHierarchyCreateChildLayer(id: string): Promise<any>; | ||
/** | ||
* 子对象分级码分级方式新增同级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodePathHierarchyCreateSibling(ids: string[], nodes: string[]): Promise<any>; | ||
/** | ||
* 子对象分级码分级方式新增子级 | ||
* @param ids 数据id顺序列表 | ||
* @param nodes 节点编号列表 | ||
* @returns | ||
*/ | ||
childNodePathHierarchyCreateChildLayer(ids: string[], nodes: string[]): Promise<any>; | ||
/** | ||
* 查询全部树信息 | ||
* @param id | ||
* @param virtualPropertyName | ||
* @param fullTreeType | ||
* @param loadType | ||
* @param filter | ||
* @returns | ||
*/ | ||
parentIDFullTreeQuery(id: string, virtualPropertyName: string, fullTreeType: string, loadType: string, filter: any[]): Promise<any>; | ||
/** | ||
* 获取帮助数据 | ||
* @param labelId | ||
* @param nodeCode | ||
* @param queryParam | ||
* @returns | ||
*/ | ||
elementhelps(labelId: string, nodeCode: string, queryParam: any): Promise<any>; | ||
/** | ||
* 发送请求 | ||
*/ | ||
request(method: HttpMethod, url: string, requestConfigs?: HttpRequestConfig, ignoreHandlingChanges?: boolean): Promise<any>; | ||
request(method: HttpMethod, url: string, requestConfigs?: HttpRequestConfig, ignoreHandlingChanges?: boolean, selfHandError?: boolean, ignoreError?: boolean): Promise<any>; | ||
private setContentType; | ||
private detectContentType; | ||
/** | ||
@@ -125,2 +197,3 @@ * 将路径转换为url | ||
private convertPathToUrl; | ||
private buildEntityFilter; | ||
} |
@@ -9,4 +9,2 @@ import { Type, Entity, EntityState, Repository, ViewModel } from '@farris/devkit-vue'; | ||
declare abstract class BefRepository<T extends Entity> extends Repository<T> { | ||
private pageIndexValue; | ||
private pageSizeValue; | ||
/** | ||
@@ -37,18 +35,2 @@ * Bef代理 | ||
/** | ||
* 当前页码 | ||
*/ | ||
get pageIndex(): number; | ||
/** | ||
* 更新页码 | ||
*/ | ||
set pageIndex(pageIndex: number); | ||
/** | ||
* 获取分页大小 | ||
*/ | ||
get pageSize(): number; | ||
/** | ||
* 更新分页大小 | ||
*/ | ||
set pageSize(pageSize: number); | ||
/** | ||
* 构造函数 | ||
@@ -80,3 +62,3 @@ */ | ||
*/ | ||
getEntities(filters: any[], sorts: any[], pageSize: number, pageIndex: number): Promise<T[]>; | ||
getEntities(filters: any[], sorts: any[], pageSize?: number, pageIndex?: number): Promise<T[]>; | ||
/** | ||
@@ -108,3 +90,3 @@ * 获取实体 | ||
*/ | ||
createEntityByPath(path: string, defaultValues: Array<any>): Promise<T>; | ||
createEntityByPath(path: string, defaultValues?: Array<any>): Promise<T>; | ||
/** | ||
@@ -111,0 +93,0 @@ * 批量创建从表或从从表实体 |
@@ -20,7 +20,10 @@ /** | ||
get formToken(): any; | ||
get params(): any; | ||
get params(): { | ||
[propName: string]: any; | ||
}; | ||
private getRuntimeFrameworkService; | ||
private get gspFrameworkService(); | ||
private isSameOrigin; | ||
private parseQueryString; | ||
} | ||
export { FrameworkSessionService }; |
@@ -9,1 +9,5 @@ export * from './types'; | ||
export * from './bef-repository'; | ||
export * from './bef-tree-repository'; | ||
export * from './bef-parent-tree-repository'; | ||
export * from './bef-path-tree-repository'; | ||
export * from './providers'; |
@@ -0,1 +1,2 @@ | ||
import { RuntimeContext } from '../types'; | ||
import { SessionHandlingStrategy } from './handling-strategies/index'; | ||
@@ -21,3 +22,3 @@ /** | ||
*/ | ||
getBeSessionId(): Promise<string>; | ||
getBeSessionId(runtimeContext?: RuntimeContext): Promise<string>; | ||
/** | ||
@@ -27,11 +28,11 @@ * 设置sessionId | ||
*/ | ||
setBeSessionId(sessionId: string): void; | ||
setBeSessionId(sessionId: string, runtimeContext?: RuntimeContext): void; | ||
/** | ||
* 清空BeSessionId | ||
*/ | ||
clearBeSessionId(): void; | ||
clearBeSessionId(runtimeContext?: RuntimeContext): void; | ||
/** | ||
* 扩展请求header | ||
*/ | ||
extendRequestHeaders(headers: any): any; | ||
extendRequestHeaders(headers: any, runtimeContext?: RuntimeContext): any; | ||
/** | ||
@@ -38,0 +39,0 @@ * 处理响应header |
@@ -5,3 +5,3 @@ import { HttpHeaders, HttpClient, Injector } from '@farris/devkit-vue'; | ||
import { SessionHandlingStrategy } from './handling-strategy'; | ||
import { RuntimeContext } from './types'; | ||
import { RuntimeContext } from '../../types'; | ||
/** | ||
@@ -38,3 +38,3 @@ * 隔离的BeSession处理策略 | ||
*/ | ||
handleRequestHeaders(headers: HttpHeaders): HttpHeaders; | ||
handleRequestHeaders(headers: HttpHeaders, runtimeContext?: RuntimeContext): HttpHeaders; | ||
/** | ||
@@ -41,0 +41,0 @@ * 处理服务器端返回的headers |
@@ -5,3 +5,3 @@ import { HttpClient, HttpHeaders, Injector } from '@farris/devkit-vue'; | ||
import { FrameworkSessionService } from '../../framework-session.service'; | ||
import { RuntimeContext } from './types'; | ||
import { RuntimeContext } from '../../types'; | ||
/** | ||
@@ -8,0 +8,0 @@ * 会话复用场景下会话处理策略 |
import { HttpHeaders, HttpClient, Injector } from '@farris/devkit-vue'; | ||
import { FrameworkSessionService } from '../../framework-session.service'; | ||
import { SessionStorageStrategy } from '../storage-strategies/index'; | ||
import { RuntimeContext } from './types'; | ||
import { RuntimeContext } from '../../types'; | ||
/** | ||
@@ -48,3 +48,3 @@ * 会话处理策略类 | ||
abstract clearSessionId(runtimeContext?: RuntimeContext): void; | ||
abstract handleRequestHeaders(headers: HttpHeaders): HttpHeaders; | ||
abstract handleRequestHeaders(headers: HttpHeaders, runtimeContext?: RuntimeContext): HttpHeaders; | ||
abstract handleReponseHeaders(headers: HttpHeaders): void; | ||
@@ -54,4 +54,5 @@ protected abstract getSessionStorageKey(runtimeContext?: RuntimeContext): string; | ||
* 获取框架SessionId | ||
* TODO: 暂不支持runtimeContext | ||
*/ | ||
getFrameworkSessionId(runtimeContext?: RuntimeContext): string; | ||
getFrameworkSessionId(): string; | ||
/** | ||
@@ -58,0 +59,0 @@ * 从缓存中获取BeSession |
@@ -1,2 +0,1 @@ | ||
export * from './types'; | ||
export * from './handling-strategy'; | ||
@@ -3,0 +2,0 @@ export * from './bef-separated-session-handling-strategy'; |
@@ -55,1 +55,16 @@ import { ChangeDetail } from './change/index'; | ||
} | ||
/** | ||
* 运行上下文 | ||
*/ | ||
export interface RuntimeContext { | ||
tabId: string; | ||
} | ||
export declare enum ContentType { | ||
NONE = 0, | ||
JSON = 1, | ||
FORM = 2, | ||
FORM_DATA = 3, | ||
TEXT = 4, | ||
BLOB = 5, | ||
ARRAY_BUFFER = 6 | ||
} |
133918
31
4459
Yes