提交 ac3b4c52 编写于 作者: WodahsOrez's avatar WodahsOrez

lxm--数据选择,自动填充编辑器参数处理

上级 580e73b5
......@@ -173,29 +173,22 @@ export default class AppAutocomplete extends Vue {
* @param callback
*/
public onSearch(query: any, callback: any): void {
// 公共参数处理
let data: any = {};
const bcancel: boolean = this.handlePublicParams(data);
if (!bcancel) {
return;
}
// 参数处理
let _context = data.context;
let _param = data.param;
// 处理搜索参数
query = !query ? '' : query;
if (!this.inputState && Object.is(query, this.value)) {
query = '';
}
this.inputState = false;
// 合并视图上下文参数和视图参数
let param: any = JSON.parse(JSON.stringify(this.viewparams));
let context: any = JSON.parse(JSON.stringify(this.context));
Object.assign(param, { query: query });
// 附加参数处理
if (this.itemParam.context) {
let _context = this.$util.formatData(this.data,this.itemParam.context);
Object.assign(context,_context);
}
if (this.itemParam.param) {
let _param = this.$util.formatData(this.data,this.itemParam.param);
Object.assign(param,_param);
}
if (this.itemParam.parentdata) {
let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
Object.assign(param,_parentdata);
}
Object.assign(_param, { query: query });
// 错误信息国际化
let error: string = (this.$t('components.appAutocomplete.error') as any);
let miss: string = (this.$t('components.appAutocomplete.miss') as any);
......@@ -208,7 +201,7 @@ export default class AppAutocomplete extends Vue {
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, context, param).then((response: any) => {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, _context, _param).then((response: any) => {
if (!response) {
this.$Notice.error({ title: error, desc: requestException });
} else {
......@@ -274,6 +267,34 @@ export default class AppAutocomplete extends Vue {
this.$forceUpdate();
}
/**
* 公共参数处理
*
* @param {*} arg
* @returns
* @memberof AppAutocomplete
*/
public handlePublicParams(arg: any): boolean {
if (!this.data) {
this.$Notice.error({ title: (this.$t('components.appPicker.error') as any), desc: (this.$t('components.appPicker.formdataException') as any) });
return false;
}
// 合并表单参数
arg.param = JSON.parse(JSON.stringify(this.viewparams));
arg.context = JSON.parse(JSON.stringify(this.context));
// 附加参数处理
if (this.itemParam.context) {
let _context = this.$util.formatData(this.data,arg.context,this.itemParam.context);
Object.assign(arg.context,_context);
}
if (this.itemParam.param) {
let _param = this.$util.formatData(this.data,arg.param,this.itemParam.param);
Object.assign(arg.param,_param);
}
return true;
}
}
</script>
......
......@@ -44,6 +44,14 @@ export default class AppMpicker extends Vue {
*/
@Prop() curvalue?: any;
/**
* 表单项参数
*
* @type {any}
* @memberof AppPicker
*/
@Prop() public itemParam: any;
/**
* 表单项名称
*/
......@@ -147,9 +155,18 @@ export default class AppMpicker extends Vue {
* @memberof AppMpicker
*/
public onSearch(query: any) {
let param: any = { query: query };
// 公共参数处理
let data: any = {};
const bcancel: boolean = this.handlePublicParams(data);
if (!bcancel) {
return;
}
// 参数处理
let _context = data.context;
let _param = data.param;
Object.assign(_param ,{ query: query });
if (this.activeData) {
Object.assign(param, { srfreferdata: this.activeData });
Object.assign(_param, { srfreferdata: this.activeData });
}
// 错误信息国际化
let error: string = (this.$t('components.appMpicker.error') as any);
......@@ -162,7 +179,7 @@ export default class AppMpicker extends Vue {
} else if(!this.acParams.interfaceName) {
this.$Notice.error({ title: error, desc: miss+'interfaceName' });
} else {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, param).then((response: any) => {
this.service.getItems(this.acParams.serviceName,this.acParams.interfaceName, _context, _param).then((response: any) => {
if (!response) {
this.$Notice.error({ title: error, desc: requestException });
} else {
......@@ -216,6 +233,33 @@ export default class AppMpicker extends Vue {
}
}
/**
* 公共参数处理
*
* @param {*} arg
* @returns
* @memberof AppMpicker
*/
public handlePublicParams(arg: any): boolean {
if (!this.activeData) {
this.$Notice.error({ title: (this.$t('components.appPicker.error') as any), desc: (this.$t('components.appPicker.formdataException') as any) });
return false;
}
// 合并表单参数
arg.param = JSON.parse(JSON.stringify(this.viewparams));
arg.context = JSON.parse(JSON.stringify(this.context));
// 附加参数处理
if (this.itemParam.context) {
let _context = this.$util.formatData(this.activeData,arg.context,this.itemParam.context);
Object.assign(arg.context,_context);
}
if (this.itemParam.param) {
let _param = this.$util.formatData(this.activeData,arg.param,this.itemParam.param);
Object.assign(arg.param,_param);
}
return true;
}
/**
* 打开视图
*
......@@ -229,8 +273,15 @@ export default class AppMpicker extends Vue {
if (this.pickupView && Object.keys(this.pickupView).length > 0) {
// 参数处理
const view = { ...this.pickupView };
let _viewparams = JSON.parse(JSON.stringify(this.viewparams));
let _context = JSON.parse(JSON.stringify(this.context));
// 公共参数处理
let data: any = {};
const bcancel: boolean = this.handlePublicParams(data);
if (!bcancel) {
return;
}
// 参数处理
let _context = data.context;
let _viewparams = data.param;
let _selectItems = JSON.parse(JSON.stringify(this.selectItems));
if(!Object.is(this.deKeyField,"srfkey")){
_selectItems.forEach((item:any, index:number)=>{
......
......@@ -259,17 +259,13 @@ export default class AppPickerSelectView extends Vue {
arg.context = JSON.parse(JSON.stringify(this.context));
// 附加参数处理
if (this.itemParam.context) {
let _context = this.$util.formatData(this.data,this.itemParam.context);
let _context = this.$util.formatData(this.data,arg.context,this.itemParam.context);
Object.assign(arg.context,_context);
}
if (this.itemParam.param) {
let _param = this.$util.formatData(this.data,this.itemParam.param);
let _param = this.$util.formatData(this.data,arg.param,this.itemParam.param);
Object.assign(arg.param,_param);
}
if (this.itemParam.parentdata) {
let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
Object.assign(arg.param,_parentdata);
}
return true;
}
......
......@@ -651,17 +651,13 @@ export default class AppPicker extends Vue {
arg.context = JSON.parse(JSON.stringify(this.context));
// 附加参数处理
if (this.itemParam.context) {
let _context = this.$util.formatData(this.data,this.itemParam.context);
let _context = this.$util.formatData(this.data,arg.context,this.itemParam.context);
Object.assign(arg.context,_context);
}
if (this.itemParam.param) {
let _param = this.$util.formatData(this.data,this.itemParam.param);
let _param = this.$util.formatData(this.data,arg.param,this.itemParam.param);
Object.assign(arg.param,_param);
}
if (this.itemParam.parentdata) {
let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
Object.assign(arg.param,_parentdata);
}
return true;
}
......
......@@ -293,11 +293,12 @@ export class Util {
*
* @static
* @param {any} arg 表单数据
* @param {any} parent 外层context或viewparams
* @param {any} params 附加参数
* @returns {any}
* @memberof Util
*/
public static formatData(arg: any, params: any): any {
public static formatData(arg: any,parent:any, params: any): any {
let _data: any = {};
Object.keys(params).forEach((name: string) => {
if (!name) {
......@@ -307,7 +308,13 @@ export class Util {
if (value && value.startsWith('%') && value.endsWith('%')) {
const key = value.substring(1, value.length - 1);
if (arg && arg.hasOwnProperty(key)) {
value = (arg[key] !== null && arg[key] !== undefined) ? arg[key] : null;
if(arg[key] !== null && arg[key] !== undefined){
value = arg[key];
}else if(parent[key] !== null && parent[key] !== undefined){
value = parent[key];
}else{
value = null;
}
} else {
value = null;
}
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册