app-grid-base.tsx 41.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
import {
    IPSDEGridColumn,
    IPSDEGridEditItem,
    IPSDEGridUAColumn,
    IPSDEUIAction,
    IPSEditor,
    IPSSysPFPlugin,
    IPSUIActionGroupDetail,
    IPSAppDEGridView,
    IPSDEGridGroupColumn,
    IPSDEGridFieldColumn
} from '@ibiz/dynamic-model-api';
import { throttle, ModelTool, Util } from 'ibiz-core';
import { Prop, Watch, Emit } from 'vue-property-decorator';
import { GridControlBase } from '../../../widgets';

/**
 * 表格部件基类
 *
 * @export
 * @class AppGridBase
 * @extends {GridControlBase}
 */
export class AppGridBase extends GridControlBase {
    /**
     * 部件动态参数
     *
     * @memberof AppGridBase
     */
    @Prop() public declare dynamicProps: any;

    /**
     * 部件静态参数
     *
     * @memberof AppGridBase
     */
    @Prop() public declare staticProps: any;

    /**
     * 监听动态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof AppGridBase
     */
    @Watch('dynamicProps', {
        immediate: true,
    })
    public onDynamicPropsChange(newVal: any, oldVal: any) {
        if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
            super.onDynamicPropsChange(newVal, oldVal);
        }
    }

    /**
     * 监听静态参数变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof AppGridBase
     */
    @Watch('staticProps', {
        immediate: true,
    })
    public onStaticPropsChange(newVal: any, oldVal: any) {
        if (newVal && !Util.isFieldsSame(newVal, oldVal)) {
            super.onStaticPropsChange(newVal, oldVal);
        }
    }

