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

ibizdev提交

上级 692729a5
import ibzdictitem_en_US from '@locale/lanres/ibzdictitem/ibzdictitem_en_US';
import ibzdictitem_en_US from '@locale/lanres/ibzdict-item/ibzdict-item_en_US';
import ibzdict_en_US from '@locale/lanres/ibzdict/ibzdict_en_US';
import components_en_US from '@locale/lanres/components/components_en_US';
import codelist_en_US from '@locale/lanres/codelist/codelist_en_US';
......
import ibzdictitem_zh_CN from '@locale/lanres/ibzdictitem/ibzdictitem_zh_CN';
import ibzdictitem_zh_CN from '@locale/lanres/ibzdict-item/ibzdict-item_zh_CN';
import ibzdict_zh_CN from '@locale/lanres/ibzdict/ibzdict_zh_CN';
import components_zh_CN from '@locale/lanres/components/components_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 {0}",
},
tbitem6: {
caption: "Copy",
tip: "Copy {0}",
},
tbitem7: {
caption: "-",
tip: "",
},
tbitem8: {
caption: "Remove",
tip: "Remove {0}",
},
tbitem9: {
caption: "-",
tip: "",
},
tbitem13: {
caption: "Export",
tip: "Export {0} Data To Excel",
},
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 Window",
},
tbitem6: {
caption: "-",
tip: "",
},
tbitem7: {
caption: "Remove And Close",
tip: "Remove And Close Window",
},
tbitem8: {
caption: "-",
tip: "",
},
tbitem12: {
caption: "New",
tip: "New",
},
tbitem13: {
caption: "-",
tip: "",
},
tbitem14: {
caption: "Copy",
tip: "Copy {0}",
},
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> = [
];
// Select
mock.onGet(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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.itemid, tempValue.itemid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items);
console.groupEnd();
console.groupEnd();
return [status, _items];
});
// Select
mock.onGet(new RegExp(/^\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})\/select$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items);
console.groupEnd();
console.groupEnd();
return [status, _items];
});
// GetDraft
mock.onGet(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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, {}];
});
// GetDraft
mock.onGet(new RegExp(/^\/ibzdictitems\/getdraft$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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, {}];
});
// Save
mock.onPost(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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]
});
});
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// Save
mock.onPost(new RegExp(/^\/ibzdictitems\/?([a-zA-Z0-9\-\;]{0,35})\/save$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['itemid'] == tempValue['itemid'] ){
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];
});
// CheckKey
mock.onPost(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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]
});
});
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// CheckKey
mock.onPost(new RegExp(/^\/ibzdictitems\/?([a-zA-Z0-9\-\;]{0,35})\/checkkey$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['itemid'] == tempValue['itemid'] ){
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];
});
// Create
mock.onPost(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// Create
mock.onPost(new RegExp(/^\/ibzdictitems\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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]];
});
// Update
mock.onPut(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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({});
console.groupEnd();
console.groupEnd();
return [status, {}];
});
// Update
mock.onPut(new RegExp(/^\/ibzdictitems\/?([a-zA-Z0-9\-\;]{0,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
let data = JSON.parse(config.data);
mockDatas.forEach((item)=>{
if(item['itemid'] == tempValue['itemid'] ){
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\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: FetchDefault");
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'];
let tempValue: any = {};
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/fetchdefault$/).exec(config.url);
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 : [];
if (items.length > 0 && paramArray.length > 0) {
paramArray.forEach((paramkey: any) => {
if (tempValue[paramkey] && tempValue[paramkey].indexOf(";") > 0) {
let keysGrounp: Array<any> = tempValue[paramkey].split(new RegExp(/[\;]/));
let tempArray: Array<any> = [];
keysGrounp.forEach((singlekey: any) => {
let _items = items.filter((item: any) => { return item[paramkey] == singlekey });
if(_items.length >0){
tempArray.push(..._items);
}
})
items = tempArray;
} else {
items = items.filter((item: any) => { return item[paramkey] == tempValue[paramkey] });
}
})
}
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(items);
console.groupEnd();
console.groupEnd();
return [status, items];
});
// FetchDefault
mock.onGet(new RegExp(/^\/ibzdictitems\/fetchdefault$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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(/^\/ibzdictitems\/fetchdefault(\?[\w-./?%&=,]*)*$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// URI参数传递情况未实现
// Get
mock.onGet(new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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.itemid, tempValue.itemid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
// Get
mock.onGet(new RegExp(/^\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
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})\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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','itemid'];
const matchArray:any = new RegExp(/^\/ibzdicts\/([a-zA-Z0-9\-\;]{1,35})\/ibzdictitems\/([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.itemid, tempValue.itemid));
console.groupCollapsed("response数据 status: "+status+" data: ");
console.table(_items?_items:{});
console.groupEnd();
console.groupEnd();
return [status, _items?_items:{}];
});
// Remove
mock.onDelete(new RegExp(/^\/ibzdictitems\/([a-zA-Z0-9\-\;]{1,35})$/)).reply((config: any) => {
console.groupCollapsed("实体:ibzdictitem 方法: 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> = ['itemid'];
const matchArray:any = new RegExp(/^\/ibzdictitems\/([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.itemid, tempValue.itemid));
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/ibzdictitems/ibzdictitems';
import './entity/ibzdict-items/ibzdict-items';
import './entity/ibzdicts/ibzdicts';
......@@ -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/ibzdictitem/ibzdictitem-service';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-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;
/**
......@@ -667,7 +667,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");
}
/**
......@@ -693,7 +693,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");
}
/**
......@@ -719,7 +719,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");
}
/**
......@@ -745,7 +745,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");
}
/**
......@@ -771,7 +771,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");
}
/**
......@@ -797,7 +797,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");
}
/**
......@@ -823,7 +823,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");
}
/**
......@@ -849,7 +849,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");
}
/**
......@@ -875,7 +875,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");
}
/**
......@@ -901,7 +901,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");
}
/**
......@@ -927,7 +927,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");
}
/**
......@@ -953,7 +953,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");
}
/**
......@@ -979,7 +979,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");
}
/**
......@@ -1005,7 +1005,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");
}
/**
......@@ -1346,6 +1346,33 @@ 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/ibzdictitem/main-form/main-form.vue';
import view_form from '@widgets/ibzdict-item/main-form/main-form.vue';
@Component({
components: {
view_form,
......
......@@ -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/ibzdictitem/ibzdictitem-service';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-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;
/**
......@@ -761,7 +761,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");
}
/**
......@@ -787,7 +787,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");
}
/**
......@@ -813,7 +813,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");
}
/**
......@@ -839,7 +839,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");
}
/**
......@@ -865,7 +865,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");
}
/**
......@@ -891,7 +891,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");
}
/**
......@@ -917,7 +917,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");
}
/**
......@@ -943,7 +943,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");
}
/**
......@@ -969,7 +969,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");
}
/**
......@@ -995,7 +995,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");
}
/**
......@@ -1021,7 +1021,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");
}
/**
......@@ -1047,7 +1047,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");
}
/**
......@@ -1073,7 +1073,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");
}
/**
......@@ -1093,9 +1093,11 @@ export default class IBZDictItemGridViewBase extends Vue {
Object.assign(curViewParam,args[0]);
}
let deResParameters: any[] = [];
deResParameters = [
if(curViewParam.ibzdict && true){
deResParameters = [
{ pathName: 'ibzdicts', parameterName: 'ibzdict' },
];
]
}
const parameters: any[] = [
{ pathName: 'ibzdictitems', parameterName: 'ibzdictitem' },
{ pathName: 'editview', parameterName: 'editview' },
......@@ -1128,9 +1130,11 @@ export default class IBZDictItemGridViewBase extends Vue {
Object.assign(curViewParam,args[0]);
}
let deResParameters: any[] = [];
deResParameters = [
if(curViewParam.ibzdict && true){
deResParameters = [
{ pathName: 'ibzdicts', parameterName: 'ibzdict' },
];
]
}
const parameters: any[] = [
{ pathName: 'ibzdictitems', parameterName: 'ibzdictitem' },
{ pathName: 'editview', parameterName: 'editview' },
......@@ -1419,6 +1423,33 @@ 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/ibzdictitem/main-grid/main-grid.vue';
import view_searchform from '@widgets/ibzdictitem/default-searchform/default-searchform.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';
@Component({
components: {
view_grid,
......
......@@ -39,7 +39,7 @@ export class EntityServiceRegister {
* @memberof EntityServiceRegister
*/
protected init(): void {
this.allEntityService.set('ibzdictitem', () => import('@/service/ibzdictitem/ibzdictitem-service'));
this.allEntityService.set('ibzdictitem', () => import('@/service/ibzdict-item/ibzdict-item-service'));
this.allEntityService.set('ibzdict', () => import('@/service/ibzdict/ibzdict-service'));
}
......
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';
}
// 实体接口
/**
* Select接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Select(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().get(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}/select`,isloading);
}
return Http.getInstance().get(`/ibzdictitems/${context.ibzdictitem}/select`,isloading);
}
/**
* Get接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Get(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().get(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}`,isloading);
}
let res:any = await Http.getInstance().get(`/ibzdictitems/${context.ibzdictitem}`,isloading);
return res;
}
/**
* GetDraft接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async GetDraft(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && true){
return Http.getInstance().get(`/ibzdicts/${context.ibzdict}/ibzdictitems/getdraft`,isloading);
}
let res:any = await Http.getInstance().get(`/ibzdictitems/getdraft`,isloading);
res.data.ibzdictitem = data.ibzdictitem;
return res;
}
/**
* Save接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Save(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().post(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}/save`,data,isloading);
}
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().post(`/ibzdictitems/${context.ibzdictitem}/save`,data,isloading);
return res;
}
/**
* CheckKey接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async CheckKey(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().post(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}/checkkey`,data,isloading);
}
return Http.getInstance().post(`/ibzdictitems/${context.ibzdictitem}/checkkey`,data,isloading);
}
/**
* Remove接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Remove(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().delete(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}`,isloading);
}
return Http.getInstance().delete(`/ibzdictitems/${context.ibzdictitem}`,isloading);
}
/**
* Create接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Create(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && true){
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
return Http.getInstance().post(`/ibzdicts/${context.ibzdict}/ibzdictitems`,data,isloading);
}
let masterData:any = {};
Object.assign(data,masterData);
if(!data.srffrontuf || data.srffrontuf !== "1"){
data[this.APPDEKEY] = null;
}
if(data.srffrontuf){
delete data.srffrontuf;
}
let tempContext:any = JSON.parse(JSON.stringify(context));
let res:any = await Http.getInstance().post(`/ibzdictitems`,data,isloading);
return res;
}
/**
* Update接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async Update(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && context.ibzdictitem){
return Http.getInstance().put(`/ibzdicts/${context.ibzdict}/ibzdictitems/${context.ibzdictitem}`,data,isloading);
}
let masterData:any = {};
Object.assign(data,masterData);
let res:any = await Http.getInstance().put(`/ibzdictitems/${context.ibzdictitem}`,data,isloading);
return res;
}
/**
* FetchDefault接口方法
*
* @param {*} [context={}]
* @param {*} [data={}]
* @param {boolean} [isloading]
* @returns {Promise<any>}
* @memberof IBZDictItemServiceBase
*/
public async FetchDefault(context: any = {},data: any = {}, isloading?: boolean): Promise<any> {
if(context.ibzdict && true){
let tempData:any = JSON.parse(JSON.stringify(data));
return Http.getInstance().get(`/ibzdicts/${context.ibzdict}/ibzdictitems/fetchdefault`,tempData,isloading);
}
let tempData:any = JSON.parse(JSON.stringify(data));
return Http.getInstance().get(`/ibzdictitems/fetchdefault`,tempData,isloading);
}
}
\ No newline at end of file
import { Http,Util } from '@/utils';
import IBZDictItemServiceBase from './ibzdict-item-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/ibzdict-item/ibzdict-item-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 './ibzdict-item-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/ibzdictitem/ibzdictitem-ui-service'));
this.allUIService.set('ibzdictitem', () => import('@/uiservice/ibzdict-item/ibzdict-item-ui-service'));
this.allUIService.set('ibzdict', () => import('@/uiservice/ibzdict/ibzdict-ui-service'));
}
......
<template>
<i-form :model="this.data" class='app-search-form' ref='searchform' style="">
<input style="display:none;"/>
<row>
<i-col span="20">
<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('entities.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('entities.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>
</i-col>
<i-col span="4">
<row v-show="Object.keys(data).length>0">
<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>
</row>
</i-col>
</row>
</i-form>
</template>
<script lang='tsx'>
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/ibzdict-item/ibzdict-item-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 DefaultBase
*/
public getDatas(): any[] {
return [this.data];
}
/**
* 获取单项树
*
* @returns {*}
* @memberof DefaultBase
*/
public getData(): any {
return this.data;
}
/**
* 显示处理提示
*
* @type {boolean}
* @memberof DefaultBase
*/
@Prop({ default: true }) protected showBusyIndicator?: boolean;
/**
* 部件行为--loaddraft
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() protected loaddraftAction!: string;
/**
* 部件行为--load
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() protected loadAction!: string;
/**
* 视图标识
*
* @type {string}
* @memberof DefaultBase
*/
@Prop() protected viewtag!: string;
/**
* 表单状态
*
* @type {Subject<any>}
* @memberof DefaultBase
*/
protected formState: Subject<any> = new Subject();
/**
* 忽略表单项值变化
*
* @type {boolean}
* @memberof DefaultBase
*/
protected ignorefieldvaluechange: boolean = false;
/**
* 数据变化
*
* @private
* @type {Subject<any>}
* @memberof DefaultBase
*/
private dataChang: Subject<any> = new Subject();
/**
* 视图状态事件
*
* @private
* @type {(Subscription | undefined)}
* @memberof DefaultBase
*/
private dataChangEvent: Subscription | undefined;
/**
* 原始数据
*
* @private
* @type {*}
* @memberof DefaultBase
*/
private oldData: any = {};
/**
* 表单数据对象
*
* @type {*}
* @memberof DefaultBase
*/
protected data: any = {
n_ibzdictitemname_like: null,
n_dictitemval_like: null,
};
/**
* 属性值规则
*
* @type {*}
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
@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 DefaultBase
*/
@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 DefaultBase
*/
private resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
}
/**
* 表单逻辑
*
* @private
* @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
private onFormLoad(data: any = {}): void {
this.setFormEnableCond(data);
this.fillForm(data);
this.formLogic({ name: '', newVal: null, oldVal: null });
}
/**
* 值填充
*
* @param {*} [_datas={}]
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
private resetDraftFormStates(): void {
const form: any = this.$refs.form;
if (form) {
form.resetFields();
}
}
/**
* 重置校验结果
*
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
protected getValues(): any {
return this.data;
}
/**
* 表单项值变更
*
* @param {{ name: string, value: any }} $event
* @returns {void}
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
protected groupUIActionClick($event: any): void {
if (!$event) {
return;
}
const item:any = $event.item;
}
/**
* Vue声明周期(处理组件的输入属性)
*
* @memberof DefaultBase
*/
protected created(): void {
this.afterCreated();
}
/**
* 执行created后的逻辑
*
* @memberof DefaultBase
*/
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);
}
});
}
}
/**
* vue 生命周期
*
* @memberof DefaultBase
*/
protected destroyed() {
this.afterDestroy();
}
/**
* 执行destroyed后的逻辑
*
* @memberof DefaultBase
*/
protected afterDestroy() {
if (this.viewStateEvent) {
this.viewStateEvent.unsubscribe();
}
if (this.dataChangEvent) {
this.dataChangEvent.unsubscribe();
}
}
/**
* 自动加载
*
* @param {*} [arg={}]
* @returns {void}
* @memberof DefaultBase
*/
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 DefaultBase
*/
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 DefaultBase
*/
protected loadDraft(opt: any = {},mode?:string): 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);
setTimeout(() => {
const form: any = this.$refs.form;
if (form) {
form.fields.forEach((field: any) => {
field.validateMessage = "";
field.validateState = "";
field.validateStatus = false;
});
}
});
if(Object.is(mode,'RESET')){
if (!this.formValidateStatus()) {
return;
}
}
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 {string} mode 界面行为名称
* @param {*} [data={}] 请求数据
* @param {string[]} updateDetails 更新项
* @param {boolean} [showloading] 是否显示加载状态
* @returns {void}
* @memberof DefaultBase
*/
protected updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
}
/**
* 回车事件
*
* @param {*} $event
* @memberof DefaultBase
*/
protected onEnter($event: any): void {
if (!this.formValidateStatus()) {
return;
}
this.$emit('load', this.data);
}
/**
* 搜索
*
* @memberof DefaultBase
*/
protected onSearch() {
if (!this.formValidateStatus()) {
return;
}
this.$emit('load', this.data);
}
/**
* 重置
*
* @memberof DefaultBase
*/
protected onReset() {
this.loadDraft({},'RESET');
}
}
</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',
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
{
name: 'n_ibzdictitemname_like',
prop: 'itemname',
dataType: 'TEXT',
},
{
name: 'n_dictitemval_like',
prop: 'itemval',
dataType: 'TEXT',
},
]
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-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: 8px 14px 0;
.ivu-form-item{
margin-bottom: 8px;
}
.search_reset {
margin-right: 12px;
margin-bottom: 8px;
}
}
.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='tsx'>
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('entities.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('entities.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('entities.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('entities.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('entities.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('entities.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('entities.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('entities.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='tsx'>
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/ibzdict-item/ibzdict-item-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;
/**
* 需要等待关系界面保存时,第一次调用save参数的备份
*
* @type {number}
* @memberof Main
*/
protected drsaveopt: any = {};
/**
* 表单保存回调存储对象
*
* @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: 'entities.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;
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.drsaveopt = opt;
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');
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(this.drsaveopt, undefined, false).then((res) =>{
this.saveState(res);
this.drsaveopt = {};
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',
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
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: '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/ibzdict-item/ibzdict-item-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;
}
}
}
}
// 表单行间距
.app-form{
.app-form-item{
margin-bottom: 20px;
}
}
// this is less
<script lang='tsx'>
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 align="center" type='selection' :width="checkboxColWidth"></el-table-column>
</template>
<template v-if="getColumnState('ibzdictitemname')">
<el-table-column show-overflow-tooltip :prop="'ibzdictitemname'" :label="$t('entities.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('entities.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('entities.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('entities.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('entities.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('entities.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('entities.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('entities.ibzdictitem.main_grid.columns.updatedate')" :width="250" :align="'left'" :sortable="'custom'">
<template v-slot="{row,column}">
<app-format-data format="YYYY-MM-DD hh:mm:ss" :data="row.updatedate"></app-format-data>
</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='tsx'>
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/ibzdict-item/ibzdict-item-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: 'entities.ibzdictitem.main_grid.columns.ibzdictitemname',
show: true,
util: 'PX'
},
{
name: 'dictitemval',
label: '栏目值',
langtag: 'entities.ibzdictitem.main_grid.columns.dictitemval',
show: true,
util: 'PX'
},
{
name: 'pitemval',
label: '父栏目值',
langtag: 'entities.ibzdictitem.main_grid.columns.pitemval',
show: true,
util: 'PX'
},
{
name: 'itemfilter',
label: '过滤项',
langtag: 'entities.ibzdictitem.main_grid.columns.itemfilter',
show: true,
util: 'PX'
},
{
name: 'itemcls',
label: '栏目样式',
langtag: 'entities.ibzdictitem.main_grid.columns.itemcls',
show: true,
util: 'PX'
},
{
name: 'itemicon',
label: '图标',
langtag: 'entities.ibzdictitem.main_grid.columns.itemicon',
show: true,
util: 'PX'
},
{
name: 'showorder',
label: '排序',
langtag: 'entities.ibzdictitem.main_grid.columns.showorder',
show: true,
util: 'PX'
},
{
name: 'updatedate',
label: '更新时间',
langtag: 'entities.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.itemname;
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
*/
public importExcel(data:any ={}):void{
//导入excel
const importDataModel:any ={
}
if(Object.keys(importDataModel).length == 0){
this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
return;
}
const view:any ={
viewname: 'app-data-upload',
title: this.$t("app.utilview.importview"),
width: 900,
height: 700
}
let container: Subject<any> = this.$appmodal.openModal(view, JSON.parse(JSON.stringify(this.context)), importDataModel);
container.subscribe((result: any) => {
if(Object.is(result.ret,'OK')){
this.refresh(result.datas);
}
});
}
/**
* 数据导出
*
* @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(this.$t(item.langtag)) : "";
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);
this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]);
}).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 isDEExport: boolean = false;
/**
* 获取数据项集合
*
* @returns {any[]}
* @memberof MainGridMode
*/
public getDataItems(): any[] {
if(this.isDEExport){
return [
]
}else{
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: 'ibzdictitem',
prop: 'itemid',
},
{
name: 'n_ibzdictitemname_like',
prop: 'n_ibzdictitemname_like',
dataType: 'TEXT',
},
{
name: 'n_dictitemval_like',
prop: 'n_dictitemval_like',
dataType: 'TEXT',
},
{
name:'size',
prop:'size'
},
{
name:'query',
prop:'query'
},
{
name:'page',
prop:'page'
},
{
name:'sort',
prop:'sort'
},
{
name:'srfparentdata',
prop:'srfparentdata'
},
// 前端新增修改标识,新增为"0",修改为"1"或未设值
{
name: 'srffrontuf',
prop: 'srffrontuf',
dataType: 'TEXT',
},
]
}
}
}
\ No newline at end of file
import { Http,Util,Errorlog } from '@/utils';
import ControlService from '@/widgets/control-service';
import IBZDictItemService from '@/service/ibzdict-item/ibzdict-item-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);
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'});
//仿真主键数据
response.data.ibzdictitem = Util.createUUID();
}
this.handleResponse(action, response, true);
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 th>.cell, .el-table td>.cell{
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
}
.app-column-link, .app-format-data{
display: inline;
}
.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% - 43px) !important;
}
.el-table__empty-block{
height: auto !important;
}
}
.ivu-modal-content{
.footer{
.ivu-row{
text-align: right;
}
}
}
// this is less
<script lang='tsx'>
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
......@@ -91,12 +91,5 @@ public class IBZDictDTO extends DTOBase implements Serializable {
}
/**
* [IBZDICTITEM]
*/
@JsonProperty("ibzdictitems")
@JSONField(name = "ibzdictitems")
private List<IBZDictItemDTO> items ;
}
package cn.ibizlab.dictapi.rest;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.math.BigInteger;
import java.util.HashMap;
import lombok.extern.slf4j.Slf4j;
import com.alibaba.fastjson.JSONObject;
import javax.servlet.ServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.http.HttpStatus;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.util.StringUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import cn.ibizlab.dictapi.dto.*;
import cn.ibizlab.dictapi.mapping.*;
import cn.ibizlab.core.dict.domain.IBZDictItem;
import cn.ibizlab.core.dict.service.IIBZDictItemService;
import cn.ibizlab.core.dict.filter.IBZDictItemSearchContext;
@Slf4j
@Api(tags = {"IBZDictItem" })
@RestController("dictapi-ibzdictitem")
@RequestMapping("")
public class IBZDictItemResource {
@Autowired
private IIBZDictItemService ibzdictitemService;
@Autowired
@Lazy
private IBZDictItemMapping ibzdictitemMapping;
@PreAuthorize("hasPermission(#ibzdictitem_id,'READ',this.getEntity())")
@ApiOperation(value = "Get", tags = {"IBZDictItem" }, notes = "Get")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdictitems/{ibzdictitem_id}")
public ResponseEntity<IBZDictItemDTO> get(@PathVariable("ibzdictitem_id") String ibzdictitem_id) {
IBZDictItem domain = ibzdictitemService.get(ibzdictitem_id);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@ApiOperation(value = "GetDraft", tags = {"IBZDictItem" }, notes = "GetDraft")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdictitems/getdraft")
public ResponseEntity<IBZDictItemDTO> getDraft() {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemMapping.toDto(ibzdictitemService.getDraft(new IBZDictItem())));
}
@ApiOperation(value = "Save", tags = {"IBZDictItem" }, notes = "Save")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/save")
public ResponseEntity<Boolean> save(@RequestBody IBZDictItemDTO ibzdictitemdto) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.save(ibzdictitemMapping.toDomain(ibzdictitemdto)));
}
@ApiOperation(value = "SaveBatch", tags = {"SaveBatch" }, notes = "SaveBatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/savebatch")
public ResponseEntity<Boolean> saveBatch(@RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.saveBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "CheckKey", tags = {"IBZDictItem" }, notes = "CheckKey")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/checkkey")
public ResponseEntity<Boolean> checkKey(@RequestBody IBZDictItemDTO ibzdictitemdto) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.checkKey(ibzdictitemMapping.toDomain(ibzdictitemdto)));
}
@PreAuthorize("hasPermission('DELETE',{#ibzdictitem_id,this.getEntity()})")
@ApiOperation(value = "Remove", tags = {"IBZDictItem" }, notes = "Remove")
@RequestMapping(method = RequestMethod.DELETE, value = "/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<Boolean> remove(@PathVariable("ibzdictitem_id") String ibzdictitem_id) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.remove(ibzdictitem_id));
}
@ApiOperation(value = "RemoveBatch", tags = {"RemoveBatch" }, notes = "RemoveBatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/removebatch")
public ResponseEntity<Boolean> removeBatch(@RequestBody List<String> ids) {
ibzdictitemService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@ApiOperation(value = "Create", tags = {"IBZDictItem" }, notes = "Create")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems")
@Transactional
public ResponseEntity<IBZDictItemDTO> create(@RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
ibzdictitemService.create(domain);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission('','CREATE',this.getEntity())")
@ApiOperation(value = "createBatch", tags = {"createBatch" }, notes = "createBatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/createbatch")
public ResponseEntity<Boolean> createBatch(@RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.createBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasPermission(#ibzdictitem_id,'UPDATE',this.getEntity())")
@ApiOperation(value = "Update", tags = {"IBZDictItem" }, notes = "Update")
@RequestMapping(method = RequestMethod.PUT, value = "/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<IBZDictItemDTO> update(@PathVariable("ibzdictitem_id") String ibzdictitem_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
domain.setItemid(ibzdictitem_id);
ibzdictitemService.update(domain);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@PreAuthorize("hasPermission(#ibzdictitem_id,'UPDATE',this.getEntity())")
@ApiOperation(value = "UpdateBatch", tags = {"UpdateBatch" }, notes = "UpdateBatch")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdictitems/updatebatch")
public ResponseEntity<Boolean> updateBatch(@RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
ibzdictitemService.updateBatch(ibzdictitemMapping.toDomain(ibzdictitemdtos));
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@PreAuthorize("hasPermission('READ',{#context,'Default',this.getEntity()})")
@ApiOperation(value = "fetchDEFAULT", tags = {"IBZDictItem" } ,notes = "fetchDEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/ibzdictitems/fetchdefault")
public ResponseEntity<List<IBZDictItemDTO>> fetchDefault(IBZDictItemSearchContext context) {
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
List<IBZDictItemDTO> list = ibzdictitemMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@PreAuthorize("hasPermission('READ',{#context,'Default',this.getEntity()})")
@ApiOperation(value = "searchDEFAULT", tags = {"IBZDictItem" } ,notes = "searchDEFAULT")
@RequestMapping(method= RequestMethod.GET , value="/ibzdictitems/searchdefault")
public ResponseEntity<Page<IBZDictItemDTO>> searchDefault(IBZDictItemSearchContext context) {
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(ibzdictitemMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
@ApiOperation(value = "GetByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "GetByIBZDict")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
public ResponseEntity<IBZDictItemDTO> getByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id) {
IBZDictItem domain = ibzdictitemService.get(ibzdictitem_id);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "GetDraftByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "GetDraftByIBZDict")
@RequestMapping(method = RequestMethod.GET, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/getdraft")
public ResponseEntity<IBZDictItemDTO> getDraftByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id) {
IBZDictItem domain = new IBZDictItem();
domain.setDictid(ibzdict_id);
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemMapping.toDto(ibzdictitemService.getDraft(domain)));
}
@ApiOperation(value = "SaveByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "SaveByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/save")
public ResponseEntity<Boolean> saveByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
domain.setDictid(ibzdict_id);
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.save(domain));
}
@ApiOperation(value = "SaveBatchByIBZDict", tags = {"SaveBatchByIBZDict" }, notes = "SaveBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/savebatch")
public ResponseEntity<Boolean> saveBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
List<IBZDictItem> domainlist=ibzdictitemMapping.toDomain(ibzdictitemdtos);
for(IBZDictItem domain:domainlist){
domain.setDictid(ibzdict_id);
}
ibzdictitemService.saveBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "CheckKeyByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "CheckKeyByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/checkkey")
public ResponseEntity<Boolean> checkKeyByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.checkKey(ibzdictitemMapping.toDomain(ibzdictitemdto)));
}
@ApiOperation(value = "RemoveByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "RemoveByIBZDict")
@RequestMapping(method = RequestMethod.DELETE, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<Boolean> removeByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id) {
return ResponseEntity.status(HttpStatus.OK).body(ibzdictitemService.remove(ibzdictitem_id));
}
@ApiOperation(value = "RemoveBatchByIBZDict", tags = {"RemoveBatchByIBZDict" }, notes = "RemoveBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/removebatch")
public ResponseEntity<Boolean> removeBatchByIBZDict(@RequestBody List<String> ids) {
ibzdictitemService.removeBatch(ids);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "CreateByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "CreateByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems")
@Transactional
public ResponseEntity<IBZDictItemDTO> createByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
domain.setDictid(ibzdict_id);
ibzdictitemService.create(domain);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "createBatchByIBZDict", tags = {"createBatchByIBZDict" }, notes = "createBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/createbatch")
public ResponseEntity<Boolean> createBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
List<IBZDictItem> domainlist=ibzdictitemMapping.toDomain(ibzdictitemdtos);
for(IBZDictItem domain:domainlist){
domain.setDictid(ibzdict_id);
}
ibzdictitemService.createBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "UpdateByIBZDict", tags = {"IBZDictItemByIBZDict" }, notes = "UpdateByIBZDict")
@RequestMapping(method = RequestMethod.PUT, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/{ibzdictitem_id}")
@Transactional
public ResponseEntity<IBZDictItemDTO> updateByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @PathVariable("ibzdictitem_id") String ibzdictitem_id, @RequestBody IBZDictItemDTO ibzdictitemdto) {
IBZDictItem domain = ibzdictitemMapping.toDomain(ibzdictitemdto);
domain.setDictid(ibzdict_id);
domain.setItemid(ibzdictitem_id);
ibzdictitemService.update(domain);
IBZDictItemDTO dto = ibzdictitemMapping.toDto(domain);
return ResponseEntity.status(HttpStatus.OK).body(dto);
}
@ApiOperation(value = "UpdateBatchByIBZDict", tags = {"UpdateBatchByIBZDict" }, notes = "UpdateBatchByIBZDict")
@RequestMapping(method = RequestMethod.POST, value = "/ibzdicts/{ibzdict_id}/ibzdictitems/updatebatch")
public ResponseEntity<Boolean> updateBatchByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id, @RequestBody List<IBZDictItemDTO> ibzdictitemdtos) {
List<IBZDictItem> domainlist=ibzdictitemMapping.toDomain(ibzdictitemdtos);
for(IBZDictItem domain:domainlist){
domain.setDictid(ibzdict_id);
}
ibzdictitemService.updateBatch(domainlist);
return ResponseEntity.status(HttpStatus.OK).body(true);
}
@ApiOperation(value = "fetchDEFAULTByIBZDict", tags = {"IBZDictItemByIBZDict" } ,notes = "fetchDEFAULTByIBZDict")
@RequestMapping(method= RequestMethod.GET , value="/ibzdicts/{ibzdict_id}/ibzdictitems/fetchdefault")
public ResponseEntity<List<IBZDictItemDTO>> fetchIBZDictItemDefaultByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id,IBZDictItemSearchContext context) {
context.setN_dictid_eq(ibzdict_id);
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
List<IBZDictItemDTO> list = ibzdictitemMapping.toDto(domains.getContent());
return ResponseEntity.status(HttpStatus.OK)
.header("x-page", String.valueOf(context.getPageable().getPageNumber()))
.header("x-per-page", String.valueOf(context.getPageable().getPageSize()))
.header("x-total", String.valueOf(domains.getTotalElements()))
.body(list);
}
@ApiOperation(value = "searchDEFAULTByIBZDict", tags = {"IBZDictItemByIBZDict" } ,notes = "searchDEFAULTByIBZDict")
@RequestMapping(method= RequestMethod.GET , value="/ibzdicts/{ibzdict_id}/ibzdictitems/searchdefault")
public ResponseEntity<Page<IBZDictItemDTO>> searchIBZDictItemDefaultByIBZDict(@PathVariable("ibzdict_id") String ibzdict_id,IBZDictItemSearchContext context) {
context.setN_dictid_eq(ibzdict_id);
Page<IBZDictItem> domains = ibzdictitemService.searchDefault(context) ;
return ResponseEntity.status(HttpStatus.OK)
.body(new PageImpl(ibzdictitemMapping.toDto(domains.getContent()), context.getPageable(), domains.getTotalElements()));
}
/**
* 用户权限校验
* @return
*/
public IBZDictItem getEntity(){
return new IBZDictItem();
}
}
......@@ -38,9 +38,6 @@ import cn.ibizlab.core.dict.filter.IBZDictSearchContext;
import cn.ibizlab.core.dict.filter.IBZDictItemSearchContext;
import cn.ibizlab.core.dict.domain.IBZDictItem;
import cn.ibizlab.core.dict.service.IIBZDictItemService;
@Slf4j
@Api(tags = {"IBZDict" })
......@@ -55,10 +52,6 @@ public class IBZDictResource {
@Lazy
private IBZDictMapping ibzdictMapping;
@Autowired
private IIBZDictItemService ibzdictitemService;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册