提交 f0dc5cd9 编写于 作者: ibizdev's avatar ibizdev

ibizdev提交

上级 59212962
......@@ -5,7 +5,6 @@ html, body {
.app-error-view {
height: 100%;
width: 100%;
position: relative;
.app-error-container {
height: 380px;
width: 670px;
......
......@@ -3,8 +3,8 @@
<div class="app-error-container">
<img src="/assets/img/404.png" />
<div class="error-text">
<div class="error-text1">抱歉,您访问的页面不存在!</div>
<div class="error-text2">您要找的页面存在,请返回 <a on-click={this.gotoIndexView}>首页</a> 继续浏览</div>
<div class="error-text1">{{$t('errorInfo.errorText1')}}</div>
<div class="error-text2">{{$t('errorInfo.errorText2')}} <a @click="gotoIndexView">{{$t('errorInfo.indexPage')}}</a> {{$t('errorInfo.continue')}}</div>
</div>
</div>
</div>
......@@ -13,7 +13,28 @@
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
errorText1: '抱歉,您访问的页面不存在!',
errorText2: '您要找的页面不存在,请返回',
indexPage: '首页',
continue: '继续浏览',
}
},
'en-US': {
errorInfo: {
errorText1: 'sorry,the page you visited is not exist!',
errorText2: 'The page you visited is not exist,please return to',
indexPage: 'home page',
continue: 'to continue browsing',
}
}
}
}
})
export default class Error404 extends Vue {
/**
......
html, body {
height: 100%;
}
.app-error-view {
height: 100%;
width: 100%;
position: relative;
.app-error-container {
height: 380px;
width: 670px;
......
......@@ -3,8 +3,8 @@
<div class="app-error-container">
<img src="/assets/img/500.png" />
<div class="error-text">
<div class="error-text1">抱歉,服务器出错了!</div>
<div class="error-text2">服务器出错了,请返回 <a on-click={this.gotoIndexView}>首页</a> 继续浏览</div>
<div class="error-text1">{{$t('errorInfo.errorText1')}}</div>
<div class="error-text2">{{$t('errorInfo.errorText2')}} <a @click="gotoIndexView">{{$t('errorInfo.indexPage')}}</a> {{$t('errorInfo.continue')}}</div>
</div>
</div>
</div>
......@@ -13,7 +13,28 @@
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
errorText1: '抱歉,服务器出错了!',
errorText2: '服务器出错了,请返回 ',
indexPage: '首页',
continue: '继续浏览',
}
},
'en-US': {
errorInfo: {
errorText1: "sorry,there's something wrong with the server!",
errorText2: "There's something wrong with the server,please return to",
indexPage: 'home page',
continue: 'to continue browsing',
}
}
}
}
})
export default class Error404 extends Vue {
/**
......
......@@ -23,7 +23,26 @@ import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
error: '错误',
miss: '缺少参数',
requestException: '请求异常!',
}
},
'en-US': {
errorInfo: {
error: 'Error',
miss: 'Missing parameter ',
requestException: 'Request Exception!',
}
}
}
}
})
export default class AppAutocomplete extends Vue {
/**
......@@ -195,16 +214,21 @@ export default class AppAutocomplete extends Vue {
let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
Object.assign(param,_parentdata);
}
// 错误信息国际化
let error: string = (this.$t('errorInfo.error') as any);
let miss: string = (this.$t('errorInfo.miss') as any);
let requestException: string = (this.$t('errorInfo.requestException') as any);
if(!this.service){
this.$Notice.error({ title: '错误', desc: '缺少参数service' });
this.$Notice.error({ title: error, desc: miss+'service' });
} else if(!this.acParams.serviceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数serviceName' });
this.$Notice.error({ title: error, desc: miss+'serviceName' });
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数interfaceName' });
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, context, param).then((response: any) => {
if (!response) {
this.$Notice.error({ title: '错误', desc: '请求异常' });
this.$Notice.error({ title: error, desc: requestException });
} else {
this.items = [...response];
}
......
......@@ -6,7 +6,7 @@
</i-button>
</button-group>
<button-group v-show="showTypeDir">
<el-tooltip content="定制">
<el-tooltip :content="$t('info.custom')">
<i-button icon="md-build" type="primary" @click="handleClick"></i-button>
</el-tooltip>
<i-button class="collapse-btn" type="primary" @click="clickCollapse('right')">
......@@ -21,7 +21,19 @@ import {Vue, Component, Prop, Watch} from 'vue-property-decorator';
@Component({
components: {
i18n: {
messages: {
'zh-CN': {
info: {
custom: '定制',
}
},
'en-US': {
info: {
custom: 'Customize',
}
}
}
}
})
export default class AppBuild extends Vue {
......
......@@ -10,7 +10,22 @@
import { Component, Vue, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
notExist: '代码表不存在',
}
},
'en-US': {
errorInfo: {
notExist: 'codelist is not existed',
}
}
}
}
})
export default class AppCheckBox extends Vue {
/**
* 代码表服务对象
......@@ -191,13 +206,13 @@ export default class AppCheckBox extends Vue {
if (codelist) {
this.items = [...JSON.parse(JSON.stringify(codelist.items))];
} else {
console.log(`----${this.tag}----代码表不存在`);
console.log(`----${this.tag}----$t('errorInfo.notExist')`);
}
} else if (Object.is(this.codelistType,"DYNAMIC")) {
this.codeListService.getItems(this.tag).then((res:any) => {
this.items = res;
}).catch((error:any) => {
console.log(`----${this.tag}----代码表不存在`);
console.log(`----${this.tag}----$t('errorInfo.notExist')`);
});
}
}
......
......@@ -5,12 +5,12 @@
<input-box :disabled="disabled" v-model="editorvalue" @change="($event)=>{onEditorValueChange($event)}"></input-box>
</template>
<template v-else-if="Object.is(type,'dropdown')">
<i-select v-model="editorvalue" :disabled="disabled" :clearable="true" placeholder='请选择...' >
<i-select v-model="editorvalue" :disabled="disabled" :clearable="true" :placeholder="$t('info.select')" >
<i-option v-for="(item, index) in codelist" :key="index" :value="item.value">{{item.text}}</i-option>
</i-select>
</template>
<template v-else>
<span>{{type}}不支持</span>
<span>{{type}}{{$t('info.unsupported')}}</span>
</template>
</div>
</template>
......@@ -20,7 +20,24 @@ import { Vue, Component, Prop, Model, Emit, Watch } from "vue-property-decorator
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
select: '请选择...',
unsupported: '不支持',
}
},
'en-US': {
info: {
select: 'please select...',
unsupported: '不支持',
}
}
}
}
})
export default class AppColumnRender extends Vue {
/**
* 值
......
......@@ -10,7 +10,7 @@
<el-menu v-show="!filterVal" :unique-opened="true">
<template v-for="(item, index) of list">
<el-submenu :key="item.type + index" :index="item.type + index">
<div slot="title">{{item.name}}</div>
<div slot="title">{{Object.is(item.type, 'app') ? $t('info.global') : item.name}}</div>
<template v-for="(item2, index2) of item.children">
<el-submenu :key="item2.type + index2" :index="item2.type + index2">
<div slot="title">{{item2.name}}</div>
......@@ -89,6 +89,20 @@ import { Http } from '../../utils/http/http';
import { Subject, Subscription } from 'rxjs';
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
global: '全局',
}
},
'en-US': {
info: {
global: 'Global',
}
}
}
},
components: {
GridLayout: VueGridLayout.GridLayout,
GridItem: VueGridLayout.GridItem
......@@ -225,9 +239,9 @@ export default class AppDashboardDesign extends Vue {
* @memberof AppDashboardDesign
*/
public created() {
this.loadList();
this.load();
if (this.viewState) {
this.loadList();
this.load();
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (Object.is('save', action)) {
this.save();
......
......@@ -2,7 +2,7 @@
<div class="app-debug-actions">
<div class="actions">
<button-group vertical>
<i-button title="开启配置模式" :type="sdc.isShowTool ? 'warning' : 'info'" ghost @click="() => sdc.showToolChange()" :icon="sdc.isShowTool ? 'ios-bug' : 'ios-bug-outline'" ></i-button>
<i-button :title="$t('info.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">
......@@ -21,7 +21,22 @@ import { Environment } from '@/environments/environment';
* @class AppDebugActions
* @extends {Vue}
*/
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
button: '开启配置模式',
}
},
'en-US': {
info: {
button: 'Open Configuration Mode',
}
}
}
}
})
export default class AppDebugActions extends Vue {
/**
......
......@@ -11,8 +11,8 @@
</component>
</div>
<template v-if="placeholder">
<div v-if="value" class="app-embed-value">{this.value}</div>
<div v-else class="app-embed-placeholder">{this.placeholder}</div>
<div v-if="value" class="app-embed-value">{{value}}</div>
<div v-else class="app-embed-placeholder">{{placeholder}}</div>
</template>
</div>
<div v-else>{{emptyText}}</div>
......
......@@ -2,7 +2,7 @@
<div class="app-file-upload">
<el-row>
<el-col v-if="rowPreview && files.length > 0" :span="12" class="upload-col">
<el-button size='small' class="button-preview" icon='el-icon-view' :disabled="disabled" @click="()=>{this.dialogVisible = true;}">查看<Badge :count="files.length" type="info"></Badge></el-button>
<el-button size='small' class="button-preview" icon='el-icon-view' :disabled="disabled" @click="()=>{this.dialogVisible = true;}">{{$t('info.preview')}}<Badge :count="files.length" type="info"></Badge></el-button>
</el-col>
<el-col :span="(rowPreview && files.length > 0) ? 12 : 24" class="upload-col">
<el-upload
......@@ -20,7 +20,7 @@
>
<el-button v-if="!isdrag" size='small' icon='el-icon-upload' :disabled="disabled">{{this.$t('app.fileUpload.caption')}}</el-button>
<i v-if="isdrag" class="el-icon-upload"></i>
<div v-if="isdrag" class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div v-if="isdrag" class="el-upload__text" v-html="$t('info.uploadText')"></div>
</el-upload>
</el-col>
</el-row>
......@@ -55,7 +55,29 @@ import { Environment } from '@/environments/environment';
import { CreateElement } from 'vue';
import { Subject, Unsubscribable } from 'rxjs';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
preview: '查看',
uploadText: '将文件拖到此处,或<em>点击上传</em>',
uploadError: '上传失败',
fileTypeErrorTitle: '文件类型错误',
fileTypeErrorInfo: '请选择图片类型的文件,如JPEG,GIF,PNG,BMP',
}
},
'en-US': {
info: {
preview: 'preview',
uploadText: 'Drag files here,or <em>Click</em> to upload',
fileTypeErrorTitle: 'File type incorrect',
fileTypeErrorInfo: 'Please select files with picture types,such as JPEG,GIF,PNG,BMP',
}
}
}
}
})
export default class AppFileUpload extends Vue {
/**
......@@ -338,7 +360,7 @@ export default class AppFileUpload extends Vue {
const imageTypes = ["image/jpeg" , "image/gif" , "image/png" , "image/bmp"];
const isImage = imageTypes.some((type: any)=> Object.is(type, file.type));
if (!isImage) {
this.$Notice.error({ title: '文件类型错误' ,desc: '请选择图片类型的文件,如JPEG,GIF,PNG,BMP'});
this.$Notice.error({ title: (this.$t('info.fileTypeErrorTitle') as any) ,desc: (this.$t('info.fileTypeErrorInfo') as any)});
}
return isImage;
}
......@@ -376,7 +398,7 @@ export default class AppFileUpload extends Vue {
* @memberof AppFileUpload
*/
public onError(error: any, file: any, fileList: any) {
this.$Notice.error({ title: '上传失败' });
this.$Notice.error({ title: (this.$t('info.uploadError') as any) });
}
/**
......
......@@ -13,13 +13,28 @@
@viewdataschange="viewdataschange"
@viewload="viewload">
</component>
<spin v-if="blockUI" class='app-druipart-spin' fix >{{ blockUITipInfo }}</spin>
<spin v-if="blockUI" class='app-druipart-spin' fix >{{ $t('info.blockUITipInfo') }}</spin>
</div>
</template>
<script lang = 'ts'>
import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { Subject, Unsubscribable } from 'rxjs';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
blockUITipInfo: '请先保存主数据',
}
},
'en-US': {
info: {
blockUITipInfo: 'Please save the major data first',
}
}
}
}
})
export default class AppFormDRUIPart extends Vue {
/**
......@@ -183,14 +198,6 @@ export default class AppFormDRUIPart extends Vue {
*/
public blockUI: boolean = false;
/**
* 遮罩提示信息
*
* @type {string}
* @memberof AppFormDRUIPart
*/
public blockUITipInfo: string = '请先保存主数据';
/**
* 是否刷新关系数据
*
......
......@@ -15,7 +15,26 @@ import { Component, Vue, Prop, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { AppModal } from '@/utils';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
error: '错误',
miss: '缺少参数',
requestException: '请求异常!',
}
},
'en-US': {
errorInfo: {
error: 'Error',
miss: 'Missing parameter ',
requestException: 'Request Exception!',
}
}
}
}
})
export default class AppMpicker extends Vue {
/**
......@@ -150,16 +169,20 @@ export default class AppMpicker extends Vue {
if (this.activeData) {
Object.assign(param, { srfreferdata: this.activeData });
}
// 错误信息国际化
let error: string = (this.$t('errorInfo.error') as any);
let miss: string = (this.$t('errorInfo.miss') as any);
let requestException: string = (this.$t('errorInfo.requestException') as any);
if(!this.service){
this.$Notice.error({ title: '错误', desc: '缺少参数service' });
this.$Notice.error({ title: error, desc: miss+'service' });
} else if(!this.acParams.serviceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数serviceName' });
this.$Notice.error({ title: error, desc: miss+'serviceName' });
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数interfaceName' });
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, param).then((response: any) => {
if (!response) {
this.$Notice.error({ title: '错误', desc: '请求异常' });
this.$Notice.error({ title: error, desc: requestException });
} else {
this.items = [...response];
}
......
<template>
<div class="app-picker-select-view">
<Dropdown :visible="visible" trigger="custom" style="left:0px;width: 100%" @on-clickoutside="() => {triggerMenu(false);}" >
<Input v-if="isSingleSelect" v-model="queryValue" class="tree-input" type="text" :placeholder="placeholder" :disabled="disabled" @on-change="OnInputChange" @on-focus="()=>{triggerMenu(true);}" >
<Input v-if="isSingleSelect" v-model="queryValue" class="tree-input" type="text" :placeholder="placeholder ? placeholder : $t('errorInfo.placeholder')" :disabled="disabled" @on-change="OnInputChange" @on-focus="()=>{triggerMenu(true);}" >
<template v-slot:suffix>
<i v-if="queryValue && !disabled" class='el-icon-circle-close' @click="onClear"></i>
<Icon :type="visible ? 'ios-arrow-up' : 'ios-arrow-down'" class="icon-arrow" @click="() => {triggerMenu();}"></Icon>
......@@ -32,7 +32,28 @@ import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ViewTool } from '@/utils/view-tool/view-tool';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
error: '错误',
valueitemException: '值项异常!',
formdataException: '表单数据异常!',
placeholder: '请选择...',
}
},
'en-US': {
errorInfo: {
error: 'Error',
valueitemException: 'valueitem Error!',
formdataException: 'formdata Error!',
placeholder: 'Please select...',
}
}
}
}
})
export default class AppPickerSelectView extends Vue {
/**
* 视图上下文
......@@ -176,7 +197,7 @@ export default class AppPickerSelectView extends Vue {
* @type {string}
* @memberof AppTreePicker
*/
@Prop({default:"请选择..."}) public placeholder!: string;
@Prop() public placeholder!: string;
/**
* 属性项名称
......@@ -250,7 +271,7 @@ export default class AppPickerSelectView extends Vue {
return true;
}
if (!this.data) {
this.$Notice.error({ title: '错误', desc: '表单数据异常' });
this.$Notice.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.formdataException') as any) });
return false;
}
// 合并表单参数
......@@ -304,7 +325,7 @@ export default class AppPickerSelectView extends Vue {
if(this.isSingleSelect){
this.queryValue = newVal;
if (!this.data || !this.valueitem || !this.data[this.valueitem]) {
this.$Notice.error({ title: '错误', desc: "编辑器"+this.name+'值项异常' });
this.$Notice.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.editor') as any)+this.name+(this.$t('errorInfo.valueitemException') as any) });
}else{
let _viewparam = JSON.parse(this.viewparam);
_viewparam.selectedData = [{srfkey: this.data[this.valueitem], srfmajortext: this.value }];
......@@ -416,7 +437,7 @@ export default class AppPickerSelectView extends Vue {
*/
public openLinkView($event: any): void {
if (!this.data || !this.valueitem || !this.data[this.valueitem]) {
console.error({ title: '错误', desc: '值项异常!' });
console.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.editor') as any)+this.name+(this.$t('errorInfo.valueitemException') as any) });
return;
}
// 公共参数处理
......
......@@ -9,7 +9,7 @@
@input="onInput" @blur="onBlur" style='width:100%;'>
<template v-slot:default="{item}">
<template v-if="item.isNew">
<div v-if="linkview" @click="newAndEdit">创建并编辑...</div>
<div v-if="linkview" @click="newAndEdit">{{$t('errorInfo.newAndEdit')}}</div>
</template>
<slot v-else name="default" :item="item"></slot>
</template>
......@@ -52,7 +52,34 @@ import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { AppModal } from '@/utils';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
errorInfo: {
error: '错误',
miss: '缺少参数',
requestException: '请求异常!',
newAndEdit: '创建并编辑...',
systemException: '系统异常!',
valueitemException: '值项异常!',
formdataException: '表单数据异常!',
}
},
'en-US': {
errorInfo: {
error: 'Error',
miss: 'Missing parameter ',
requestException: 'Request Exception!',
newAndEdit: 'Create And Edit...',
systemException: 'System Error!',
valueitemException: 'valueitem Error!',
formdataException: 'formdata Error!',
}
}
}
}
})
export default class AppPicker extends Vue {
/**
......@@ -309,16 +336,20 @@ export default class AppPicker extends Vue {
}
this.inputState = false;
Object.assign(_param, { query: query });
// 错误信息国际化
let error: string = (this.$t('errorInfo.error') as any);
let miss: string = (this.$t('errorInfo.miss') as any);
let requestException: string = (this.$t('errorInfo.requestException') as any);
if(!this.service){
this.$Notice.error({ title: '错误', desc: '缺少参数service' });
this.$Notice.error({ title: error, desc: miss+'service' });
} else if(!this.acParams.serviceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数serviceName' });
this.$Notice.error({ title: error, desc: miss+'serviceName' });
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: '错误', desc: '缺少参数interfaceName' });
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, _context, _param).then((response: any) => {
if (!response) {
this.$Notice.error({ title: '错误', desc: '请求异常' });
this.$Notice.error({ title: error, desc: requestException });
} else {
this.items = [...response];
}
......@@ -506,7 +537,7 @@ export default class AppPicker extends Vue {
private openRedirectView($event: any, view: any, data: any): void {
this.$http.get(view.url, data).then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '错误', desc: '请求异常' });
this.$Notice.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.requestException') as any) });
}
if (response.status === 401) {
return;
......@@ -558,7 +589,7 @@ export default class AppPicker extends Vue {
}
}).catch((response: any) => {
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常!' });
this.$Notice.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.systemException') as any) });
return;
}
if (response.status === 401) {
......@@ -574,7 +605,7 @@ export default class AppPicker extends Vue {
*/
public openLinkView($event: any): void {
if (!this.data || !this.valueitem || !this.data[this.valueitem]) {
console.error({ title: '错误', desc: '值项异常!' });
console.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.valueitemException') as any) });
return;
}
// 公共参数处理
......@@ -638,7 +669,7 @@ export default class AppPicker extends Vue {
return true;
}
if (!this.data) {
this.$Notice.error({ title: '错误', desc: '表单数据异常' });
this.$Notice.error({ title: (this.$t('errorInfo.error') as any), desc: (this.$t('errorInfo.formdataException') as any) });
return false;
}
// 合并表单参数
......
<template>
<card class="app-portal-design" :dis-hover="true" :padding="0" :bordered="false">
<p slot="title">
自定义门户
{{$t('info.customPortal')}}
</p>
<div class="design-toolbar" slot="extra">
<i-button @click="click">保存</i-button>
<i-button @click="click">{{$t('info.save')}}</i-button>
</div>
<div class="design-container">
<app-dashboard-design :viewState="viewState" :context="context" :viewparams="viewparams" :utilServiceName="utilServiceName" @save="onSaved"></app-dashboard-design>
......@@ -18,6 +18,22 @@ import { Subject } from "rxjs";
import AppDashboardDesign from '@components/app-dashboard-design/app-dashboard-design.vue';
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
customPortal: '自定义门户',
save: '保存',
}
},
'en-US': {
info: {
customPortal: 'Custom portal',
save: 'Save',
}
}
}
},
components: {
AppDashboardDesign
}
......
<template>
<div class="app-range-date">
<span class="editor-span"></span>
<span class="editor-span">{{$t('info.from')}}</span>
<template v-for="(item, index) in refFormItem">
<span v-if="index > 0" class="editor-space" :key="index">日 0 时 起 至</span>
<span v-if="index > 0" class="editor-space" :key="index">{{$t('info.daystart')}}</span>
<date-picker
:key="index + '-onlydate'"
v-if="Object.is(editorType, 'DATEPICKEREX') || Object.is(editorType, 'DATEPICKEREX_NOTIME') && index == 0"
type="date"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="startOnValueChange"
......@@ -21,7 +21,7 @@
type="datetime"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="startOnValueChange"
......@@ -33,7 +33,7 @@
type="date"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="endOnValueChange"
......@@ -45,12 +45,12 @@
type="datetime"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="endOnValueChange"
></date-picker>
<span v-if="index > 0" :key="index + '-only'" class="editor-space">日 24 时 止</span>
<span v-if="index > 0" :key="index + '-only'" class="editor-space">{{$t('info.dayend')}}</span>
</template>
</div>
</template>
......@@ -60,7 +60,28 @@ import { Component, Vue, Prop, Model, Watch } from "vue-property-decorator";
import { Subject } from "rxjs";
import { debounceTime, distinctUntilChanged } from "rxjs/operators";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
placeholder: '请选择时间...',
from: '自',
daystart: '日 0 时 起 至',
dayend: '日 24 时 止',
}
},
'en-US': {
info: {
placeholder: 'Please select time...',
from: 'from',
daystart: '00:00:00 to',
dayend: '24:00:00',
}
}
}
}
})
export default class AppRangDate extends Vue {
/**
* 编辑项名称
......
......@@ -8,7 +8,7 @@
type="date"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="onValueChange">
......@@ -18,7 +18,7 @@
v-else-if="editorType.startsWith('DATEPICKEREX')"
:transfer="true"
:format="valFormat"
placeholder="请选择时间..."
:placeholder="$t('info.placeholder')"
:value="activeData[item]"
:disabled="disabled"
@on-change="onValueChange">
......@@ -29,7 +29,7 @@
type="number"
:value="getValue(item)"
:disabled="disabled"
placeholder="请输入"
:placeholder="$t('info.input')"
@on-change="setValue">
</i-input>
</template>
......@@ -41,7 +41,24 @@ import { Component, Vue, Prop, Model, Watch } from 'vue-property-decorator';
import { Subject } from 'rxjs';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
placeholder: '请选择时间...',
input: '请输入...',
}
},
'en-US': {
info: {
placeholder: 'Please select time...',
input: 'Please input...',
}
}
}
}
})
export default class AppPicker extends Vue {
/**
......
<template>
<div class="app-stepper">
<el-input-number :value="currentVal" :disabled="disabled" @change="onChange" :min="min" :max="max" :step="step" label="描述文字"></el-input-number>
<el-input-number :value="currentVal" :disabled="disabled" @change="onChange" :min="min" :max="max" :step="step"></el-input-number>
</div>
</template>
......
......@@ -5,11 +5,11 @@
{{viewTitle}}
</div>
<div class="actions">
<div class="action-item" title="进入当前视图配置界面">
<i-button type="text" ghost @click="configView()">配置</i-button>
<div class="action-item" :title="$t('info.configTitle')">
<i-button type="text" ghost @click="configView()">{{$t('info.configButton')}}</i-button>
</div>
<div class="action-item" title="建立当前界面的issues">
<i-button type="text" ghost @click="createIssues()">新建issues</i-button>
<div class="action-item" :title="$t('info.issueTitle')">
<i-button type="text" ghost @click="createIssues()">{{$t('info.issueButton')}}</i-button>
</div>
</div>
</div>
......@@ -20,7 +20,28 @@ import { Vue, Component, Inject, Prop } from "vue-property-decorator";
import { Environment } from '@/environments/environment';
import { StudioActionUtil } from '@/utils';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
configTitle: '进入当前视图配置界面',
configButton: '配置',
issueTitle: '建立当前界面的issues',
issueButton: '新建issues',
}
},
'en-US': {
info: {
configTitle: 'Enter the configuration of current view',
configButton: 'Configuration',
issueTitle: 'Create issues of current view',
issueButton: 'Create issues',
}
}
}
}
})
export default class AppStudioAction extends Vue {
/**
......
......@@ -4,7 +4,7 @@
:title="$t('caption.theme')"
popper-class='app-app-theme'
placement='bottom-end'
:width="Object.is($i18n.locale, 'zh-CN') ? 180 : 240">
:width="Object.is($i18n.locale, 'zh-CN') ? 180 : 250">
<a>
<icon class='app-theme-icon' type='md-settings' :size="22" />
</a>
......
<template>
<div v-if="refviewname" class="app-tree-picker">
<Dropdown :visible="visible" trigger="custom" style="left:0px;width: 100%" @on-clickoutside="() => {triggerMenu(false);}" >
<Input v-model="inputValue" class="tree-input" type="text" :placeholder="placeholder" :disabled="disabled" @on-change="OnInputChange" @on-focus="()=>{triggerMenu();}" >
<Input v-model="inputValue" class="tree-input" type="text" :placeholder="placeholder ? placeholder : $t('placeholder')" :disabled="disabled" @on-change="OnInputChange" @on-focus="()=>{triggerMenu();}" >
<template v-slot:suffix>
<i v-if="inputValue && !disabled" class='el-icon-circle-close' @click="onClear"></i>
<Icon :type="visible ? 'ios-arrow-up' : 'ios-arrow-down'" class="icon-arrow" @click="() => {triggerMenu();}"></Icon>
......@@ -28,7 +28,18 @@ import { Vue, Component, Prop, Watch } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
placeholder: '请选择...'
},
'en-US': {
placeholder: 'please select...'
}
}
}
})
export default class AppTreePicker extends Vue {
/**
......@@ -118,7 +129,7 @@ export default class AppTreePicker extends Vue {
* @type {string}
* @memberof AppTreePicker
*/
@Prop({default:"请选择..."}) public placeholder!: string;
@Prop() public placeholder?: string;
/**
* 属性项名称
......
<template>
<div class="ibiz-date-picker">
<div class="date-picker-text">保险期限 : 自</div>
<div class="date-picker-text">{{$t('info.startText')}}</div>
<el-date-picker
v-model="value"
type="daterange"
:range-separator="rangeSeparatorr"
:start-placeholder="startPlaceholder"
:end-placeholder="endPlaceholder"
:range-separator="rangeSeparatorr ? rangeSeparatorr : $t('info.rangeSeparatorr')"
:start-placeholder="startPlaceholder ? startPlaceholder : $t('info.startPlaceholder')"
:end-placeholder="endPlaceholder ? endPlaceholder : $t('info.endPlaceholder')"
:disabled="disabled"
value-format="yyyy-MM-dd"
@change="change"
:format="format"
></el-date-picker>
<div class="date-picker-text">日 24 时 止</div>
<div class="date-picker-text">{{$t('info.endText')}}</div>
</div>
</template>
<script lang = 'ts'>
import { Component, Vue, Model, Prop } from "vue-property-decorator";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
info: {
startText: '保险期限 : 自',
endText: '日 24 时 止',
startPlaceholder: '开始日期',
rangeSeparatorr: ' 0 时起 至',
endPlaceholder: '结束日期',
}
},
'en-US': {
info: {
startText: 'Insurance period : From',
endText: '24:00:00',
startPlaceholder: 'Begin Date',
rangeSeparatorr: ' 00:00:00 To',
endPlaceholder: 'End Dat4e',
}
}
}
}
})
export default class DateRange extends Vue {
/**
* 日期格式
* @type {any}
......@@ -48,7 +65,7 @@ export default class DateRange extends Vue {
* @type {*}
* @memberof DateRange
*/
@Prop({ default: "结束日期" }) public endPlaceholder?: string;
@Prop() public endPlaceholder?: string;
/**
* 中间Placeholder
......@@ -56,7 +73,7 @@ export default class DateRange extends Vue {
* @type {*}
* @memberof DateRange
*/
@Prop({ default: "日 0 时起 至" }) public rangeSeparatorr?: string;
@Prop() public rangeSeparatorr?: string;
/**
* 开始日期Placeholder
......@@ -64,7 +81,7 @@ export default class DateRange extends Vue {
* @type {*}
* @memberof DateRange
*/
@Prop({ default: "开始日期" }) public startPlaceholder?: string;
@Prop() public startPlaceholder?: string;
/**
* 双向绑定值
......
......@@ -8,7 +8,7 @@
:clearable="true"
:filterable="filterable === true ? true : false"
@on-open-change="onClick"
:placeholder="placeholder ? this.placeholder : '请选择'">
:placeholder="placeholder ? this.placeholder : $t('placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value" :label="item.text">
<Checkbox :value = "(currentVal.indexOf(item.value))==-1?false:true">
{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}}
......@@ -20,7 +20,18 @@
<script lang="ts">
import { Vue, Component, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
placeholder: '请选择...'
},
'en-US': {
placeholder: 'please select...'
}
}
}
})
export default class DropDownList extends Vue {
/**
* 代码表服务对象
......
......@@ -7,7 +7,7 @@
:clearable="true"
:filterable="filterable === true ? true : false"
@on-open-change="onClick"
:placeholder="placeholder ? this.placeholder : '请选择'">
:placeholder="placeholder ? this.placeholder : $t('placeholder')">
<i-option v-for="(item, index) in items" :key="index" :value="item.value">{{Object.is(codelistType,'STATIC') ? $t('codelist.'+tag+'.'+item.value) : item.text}}</i-option>
</i-select>
</template>
......@@ -16,7 +16,18 @@
import { Vue, Component, Prop, Model } from 'vue-property-decorator';
import CodeListService from "@service/app/codelist-service";
@Component({})
@Component({
i18n: {
messages: {
'zh-CN': {
placeholder: '请选择...'
},
'en-US': {
placeholder: 'please select...'
}
}
}
})
export default class DropDownList extends Vue {
/**
* 代码表服务对象
......
......@@ -42,7 +42,7 @@
</template>
<script lang="ts">
import { Vue, Component } from 'vue-property-decorator';
import { Vue, Component, Watch } from 'vue-property-decorator';
import { Environment } from '@/environments/environment';
@Component({
......@@ -50,6 +50,7 @@ import { Environment } from '@/environments/environment';
messages: {
'zh-CN': {
login: {
error: '错误',
caption: '欢迎登录',
name: '登录',
tip: '输入用户名和密码',
......@@ -66,6 +67,7 @@ import { Environment } from '@/environments/environment';
},
'en-US': {
login: {
error: 'Error',
caption: 'Welcome to login',
name: 'Login',
tip: 'Enter username and password',
......@@ -99,15 +101,43 @@ export default class Login extends Vue {
* @type {*}
* @memberof Login
*/
public rules: any = {
loginname: [
{ required: true, message: '用户名不能为空', trigger: 'change' },
],
password: [
{ required: true, message: '密码不能为空', trigger: 'change' },
],
public rules = {};
/**
* 设置值规则
*
* @memberof Login
*/
public setRules(){
this.rules = {
loginname: [
{ required: true, message: this.$t('login.loginname.message'), trigger: 'change' },
],
password: [
{ required: true, message: this.$t('login.password.message'), trigger: 'change' },
],
}
};
/**
* 生命周期Create
*
* @memberof Login
*/
public created(){
this.setRules();
}
/**
* 监听语言变化
*
* @memberof Login
*/
@Watch('$i18n.locale')
onLocaleChange(newval: any, val: any) {
this.setRules();
}
/**
* 登陆处理
*
......@@ -133,7 +163,7 @@ export default class Login extends Vue {
}
}).catch((error: any) => {
const loginfailed: any = this.$t('login.loginfailed');
this.$Notice.error({ title: '错误', desc: loginfailed });
this.$Notice.error({ title: (this.$t('login.error') as any), desc: loginfailed });
});
}
......
import ibzdictitem_en_US from '@locale/lanres/ibzdict-item/ibzdict-item_en_US';
import ibzdictitem_en_US from '@locale/lanres/ibzdictitem/ibzdictitem_en_US';
import ibzdict_en_US from '@locale/lanres/ibzdict/ibzdict_en_US';
import userCustom_en_US from '@locale/lanres/userCustom/userCustom_en_US';
import codelist_en_US from '@locale/lanres/codelist/codelist_en_US';
......
import ibzdictitem_zh_CN from '@locale/lanres/ibzdict-item/ibzdict-item_zh_CN';
import ibzdictitem_zh_CN from '@locale/lanres/ibzdictitem/ibzdictitem_zh_CN';
import ibzdict_zh_CN from '@locale/lanres/ibzdict/ibzdict_zh_CN';
import userCustom_zh_CN from '@locale/lanres/userCustom/userCustom_zh_CN';
import codelist_zh_CN from '@locale/lanres/codelist/codelist_zh_CN';
......
export default {
views: {
gridview: {
caption: "字典项目",
title: '字典项目',
},
editview: {
caption: "字典项目",
title: '字典项目',
},
},
main_form: {
details: {
group1: "字典项目基本信息",
formpage1: "基本信息",
srfupdatedate: "更新时间",
srforikey: "",
srfkey: "字典项目标识",
srfmajortext: "栏目显示值",
srftempmode: "",
srfuf: "",
srfdeid: "",
srfsourcekey: "",
dictid: "字典标识",
ibzdictitemname: "栏目显示值",
dictitemval: "栏目值",
pitemval: "父栏目值",
itemfilter: "过滤项",
itemcls: "栏目样式",
itemicon: "图标",
showorder: "排序",
ibzdictitemid: "字典项目标识",
},
uiactions: {
},
},
main_grid: {
columns: {
ibzdictitemname: "栏目显示值",
dictitemval: "栏目值",
pitemval: "父栏目值",
itemfilter: "过滤项",
itemcls: "栏目样式",
itemicon: "图标",
showorder: "排序",
updatedate: "更新时间",
},
uiactions: {
},
},
default_searchform: {
details: {
formpage1: "常规条件",
n_ibzdictitemname_like: "栏目显示值(文本包含(%))",
n_dictitemval_like: "栏目值(文本包含(%))",
},
uiactions: {
},
},
gridviewtoolbar_toolbar: {
tbitem3: {
caption: "New",
tip: "New",
},
tbitem4: {
caption: "Edit",
tip: "Edit",
},
tbitem6: {
caption: "Copy",
tip: "Copy",
},
tbitem7: {
caption: "-",
tip: "",
},
tbitem8: {
caption: "Remove",
tip: "Remove",
},
tbitem9: {
caption: "-",
tip: "",
},
tbitem13: {
caption: "Export",
tip: "Export",
},
tbitem10: {
caption: "-",
tip: "",
},
tbitem16: {
caption: "其它",
tip: "其它",
},
tbitem21: {
caption: "Export Data Model",
tip: "导出数据模型",
},
tbitem23: {
caption: "数据导入",
tip: "数据导入",
},
tbitem17: {
caption: "-",
tip: "",
},
tbitem19: {
caption: "Filter",
tip: "Filter",
},
tbitem18: {
caption: "Help",
tip: "Help",
},
},
editviewtoolbar_toolbar: {
tbitem3: {
caption: "Save",
tip: "Save",
},
tbitem4: {
caption: "Save And New",
tip: "Save And New",
},
tbitem5: {
caption: "Save And Close",
tip: "Save And Close",
},
tbitem6: {
caption: "-",
tip: "",
},
tbitem7: {
caption: "Remove And Close",
tip: "Remove And Close",
},
tbitem8: {
caption: "-",
tip: "",
},
tbitem12: {
caption: "New",
tip: "New",
},
tbitem13: {
caption: "-",
tip: "",
},
tbitem14: {
caption: "Copy",
tip: "Copy",
},
tbitem16: {
caption: "-",
tip: "",
},
tbitem23: {
caption: "第一个记录",
tip: "第一个记录",
},
tbitem24: {
caption: "上一个记录",
tip: "上一个记录",
},
tbitem25: {
caption: "下一个记录",
tip: "下一个记录",
},
tbitem26: {
caption: "最后一个记录",
tip: "最后一个记录",
},
tbitem21: {
caption: "-",
tip: "",
},
tbitem22: {
caption: "Help",
tip: "Help",
},
},
};
\ No newline at end of file
export default {
views: {
gridview: {
caption: '字典项目',
title: '字典项目',
},
editview: {
caption: '字典项目',
title: '字典项目',
},
},
main_form: {
details: {
group1: '字典项目基本信息',
formpage1: '基本信息',
srfupdatedate: '更新时间',
srforikey: '',
srfkey: '字典项目标识',
srfmajortext: '栏目显示值',
srftempmode: '',
srfuf: '',
srfdeid: '',
srfsourcekey: '',
dictid: '字典标识',
ibzdictitemname: '栏目显示值',
dictitemval: '栏目值',
pitemval: '父栏目值',
itemfilter: '过滤项',
itemcls: '栏目样式',
itemicon: '图标',
showorder: '排序',
ibzdictitemid: '字典项目标识',
},
uiactions: {
},
},
main_grid: {
columns: {
ibzdictitemname: '栏目显示值',
dictitemval: '栏目值',
pitemval: '父栏目值',
itemfilter: '过滤项',
itemcls: '栏目样式',
itemicon: '图标',
showorder: '排序',
updatedate: '更新时间',
},
uiactions: {
},
},
default_searchform: {
details: {
formpage1: '常规条件',
n_ibzdictitemname_like: '栏目显示值(文本包含(%))',
n_dictitemval_like: '栏目值(文本包含(%))',
},
uiactions: {
},
},
gridviewtoolbar_toolbar: {
tbitem3: {
caption: '新建',
tip: '新建',
},
tbitem4: {
caption: '编辑',
tip: '编辑',
},
tbitem6: {
caption: '拷贝',
tip: '拷贝',
},
tbitem7: {
caption: '-',
tip: '',
},
tbitem8: {
caption: '删除',
tip: '删除',
},
tbitem9: {
caption: '-',
tip: '',
},
tbitem13: {
caption: '导出',
tip: '导出',
},
tbitem10: {
caption: '-',
tip: '',
},
tbitem16: {
caption: '其它',
tip: '其它',
},
tbitem21: {
caption: '导出数据模型',
tip: '导出数据模型',
},
tbitem23: {
caption: '数据导入',
tip: '数据导入',
},
tbitem17: {
caption: '-',
tip: '',
},
tbitem19: {
caption: '过滤',
tip: '过滤',
},
tbitem18: {
caption: '帮助',
tip: '帮助',
},
},
editviewtoolbar_toolbar: {
tbitem3: {
caption: '保存',
tip: '保存',
},
tbitem4: {
caption: '保存并新建',
tip: '保存并新建',
},
tbitem5: {
caption: '保存并关闭',
tip: '保存并关闭',
},
tbitem6: {
caption: '-',
tip: '',
},
tbitem7: {
caption: '删除并关闭',
tip: '删除并关闭',
},
tbitem8: {
caption: '-',
tip: '',
},
tbitem12: {
caption: '新建',
tip: '新建',
},
tbitem13: {
caption: '-',
tip: '',
},
tbitem14: {
caption: '拷贝',
tip: '拷贝',
},
tbitem16: {
caption: '-',
tip: '',
},
tbitem23: {
caption: '第一个记录',
tip: '第一个记录',
},
tbitem24: {
caption: '上一个记录',
tip: '上一个记录',
},
tbitem25: {
caption: '下一个记录',
tip: '下一个记录',
},
tbitem26: {
caption: '最后一个记录',
tip: '最后一个记录',
},
tbitem21: {
caption: '-',
tip: '',
},
tbitem22: {
caption: '帮助',
tip: '帮助',
},
},
};
\ No newline at end of file
import qs from 'qs';
import { MockAdapter } from '@/mock/mock-adapter';
const mock = MockAdapter.getInstance();
// 模拟数据
const mockDatas: Array<any> = [
];
......@@ -7,3 +7,294 @@ const mockDatas: Array<any> = [
];
// Select
mock.onGet(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Select");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/select$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items);
console.groupEnd();
console.groupEnd();
return [status, _items];
});
// Create
mock.onPost(new RegExp(/^\/ibzdicts\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Create");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas[0]);
console.groupEnd();
console.groupEnd();
return [status, mockDatas[0]];
});
// CheckKey
mock.onPost(new RegExp(/^\/ibzdicts\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: CheckKey");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['dictid'] == tempValue['dictid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// GetDraft
mock.onGet(new RegExp(/^\/ibzdicts\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: GetDraft");
console.table({url:config.url, method: config.method, data:config.data});
// GetDraft
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// Update
mock.onPut(new RegExp(/^\/ibzdicts\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Update");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['dictid'] == tempValue['dictid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// Save
mock.onPost(new RegExp(/^\/ibzdicts\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Save");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/save$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
//let items = mockDatas ? mockDatas : [];
//let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['dictid'] == tempValue['dictid'] ){
for(let value in data){
if(item.hasOwnProperty(value)){
item[value] = data[value];
}
}
}
})
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(data);
console.groupEnd();
console.groupEnd();
return [status, data];
});
// FetchDefault
mock.onGet(new RegExp(/^\/ibzdicts\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: FetchDefault");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(mockDatas);
console.groupEnd();
console.groupEnd();
return [status, mockDatas ? mockDatas : []];
});
// FetchDefault
mock.onGet(new RegExp(/^\/ibzdicts\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: FetchDefault");
console.table({url:config.url, method: config.method, data:config.data});
if(config.url.includes('page')){
let url = config.url.split('?')[1];
let params = qs.parse(url);
Object.assign(config, params);
}
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
let total = mockDatas.length;
let records: Array<any> = [];
if(!config.page || !config.size){
records = mockDatas;
}else{
if((config.page-1)*config.size < total){
records = mockDatas.slice(config.page,config.size);
}
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(records ? records : []);
console.groupEnd();
console.groupEnd();
return [status, records ? records : []];
});
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// Get
mock.onGet(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Get");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
// Remove
mock.onDelete(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdict 方法: Remove");
console.table({url:config.url, method: config.method, data:config.data});
let status = MockAdapter.mockStatus(config);
if (status !== 200) {
return [status, null];
}
const paramArray:Array<any> = ['dictid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})$/).exec(config.url);
let tempValue: any = {};
if(matchArray && matchArray.length >1 && paramArray && paramArray.length >0){
paramArray.forEach((item: any, index: number) => {
Object.defineProperty(tempValue, item, {
enumerable: true,
value: matchArray[index + 1]
});
});
}
let items = mockDatas ? mockDatas : [];
let _items = items.find((item: any) => Object.is(item.dictid, tempValue.dictid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
......@@ -7,5 +7,5 @@ import './login/login';
import './upload/upload';
// 实体级接口对象
import './entity/ibzdict-items/ibzdict-items';
import './entity/ibzdictitems/ibzdictitems';
import './entity/ibzdicts/ibzdicts';
......@@ -99,11 +99,11 @@
:autosave="false"
:viewtag="viewtag"
:showBusyIndicator="true"
updateAction=""
removeAction=""
loaddraftAction=""
loadAction=""
createAction=""
updateAction="Update"
removeAction="Remove"
loaddraftAction="GetDraft"
loadAction="Get"
createAction="Create"
WFSubmitAction=""
WFStartAction=""
style=''
......@@ -357,6 +357,7 @@ export default class IBZDictEditViewBase extends Vue {
form: this.$refs.form,
p2k: '0',
keyPSDEField: 'ibzdict',
majorPSDEField: 'dictname',
isLoadDefault: true,
});
}
......
......@@ -101,8 +101,8 @@
:context="context"
:showBusyIndicator="true"
v-show="isExpandSearchForm"
loaddraftAction=""
loadAction=""
loaddraftAction="FilterGetDraft"
loadAction="FilterGet"
name="searchform"
ref='searchform'
@save="searchform_save($event)"
......@@ -120,11 +120,11 @@
:gridRowActiveMode="gridRowActiveMode"
@save="onSave"
updateAction=""
removeAction=""
removeAction="Remove"
loaddraftAction=""
loadAction=""
createAction=""
fetchAction=""
fetchAction="FetchDefault"
:newdata="newdata"
:opendata="opendata"
name="grid"
......@@ -383,6 +383,7 @@ export default class IBZDictGridViewBase extends Vue {
grid: this.$refs.grid,
searchform: this.$refs.searchform,
keyPSDEField: 'ibzdict',
majorPSDEField: 'dictname',
isLoadDefault: true,
});
}
......
......@@ -99,11 +99,11 @@
:autosave="false"
:viewtag="viewtag"
:showBusyIndicator="true"
updateAction=""
removeAction=""
loaddraftAction=""
loadAction=""
createAction=""
updateAction="Update"
removeAction="Remove"
loaddraftAction="GetDraft"
loadAction="Get"
createAction="Create"
WFSubmitAction=""
WFStartAction=""
style=''
......@@ -125,7 +125,7 @@
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import { Subject } from 'rxjs';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-service';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import EditViewEngine from '@engine/view/edit-view-engine';
......@@ -140,10 +140,10 @@ export default class IBZDictItemEditViewBase extends Vue {
/**
* 实体服务对象
*
* @type {IBZDictItemService}
* @type {IBZDICTITEMService}
* @memberof IBZDictItemEditViewBase
*/
protected appEntityService: IBZDictItemService = new IBZDictItemService;
protected appEntityService: IBZDICTITEMService = new IBZDICTITEMService;
/**
......@@ -357,6 +357,7 @@ export default class IBZDictItemEditViewBase extends Vue {
form: this.$refs.form,
p2k: '0',
keyPSDEField: 'ibzdictitem',
majorPSDEField: 'itemname',
isLoadDefault: true,
});
}
......@@ -651,7 +652,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Save(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Save(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -677,7 +678,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.SaveAndNew(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.SaveAndNew(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -703,7 +704,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.SaveAndExit(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.SaveAndExit(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -729,7 +730,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.RemoveAndExit(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.RemoveAndExit(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -755,7 +756,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.SaveAndStart(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.SaveAndStart(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -781,7 +782,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.ViewWFStep(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.ViewWFStep(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -807,7 +808,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.New(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.New(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -833,7 +834,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Copy(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Copy(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -859,7 +860,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Print(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Print(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -885,7 +886,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.FirstRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.FirstRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -911,7 +912,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.PrevRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.PrevRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -937,7 +938,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.NextRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.NextRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -963,7 +964,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.LastRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.LastRecord(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -989,7 +990,7 @@ export default class IBZDictItemEditViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Help(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Help(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -1329,33 +1330,6 @@ export default class IBZDictItemEditViewBase extends Vue {
}
}
/**
* 销毁视图回调
*
* @memberof IBZDictItemEditViewBase
*/
protected destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof IBZDictItemEditViewBase
*/
protected afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
}
}
}
</script>
......
......@@ -2,7 +2,7 @@
import { Component } from 'vue-property-decorator';
import IBZDictItemEditViewBase from './ibzdict-item-edit-view-base.vue';
import view_form from '@widgets/ibzdict-item/main-form/main-form.vue';
import view_form from '@widgets/ibzdictitem/main-form/main-form.vue';
@Component({
components: {
view_form,
......
......@@ -101,8 +101,8 @@
:context="context"
:showBusyIndicator="true"
v-show="isExpandSearchForm"
loaddraftAction=""
loadAction=""
loaddraftAction="FilterGetDraft"
loadAction="FilterGet"
name="searchform"
ref='searchform'
@save="searchform_save($event)"
......@@ -120,11 +120,11 @@
:gridRowActiveMode="gridRowActiveMode"
@save="onSave"
updateAction=""
removeAction=""
removeAction="Remove"
loaddraftAction=""
loadAction=""
createAction=""
fetchAction=""
fetchAction="FetchDefault"
:newdata="newdata"
:opendata="opendata"
name="grid"
......@@ -147,7 +147,7 @@
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
import { UIActionTool,Util } from '@/utils';
import { Subject } from 'rxjs';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-service';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import GridViewEngine from '@engine/view/grid-view-engine';
......@@ -162,10 +162,10 @@ export default class IBZDictItemGridViewBase extends Vue {
/**
* 实体服务对象
*
* @type {IBZDictItemService}
* @type {IBZDICTITEMService}
* @memberof IBZDictItemGridViewBase
*/
protected appEntityService: IBZDictItemService = new IBZDictItemService;
protected appEntityService: IBZDICTITEMService = new IBZDICTITEMService;
/**
......@@ -383,6 +383,7 @@ export default class IBZDictItemGridViewBase extends Vue {
grid: this.$refs.grid,
searchform: this.$refs.searchform,
keyPSDEField: 'ibzdictitem',
majorPSDEField: 'itemname',
isLoadDefault: true,
});
}
......@@ -745,7 +746,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.New(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.New(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -771,7 +772,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Edit(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Edit(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -797,7 +798,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.View(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.View(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -823,7 +824,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Copy(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Copy(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -849,7 +850,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.ToggleRowEdit(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.ToggleRowEdit(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -875,7 +876,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.NewRow(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.NewRow(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -901,7 +902,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Remove(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Remove(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -927,7 +928,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.ExportExcel(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.ExportExcel(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -953,7 +954,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Print(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Print(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -979,7 +980,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.ExportModel(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.ExportModel(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -1005,7 +1006,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Import(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Import(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -1031,7 +1032,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.ToggleFilter(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.ToggleFilter(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -1057,7 +1058,7 @@ export default class IBZDictItemGridViewBase extends Vue {
datas = [...xData.getDatas()];
}
// 界面行为
this.Help(datas, contextJO,paramJO, $event, xData,this,"IBZDictItem");
this.Help(datas, contextJO,paramJO, $event, xData,this,"IBZDICTITEM");
}
/**
......@@ -1076,7 +1077,10 @@ export default class IBZDictItemGridViewBase extends Vue {
if(args.length >0){
Object.assign(curViewParam,args[0]);
}
const deResParameters: any[] = [];
let deResParameters: any[] = [];
deResParameters = [
{ pathName: 'ibzdicts', parameterName: 'ibzdict' },
];
const parameters: any[] = [
{ pathName: 'ibzdictitems', parameterName: 'ibzdictitem' },
{ pathName: 'editview', parameterName: 'editview' },
......@@ -1108,7 +1112,10 @@ export default class IBZDictItemGridViewBase extends Vue {
if(args.length >0){
Object.assign(curViewParam,args[0]);
}
const deResParameters: any[] = [];
let deResParameters: any[] = [];
deResParameters = [
{ pathName: 'ibzdicts', parameterName: 'ibzdict' },
];
const parameters: any[] = [
{ pathName: 'ibzdictitems', parameterName: 'ibzdictitem' },
{ pathName: 'editview', parameterName: 'editview' },
......@@ -1393,33 +1400,6 @@ export default class IBZDictItemGridViewBase extends Vue {
}
}
/**
* 销毁视图回调
*
* @memberof IBZDictItemGridViewBase
*/
protected destroyed(){
this.afterDestroyed();
}
/**
* 执行destroyed后的逻辑
*
* @memberof IBZDictItemGridViewBase
*/
protected afterDestroyed(){
if(this.viewDefaultUsage){
let localStoreLength = Object.keys(localStorage);
if(localStoreLength.length > 0){
localStoreLength.forEach((item:string) =>{
if(item.startsWith(this.context.srfsessionid)){
localStorage.removeItem(item);
}
})
}
}
}
/**
* 是否单选
*
......
......@@ -2,8 +2,8 @@
import { Component } from 'vue-property-decorator';
import IBZDictItemGridViewBase from './ibzdict-item-grid-view-base.vue';
import view_grid from '@widgets/ibzdict-item/main-grid/main-grid.vue';
import view_searchform from '@widgets/ibzdict-item/default-searchform/default-searchform.vue';
import view_grid from '@widgets/ibzdictitem/main-grid/main-grid.vue';
import view_searchform from '@widgets/ibzdictitem/default-searchform/default-searchform.vue';
@Component({
components: {
view_grid,
......
......@@ -39,7 +39,7 @@ export class EntityServiceRegister {
* @memberof EntityServiceRegister
*/
protected init(): void {
this.allEntityService.set('ibzdictitem', () => import('@/service/ibzdict-item/ibzdict-item-service'));
this.allEntityService.set('ibzdictitem', () => import('@/service/ibzdictitem/ibzdictitem-service'));
this.allEntityService.set('ibzdict', () => import('@/service/ibzdict/ibzdict-service'));
}
......
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${item.getKeyPSAppDEField().getCodeNa... [in template "TEMPLCODE_zh_CN" at line 410, column 26]
----
\ No newline at end of file
import { Http,Util } from '@/utils';
import EntityService from '../entity-service';
/**
* 数据字典服务对象基类
*
* @export
* @class IBZDictServiceBase
* @extends {EntityServie}
*/
export default class IBZDictServiceBase extends EntityService {
/**
* Creates an instance of IBZDictServiceBase.
*
* @param {*} [opts={}]
* @memberof IBZDictServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 初始化基础数据
*
* @memberof IBZDictServiceBase
*/
public initBasicData(){
this.APPLYDEKEY ='ibzdict';
this.APPDEKEY = 'dictid';
this.APPDENAME = 'ibzdicts';
this.APPDETEXT = 'dictname';
}
// 实体接口
/**
* Select接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().get(`/ibzdicts/${context.ibzdict}/select`,isloading);
}
/**
* Get接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/ibzdicts/${context.ibzdict}`,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_ibzdictitems',JSON.stringify(res.data.ibzdictitems));
return res;
}
/**
* Create接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let ibzdictitemsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems'),'undefined')){
ibzdictitemsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems') as any);
}
masterData.ibzdictitems = ibzdictitemsData;
Object.assign(data,masterData);
data[this.APPDEKEY] = null;
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/ibzdicts`,data,isloading);
this.tempStorage.setItem(tempContext.srfsessionkey+'_ibzdictitems',JSON.stringify(res.data.ibzdictitems));
return res;
}
/**
* CheckKey接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().post(`/ibzdicts/${context.ibzdict}/checkkey`,data,isloading);
}
/**
* GetDraft接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let res:any = await Http.getInstance().get(`/ibzdicts/getdraft`,isloading);
res.data.ibzdict = data.ibzdict;
this.tempStorage.setItem(context.srfsessionkey+'_ibzdictitems',JSON.stringify(res.data.ibzdictitems));
return res;
}
/**
* Update接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let ibzdictitemsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems'),'undefined')){
ibzdictitemsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems') as any);
}
masterData.ibzdictitems = ibzdictitemsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/ibzdicts/${context.ibzdict}`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_ibzdictitems',JSON.stringify(res.data.ibzdictitems));
return res;
}
/**
* Remove接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
return Http.getInstance().delete(`/ibzdicts/${context.ibzdict}`,isloading);
}
/**
* Save接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let masterData:any = {};
let ibzdictitemsData:any = [];
if(!Object.is(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems'),'undefined')){
ibzdictitemsData = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems') as any);
}
masterData.ibzdictitems = ibzdictitemsData;
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/ibzdicts/${context.ibzdict}/save`,data,isloading);
this.tempStorage.setItem(context.srfsessionkey+'_ibzdictitems',JSON.stringify(res.data.ibzdictitems));
return res;
}
/**
* FetchDefault接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictServiceBase
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
let tempData:any = JSON.parse(JSON.stringify(data));
return Http.getInstance().get(`/ibzdicts/fetchdefault`,tempData,isloading);
}
}
\ No newline at end of file
import { Http,Util } from '@/utils';
import EntityService from '../entity-service';
/**
* 字典项目服务对象基类
*
* @export
* @class IBZDICTITEMServiceBase
* @extends {EntityServie}
*/
export default class IBZDICTITEMServiceBase extends EntityService {
/**
* Creates an instance of IBZDICTITEMServiceBase.
*
* @param {*} [opts={}]
* @memberof IBZDICTITEMServiceBase
*/
constructor(opts: any = {}) {
super(opts);
}
/**
* 初始化基础数据
*
* @memberof IBZDICTITEMServiceBase
*/
public initBasicData(){
this.APPLYDEKEY ='ibzdictitem';
this.APPDEKEY = 'itemid';
this.APPDENAME = 'ibzdictitems';
this.APPDETEXT = 'itemname';
}
// 实体接口
/**
* FetchDefault接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDICTITEMServiceBase
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
// FetchDefault ---FETCH
if(context.srfsessionkey && !Object.is(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems'),'undefined')){
let result:any = JSON.parse(this.tempStorage.getItem(context.srfsessionkey+'_ibzdictitems') as any);
if(result){
return {"status":200,"data":result};
}else{
return {"status":200,"data":[]};
}
}else{
return {"status":200,"data":[]};
}
}
}
\ No newline at end of file
import { Http,Util } from '@/utils';
import IBZDICTITEMServiceBase from './ibzdictitem-service-base';
/**
* 字典项目服务对象
*
* @export
* @class IBZDICTITEMService
* @extends {IBZDICTITEMServiceBase}
*/
export default class IBZDICTITEMService extends IBZDICTITEMServiceBase {
/**
* Creates an instance of IBZDICTITEMService.
*
* @param {*} [opts={}]
* @memberof IBZDICTITEMService
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
import { Environment } from '@/environments/environment';
import { UIActionTool,Util } from '@/utils';
import UIService from '../ui-service';
import { Subject } from 'rxjs';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
/**
* 字典项目UI服务对象基类
*
* @export
* @class IBZDICTITEMUIServiceBase
*/
export default class IBZDICTITEMUIServiceBase extends UIService {
/**
* 是否支持工作流
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected isEnableWorkflow:boolean = false;
/**
* 当前UI服务对应的数据服务对象
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected dataService:IBZDICTITEMService = new IBZDICTITEMService();
/**
* 所有关联视图
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected allViewMap: Map<string, Object> = new Map();
/**
* 状态值
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected stateValue: number = 0;
/**
* 状态属性
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected stateField: string = "";
/**
* 主状态属性集合
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected mainStateFields:Array<any> = [];
/**
* 主状态集合Map
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected allDeMainStateMap:Map<string,string> = new Map();
/**
* Creates an instance of IBZDICTITEMUIServiceBase.
*
* @param {*} [opts={}]
* @memberof IBZDICTITEMUIServiceBase
*/
constructor(opts: any = {}) {
super(opts);
this.initViewMap();
this.initDeMainStateMap();
}
/**
* 初始化视图Map
*
* @memberof IBZDICTITEMUIServiceBase
*/
public initViewMap(){
this.allViewMap.set('MDATAVIEW:',{viewname:'gridview',srfappde:'ibzdictitems'});
this.allViewMap.set('EDITVIEW:',{viewname:'editview',srfappde:'ibzdictitems'});
}
/**
* 初始化主状态集合
*
* @memberof IBZDICTITEMUIServiceBase
*/
public initDeMainStateMap(){
}
/**
* 获取指定数据的重定向页面
*
* @param srfkey 数据主键
* @param isEnableWorkflow 重定向视图是否需要处理流程中的数据
* @memberof IBZDICTITEMUIServiceBase
*/
public async getRDAppView(srfkey:string,isEnableWorkflow:boolean){
this.isEnableWorkflow = isEnableWorkflow;
// 进行数据查询
let result:any = await this.dataService.Get({ibzdictitem:srfkey});
const curData:any = result.data;
//判断当前数据模式,默认为true,todo
const iRealDEModel:boolean = true;
let bDataInWF:boolean = false;
let bWFMode:any = false;
// 计算数据模式
if (this.isEnableWorkflow) {
bDataInWF = await this.dataService.testDataInWF({stateValue:this.stateValue,stateField:this.stateField},curData);
if (bDataInWF) {
bDataInWF = true;
bWFMode = await this.dataService.testUserExistWorklist(null,curData);
}
}
let strPDTViewParam:string = await this.getDESDDEViewPDTParam(curData, bDataInWF, bWFMode);
//若不是当前数据模式,处理strPDTViewParam,todo
//查找视图
//返回视图
return this.allViewMap.get(strPDTViewParam);
}
/**
* 获取实际的数据类型
*
* @memberof IBZDICTITEMUIServiceBase
*/
protected getRealDEType(entity:any){
}
/**
* 获取实体单数据实体视图预定义参数
*
* @param curData 当前数据
* @param bDataInWF 是否有数据在工作流中
* @param bWFMode 是否工作流模式
* @memberof IBZDICTITEMUIServiceBase
*/
protected async getDESDDEViewPDTParam(curData:any, bDataInWF:boolean, bWFMode:boolean){
let strPDTParam:string = '';
if (bDataInWF) {
// 判断数据是否在流程中
}
//多表单,todo
const isEnableMultiForm:boolean = false;
const multiFormDEField:string|null =null;
if (isEnableMultiForm && multiFormDEField) {
const objFormValue:string = curData[multiFormDEField];
if(!Environment.isAppMode){
return 'MOBEDITVIEW'+objFormValue;
}
return 'EDITVIEW'+objFormValue;
}
if(!Environment.isAppMode){
if(this.getDEMainStateTag(curData)){
return `MOBEDITVIEW:MSTAG:${ await this.getDEMainStateTag(curData)}`;
}
return 'MOBEDITVIEW:';
}
if(this.getDEMainStateTag(curData)){
return `EDITVIEW:MSTAG:${ await this.getDEMainStateTag(curData)}`;
}
return 'EDITVIEW:';
}
/**
* 获取数据对象的主状态标识
*
* @param curData 当前数据
* @memberof IBZDICTITEMUIServiceBase
*/
protected async getDEMainStateTag(curData:any){
if(this.mainStateFields.length === 0) return null;
this.mainStateFields.forEach((singleMainField:any) =>{
if(!(singleMainField in curData)){
console.error(`当前数据对象不包含属性singleMainField,可能会发生错误`);
}
})
let strTag:String = "";
for (let i = 0; i <= 1; i++) {
let strTag:string = (curData[this.mainStateFields[0]])?(i == 0) ? curData[this.mainStateFields[0]] : "":"";
if (this.mainStateFields.length >= 2) {
for (let j = 0; j <= 1; j++) {
let strTag2:string = (curData[this.mainStateFields[1]])?`${strTag}__${(j == 0) ? curData[this.mainStateFields[1]] : ""}`:strTag;
if (this.mainStateFields.length >= 3) {
for (let k = 0; k <= 1; k++) {
let strTag3:string = (curData[this.mainStateFields[2]])?`${strTag2}__${(k == 0) ? curData[this.mainStateFields[2]] : ""}`:strTag2;
// 判断是否存在
return this.allDeMainStateMap.get(strTag3);
}
}else{
return this.allDeMainStateMap.get(strTag2);
}
}
}else{
return this.allDeMainStateMap.get(strTag);
}
}
return null;
}
}
\ No newline at end of file
import IBZDICTITEMUIServiceBase from './ibzdictitem-ui-service-base';
/**
* 字典项目UI服务对象
*
* @export
* @class IBZDICTITEMUIService
*/
export default class IBZDICTITEMUIService extends IBZDICTITEMUIServiceBase {
/**
* Creates an instance of IBZDICTITEMUIService.
*
* @param {*} [opts={}]
* @memberof IBZDICTITEMUIService
*/
constructor(opts: any = {}) {
super(opts);
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ export class UIServiceRegister {
* @memberof UIServiceRegister
*/
protected init(): void {
this.allUIService.set('ibzdictitem', () => import('@/uiservice/ibzdict-item/ibzdict-item-ui-service'));
this.allUIService.set('ibzdictitem', () => import('@/uiservice/ibzdictitem/ibzdictitem-ui-service'));
this.allUIService.set('ibzdict', () => import('@/uiservice/ibzdict/ibzdict-ui-service'));
}
......
......@@ -29,6 +29,11 @@ export default class DefaultModel {
prop: 'dictname',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
]
}
......
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 334, column 14]
----
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDictService from '@/service/ibzdict/ibzdict-service';
import DefaultModel from './default-searchform-model';
/**
* Default 部件服务对象
*
* @export
* @class DefaultService
*/
export default class DefaultService extends ControlService {
/**
* 数据字典服务对象
*
* @type {IBZDictService}
* @memberof DefaultService
*/
public appEntityService: IBZDictService = new IBZDictService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof DefaultService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of DefaultService.
*
* @param {*} [opts={}]
* @memberof DefaultService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new DefaultModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof DefaultService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof DefaultService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
Data.dictid = Util.createUUID();
Data.ibzdict = Data.dictid;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof DefaultService
*/
public handleRequestData(action: string,context:any, data: any = {}){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}
}
});
if(data && data.viewparams){
Object.assign(requestData,data.viewparams);
}
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
}
\ No newline at end of file
......@@ -59,6 +59,11 @@ export default class MainModel {
prop: 'dictname',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
]
}
......
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 334, column 14]
----
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDictService from '@/service/ibzdict/ibzdict-service';
import MainModel from './main-form-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 数据字典服务对象
*
* @type {IBZDictService}
* @memberof MainService
*/
public appEntityService: IBZDictService = new IBZDictService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
Data.dictid = Util.createUUID();
Data.ibzdict = Data.dictid;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof MainService
*/
public handleRequestData(action: string,context:any, data: any = {}){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}
}
});
if(data && data.viewparams){
Object.assign(requestData,data.viewparams);
}
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
}
\ No newline at end of file
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${ctrl.getPSAppDataEntity().getKeyPSA... [in template "TEMPLCODE_zh_CN" at line 800, column 186]
----
\ No newline at end of file
<template>
<div class='grid' style="height:100%;">
<el-table v-if="isDisplay === true"
:default-sort="{ prop: minorSortPSDEF, order: Object.is(minorSortDir, 'ASC') ? 'ascending' : Object.is(minorSortDir, 'DESC') ? 'descending' : '' }"
@sort-change="onSortChange($event)"
:border="isDragendCol"
:height="isEnablePagingBar && items.length > 0 ? 'calc(100% - 50px)' : '100%'"
:highlight-current-row ="isSingleSelect"
:row-class-name="getRowClassName"
@row-click="rowClick($event)"
@select-all="selectAll($event)"
@select="select($event)"
@row-class-name="onRowClassName($event)"
@row-dblclick="rowDBLClick($event)"
ref='multipleTable' :data="items" :show-header="!isHideHeader">
<template v-if="!isSingleSelect">
<el-table-column type='selection' :width="checkboxColWidth"></el-table-column>
</template>
<template v-if="getColumnState('ibzdictid')">
<el-table-column show-overflow-tooltip :prop="'ibzdictid'" :label="$t('ibzdict.main_grid.columns.ibzdictid')" :width="250" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.ibzdictid}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('ibzdictname')">
<el-table-column show-overflow-tooltip :prop="'ibzdictname'" :label="$t('ibzdict.main_grid.columns.ibzdictname')" :width="350" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.ibzdictname}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('updatedate')">
<el-table-column show-overflow-tooltip :prop="'updatedate'" :label="$t('ibzdict.main_grid.columns.updatedate')" :width="250" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.updatedate}}</span>
</template>
</el-table-column>
</template>
<template v-if="adaptiveState">
<el-table-column></el-table-column>
</template>
</el-table>
<row class='grid-pagination' v-show="items.length > 0">
<page class='pull-right' @on-change="pageOnChange($event)"
@on-page-size-change="onPageSizeChange($event)"
:transfer="true" :total="totalrow"
show-sizer :current="curPage" :page-size="limit"
:page-size-opts="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]" show-elevator show-total>
<span>
<span class="page-column">
<poptip transfer placement="top-start">
<i-button icon="md-menu">{{$t('app.gridpage.choicecolumns')}}</i-button>
<div slot="content">
<template v-for="col in allColumns">
<div :key="col.name"><el-checkbox v-model="col.show" @change="onColChange()">{{$t(col.langtag)}}</el-checkbox></div>
</template>
</div>
</poptip>
</span>
<span class="page-button"><i-button icon="md-refresh" :title="$t('app.gridpage.refresh')" @click="pageRefresh()"></i-button></span>&nbsp;
<span>
{{$t('app.gridpage.show')}}&nbsp;
<span>
<template v-if="items.length === 1">
1
</template>
<template v-else>
<span>{{(curPage - 1) * limit + 1}}&nbsp;-&nbsp;{{totalrow > curPage * limit ? curPage * limit : totalrow}}</span>
</template>
</span>&nbsp;
{{$t('app.gridpage.records')}},{{$t('app.gridpage.totle')}}&nbsp;{{totalrow}}&nbsp;{{$t('app.gridpage.records')}}
</span>
</span>
</page>
</row>
</div>
</template>
<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import IBZDictService from '@/service/ibzdict/ibzdict-service';
import MainService from './main-grid-service';
import CodeListService from "@service/app/codelist-service";
@Component({
components: {
}
})
export default class MainBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof Main
*/
@Prop() protected name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof Main
*/
@Prop() protected viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof Main
*/
@Prop() protected context: any;
/**
* 视图参数
*
* @type {*}
* @memberof Main
*/
@Prop() protected viewparams: any;
/**
* 视图状态事件
*
* @protected
* @type {(Subscription | undefined)}
* @memberof Main
*/
protected viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof Main
*/
protected getControlType(): string {
return 'GRID'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof Main
*/
protected counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {MainService}
* @memberof Main
*/
protected service: MainService = new MainService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {IBZDictService}
* @memberof Main
*/
protected appEntityService: IBZDictService = new IBZDictService({ $store: this.$store });
/**
* 关闭视图
*
* @param {any[]} args
* @memberof Main
*/
protected closeView(args: any[]): void {
let _this: any = this;
_this.$emit('closeview', args);
}
/**
* 计数器刷新
*
* @memberof Main
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof Main
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof Main
*/
public getDatas(): any[] {
return this.selections;
}
/**
* 获取单项树
*
* @returns {*}
* @memberof Main
*/
public getData(): any {
return this.selections[0];
}
/**
* 打开新建数据视图
*
* @type {any}
* @memberof Main
*/
@Prop() protected newdata: any;
/**
* 打开编辑数据视图
*
* @type {any}
* @memberof Main
*/
@Prop() protected opendata: any;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--update
*
* @type {string}
* @memberof Main
*/
@Prop() protected updateAction!: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof Main
*/
@Prop() protected fetchAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof Main
*/
@Prop() protected removeAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof Main
*/
@Prop() protected loadAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof Main
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Main
*/
@Prop() protected createAction!: string;
/**
* 当前页
*
* @type {number}
* @memberof Main
*/
protected curPage: number = 1;
/**
* 数据
*
* @type {any[]}
* @memberof Main
*/
protected items: any[] = [];
/**
* 是否支持分页
*
* @type {boolean}
* @memberof Main
*/
protected isEnablePagingBar: boolean = true;
/**
* 是否禁用排序
*
* @type {boolean}
* @memberof Main
*/
protected isNoSort: boolean = false;
/**
* 排序方向
*
* @type {string}
* @memberof Main
*/
protected minorSortDir: string = '';
/**
* 排序字段
*
* @type {string}
* @memberof Main
*/
protected minorSortPSDEF: string = '';
/**
* 分页条数
*
* @type {number}
* @memberof Main
*/
protected limit: number = 20;
/**
* 是否显示标题
*
* @type {boolean}
* @memberof Main
*/
protected isHideHeader: boolean = false;
/**
* 是否默认选中第一条数据
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: false }) protected isSelectFirstDefault!: boolean;
/**
* 是否单选
*
* @type {boolean}
* @memberof Main
*/
@Prop() protected isSingleSelect?: boolean;
/**
* 选中数据字符串
*
* @type {string}
* @memberof Main
*/
@Prop() protected selectedData?: string;
/**
* 选中值变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainTree
*/
@Watch('selectedData')
public onValueChange(newVal: any, oldVal: any) {
this.selections = [];
if(this.selectedData){
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(this.selectedData).forEach((selection:any)=>{
let selectedItem = this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
this.rowClick(selectedItem);
}
});
}
}
}
/**
* 表格行数据默认激活模式
* 0 不激活
* 1 单击激活
* 2 双击激活
*
* @type {(number | 0 | 1 | 2)}
* @memberof Main
*/
@Prop({default: 2}) protected gridRowActiveMode!: number;
/**
* 是否开启行编辑
*
* @type {boolean}
* @memberof Main
*/
@Prop({default: false}) protected isOpenEdit!: boolean;
/**
* 实际是否开启行编辑
*
* @type {boolean}
* @memberof Main
*/
protected actualIsOpenEdit: boolean = this.isOpenEdit;
/**
* 总条数
*
* @type {number}
* @memberof Main
*/
protected totalrow: number = 0;
/**
* 选中行数据
*
* @type {any[]}
* @memberof Main
*/
protected selections: any[] = [];
/**
* 拦截行选中
*
* @type {boolean}
* @memberof Main
*/
protected stopRowClick: boolean = false;
/**
* 表格是否显示
*
* @type {boolean}
* @memberof Main
*/
protected isDisplay:boolean = true;
/**
* 部件刷新
*
* @param {any[]} args
* @memberof Main
*/
protected refresh(args: any[]): void {
this.load();
}
/**
* 选项框列宽
*
* @type {number}
* @memberof AppIndex
*/
protected checkboxColWidth: number = 80;
/**
* 是否允许拖动列宽
*
* @type {boolean}
* @memberof AppEmbedPicker
*/
protected isDragendCol: boolean = false;
/**
* 所有列成员
*
* @type {any[]}
* @memberof Main
*/
protected allColumns: any[] = [
{
name: 'ibzdictid',
label: '字典标识',
langtag: 'ibzdict.main_grid.columns.ibzdictid',
show: true,
util: 'PX'
},
{
name: 'ibzdictname',
label: '字典名称',
langtag: 'ibzdict.main_grid.columns.ibzdictname',
show: true,
util: 'PX'
},
{
name: 'updatedate',
label: '更新时间',
langtag: 'ibzdict.main_grid.columns.updatedate',
show: true,
util: 'PX'
},
]
/**
* 属性值规则
*
* @type {*}
* @memberof Main
*/
protected rules: any = {
srfkey: [
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '字典标识 值不能为空', trigger: 'change' },
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '字典标识 值不能为空', trigger: 'blur' },
],
}
/**
* 表格数据加载
*
* @param {*} [arg={}]
* @memberof Main
*/
protected load(opt: any = {}, pageReset: boolean = false): void {
if(!this.fetchAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictGridView视图表格fetchAction参数未配置' });
return;
}
if(pageReset){
this.curPage = 1;
}
const arg: any = {...opt};
const page: any = {};
if (this.isEnablePagingBar) {
Object.assign(page, { page: this.curPage-1, size: this.limit });
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
Object.assign(arg, page);
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data: any = response.data;
this.totalrow = response.total;
this.items = JSON.parse(JSON.stringify(data));
// 清空selections
this.selections = [];
this.$emit('load', this.items);
// 设置默认选中
let _this = this;
setTimeout(() => {
if(_this.isSelectFirstDefault){
_this.rowClick(_this.items[0]);
}
if(_this.selectedData){
const refs: any = _this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(_this.selectedData).forEach((selection:any)=>{
let selectedItem = _this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
_this.rowClick(selectedItem);
}
});
}
}
}, 300);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '错误', desc: response.errorMessage });
});
}
/**
* 删除
*
* @param {any[]} datas
* @returns {Promise<any>}
* @memberof Main
*/
protected async remove(datas: any[]): Promise<any> {
if(!this.removeAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictGridView视图表格removeAction参数未配置' });
return;
}
let _datas:any[] = [];
datas.forEach((record: any, index: number) => {
if (!record.srfkey) {
this.items.some((val: any, num: number) =>{
if(JSON.stringify(val) == JSON.stringify(record)){
this.items.splice(num,1);
return true;
}
});
}else{
_datas.push(datas[index]);
}
});
if (_datas.length === 0) {
return;
}
let dataInfo = '';
_datas.forEach((record: any, index: number) => {
let srfmajortext = record.srfmajortext;
if (index < 5) {
if (!Object.is(dataInfo, '')) {
dataInfo += '、';
}
dataInfo += srfmajortext;
} else {
return false;
}
});
if (_datas.length < 5) {
dataInfo = dataInfo + ' 共' + _datas.length + '条数据';
} else {
dataInfo = dataInfo + '...' + ' 共' + _datas.length + '条数据';
}
const removeData = () => {
let keys: any[] = [];
_datas.forEach((data: any) => {
keys.push(data.srfkey);
});
const context:any = JSON.parse(JSON.stringify(this.context));
const post: Promise<any> = this.service.delete(this.removeAction,Object.assign(context,{ ibzdict: keys.join(';') }),Object.assign({ dictid: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '删除数据失败,' + response.info });
return;
} else {
this.$Notice.success({ title: '', desc: '删除成功!' });
}
//删除items中已删除的项
console.log(this.items);
_datas.forEach((data: any) => {
this.items.some((item:any,index:number)=>{
if(Object.is(item.srfkey,data.srfkey)){
this.items.splice(index,1);
return true;
}
});
});
this.totalrow -= _datas.length;
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
});
}
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
this.$Modal.confirm({
title: '警告',
content: '确认要删除 ' + dataInfo + ',删除操作将不可恢复?',
onOk: () => {
removeData();
},
onCancel: () => { }
});
return removeData;
}
/**
* 批量添加
*
* @param {*} [arg={}]
* @memberof Main
*/
protected addBatch(arg: any = {}): void {
if(!this.fetchAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictGridView视图表格fetchAction参数未配置' });
return;
}
if(!arg){
arg = {};
}
console.error("批量添加未实现");
}
/**
* 数据导出
*
* @param {*} data
* @memberof Main
*/
protected exportExcel(data: any = {}): void {
// 导出Excel
const doExport = async (_data:any) => {
const tHeader: Array<any> = [];
const filterVal: Array<any> = [];
this.allColumns.forEach((item: any) => {
item.show && item.label ? tHeader.push(item.label) : "";
item.show && item.name ? filterVal.push(item.name) : "";
});
const data = await this.formatExcelData(filterVal, _data);
this.$export.exportExcel().then((excel:any)=>{
excel.export_json_to_excel({
header: tHeader, //表头 必填
data, //具体数据 必填
filename: "主实体"+"表", //非必填
autoWidth: true, //非必填
bookType: "xlsx" //非必填
});
});
};
const page: any = {};
// 设置page,size
if (Object.is(data.type, 'maxRowCount')) {
Object.assign(page, { page: 0, size: data.maxRowCount });
} else if (Object.is(data.type, 'activatedPage')) {
try {
doExport(JSON.parse(JSON.stringify(this.items)));
} catch (error) {
console.error(error);
}
return;
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
const arg: any = {};
Object.assign(arg, page);
// 获取query,搜索表单,viewparams等父数据
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '数据导出失败,' + response.info });
return;
}
try {
doExport(JSON.parse(JSON.stringify(response.data)));
} catch (error) {
console.error(error);
}
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '', desc: '数据导出失败' });
});
}
/**
* 导出数据格式化
*
* @param {*} filterVal
* @param {*} jsonData
* @returns {[]}
* @memberof Main
*/
public async formatExcelData(filterVal:any, jsonData:any) {
let codelistColumns:Array<any> = [
];
let _this = this;
for (const codelist of codelistColumns) {
// 动态代码表处理
if (Object.is(codelist.codelistType, "DYNAMIC")) {
let items = await _this.codeListService.getItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
// 静态处理
} else if(Object.is(codelist.codelistType, "STATIC")){
let items = await _this.$store.getters.getCodeListItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
}
}
return jsonData.map((v:any) => filterVal.map((j:any) => v[j]))
}
/**
* 解析代码表和vlaue,设置items
*
* @private
* @param {any[]} items 代码表数据
* @param {*} value
* @returns {*}
* @memberof Main
*/
private getCodelistValue(items: any[], value: any, codelist: any,){
if(!value){
return this.$t('codelist.'+codelist.srfkey+'.empty');
}
if (items) {
let result:any = [];
if(Object.is(codelist.renderMode,"number")){
items.map((_item: any, index: number)=>{
const nValue = parseInt((value as any), 10);
const codevalue = _item.value;
if((parseInt(codevalue, 10) & nValue) > 0){
result.push(_item);
}
});
} else if(Object.is(codelist.renderMode,"string")){
const arrayValue: Array<any> = (value as any).split(codelist.valueSeparator);
arrayValue.map((value: any, index: number) => {
result.push([]);
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((val:any ,num: number)=>{
const item = this.getItem(items, val, codelist);
if(item){
result[index].push(item);
}
});
});
} else {
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((value:any ,index: number)=>{
const item = this.getItem(items, value, codelist);
if(item){
result.push(item);
}
});
}
// 设置items
if(result.length != 0){
return result.join(codelist.valueSeparator);
}else{
return value;
}
}
}
/**
* 获取代码项
*
* @private
* @param {any[]} items
* @param {*} value
* @returns {*}
* @memberof Main
*/
private getItem(items: any[], value: any, codelist: any): any {
const arr: Array<any> = items.filter(item => {return item.value == value});
if (arr.length !== 1) {
return undefined;
}
if(Object.is(codelist.codelistType,'STATIC')){
return this.$t('codelist.'+codelist.srfkey+'.'+arr[0].value);
}else{
return arr[0].text;
}
}
/**
* 生命周期
*
* @memberof Main
*/
protected created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof Main
*/
protected afterCreated(){
this.setColState();
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('save', action)) {
this.save(data);
}
});
}
}
/**
* vue 生命周期
*
* @memberof Main
*/
protected destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof Main
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
}
/**
* 获取选中行胡数据
*
* @returns {any[]}
* @memberof Main
*/
protected getSelection(): any[] {
return this.selections;
}
/**
* 行双击事件
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected rowDBLClick($event: any): void {
if (!$event || this.actualIsOpenEdit || Object.is(this.gridRowActiveMode,0)) {
return;
}
this.selections = [];
this.selections.push(JSON.parse(JSON.stringify($event)));
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
refs.multipleTable.toggleRowSelection($event);
}
this.$emit('rowdblclick', this.selections);
this.$emit('selectionchange', this.selections);
}
/**
* 复选框数据选中
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected select($event: any): void {
if (!$event) {
return;
}
this.selections = [];
this.selections = [...JSON.parse(JSON.stringify($event))];
this.$emit('selectionchange', this.selections);
}
/**
* 复选框数据全部选中
*
* @param {*} $event
* @memberof Main
*/
protected selectAll($event: any): void {
if (!$event) {
return;
}
this.selections = [];
this.selections = [...JSON.parse(JSON.stringify($event))];
this.$emit('selectionchange', this.selections);
}
/**
* 行单击选中
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected rowClick($event: any, ifAlways: boolean = false): void {
if (!ifAlways && (!$event || this.actualIsOpenEdit)) {
return;
}
if(this.stopRowClick) {
this.stopRowClick = false;
return;
}
if(this.isSingleSelect){
this.selections = [];
}
// 已选中则删除,没选中则添加
let selectIndex = this.selections.findIndex((item:any)=>{
return Object.is(item.ibzdict,$event.ibzdict);
});
if (Object.is(selectIndex,-1)){
this.selections.push(JSON.parse(JSON.stringify($event)));
} else {
this.selections.splice(selectIndex,1);
}
const refs: any = this.$refs;
if (refs.multipleTable) {
if(this.isSingleSelect){
refs.multipleTable.clearSelection();
refs.multipleTable.setCurrentRow($event);
}else{
refs.multipleTable.toggleRowSelection($event);
}
}
this.$emit('selectionchange', this.selections);
}
/**
* 页面变化
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected pageOnChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.curPage) {
return;
}
this.curPage = $event;
this.load({});
}
/**
* 分页条数变化
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected onPageSizeChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.limit) {
return;
}
this.limit = $event;
if (this.curPage === 1) {
this.load({});
}
}
/**
* 分页刷新
*
* @memberof Main
*/
protected pageRefresh(): void {
this.load({});
}
/**
* 排序变化
*
* @param {{ column: any, prop: any, order: any }} { column, prop, order }
* @memberof Main
*/
protected onSortChange({ column, prop, order }: { column: any, prop: any, order: any }): void {
const dir = Object.is(order, 'ascending') ? 'asc' : Object.is(order, 'descending') ? 'desc' : '';
if (Object.is(dir, this.minorSortDir) && Object.is(this.minorSortPSDEF, prop)) {
return;
}
this.minorSortDir = dir;
this.minorSortPSDEF = prop ? prop : '';
this.load({});
}
/**
* 表格行选中样式
*
* @param {{ row: any, rowIndex: any }} { row, rowIndex }
* @returns {string}
* @memberof Main
*/
protected onRowClassName({ row, rowIndex }: { row: any, rowIndex: any }): string {
const index = this.selections.findIndex((select: any) => Object.is(select.srfkey, row.srfkey));
return index !== -1 ? 'grid-row-select' : '';
}
/**
* 界面行为
*
* @param {*} row
* @param {*} tag
* @param {*} $event
* @memberof Main
*/
protected uiAction(row: any, tag: any, $event: any) {
this.rowClick(row, true);
}
/**
* 设置列状态
*
* @memberof Main
*/
protected setColState() {
const _data: any = localStorage.getItem('ibzdict_main_grid');
if (_data) {
let columns = JSON.parse(_data);
columns.forEach((col: any) => {
let column = this.allColumns.find((item) => Object.is(col.name, item.name));
if (column) {
Object.assign(column, col);
}
});
}
}
/**
* 列变化
*
* @memberof Main
*/
protected onColChange() {
localStorage.setItem('ibzdict_main_grid', JSON.stringify(this.allColumns));
}
/**
* 获取列状态
*
* @param {string} name
* @returns {boolean}
* @memberof Main
*/
protected getColumnState(name: string): boolean {
let column = this.allColumns.find((col: any) =>
Object.is(name, col.name)
);
return column.show ? true : false;
}
/**
* 表格列是否自适应布局
*
* @readonly
* @type {boolean}
* @memberof Main
*/
get adaptiveState(): boolean {
return !this.allColumns.find((column: any) => column.show && Object.is(column.util, 'STAR'));
}
/**
* 保存
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected save(args: any[], params?: any, $event?: any, xData?: any): void {
let _this = this;
let promises:any = [];
_this.items.forEach((item:any)=>{
if(!item.rowDataState){
return;
} else if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictGridView视图表格createAction参数未配置' });
return;
}
Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
}else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictGridView视图表格updateAction参数未配置' });
return;
}
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdict){
Object.assign(this.context,{ibzdict:item.ibzdict})
}
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
}
});
Promise.all(promises).then((response: any) => {
this.$emit('save', response);
}).catch((response: any) => {
this.$Notice.error({ title: '错误', desc: '系统异常' });
});
}
/**
* 获取对应行class
*
* @param {*} $args row 行数据,rowIndex 行索引
* @returns {void}
* @memberof Main
*/
protected getRowClassName(args:{row: any,rowIndex: number}){
let isSelected = this.selections.some((item:any)=>{
return Object.is(item.ibzdict,args.row.ibzdict);
});
return isSelected ? "grid-selected-row" : "";
}
}
</script>
<style lang='less'>
@import './main-grid.less';
</style>
\ No newline at end of file
......@@ -59,6 +59,11 @@ export default class MainModel {
prop: 'n_ibzdictname_like',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
{
name:'size',
......
!!!!模版产生代码错误:----
Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing</#if>. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
----
----
FTL stack trace ("~" means nesting-related):
- Failed at: ${appde.getKeyPSAppDEField().getCodeN... [in template "TEMPLCODE_zh_CN" at line 310, column 14]
----
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDictService from '@/service/ibzdict/ibzdict-service';
import MainModel from './main-grid-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 数据字典服务对象
*
* @type {IBZDictService}
* @memberof MainService
*/
public appEntityService: IBZDictService = new IBZDictService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Data,Context,isloading);
}else{
result =_appEntityService.Update(Data,Context,isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:0});
}
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public search(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.FetchDefault(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string, context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
//仿真主键数据
data.dictid = Util.createUUID();
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:'0'});
}
this.handleResponse(action, response);
this.mergeDefaults(response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 合并配置的默认值
* @param {*}
* @memberof MainService
*/
public mergeDefaults(response:any = {}){
if(response.data){
}
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
}
\ No newline at end of file
<template>
<i-form :model="this.data" class='app-search-form' ref='searchform' style="">
<input style="display:none;"/>
<row >
<i-col v-show="detailsModel.n_ibzdictitemname_like.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 12, offset: 0 }" :xl="{ span: 12, offset: 0 }">
<app-form-item name='n_ibzdictitemname_like' :itemRules="this.rules.n_ibzdictitemname_like" class='' :caption="$t('ibzdictitem.default_searchform.details.n_ibzdictitemname_like')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_ibzdictitemname_like.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.n_ibzdictitemname_like" @enter="onEnter($event)" :disabled="detailsModel.n_ibzdictitemname_like.disabled" type='text' style="width:100px;"></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.n_dictitemval_like.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 12, offset: 0 }" :xl="{ span: 12, offset: 0 }">
<app-form-item name='n_dictitemval_like' :itemRules="this.rules.n_dictitemval_like" class='' :caption="$t('ibzdictitem.default_searchform.details.n_dictitemval_like')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_dictitemval_like.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.n_dictitemval_like" @enter="onEnter($event)" :disabled="detailsModel.n_dictitemval_like.disabled" type='text' style="width:100px;"></input-box>
</app-form-item>
</i-col>
</row>
<row v-show="Object.keys(data).length>0">
<i-col :md="{ span: 4, offset: 20 }" :sm="{ span: 4, offset: 20 }" :lg="{ span: 4, offset: 20 }">
<i-button class='search_reset' size="default" type="primary" @click="onSearch">{{$t('app.searchButton.search')}}</i-button>
<i-button class='search_reset' size="default" @click="onReset">{{this.$t('app.searchButton.reset')}}</i-button>
</i-col>
</row>
</i-form>
</template>
<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import DefaultService from './default-searchform-service';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
components: {
}
})
export default class DefaultBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof Default
*/
@Prop() protected name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof Default
*/
@Prop() protected viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof Default
*/
@Prop() protected context: any;
/**
* 视图参数
*
* @type {*}
* @memberof Default
*/
@Prop() protected viewparams: any;
/**
* 视图状态事件
*
* @protected
* @type {(Subscription | undefined)}
* @memberof Default
*/
protected viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof Default
*/
protected getControlType(): string {
return 'SEARCHFORM'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof Default
*/
protected counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {DefaultService}
* @memberof Default
*/
protected service: DefaultService = new DefaultService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {IBZDICTITEMService}
* @memberof Default
*/
protected appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.$store });
/**
* 关闭视图
*
* @param {any[]} args
* @memberof Default
*/
protected closeView(args: any[]): void {
let _this: any = this;
_this.$emit('closeview', args);
}
/**
* 计数器刷新
*
* @memberof Default
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof Default
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof Default
*/
public getData(): any {
return this.data;
}
/**
* 是否默认保存
*
* @type {boolean}
* @memberof Default
*/
@Prop({ default: false }) protected autosave?: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof Default
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--update
*
* @type {string}
* @memberof Default
*/
@Prop() protected updateAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof Default
*/
@Prop() protected removeAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof Default
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof Default
*/
@Prop() protected loadAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Default
*/
@Prop() protected createAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Default
*/
@Prop() protected searchAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof Default
*/
@Prop() protected viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof Default
*/
protected formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof Default
*/
protected ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @private
* @type {Subject<any>}
* @memberof Default
*/
private dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @private
* @type {(Subscription | undefined)}
* @memberof Default
*/
private dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @private
* @type {*}
* @memberof Default
*/
private oldData: any = {};
/**
* 表单数据对象
*
* @type {*}
* @memberof Default
*/
protected data: any = {
n_ibzdictitemname_like: null,
n_dictitemval_like: null,
};
/**
* 属性值规则
*
* @type {*}
* @memberof Default
*/
protected rules: any = {
n_ibzdictitemname_like: [
{ type: 'string', message: '栏目显示值(文本包含(%)) 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目显示值(文本包含(%)) 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '栏目显示值(文本包含(%)) 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '栏目显示值(文本包含(%)) 值不能为空', trigger: 'blur' },
],
n_dictitemval_like: [
{ type: 'string', message: '栏目值(文本包含(%)) 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目值(文本包含(%)) 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '栏目值(文本包含(%)) 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '栏目值(文本包含(%)) 值不能为空', trigger: 'blur' },
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Default
*/
protected detailsModel: any = {
formpage1: new FormPageModel({ caption: '常规条件', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
,
n_ibzdictitemname_like: new FormItemModel({ caption: '栏目显示值(文本包含(%))', detailType: 'FORMITEM', name: 'n_ibzdictitemname_like', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
n_dictitemval_like: new FormItemModel({ caption: '栏目值(文本包含(%))', detailType: 'FORMITEM', name: 'n_dictitemval_like', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
};
/**
* 监控表单属性 n_ibzdictitemname_like 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Default
*/
@Watch('data.n_ibzdictitemname_like')
onN_ibzdictitemname_likeChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'n_ibzdictitemname_like', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 n_dictitemval_like 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Default
*/
@Watch('data.n_dictitemval_like')
onN_dictitemval_likeChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'n_dictitemval_like', newVal: newVal, oldVal: oldVal });
}
/**
* 重置表单项值
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof Default
*/
private resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单逻辑
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof Default
*/
private formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单值变化
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @returns {void}
* @memberof Default
*/
private formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (this.ignorefieldvaluechange) {
return;
}
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data));
}
/**
* 表单加载完成
*
* @private
* @param {*} [data={}]
* @memberof Default
*/
private onFormLoad(data: any = {}): void {
this.setFormEnableCond(data);
this.fillForm(data);
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @memberof Default
*/
protected fillForm(_datas: any = {}): void {
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = _datas[name];
}
});
this.$nextTick(function () {
this.ignorefieldvaluechange = false;
})
}
/**
* 设置表单项是否启用
*
* @protected
* @param {*} data
* @memberof Default
*/
protected setFormEnableCond(data: any): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setEnableCond(data.srfuf);
});
}
/**
* 重置草稿表单状态
*
* @private
* @memberof Default
*/
private resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof Default
*/
protected resetValidates(): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setError('');
});
}
/**
* 填充校验结果 (后台)
*
* @param {any[]} fieldErrors
* @memberof Default
*/
protected fillValidates(fieldErrors: any[]): void {
fieldErrors.forEach((error: any) => {
const formItem: FormItemModel = this.detailsModel[error.field];
if (!formItem) {
return;
}
this.$nextTick(() => {
formItem.setError(error.message);
});
});
}
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof Default
*/
protected formValidateStatus(): boolean {
const form: any = this.$refs.searchform;
let validatestate: boolean = true;
form.validate((valid: boolean) => {
validatestate = valid ? true : false;
});
return validatestate
}
/**
* 获取全部值
*
* @returns {*}
* @memberof Default
*/
protected getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof Default
*/
protected onFormItemValueChange($event: { name: string, value: any }): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
return;
}
this.data[$event.name] = $event.value;
}
/**
* 设置数据项值
*
* @param {string} name
* @param {*} value
* @returns {void}
* @memberof Default
*/
protected setDataItemValue(name: string, value: any): void {
if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
return;
}
if (Object.is(this.data[name], value)) {
return;
}
this.data[name] = value;
}
/**
* 分组界面行为事件
*
* @param {*} $event
* @memberof Default
*/
protected groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof Default
*/
protected created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof Default
*/
protected afterCreated(){
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('autoload', action)) {
this.autoLoad(data);
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('loaddraft', action)) {
this.loadDraft(data);
}
if (Object.is('save', action)) {
this.save(data);
}
});
}
this.dataChang
.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe((data: any) => {
if (this.autosave) {
this.autoSave();
}
});
}
/**
* vue 生命周期
*
* @memberof Default
*/
protected destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof Default
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
}
/**
* 拷贝内容
*
* @param {*} [arg={}]
* @memberof @memberof Default
*/
protected copy(arg: any = {}): void {
this.loadDraft(arg);
}
/**
* 部件刷新
*
* @param {any[]} args
* @memberof Default
*/
protected refresh(args: any[]): void {
let arg: any = {};
if (this.data.srfkey && !Object.is(this.data.srfkey, '')) {
Object.assign(arg, { srfkey: this.data.srfkey });
this.load(arg);
return;
}
if (this.data.srfkeys && !Object.is(this.data.srfkeys, '')) {
Object.assign(arg, { srfkey: this.data.srfkeys });
this.load(arg);
return;
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof Default
*/
protected autoLoad(arg: any = {}): void {
if (arg.srfkey && !Object.is(arg.srfkey, '')) {
Object.assign(arg, { srfkey: arg.srfkey });
this.load(arg);
return;
}
if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
Object.assign(arg, { srfkey: arg.srfkeys });
this.load(arg);
return;
}
this.loadDraft(arg);
}
/**
* 加载
*
* @private
* @param {*} [opt={}]
* @memberof Default
*/
private load(opt: any = {}): void {
if(!this.loadAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图搜索表单loadAction参数未配置' });
return;
}
const arg: any = { ...opt };
Object.assign(arg,{viewparams:this.viewparams});
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
get.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
this.onFormLoad(data);
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 加载草稿
*
* @param {*} [opt={}]
* @memberof Default
*/
protected loadDraft(opt: any = {}): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图搜索表单loaddraftAction参数未配置' });
return;
}
const arg: any = { ...opt } ;
Object.assign(arg,{viewparams:this.viewparams});
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
this.resetDraftFormStates();
this.onFormLoad(data);
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
const { data: _data } = response;
this.$Notice.error({ title: _data.title, desc: _data.message });
});
}
/**
* 自动保存
*
* @param {*} [opt={}]
* @memberof Default
*/
protected autoSave(opt: any = {}): void {
if (!this.formValidateStatus()) {
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.add(action,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
this.onFormLoad(data);
this.$emit('save', data);
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
});
}
/**
* 保存
*
* @param {*} [opt={}]
* @param {boolean} [showResultInfo]
* @returns {Promise<any>}
* @memberof Default
*/
protected async save(opt: any = {}, showResultInfo?: boolean): Promise<any> {
showResultInfo = showResultInfo === undefined ? true : false;
if (!this.formValidateStatus()) {
this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
this.onFormLoad(data);
this.$emit('save', data);
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;保存成功!' });
}
resolve(response);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
})
}
/**
* 表单项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof Default
*/
protected updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
}
/**
* 回车事件
*
* @param {*} $event
* @memberof Default
*/
protected onEnter($event: any): void {
this.$emit('load', this.data);
}
/**
* 搜索
*
* @memberof Default
*/
protected onSearch() {
this.$emit('load', this.data);
}
/**
* 重置
*
* @memberof Default
*/
protected onReset() {
this.loadDraft();
}
}
</script>
<style lang='less'>
@import './default-searchform.less';
</style>
\ No newline at end of file
/**
* Default 部件模型
*
* @export
* @class DefaultModel
*/
export default class DefaultModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof DefaultModel
*/
public getDataItems(): any[] {
return [
{
name: 'srfwfmemo',
prop: 'srfwfmemo',
dataType: 'TEXT',
},
{
name: 'n_ibzdictitemname_like',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'n_dictitemval_like',
prop: 'itemval',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import DefaultModel from './default-searchform-model';
/**
* Default 部件服务对象
*
* @export
* @class DefaultService
*/
export default class DefaultService extends ControlService {
/**
* 字典项目服务对象
*
* @type {IBZDICTITEMService}
* @memberof DefaultService
*/
public appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof DefaultService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of DefaultService.
*
* @param {*} [opts={}]
* @memberof DefaultService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new DefaultModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof DefaultService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof DefaultService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
Data.itemid = Util.createUUID();
Data.ibzdictitem = Data.itemid;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof DefaultService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof DefaultService
*/
public handleRequestData(action: string,context:any, data: any = {}){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}
}
});
if(data && data.viewparams){
Object.assign(requestData,data.viewparams);
}
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
}
\ No newline at end of file
.ivu-tabs-no-animation>.ivu-tabs-content{
padding: 0 16px;
}
.ivu-card-head{
padding: 14px 0;
}
.app-search-form {
padding: 0 14px;
.search_reset {
margin-right: 12px;
}
}
.app-search-form-flex {
height: 100%;
> .ivu-row {
height: 100%;
> .ivu-tabs {
height: 100%;
display: flex;
flex-direction: column;
> .ivu-tabs-content {
flex-grow: 1;
overflow: auto;
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
}
}
.app-tabpanel-flex {
height: 100%;
> .ivu-tabs-content {
height: calc(100% - 52px);
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
// this is less
<script lang='ts'>
import { Component } from 'vue-property-decorator';
import DefaultBase from './default-searchform-base.vue';
@Component({
components: {
}
})
export default class Default extends DefaultBase {
}
</script>
\ No newline at end of file
<template>
<i-form :model="this.data" class='app-form' ref='form' id='form' style="">
<input style="display:none;" />
<row >
<i-col v-show="detailsModel.group1.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-group layoutType="TABLE_24COL" titleStyle="" class='' uiActionGroup="detailsModel.group1.uiActionGroup" @groupuiactionclick="groupUIActionClick($event)" :caption="$t('ibzdictitem.main_form.details.group1')" :isShowCaption="false" uiStyle="DEFAULT" :titleBarCloseMode="0" :isInfoGroupMode="false">
<row>
<i-col v-show="detailsModel.ibzdictitemname.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='ibzdictitemname' :itemRules="this.rules.ibzdictitemname" class='' :caption="$t('ibzdictitem.main_form.details.ibzdictitemname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.ibzdictitemname.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.ibzdictitemname" @enter="onEnter($event)" unit="" :disabled="detailsModel.ibzdictitemname.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.dictitemval.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='dictitemval' :itemRules="this.rules.dictitemval" class='' :caption="$t('ibzdictitem.main_form.details.dictitemval')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.dictitemval.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.dictitemval" @enter="onEnter($event)" unit="" :disabled="detailsModel.dictitemval.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.pitemval.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='pitemval' :itemRules="this.rules.pitemval" class='' :caption="$t('ibzdictitem.main_form.details.pitemval')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.pitemval.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.pitemval" @enter="onEnter($event)" unit="" :disabled="detailsModel.pitemval.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.itemfilter.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='itemfilter' :itemRules="this.rules.itemfilter" class='' :caption="$t('ibzdictitem.main_form.details.itemfilter')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.itemfilter.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.itemfilter" @enter="onEnter($event)" unit="" :disabled="detailsModel.itemfilter.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.itemcls.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='itemcls' :itemRules="this.rules.itemcls" class='' :caption="$t('ibzdictitem.main_form.details.itemcls')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.itemcls.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.itemcls" @enter="onEnter($event)" unit="" :disabled="detailsModel.itemcls.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.itemicon.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='itemicon' :itemRules="this.rules.itemicon" class='' :caption="$t('ibzdictitem.main_form.details.itemicon')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.itemicon.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.itemicon" @enter="onEnter($event)" unit="" :disabled="detailsModel.itemicon.disabled" type='text' style=""></input-box>
</app-form-item>
</i-col>
<i-col v-show="detailsModel.showorder.visible" :style="{}" :md="{ span: 12, offset: 0 }" :lg="{ span: 8, offset: 0 }" :xl="{ span: 6, offset: 0 }">
<app-form-item name='showorder' :itemRules="this.rules.showorder" class='' :caption="$t('ibzdictitem.main_form.details.showorder')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.showorder.error" :isEmptyCaption="false" labelPos="LEFT">
<input-box v-model="data.showorder" @enter="onEnter($event)" unit="" :disabled="detailsModel.showorder.disabled" type='number' style=""></input-box>
</app-form-item>
</i-col>
</row>
</app-form-group>
</i-col>
</row>
</i-form>
</template>
<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import MainService from './main-form-service';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
components: {
}
})
export default class MainBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof Main
*/
@Prop() protected name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof Main
*/
@Prop() protected viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof Main
*/
@Prop() protected context: any;
/**
* 视图参数
*
* @type {*}
* @memberof Main
*/
@Prop() protected viewparams: any;
/**
* 视图状态事件
*
* @protected
* @type {(Subscription | undefined)}
* @memberof Main
*/
protected viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof Main
*/
protected getControlType(): string {
return 'FORM'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof Main
*/
protected counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {MainService}
* @memberof Main
*/
protected service: MainService = new MainService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {IBZDICTITEMService}
* @memberof Main
*/
protected appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.$store });
/**
* 关闭视图
*
* @param {any[]} args
* @memberof Main
*/
protected closeView(args: any[]): void {
let _this: any = this;
_this.$emit('closeview', args);
}
/**
* 计数器刷新
*
* @memberof Main
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof Main
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof Main
*/
public getData(): any {
return this.data;
}
/**
* 是否默认保存
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: false }) protected autosave?: boolean;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--submit
*
* @type {string}
* @memberof Main
*/
@Prop() protected WFSubmitAction!: string;
/**
* 部件行为--start
*
* @type {string}
* @memberof Main
*/
@Prop() protected WFStartAction!: string;
/**
* 部件行为--update
*
* @type {string}
* @memberof Main
*/
@Prop() protected updateAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof Main
*/
@Prop() protected removeAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof Main
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof Main
*/
@Prop() protected loadAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Main
*/
@Prop() protected createAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Main
*/
@Prop() protected searchAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof Main
*/
@Prop() protected viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof Main
*/
protected formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof Main
*/
protected ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @private
* @type {Subject<any>}
* @memberof Main
*/
private dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @private
* @type {(Subscription | undefined)}
* @memberof Main
*/
private dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @private
* @type {*}
* @memberof Main
*/
private oldData: any = {};
/**
* 表单数据对象
*
* @type {*}
* @memberof Main
*/
protected data: any = {
srfupdatedate: null,
srforikey: null,
srfkey: null,
srfmajortext: null,
srftempmode: null,
srfuf: null,
srfdeid: null,
srfsourcekey: null,
dictid: null,
ibzdictitemname: null,
dictitemval: null,
pitemval: null,
itemfilter: null,
itemcls: null,
itemicon: null,
showorder: null,
ibzdictitemid: null,
ibzdictitem:null,
};
/**
* 当前执行的行为逻辑
*
* @type {string}
* @memberof Main
*/
protected currentAction: string = "";
/**
* 关系界面计数器
*
* @type {number}
* @memberof Main
*/
protected drcounter: number = 0;
/**
* 表单保存回调存储对象
*
* @type {any}
* @memberof Main
*/
protected saveState:any ;
/**
* 属性值规则
*
* @type {*}
* @memberof Main
*/
protected rules: any = {
srfupdatedate: [
{ type: 'string', message: '更新时间 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '更新时间 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '更新时间 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '更新时间 值不能为空', trigger: 'blur' },
],
srforikey: [
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
],
srfkey: [
{ type: 'string', message: '字典项目标识 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '字典项目标识 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '字典项目标识 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '字典项目标识 值不能为空', trigger: 'blur' },
],
srfmajortext: [
{ type: 'string', message: '栏目显示值 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目显示值 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '栏目显示值 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '栏目显示值 值不能为空', trigger: 'blur' },
],
srftempmode: [
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
],
srfuf: [
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
],
srfdeid: [
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
],
srfsourcekey: [
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: ' 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: ' 值不能为空', trigger: 'blur' },
],
dictid: [
{ type: 'string', message: '字典标识 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '字典标识 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '字典标识 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '字典标识 值不能为空', trigger: 'blur' },
],
ibzdictitemname: [
{ type: 'string', message: '栏目显示值 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目显示值 值必须为字符串类型', trigger: 'blur' },
{ required: true, type: 'string', message: '栏目显示值 值不能为空', trigger: 'change' },
{ required: true, type: 'string', message: '栏目显示值 值不能为空', trigger: 'blur' },
],
dictitemval: [
{ type: 'string', message: '栏目值 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目值 值必须为字符串类型', trigger: 'blur' },
{ required: true, type: 'string', message: '栏目值 值不能为空', trigger: 'change' },
{ required: true, type: 'string', message: '栏目值 值不能为空', trigger: 'blur' },
],
pitemval: [
{ type: 'string', message: '父栏目值 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '父栏目值 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '父栏目值 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '父栏目值 值不能为空', trigger: 'blur' },
],
itemfilter: [
{ type: 'string', message: '过滤项 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '过滤项 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '过滤项 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '过滤项 值不能为空', trigger: 'blur' },
],
itemcls: [
{ type: 'string', message: '栏目样式 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '栏目样式 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '栏目样式 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '栏目样式 值不能为空', trigger: 'blur' },
],
itemicon: [
{ type: 'string', message: '图标 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '图标 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '图标 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '图标 值不能为空', trigger: 'blur' },
],
showorder: [
{ type: 'number', message: '排序 值必须为数值类型', trigger: 'change' },
{ type: 'number', message: '排序 值必须为数值类型', trigger: 'blur' },
{ required: false, type: 'number', message: '排序 值不能为空', trigger: 'change' },
{ required: false, type: 'number', message: '排序 值不能为空', trigger: 'blur' },
],
ibzdictitemid: [
{ type: 'string', message: '字典项目标识 值必须为字符串类型', trigger: 'change' },
{ type: 'string', message: '字典项目标识 值必须为字符串类型', trigger: 'blur' },
{ required: false, type: 'string', message: '字典项目标识 值不能为空', trigger: 'change' },
{ required: false, type: 'string', message: '字典项目标识 值不能为空', trigger: 'blur' },
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Main
*/
protected detailsModel: any = {
group1: new FormGroupPanelModel({ caption: '字典项目基本信息', detailType: 'GROUPPANEL', name: 'group1', visible: true, isShowCaption: false, form: this, uiActionGroup: { caption: '', langbase: 'ibzdictitem.main_form', extractMode: 'ITEM', details: [] } })
,
formpage1: new FormPageModel({ caption: '基本信息', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
,
srfupdatedate: new FormItemModel({ caption: '更新时间', detailType: 'FORMITEM', name: 'srfupdatedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfkey: new FormItemModel({ caption: '字典项目标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfmajortext: new FormItemModel({ caption: '栏目显示值', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
dictid: new FormItemModel({ caption: '字典标识', detailType: 'FORMITEM', name: 'dictid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
ibzdictitemname: new FormItemModel({ caption: '栏目显示值', detailType: 'FORMITEM', name: 'ibzdictitemname', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
dictitemval: new FormItemModel({ caption: '栏目值', detailType: 'FORMITEM', name: 'dictitemval', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
pitemval: new FormItemModel({ caption: '父栏目值', detailType: 'FORMITEM', name: 'pitemval', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
itemfilter: new FormItemModel({ caption: '过滤项', detailType: 'FORMITEM', name: 'itemfilter', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
itemcls: new FormItemModel({ caption: '栏目样式', detailType: 'FORMITEM', name: 'itemcls', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
itemicon: new FormItemModel({ caption: '图标', detailType: 'FORMITEM', name: 'itemicon', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
showorder: new FormItemModel({ caption: '排序', detailType: 'FORMITEM', name: 'showorder', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
ibzdictitemid: new FormItemModel({ caption: '字典项目标识', detailType: 'FORMITEM', name: 'ibzdictitemid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
};
/**
* 监控表单属性 srfupdatedate 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfupdatedate')
onSrfupdatedateChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfupdatedate', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srforikey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srforikey')
onSrforikeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srforikey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfkey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfkey')
onSrfkeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfkey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfmajortext 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfmajortext')
onSrfmajortextChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfmajortext', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srftempmode 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srftempmode')
onSrftempmodeChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srftempmode', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfuf 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfuf')
onSrfufChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfuf', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfdeid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfdeid')
onSrfdeidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfdeid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 srfsourcekey 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.srfsourcekey')
onSrfsourcekeyChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'srfsourcekey', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 dictid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.dictid')
onDictidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'dictid', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 ibzdictitemname 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.ibzdictitemname')
onIbzdictitemnameChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'ibzdictitemname', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 dictitemval 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.dictitemval')
onDictitemvalChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'dictitemval', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 pitemval 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.pitemval')
onPitemvalChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'pitemval', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 itemfilter 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.itemfilter')
onItemfilterChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'itemfilter', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 itemcls 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.itemcls')
onItemclsChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'itemcls', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 itemicon 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.itemicon')
onItemiconChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'itemicon', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 showorder 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.showorder')
onShoworderChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'showorder', newVal: newVal, oldVal: oldVal });
}
/**
* 监控表单属性 ibzdictitemid 值
*
* @param {*} newVal
* @param {*} oldVal
* @memberof Main
*/
@Watch('data.ibzdictitemid')
onIbzdictitemidChange(newVal: any, oldVal: any) {
this.formDataChange({ name: 'ibzdictitemid', newVal: newVal, oldVal: oldVal });
}
/**
* 重置表单项值
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof Main
*/
private resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 置空对象
*
* @param {any[]} args
* @memberof EditForm
*/
protected ResetData(_datas:any){
if(Object.keys(_datas).length >0){
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = null;
}
});
}
}
/**
* 表单逻辑
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof Main
*/
private formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单值变化
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @returns {void}
* @memberof Main
*/
private formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
if (this.ignorefieldvaluechange) {
return;
}
this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
this.dataChang.next(JSON.stringify(this.data));
}
/**
* 表单加载完成
*
* @private
* @param {*} [data={}]
* @param {string} [action]
* @memberof Main
*/
private onFormLoad(data: any = {},action:string): void {
if(Object.is(action,"save") || Object.is(action,"autoSave"))
// 更新context的实体主键
if(data.ibzdictitem){
Object.assign(this.context,{ibzdictitem:data.ibzdictitem})
}
this.setFormEnableCond(data);
this.fillForm(data,action);
this.oldData = {};
Object.assign(this.oldData, JSON.parse(JSON.stringify(this.data)));
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: false });
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @param {string} [action]
* @memberof Main
*/
protected fillForm(_datas: any = {},action:string): void {
this.ignorefieldvaluechange = true;
Object.keys(_datas).forEach((name: string) => {
if (this.data.hasOwnProperty(name)) {
this.data[name] = _datas[name];
}
});
if(Object.is(action,'loadDraft')){
this.createDefault();
}
this.$nextTick(function () {
this.ignorefieldvaluechange = false;
})
}
/**
* 设置表单项是否启用
*
* @protected
* @param {*} data
* @memberof Main
*/
protected setFormEnableCond(data: any): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setEnableCond(data.srfuf);
});
}
/**
* 重置草稿表单状态
*
* @private
* @memberof Main
*/
private resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof Main
*/
protected resetValidates(): void {
Object.values(this.detailsModel).forEach((detail: any) => {
if (!Object.is(detail.detailType, 'FORMITEM')) {
return;
}
const formItem: FormItemModel = detail;
formItem.setError('');
});
}
/**
* 填充校验结果 (后台)
*
* @param {any[]} fieldErrors
* @memberof Main
*/
protected fillValidates(fieldErrors: any[]): void {
fieldErrors.forEach((error: any) => {
const formItem: FormItemModel = this.detailsModel[error.field];
if (!formItem) {
return;
}
this.$nextTick(() => {
formItem.setError(error.message);
});
});
}
/**
* 表单校验状态
*
* @returns {boolean}
* @memberof Main
*/
protected formValidateStatus(): boolean {
const form: any = this.$refs.form;
let validatestate: boolean = true;
form.validate((valid: boolean) => {
validatestate = valid ? true : false;
});
return validatestate
}
/**
* 获取全部值
*
* @returns {*}
* @memberof Main
*/
protected getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof Main
*/
protected onFormItemValueChange($event: { name: string, value: any }): void {
if (!$event) {
return;
}
if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
return;
}
this.data[$event.name] = $event.value;
}
/**
* 设置数据项值
*
* @param {string} name
* @param {*} value
* @returns {void}
* @memberof Main
*/
protected setDataItemValue(name: string, value: any): void {
if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
return;
}
if (Object.is(this.data[name], value)) {
return;
}
this.data[name] = value;
}
/**
* 分组界面行为事件
*
* @param {*} $event
* @memberof Main
*/
protected groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof Main
*/
protected created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof Main
*/
protected afterCreated(){
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('autoload', action)) {
this.autoLoad(data);
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('loaddraft', action)) {
this.loadDraft(data);
}
if (Object.is('save', action)) {
this.save(data,data.showResultInfo);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('saveandexit', action)) {
this.saveAndExit(data);
}
if (Object.is('saveandnew', action)) {
this.saveAndNew(data);
}
if (Object.is('removeandexit', action)) {
this.removeAndExit(data);
}
if (Object.is('refresh', action)) {
this.refresh(data);
}
});
}
this.dataChang
.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe((data: any) => {
if (this.autosave) {
this.autoSave();
}
const state = !Object.is(JSON.stringify(this.oldData), JSON.stringify(this.data)) ? true : false;
this.$store.commit('viewaction/setViewDataChange', { viewtag: this.viewtag, viewdatachange: state });
});
}
/**
* vue 生命周期
*
* @memberof Main
*/
protected destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof Main
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
}
/**
* 拷贝内容
*
* @param {*} [arg={}]
* @memberof @memberof Main
*/
protected copy(arg: any = {}): void {
this.loadDraft(arg);
}
/**
*打印
*@memberof @memberof Main
*/
protected print(){
let _this:any = this;
_this.$print({id:'form',popTitle:'主编辑表单'});
}
/**
* 部件刷新
*
* @param {any[]} args
* @memberof Main
*/
protected refresh(args: any[]): void {
let arg: any = {};
Object.assign(arg,args[0]);
if (this.data.srfkey && !Object.is(this.data.srfkey, '')) {
Object.assign(arg, { srfkey: this.data.srfkey });
this.load(arg);
return;
}
if (this.data.srfkeys && !Object.is(this.data.srfkeys, '')) {
Object.assign(arg, { srfkey: this.data.srfkeys });
this.load(arg);
return;
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof Main
*/
protected autoLoad(arg: any = {}): void {
if (arg.srfkey && !Object.is(arg.srfkey, '')) {
Object.assign(arg, { srfkey: arg.srfkey });
this.load(arg);
return;
}
if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
Object.assign(arg, { srfkey: arg.srfkeys });
this.load(arg);
return;
}
this.loadDraft(arg);
}
/**
* 加载
*
* @private
* @param {*} [opt={}]
* @memberof Main
*/
private load(opt: any = {}): void {
if(!this.loadAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单loadAction参数未配置' });
return;
}
const arg: any = { ...opt };
let viewparamResult:any = Object.assign(arg,this.viewparams);
const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
get.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
this.onFormLoad(data,'load');
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
}
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
});
}
/**
* 加载草稿
*
* @param {*} [opt={}]
* @memberof Main
*/
protected loadDraft(opt: any = {}): void {
if(!this.loaddraftAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单loaddraftAction参数未配置' });
return;
}
const arg: any = { ...opt } ;
let viewparamResult:any = Object.assign(arg,this.viewparams);
let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)),{viewparams:viewparamResult}, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
if(data.ibzdictitem){
Object.assign(this.context,{ibzdictitem:data.ibzdictitem})
}
this.resetDraftFormStates();
this.onFormLoad(data,'loadDraft');
this.$emit('load', data);
this.$nextTick(() => {
this.formState.next({ type: 'load', data: data });
});
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
});
}
/**
* 自动保存
*
* @param {*} [opt={}]
* @memberof Main
*/
protected autoSave(opt: any = {}): void {
if (!this.formValidateStatus()) {
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单'+actionName+'参数未配置' });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.add(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
this.onFormLoad(data,'autoSave');
this.$emit('save', data);
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
});
}
/**
* 保存
*
* @param {*} [opt={}]
* @param {boolean} [showResultInfo]
* @param {boolean} [ifStateNext] formState是否下发通知
* @returns {Promise<any>}
* @memberof Main
*/
protected async save(opt: any = {}, showResultInfo?: boolean, ifStateNext: boolean = true): Promise<any> {
return new Promise((resolve: any, reject: any) => {
showResultInfo = showResultInfo === undefined ? true : false;
opt.saveEmit = opt.saveEmit === undefined ? true :false;
if (!this.formValidateStatus()) {
this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
return;
}
const arg: any = { ...opt };
const data = this.getValues();
Object.assign(arg, data);
Object.assign(arg, this.context);
if (ifStateNext) {
this.drcounter = 0;
if(this.drcounter !== 0){
this.formState.next({ type: 'beforesave', data: arg });//先通知关系界面保存
this.saveState = resolve;
return;
}
}
const action: any = Object.is(data.srfuf, '1') ? this.updateAction : this.createAction;
if(!action){
let actionName:any = Object.is(data.srfuf, '1')?"updateAction":"createAction";
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单'+actionName+'参数未配置' });
return;
}
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = Object.is(data.srfuf, '1')?this.service.update(action, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(action,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data = response.data;
this.onFormLoad(data,'save');
if(!opt.saveEmit){
this.$emit('save', data);
}
this.$store.dispatch('viewaction/datasaved', { viewtag: this.viewtag });
this.$nextTick(() => {
this.formState.next({ type: 'save', data: data });
});
if (showResultInfo) {
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;保存成功!' });
}
resolve(response);
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
})
}
/**
* 删除
*
* @private
* @param {*} [opt={}]
* @memberof EditForm
*/
private remove(opt:Array<any> = [],showResultInfo?: boolean): Promise<any> {
return new Promise((resolve: any, reject: any) => {
if(!this.removeAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单removeAction参数未配置' });
return;
}
const arg: any = opt[0];
const _this: any = this;
Object.assign(arg,{viewparams:this.viewparams});
this.service.delete(_this.removeAction, JSON.parse(JSON.stringify(this.context)),arg, showResultInfo).then((response: any) => {
if (response) {
const data = response.data;
this.$emit('remove',data);
this.formState.next({ type: 'remove', data: data });
this.data.ismodify = false;
this.$Notice.success({ title: '', desc: (data.srfmajortext ? data.srfmajortext : '') + '&nbsp;删除成功!' });
resolve(response);
}
}).catch((error: any) => {
const { data: _data } = error;
this.$Notice.error({ title: _data.title, desc: _data.message });
reject(error);
});
});
}
/**
* 工作流启动
*
* @param {*} [data={}]
* @returns {Promise<any>}
* @memberof Main
*/
protected async wfstart(data: any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
if(!this.WFStartAction){
this.$Notice.error({ title: '错误', desc: 'WFCIDEditView视图表单WFStartAction参数未配置' });
return;
}
const _this: any = this;
const arg: any = data[0];
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = Object.is(data.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response:any) =>{
const arg:any = response.data;
if(this.viewparams){
Object.assign(arg,{viewparams:this.viewparams});
}
const result: Promise<any> = this.service.wfstart(_this.WFStartAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
result.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '工作流启动失败, ' + response.info });
return;
}
this.$Notice.info({ title: '', desc: '工作流启动成功' });
resolve(response);
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
})
});
}
/**
* 工作流提交
*
* @param {*} [data={}]
* @returns {Promise<any>}
* @memberof Main
*/
protected async wfsubmit(data: any): Promise<any> {
return new Promise((resolve: any, reject: any) => {
if(!this.WFSubmitAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemEditView视图表单WFSubmitAction参数未配置' });
return;
}
const _this: any = this;
const arg: any = data[0];
Object.assign(arg,{viewparams:this.viewparams});
if (!arg.ibzdictitem || Object.is(arg.ibzdictitem, '')) {
return;
}
const post: Promise<any> = Object.is(arg.srfuf, '1')?this.service.update(this.updateAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator):this.service.add(this.createAction,JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
post.then((response:any) =>{
const arg:any = response.data;
if(this.viewparams){
Object.assign(arg,{viewparams:this.viewparams});
}
const result: Promise<any> = this.service.wfsubmit(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg, this.showBusyIndicator);
result.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '工作流提交失败, ' + response.info });
return;
}
this.$Notice.info({ title: '', desc: '工作流提交成功' });
resolve(response);
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
reject(response);
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
})
})
}
/**
* 表单项更新
*
* @param {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof Main
*/
protected updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
if (!mode || (mode && Object.is(mode, ''))) {
return;
}
const arg: any = { ...data };
Object.assign(arg,this.viewparams);
const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(this.context)),arg, showloading);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '错误', desc: '表单项更新失败' });
return;
}
const data = response.data;
const _data: any = {};
updateDetails.forEach((name: string) => {
if (!data.hasOwnProperty(name)) {
return;
}
Object.assign(_data, { [name]: data[name] });
});
this.setFormEnableCond(_data);
this.fillForm(_data,'updateFormItem');
this.formLogic({ name: '', newVal: null, oldVal: null });
this.dataChang.next(JSON.stringify(this.data));
this.$nextTick(() => {
this.formState.next({ type: 'updateformitem', ufimode: arg.srfufimode, data: _data });
});
}).catch((response: any) => {
if (response && response.status) {
this.$Notice.error({ title: '错误', desc: response.message });
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
return;
}
});
}
/**
* 回车事件
*
* @param {*} $event
* @memberof Main
*/
protected onEnter($event: any): void {
}
/**
* 保存并退出
*
* @param {any[]} args
* @memberof Main
*/
protected saveAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndExit";
_this.save([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 保存并新建
*
* @param {any[]} args
* @memberof Main
*/
protected saveAndNew(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.currentAction = "saveAndNew";
_this.save([arg]).then((res) =>{
_this.ResetData(res);
_this.loadDraft({});
}).catch((error) =>{
reject(error);
})
})
}
/**
* 删除并退出
*
* @param {any[]} args
* @memberof Main
*/
protected removeAndExit(data:any[]):Promise<any>{
let _this = this;
return new Promise((resolve: any, reject: any) =>{
let arg: any = {};
if(data && data.length > 0){
Object.assign(arg,data[0]);
}
_this.remove([arg]).then((res) =>{
if(res){
_this.closeView(res.data);
}
resolve(res);
}).catch((error) =>{
reject(error);
})
})
}
/**
* 关系界面数据保存完成
*
* @param {any} $event
* @memberof Main
*/
protected drdatasaved($event:any){
let _this = this;
this.drcounter--;
if(this.drcounter > 0){
return;
}
this.save({}, undefined, false).then((res) =>{
this.saveState(res);
if(Object.is(_this.currentAction, "saveAndNew")){
_this.ResetData(res);
_this.loadDraft({});
}else if(Object.is(_this.currentAction, "saveAndExit")){
if(res){
_this.closeView(res.data);
}
}
});
}
/**
* 新建默认值
* @memberof Main
*/
public createDefault(){
}
}
</script>
<style lang='less'>
@import './main-form.less';
</style>
\ No newline at end of file
/**
* Main 部件模型
*
* @export
* @class MainModel
*/
export default class MainModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof MainModel
*/
public getDataItems(): any[] {
return [
{
name: 'srfwfmemo',
prop: 'srfwfmemo',
dataType: 'TEXT',
},
{
name: 'srfupdatedate',
prop: 'updatedate',
dataType: 'DATETIME',
},
{
name: 'srforikey',
},
{
name: 'srfkey',
prop: 'itemid',
dataType: 'GUID',
},
{
name: 'srfmajortext',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'srftempmode',
},
{
name: 'srfuf',
},
{
name: 'srfdeid',
},
{
name: 'srfsourcekey',
},
{
name: 'dictid',
prop: 'dictid',
dataType: 'PICKUP',
},
{
name: 'ibzdictitemname',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'dictitemval',
prop: 'itemval',
dataType: 'TEXT',
},
{
name: 'pitemval',
prop: 'pitemval',
dataType: 'TEXT',
},
{
name: 'itemfilter',
prop: 'itemfilter',
dataType: 'TEXT',
},
{
name: 'itemcls',
prop: 'itemcls',
dataType: 'TEXT',
},
{
name: 'itemicon',
prop: 'itemicon',
dataType: 'TEXT',
},
{
name: 'showorder',
prop: 'showorder',
dataType: 'INT',
},
{
name: 'ibzdictitemid',
prop: 'itemid',
dataType: 'GUID',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
{
name: 'ibzdictitem',
prop: 'itemid',
dataType: 'FONTKEY',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import MainModel from './main-form-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 字典项目服务对象
*
* @type {IBZDICTITEMService}
* @memberof MainService
*/
public appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 启动工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfstart(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 提交工作流
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public wfsubmit(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
data = this.handleWFData(data,true);
context = this.handleRequestData(action,context,data).context;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](context,data, isloading);
} else {
result = this.appEntityService.Create(context,data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Update(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
//仿真主键数据
Data.itemid = Util.createUUID();
Data.ibzdictitem = Data.itemid;
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response, true);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response,true);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
/**
* 处理请求数据
*
* @param action 行为
* @param data 数据
* @memberof MainService
*/
public handleRequestData(action: string,context:any, data: any = {}){
let mode: any = this.getMode();
if (!mode && mode.getDataItems instanceof Function) {
return data;
}
let formItemItems: any[] = mode.getDataItems();
let requestData:any = {};
formItemItems.forEach((item:any) =>{
if(item && item.dataType && Object.is(item.dataType,'FONTKEY')){
if(item && item.prop){
requestData[item.prop] = context[item.name];
}
}else{
if(item && item.prop){
requestData[item.prop] = data[item.name];
}
}
});
if(data && data.viewparams){
Object.assign(requestData,data.viewparams);
}
let tempContext:any = JSON.parse(JSON.stringify(context));
if(tempContext && tempContext.srfsessionid){
tempContext.srfsessionkey = tempContext.srfsessionid;
delete tempContext.srfsessionid;
}
return {context:tempContext,data:requestData};
}
}
\ No newline at end of file
.ivu-tabs-no-animation>.ivu-tabs-content{
padding: 0 16px;
}
.ivu-card-head{
padding: 14px 0;
}
.app-form {
overflow: auto;
> .ivu-row {
> .ivu-tabs {
height: 100%;
display: flex;
flex-direction: column;
> .ivu-tabs-content {
flex-grow: 1;
overflow: auto;
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
}
}
.app-tabpanel-flex {
height: 100%;
> .ivu-tabs-content {
height: calc(100% - 52px);
> .ivu-tabs-tabpane {
height: 100%;
}
}
}
.app-form {
>.ivu-row:nth-child(2) {
>.ivu-col:nth-child(1) {
>.ivu-row.app-form-group.app-group-hiddden-caption:nth-child(1) {
margin-top: 12px;
}
}
}
}
// this is less
<script lang='ts'>
import { Component } from 'vue-property-decorator';
import MainBase from './main-form-base.vue';
@Component({
components: {
}
})
export default class Main extends MainBase {
}
</script>
\ No newline at end of file
<template>
<div class='grid' style="height:100%;">
<el-table v-if="isDisplay === true"
:default-sort="{ prop: minorSortPSDEF, order: Object.is(minorSortDir, 'ASC') ? 'ascending' : Object.is(minorSortDir, 'DESC') ? 'descending' : '' }"
@sort-change="onSortChange($event)"
:border="isDragendCol"
:height="isEnablePagingBar && items.length > 0 ? 'calc(100% - 50px)' : '100%'"
:highlight-current-row ="isSingleSelect"
:row-class-name="getRowClassName"
@row-click="rowClick($event)"
@select-all="selectAll($event)"
@select="select($event)"
@row-class-name="onRowClassName($event)"
@row-dblclick="rowDBLClick($event)"
ref='multipleTable' :data="items" :show-header="!isHideHeader">
<template v-if="!isSingleSelect">
<el-table-column type='selection' :width="checkboxColWidth"></el-table-column>
</template>
<template v-if="getColumnState('ibzdictitemname')">
<el-table-column show-overflow-tooltip :prop="'ibzdictitemname'" :label="$t('ibzdictitem.main_grid.columns.ibzdictitemname')" :width="250" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.ibzdictitemname}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('dictitemval')">
<el-table-column show-overflow-tooltip :prop="'dictitemval'" :label="$t('ibzdictitem.main_grid.columns.dictitemval')" :width="200" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.dictitemval}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('pitemval')">
<el-table-column show-overflow-tooltip :prop="'pitemval'" :label="$t('ibzdictitem.main_grid.columns.pitemval')" :width="200" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.pitemval}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('itemfilter')">
<el-table-column show-overflow-tooltip :prop="'itemfilter'" :label="$t('ibzdictitem.main_grid.columns.itemfilter')" :width="100" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.itemfilter}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('itemcls')">
<el-table-column show-overflow-tooltip :prop="'itemcls'" :label="$t('ibzdictitem.main_grid.columns.itemcls')" :width="100" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.itemcls}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('itemicon')">
<el-table-column show-overflow-tooltip :prop="'itemicon'" :label="$t('ibzdictitem.main_grid.columns.itemicon')" :width="100" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.itemicon}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('showorder')">
<el-table-column show-overflow-tooltip :prop="'showorder'" :label="$t('ibzdictitem.main_grid.columns.showorder')" :width="100" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.showorder}}</span>
</template>
</el-table-column>
</template>
<template v-if="getColumnState('updatedate')">
<el-table-column show-overflow-tooltip :prop="'updatedate'" :label="$t('ibzdictitem.main_grid.columns.updatedate')" :width="250" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<span>{{row.updatedate}}</span>
</template>
</el-table-column>
</template>
<template v-if="adaptiveState">
<el-table-column></el-table-column>
</template>
</el-table>
<row class='grid-pagination' v-show="items.length > 0">
<page class='pull-right' @on-change="pageOnChange($event)"
@on-page-size-change="onPageSizeChange($event)"
:transfer="true" :total="totalrow"
show-sizer :current="curPage" :page-size="limit"
:page-size-opts="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]" show-elevator show-total>
<span>
<span class="page-column">
<poptip transfer placement="top-start">
<i-button icon="md-menu">{{$t('app.gridpage.choicecolumns')}}</i-button>
<div slot="content">
<template v-for="col in allColumns">
<div :key="col.name"><el-checkbox v-model="col.show" @change="onColChange()">{{$t(col.langtag)}}</el-checkbox></div>
</template>
</div>
</poptip>
</span>
<span class="page-button"><i-button icon="md-refresh" :title="$t('app.gridpage.refresh')" @click="pageRefresh()"></i-button></span>&nbsp;
<span>
{{$t('app.gridpage.show')}}&nbsp;
<span>
<template v-if="items.length === 1">
1
</template>
<template v-else>
<span>{{(curPage - 1) * limit + 1}}&nbsp;-&nbsp;{{totalrow > curPage * limit ? curPage * limit : totalrow}}</span>
</template>
</span>&nbsp;
{{$t('app.gridpage.records')}},{{$t('app.gridpage.totle')}}&nbsp;{{totalrow}}&nbsp;{{$t('app.gridpage.records')}}
</span>
</span>
</page>
</row>
</div>
</template>
<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import MainService from './main-grid-service';
import CodeListService from "@service/app/codelist-service";
@Component({
components: {
}
})
export default class MainBase extends Vue implements ControlInterface {
/**
* 名称
*
* @type {string}
* @memberof Main
*/
@Prop() protected name?: string;
/**
* 视图通讯对象
*
* @type {Subject<ViewState>}
* @memberof Main
*/
@Prop() protected viewState!: Subject<ViewState>;
/**
* 应用上下文
*
* @type {*}
* @memberof Main
*/
@Prop() protected context: any;
/**
* 视图参数
*
* @type {*}
* @memberof Main
*/
@Prop() protected viewparams: any;
/**
* 视图状态事件
*
* @protected
* @type {(Subscription | undefined)}
* @memberof Main
*/
protected viewStateEvent: Subscription | undefined;
/**
* 获取部件类型
*
* @returns {string}
* @memberof Main
*/
protected getControlType(): string {
return 'GRID'
}
/**
* 计数器服务对象集合
*
* @type {Array<*>}
* @memberof Main
*/
protected counterServiceArray:Array<any> = [];
/**
* 建构部件服务对象
*
* @type {MainService}
* @memberof Main
*/
protected service: MainService = new MainService({ $store: this.$store });
/**
* 实体服务对象
*
* @type {IBZDICTITEMService}
* @memberof Main
*/
protected appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.$store });
/**
* 关闭视图
*
* @param {any[]} args
* @memberof Main
*/
protected closeView(args: any[]): void {
let _this: any = this;
_this.$emit('closeview', args);
}
/**
* 计数器刷新
*
* @memberof Main
*/
public counterRefresh(){
const _this:any =this;
if(_this.counterServiceArray && _this.counterServiceArray.length >0){
_this.counterServiceArray.forEach((item:any) =>{
if(item.refreshData && item.refreshData instanceof Function){
item.refreshData();
}
})
}
}
/**
* 代码表服务对象
*
* @type {CodeListService}
* @memberof Main
*/
public codeListService:CodeListService = new CodeListService({ $store: this.$store });
/**
* 获取多项数据
*
* @returns {any[]}
* @memberof Main
*/
public getDatas(): any[] {
return this.selections;
}
/**
* 获取单项树
*
* @returns {*}
* @memberof Main
*/
public getData(): any {
return this.selections[0];
}
/**
* 打开新建数据视图
*
* @type {any}
* @memberof Main
*/
@Prop() protected newdata: any;
/**
* 打开编辑数据视图
*
* @type {any}
* @memberof Main
*/
@Prop() protected opendata: any;
/**
* 显示处理提示
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--update
*
* @type {string}
* @memberof Main
*/
@Prop() protected updateAction!: string;
/**
* 部件行为--fetch
*
* @type {string}
* @memberof Main
*/
@Prop() protected fetchAction!: string;
/**
* 部件行为--remove
*
* @type {string}
* @memberof Main
*/
@Prop() protected removeAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof Main
*/
@Prop() protected loadAction!: string;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof Main
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--create
*
* @type {string}
* @memberof Main
*/
@Prop() protected createAction!: string;
/**
* 当前页
*
* @type {number}
* @memberof Main
*/
protected curPage: number = 1;
/**
* 数据
*
* @type {any[]}
* @memberof Main
*/
protected items: any[] = [];
/**
* 是否支持分页
*
* @type {boolean}
* @memberof Main
*/
protected isEnablePagingBar: boolean = true;
/**
* 是否禁用排序
*
* @type {boolean}
* @memberof Main
*/
protected isNoSort: boolean = false;
/**
* 排序方向
*
* @type {string}
* @memberof Main
*/
protected minorSortDir: string = '';
/**
* 排序字段
*
* @type {string}
* @memberof Main
*/
protected minorSortPSDEF: string = '';
/**
* 分页条数
*
* @type {number}
* @memberof Main
*/
protected limit: number = 20;
/**
* 是否显示标题
*
* @type {boolean}
* @memberof Main
*/
protected isHideHeader: boolean = false;
/**
* 是否默认选中第一条数据
*
* @type {boolean}
* @memberof Main
*/
@Prop({ default: false }) protected isSelectFirstDefault!: boolean;
/**
* 是否单选
*
* @type {boolean}
* @memberof Main
*/
@Prop() protected isSingleSelect?: boolean;
/**
* 选中数据字符串
*
* @type {string}
* @memberof Main
*/
@Prop() protected selectedData?: string;
/**
* 选中值变化
*
* @param {*} newVal
* @param {*} oldVal
* @memberof MainTree
*/
@Watch('selectedData')
public onValueChange(newVal: any, oldVal: any) {
this.selections = [];
if(this.selectedData){
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(this.selectedData).forEach((selection:any)=>{
let selectedItem = this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
this.rowClick(selectedItem);
}
});
}
}
}
/**
* 表格行数据默认激活模式
* 0 不激活
* 1 单击激活
* 2 双击激活
*
* @type {(number | 0 | 1 | 2)}
* @memberof Main
*/
@Prop({default: 2}) protected gridRowActiveMode!: number;
/**
* 是否开启行编辑
*
* @type {boolean}
* @memberof Main
*/
@Prop({default: false}) protected isOpenEdit!: boolean;
/**
* 实际是否开启行编辑
*
* @type {boolean}
* @memberof Main
*/
protected actualIsOpenEdit: boolean = this.isOpenEdit;
/**
* 总条数
*
* @type {number}
* @memberof Main
*/
protected totalrow: number = 0;
/**
* 选中行数据
*
* @type {any[]}
* @memberof Main
*/
protected selections: any[] = [];
/**
* 拦截行选中
*
* @type {boolean}
* @memberof Main
*/
protected stopRowClick: boolean = false;
/**
* 表格是否显示
*
* @type {boolean}
* @memberof Main
*/
protected isDisplay:boolean = true;
/**
* 部件刷新
*
* @param {any[]} args
* @memberof Main
*/
protected refresh(args: any[]): void {
this.load();
}
/**
* 选项框列宽
*
* @type {number}
* @memberof AppIndex
*/
protected checkboxColWidth: number = 80;
/**
* 是否允许拖动列宽
*
* @type {boolean}
* @memberof AppEmbedPicker
*/
protected isDragendCol: boolean = false;
/**
* 所有列成员
*
* @type {any[]}
* @memberof Main
*/
protected allColumns: any[] = [
{
name: 'ibzdictitemname',
label: '栏目显示值',
langtag: 'ibzdictitem.main_grid.columns.ibzdictitemname',
show: true,
util: 'PX'
},
{
name: 'dictitemval',
label: '栏目值',
langtag: 'ibzdictitem.main_grid.columns.dictitemval',
show: true,
util: 'PX'
},
{
name: 'pitemval',
label: '父栏目值',
langtag: 'ibzdictitem.main_grid.columns.pitemval',
show: true,
util: 'PX'
},
{
name: 'itemfilter',
label: '过滤项',
langtag: 'ibzdictitem.main_grid.columns.itemfilter',
show: true,
util: 'PX'
},
{
name: 'itemcls',
label: '栏目样式',
langtag: 'ibzdictitem.main_grid.columns.itemcls',
show: true,
util: 'PX'
},
{
name: 'itemicon',
label: '图标',
langtag: 'ibzdictitem.main_grid.columns.itemicon',
show: true,
util: 'PX'
},
{
name: 'showorder',
label: '排序',
langtag: 'ibzdictitem.main_grid.columns.showorder',
show: true,
util: 'PX'
},
{
name: 'updatedate',
label: '更新时间',
langtag: 'ibzdictitem.main_grid.columns.updatedate',
show: true,
util: 'PX'
},
]
/**
* 属性值规则
*
* @type {*}
* @memberof Main
*/
protected rules: any = {
srfkey: [
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '字典项目标识 值不能为空', trigger: 'change' },
{ required: false, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: '字典项目标识 值不能为空', trigger: 'blur' },
],
}
/**
* 表格数据加载
*
* @param {*} [arg={}]
* @memberof Main
*/
protected load(opt: any = {}, pageReset: boolean = false): void {
if(!this.fetchAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图表格fetchAction参数未配置' });
return;
}
if(pageReset){
this.curPage = 1;
}
const arg: any = {...opt};
const page: any = {};
if (this.isEnablePagingBar) {
Object.assign(page, { page: this.curPage-1, size: this.limit });
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
Object.assign(arg, page);
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
Object.assign(arg,{viewparams:this.viewparams});
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response.status || response.status !== 200) {
if (response.errorMessage) {
this.$Notice.error({ title: '错误', desc: response.errorMessage });
}
return;
}
const data: any = response.data;
this.totalrow = response.total;
this.items = JSON.parse(JSON.stringify(data));
// 清空selections
this.selections = [];
this.$emit('load', this.items);
// 设置默认选中
let _this = this;
setTimeout(() => {
if(_this.isSelectFirstDefault){
_this.rowClick(_this.items[0]);
}
if(_this.selectedData){
const refs: any = _this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
JSON.parse(_this.selectedData).forEach((selection:any)=>{
let selectedItem = _this.items.find((item:any)=>{
return Object.is(item.srfkey, selection.srfkey);
});
if(selectedItem){
_this.rowClick(selectedItem);
}
});
}
}
}, 300);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '错误', desc: response.errorMessage });
});
}
/**
* 删除
*
* @param {any[]} datas
* @returns {Promise<any>}
* @memberof Main
*/
protected async remove(datas: any[]): Promise<any> {
if(!this.removeAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图表格removeAction参数未配置' });
return;
}
let _datas:any[] = [];
datas.forEach((record: any, index: number) => {
if (!record.srfkey) {
this.items.some((val: any, num: number) =>{
if(JSON.stringify(val) == JSON.stringify(record)){
this.items.splice(num,1);
return true;
}
});
}else{
_datas.push(datas[index]);
}
});
if (_datas.length === 0) {
return;
}
let dataInfo = '';
_datas.forEach((record: any, index: number) => {
let srfmajortext = record.srfmajortext;
if (index < 5) {
if (!Object.is(dataInfo, '')) {
dataInfo += '、';
}
dataInfo += srfmajortext;
} else {
return false;
}
});
if (_datas.length < 5) {
dataInfo = dataInfo + ' 共' + _datas.length + '条数据';
} else {
dataInfo = dataInfo + '...' + ' 共' + _datas.length + '条数据';
}
const removeData = () => {
let keys: any[] = [];
_datas.forEach((data: any) => {
keys.push(data.srfkey);
});
const context:any = JSON.parse(JSON.stringify(this.context));
const post: Promise<any> = this.service.delete(this.removeAction,Object.assign(context,{ ibzdictitem: keys.join(';') }),Object.assign({ itemid: keys.join(';') },{viewparams:this.viewparams}), this.showBusyIndicator);
return new Promise((resolve: any, reject: any) => {
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '删除数据失败,' + response.info });
return;
} else {
this.$Notice.success({ title: '', desc: '删除成功!' });
}
//删除items中已删除的项
console.log(this.items);
_datas.forEach((data: any) => {
this.items.some((item:any,index:number)=>{
if(Object.is(item.srfkey,data.srfkey)){
this.items.splice(index,1);
return true;
}
});
});
this.totalrow -= _datas.length;
this.$emit('remove', null);
this.selections = [];
resolve(response);
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
if (!response || !response.status || !response.data) {
this.$Notice.error({ title: '错误', desc: '系统异常' });
reject(response);
return;
}
reject(response);
});
});
}
dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
this.$Modal.confirm({
title: '警告',
content: '确认要删除 ' + dataInfo + ',删除操作将不可恢复?',
onOk: () => {
removeData();
},
onCancel: () => { }
});
return removeData;
}
/**
* 批量添加
*
* @param {*} [arg={}]
* @memberof Main
*/
protected addBatch(arg: any = {}): void {
if(!this.fetchAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图表格fetchAction参数未配置' });
return;
}
if(!arg){
arg = {};
}
console.error("批量添加未实现");
}
/**
* 数据导出
*
* @param {*} data
* @memberof Main
*/
protected exportExcel(data: any = {}): void {
// 导出Excel
const doExport = async (_data:any) => {
const tHeader: Array<any> = [];
const filterVal: Array<any> = [];
this.allColumns.forEach((item: any) => {
item.show && item.label ? tHeader.push(item.label) : "";
item.show && item.name ? filterVal.push(item.name) : "";
});
const data = await this.formatExcelData(filterVal, _data);
this.$export.exportExcel().then((excel:any)=>{
excel.export_json_to_excel({
header: tHeader, //表头 必填
data, //具体数据 必填
filename: "主实体"+"表", //非必填
autoWidth: true, //非必填
bookType: "xlsx" //非必填
});
});
};
const page: any = {};
// 设置page,size
if (Object.is(data.type, 'maxRowCount')) {
Object.assign(page, { page: 0, size: data.maxRowCount });
} else if (Object.is(data.type, 'activatedPage')) {
try {
doExport(JSON.parse(JSON.stringify(this.items)));
} catch (error) {
console.error(error);
}
return;
}
// 设置排序
if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
Object.assign(page, { sort: sort });
}
const arg: any = {};
Object.assign(arg, page);
// 获取query,搜索表单,viewparams等父数据
const parentdata: any = {};
this.$emit('beforeload', parentdata);
Object.assign(arg, parentdata);
const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
post.then((response: any) => {
if (!response || response.status !== 200) {
this.$Notice.error({ title: '', desc: '数据导出失败,' + response.info });
return;
}
try {
doExport(JSON.parse(JSON.stringify(response.data)));
} catch (error) {
console.error(error);
}
}).catch((response: any) => {
if (response && response.status === 401) {
return;
}
this.$Notice.error({ title: '', desc: '数据导出失败' });
});
}
/**
* 导出数据格式化
*
* @param {*} filterVal
* @param {*} jsonData
* @returns {[]}
* @memberof Main
*/
public async formatExcelData(filterVal:any, jsonData:any) {
let codelistColumns:Array<any> = [
];
let _this = this;
for (const codelist of codelistColumns) {
// 动态代码表处理
if (Object.is(codelist.codelistType, "DYNAMIC")) {
let items = await _this.codeListService.getItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
// 静态处理
} else if(Object.is(codelist.codelistType, "STATIC")){
let items = await _this.$store.getters.getCodeListItems(codelist.srfkey);
jsonData.forEach((row:any)=>{
row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
});
}
}
return jsonData.map((v:any) => filterVal.map((j:any) => v[j]))
}
/**
* 解析代码表和vlaue,设置items
*
* @private
* @param {any[]} items 代码表数据
* @param {*} value
* @returns {*}
* @memberof Main
*/
private getCodelistValue(items: any[], value: any, codelist: any,){
if(!value){
return this.$t('codelist.'+codelist.srfkey+'.empty');
}
if (items) {
let result:any = [];
if(Object.is(codelist.renderMode,"number")){
items.map((_item: any, index: number)=>{
const nValue = parseInt((value as any), 10);
const codevalue = _item.value;
if((parseInt(codevalue, 10) & nValue) > 0){
result.push(_item);
}
});
} else if(Object.is(codelist.renderMode,"string")){
const arrayValue: Array<any> = (value as any).split(codelist.valueSeparator);
arrayValue.map((value: any, index: number) => {
result.push([]);
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((val:any ,num: number)=>{
const item = this.getItem(items, val, codelist);
if(item){
result[index].push(item);
}
});
});
} else {
let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
values.map((value:any ,index: number)=>{
const item = this.getItem(items, value, codelist);
if(item){
result.push(item);
}
});
}
// 设置items
if(result.length != 0){
return result.join(codelist.valueSeparator);
}else{
return value;
}
}
}
/**
* 获取代码项
*
* @private
* @param {any[]} items
* @param {*} value
* @returns {*}
* @memberof Main
*/
private getItem(items: any[], value: any, codelist: any): any {
const arr: Array<any> = items.filter(item => {return item.value == value});
if (arr.length !== 1) {
return undefined;
}
if(Object.is(codelist.codelistType,'STATIC')){
return this.$t('codelist.'+codelist.srfkey+'.'+arr[0].value);
}else{
return arr[0].text;
}
}
/**
* 生命周期
*
* @memberof Main
*/
protected created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof Main
*/
protected afterCreated(){
this.setColState();
if (this.viewState) {
this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
if (!Object.is(tag, this.name)) {
return;
}
if (Object.is('load', action)) {
this.load(data);
}
if (Object.is('remove', action)) {
this.remove(data);
}
if (Object.is('save', action)) {
this.save(data);
}
});
}
}
/**
* vue 生命周期
*
* @memberof Main
*/
protected destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof Main
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
}
/**
* 获取选中行胡数据
*
* @returns {any[]}
* @memberof Main
*/
protected getSelection(): any[] {
return this.selections;
}
/**
* 行双击事件
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected rowDBLClick($event: any): void {
if (!$event || this.actualIsOpenEdit || Object.is(this.gridRowActiveMode,0)) {
return;
}
this.selections = [];
this.selections.push(JSON.parse(JSON.stringify($event)));
const refs: any = this.$refs;
if (refs.multipleTable) {
refs.multipleTable.clearSelection();
refs.multipleTable.toggleRowSelection($event);
}
this.$emit('rowdblclick', this.selections);
this.$emit('selectionchange', this.selections);
}
/**
* 复选框数据选中
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected select($event: any): void {
if (!$event) {
return;
}
this.selections = [];
this.selections = [...JSON.parse(JSON.stringify($event))];
this.$emit('selectionchange', this.selections);
}
/**
* 复选框数据全部选中
*
* @param {*} $event
* @memberof Main
*/
protected selectAll($event: any): void {
if (!$event) {
return;
}
this.selections = [];
this.selections = [...JSON.parse(JSON.stringify($event))];
this.$emit('selectionchange', this.selections);
}
/**
* 行单击选中
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected rowClick($event: any, ifAlways: boolean = false): void {
if (!ifAlways && (!$event || this.actualIsOpenEdit)) {
return;
}
if(this.stopRowClick) {
this.stopRowClick = false;
return;
}
if(this.isSingleSelect){
this.selections = [];
}
// 已选中则删除,没选中则添加
let selectIndex = this.selections.findIndex((item:any)=>{
return Object.is(item.ibzdictitem,$event.ibzdictitem);
});
if (Object.is(selectIndex,-1)){
this.selections.push(JSON.parse(JSON.stringify($event)));
} else {
this.selections.splice(selectIndex,1);
}
const refs: any = this.$refs;
if (refs.multipleTable) {
if(this.isSingleSelect){
refs.multipleTable.clearSelection();
refs.multipleTable.setCurrentRow($event);
}else{
refs.multipleTable.toggleRowSelection($event);
}
}
this.$emit('selectionchange', this.selections);
}
/**
* 页面变化
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected pageOnChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.curPage) {
return;
}
this.curPage = $event;
this.load({});
}
/**
* 分页条数变化
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected onPageSizeChange($event: any): void {
if (!$event) {
return;
}
if ($event === this.limit) {
return;
}
this.limit = $event;
if (this.curPage === 1) {
this.load({});
}
}
/**
* 分页刷新
*
* @memberof Main
*/
protected pageRefresh(): void {
this.load({});
}
/**
* 排序变化
*
* @param {{ column: any, prop: any, order: any }} { column, prop, order }
* @memberof Main
*/
protected onSortChange({ column, prop, order }: { column: any, prop: any, order: any }): void {
const dir = Object.is(order, 'ascending') ? 'asc' : Object.is(order, 'descending') ? 'desc' : '';
if (Object.is(dir, this.minorSortDir) && Object.is(this.minorSortPSDEF, prop)) {
return;
}
this.minorSortDir = dir;
this.minorSortPSDEF = prop ? prop : '';
this.load({});
}
/**
* 表格行选中样式
*
* @param {{ row: any, rowIndex: any }} { row, rowIndex }
* @returns {string}
* @memberof Main
*/
protected onRowClassName({ row, rowIndex }: { row: any, rowIndex: any }): string {
const index = this.selections.findIndex((select: any) => Object.is(select.srfkey, row.srfkey));
return index !== -1 ? 'grid-row-select' : '';
}
/**
* 界面行为
*
* @param {*} row
* @param {*} tag
* @param {*} $event
* @memberof Main
*/
protected uiAction(row: any, tag: any, $event: any) {
this.rowClick(row, true);
}
/**
* 设置列状态
*
* @memberof Main
*/
protected setColState() {
const _data: any = localStorage.getItem('ibzdictitem_main_grid');
if (_data) {
let columns = JSON.parse(_data);
columns.forEach((col: any) => {
let column = this.allColumns.find((item) => Object.is(col.name, item.name));
if (column) {
Object.assign(column, col);
}
});
}
}
/**
* 列变化
*
* @memberof Main
*/
protected onColChange() {
localStorage.setItem('ibzdictitem_main_grid', JSON.stringify(this.allColumns));
}
/**
* 获取列状态
*
* @param {string} name
* @returns {boolean}
* @memberof Main
*/
protected getColumnState(name: string): boolean {
let column = this.allColumns.find((col: any) =>
Object.is(name, col.name)
);
return column.show ? true : false;
}
/**
* 表格列是否自适应布局
*
* @readonly
* @type {boolean}
* @memberof Main
*/
get adaptiveState(): boolean {
return !this.allColumns.find((column: any) => column.show && Object.is(column.util, 'STAR'));
}
/**
* 保存
*
* @param {*} $event
* @returns {void}
* @memberof Main
*/
protected save(args: any[], params?: any, $event?: any, xData?: any): void {
let _this = this;
let promises:any = [];
_this.items.forEach((item:any)=>{
if(!item.rowDataState){
return;
} else if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图表格createAction参数未配置' });
return;
}
Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
}else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDictItemGridView视图表格updateAction参数未配置' });
return;
}
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdictitem){
Object.assign(this.context,{ibzdictitem:item.ibzdictitem})
}
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
}
});
Promise.all(promises).then((response: any) => {
this.$emit('save', response);
}).catch((response: any) => {
this.$Notice.error({ title: '错误', desc: '系统异常' });
});
}
/**
* 获取对应行class
*
* @param {*} $args row 行数据,rowIndex 行索引
* @returns {void}
* @memberof Main
*/
protected getRowClassName(args:{row: any,rowIndex: number}){
let isSelected = this.selections.some((item:any)=>{
return Object.is(item.ibzdictitem,args.row.ibzdictitem);
});
return isSelected ? "grid-selected-row" : "";
}
}
</script>
<style lang='less'>
@import './main-grid.less';
</style>
\ No newline at end of file
/**
* Main 部件模型
*
* @export
* @class MainModel
*/
export default class MainModel {
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof MainGridMode
*/
public getDataItems(): any[] {
return [
{
name: 'dictitemval',
prop: 'itemval',
dataType: 'TEXT',
},
{
name: 'dictid',
prop: 'dictid',
dataType: 'PICKUP',
},
{
name: 'showorder',
prop: 'showorder',
dataType: 'INT',
},
{
name: 'pitemval',
prop: 'pitemval',
dataType: 'TEXT',
},
{
name: 'updatedate',
prop: 'updatedate',
dataType: 'DATETIME',
},
{
name: 'itemicon',
prop: 'itemicon',
dataType: 'TEXT',
},
{
name: 'itemfilter',
prop: 'itemfilter',
dataType: 'TEXT',
},
{
name: 'ibzdictitemname',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'srfmajortext',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'srfdataaccaction',
prop: 'itemid',
dataType: 'GUID',
},
{
name: 'srfkey',
prop: 'itemid',
dataType: 'GUID',
},
{
name: 'itemcls',
prop: 'itemcls',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
{
name: 'ibzdictitem',
prop: 'itemid',
},
{
name: 'n_ibzdictitemname_like',
prop: 'n_ibzdictitemname_like',
dataType: 'TEXT',
},
{
name: 'n_dictitemval_like',
prop: 'n_dictitemval_like',
dataType: 'TEXT',
},
{
name: 'ibzdict',
prop: 'dictid',
dataType: 'FONTKEY',
},
{
name:'size',
prop:'size'
},
{
name:'query',
prop:'query'
},
{
name:'page',
prop:'page'
},
{
name:'sort',
prop:'sort'
},
{
name:'srfparentdata',
prop:'srfparentdata'
}
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDICTITEMService from '@/service/ibzdictitem/ibzdictitem-service';
import MainModel from './main-grid-model';
/**
* Main 部件服务对象
*
* @export
* @class MainService
*/
export default class MainService extends ControlService {
/**
* 字典项目服务对象
*
* @type {IBZDICTITEMService}
* @memberof MainService
*/
public appEntityService: IBZDICTITEMService = new IBZDICTITEMService({ $store: this.getStore() });
/**
* 设置从数据模式
*
* @type {boolean}
* @memberof MainService
*/
public setTempMode(){
this.isTempMode = false;
}
/**
* Creates an instance of MainService.
*
* @param {*} [opts={}]
* @memberof MainService
*/
constructor(opts: any = {}) {
super(opts);
this.model = new MainModel();
}
/**
* 处理数据
*
* @private
* @param {Promise<any>} promise
* @returns {Promise<any>}
* @memberof MainService
*/
private doItems(promise: Promise<any>, deKeyField: string, deName: string): Promise<any> {
return new Promise((resolve, reject) => {
promise.then((response: any) => {
if (response && response.status === 200) {
const data = response.data;
data.forEach((item:any,index:number) =>{
item[deName] = item[deKeyField];
data[index] = item;
});
resolve(data);
} else {
reject([])
}
}).catch((response: any) => {
reject([])
});
});
}
/**
* 获取跨实体数据集合
*
* @param {string} serviceName 服务名称
* @param {string} interfaceName 接口名称
* @param {*} data
* @param {boolean} [isloading]
* @returns {Promise<any[]>}
* @memberof MainService
*/
@Errorlog
public getItems(serviceName: string, interfaceName: string, context: any = {}, data: any, isloading?: boolean): Promise<any[]> {
return Promise.reject([])
}
/**
* 添加数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public add(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Create(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 删除数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public delete(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.Remove(Context,Data, isloading);
}
result.then((response) => {
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 修改数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public update(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Data,Context,isloading);
}else{
result =_appEntityService.Update(Data,Context,isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public get(action: string, context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.Get(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:0});
}
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 查询数据
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public search(action: string,context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any) => {
const _appEntityService: any = this.appEntityService;
let result: Promise<any>;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
}else{
result =_appEntityService.FetchDefault(Context,Data, isloading);
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 加载草稿
*
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public loadDraft(action: string, context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
//仿真主键数据
data.itemid = Util.createUUID();
return new Promise((resolve: any, reject: any) => {
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
result = this.appEntityService.GetDraft(Context,Data, isloading);
}
result.then((response) => {
//处理返回数据,补充判断标识
if(response.data){
Object.assign(response.data,{srfuf:'0'});
}
this.handleResponse(action, response);
this.mergeDefaults(response);
resolve(response);
}).catch(response => {
reject(response);
});
});
}
/**
* 合并配置的默认值
* @param {*}
* @memberof MainService
*/
public mergeDefaults(response:any = {}){
if(response.data){
}
}
/**
* 前台逻辑
* @param {string} action
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof MainService
*/
@Errorlog
public frontLogic(action:string,context: any = {}, data: any = {}, isloading?: boolean): Promise<any> {
const {data:Data,context:Context} = this.handleRequestData(action,context,data,true);
return new Promise((resolve: any, reject: any)=>{
let result: Promise<any>;
const _appEntityService: any = this.appEntityService;
if (_appEntityService[action] && _appEntityService[action] instanceof Function) {
result = _appEntityService[action](Context,Data, isloading);
} else {
return Promise.reject({ status: 500, data: { title: '失败', message: '系统异常' } });
}
result.then((response) => {
this.handleResponse(action, response);
resolve(response);
}).catch(response => {
reject(response);
});
})
}
}
\ No newline at end of file
.grid {
flex-grow: 1;
height: 100%;
overflow: auto;
.el-table__body-wrapper::-webkit-scrollbar {
/*滚动条整体样式*/
width : 10px !important; /*高宽分别对应横竖滚动条的尺寸*/
height: 10px !important;
}
.el-table__body-wrapper::-webkit-scrollbar-thumb {
/*滚动条颜色*/
border-radius : 10px !important;
background-color: #cecece !important;
}
.el-table__body-wrapper::-webkit-scrollbar-track {
/*滚动条里面轨道*/
box-shadow : inset 0 0 5px rgba(0, 0, 0, 0.2) !important;
background : #ededed !important;
border-radius: 10px !important;
}
.el-table {
.el-tooltip{
.ivu-form-item{
margin-bottom: unset !important;
}
}
}
.grid-pagination {
height: 50px;
padding: 6px 0px;
.page-button {
button {
padding: 0;
font-size: 16px;
min-width: 32px;
height: 32px;
margin-right: 4px;
}
}
.page-column {
position: absolute;
left: 0;
}
}
.el-table__body-wrapper{
height: calc(100% - 83px) !important;
}
.el-table__empty-block{
height: auto !important;
}
}
.ivu-modal-content{
.footer{
.ivu-row{
text-align: right;
}
}
}
// this is less
<script lang='ts'>
import { Component } from 'vue-property-decorator';
import MainBase from './main-grid-base.vue';
@Component({
components: {
}
})
export default class Main extends MainBase {
}
</script>
\ No newline at end of file
......@@ -20,6 +20,8 @@ public class AppDataEntitySysApiMappingFilter extends ZuulFilter {
@PostConstruct
private void initDataEntitySysApiMapping() {
AppDataEntitySysApiMapping.put("ibzdictitem", "dictapi");
AppDataEntitySysApiMapping.put("ibzdict", "dictapi");
}
@Override
......
......@@ -21,6 +21,14 @@ sysapi:
zuul:
routes:
ibzdictitem:
path: /ibzdictitems/**
serviceId: ${sysapi.defaultServiceId}
stripPrefix: ${sysapi.defaultStripPrefix}
ibzdict:
path: /ibzdicts/**
serviceId: ${sysapi.defaultServiceId}
stripPrefix: ${sysapi.defaultStripPrefix}
ribbon:
ReadTimeout: 60000
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册