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

ibiz4j 发布系统代码

上级 137b1c56
...@@ -851,17 +851,44 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -851,17 +851,44 @@ export default class EditGridBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof EditGrid * @memberof EditGrid
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof EditGrid
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1572,41 +1599,56 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -1572,41 +1599,56 @@ export default class EditGridBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof EditGrid * @memberof EditGrid
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzdepartment){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdepartment){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
/** /**
......
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
</i-col> </i-col>
<i-col v-show="detailsModel.orgname.visible" :style="{}" :lg="{ span: 24, offset: 0 }"> <i-col v-show="detailsModel.orgname.visible" :style="{}" :lg="{ span: 24, offset: 0 }">
<app-form-item name='orgname' :itemRules="this.rules.orgname" class='' :caption="$t('entities.ibzdepartment.main_form.details.orgname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.orgname.error" :isEmptyCaption="false" labelPos="LEFT"> <app-form-item name='orgname' :itemRules="this.rules.orgname" class='' :caption="$t('entities.ibzdepartment.main_form.details.orgname')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.orgname.error" :isEmptyCaption="false" labelPos="LEFT">
<app-org-select :data="data" :context="JSON.parse(JSON.stringify(context))" :fillMap="{'id':'orgid','label':'orgname'}" url="/ibzorganizations/${orgid}/suborg/picker" filter="srforgid" :multiple="false" style="" @select-change="onFormItemValueChange"></app-org-select> <app-org-select :data="data" :context="JSON.parse(JSON.stringify(context))" :fillMap="{'id':'orgid','label':'orgname'}" url="/ibzorganizations/alls/suborg/picker" filter="srforgid" :multiple="false" style="" @select-change="onFormItemValueChange"></app-org-select>
</app-form-item> </app-form-item>
</i-col> </i-col>
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
:value='data.leadername' :value='data.leadername'
valueitem="leaderid" valueitem="leaderid"
url="/ibzorganizations/${selected-orgid}/ibzemployees/picker" url="/ibzorganizations/${selected-orgid}/ibzemployees/picker"
treeurl="/ibzorganizations/${orgid}/suborg/picker"
:multiple="true" :multiple="true"
filter="orgid" filter="orgid"
:fillmap="{'id':'leaderid','label':'leadername'}" :fillmap="{'id':'leaderid','label':'leadername'}"
......
...@@ -806,17 +806,44 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -806,17 +806,44 @@ export default class MainBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof Main * @memberof Main
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof Main
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1527,41 +1554,56 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1527,41 +1554,56 @@ export default class MainBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof Main * @memberof Main
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzdepartment){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdepartment){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
......
...@@ -629,17 +629,44 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -629,17 +629,44 @@ export default class MainBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof Main * @memberof Main
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof Main
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1350,41 +1377,56 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1350,41 +1377,56 @@ export default class MainBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof Main * @memberof Main
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzdeptmember){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzdeptmember:item.ibzdeptmember}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdeptmember){
Object.assign(this.context,{ibzdeptmember:item.ibzdeptmember});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
/** /**
......
...@@ -953,17 +953,44 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -953,17 +953,44 @@ export default class EditGridBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof EditGrid * @memberof EditGrid
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof EditGrid
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1682,41 +1709,56 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -1682,41 +1709,56 @@ export default class EditGridBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof EditGrid * @memberof EditGrid
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzemployee){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzemployee:item.ibzemployee}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzemployee){
Object.assign(this.context,{ibzemployee:item.ibzemployee});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
/** /**
......
...@@ -737,17 +737,44 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -737,17 +737,44 @@ export default class MainBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof Main * @memberof Main
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof Main
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1466,41 +1493,56 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1466,41 +1493,56 @@ export default class MainBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof Main * @memberof Main
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzemployee){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzemployee:item.ibzemployee}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzemployee){
Object.assign(this.context,{ibzemployee:item.ibzemployee});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
......
...@@ -730,17 +730,44 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -730,17 +730,44 @@ export default class MainBase extends Vue implements ControlInterface {
* @param {string} property 属性名 * @param {string} property 属性名
* @param {*} data 行数据 * @param {*} data 行数据
* @param {number} rowIndex 行索引 * @param {number} rowIndex 行索引
* * @returns Promise<any>
*
* @memberof Main * @memberof Main
*/ */
public validate(property:string, data:any, rowIndex:number){ public validate(property:string, data:any, rowIndex:number):Promise<any>{
this.$util.validateItem(property,data,this.rules).then(()=>{ return new Promise((resolve, reject) => {
this.gridItemsModel[rowIndex][property].setError(null); this.$util.validateItem(property,data,this.rules).then(()=>{
}).catch(({ errors, fields }) => { this.gridItemsModel[rowIndex][property].setError(null);
this.gridItemsModel[rowIndex][property].setError(errors[0].message); resolve(true);
}).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message);
resolve(false);
});
}); });
} }
/**
* 校验所有修改过的编辑项
*
* @returns Promise<any>
* @memberof Main
*/
public async validateAll(){
let validateState = true;
let index = -1;
for(let item of this.items){
index++;
if(item.rowDataState === "create" || item.rowDataState === "update"){
for(let property of Object.keys(this.rules)){
if(!await this.validate(property,item,index)){
validateState = false;
}
}
}
}
return validateState;
}
/** /**
* 表格数据加载 * 表格数据加载
* *
...@@ -1451,41 +1478,56 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1451,41 +1478,56 @@ export default class MainBase extends Vue implements ControlInterface {
* 保存 * 保存
* *
* @param {*} $event * @param {*} $event
* @returns {void} * @returns {Promise<any>}
* @memberof Main * @memberof Main
*/ */
public save(args: any[], params?: any, $event?: any, xData?: any): void { public async save(args: any[], params?: any, $event?: any, xData?: any){
let _this = this; let _this = this;
let promises:any = []; if(!await this.validateAll()){
_this.items.forEach((item:any)=>{ this.$Notice.error({ title: '错误', desc: '值规则校验异常' });
if(!item.rowDataState){ return [];
return; }
} else if(Object.is(item.rowDataState, 'create')){ let successItems:any = [];
if(!this.createAction){ let errorItems:any = [];
this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格createAction参数未配置' }); let errorMessage:any = [];
return; for (const item of _this.items) {
} try {
Object.assign(item,{viewparams:this.viewparams}); if(Object.is(item.rowDataState, 'create')){
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); if(!this.createAction){
}else if(Object.is(item.rowDataState, 'update')){ this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格createAction参数未配置' });
if(!this.updateAction){ }else{
this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格updateAction参数未配置' }); Object.assign(item,{viewparams:this.viewparams});
return; let response = await this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
} successItems.push(JSON.parse(JSON.stringify(response.data)));
Object.assign(item,{viewparams:this.viewparams}); }
if(item.ibzorganization){ }else if(Object.is(item.rowDataState, 'update')){
Object.assign(this.context,{ibzorganization:item.ibzorganization}) if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格updateAction参数未配置' });
}else{
Object.assign(item,{viewparams:this.viewparams});
if(item.ibzorganization){
Object.assign(this.context,{ibzorganization:item.ibzorganization});
}
let response = await this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator);
successItems.push(JSON.parse(JSON.stringify(response.data)));
}
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); } catch (error) {
errorItems.push(JSON.parse(JSON.stringify(item)));
errorMessage.push(error);
} }
}); }
Promise.all(promises).then((response: any) => { this.$emit('save', successItems);
this.$emit('save', response); this.refresh([]);
if(errorItems.length === 0){
this.$Notice.success({ title: '', desc: '保存成功!' }); this.$Notice.success({ title: '', desc: '保存成功!' });
this.refresh([]); }else{
}).catch((response: any) => { errorItems.forEach((item:any,index:number)=>{
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.error({ title: '保存失败', desc: item.majorentityname+'保存失败!' });
}); console.error(errorMessage[index]);
});
}
return successItems;
} }
......
...@@ -126,7 +126,7 @@ ...@@ -126,7 +126,7 @@
<!--输出实体[IBZDEPT]数据结构 --> <!--输出实体[IBZDEPT]数据结构 -->
<changeSet author="a_A_5d9d78509" id="tab-ibzdept-681-4"> <changeSet author="a_A_5d9d78509" id="tab-ibzdept-682-4">
<createTable tableName="IBZDEPT"> <createTable tableName="IBZDEPT">
<column name="DEPTID" remarks="" type="VARCHAR(100)"> <column name="DEPTID" remarks="" type="VARCHAR(100)">
<constraints primaryKey="true" primaryKeyName="PK_IBZDEPT_DEPTID"/> <constraints primaryKey="true" primaryKeyName="PK_IBZDEPT_DEPTID"/>
...@@ -179,10 +179,10 @@ ...@@ -179,10 +179,10 @@
<addForeignKeyConstraint baseColumnNames="USERID" baseTableName="IBZDEPTMEMBER" constraintName="DER1N_IBZDEPTMEMBER_IBZEMP_USE" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="USERID" referencedTableName="IBZEMP" validate="true"/> <addForeignKeyConstraint baseColumnNames="USERID" baseTableName="IBZDEPTMEMBER" constraintName="DER1N_IBZDEPTMEMBER_IBZEMP_USE" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="USERID" referencedTableName="IBZEMP" validate="true"/>
</changeSet> </changeSet>
<!--输出实体[IBZDEPT]外键关系 --> <!--输出实体[IBZDEPT]外键关系 -->
<changeSet author="a_A_5d9d78509" id="fk-ibzdept-681-10"> <changeSet author="a_A_5d9d78509" id="fk-ibzdept-682-10">
<addForeignKeyConstraint baseColumnNames="PDEPTID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZDEPT_PDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/> <addForeignKeyConstraint baseColumnNames="PDEPTID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZDEPT_PDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/>
</changeSet> </changeSet>
<changeSet author="a_A_5d9d78509" id="fk-ibzdept-681-11"> <changeSet author="a_A_5d9d78509" id="fk-ibzdept-682-11">
<addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/> <addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet> </changeSet>
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册