提交 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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1599,57 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -1572,42 +1599,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDepartmentEditGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdepartment){ if(item.ibzdepartment){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment}) Object.assign(this.context,{ibzdepartment:item.ibzdepartment});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1554,57 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1527,42 +1554,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDepartmentGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdepartment){ if(item.ibzdepartment){
Object.assign(this.context,{ibzdepartment:item.ibzdepartment}) Object.assign(this.context,{ibzdepartment:item.ibzdepartment});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1377,57 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1350,42 +1377,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZDeptMemberGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzdeptmember){ if(item.ibzdeptmember){
Object.assign(this.context,{ibzdeptmember:item.ibzdeptmember}) Object.assign(this.context,{ibzdeptmember:item.ibzdeptmember});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1709,57 @@ export default class EditGridBase extends Vue implements ControlInterface { ...@@ -1682,42 +1709,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZEmployeeEditGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzemployee){ if(item.ibzemployee){
Object.assign(this.context,{ibzemployee:item.ibzemployee}) Object.assign(this.context,{ibzemployee:item.ibzemployee});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1493,57 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1466,42 +1493,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZEmployeePickupGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzemployee){ if(item.ibzemployee){
Object.assign(this.context,{ibzemployee:item.ibzemployee}) Object.assign(this.context,{ibzemployee:item.ibzemployee});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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>{
return new Promise((resolve, reject) => {
this.$util.validateItem(property,data,this.rules).then(()=>{ this.$util.validateItem(property,data,this.rules).then(()=>{
this.gridItemsModel[rowIndex][property].setError(null); this.gridItemsModel[rowIndex][property].setError(null);
resolve(true);
}).catch(({ errors, fields }) => { }).catch(({ errors, fields }) => {
this.gridItemsModel[rowIndex][property].setError(errors[0].message); 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,42 +1478,57 @@ export default class MainBase extends Vue implements ControlInterface { ...@@ -1451,42 +1478,57 @@ 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 = [];
let errorItems:any = [];
let errorMessage:any = [];
for (const item of _this.items) {
try {
if(Object.is(item.rowDataState, 'create')){
if(!this.createAction){ if(!this.createAction){
this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格createAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格createAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
}
}else if(Object.is(item.rowDataState, 'update')){ }else if(Object.is(item.rowDataState, 'update')){
if(!this.updateAction){ if(!this.updateAction){
this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格updateAction参数未配置' }); this.$Notice.error({ title: '错误', desc: 'IBZOrganizationGridView视图表格updateAction参数未配置' });
return; }else{
}
Object.assign(item,{viewparams:this.viewparams}); Object.assign(item,{viewparams:this.viewparams});
if(item.ibzorganization){ if(item.ibzorganization){
Object.assign(this.context,{ibzorganization:item.ibzorganization}) Object.assign(this.context,{ibzorganization:item.ibzorganization});
} }
promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator)); 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)));
} }
}); }
Promise.all(promises).then((response: any) => { } catch (error) {
this.$emit('save', response); errorItems.push(JSON.parse(JSON.stringify(item)));
this.$Notice.success({ title: '', desc: '保存成功!' }); errorMessage.push(error);
}
}
this.$emit('save', successItems);
this.refresh([]); this.refresh([]);
}).catch((response: any) => { if(errorItems.length === 0){
this.$Notice.error({ title: '错误', desc: '系统异常' }); this.$Notice.success({ title: '', desc: '保存成功!' });
}else{
errorItems.forEach((item:any,index:number)=>{
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 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册