提交 24d1285a 编写于 作者: tony001's avatar tony001

update:更新

上级 94628718
......@@ -19,10 +19,11 @@ function copyFolder(copiedPath, resultPath, direct) {
console.log(`form ${ccp} copy to ${crp}`);
} else {
try {
fs.accessSync(path.join(crp, '..'), fs.constants.W_OK);
copyFolder(ccp, crp, true);
fs.accessSync(crp, fs.constants.F_OK);
} catch (error) {
console.log('folder write error:', error);
fs.mkdirSync(crp);
} finally {
copyFolder(ccp, crp, true);
}
}
......
因为 它太大了无法显示 源差异 。您可以改为 查看blob
<template>
<div id='app'>
<app-debug-actions />
<router-view v-if="isRouterAlive"/>
</div>
</template>
......
......@@ -63,9 +63,6 @@ import AppRangeDate from './components/app-range-date/app-range-date.vue'
import AppActionBar from './components/app-actionbar/app-actionbar.vue'
import AppOrgSector from './components/app-orgsector/app-orgsector.vue'
import AppBuild from './components/app-build/app-build.vue'
import AppStudioAction from './components/app-studioaction/app-studioaction.vue'
import AppDebugActions from './components/app-debug-actions/app-debug-actions.vue'
import AppHeaderMenus from './components/app-header-menus/app-header-menus.vue'
import AppColumnLink from './components/app-column-link/app-column-link.vue'
import DropDownListDynamic from './components/dropdown-list-dynamic/dropdown-list-dynamic.vue'
import AppImagePreview from './components/app-image-preview/app-image-preview.vue'
......@@ -222,9 +219,6 @@ export const AppComponents = {
v.component('app-actionbar', AppActionBar);
v.component('app-orgsector', AppOrgSector);
v.component('app-build', AppBuild);
v.component('app-studioaction', AppStudioAction);
v.component('app-debug-actions', AppDebugActions);
v.component('app-header-menus', AppHeaderMenus);
v.component('app-column-link', AppColumnLink);
v.component('app-data-upload', () => import('./components/app-data-upload/app-data-upload.vue'));
v.component('dropdown-list-dynamic', DropDownListDynamic);
......
// 导入视图样式
.app-data-upload-view{
font-family: "Microsoft YaHei";
display: flex;
flex-direction: column;
.main-content{
height: calc(100% - 68px);
background: #FAFAFB;
......@@ -41,7 +43,7 @@
}
}
.message-container{
height: 150px;
height: calc(100% - 26px);
display: flex;
justify-content: space-between;
ul li{
......
<template>
<div
class="app-data-upload-view"
v-loading.fullscreen="isUploading"
element-loading-background="rgba(57, 57, 57, 0.2)"
>
<input
ref="inputUpLoad"
type="file"
style="display: none"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
@change="importFile"
/>
<div class="app-data-upload-view" v-loading.fullscreen="isUploading"
element-loading-background="rgba(57, 57, 57, 0.2)">
<input ref="inputUpLoad" type="file" style="display: none"
accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" @change="importFile" />
<div class="main-content">
<div v-if="importDataArray.length === 0 && !isUploading && uploadProgress !== 100" class="upload-container" @click="handleUpLoad">
<div v-if="importDataArray.length === 0 && !isUploading && uploadProgress !== 100" class="upload-container"
@click="handleUpLoad">
<img class="icon-import" src="@/assets/img/icon-import.svg" />
<span class="select-file-text">{{ $t("components.appDataUploadView.selectfile") }}</span>
</div>
<div class="data-info-container" v-if="importDataArray.length > 0 || isUploading || uploadProgress == 100">
<el-progress
class="progress"
v-show="isUploading"
:text-inside="true"
:stroke-width="14"
:percentage="uploadProgress"
></el-progress>
<span class="font-class">{{ promptInfo }}</span>
<el-progress class="progress" v-show="isUploading" :text-inside="true" :stroke-width="14"
:percentage="uploadProgress"></el-progress>
<div class="message-container">
<div class="result-list">
<template v-if="(errorInfos.length === 0)">
<span>{{ promptInfo }}</span>
</template>
<template v-else>
<span>导入错误信息</span>
<ui>
<li class="error-item" v-for="(item, index) in errorInfos" :key="index">
<span v-if="item.index">{{ $t('components.appDataUploadView.start') }} {{item.index}} {{ $t('components.appDataUploadView.row') }}</span><span v-html="item.info"></span>
</li>
</ui>
</template>
</div>
</div>
</div>
</div>
<div class="second-content">
<div class="import-template-message">{{ $t('components.appDataUploadView.datatemplatemessage') }}</div>
<div class="import-template">
<img class="icon-link" src="@/assets/img/icon-link.svg" />
<span style="cursor: pointer;"
@click="downloadTemp">{{ $t('components.appDataUploadView.datatemplate') }}</span>
</div>
</div>
<el-row class="button-container">
<el-button type="primary" @click="handleCancel">{{ $t("components.appDataUploadView.cancel") }}</el-button>
<el-button
:disabled="importDataArray.length === 0"
:loading="isUploading"
type="primary"
class="primary-button"
@click="uploadServer"
>{{ $t("components.appDataUploadView.uploadserver") }}</el-button
>
<el-button :disabled="importDataArray.length === 0" :loading="isUploading" type="primary"
class="primary-button" @click="uploadServer">{{ $t("components.appDataUploadView.uploadserver")
}}</el-button>
</el-row>
</div>
</template>
......@@ -149,14 +154,6 @@ export default class AppDataUploadView extends Vue {
*/
public isUploading: boolean = false;
/**
* 导入成功数据
*
* @type {string}
* @memberof AppDataUploadView
*/
public importSuccessData: Array<any> = [];
/**
* 导入失败数据
*
......@@ -205,6 +202,30 @@ export default class AppDataUploadView extends Vue {
*/
public uploadProgress: number = 0;
/**
* 是否忽略导入错误
*
* @type {boolean}
* @memberof AppDataUploadView
*/
public ignoreError: boolean = false;
/**
* 错误消息集合
*
* @type {any[]}
* @memberof AppDataUploadView
*/
public errorInfos: any[] = [];
/**
* 导入成功计数
*
* @type {number}
* @memberof AppDataUploadView
*/
public successCount: number = 0;
/**
* 视图参数变化
*
......@@ -242,6 +263,7 @@ export default class AppDataUploadView extends Vue {
if (this.viewparams.serviceName) {
this.entityService = await window.entityServiceRegister.getService(this.viewparams.serviceName.toLowerCase());
}
this.ignoreError = this.viewparams.ignoreError === true || this.viewparams.ignoreError === 'true' ? true : false;
//获取代码表值
this.allCodeList = await this.getChartAllCodeList();
}
......@@ -272,7 +294,7 @@ export default class AppDataUploadView extends Vue {
* @memberof AppDataUploadView
*/
public downloadTemp() {
this.importExcel(this.viewparams.appDeLogicName + this.$t("components.appDataUploadView.datatemp"), []);
this.importExcel(this.viewparams.appDeLogicName + this.$t("components.appDataUploadView.datatemplate"), []);
}
/**
......@@ -281,7 +303,6 @@ export default class AppDataUploadView extends Vue {
* @memberof AppDataUploadView
*/
public handleUpLoad() {
this.importSuccessData = [];
(this.$refs.inputUpLoad as any).click();
}
......@@ -299,6 +320,7 @@ export default class AppDataUploadView extends Vue {
this.hasImported = true;
this.isUploading = true;
this.uploadProgress = 0;
this.successCount = 0;
this.importDataArray = [];
this.sliceUploadService(tempDataArray, 0);
}
......@@ -309,11 +331,11 @@ export default class AppDataUploadView extends Vue {
* @memberof AppDataUploadView
*/
public sliceUploadService(dataArray: Array<any>, cnt: number) {
if (cnt > dataArray.length) {
if (cnt >= dataArray.length) {
this.isUploading = false;
this.uploadProgress = 100;
this.$Notice.success({ desc: this.$t("components.appDataUploadView.completed") as string });
this.handleCancel();
this.promptInfo = `${this.$t('components.appDataUploadView.completed')}, ${this.$t('components.appDataUploadView.totaldata')} ${this.successCount} ${this.$t('components.appDataUploadView.total')}`;
return;
}
let sliceArray: Array<any> = [];
......@@ -322,16 +344,17 @@ export default class AppDataUploadView extends Vue {
}
try {
this.entityService
.ImportData(this.viewdata, { name: this.importId, importData: sliceArray })
.ImportData(this.viewdata, { name: this.importId, importData: sliceArray, ignoreError: this.ignoreError })
.then((res: any) => {
const result: any = res.data;
if (result && result.rst !== 0) {
this.promptInfo = this.$t("components.appDataUploadView.importfailed") as string;
this.successCount += result.success;
if (result.total !== result.success) {
this.handleErrorInfo(result.errorinfo, cnt);
if (!this.ignoreError) {
this.isUploading = false;
return;
}
this.importSuccessData = result.data;
this.promptInfo = this.$t("components.appDataUploadView.completed") as string;
}
this.uploadProgress = Number(((cnt / dataArray.length) * 100).toFixed(2));
this.sliceUploadService(dataArray, cnt + this.sliceUploadCnt);
})
......@@ -340,8 +363,28 @@ export default class AppDataUploadView extends Vue {
this.promptInfo = this.$t("components.appDataUploadView.importfailed") as string;
});
} catch (error: any) {
this.handleErrorInfo(error.errorinfo, cnt);
if (!this.ignoreError) {
this.isUploading = false;
this.promptInfo = this.$t("components.appDataUploadView.importfailed") as string;
return;
}
this.uploadProgress = Number(((cnt / dataArray.length) * 100).toFixed(2));
this.sliceUploadService(dataArray, cnt + this.sliceUploadCnt);
}
}
/**
* 处理错误信息
*
* @memberof AppDataUploadView
*/
public handleErrorInfo(infos: any[], cnt: number) {
if (infos && infos.length) {
infos.forEach((item: any) => {
this.errorInfos.push(Object.assign({
index: cnt + item.row
}, item));
})
}
}
......@@ -351,7 +394,7 @@ export default class AppDataUploadView extends Vue {
* @memberof AppDataUploadView
*/
public handleCancel() {
this.$emit("close", []);
this.$emit("close", this.successCount > 0 ? [{ count: this.successCount }] : []);
}
/**
......@@ -381,7 +424,7 @@ export default class AppDataUploadView extends Vue {
* @memberof AppDataUploadView
*/
public handleOK() {
this.$emit("close", this.importSuccessData);
this.$emit("close", this.successCount > 0 ? [{ count: this.successCount }] : []);
}
/**
......@@ -403,7 +446,7 @@ export default class AppDataUploadView extends Vue {
let list1 = this.getFirstRow(this.workBookData);
xlsxData = this.addXlsxData(xlsxData, list1);
this.importDataArray = Util.deepCopy(xlsxData);
this.promptInfo = `${this.$t('components.appDataUploadView.selectfilesucess')}, ${this.$t('components.appDataUploadView.totaldata')} ${this.importDataArray.length} ${this.$t('components.appDataUploadView.total')}`;
this.promptInfo = this.$t('components.appDataUploadView.read') as string;
(this.$refs.inputUpLoad as any).value = "";
};
reader.readAsBinaryString(f);
......
.app-debug-actions {
position: absolute;
top: 0px;
left: 50%;
z-index: 10000;
text-align: center;
transition: all 0.3s;
margin-top: -32px;
>.actions {
.ivu-btn {
width: 100%;
}
}
>.show-buttons {
width: 100%;
height: 18px;
border-width: 0px 1px 1px 1px;
border-style: solid;
border-color: #8893a7;
text-align: center;
color: #8893a7;
cursor: pointer;
>.button {
margin-top: -5px;
}
}
}
.app-debug-actions:hover {
margin-top: 0px;
}
\ No newline at end of file
<template>
<div class="app-debug-actions" v-if="isShow">
<div class="actions">
<button-group vertical>
<i-button :title="$t('components.appDebugActions.button')" :type="sdc.isShowTool ? 'warning' : 'info'" ghost @click="() => sdc.showToolChange()" :icon="sdc.isShowTool ? 'ios-bug' : 'ios-bug-outline'" ></i-button>
</button-group>
</div>
<div class="show-buttons">
<div class="button"><i class="ivu-icon ivu-icon-ios-arrow-down" /></div>
</div>
</div>
</template>
<script lang = 'ts'>
import { Vue, Component } from 'vue-property-decorator';
import { StudioActionUtil } from '@/utils';
import { Environment } from '@/environments/environment';
/**
* 开发模式控制行为组
*
* @export
* @class AppDebugActions
* @extends {Vue}
*/
@Component({
})
export default class AppDebugActions extends Vue {
/**
* 是否显示
*
* @type {boolean}
* @memberof AppDebugActions
*/
public isShow:boolean = Environment.devMode;
/**
* 配置平台操作控制器
*
* @type {StudioActionController}
* @memberof AppDebugActions
*/
public sdc: StudioActionUtil = StudioActionUtil.getInstance();
}
</script>
<style lang = "less">
@import "./app-debug-actions.less";
</style>
\ No newline at end of file
.app-header-menus {
display: flex;
align-items: center;
height: 100%;
line-height: 20px;
>.app-header-menu-item{
height: 24px;
display: flex;
align-items: center;
margin-right: 16px;
color: #8893a7;
border: 1px solid rgba(0, 0, 0, 0);
cursor: pointer;
}
>.app-header-menu-item.icon {
>.app-header-menu-item-icon {
font-size: 20px;
}
>.app-header-menu-item-img {
height: 20px;
width: 20px;
>img {
height: 100%;
width: 100%;
}
}
}
>.app-header-menu-item.icon:hover{
color: #68758e;
text-decoration: none;
}
>.app-header-menu-item.text {
border-radius: 4px;
border: 1px solid #8893a7;
text-align: center;
font-size: 12px;
padding: 2px 4px;
>.app-header-menu-item-icon {
width: 20px;
height: 20px;
overflow: hidden;
font-size: 16px;
margin-right: 3px;
margin-top: -3px;
}
>.app-header-menu-item-img {
height: 16px;
width: 16px;
margin-right: 3px;
>img {
height: 100%;
width: 100%;
}
}
}
>.app-header-menu-item.text:hover {
color: #107fff;
border: 1px solid #107fff;
}
}
.app-header-menus:hover {
background: none !important;
}
\ No newline at end of file
<template>
<div class="app-header-menus" v-if="isShow">
<div v-for="(menu,index) in menus" :key="index" class="app-header-menu-item text" @click="openWindow(menu)">
<div class="app-header-menu-item-icon">
<i :class="menu.iconcls" :aria-hidden="true" />
</div>
<div class="app-header-menu-item-text">{{$t(menu.title)}}</div>
</div>
</div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Model, Emit } from "vue-property-decorator";
import { Subject } from "rxjs";
import { Environment } from '@/environments/environment';
@Component({
})
export default class AppHeaderMenus extends Vue {
/**
* 是否显示
*
* @type {boolean}
* @memberof AppHeaderMenus
*/
public isShow:boolean = Environment.devMode;
/**
* 菜单数据
*
* @type {any}
* @memberof AppHeaderMenus
*/
public menus:any = [
{
name: "ibizlab",
title: "components.appHeaderMenus.ibizlab.title",
url: Environment.ibizlabtUrl,
iconcls: 'fa fa-home',
},
{
name: "publishProject",
title: "components.appHeaderMenus.publishProject.title",
url: Environment.PublishProjectUrl,
iconcls: 'fa fa-folder-open-o',
},
{
name: "ibizstudio",
title: "components.appHeaderMenus.ibizstudio.title",
url: `${Environment.StudioUrl}?#/common_mosindex/srfkeys=${Environment.SysId}`,
iconcls: 'fa fa-wrench',
},
{
name: "ibizbbs",
title: "components.appHeaderMenus.ibizbbs.title",
url: Environment.ibizbbstUrl,
iconcls: 'fa fa-comments-o',
},
];
/**
* 触发界面行为
*
* @memberof AppHeaderMenus
*/
public openWindow(menu:any){
window.open(menu.url, '_blank');
}
}
</script>
<style lang='less'>
@import "./app-header-menus.less";
</style>
\ No newline at end of file
......@@ -6,7 +6,8 @@
</div>
<div v-else-if="Object.is(contentType,'HTML')" :class="contentStyle" v-html="htmlContent" />
<div v-else-if="Object.is(contentType,'IMAGE')" :class="contentStyle">
<i :class="imageClass ? imageClass : ''"></i>
<img v-if="imageSrc && imageSrc !== ''" :src="imageSrc"/>
<i v-if="imageClass" :class="imageClass"></i>
</div>
</div>
</template>
......@@ -57,6 +58,14 @@ export default class AppRawItem extends Vue {
*/
@Prop() public imageClass?: string;
/**
* 图片路径
*
* @type {strin}
* @memberof AppRawItem
*/
@Prop() public imageSrc?: string;
/**
* 标题
*
......
.app-studioaction {
.studio-config-container {
position: absolute;
top: 10px;
right: 30px;
z-index: 1;
background: rgba(22, 22, 22, 0.6);
border-radius: 5px;
display: flex;
>.title {
color: white;
border-right: 1px solid #333;
padding: 5px;
text-align: center;
}
>.actions {
display: flex;
}
}
}
\ No newline at end of file
<template>
<div class="app-studioaction" v-if="isDevMode">
<div v-show="sdc.isShowTool" class="studio-config-container">
<div class="title">
{{viewTitle}}
</div>
<div class="actions">
<div class="action-item" :title="$t('components.appStudioAction.configTitle')">
<i-button type="text" ghost @click="configView()">{{$t('components.appStudioAction.configButton')}}</i-button>
</div>
<div class="action-item" :title="$t('components.appStudioAction.issueTitle')">
<i-button type="text" ghost @click="createIssues()">{{$t('components.appStudioAction.issueButton')}}</i-button>
</div>
</div>
</div>
</div>
</template>
<script lang = 'ts'>
import { Vue, Component, Inject, Prop } from "vue-property-decorator";
import { Environment } from '@/environments/environment';
import { StudioActionUtil } from '@/utils';
@Component({
})
export default class AppStudioAction extends Vue {
/**
* 视图标题
*
* @type {string}
* @memberof AppStudioAction
*/
@Prop() public viewTitle!:string;
/**
* 视图名称
*
* @type {string}
* @memberof AppStudioAction
*/
@Prop() public viewName!:string;
/**
* 是否开发为环境
*
* @type {boolean}
* @memberof AppStudioAction
*/
public isDevMode:boolean = Environment.devMode;
/**
* 配置平台操作控制器
*
* @type {StudioActionController}
* @memberof AppStudioAction
*/
public sdc: StudioActionUtil = StudioActionUtil.getInstance();
/**
* 触发配置
*
* @protected
* @memberof AppStudioAction
*/
protected configView(): void {
this.sdc.openStudioConfigView(this.viewName);
}
/**
* 新建issues
*
* @protected
* @memberof AppStudioAction
*/
protected createIssues(): void {
this.sdc.createdIssues(this.viewName);
}
}
</script>
<style lang="less">
@import "./app-studioaction.less";
</style>
\ No newline at end of file
......@@ -5,7 +5,6 @@
</template>
<script lang = 'ts'>
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { ImgurlBase64 } from '@/utils';
import { Environment } from "@/environments/environment";
@Component({})
export default class AppFieldImageDynamic extends Vue {
......@@ -119,13 +118,8 @@ export default class AppFieldImageDynamic extends Vue {
try {
const _files = JSON.parse(this.value);
const file = _files instanceof Array ? _files[0] : null;
const url =
file && file.id ? `${this.downloadUrl}/${file.id}` : "";
ImgurlBase64.getInstance()
.getImgURLOfBase64(url)
.then((res: any) => {
this.dynaImgUrl = res;
});
const url = file && file.id ? `${this.downloadUrl}/${file.id}` : "";
this.dynaImgUrl = url;
} catch (error) {
this.dynaImgUrl = this.value;
}
......
......@@ -37,10 +37,12 @@ export class UILogicActiveCtrlParam extends UILogicParamBase {
* @memberof UILogicActiveCtrlParam
*/
private getActiveCtrl(params: any) {
const { actioncontext } = params;
if (actioncontext.viewCtx && actioncontext.viewCtx.ctrl) {
const { actioncontext, xData } = params;
if (xData) {
return xData;
} else if (actioncontext.viewCtx && actioncontext.viewCtx.ctrl) {
return actioncontext.viewCtx.ctrl;
}else{
} else {
return null;
}
}
......
......@@ -60,4 +60,37 @@ export class AppDeUILogicEntityListParam extends UILogicParamBase {
this.realValue = [];
}
/**
* 获取指定属性值
*
* @param {string} strName
* @memberof AppDeUILogicEntityListParam
*/
public get(strName: string) {
if (Object.prototype.toString.call(this.realValue) !== '[object Array]') {
throw new Error(`逻辑参数${this.strCodeName}非对象类型参数无法执行获取指定属性值`);
}
if (!isNaN(Number(strName))) {
return this.realValue[Number(strName)];
}
throw new Error(`逻辑参数${this.strCodeName}对象列表类型参数无法获取非数值下标属性`);
}
/**
* 设置指定属性值
*
* @param {string} strName
* @param {*} value
* @memberof AppDeUILogicEntityListParam
*/
public set(strName: string, value: any) {
if (Object.prototype.toString.call(this.realValue) !== '[object Array]') {
throw new Error(`逻辑参数${this.strCodeName}无法执行绑定非对象列表类型参数`);
}
if (isNaN(Number(strName))) {
throw new Error(`逻辑参数${this.strCodeName}对象列表类型参数无法执行绑定到非数值下标`);
}
this.realValue[Number(strName)] = value;
}
}
\ No newline at end of file
......@@ -442,7 +442,6 @@ export class PanelDetailModel {
// 识别父FLEX
if (parentItem) {
if (parentItem.layout == 'FLEX') {
Object.assign(boxStyle, { 'display': 'contents' });
Object.assign(boxStyle, { 'flex-grow': this.flexGrow ? this.flexGrow : 0 });
}
// 识别SIMPLEFLEX
......
import { Http } from '@/utils';
import { Http, Util } from '@/utils';
import CodeListService from "@/codelist/codelist-service";
/**
......@@ -28,7 +28,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public tempStorage:any;
public tempStorage: any;
/**
* 当前DE标识
......@@ -37,7 +37,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public APPDEKEY:string= '';
public APPDEKEY: string = '';
/**
* 当前APPDE标识
......@@ -46,7 +46,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public APPLYDEKEY:string= '';
public APPLYDEKEY: string = '';
/**
* 当前NAME
......@@ -55,7 +55,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public APPDENAME:string= '';
public APPDENAME: string = '';
/**
* 当前主信息名
......@@ -64,7 +64,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public APPDETEXT:string= '';
public APPDETEXT: string = '';
/**
* 当前系统名
......@@ -73,7 +73,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public SYSTEMNAME:string= '';
public SYSTEMNAME: string = '';
/**
* 当前应用名
......@@ -82,7 +82,7 @@ export default class EntityService {
* @type {(string)}
* @memberof EntityService
*/
public APPNAME:string= '';
public APPNAME: string = '';
/**
* Creates an instance of EntityService.
......@@ -100,17 +100,17 @@ export default class EntityService {
*
* @memberof EntityService
*/
public getCodeList(tag:string,codelistType:string,context:any = {},param:any ={}){
return new Promise((resolve:any,reject:any) =>{
public getCodeList(tag: string, codelistType: string, context: any = {}, param: any = {}) {
return new Promise((resolve: any, reject: any) => {
let codeListService = new CodeListService();
if(tag && Object.is(codelistType,"STATIC")){
codeListService.getStaticItems(tag).then((items:any) =>{
if (tag && Object.is(codelistType, "STATIC")) {
codeListService.getStaticItems(tag).then((items: any) => {
resolve(items);
})
}else if(tag && Object.is(codelistType,"DYNAMIC")){
codeListService.getItems(tag,context,param).then((res:any) => {
} else if (tag && Object.is(codelistType, "DYNAMIC")) {
codeListService.getItems(tag, context, param).then((res: any) => {
resolve(res);
}).catch((error:any) => {
}).catch((error: any) => {
reject(`${tag}代码表不存在`);
});
}
......@@ -122,7 +122,7 @@ export default class EntityService {
*
* @memberof EntityService
*/
public initBasicData(){
public initBasicData() {
}
......@@ -135,8 +135,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.SelectTemp(context,data,isloading);
public async Select(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.SelectTemp(context, data, isloading);
}
/**
......@@ -148,17 +148,17 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async SelectTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
if(result){
let tempResult:any = result.filter((item:any) =>{
return Object.is(item[this.APPDEKEY],data[this.APPDEKEY]);
public async SelectTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
if (result) {
let tempResult: any = result.filter((item: any) => {
return Object.is(item[this.APPDEKEY], data[this.APPDEKEY]);
})
let tempResultData:any = tempResult.length>0?tempResult[0]:Object.assign({},data);
return {"status":200,"data":tempResultData};
}else{
return {"status":500,"data":null};
let tempResultData: any = tempResult.length > 0 ? tempResult[0] : Object.assign({}, data);
return { "status": 200, "data": tempResultData };
} else {
return { "status": 500, "data": null };
}
}
}
......@@ -172,16 +172,19 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async CreateTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let tempData:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
public async CreateTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let tempData: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
data.srffrontuf = "0";
data[this.APPDEKEY] = null;
if (!tempData || tempData === null || tempData === undefined) {
tempData = [];
}
tempData.push(data);
this.tempStorage.setItem(context.srfsessionkey+'_'+this.APPDENAME,JSON.stringify(tempData));
return {"status":200,"data":data};
}else{
return {"status":200,"data":{}};
this.tempStorage.setItem(context.srfsessionkey + '_' + this.APPDENAME, JSON.stringify(tempData));
return { "status": 200, "data": data };
} else {
return { "status": 200, "data": {} };
}
}
......@@ -194,17 +197,17 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
if(result){
let tempResult:any = result.filter((item:any) =>{
return Object.is(item[this.APPDEKEY],data[this.APPDEKEY]);
public async GetTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
if (result) {
let tempResult: any = result.filter((item: any) => {
return Object.is(item[this.APPDEKEY], data[this.APPDEKEY]);
})
let tempResultData:any = tempResult.length>0?tempResult[0]:Object.assign({},data);
return {"status":200,"data":tempResultData};
}else{
return {"status":500,"data":null};
let tempResultData: any = tempResult.length > 0 ? tempResult[0] : Object.assign({}, data);
return { "status": 200, "data": tempResultData };
} else {
return { "status": 500, "data": null };
}
}
}
......@@ -218,8 +221,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.UpdateTemp(context,data,isloading);
public async Update(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.UpdateTemp(context, data, isloading);
}
/**
......@@ -231,8 +234,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async UpdateTempMajor(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Update(context,data,isloading);
public async UpdateTempMajor(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Update(context, data, isloading);
}
/**
......@@ -244,8 +247,21 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 Save 未实现' }};
public async Save(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 Save 未实现' } };
}
/**
* SaveDraft接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof EntityService
*/
public async SaveDraft(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 SaveDraft 未实现' } };
}
/**
......@@ -257,28 +273,28 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async UpdateTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
let tempData:Array<any> = [];
if(result && result.length >0){
result.forEach((item:any) => {
let singleData:any = {};
if(Object.is(item[this.APPDEKEY],data[this.APPDEKEY])){
Object.keys(item).forEach((field:any) =>{
singleData[field] = data[field]?data[field]:item[field];
public async UpdateTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
let tempData: Array<any> = [];
if (result && result.length > 0) {
result.forEach((item: any) => {
let singleData: any = {};
if (Object.is(item[this.APPDEKEY], data[this.APPDEKEY])) {
Object.keys(item).forEach((field: any) => {
singleData[field] = data[field] ? data[field] : item[field];
})
}
if(Object.keys(singleData).length >0){
if (Object.keys(singleData).length > 0) {
tempData.push(singleData);
}else{
} else {
tempData.push(item);
}
});
this.tempStorage.setItem(context.srfsessionkey+'_'+this.APPDENAME,JSON.stringify(tempData));
return {"status":200,"data":data};
}else{
return {"status":500,"data":null};
this.tempStorage.setItem(context.srfsessionkey + '_' + this.APPDENAME, JSON.stringify(tempData));
return { "status": 200, "data": data };
} else {
return { "status": 500, "data": null };
}
}
}
......@@ -292,18 +308,18 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async RemoveTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
if(result){
let tempResult:any = result.filter((item:any) =>{
public async RemoveTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
if (result) {
let tempResult: any = result.filter((item: any) => {
// return !( Object.is(item[this.APPDEKEY],data[this.APPDEKEY]) && Object.is(item[this.APPDETEXT],data[this.APPDETEXT]));
return !Object.is(item[this.APPDEKEY],data[this.APPDEKEY]);
return !Object.is(item[this.APPDEKEY], data[this.APPDEKEY]);
})
this.tempStorage.setItem(context.srfsessionkey+'_'+this.APPDENAME,JSON.stringify(tempResult));
return {"status":200,"data":data};
}else{
return {"status":500,"data":null};
this.tempStorage.setItem(context.srfsessionkey + '_' + this.APPDENAME, JSON.stringify(tempResult));
return { "status": 200, "data": data };
} else {
return { "status": 500, "data": null };
}
}
}
......@@ -317,19 +333,19 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_'+this.APPDENAME) as any);
if(result){
let flag:boolean = false;
result.forEach((item:any) => {
if(Object.is(item[this.APPDEKEY],data[this.APPDEKEY])){
public async CheckKey(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + '_' + this.APPDENAME) as any);
if (result) {
let flag: boolean = false;
result.forEach((item: any) => {
if (Object.is(item[this.APPDEKEY], data[this.APPDEKEY])) {
flag = true;
}
});
return {"status":200,"data":flag};
}else{
return {"status":500,"data":null};
return { "status": 200, "data": flag };
} else {
return { "status": 500, "data": null };
}
}
}
......@@ -343,8 +359,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraftTemp(context,data,isloading);
public async GetDraft(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraftTemp(context, data, isloading);
}
/**
......@@ -356,8 +372,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.RemoveTemp(context,data,isloading);
public async Remove(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.RemoveTemp(context, data, isloading);
}
/**
......@@ -369,8 +385,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async CreateTempMajor(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Create(context,data,isloading);
public async CreateTempMajor(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Create(context, data, isloading);
}
/**
......@@ -382,8 +398,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async RemoveTempMajor(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Remove(context,data,isloading);
public async RemoveTempMajor(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Remove(context, data, isloading);
}
/**
......@@ -395,8 +411,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.GetTemp(context,data,isloading);
public async Get(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.GetTemp(context, data, isloading);
}
/**
......@@ -408,8 +424,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetDraftTempMajor(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraft(context,data,isloading);
public async GetDraftTempMajor(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraft(context, data, isloading);
}
/**
......@@ -421,8 +437,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.CreateTemp(context,data,isloading);
public async Create(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.CreateTemp(context, data, isloading);
}
/**
......@@ -434,8 +450,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetTempMajor(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Get(context,data,isloading);
public async GetTempMajor(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Get(context, data, isloading);
}
/**
......@@ -447,14 +463,14 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetDraftTemp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData = {srfsessionkey:context.srfsessionkey};
public async GetDraftTemp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
let tempData = { srfsessionkey: context.srfsessionkey };
Object.defineProperty(tempData, this.APPDEKEY, {
enumerable: true,
value: data[this.APPDEKEY]
});
Object.assign(data,tempData);
return {"status":200,"data":data};
Object.assign(data, tempData);
return { "status": 200, "data": data };
}
/**
......@@ -466,8 +482,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 FetchDefault 未实现' }};
public async FetchDefault(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 FetchDefault 未实现' } };
}
/**
......@@ -479,8 +495,17 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FetchTempDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return { status: 500, data: { title: '失败', message: '预置实体行为 FetchDefault 未实现' }};
public async FetchTempDefault(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey + `_${this.APPDENAME.toLowerCase()}`), 'undefined')) {
let result: any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey + `_${this.APPDENAME.toLowerCase()}`) as any);
if (result) {
return { "status": 200, "data": result };
} else {
return { "status": 200, "data": [] };
}
} else {
return { "status": 200, "data": [] };
}
}
/**
......@@ -492,8 +517,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterUpdate(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Update(context,data,isloading);
public async FilterUpdate(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Update(context, data, isloading);
}
/**
......@@ -505,8 +530,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterSearch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.FetchDefault(context,data,isloading);
public async FilterSearch(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.FetchDefault(context, data, isloading);
}
/**
......@@ -518,8 +543,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterGet(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Get(context,data,isloading);
public async FilterGet(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Get(context, data, isloading);
}
/**
......@@ -531,8 +556,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterCreate(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Create(context,data,isloading);
public async FilterCreate(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Create(context, data, isloading);
}
/**
......@@ -544,8 +569,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterGetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraft(context,data,isloading);
public async FilterGetDraft(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.GetDraft(context, data, isloading);
}
/**
......@@ -557,8 +582,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterRemove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.Remove(context,data,isloading);
public async FilterRemove(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.Remove(context, data, isloading);
}
/**
......@@ -570,8 +595,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async FilterFetch(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return this.FetchDefault(context,data,isloading);
public async FilterFetch(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return this.FetchDefault(context, data, isloading);
}
/**
......@@ -583,10 +608,10 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async ImportData(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let _data:Array<any> = [];
public async ImportData(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
let _data: Array<any> = [];
if (data && data.importData) _data = data.importData;
return Http.getInstance().post(`/${this.APPDENAME}/import?config=${data.name}`,_data,isloading);
return Http.getInstance().post(`/${this.APPDENAME}/import?config=${data.name}&ignoreerror=${data.ignoreerror ? true : false}`, _data, isloading);
}
/**
......@@ -598,8 +623,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async createBatch(context: any = {},data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/batch`,data,isloading);
public async createBatch(context: any = {}, data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/batch`, data, isloading);
}
/**
......@@ -611,8 +636,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async saveBatch(context: any = {},data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/savebatch`,data,isloading);
public async saveBatch(context: any = {}, data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/savebatch`, data, isloading);
}
/**
......@@ -624,8 +649,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async updateBatch(context: any = {},data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().put(`/${this.APPDENAME}/batch`,data,isloading);
public async updateBatch(context: any = {}, data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().put(`/${this.APPDENAME}/batch`, data, isloading);
}
/**
......@@ -637,8 +662,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async removeBatch(context: any = {},data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().delete(`/${this.APPDENAME}/batch`,isloading,data[this.APPDEKEY]);
public async removeBatch(context: any = {}, data: any, isloading?: boolean): Promise<any> {
return Http.getInstance().delete(`/${this.APPDENAME}/batch`, data[this.APPDEKEY], isloading);
}
/**
......@@ -650,9 +675,9 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async getDataInfo(context: any = {},data: any, isloading?: boolean):Promise<any> {
if(context[this.APPLYDEKEY]){
return this.Get(context,data, isloading);
public async getDataInfo(context: any = {}, data: any, isloading?: boolean): Promise<any> {
if (context[this.APPLYDEKEY]) {
return this.Get(context, data, isloading);
}
}
......@@ -665,8 +690,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async getDynaModel(context: any = {},data: any, isloading?: boolean):Promise<any> {
if(data && data.configType && data.targetType){
public async getDynaModel(context: any = {}, data: any, isloading?: boolean): Promise<any> {
if (data && data.configType && data.targetType) {
return Http.getInstance().get(`/configs/${data.configType}/${data.targetType}`);
}
}
......@@ -680,9 +705,9 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async setDynaModel(context: any = {},data: any, isloading?: boolean):Promise<any> {
if(data && data.configType && data.targetType){
return Http.getInstance().put(`/configs/${data.configType}/${data.targetType}`,{model:data.model});
public async setDynaModel(context: any = {}, data: any, isloading?: boolean): Promise<any> {
if (data && data.configType && data.targetType) {
return Http.getInstance().put(`/configs/${data.configType}/${data.targetType}`, { model: data.model });
}
}
......@@ -696,16 +721,16 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFStart(context: any = {},data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
if(localdata && Object.keys(localdata).length > 0){
const requestData:any = {};
Object.assign(requestData,{activedata:data});
Object.assign(requestData,localdata);
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${data[this.APPDEKEY]}/process-instances`,requestData,isloading);
}else{
const requestData:any = {};
Object.assign(requestData,{wfdata:data});
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfstart`,requestData,isloading);
public async WFStart(context: any = {}, data: any = {}, isloading?: boolean, localdata?: any): Promise<any> {
if (localdata && Object.keys(localdata).length > 0) {
const requestData: any = {};
Object.assign(requestData, { activedata: data });
Object.assign(requestData, localdata);
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${data[this.APPDEKEY]}/process-instances`, requestData, isloading);
} else {
const requestData: any = {};
Object.assign(requestData, { wfdata: data });
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfstart`, requestData, isloading);
}
}
......@@ -719,8 +744,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFClose(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfclose`,data,isloading);
public async WFClose(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfclose`, data, isloading);
}
......@@ -733,8 +758,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFMarkRead(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfmarkread`,data,isloading);
public async WFMarkRead(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfmarkread`, data, isloading);
}
/**
......@@ -746,8 +771,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFGoto(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfgoto`,data,isloading);
public async WFGoto(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfgoto`, data, isloading);
}
/**
......@@ -759,8 +784,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFRollback(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfrollback`,data,isloading);
public async WFRollback(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfrollback`, data, isloading);
}
/**
......@@ -772,8 +797,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFRestart(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfrestart`,data,isloading);
public async WFRestart(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfrestart`, data, isloading);
}
/**
......@@ -785,8 +810,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFReassign(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfreassign`,data,isloading);
public async WFReassign(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfreassign`, data, isloading);
}
......@@ -799,7 +824,7 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFGetWorkFlow(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
public async WFGetWorkFlow(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/process-definitions`);
}
......@@ -812,7 +837,7 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFGetWFStep(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
public async WFGetWFStep(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/process-definitions-nodes`);
}
......@@ -825,7 +850,7 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetWFLink(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
public async GetWFLink(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/usertasks/${data['taskDefinitionKey']}/ways`);
}
......@@ -838,7 +863,7 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async getWFLinks(context: any = {},data: any = {}, isloading?: boolean):Promise<any>{
public async getWFLinks(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/process-definitions/${data['processDefinitionKey']}/usertasks/${data['userTaskId']}/ways`);
}
......@@ -851,8 +876,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async wfSubmitBatch(context: any = {},data: any = {},localdata:any,isloading?: boolean):Promise<any>{
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/process-definitions/${localdata['processDefinitionKey']}/usertasks/${localdata['taskDefinitionKey']}/ways/${localdata['sequenceFlowId']}/submit`,data);
public async wfSubmitBatch(context: any = {}, data: any = {}, localdata: any, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/process-definitions/${localdata['processDefinitionKey']}/usertasks/${localdata['taskDefinitionKey']}/ways/${localdata['sequenceFlowId']}/submit`, data);
}
/**
......@@ -864,7 +889,7 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async GetWFHistory(context: any = {},data: any = {}, isloading?: boolean):Promise<any> {
public async GetWFHistory(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/process-instances/alls/history`);
}
......@@ -877,8 +902,8 @@ export default class EntityService {
* @return {*} {Promise<any>}
* @memberof EntityService
*/
public async BeforeSign(context:any = {},data:any = {}, isloading?: boolean):Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/tasks/${context.taskId}/beforesign`,data);
public async BeforeSign(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/tasks/${context.taskId}/beforesign`, data);
}
/**
......@@ -890,8 +915,8 @@ export default class EntityService {
* @return {*} {Promise<any>}
* @memberof EntityService
*/
public async TransFerTask(context:any = {},data:any = {}, isloading?: boolean):Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/tasks/${context.taskId}/transfer`,data);
public async TransFerTask(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/tasks/${context.taskId}/transfer`, data);
}
/**
......@@ -903,7 +928,7 @@ export default class EntityService {
* @return {*} {Promise<any>}
* @memberof EntityService
*/
public async SendBack(context:any = {},data:any = {}, isloading?: boolean):Promise<any> {
public async SendBack(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${context[this.APPLYDEKEY]}/tasks/${context.taskId}/sendback`);
}
......@@ -917,27 +942,27 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFSubmit(context: any = {},data: any = {}, isloading?: boolean,localdata?:any): Promise<any> {
if(localdata && Object.keys(localdata).length > 0){
const requestData:any = {};
if(data.viewparams){
public async WFSubmit(context: any = {}, data: any = {}, isloading?: boolean, localdata?: any): Promise<any> {
if (localdata && Object.keys(localdata).length > 0) {
const requestData: any = {};
if (data.viewparams) {
delete data.viewparams;
}
Object.assign(requestData,{activedata:data});
Object.assign(requestData,localdata);
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${data[this.APPDEKEY]}/tasks/${localdata['taskId']}`,requestData,isloading);
}else{
const requestData:any = {};
if(data.srfwfmemo){
Object.assign(requestData, { activedata: data });
Object.assign(requestData, localdata);
return Http.getInstance().post(`/wfcore/${this.SYSTEMNAME}-app-${this.APPNAME}/${this.APPDENAME}/${data[this.APPDEKEY]}/tasks/${localdata['taskId']}`, requestData, isloading);
} else {
const requestData: any = {};
if (data.srfwfmemo) {
requestData.srfwfmemo = JSON.parse(JSON.stringify(data)).srfwfmemo;
delete data.srfwfmemo;
}
if(data.viewparams){
if (data.viewparams) {
delete data.viewparams;
}
Object.assign(requestData,{wfdata:data});
Object.assign(requestData,{opdata:{srfwfiatag:context.srfwfiatag,srfwfstep:context.srfwfstep}});
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfsubmit`,requestData,isloading);
Object.assign(requestData, { wfdata: data });
Object.assign(requestData, { opdata: { srfwfiatag: context.srfwfiatag, srfwfstep: context.srfwfstep } });
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/wfsubmit`, requestData, isloading);
}
}
......@@ -967,8 +992,8 @@ export default class EntityService {
* @returns {Promise<any>}
* @memberof EntityService
*/
public async WFGetProxyData(context: any = {},data: any = {}, isloading?: boolean): Promise<any>{
return Http.getInstance().get(`/${this.APPDENAME}/${context[this.APPLYDEKEY]}/wfgetproxydata`,data,isloading);
public async WFGetProxyData(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/${this.APPDENAME}/${context[this.APPLYDEKEY]}/wfgetproxydata`, data, isloading);
}
/**
......@@ -978,9 +1003,9 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async testDataInWF(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(!context.stateField || !context.stateValue) return false;
if(context.stateValue == data[context.stateField]){
public async testDataInWF(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
if (!context.stateField || !context.stateValue) return false;
if (context.stateValue == data[context.stateField]) {
return true;
}
return false;
......@@ -993,7 +1018,7 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async testUserWFSubmit(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
public async testUserWFSubmit(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return true;
}
......@@ -1004,10 +1029,10 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async testUserExistWorklist(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const requestData:any = {};
Object.assign(requestData,{wfdata:data});
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/testuserexistworklist`,requestData,isloading);
public async testUserExistWorklist(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const requestData: any = {};
Object.assign(requestData, { wfdata: data });
return Http.getInstance().post(`/${this.APPDENAME}/${data[this.APPDEKEY]}/testuserexistworklist`, requestData, isloading);
}
/**
......@@ -1017,8 +1042,8 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async getAllApp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/uaa/access-center/app-switcher/default`,data,isloading);
public async getAllApp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/uaa/access-center/app-switcher/default`, data, isloading);
}
/**
......@@ -1028,8 +1053,8 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async updateChooseApp(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().put(`/uaa/access-center/app-switcher/default`,data,isloading);
public async updateChooseApp(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().put(`/uaa/access-center/app-switcher/default`, data, isloading);
}
/**
......@@ -1039,8 +1064,8 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async changPassword(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/v7/changepwd`,data,isloading);
public async changPassword(context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/v7/changepwd`, data, isloading);
}
/**
......@@ -1050,8 +1075,8 @@ export default class EntityService {
* @param data
* @param isloading
*/
public async getPredefinedCodelist(tag:string,data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/dictionarys/codelist/${tag}`,data,isloading);
public async getPredefinedCodelist(tag: string, data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/dictionarys/codelist/${tag}`, data, isloading);
}
}
\ No newline at end of file
......@@ -45,18 +45,28 @@
.el-table th {
padding: 5px 0;
}
.el-table th.gutter:last-of-type {
display: block !important;
width: 10px !important;
}
.grid .el-table__body-wrapper .el-table__row td{
border-left: 1px solid rgb(245,245,245);
border-top: 1px solid rgb(245,245,245);
// 解决横向滚动条错位问题
.el-scrollbar__wrap {
// 滚动条样式
&::-webkit-scrollbar {
width: 10px;
height: 10px;
border: none;
}
&::-webkit-scrollbar-thumb {
border-radius: 10px;
}
&::-webkit-scrollbar-track {
border-radius: 10px;
}
}
.el-table--enable-row-hover .el-table__body tr:hover>td {
background-color: #badfffba !important;
}
.grid .el-table__body-wrapper .grid-selected-row{
.grid .grid-selected-row{
background-color: #badfffba !important;
}
......
......@@ -13,6 +13,5 @@
</noscript>
<div id="app"></div>
<script src="./environments/environment.js"></script>
<script src="./assets/js/avue.min.js"></script>
</body>
</html>
......@@ -65,6 +65,7 @@ export class AppDrawer {
const vm = new Vue({
store: store,
i18n: i18n,
router: (window as any).appRouter,
render(h) {
return h(component, { props });
}
......
......@@ -2,7 +2,6 @@ import Vue from 'vue';
import { Subject } from 'rxjs';
import store from '../../store';
import i18n from '@/locale';
import { ViewTool } from '../view-tool/view-tool';
import AppModalCompponent from "./app-modal.vue";
import './app-modal.less';
......@@ -64,6 +63,7 @@ export class AppModal {
this.VueExample = new Vue({
store: store,
i18n: i18n,
router: (window as any).appRouter,
render(h) {
return h(AppModalCompponent, { props });
}
......
......@@ -103,6 +103,7 @@ export class AppPopover {
this.vueExample = new Vue({
el: div,
store: store,
router: (window as any).appRouter,
i18n: i18n,
data: { content: null, width: 300, height: 300 },
methods: {
......
......@@ -11,5 +11,3 @@ export { Errorlog } from './decorators/errorlog';
export { UIActionTool } from './uiaction-tool/uiaction-tool';
export { LoadAppData } from './load-app-data/load-app-data';
export { Interceptors } from './interceptor/interceptor';
\ No newline at end of file
export { StudioActionUtil } from './studio-action/StudioActionUtil';
export { ImgurlBase64 } from './util/imgurl-base64';
\ No newline at end of file
......@@ -86,13 +86,6 @@ export class Interceptors {
if (appdata && appdata.context) {
config.headers['srforgsectorid'] = appdata.context.srforgsectorid;
}
if(!window.localStorage.getItem('token')){
let arr;
let reg = new RegExp("(^| )ibzuaa-token=([^;]*)(;|$)");
if (arr = document.cookie.match(reg)){
window.localStorage.setItem('token',unescape(arr[2]));
}
}
if (window.localStorage.getItem('token')) {
const token = window.localStorage.getItem('token');
config.headers['Authorization'] = `Bearer ${token}`;
......
......@@ -198,7 +198,7 @@ export default class {
}
// 处理textarea
} else {
copiedInput.innerHTML = item.value;
copiedInput.textContent = item.value;
copiedInput.setAttribute('html', item.value);
}
}
......
import Vue from 'vue';
import { Http } from '@/utils';
import { Environment } from '@/environments/environment';
import { on } from '@/utils/dom/dom';
/**
* Studio Debug工具类
*
* @export
* @class StudioActionUtil
*/
export class StudioActionUtil {
/**
* 唯一实例
*
* @private
* @static
* @type {StudioActionUtil}
* @memberof StudioActionUtil
*/
private static readonly instance: StudioActionUtil = new StudioActionUtil();
/**
* 是否启用
*
* @protected
* @type {boolean}
* @memberof StudioActionUtil
*/
protected isEnable: boolean = Environment.devMode;
/**
* 请求对象
*
* @protected
* @type {Http}
* @memberof StudioActionUtil
*/
protected http: Http = Http.getInstance();
/**
* 配置信息
*
* @protected
* @type {*}
* @memberof StudioActionUtil
*/
protected config: any = null;
/**
* 配置平台界面
*
* @protected
* @type {Window}
* @memberof StudioActionUtil
*/
protected studioWin: Window | null = null;
/**
* 是否显示开发配置工具栏
*
* @type {boolean}
* @memberof StudioActionUtil
*/
public isShowTool: boolean = false;
/**
* Creates an instance of StudioActionUtil.
* @memberof StudioActionUtil
*/
constructor() {
if (StudioActionUtil.instance) {
return StudioActionUtil.instance;
}
if (Environment.devMode) {
on(window, 'keydown', (e: KeyboardEvent) => {
if ((e.ctrlKey || e.metaKey) && e.keyCode === 123) {
this.showToolChange();
}
});
}
}
/**
* 为当前视图建立issues
*
* @param {string} viewName
* @returns {Promise<void>}
* @memberof StudioActionUtil
*/
public async createdIssues(viewName: string): Promise<void> {
const config: any = await this.getConfig(viewName);
if (config) {
const context: string = `视图模块:${config.viewmodule}\n视图标识:${config.viewname}\n视图类型:${config.viewtype}\n`;
window.open(`${Environment.ProjectUrl}/issues/new?issue[title]=${encodeURIComponent('问题')}&issue[description]=${encodeURIComponent(context)}`, '_blank');
}
}
/**
* 打开Studio配置界面
*
* @param {string} viewName
* @returns {Promise<void>}
* @memberof StudioActionUtil
*/
public async openStudioConfigView(viewName: string): Promise<void> {
const config: any = await this.getConfig(viewName);
if (config) {
const params: any = {
"appType": "APPSTUDIO",
"appKey": Environment.AppId,
"dataType": "AppDesign_PSAppViewDesignRedirectView",
"srfkey": config.viewtag
};
if (this.studioWin && this.studioWin.closed === false) {
this.studioWin.postMessage({
type: 'OpenView',
params
}, '*');
Vue.prototype.$message.warning('请在已打开的配置平台查看!');
} else {
if(Environment.debugOpenMode === 'sln'){
console.log("打开sln未支持");
// this.studioWin = window.open(`${Environment.StudioUrl}?ov=${encodeURIComponent(JSON.stringify(params))}#/common_slnindex/srfkeys=${Environment.SlnId}/sysdesign_psdevslnsysmodeltreeexpview/srfkey=${Environment.SysId}`, '_blank');
}else{
this.studioWin = window.open(`${Environment.StudioUrl}?ov=${encodeURIComponent(JSON.stringify(params))}#/common_mosindex/srfkeys=${Environment.SysId}`, '_blank');
}
}
}
}
/**
* 获取视图配置参数
*
* @protected
* @param {string} viewName
* @returns {Promise<any>}
* @memberof StudioActionUtil
*/
protected async getConfig(viewName: string): Promise<any> {
if (!this.config) {
await this.loadConfig();
}
return this.config[viewName];
}
/**
* 加载配置信息
*
* @protected
* @returns {Promise<void>}
* @memberof StudioActionUtil
*/
protected async loadConfig(): Promise<void> {
const response: any = await this.http.get('./assets/json/view-config.json');
if (response && response.status === 200 && response.data) {
this.config = response.data
} else {
console.warn('Studio操作控制器,视图参数信息加载失败!');
}
}
/**
* 展示配置工具栏状态变更
*
* @memberof StudioActionController
*/
public showToolChange(): void {
this.isShowTool = !this.isShowTool;
}
/**
* 获取实例
*
* @static
* @returns {StudioActionUtil}
* @memberof StudioActionUtil
*/
public static getInstance(): StudioActionUtil {
return this.instance;
}
}
\ No newline at end of file
import axios from 'axios';
export class ImgurlBase64{
/**
* 单例变量声明
*
* @memberof ImgurlBase64
*/
private static imgurlBase64: ImgurlBase64;
/**
* 图片缓存(加载中)
*
* @type {Map<string,any>}
* @memberof ImgurlBase64
*/
public static imgCache: Map<string, any> = new Map();
/**
* 图片缓存(已完成)
*
* @type {Map<string,any>}
* @memberof ImgurlBase64
*/
public static imgCached: Map<string, any> = new Map();
/**
* 获取 ImgurlBase64 单例对象
*
* @memberof ImgurlBase64
*/
public static getInstance() {
if (!this.imgurlBase64) {
this.imgurlBase64 = new ImgurlBase64();
}
return this.imgurlBase64;
}
/**
* 手动获取图片
*
*
* @param url 图片url路径
* @returns
*/
public async getImgURLOfBase64(url: string) {
return new Promise((resolve, reject) => {
let img = '/';
// 富文本CV上传图片与鼠标移出抛值冲突问题,上传成功回调还没执行时就抛值
var reg = /^\s*data:([a-z]+\/[a-z0-9-+.]+(;[a-z-]+=[a-z0-9-]+)?)?(;base64)?,([a-z0-9!$&',()*+;=\-._~:@\/?%\s]*?)\s*$/i;
if (reg.test(url)) {
return resolve(url);
}
// 缓存中有从缓存中拿
if (ImgurlBase64.imgCached.get(url)) {
let img = ImgurlBase64.imgCached.get(url);
resolve(img);
}
const callback: Function = (url: string, promise: Promise<any>) => {
promise.then((response: any) => {
if (response && response.status === 200 && response.data) {
// 获取文件名
const disposition = response.headers['content-disposition'];
const filename = disposition.split('filename=')[1];
let type = 'image/png';
if (filename && filename.indexOf('.') > 0) {
const start = filename.lastIndexOf('.');
const expandedName = filename.substring(start + 1);
if (expandedName.match(/(bmp|jpg|jpeg|png|tif|gif|pcx|tga|exif|fpx|svg|psd|cdr|pcd|dxf|ufo|eps|ai|raw|WMF|webp)/gi) != null) {
type = 'image/' + expandedName;
} else {
resolve(img);
}
}
let blob = new Blob([response.data],{type: type});
this.blobToBase64(blob).then((res) => {
// 转化后的base64
img = `${res}`;
// 缓存图片
ImgurlBase64.imgCached.set(url, img);
resolve(img);
})
} else {
resolve(img);
}
}).catch((result: any) => {
return resolve(img);
})
}
// 加载中
if (ImgurlBase64.imgCache.get(url)) {
callback(url, ImgurlBase64.imgCache.get(url));
} else {
let _url = url;
if (!Object.is('/', _url.substring(0,1))) {
_url = '/'+_url;
}
let result:Promise<any> = axios({method: 'get', url: _url, responseType: 'blob'});
ImgurlBase64.imgCache.set(url, result);
callback(url, result);
}
});
}
/**
* 将blob转为base64
*
*
* @param blob blob对象
* @returns
*/
public blobToBase64(blob: any) {
return new Promise((resolve, reject) => {
const fileReader = new FileReader();
fileReader.onload = (e: any) => {
resolve(e.target.result);
};
// readAsDataURL
fileReader.readAsDataURL(blob);
fileReader.onerror = () => {
reject(new Error('blobToBase64 error'));
};
});
}
}
\ No newline at end of file
......@@ -589,4 +589,22 @@ export class Util {
throw new Error(`${layoutModelItem.itemType}暂不支持`);
}
}
/**
* 清除附加数据(源数据里面有的数据在目标数据中都清除)
*
* @param source 源数据
* @param target 目标数据
*
* @memberof Util
*/
public static clearAdditionalData(source: any, target: any) {
if (target && (Object.keys(target).length > 0) && source && (Object.keys(source).length > 0)) {
Object.keys(source).forEach((key: string) => {
if (target.hasOwnProperty(key)) {
delete target[key];
}
})
}
}
}
\ No newline at end of file
......@@ -56,6 +56,7 @@
"tests/**/*.tsx",
],
"exclude": [
"node_modules"
"node_modules",
"user"
]
}
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册