提交 24931140 编写于 作者: KK's avatar KK

update 编辑器 导航上下文、导航参数

上级 2f519bf9
...@@ -79,6 +79,39 @@ ...@@ -79,6 +79,39 @@
*/ */
@Prop() public type!: string; @Prop() public type!: string;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateParam?: any;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateContext?: any;
/**
* 应用上下文
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected context?: any;
/**
* 是否缓存
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: true }) protected isCache?: boolean;
public created() { public created() {
if (this.tag && this.type) { if (this.tag && this.type) {
if (Object.is(this.type, "dynamic")) { if (Object.is(this.type, "dynamic")) {
...@@ -91,7 +124,12 @@ ...@@ -91,7 +124,12 @@
this.options = []; this.options = [];
}); });
} else { } else {
this.options = this.$store.getters.getCodeListItems(this.tag); // 处理导航参数、上下文参数
let _context: any = {};
let _queryParam: any = {};
Object.assign(_context,this.context,this.navigateContext);
Object.assign(_queryParam,this.navigateParam);
this.options = this.$store.getters.getCodeListItems(this.tag ,this.isCache, { ..._context }, _queryParam);
} }
} }
} }
......
...@@ -20,250 +20,270 @@ import { Subject, Subscription } from "rxjs"; ...@@ -20,250 +20,270 @@ import { Subject, Subscription } from "rxjs";
@Component({}) @Component({})
export default class AppMobMpicker extends Vue { export default class AppMobMpicker extends Vue {
/** /**
* 表单数据 * 表单数据
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
@Prop() public data!: any; @Prop() public data!: any;
/**
* 是否启用
*
* @type {boolean}
* @memberof AppMobMpicker
*/
@Prop() public disabled?: boolean;
/** /**
* 是否启用 * 值
* *
* @type {boolean} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
@Prop() public disabled?: boolean; @Prop() public value?: any;
/** /**
* 值 * 源数组
* * @type {any[]}
* @type {*} * @memberof AppMobMpicker
* @memberof AppMobMpicker */
*/ public items: any[] = [];
@Prop() public value?: any;
/** /**
* 源数组 * 属性项名称
* @type {any[]} *
* @memberof AppMobMpicker * @type {string}
*/ * @memberof AppMobMpicker
public items: any[] = []; */
@Prop() public name!: string;
/** /**
* 属性项名称 * 视图上下文
* *
* @type {string} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
@Prop() public name!: string; @Prop() public context!: any;
/** /**
* 视图上下文 * 视图参数
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
@Prop() public context!: any; @Prop() public viewparams!: any;
/** /**
* 视图参数 * 视图参数(如:视图name,title,width,height)
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
@Prop() public viewparams!: any; @Prop() public pickupView?: any;
/** /**
* 视图参数(如:视图name,title,width,height) * 导航参数
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppSelect
*/ */
@Prop() public pickupView?: any; @Prop({ default: {} }) protected navigateParam?: any;
/** /**
* 值 * 导航上下文
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppSelect
*/ */
get curValue() { @Prop({ default: {} }) protected navigateContext?: any;
if (this.value) {
return JSON.parse(this.value);
}
return [];
}
/** /**
* 删除 * 值
* *
* @type {*} * @type {*}
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
public remove(index: number) { get curValue() {
let datas: any[] = JSON.parse(this.value); if (this.value) {
datas.splice(index, 1); return JSON.parse(this.value);
if (this.name) { }
this.$emit("formitemvaluechange", { return [];
name: this.name,
value: datas.length > 0 ? JSON.stringify(datas) : null
});
} }
}
/** /**
* 打开视图 * 删除
*/ *
public openView($event: any): void { * @type {*}
if (this.disabled) { * @memberof AppMobMpicker
return; */
} public remove(index: number) {
// 公共参数处理 let datas: any[] = JSON.parse(this.value);
let data: any = {}; datas.splice(index, 1);
const bcancel: boolean = this.handlePublicParams(data); if (this.name) {
if (!bcancel) { this.$emit("formitemvaluechange", {
return; name: this.name,
value: datas.length > 0 ? JSON.stringify(datas) : null
});
}
} }
// 参数处理
const view = { ...this.pickupView }; /**
let _context = data.context; * 打开视图
let _param = data.param; */
// 判断打开方式 public openView($event: any): void {
if (view.placement && !Object.is(view.placement, "")) { if (this.disabled) {
if (Object.is(view.placement, "POPOVER")) { return;
this.openPopOver($event, view, _context, data); }
// 公共参数处理
let data: any = {};
const bcancel: boolean = this.handlePublicParams(data);
if (!bcancel) {
return;
}
// 参数处理
const view = { ...this.pickupView };
let _context = data.context;
let _param = data.param;
// 判断打开方式
if (view.placement && !Object.is(view.placement, "")) {
if (Object.is(view.placement, "POPOVER")) {
this.openPopOver($event, view, _context, data);
} else {
this.openDrawer(view, _context, data);
}
} else { } else {
this.openDrawer(view, _context, data); this.openPopupModal(view, _context, _param);
} }
} else {
this.openPopupModal(view, _context, _param);
} }
}
/**
* 模态模式打开视图
*
* @private
* @param {*} view
* @param {*} data
* @memberof AppMobMpicker
*/
private async openPopupModal(view: any, context: any, param: any): Promise<any> {
const result: any = await this.$appmodal.openModal(view, context, param);
if (result || Object.is(result.ret, 'OK')) {
this.openViewClose(result);
}
}
/** /**
* 模态模式打开视图 * 气泡卡片模式打开
* *
* @private * @private
* @param {*} $event
* @param {*} view * @param {*} view
* @param {*} data * @param {*} data
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
private async openPopupModal(view: any, context: any, param: any): Promise<any> { private openPopOver($event: any, view: any, context: any, param: any): void {
const result: any = await this.$appmodal.openModal(view, context, param); // let container: Subject<any> = this.$apppopover.openPop($event, view, context, param);
if (result || Object.is(result.ret, 'OK')) { // container.subscribe((result: any) => {
this.openViewClose(result); // if (!result || !Object.is(result.ret, 'OK')) {
} // return;
// }
// this.openViewClose(result);
// });
} }
/** /**
* 气泡卡片模式打开 * 抽屉模式打开视图
* *
* @private * @private
* @param {*} $event * @param {*} view
* @param {*} view * @param {*} data
* @param {*} data * @memberof AppMobMpicker
* @memberof AppMobMpicker */
*/ private async openDrawer(view: any, context: any, param: any): Promise<any> {
private openPopOver($event: any, view: any, context: any, param: any): void { let container: Subject<any> = await this.$appdrawer.openDrawer(
// let container: Subject<any> = this.$apppopover.openPop($event, view, context, param); view,
// container.subscribe((result: any) => { context,
// if (!result || !Object.is(result.ret, 'OK')) { param
// return; );
// } container.subscribe((result: any) => {
// this.openViewClose(result); if (!result || !Object.is(result.ret, "OK")) {
// }); return;
} }
this.openViewClose(result);
/** });
* 抽屉模式打开视图 }
*
* @private
* @param {*} view
* @param {*} data
* @memberof AppMobMpicker
*/
private async openDrawer(view: any, context: any, param: any): Promise<any> {
let container: Subject<any> = await this.$appdrawer.openDrawer(
view,
context,
param
);
container.subscribe((result: any) => {
if (!result || !Object.is(result.ret, "OK")) {
return;
}
this.openViewClose(result);
});
}
/**
* 独立里面弹出
*
* @private
* @param {string} url
* @memberof AppMobMpicker
*/
private openPopupApp(url: string): void {
window.open(url, "_blank");
}
/** /**
* 公共参数处理 * 独立里面弹出
* *
* @param {*} arg * @private
* @returns * @param {string} url
* @memberof AppMobMpicker * @memberof AppMobMpicker
*/ */
public handlePublicParams(arg: any): boolean { private openPopupApp(url: string): void {
// if (!this.itemParam) { window.open(url, "_blank");
// return true; }
// }
// if (!this.data) {
// this.$notify({ type: "danger", message: "表单数据异常!" });
// 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,this.itemParam.context);
// Object.assign(arg.context, {});
// }
// if (this.itemParam.param) {
// let _param = this.$util.formatData(this.data,this.itemParam.param);
// Object.assign(arg.param, {});
// }
// if (this.itemParam.parentdata) {
// let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
// Object.assign(arg.param, {});
// }
return true;
}
/** /**
* 打开页面关闭 * 公共参数处理
* *
* @param {*} result * @param {*} arg
* @memberof AppMobMpicker * @returns
*/ * @memberof AppMobMpicker
public openViewClose(result: any) { */
let datas: any = []; public handlePublicParams(arg: any): boolean {
if (result.datas && Array.isArray(result.datas)) { // if (!this.itemParam) {
result.datas.forEach((data: any) => { // return true;
datas.push({ text: data.srfmajortext, value: data.srfkey }); // }
}); // if (!this.data) {
// this.$notify({ type: "danger", message: "表单数据异常!" });
// return false;
// }
// 合并表单参数
let _context: any = {};
let _params: any = {};
Object.assign(_context,this.context,this.navigateContext);
Object.assign(_params,this.viewparams,this.navigateParam);
arg.param = _params;
arg.context = _context;
// 附加参数处理
// if (this.itemParam.context) {
// let _context = this.$util.formatData(this.data,this.itemParam.context);
// Object.assign(arg.context, {});
// }
// if (this.itemParam.param) {
// let _param = this.$util.formatData(this.data,this.itemParam.param);
// Object.assign(arg.param, {});
// }
// if (this.itemParam.parentdata) {
// let _parentdata = this.$util.formatData(this.data,this.itemParam.parentdata);
// Object.assign(arg.param, {});
// }
return true;
} }
if (this.name) { /**
this.$emit("formitemvaluechange", { * 打开页面关闭
name: this.name, *
value: datas.length > 0 ? JSON.stringify(datas) : null * @param {*} result
}); * @memberof AppMobMpicker
*/
public openViewClose(result: any) {
let datas: any = [];
if (result.datas && Array.isArray(result.datas)) {
result.datas.forEach((data: any) => {
datas.push({ text: data.srfmajortext, value: data.srfkey });
});
}
if (this.name) {
this.$emit("formitemvaluechange", {
name: this.name,
value: datas.length > 0 ? JSON.stringify(datas) : null
});
}
} }
}
} }
</script> </script>
......
...@@ -168,6 +168,22 @@ export default class AppPicker extends Vue { ...@@ -168,6 +168,22 @@ export default class AppPicker extends Vue {
*/ */
@Model('change') public value?: any; @Model('change') public value?: any;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateParam?: any;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateContext?: any;
/** /**
* 当前值 * 当前值
* *
...@@ -686,8 +702,12 @@ export default class AppPicker extends Vue { ...@@ -686,8 +702,12 @@ export default class AppPicker extends Vue {
return false; return false;
} }
// 合并表单参数 // 合并表单参数
arg.param = JSON.parse(JSON.stringify(this.viewparams)); let _context: any = {};
arg.context = JSON.parse(JSON.stringify(this.context)); let _params: any = {};
Object.assign(_context,this.context,this.navigateContext);
Object.assign(_params,this.viewparams,this.navigateParam);
arg.param = JSON.parse(JSON.stringify(_params));
arg.context = JSON.parse(JSON.stringify(_context));
// 附加参数处理 // 附加参数处理
if (this.itemParam.context) { if (this.itemParam.context) {
// let _context = this.$util.formatData(this.data,this.itemParam.context); // let _context = this.$util.formatData(this.data,this.itemParam.context);
......
...@@ -144,6 +144,22 @@ export default class AppSelectDropDown extends Vue { ...@@ -144,6 +144,22 @@ export default class AppSelectDropDown extends Vue {
*/ */
@Model('change') public value?: any; @Model('change') public value?: any;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateParam?: any;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateContext?: any;
/** /**
* 当前值 * 当前值
* *
...@@ -632,8 +648,12 @@ export default class AppSelectDropDown extends Vue { ...@@ -632,8 +648,12 @@ export default class AppSelectDropDown extends Vue {
return false; return false;
} }
// 合并表单参数 // 合并表单参数
arg.param = JSON.parse(JSON.stringify(this.viewparams)); let _context: any = {};
arg.context = JSON.parse(JSON.stringify(this.context)); let _params: any = {};
Object.assign(_context,this.context,this.navigateContext);
Object.assign(_params,this.viewparams,this.navigateParam);
arg.param = JSON.parse(JSON.stringify(_params));
arg.context = JSON.parse(JSON.stringify(_context));
// 附加参数处理 // 附加参数处理
if (this.itemParam.context) { if (this.itemParam.context) {
......
...@@ -118,6 +118,22 @@ export default class AppSelect extends Vue { ...@@ -118,6 +118,22 @@ export default class AppSelect extends Vue {
*/ */
@Prop({ default: {} }) protected context?: any; @Prop({ default: {} }) protected context?: any;
/**
* 导航参数
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateParam?: any;
/**
* 导航上下文
*
* @type {*}
* @memberof AppSelect
*/
@Prop({ default: {} }) protected navigateContext?: any;
/** /**
* 是否缓存 * 是否缓存
* *
...@@ -174,7 +190,12 @@ export default class AppSelect extends Vue { ...@@ -174,7 +190,12 @@ export default class AppSelect extends Vue {
if (!this.isCached) { if (!this.isCached) {
Loading.show(this.$t('app.loadding')); Loading.show(this.$t('app.loadding'));
} }
let response: any = await this.codeListService.getItems(this.tag, this.isCache, { ...this.context }, this.queryParam); // 处理导航参数、上下文参数
let _context: any = {};
let _queryParam: any = {};
Object.assign(_context,this.context,this.navigateContext);
Object.assign(_queryParam,this.queryParam,this.navigateParam);
let response: any = await this.codeListService.getItems(this.tag, this.isCache, { ..._context }, _queryParam);
if (!this.isCached) { if (!this.isCached) {
Loading.hidden(); Loading.hidden();
} }
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册