提交 4e36da80 编写于 作者: RedPig97's avatar RedPig97

update:内存优化

上级 18bf0753
......@@ -61,7 +61,7 @@ export default class Breadcrumb extends Vue {
*
* @memberof Breadcrumb
*/
private navDataService = NavDataService.getInstance(this.$store);
private navDataService = NavDataService.getInstance();
/**
* 默认视图标识
......
......@@ -19,7 +19,7 @@ export default class AppCheckBox extends Vue {
* @type {CodeListService}
* @memberof AppCheckBox
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 代码表标识
......
......@@ -80,7 +80,7 @@ export default class AppDataUploadView extends Vue {
* @type {CodeListService}
* @memberof AppDataUploadView
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 实体服务对象
......
......@@ -21,7 +21,7 @@
class="editor"
:style="slotstyle"
>
<form-item :prop="name" :error="error" :rules="rules">
<form-item :prop="name" :error="error" :rules="itemRules">
<slot></slot>
</form-item>
</div>
......@@ -48,7 +48,7 @@
class="editor"
:style="slotstyle"
>
<form-item :prop="name" :error="error" :rules="rules">
<form-item :prop="name" :error="error" :rules="itemRules">
<slot></slot>
</form-item>
</div>
......@@ -154,14 +154,6 @@ export default class AppFormItem extends Vue {
*/
public isShowTip:boolean = false;
/**
* 值规则数组
*
* @type {any[]}
* @memberof AppFormItem
*/
public rules: any[] = [];
/**
* 是否必填
*
......@@ -181,10 +173,7 @@ export default class AppFormItem extends Vue {
onItemRulesChange(newVal: any, oldVal: any) {
if (newVal) {
try {
this.rules = [];
const _rules: any[] = newVal;
this.rules = [..._rules];
this.rules.some((rule: any) => {
this.itemRules.some((rule: any) => {
if (rule.hasOwnProperty("required")) {
this.required = rule.required;
return true;
......@@ -273,9 +262,7 @@ export default class AppFormItem extends Vue {
public mounted() {
if (this.itemRules) {
try {
const _rules: any[] = this.itemRules;
this.rules = [..._rules];
this.rules.some((rule: any) => {
this.itemRules.some((rule: any) => {
if (rule.hasOwnProperty("required")) {
this.required = rule.required;
return true;
......
......@@ -57,7 +57,7 @@
<script lang = 'ts'>
import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { Subject, Subscription } from 'rxjs';
import { AppModal } from '@/utils';
@Component({
......@@ -278,6 +278,14 @@ export default class AppPicker extends Vue {
*/
public dropdownDom:any = {};
/**
* 订阅对象
*
* @type {*}
* @memberof AppPicker
*/
containerEvent: Subscription | null = null;
/**
* 获取关联数据项值
*
......@@ -345,6 +353,9 @@ export default class AppPicker extends Vue {
* @memberof AppPicker
*/
public destroyed(): void {
if (this.containerEvent) {
this.containerEvent.unsubscribe();
}
}
/**
......@@ -532,7 +543,7 @@ export default class AppPicker extends Vue {
*/
private openPopupModal(view: any, context: any, param: any): void {
let container: Subject<any> = this.$appmodal.openModal(view, context, param);
container.subscribe((result: any) => {
this.containerEvent = container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
......@@ -550,7 +561,7 @@ export default class AppPicker extends Vue {
*/
private openDrawer(view: any, context: any, param: any): void {
let container: Subject<any> = this.$appdrawer.openDrawer(view, context, param);
container.subscribe((result: any) => {
this.containerEvent = container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
......@@ -569,7 +580,7 @@ export default class AppPicker extends Vue {
*/
private openPopOver($event: any, view: any, context: any, param: any): void {
let container: Subject<any> = this.$apppopover.openPop($event, view, context, param);
container.subscribe((result: any) => {
this.containerEvent = container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, 'OK')) {
return;
}
......
......@@ -17,7 +17,7 @@ export default class AppRadioGroup extends Vue {
* @type {CodeListService}
* @memberof AppRadioGroup
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 双向绑定值
......
......@@ -37,7 +37,7 @@ export default class AppRate extends Vue {
* @type {CodeListService}
* @memberof AppRate
*/
public codeListService: CodeListService = new CodeListService({ $store: this.$store });
public codeListService: CodeListService = new CodeListService();
/**
* 传递最大值
......
......@@ -29,7 +29,7 @@ export default class CodeList extends Vue {
* @type {CodeListService}
* @memberof CodeList
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 代码表标识
......@@ -195,16 +195,14 @@ export default class CodeList extends Vue {
let _context = data.context;
let _param = data.param;
this.codeListService.getItems(this.tag,_context,_param).then((res:any) => {
let items = res;
_this.setItems(items, _this);
_this.setItems(res, _this);
}).catch((error: any) => {
console.log(`----${_this.tag}----${(this.$t('app.commonWords.codeNotExist') as string)}`);
});
// 静态处理
} else if(Object.is(this.codelistType, "STATIC")){
this.isUseLangres = true;
let items = this.$store.getters.getCodeListItems(this.tag);
_this.setItems(items, _this);
_this.setItems(this.$store.getters.getCodeListItems(this.tag), _this);
}
}
......
......@@ -25,7 +25,7 @@ export default class DropDownListDynamic extends Vue {
* @type {CodeListService}
* @memberof DropDownListDynamic
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 额外参数
......
......@@ -30,7 +30,7 @@ export default class DropDownList extends Vue {
* @type {CodeListService}
* @memberof DropDownList
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 额外参数
......
......@@ -35,7 +35,7 @@ export default class DropDownListMpicker extends Vue {
* @type {CodeListService}
* @memberof DropDownListMpicker
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 是否有子集
......
......@@ -30,7 +30,7 @@ export default class DropDownList extends Vue {
* @type {CodeListService}
* @memberof DropDownList
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
public codeListService:CodeListService = new CodeListService();
/**
* 额外参数
......
import { Store } from 'vuex';
import EntityService from '@/service/entity-service';
import EntityService from '@/api/service/entity-service';
import store from '@/store';
/**
......@@ -71,7 +72,7 @@ export default class CounterService {
* @memberof CounterService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.$store = store;
this.context = opts.context?opts.context:{};
this.viewparams = opts.viewparams?opts.viewparams:{};
}
......
......@@ -26,7 +26,14 @@ export class LoaddingService {
* @type {(Subscription | undefined)}
* @memberof LoaddingService
*/
public loaddingStateEvent: Subscription | undefined;
public loaddingStateEvent: Subscription | null = null;
/**
* @description dom映射对象
* @type {Map<string, any>}
* @memberof LoaddingService
*/
public domMap: Map<string, any> = new Map();
/**
* 获取 LoaddingService 单例对象
......@@ -56,6 +63,9 @@ export class LoaddingService {
if(el.getElementsByTagName('i') && el.getElementsByTagName('i').length >0){
let iconElement:any = el.getElementsByTagName('i')[0];
iconElement.setAttribute('ownclassname',iconElement.className);
const uuid: string = String(el.__vue__._uid);
el.setAttribute('uuid',uuid);
this.domMap.set(uuid, iconElement);
}
}
}
......@@ -69,16 +79,17 @@ export class LoaddingService {
* @memberof LoaddingService
*/
public setLoadState(el:any, binding:any){
if (!this.loaddingStateEvent) {
this.loaddingStateEvent = Http.getInstance().getNotifyObject().subscribe((result:any) =>{
if(result && result.action && Object.is(result.action,'setloadstate')){
if(result && result.state){
this.addLoadState(el,binding);
}else{
this.removeLoadState(el,binding);
}
}
if(result && result.action && Object.is(result.action,'setloadstate')){
if(result && result.state){
this.addLoadState();
}else{
this.removeLoadState();
}
}
})
}
}
/**
......@@ -88,17 +99,10 @@ export class LoaddingService {
* @param {any} binding 指令附加参数
* @memberof LoaddingService
*/
public addLoadState(el:any, binding:any){
if(binding && binding.arg){
el.style.pointerEvents = 'none';
// 工具栏按钮
if(Object.is(binding.arg,'i-button')){
if(el.getElementsByTagName('i') && el.getElementsByTagName('i').length >0){
let iconElement:any = el.getElementsByTagName('i')[0];
iconElement.className = "el-icon-loading";
}
}
}
public addLoadState(){
this.domMap.forEach((dom: any, key: string) => {
dom.className = "el-icon-loading";
})
}
/**
......@@ -108,17 +112,10 @@ export class LoaddingService {
* @param {any} binding 指令附加参数
* @memberof LoaddingService
*/
public removeLoadState(el:any, binding:any){
if(binding && binding.arg){
el.style.pointerEvents = '';
// 工具栏按钮
if(Object.is(binding.arg,'i-button')){
if(el.getElementsByTagName('i') && el.getElementsByTagName('i').length >0){
let iconElement:any = el.getElementsByTagName('i')[0];
iconElement.className = iconElement.getAttribute('ownclassname');
}
}
}
public removeLoadState(){
this.domMap.forEach((dom: any, key: string) => {
dom.className = dom.getAttribute('ownclassname');
})
}
/**
......@@ -129,8 +126,13 @@ export class LoaddingService {
* @memberof LoaddingService
*/
public clearResource(el:any, binding:any){
if(this.loaddingStateEvent){
if(this.loaddingStateEvent && this.domMap.size == 0){
this.loaddingStateEvent.unsubscribe();
this.loaddingStateEvent = null;
}
const uuid: string = el.getAttribute('uuid');
if (uuid && this.domMap.has(uuid)) {
this.domMap.delete(uuid);
}
}
......
......@@ -98,5 +98,13 @@ export default class CalendarExpViewEngine extends ViewEngine {
return this.calendarExpBar;
}
/**
* @description 销毁
* @memberof CalendarExpViewEngine
*/
public destroy() {
super.destroy();
this.calendarExpBar = null;
}
}
\ No newline at end of file
......@@ -99,4 +99,13 @@ export default class ChartViewEngine extends SearchViewEngine {
public getChart(): any {
return this.chart;
}
/**
* @description 销毁
* @memberof ChartViewEngine
*/
public destroy() {
super.destroy();
this.chart = null;
}
}
\ No newline at end of file
......@@ -138,4 +138,13 @@ export default class DataViewEngine extends MDViewEngine {
}
}
/**
* @description 销毁
* @memberof DataViewEngine
*/
public destroy() {
super.destroy();
this.dataView = null;
}
}
\ No newline at end of file
......@@ -98,5 +98,14 @@ export default class DataViewExpViewEngine extends ViewEngine {
return this.dataviewExpBar;
}
/**
* @description 销毁
* @memberof DataViewExpViewEngine
*/
public destroy() {
super.destroy();
this.dataviewExpBar = null;
}
}
\ No newline at end of file
......@@ -222,4 +222,13 @@ export default class EditViewEngine extends ViewEngine {
return this.getForm().transformData(arg);
}
/**
* @description 销毁
* @memberof EditViewEngine
*/
public destroy() {
super.destroy();
this.form = null;
}
}
\ No newline at end of file
......@@ -120,4 +120,13 @@ export default class EditView2Engine extends EditViewEngine {
public getDRBar(): any {
return this.drBar;
}
/**
* @description 销毁
* @memberof EditView2Engine
*/
public destroy() {
super.destroy();
this.drBar = null;
}
}
\ No newline at end of file
......@@ -118,4 +118,13 @@ export default class EditView3Engine extends EditViewEngine {
public getDrTab(): any {
return this.drTab;
}
/**
* @description 销毁
* @memberof EditView3Engine
*/
public destroy() {
super.destroy();
this.drTab = null;
}
}
\ No newline at end of file
......@@ -118,4 +118,13 @@ export default class EditView4Engine extends EditViewEngine {
public getDrTab(): any {
return this.drTab;
}
/**
* @description 销毁
* @memberof EditView4Engine
*/
public destroy() {
super.destroy();
this.drTab = null;
}
}
\ No newline at end of file
......@@ -62,4 +62,13 @@ export default class FormPickupDataViewEngine extends MDViewEngine {
return this.dataview;
}
/**
* @description 销毁
* @memberof FormPickupDataViewEngine
*/
public destroy() {
super.destroy();
this.dataview = null;
}
}
\ No newline at end of file
......@@ -98,5 +98,14 @@ export default class GridExpViewEngine extends ViewEngine {
return this.gridExpBar;
}
/**
* @description 销毁
* @memberof GridExpViewEngine
*/
public destroy() {
super.destroy();
this.gridExpBar = null;
}
}
\ No newline at end of file
......@@ -111,4 +111,13 @@ export default class GridViewEngine extends MDViewEngine {
public gridRowAllowActive(mode: number): boolean {
return this.view.gridRowActiveMode === mode ? true : false;
}
/**
* @description 销毁
* @memberof GridViewEngine
*/
public destroy() {
super.destroy();
this.grid = null;
}
}
\ No newline at end of file
......@@ -51,7 +51,6 @@ export default class GridView8Engine extends GridViewEngine {
* @memberof GridView8Engine
*/
public init(options: any = {}): void {
this.grid = options.grid;
this.totalgrid = options.totalgrid;
super.init(options);
}
......@@ -277,4 +276,13 @@ export default class GridView8Engine extends GridViewEngine {
this.removeData(items);
}
}
/**
* @description 销毁
* @memberof GridView8Engine
*/
public destroy() {
super.destroy();
this.totalgrid = null;
}
}
......@@ -55,4 +55,13 @@ export default class KanBanViewEngine extends DataViewEngine {
public getMDCtrl(): any {
return this.kanban;
}
/**
* @description 销毁
* @memberof KanBanViewEngine
*/
public destroy() {
super.destroy();
this.kanban = null;
}
}
\ No newline at end of file
......@@ -98,5 +98,12 @@ export default class ListExpViewEngine extends ViewEngine {
return this.listExpBar;
}
/**
* @description 销毁
* @memberof ListExpViewEngine
*/
public destroy() {
super.destroy();
this.listExpBar = null;
}
}
\ No newline at end of file
......@@ -147,4 +147,13 @@ export default class ListViewEngine extends MDViewEngine {
}
}
/**
* @description 销毁
* @memberof ListViewEngine
*/
public destroy() {
super.destroy();
this.list = null;
}
}
\ No newline at end of file
......@@ -64,5 +64,12 @@ export default class MapViewEngine extends MDViewEngine {
return this.map;
}
/**
* @description 销毁
* @memberof MapViewEngine
*/
public destroy() {
super.destroy();
this.map = null;
}
}
\ No newline at end of file
......@@ -466,4 +466,15 @@ export default class MDViewEngine extends ViewEngine {
public MDCtrlRemove(arg: any = {}): void {
this.view.$emit('drdatasremove', arg);
}
/**
* @description 销毁
* @memberof MDViewEngine
*/
public destroy() {
super.destroy();
this.searchForm = null;
this.propertypanel = null;
this.md = null;
}
}
\ No newline at end of file
......@@ -120,4 +120,13 @@ export default class MPickupViewEngine extends ViewEngine {
public getPickupViewPanel(): any {
return this.pickupViewPanel;
}
/**
* @description 销毁
* @memberof MPickupViewEngine
*/
public destroy() {
super.destroy();
this.pickupViewPanel = null;
}
}
\ No newline at end of file
......@@ -62,4 +62,13 @@ export default class PickupDataViewEngine extends MDViewEngine {
return this.dataview;
}
/**
* @description 销毁
* @memberof PickupDataViewEngine
*/
public destroy() {
super.destroy();
this.dataview = null;
}
}
\ No newline at end of file
......@@ -96,4 +96,13 @@ export default class PickupViewEngine extends ViewEngine {
public getPickupViewPanel(): any {
return this.pickupViewPanel;
}
/**
* @description 销毁
* @memberof PickupViewEngine
*/
public destroy() {
super.destroy();
this.pickupViewPanel = null;
}
}
\ No newline at end of file
......@@ -92,4 +92,13 @@ export default class PortalViewEngine extends ViewEngine {
return this.dashboard;
}
/**
* @description 销毁
* @memberof PortalViewEngine
*/
public destroy() {
super.destroy();
this.dashboard = null;
}
}
\ No newline at end of file
......@@ -118,4 +118,13 @@ export class SearchViewEngine extends ViewEngine {
public getSearchForm(): any {
return this.searchForm;
}
/**
* @description 销毁
* @memberof SearchViewEngine
*/
public destroy() {
super.destroy();
this.searchForm = null;
}
}
\ No newline at end of file
......@@ -99,5 +99,14 @@ export default class TreeExpView extends ViewEngine {
return this.treeExpBar;
}
/**
* @description 销毁
* @memberof TreeExpView
*/
public destroy() {
super.destroy();
this.treeExpBar = null;
}
}
\ No newline at end of file
......@@ -111,4 +111,13 @@ export default class TreeGridExViewEngine extends MDViewEngine {
public gridRowAllowActive(mode: number): boolean {
return this.view.gridRowActiveMode === mode ? true : false;
}
/**
* @description 销毁
* @memberof TreeGridExViewEngine
*/
public destroy() {
super.destroy();
this.treegridex = null;
}
}
\ No newline at end of file
......@@ -98,5 +98,14 @@ export default class TreeViewEngine extends ViewEngine {
return this.tree;
}
/**
* @description 销毁
* @memberof TreeViewEngine
*/
public destroy() {
super.destroy();
this.tree = null;
}
}
\ No newline at end of file
......@@ -227,6 +227,16 @@ export default class ViewEngine {
}
}
}
}
}
/**
* @description 销毁
* @memberof ViewEngine
*/
public destroy() {
this.view = null;
this.opt = {};
this.methods = {};
}
}
\ No newline at end of file
......@@ -94,4 +94,13 @@ export default class WizardViewEngine extends ViewEngine {
public getWizardPanel(): any {
return this.wizardpanel;
}
/**
* @description 销毁
* @memberof WizardViewEngine
*/
public destroy() {
super.destroy();
this.wizardpanel = null;
}
}
\ No newline at end of file
......@@ -33,15 +33,6 @@ export interface Message {
*/
export default class AppCenterService {
/**
* Vue 状态管理器
*
* @private
* @type {*}
* @memberof AppCenterService
*/
private static store: any;
/**
* 应用数据状态管理对象
*
......@@ -75,11 +66,10 @@ export default class AppCenterService {
* @returns {AppCenterService}
* @memberof AppCenterService
*/
public static getInstance(store: any): AppCenterService {
public static getInstance(): AppCenterService {
if (!AppCenterService.appCenterService) {
AppCenterService.appCenterService = new AppCenterService();
}
this.store = store;
return this.appCenterService;
}
......
......@@ -84,6 +84,7 @@ export interface ServiceState {
}
import { Subject } from 'rxjs';
import store from '@/store/index'
/**
* 导航数据服务
......@@ -150,7 +151,7 @@ export default class NavDataService {
* @returns {NavDataService}
* @memberof NavDataService
*/
public static getInstance(store: any): NavDataService {
public static getInstance(): NavDataService {
if (!NavDataService.navDataService) {
NavDataService.navDataService = new NavDataService();
}
......
import { Store } from 'vuex';
import AuthService from '@/authservice/auth-service';
import AuthService from '@/api/authservice/auth-service';
import store from '@/store';
/**
* 界面服务基类
......@@ -32,7 +33,7 @@ export default class UIService {
* @memberof UIService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.$store = store;
}
/**
......
import Vue from 'vue';
import { Subject } from 'rxjs';
import store from '../../store';
import i18n from '@/locale';
import i18n from '@/common/locale';
import { ViewTool } from '../view-tool/view-tool';
import AppModalCompponent from "./app-modal.vue";
import './app-modal.less';
......@@ -15,16 +15,7 @@ export class AppModal {
* @static
* @memberof AppModal
*/
private static modal = new AppModal();
/**
* vue 实例
*
* @private
* @type {Vue}
* @memberof AppModal
*/
private vueExample!: Vue;
private static modal: AppModal;
/**
* Creates an instance of AppModal.
......@@ -32,11 +23,16 @@ export class AppModal {
* @memberof AppModal
*/
private constructor() {
if (AppModal.modal) {
return AppModal.modal;
}
}
/**
* @description 临时vue对象
* @private
* @type {(Vue | null)}
* @memberof AppModal
*/
private VueExample: Vue | null = null;
/**
* 获取单例对象
*
......@@ -65,17 +61,15 @@ export class AppModal {
private createVueExample(view: { viewname: string, title: string, width?: number, height?: number,isfullscreen?:boolean }, context: any = {},viewparams:any ={}, uuid: string): Subject<any> {
try {
let props = { view: view, viewdata: context,viewparams:viewparams,uuid: uuid };
let component = AppModalCompponent;
const vm = new Vue({
this.VueExample = new Vue({
store: store,
i18n: i18n,
render(h) {
return h(component, { props });
return h(AppModalCompponent, { props });
}
}).$mount();
this.vueExample = vm;
document.body.appendChild(vm.$el);
const comp: any = vm.$children[0];
document.body.appendChild(this.VueExample.$el);
const comp: any = this.VueExample.$children[0];
return comp.getSubject();
} catch (error) {
console.error(error);
......@@ -122,4 +116,15 @@ export class AppModal {
return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
}
/**
* @description 销毁临时vue对象
* @memberof AppModal
*/
destroyVueExample() {
if (this.VueExample) {
this.VueExample.$destroy();
this.VueExample = null;
}
}
}
\ No newline at end of file
......@@ -27,6 +27,7 @@
<script lang="ts">
import { Vue, Component, Prop, Provide, Emit, Watch } from "vue-property-decorator";
import { Subject } from "rxjs";
import {AppModal} from './app-modal';
@Component({
components: {}
})
......@@ -279,6 +280,7 @@ export default class AppModalCompponent extends Vue {
setTimeout(() => {
document.body.removeChild(this.$el);
this.$destroy();
AppModal.getInstance().destroyVueExample();
this.subject = null;
}, 500)
}
......
import { Store } from 'vuex';
import { Util } from '@/utils/util/util';
import CodeListService from "@/codelist/codelist-service";
import store from '@/store';
/**
* 部件服务基类
......@@ -50,9 +51,9 @@ export default class ControlService {
* @memberof ControlService
*/
constructor(opts: any = {}) {
this.$store = opts.$store;
this.$store = store;
this.setTempMode();
this.codeListService = new CodeListService({ $store:opts.$store });
this.codeListService = new CodeListService();
}
/**
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册