71 72 73 74 75 76
    public mounted() {
        setTimeout(() => {
            this.initEmptyColumn();
        });
    }
    
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
    /**
     * 销毁视图回调
     *
     * @memberof AppGridBase
     */
    public destroyed() {
        this.ctrlDestroyed();
    }

    /**
     * 部件事件
     *
     * @param {{ controlname: string; action: string; data: any }} { controlname 部件名称, action 事件名称, data 事件参数 }
     * @memberof AppGridBase
     */
    @Emit('ctrl-event')
    public ctrlEvent({ controlname, action, data }: { controlname: string; action: string; data: any }): void { }

    /**
     * 操作列动画
     *
     * @param {show: boolean}
     * @memberof AppGridBase
     */
    public showPoptip(show: boolean) {
        let cls: string = show ? "ivu-poptip app-control-grid__filter filter__tip--show" : "ivu-poptip app-control-grid__filter filter__tip--hide";
        (this.$refs.pageColumn as any).$el.setAttribute("class", cls);
    }

    /**
     * 计算表格行样式
     *
     * @memberof AppGridBase
     */
    public calcGridRowStyle(row: any, rowIndex: number) {
        if (this.ctrlTriggerLogicMap.get('calcrowstyle')) {
            return this.ctrlTriggerLogicMap.get('calcrowstyle').executeUILogic({ arg: { row, rowIndex } });
        }
    }

    /**
     * 计算表格单元格样式
     *
     * @memberof AppGridBase
     */
    public calcGridCellStyle(row: any, column: any, rowIndex: number, columnIndex: number) {
        if (this.ctrlTriggerLogicMap.get('calccellstyle')) {
            return this.ctrlTriggerLogicMap.get('calccellstyle').executeUILogic({ arg: { row, column, rowIndex, columnIndex } });
        }
    }

    /**
     * 计算表格头行样式
     *
     * @memberof AppGridBase
     */
    public calcGridHeaderRowStyle(row: any, rowIndex: number) {
        if (this.ctrlTriggerLogicMap.get('calcheaderrowstyle')) {
            return this.ctrlTriggerLogicMap.get('calcheaderrowstyle').executeUILogic({ arg: { row, rowIndex } });
        }
    }

    /**
     * 计算表格头单元格样式
     *
     * @memberof AppGridBase
     */
    public calcGridHeaderCellStyle(row: any, column: any, rowIndex: number, columnIndex: number) {
        if (this.ctrlTriggerLogicMap.get('calcheadercellstyle')) {
            return this.ctrlTriggerLogicMap.get('calcheadercellstyle').executeUILogic({ arg: { row, column, rowIndex, columnIndex } });
        }
    }

    /**
     * 计算表格头单元格样式表
     *
     * @memberof AppGridBase
     */
    public calcGridHeaderCellClassName(row: any, column: any, rowIndex: number, columnIndex: number) {
        const columnInstance: any = this.controlInstance.findPSDEGridColumn(column.property);
        if (columnInstance && columnInstance.getHeaderPSSysCss?.()?.cssName) {
            return columnInstance.getHeaderPSSysCss().cssName
        }
    }

    /**
     * 计算表格参数
     *
     * @memberof AppGridBase
     */
    public computeGridParams() {
        let options: any = {
            data: this.items,
            border: true,
            'high-light-current-row': this.controlInstance?.singleSelect,
            'show-header': !this.controlInstance.hideHeader && !Object.is(this.controlInstance.gridStyle, 'USER'),
            'row-class-name': ({ row, rowIndex }: any) => this.getRowClassName({ row, rowIndex }),
            'row-style': ({ row, rowIndex }: any) => this.calcGridRowStyle(row, rowIndex),
            'cell-style': ({ row, column, rowIndex, columnIndex }: any) =>
                this.calcGridCellStyle(row, column, rowIndex, columnIndex),
            'header-row-style': ({ row, rowIndex }: any) => this.calcGridHeaderRowStyle(row, rowIndex),
            'header-cell-style': ({ row, column, rowIndex, columnIndex }: any) =>
                this.calcGridHeaderCellStyle(row, column, rowIndex, columnIndex),
            'header-cell-class-name': (({row, column, rowIndex, columnIndex}: any) => this.calcGridHeaderCellClassName(row, column, rowIndex, columnIndex)),
            'cell-class-name': ({ row, column, rowIndex, columnIndex }: any) =>
                this.getCellClassName({ row, column, rowIndex, columnIndex }),
            "max-height": "100%",
            stripe: (this.controlInstance?.getParentPSModelObject?.() as IPSAppDEGridView)?.viewStyle == 'STYLE2' ? true : false,
        };
        const aggMode = this.controlInstance?.aggMode;
        //  支持排序
        if (!this.isNoSort) {
            Object.assign(options, {
                'default-sort': {
                    prop: this.minorSortPSDEF,
192
                    order: Object.is(this.minorSortDir, 'asc')
193
                        ? 'ascending'
194
                        : Object.is(this.minorSortDir, 'desc')
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245
                            ? 'descending'
                            : '',
                },
            });
        }
        //  支持表格聚合
        if (aggMode && aggMode != 'NONE' && !this.controlInstance.getAggPSLayoutPanel()) {
            Object.assign(options, {
                'show-summary': true,
                'summary-method': (param: any) => this.getSummaries(param),
            });
        }
        //  支持分组
        if (this.isEnableGroup) {
            Object.assign(options, {
                'span-method': ({ row, column, rowIndex, columnIndex }: any) =>
                    this.arraySpanMethod({ row, column, rowIndex, columnIndex }),
                'tree-props': {
                    children: 'children',
                    hasChildren: 'children && children.length>0 ? true : false',
                },
                'row-key': 'groupById',
            });
        }
        return options;
    }

    /**
     * 计算表格事件
     *
     * @memberof AppGridBase
     */
    public computeGridEvents() {
        let events: any = {
            'row-click': (row: any, column: any, event: any) => throttle(this.rowClick, [row, column, event], this),
            'row-dblclick': (row: any, column: any, event: any) => throttle(this.rowDBLClick, [row, column, event], this),
            'select': (selection: any, row: any) => throttle(this.select, [selection, row], this),
            'select-all': (selection: any) => throttle(this.selectAll, [selection], this),
        };
        //  支持排序
        if (!this.controlInstance?.noSort) {
            if (this.Environment && this.Environment.isPreviewMode) {
                return;
            }
            Object.assign(events, {
                'sort-change': ({ column, prop, order }: any) => this.onSortChange({ column, prop, order }),
            });
        }
        return events;
    }

246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
    /**
     * 获取内建行为权限
     *
     * @protected
     * @param {('add' | 'remove')} action
     * @return {*} 
     * @memberof AppGridBase
     */
    protected calcBuildInActionsAuth(action: 'add' | 'remove') {
        let state: boolean = false;
        const buildInActions: number = this.staticProps.buildInActions || 0;
        if (action == 'add') {
            if (
                buildInActions == 1 ||
                buildInActions == 3 ||
                buildInActions == 5 ||
                buildInActions == 7
            ) {
                state = true;
            }
        } else {
            if (
                buildInActions == 4 ||
                buildInActions == 5 ||
                buildInActions == 6 ||
                buildInActions == 7
            ) {
                state = true;
            }
        }
        return state;
    }

