import { Vue, Component, Prop } from 'vue-property-decorator'; import { DataTypes, ModelTool, Util } from '@ibizstudio/runtime'; import { IPSAppCodeList, IPSAppDataEntity, IPSAppDEField, IPSAppDEView, IPSAppView, IPSDEGrid, IPSDEGridColumn, IPSDEGridEditItem, IPSDEGridFieldColumn, IPSDEUIAction, IPSEditor } from '@ibizstudio/runtime'; @Component({}) export class AppDefaultGridColumn extends Vue { /** * 表格列实例 * * @type {IBizGridColumnModel} * @memberof AppDefaultGridColumn */ @Prop() columnInstance!: IPSDEGridColumn; /** * 表格实例 * * @type {IBizGridColumnModel} * @memberof AppDefaultGridColumn */ @Prop() gridInstance!: IPSDEGrid; /** * 当前行 * * @type {*} * @memberof AppDefaultGridColumn */ @Prop() row!: any; /** * 当前行下标 * * @type {number} * @memberof AppDefaultGridColumn */ @Prop() index!: number; /** * 应用上下文 * * @type {*} * @memberof AppDefaultGridColumn */ @Prop() declare context: any; /** * 视图参数 * * @type {*} * @memberof AppDefaultGridColumn */ @Prop() declare viewparams: any; /** * 界面UI服务对象 * * @type {*} * @memberof AppDefaultGridColumn */ @Prop() appUIService!: any; /** * 绘制 * * @memberof AppDefaultGridColumn */ render() { const uiAction: IPSDEUIAction | null= (this.columnInstance as IPSDEGridFieldColumn).getPSDEUIAction(); if (uiAction && uiAction.uIActionTag) { return ( { this.onClick($event) }}> {this.renderGridColumn()} ) } else { return this.renderGridColumn() } } /** * 绘制表格列 * * @memberof AppDefaultGridColumn */ renderGridColumn() { const columnModel: IPSDEGridFieldColumn = this.columnInstance as IPSDEGridFieldColumn; const { cLConvertMode, enableLinkView, name } = columnModel; const codeList: IPSAppCodeList | null = columnModel.getPSAppCodeList(); if (codeList && cLConvertMode == "FRONT") { // 代码表 return ( ) } else if (enableLinkView && columnModel.getLinkPSAppView()) { // 链接视图 const linkView: IPSAppView = columnModel.getLinkPSAppView() as IPSAppView; let view: any = { viewname: 'app-view-shell', height: linkView.height, width: linkView.width, title: linkView.title, isRedirectView: linkView.redirectView ? true : false, placement: linkView.openMode ? linkView.openMode : '', viewpath: linkView.modelFilePath, } Object.defineProperty(view,'viewModel', { enumerable: false, writable: true, value: linkView }); this.handleLinkViewParams(linkView, view); return this.renderLinkView(linkView, view); } else { //常规显示 return this.renderDefault(); } } /** * 计算路由参数 * * @param linkView 链接视图 * @param view 模型 * @param entity 链接视图实体 */ handleLinkViewParams(linkView: IPSAppView, view: any) { const entity: IPSAppDataEntity = linkView.getPSAppDataEntity() as IPSAppDataEntity; //获取父关系路由参数 let tempDeResParameters: any[] = []; //视图本身路由参数 let tempParameters: any[] = []; if (entity && entity.codeName) { tempDeResParameters = Util.formatAppDERSPath(this.context, (linkView as IPSAppDEView).getPSAppDERSPaths()); tempParameters.push({ pathName: Util.srfpluralize(entity.codeName).toLowerCase(), parameterName: entity.codeName.toLowerCase() }); tempParameters.push({ pathName: (linkView as IPSAppDEView).getPSDEViewCodeName()?.toLowerCase(), parameterName: (linkView as IPSAppDEView).getPSDEViewCodeName()?.toLowerCase() }); } else { tempParameters.push({ pathName: linkView.codeName?.toLowerCase(), parameterName: linkView.codeName?.toLowerCase() }); } Object.assign(view, { parameters: tempParameters, deResParameters: tempDeResParameters }) } /** * 绘制常规显示内容 * * @memberof AppDefaultGridColumn */ renderDefault() { const editItem: IPSDEGridEditItem = ModelTool.getGridItemByCodeName(this.columnInstance.codeName, this.gridInstance) as IPSDEGridEditItem; const editor: IPSEditor | null = editItem?.getPSEditor(); const appDEField: IPSAppDEField = (editItem ? editItem.getPSAppDEField() : (this.columnInstance as IPSDEGridFieldColumn).getPSAppDEField()) as IPSAppDEField; const { stdDataType, precision, valueFormat } = appDEField; const name = this.columnInstance.name; if (editor && editor.editorType) { return ( ) } else if (valueFormat && valueFormat != '%1$s') { return ( ) } else if (stdDataType && DataTypes.toString(stdDataType) && (DataTypes.toString(stdDataType) == "FLOAT" || DataTypes.toString(stdDataType) == "CURRENCY" || DataTypes.toString(stdDataType) == "DECIMAL")) { return ( ) } else { return ( {this.row[name]} ) } } /** * 绘制链接视图内容 * * @memberof AppDefaultGridColumn */ renderLinkView(linkView: IPSAppView,view: any) { const linkViewEntity: IPSAppDataEntity | null = linkView.getPSAppDataEntity(); const editInstance: IPSEditor = (ModelTool.getGridItemByCodeName(this.columnInstance.codeName, this.gridInstance) as IPSDEGridEditItem)?.getPSEditor() as IPSEditor; const name = this.columnInstance.name.toLowerCase(); let tempContext: any = Util.deepCopy(this.context); if (view.viewpath) { Object.assign(tempContext, { viewpath: view.viewpath }); } let tempViewParam: any = Util.deepCopy(this.viewparams); return ( {editInstance && editInstance.editorType ? : {this.row[name]} } ) } /** * 链接点击 * * @param {*} row 当前行数据 * @param {*} tag 标识 * @param {*} $event 点击Event * @memberof AppDefaultGridColumn */ onClick($event: any) { this.$emit("uiAction", $event); } }