279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304
    /**
     * 绘制表格内容
     *
     * @param {*} h CreateElement对象
     * @memberof AppGridBase
     */
    public renderGridContent(h: any) {
        this.renderEmptyColumn = !this.allColumns.find((column: any) => {
            return column.columnType != 'GROUPGRIDCOLUMN' && column.show && Object.is(column.unit, 'STAR');
        });
        const cls = {'app-control-grid--rowactive': this.gridRowActiveMode == 1};
        return this.$createElement(
            'el-table',
            {
                props: this.computeGridParams(),
                on: this.computeGridEvents(),
                ref: `${this.realCtrlRefName}`,
                class: cls,
                scopedSlots: {
                    // 无数据插槽
                    empty: () => {
                        return this.renderEmptyDataTip();
                    }
                },
            },
            [
305
                !this.isSingleSelect && !this.localMode ? (
306 307
                    <el-table-column align='center' class-name="grid-column--selection" type='selection' width='64'></el-table-column>
                ) : null,
308
                this.renderMDCtrlActionColumn(),
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
                this.isEnableGroup ? (
                    <el-table-column
                        show-overflow-tooltip
                        prop='group'
                        label={this.$t('app.grid.group')}
                        min-width='80'
                        scopedSlots={{
                            default: (scope: any) => {
                                return <span>{scope.row.group}</span>;
                            },
                        }}
                    ></el-table-column>
                ) : null,
                this.renderGridColumns(this.allColumnsInstance),
                this.renderEmptyColumn ? <el-table-column class="grid-column--empty"></el-table-column> : null,
                this.renderSummaryPanel()
            ],
        );
    }

329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381
    /**
     * 渲染多数据部件行为列
     *
     * @return {*} 
     * @memberof AppGridBase
     */
    public renderMDCtrlActionColumn() {
        const showAdd = this.calcBuildInActionsAuth('add');
        const showRemove = this.calcBuildInActionsAuth('remove');
        if (!showAdd && !showRemove) {
            return null;
        }
        if (this.localMode) {
            return (
                <el-table-column align='center' class-name='grid-column__localaction' width='64' scopedSlots={{
                    header: ({ column, $index }: any) => {
                        return (
                            showAdd ?
                            <el-button
                                type='primary'
                                size='mini'
                                icon='el-icon-plus'
                                circle
                                on-click={() => {
                                    this.newRow([{}]);
                                }}>
                            </el-button> : null
                        )
                    },
                    default: ({ row, column, $index}: any) => {
                        return (
                            showRemove ?
                            <div class="grid-column__localaction__content">
                                <span class='grid-column__localaction__index'>{ $index + 1 }</span>
                                <el-button
                                    class='grid-column__localaction__remove'
                                    type='danger'
                                    size='mini'
                                    icon='el-icon-delete'
                                    circle
                                    on-click={() => {
                                        this.remove([row]);
                                    }}
                                ></el-button>
                            </div> : null
                        )
                    }
                }}>
                </el-table-column>
            )
        }
    }

382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954
    /**
     * 渲染聚合面板
     *
     * @memberof AppGridBase
     */
    public renderSummaryPanel() {
        const panel = this.controlInstance.getAggPSLayoutPanel();
        if (!panel) {
            return;
        }
        let { targetCtrlName, targetCtrlParam, targetCtrlEvent } = this.computeTargetCtrlData(panel, this.remoteData);
        return this.$createElement(targetCtrlName, { slot: 'append', props: targetCtrlParam, on: targetCtrlEvent, ref: panel.name });
    }

    /**
     * 绘制表格列
     *
     * @param {*} h CreateElement对象
     * @memberof AppGridBase
     */
    public renderGridColumns(allColumnsInstance: IPSDEGridColumn[]) {
        if (!allColumnsInstance || allColumnsInstance.length === 0) {
            return;
        }
        return allColumnsInstance.map((item: IPSDEGridColumn) => {
            //隐藏表格项
            if (item.hideDefault || item.hiddenDataItem || !this.getColumnState(item.name)) {
                return null;
            }
            const plugin: IPSSysPFPlugin = item.getPSSysPFPlugin() as IPSSysPFPlugin;
            if (plugin) {
                if (Object.is('fileDownload', plugin.pluginCode)) {
                  return this.renderDownloadColumn(item);
                }
                const pluginInstance: any = this.PluginFactory.getPluginInstance('CONTROLITEM', plugin.pluginCode);
                if (pluginInstance) {
                    return pluginInstance.renderCtrlItem(this.$createElement, item, this, null);
                }
            } else {
                if (item.columnType == 'UAGRIDCOLUMN') {
                    return this.renderUAColumn(item as IPSDEGridUAColumn);
                } else if (item.columnType == 'DEFGRIDCOLUMN') {
                    //  数据列
                    return this.renderGridColumn(item);
                } else if (item.columnType == 'GROUPGRIDCOLUMN') {
                    //分组列
                    return this.renderGroupGridColumn(item as IPSDEGridGroupColumn);
                }
            }
        });
    }

    /**
     * @description 绘制预置表格列下载列插件
     * @param {IPSDEGridColumn} column 表格列
     * @memberof AppGridBase
     */
    public renderDownloadColumn(column: IPSDEGridColumn) {
      const { name, codeName, enableRowEdit, width, caption, widthUnit, align, enableSort } = column;
      const editItem: IPSDEGridEditItem = ModelTool.getGridItemByCodeName(
          codeName,
          this.controlInstance,
      ) as IPSDEGridEditItem;
      const sysImage = column.getPSSysImage();
      let renderParams: any = {
          label: this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption),
          prop: name,
          align: align ? align.toLowerCase() : 'center',
          sortable: !this.controlInstance.noSort && enableSort ? 'custom' : false,
      };

      if (widthUnit && widthUnit != 'STAR') {
          renderParams['width'] = width;
      } else {
          renderParams['min-width'] = width;
      }
      return this.$createElement('el-table-column', {
          props: renderParams,
          scopedSlots: {
              default: (scope: any) => {
                  return this.actualIsOpenEdit && enableRowEdit && editItem
                      ? this.renderOpenEditItem(column, scope)
                      : this.renderDownload(column, scope);
              },
              header: () => {
                  this.allColumnsInstance; // 别删,触发表格头刷新用
                  return (
                      <span class='grid-column__header'>
                          {sysImage ? <i class={sysImage?.cssClass} style='margin-right: 4px;'></i> : null}
                          {this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption)}
                      </span>
                  );
              },
          },
      });
    }

    /**
     * @description 绘制文件下载
     * @param {IPSDEGridColumn} item 列实例
     * @param {*} scope 插槽
     * @return {*} 
     * @memberof AppGridBase
     */
    renderDownload(item: IPSDEGridColumn, scope: any) {
      const fileList: any[] = scope.row[item.dataItemName] ? JSON.parse(scope.row[item.dataItemName]) : [];
      return (
        fileList.map((file: any) => {
          return (
            <div>
              <a 
                target="_blank"
                class="grid-column--download"
                href={`${this.downloadUrl}/${file.id}`}>
                  {file.name}
              </a>
            </div>
          )
        })  
      )
    }

    /**
     * 绘制操作列
     *
     * @param {any} column 表格列实例
     * @memberof AppGridBase
     */
    public renderUAColumn(column: IPSDEGridUAColumn) {
        if (this.viewStyle == 'DEFAULT' && column.columnStyle == "EXPAND") {
            return this.renderDefaultUAColumn(column);
        } else {
            return this.renderStyle2UAColumn(column);
        }
    }

    /**
     * 绘制DEFAULT的操作列
     *
     * @param {any} column 表格列实例
     * @memberof AppGridBase
     */
    public renderDefaultUAColumn(column: IPSDEGridUAColumn) {
        const { name, caption, align, width, widthUnit } = column;
        //参数
        let renderParams: any = {
            'column-key': name,
            label: this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption),
            align: 'center',
            'class-name': 'grid-column--ua--default',
        };
        const sysImage = column.getPSSysImage();
        renderParams['width'] = 42;
        renderParams['fixed'] = 'right';
        //绘制
        return this.$createElement('el-table-column', {
            props: renderParams,
            scopedSlots: {
                default: (scope: any) => {
                    let offset = require('@popperjs/core/lib/modifiers/offset').default;
                    return <div class="grid-column--ua__content" on-mouseenter={(e: any) => {
                        let _offset = Object.assign({ options: { offset: [0, -48] } }, offset);
                        (this.$apppopover as any).openPopover2(e, () => this.renderActionButtons(column, scope), 'left', true, true, undefined, 48, "view-default grid-column--ua__popover", [_offset]);
                    }}>
                        <i class='el-icon-more popover__icon' ></i>
                    </div>
                },
                header: () => {
                    return (
                        <span class='grid-column--ua__header'>
                            {sysImage ? <i class={sysImage?.cssClass}></i> : null}
                            {this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption)}
                        </span>
                    );
                },
            },
        });
    }

    /**
     * 绘制操作列按钮组
     *
     * @param {any} _column 表格列实例
     * @param {row, column, $index} scope 插槽返回数据
     * @memberof AppGridBase
     */
    public renderActionButtons(_column: IPSDEGridUAColumn, scope: any) {
        const UIActionGroupDetails: Array<IPSUIActionGroupDetail> =
            _column.getPSDEUIActionGroup()?.getPSUIActionGroupDetails() || [];
        const { row, column, $index } = scope;
        if (UIActionGroupDetails.length > 0) {
            return (
                <div class='grid-column--ua'>
                    {UIActionGroupDetails.map((uiactionDetail: IPSUIActionGroupDetail, index: number) => {
                        const uiaction: IPSDEUIAction = uiactionDetail.getPSUIAction() as IPSDEUIAction;
                        const actionModel = row[uiaction.uIActionTag];
                        let columnClass = {};
                        if (uiactionDetail.actionLevel) {
                            Object.assign(columnClass, { [`srfactionlevel${uiactionDetail.actionLevel}`]: true });
                        }
                        if (index === 0) {
                            Object.assign(columnClass, { 'column--first': true });
                        } else {
                            Object.assign(columnClass, { 'column__divider': true });
                        }
                        if (actionModel?.disabled) {
                            Object.assign(columnClass, { 'column__content--disabled': true });
                        } else {
                            Object.assign(columnClass, { 'column__content--normal': true });
                        }
                        if (Util.isEmpty(actionModel) || actionModel.visabled) {
                            return <i-button
                                disabled={!Util.isEmpty(actionModel) && actionModel.disabled}
                                class={columnClass}
                                on-click={($event: any) => {
                                    throttle(this.handleActionButtonClick, [row, $event, _column, uiactionDetail], this);
                                }}
                            >
                                {uiactionDetail.showIcon ? <menu-icon item={uiaction} /> : null}
                                {uiactionDetail.showCaption ? <span class='column__content__caption'>{this.$tl(uiaction.getCapPSLanguageRes()?.lanResTag, uiaction.caption)}</span> : ''}
                            </i-button>
                        }
                    })}
                </div>
            );
        }
    }


    /**
     * 绘制STYLE2的操作列
     *
     * @param {any} column 表格列实例
     * @memberof AppGridBase
     */
    public renderStyle2UAColumn(column: IPSDEGridUAColumn) {
        const { name, caption, align, width, widthUnit } = column;
        //参数
        let renderParams: any = {
            'column-key': name,
            'class-name': 'grid-column--ua grid-column--ua--style2',
            label: this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption),
            align: align ? align.toLowerCase() : 'center',
        };
        const sysImage = column.getPSSysImage();
        if (widthUnit && widthUnit != 'STAR') {
            renderParams['width'] = width;
        } else {
            renderParams['min-width'] = width;
        }
        //视图样式2操作列需要悬浮  加fixed: right
        renderParams['fixed'] = 'right';
        //绘制
        return this.$createElement('el-table-column', {
            props: renderParams,
            scopedSlots: {
                default: (scope: any) => {
                    return this.renderActionModel(column, scope);
                },
                header: () => {
                    return (
                        <span class='grid-column--ua__header'>
                            {sysImage ? <i class={sysImage?.cssClass}></i> : null}
                            {this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption)}
                        </span>
                    );
                },
            },
        });
    }

    /**
     * 绘制操作列内容
     *
     * @param {any} _column 表格列实例
     * @param {row, column, $index} scope 插槽返回数据
     * @memberof AppGridBase
     */
    public renderActionModel(_column: IPSDEGridUAColumn, scope: any) {
        const UIActionGroupDetails: Array<IPSUIActionGroupDetail> =
            _column.getPSDEUIActionGroup()?.getPSUIActionGroupDetails() || [];
        const { row, column, $index } = scope;
        if (UIActionGroupDetails.length > 0) {
            return (
                <div class="grid-column--ua__content">
                    {UIActionGroupDetails.map((uiactionDetail: IPSUIActionGroupDetail, index: number) => {
                        const uiaction: IPSDEUIAction = uiactionDetail.getPSUIAction() as IPSDEUIAction;
                        const actionModel = row[uiaction.uIActionTag];
                        let columnClass = {};
                        if (index === 0) {
                            Object.assign(columnClass, { 'column--first': true });
                        } else {
                            Object.assign(columnClass, { 'column__divider': true });
                        }
                        if (actionModel?.disabled) {
                            Object.assign(columnClass, { 'column__content--disabled': true });
                        } else {
                            Object.assign(columnClass, { 'column__content--normal': true });
                        }
                        if (Util.isEmpty(actionModel) || actionModel.visabled) {
                            if (!uiactionDetail.showCaption) {
                                return (
                                    <span title={this.$tl(uiaction.getCapPSLanguageRes()?.lanResTag, uiaction.caption)}>
                                        <a
                                            class={columnClass}
                                            disabled={!Util.isEmpty(actionModel) && actionModel.disabled}
                                            on-click={($event: any) => {
                                                throttle(this.handleActionClick, [row, $event, _column, uiactionDetail], this);
                                            }}
                                        >
                                            {uiactionDetail.showIcon ? (
                                                    uiaction && uiaction.getPSSysImage()?.cssClass?
                                                <i
                                                    class={
                                                         uiaction.getPSSysImage()?.cssClass
                                                    }
                                                ></i>
                                                :uiaction && uiaction.getPSSysImage()?.imagePath?
                                                <img src={uiaction.getPSSysImage()?.imagePath} alt="" />:<i
                                                class='fa fa-save'
                                            ></i>
                                            ) : (
                                                ''
                                            )}
                                        </a>
                                    </span>
                                );
                            } else {
                                return (
                                    <a
                                        class={columnClass}
                                        disabled={!Util.isEmpty(actionModel) && actionModel.disabled}
                                        on-click={($event: any) => {
                                            throttle(this.handleActionClick, [row, $event, _column, uiactionDetail], this);
                                        }}
                                    >
                                        {uiactionDetail.showIcon ? (
                                            <i class={uiaction?.getPSSysImage?.()?.cssClass}></i>
                                        ) : (
                                            ''
                                        )}
                                        {uiactionDetail.showCaption ? this.$tl(uiaction.getCapPSLanguageRes()?.lanResTag, uiaction.caption) : ''}
                                    </a>
                                );
                            }
                        }
                    })}
                </div>
            );
        }
    }

    /**
     * 绘制数据列
     *
     * @param {any} column 表格列实例
     * @memberof AppGridBase
     */
    public renderGridColumn(column: IPSDEGridColumn) {
        const { name, codeName, enableRowEdit, width, caption, widthUnit, align, enableSort } = column;
        const editItem: IPSDEGridEditItem = ModelTool.getGridItemByCodeName(
            codeName,
            this.controlInstance,
        ) as IPSDEGridEditItem;
        const sysImage = column.getPSSysImage();
        let renderParams: any = {
            label: this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption),
            prop: name,
            align: align ? align.toLowerCase() : 'center',
            sortable: !this.controlInstance.noSort && enableSort ? 'custom' : false,
        };
        if (widthUnit && widthUnit != 'STAR') {
            renderParams['width'] = width;
        } else {
            renderParams['min-width'] = width;
        }
        return this.$createElement('el-table-column', {
            props: renderParams,
            scopedSlots: {
                default: (scope: any) => {
                    return this.actualIsOpenEdit && enableRowEdit && editItem
                        ? this.renderOpenEditItem(column, scope)
                        : this.renderColumn(column, scope);
                },
                header: () => {
                    this.allColumnsInstance; // 别删,触发表格头刷新用
                    return (
                        <span class='grid-column__header'>
                            {sysImage ? <i class={sysImage?.cssClass}></i> : null}
                            {this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption)}
                        </span>
                    );
                },
            },
        });
    }

    /**
     * 绘制分组列
     *
     * @param {IPSDEGridGroupColumn} column 表格分组列实例对象
     * @memberof AppGridBase
     */
    public renderGroupGridColumn(column: IPSDEGridGroupColumn): any {
        const { name, width, caption, widthUnit, align, enableSort } = column;
        let renderParams: any = {
            'show-overflow-tooltip': true,
            label: this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption),
            prop: name,
            align: align ? align.toLowerCase() : 'center',
            sortable: !this.controlInstance.noSort && enableSort ? 'custom' : false,
        };
        const sysImage = column.getPSSysImage();
        if (widthUnit && widthUnit != 'STAR') {
            renderParams['width'] = width;
        } else {
            renderParams['min-width'] = width;
        }
        return this.$createElement('el-table-column', {
            props: renderParams,
            scopedSlots: {
                header: () => {
                    return (
                        <span class='grid-column__header'>
                            {sysImage ? <i class={sysImage?.cssClass}></i> : null}
                            {this.$tl(column.getCapPSLanguageRes()?.lanResTag, caption)}
                        </span>
                    );
                },
            },
        }, this.renderGridColumns(column.getPSDEGridColumns() || []));
    }

    /**
     * 绘制分页栏
     *
     * @param {*} h CreateElement对象
     * @memberof AppGridBase
     */
    public renderPagingBar(h: any) {
        // 表格列筛选
        let columnPopTip;
        // 分页显示文字
        let pageText = <span>{this.$t('app.dataview.sum')}&nbsp;{this.totalRecord}&nbsp;{this.$t('app.dataview.data')}</span>
        if (this.viewStyle == 'STYLE2') {
            pageText = <span>
                &nbsp; {this.$t('app.grid.show')}&nbsp;
                {this.items.length > 0 ? 1 : (this.curPage - 1) * this.limit + 1}&nbsp;-&nbsp;
                {this.totalRecord > this.curPage * this.limit ? this.curPage * this.limit : this.totalRecord}&nbsp;
                {this.$t('app.dataview.data')}{this.$t('app.dataview.sum')}&nbsp;{this.totalRecord}&nbsp;{this.$t('app.dataview.data')}
            </span>
            columnPopTip = <poptip transfer placement='top-start' class='page-column'>
                <i-button icon='md-menu'>{this.$t('app.grid.choicecolumns')}</i-button>
                <div slot='content'>
                    {this.allColumns.map((col: any) => {
                        return (
                            col.columnType != "UAGRIDCOLUMN" ?
                                <div>
                                    <el-checkbox
                                        key={col.name}
                                        v-model={col.show}
                                        on-change={this.onColChange.bind(this)}
                                    >
                                        {col.label}
                                    </el-checkbox>
                                </div> : null
                        );
                    })}
                </div>
            </poptip>
        } else {
            pageText = <span>{this.$t('app.dataview.sum')}&nbsp;{this.totalRecord}&nbsp;{this.$t('app.dataview.data')}</span>
        }
        return this.items?.length > 0 ? (
            <row class='app-control-grid__pagination control-footer'>
                <page
                    class='pagination--pull-right'
                    on-on-change={($event: any) => this.pageOnChange($event)}
                    on-on-page-size-change={($event: any) => this.onPageSizeChange($event)}
                    transfer={true}
                    total={this.totalRecord}
                    show-sizer
                    current={this.curPage}
                    page-size={this.limit}
                    page-size-opts={[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]}
                    show-elevator
                    show-total
                >
                    {this.controlInstance.enableColFilter ? columnPopTip : null}
                    {this.renderBatchToolbar()}
                    <span>
                        <i-button icon='md-refresh' class="pagination__refresh" title={this.$t('app.grid.refresh')} on-click={() => throttle(this.pageRefresh, [], this)}></i-button>
                    </span>
                    {pageText}
                </page>
            </row>
        ) : null;
    }

    /**
     * 绘制表格列过滤
     *
     * @memberof AppGridBase
     */
    public renderColumnFilter() {
        if (this.viewStyle == 'DEFAULT') {
            let ifShow = !!this.allColumnsInstance.find((item: IPSDEGridColumn) => item.columnType == 'UAGRIDCOLUMN' && item.columnStyle == 'EXPAND');
            if (!ifShow) {
                return
            }
            return <poptip transfer ref='pageColumn' placement='bottom-end' class='app-control-grid__filter' on-on-popper-show={() => this.showPoptip(true)} on-on-popper-hide={() => this.showPoptip(false)}>
                <icon type="md-options" />
                <div slot='content'>
                    <draggable value={this.allColumns} animation={300} handle='.handle-icon' on-change={({ moved }: any) => {
                        Util.changeIndex(this.allColumns, moved.oldIndex, moved.newIndex);
                        Util.changeIndex(this.allColumnsInstance, moved.oldIndex, moved.newIndex);
                    }}>
                        {this.allColumns.map((col: any) => {
                            return (
                                col.columnType != "UAGRIDCOLUMN" ?
                                    <div class='column--filter-item'>
                                        <el-checkbox
                                            key={col.name}
                                            v-model={col.show}
                                            on-change={this.onColChange.bind(this)}
                                        >
                                            {col.label}
                                        </el-checkbox>
                                        <icon type="md-menu handle-icon" />
                                    </div> : null
                            );
                        })}
                    </draggable>
                </div>
            </poptip>
        }
    }

    /**
     * 行编辑绘制
     *
     * @param {any} item 表格列实例
     * @param {row,column, $index} scope 插槽返回数据
     * @memberof AppGridBase
     */
    public renderOpenEditItem(item: IPSDEGridColumn, scope: any) {
        const editItem: IPSDEGridEditItem = ModelTool.getGridItemByCodeName(
            item.codeName,
            this.controlInstance,
        ) as IPSDEGridEditItem;
        let editor: IPSEditor | null = editItem?.getPSEditor();
        if (!editor) {
            return null;
        }
        const valueFormat = (item as IPSDEGridFieldColumn).valueFormat;
        const { row, column, $index } = scope;
        return (
            <app-form-item gridError={this.gridItemsModel[$index]?.[column.property]?.error}>
                <app-default-editor
                    name={ModelTool.getGridDataColName(item as IPSDEGridFieldColumn)}
                    editorInstance={editor}
                    ref={editor.name}
                    parentItem={editItem}
                    value={row[editor?.name]}
                    disabled={this.getColumnDisabled(row, editor?.name)}
                    context={this.context}
                    contextData={row}
                    viewparams={this.viewparams}
                    valueFormat={valueFormat}
                    service={this.service}
                    on-change={(value: any) => {
                        this.onGridItemValueChange(row, value, $index);
                    }}
955 956 957 958 959 960 961 962 963
                    on-blur={(value: any) => {
                        this.gridDetailBlur(row, value, $index);
                    }}
                    on-focus={(value: any) => {
                        this.gridDetailFocus(row, value, $index);
                    }}
                    on-click={(value: any) => {
                        this.gridDetailClick(row, value, $index);
                    }}
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042
                />
            </app-form-item>
        );
    }

    /**
     * 绘制数据表格列
     *
     * @memberof AppGridBase
     */
    public renderColumn(item: IPSDEGridColumn, scope: any) {
        return (
            <app-grid-column
                row={scope.row}
                index={scope.$index}
                columnInstance={item}
                gridInstance={this.controlInstance}
                context={this.context}
                modelService={this.modelService}
                viewparams={this.viewparams}
                appUIService={this.appUIService}
                on-uiAction={($event: any) => this.columnUIAction(scope.row, $event, item)}
            ></app-grid-column>
        );
    }

    /**
     * 绘制
     *
     * @param {*} h CreateElement对象
     * @memberof AppGridBase
     */
    public render(h: any) {
        if (!this.controlIsLoaded || !this.controlInstance) {
            return null;
        }
        const { controlClassNames } = this.renderOptions;
        return (
            <div class={{ ...controlClassNames,'app-control-grid--no-paging-bar': !this.controlInstance?.enablePagingBar }}>
                {
                  Object.is("USER", this.controlInstance.gridStyle) ? 
                  <app-pq-grid
                    data={this.items}
                    aggMode={this.aggMode}
                    remoteData={this.remoteData}
                    context={this.context}
                    viewparams={this.viewparams}
                    rowEdit={this.actualIsOpenEdit}
                    gridInstance={this.controlInstance}
                    gridRowActiveMode={this.gridRowActiveMode}
                    gridItemsModel={this.gridItemsModel}
                    curPage={this.curPage}
                    pageSize={this.limit}
                    modelService={this.modelService}
                    appUIService={this.appUIService}
                    totalRecord={this.totalRecord}
                    on-actionClick={(data: any, event: any, column: any, detail: any) => {this.handleActionClick(data, event, column, detail)}}
                    on-rowClick={(row: any) => {this.rowClick(row)}}
                    on-rowDblclick={(row: any) => {this.rowDBLClick(row)}}
                    on-rowSelect={($event: any[]) => {this.selectAll($event)}}
                    on-pageChange={($event: any) => {this.pageOnChange($event)}}
                    on-pageRefresh={($event: any) => {this.pageRefresh()}}
                    on-uiAction={(row: any, $event: any, column: number) => {this.columnUIAction(row, $event, column)}}
                    on-valueChange={(row: any, $event: any, rowIndex: number) => this.onGridItemValueChange(row, $event, rowIndex)}
                    on-pageSizeChange={($event: any) => {this.onPageSizeChange($event)}}>
                  </app-pq-grid> : [
                  <i-form class="control-content">
                    {
                        !this.ctrlLoadingService?.isLoading ? this.renderGridContent(h) : this.renderLoadDataTip()
                    }
                  </i-form>,
                    this.controlInstance?.enablePagingBar && !Object.is(this.controlInstance?.gridStyle, 'USER') ? this.renderPagingBar(h) : '',
                    this.items?.length > 0 ? this.renderColumnFilter() : null
                  ]
                }
            </div>
        );
    }
}