CONTROL-BASE.vue.ftl 107.4 KB
Newer Older
1 2 3
<#ibizinclude>
../@MACRO/CONTROL/LANGBASE.vue.ftl
</#ibizinclude>
4
<template>
5 6 7
<#if ctrl.render??> 
${ctrl.render.code}
<#else>
8
<div class='grid<#if ctrl.getPSSysCss?? && ctrl.getPSSysCss()??><#assign singleCss = ctrl.getPSSysCss()> ${singleCss.getCssName()}</#if>' style="height:100%">
9
  <i-form style="height:100%;display:flex;flex-direction: column;justify-content: space-between">
10
  <input style="display:none;" />
11 12 13 14 15 16 17 18 19 20 21 22 23
    <el-table v-if="isDisplay === true"
<#--  BEGIN:是否支持排序  --> 
        <#if !ctrl.isNoSort()> 
        :default-sort="{ prop: minorSortPSDEF, order: Object.is(minorSortDir, 'ASC') ? 'ascending' : Object.is(minorSortDir, 'DESC') ? 'descending' : '' }"  
        @sort-change="onSortChange($event)"  
        </#if>
<#--  END:是否支持排序  -->
        :border="isDragendCol"
        <#-- 表格聚合start -->
        <#if ctrl.getAggMode() != "NONE">
        :show-summary="true && items.length > 0"
        :summary-method="getSummaries"
        </#if>
24
        <#-- 表格聚合end -->  
25 26
        :highlight-current-row ="isSingleSelect"
        :row-class-name="getRowClassName"
27
        :cell-class-name="getCellClassName"
tony001's avatar
tony001 committed
28 29
        <#if ctrl.isEnableGroup()>
        :span-method="arraySpanMethod"
30
        :tree-props="{children: 'children', hasChildren: 'children?true:false'}"
tony001's avatar
tony001 committed
31 32
        row-key="groupById"
        </#if>
33
        max-height="100%"
34
        :header-row-style="{'height': '50px'}"
35
        @row-click="rowClick($event)"  
36
        @cell-click="cellClick" 
37
        @select-all="selectAll($event)"  
tony001's avatar
tony001 committed
38
        @select="select"  
39 40 41
        @row-class-name="onRowClassName($event)"  
        @row-dblclick="rowDBLClick($event)"  
        ref='multipleTable' :data="items" :show-header="!isHideHeader">
tony001's avatar
tony001 committed
42
            <template slot="empty">
43
                {{$t('<#if langbase??>${langbase}.nodata</#if>')}} 
tony001's avatar
tony001 committed
44
                <#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
tony001's avatar
tony001 committed
45
                <span class="quick-toolbar">
tony001's avatar
tony001 committed
46 47 48 49 50
                  <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>
                  <@ibizindent blank=12>
                  ${P.getCtrlCode(quickToolbar, 'CONTROL.html').code}
                  </@ibizindent>
                </span>
tony001's avatar
tony001 committed
51
                </#if>
tony001's avatar
tony001 committed
52
            </template>
53 54 55
            <template v-if="!isSingleSelect">
                <el-table-column align="center" type='selection' :width="checkboxColWidth"></el-table-column>
            </template>
tony001's avatar
tony001 committed
56 57
            <#if ctrl.isEnableGroup()>
            <template>
58
            <el-table-column show-overflow-tooltip prop="group" :label="$t('app.gridpage.group')" :min-width="80">
tony001's avatar
tony001 committed
59 60 61 62 63 64
                <template v-slot="{row,column,$index}">
                    <span>{{ row.group }}</span>
                </template>
            </el-table-column>
            </template>
            </#if>
65 66 67 68 69 70 71 72 73 74
            <#assign adaptationColu = true/>
            <#list ctrl.getPSDEGridColumns() as column>
            <@ibizindent blank=12>
            ${P.getPartCode(column,'COLUMN').code}<#t>
            </@ibizindent>
            </#list>
            <template v-if="adaptiveState">
                <el-table-column></el-table-column>
            </template>
    </el-table>
75
  
76
    <#if ctrl.isEnablePagingBar()>
77
    <app-grid-pagination :totalRow="totalrow" :curPage="curPage" :limit="limit" @page-change="handlePageChange" @page-size-change="handlePageSizeChange" />
78
    </#if>
79
  </i-form>
80
</div>
81
</#if>
82
</template>
83
// 基于 @CONTROL/表格/CONTROL-BASE.vue.ftl 生成
84
<#assign import_block>
85
import CodeListService from "@/codelist/codelist-service";
86
import { FormItemModel } from '@/model/form-detail';
87
import { Environment } from '@/environments/environment';
88 89 90
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
91 92 93
</#ibizinclude>
<#ibizinclude>
../../@MACRO/LANG_FUN.ftl
94
</#ibizinclude>
95 96 97 98 99 100 101 102 103 104 105 106 107 108
<#macro getMajorInfoColName ctrl>
<#compress>
<#if ctrl.getPSDEGridColumns?? && ctrl.getPSDEGridColumns()??>
<#list ctrl.getPSDEGridColumns() as gridColumn>
<#if gridColumn.getPSAppDEField?? && gridColumn.getPSAppDEField()??>
<#assign majorInfoField = gridColumn.getPSAppDEField() />
<#if majorInfoField.isMajorField()>
${gridColumn.getName()}
</#if>
</#if>
</#list>
</#if>
</#compress>
</#macro>
109 110 111 112
    /**
     * 代码表服务对象
     *
     * @type {CodeListService}
KK's avatar
KK committed
113
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
114
     */  
RedPig97's avatar
RedPig97 committed
115
    public codeListService:CodeListService = new CodeListService();
116

117 118 119 120 121 122 123 124
    /**
     * 主信息表格列
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
    public majorInfoColName:string = "<@getMajorInfoColName ctrl/>";

125 126 127 128 129 130
    /**
     * 界面UI服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}UIService}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
RedPig97's avatar
RedPig97 committed
131
    public appUIService:${srfclassname('${appde.getCodeName()}')}UIService = new ${srfclassname('${appde.getCodeName()}')}UIService();
132

133 134 135 136 137 138
    /**
     * 界面行为模型
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */  
139
    public actionModel:any ={
140 141
    <#if ctrl.getPSUIActions()??>
    <#list ctrl.getPSUIActions() as item>
142
        ${item.getUIActionTag()}: { name: '${item.getUIActionTag()}',disabled: false, visabled: true,noprivdisplaymode:<#if item.getNoPrivDisplayMode(view)??>${item.getNoPrivDisplayMode(view)}</#if>,dataaccaction: '<#if item.getDataAccessAction()??>${item.getDataAccessAction()}</#if>', actiontarget: '${item.getActionTarget()}'}<#if item_has_next>,</#if>
143 144 145 146
    </#list>
    </#if>  
    };

147 148 149 150 151 152 153 154 155
    /**
     * 应用状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public appStateEvent: Subscription | undefined;

156 157 158 159
    /**
     * 获取多项数据
     *
     * @returns {any[]}
KK's avatar
KK committed
160
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
161 162 163 164 165 166 167 168 169
     */
    public getDatas(): any[] {
        return this.selections;
    }

    /**
     * 获取单项树
     *
     * @returns {*}
KK's avatar
KK committed
170
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
171 172 173 174 175 176 177 178 179 180 181 182
     */
    public getData(): any {
        return this.selections[0];
    }

<#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
  <#list view.getPSAppViewLogics() as logic>
    <#if logic.getPFLogicCodeType() == 'APP_NEWDATA'>
    /**
     * 打开新建数据视图
     *
     * @type {any}
KK's avatar
KK committed
183
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
184
     */
185
    @Prop() public newdata: any;
186 187 188 189 190 191
    </#if>
    <#if logic.getPFLogicCodeType() == 'APP_OPENDATA'>
    /**
     * 打开编辑数据视图
     *
     * @type {any}
KK's avatar
KK committed
192
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
193
     */
194
    @Prop() public opendata: any;
195 196 197
    </#if>
  </#list>
</#if>
198 199 200 201 202 203 204 205
    
    /**
    * 是否嵌入关系界面
    *
    * @type {boolean}
    * @memberof ${srfclassname('${ctrl.codeName}')}Base
    */
    @Prop({default:false}) public isformDruipart?: boolean;
206 207 208 209 210

    /**
     * 显示处理提示
     *
     * @type {boolean}
KK's avatar
KK committed
211
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
212
     */
213
    @Prop({ default: true }) public showBusyIndicator?: boolean;
214 215 216 217 218

    /**
     * 部件行为--update
     *
     * @type {string}
KK's avatar
KK committed
219
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
220
     */
221
    @Prop() public updateAction!: string;
222 223 224 225 226
    
    /**
     * 部件行为--fetch
     *
     * @type {string}
KK's avatar
KK committed
227
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
228
     */
229
    @Prop() public fetchAction!: string;
230 231 232 233 234
    
    /**
     * 部件行为--remove
     *
     * @type {string}
KK's avatar
KK committed
235
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
236
     */
237
    @Prop() public removeAction!: string;
238 239 240 241 242
    
    /**
     * 部件行为--load
     *
     * @type {string}
KK's avatar
KK committed
243
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
244
     */
245
    @Prop() public loadAction!: string;
246 247 248 249 250
    
    /**
     * 部件行为--loaddraft
     *
     * @type {string}
KK's avatar
KK committed
251
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
252
     */
253
    @Prop() public loaddraftAction!: string;
254 255 256 257 258
    
    /**
     * 部件行为--create
     *
     * @type {string}
KK's avatar
KK committed
259
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
260
     */
261
    @Prop() public createAction!: string;
262 263 264 265 266

    /**
     * 当前页
     *
     * @type {number}
KK's avatar
KK committed
267
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
268
     */
269
    public curPage: number = 1;
270 271 272 273 274

    /**
     * 数据
     *
     * @type {any[]}
KK's avatar
KK committed
275
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
276
     */
277
    public items: any[] = [];
278 279 280 281 282

    /**
     * 是否支持分页
     *
     * @type {boolean}
KK's avatar
KK committed
283
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
284
     */
285
    public isEnablePagingBar: boolean = ${ctrl.isEnablePagingBar()?c};
286 287 288 289 290

    /**
     * 是否禁用排序
     *
     * @type {boolean}
KK's avatar
KK committed
291
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
292
     */
293
    public isNoSort: boolean = ${ctrl.isNoSort()?c};
294 295 296 297 298

    /**
     * 排序方向
     *
     * @type {string}
KK's avatar
KK committed
299
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
300
     */
301
    public minorSortDir: string = '<#if ctrl.getMinorSortDir()??>${ctrl.getMinorSortDir()}</#if>';
302 303 304 305 306

    /**
     * 排序字段
     *
     * @type {string}
KK's avatar
KK committed
307
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
308
     */
309
    public minorSortPSDEF: string = '<#if ctrl.getMinorSortPSDEF()??>${ctrl.getMinorSortPSDEF().getName()?lower_case}</#if>';
310 311 312 313 314

    /**
     * 分页条数
     *
     * @type {number}
KK's avatar
KK committed
315
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
316
     */
317
    public limit: number = ${ctrl.getPagingSize()?c};
318 319 320 321 322

    /**
     * 是否显示标题
     *
     * @type {boolean}
KK's avatar
KK committed
323
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
324
     */
325
    public isHideHeader: boolean = ${ctrl.isHideHeader()?c};
326 327 328 329 330

    /**
     * 是否默认选中第一条数据
     *
     * @type {boolean}
KK's avatar
KK committed
331
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
332
     */
333
    @Prop({ default: false }) public isSelectFirstDefault!: boolean;
334 335 336 337 338

    /**
     * 是否单选
     *
     * @type {boolean}
KK's avatar
KK committed
339
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
340
     */
341
    @Prop() public isSingleSelect?: boolean;
342 343 344 345 346

    /**
     * 选中数据字符串
     *
     * @type {string}
KK's avatar
KK committed
347
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
348
     */
349
    @Prop() public selectedData?: string;
350 351 352 353 354 355

    /**
     * 选中值变化
     *
     * @param {*} newVal
     * @param {*} oldVal
KK's avatar
KK committed
356
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
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 382 383
     */
    @Watch('selectedData')
    public onValueChange(newVal: any, oldVal: any) {
        this.selections = [];
        if(this.selectedData){
            const refs: any = this.$refs;
            if (refs.multipleTable) {
                refs.multipleTable.clearSelection();
                JSON.parse(this.selectedData).forEach((selection:any)=>{
                    let selectedItem = this.items.find((item:any)=>{
                        return Object.is(item.srfkey, selection.srfkey);
                    });
                    if(selectedItem){
                        this.rowClick(selectedItem);
                    }
                });
            }
        }
    }

    /**
     * 表格行数据默认激活模式
     * 0 不激活
     * 1 单击激活
     * 2 双击激活
     *
     * @type {(number | 0 | 1 | 2)}
KK's avatar
KK committed
384
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
385
     */
386
    @Prop({default: 2}) public gridRowActiveMode!: number;
387 388 389 390 391

    /**
     * 是否开启行编辑
     *
     * @type {boolean}
KK's avatar
KK committed
392
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
393
     */
394
    @Prop({default: false}) public isOpenEdit!: boolean;
395 396 397 398 399

    /**
     * 实际是否开启行编辑
     *
     * @type {boolean}
KK's avatar
KK committed
400
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
401
     */
402
    public actualIsOpenEdit: boolean = false;
403 404 405 406 407

    /**
     * 总条数
     *
     * @type {number}
KK's avatar
KK committed
408
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
409
     */
410
    public totalrow: number = 0;
411

412 413 414 415 416
    /**
     * 表格更新默认值项
     * 
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
417
    public defaultUpdateItems:Array<any> =[<#list ctrl.getPSDEGridEditItems() as editItem><#if editItem.getUpdateDV?? && editItem.getUpdateDV()?? && !(editItem.getUpdateDV() == '')>'${editItem.getCodeName()?lower_case}'</#if><#if editItem_has_next>,</#if></#list>];
418

419 420 421 422
    /**
     * 选中行数据
     *
     * @type {any[]}
423
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
424
     */
425
    public selections: any[] = [];
426 427 428 429 430

    /**
     * 拦截行选中
     *
     * @type {boolean}
431
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
432
     */
433
    public stopRowClick: boolean = false;
434

435 436 437 438 439 440 441 442
    /**
     * 当前编辑行数据
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public curEditRowData:any;

443 444 445 446 447
    <#if ctrl.getAggMode() == "ALL">
    /**
     * 表格聚合行为
     *
     * @type {string}
KK's avatar
KK committed
448
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
449
     */
450
    public aggAction:string ='<#if ctrl.getAggPSDEAction()??>${ctrl.getAggPSDEAction().getCodeName()}</#if>';
451 452 453 454 455

    /**
     * 远程数据
     *
     * @type {any}
KK's avatar
KK committed
456
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
457
     */
458
    public remoteData:any = {};
459 460
    </#if>

tony001's avatar
tony001 committed
461 462 463 464 465 466 467 468 469 470
    <#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
      <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>
      ${P.getCtrlCode(quickToolbar, 'CONTROL.vue').code}
    </#if>

    <#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
      <#assign batchToolbar = ctrl.getBatchPSDEToolbar()/>
      ${P.getCtrlCode(batchToolbar, 'CONTROL.vue').code}
    </#if>

471 472 473 474
    /**
     * 表格是否显示
     *
     * @type {boolean}
KK's avatar
KK committed
475
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
476
     */
477
    public isDisplay:boolean = <#if ctrl.getAggMode() == "ALL">false<#else>true</#if>;
478

479 480 481 482 483 484 485 486
    /**
     * 表格行编辑项校验错误提示信息
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public errorMessages: Array<any> = [];

487 488 489
    /**
     * 部件刷新
     *
490
     * @param {any} args
KK's avatar
KK committed
491
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
492
     */
493
    public refresh(args?: any): void {
494 495 496 497 498 499 500 501 502
        this.load();
    }

    /**
    * 选项框列宽
    *
    * @type {number}
    * @memberof AppIndex
    */
503
    public checkboxColWidth: number = <#if app.getPSApplicationUI()??>${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.CHECKCOLWIDTH',50)}<#else>50</#if>;
504 505 506 507 508 509 510

    /**
     * 是否允许拖动列宽
     *
     * @type {boolean}
     * @memberof AppEmbedPicker
     */
KK's avatar
KK committed
511 512 513
    public isDragendCol: boolean = true;
    <#-- public isDragendCol: boolean = <#if app.getPSApplicationUI()??>${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.ISDRAGENDCOL',false)?c}<#else>false</#if>;-->
    
514 515 516 517
    /**
     * 所有列成员
     *
     * @type {any[]}
KK's avatar
KK committed
518
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
519
     */
520
    public allColumns: any[] = [
521 522
<#if ctrl.getAllPSDEGridColumns()??>
  <#list ctrl.getAllPSDEGridColumns() as column>
523 524 525 526 527
        {
            name: '${column.getName()?lower_case}',
            label: '${column.getCaption()}',
            langtag: '<#if langbase??>${langbase}.columns.${column.getName()?lower_case}</#if>',
            show: <#if column.isHideDefault()>false<#else>true</#if>,
tony001's avatar
tony001 committed
528
            unit: '${column.getWidthUnit()}',
529 530 531 532 533 534 535
    <#--  BEGIN:是否支持行编辑  -->
    <#if ctrl.isEnableRowEdit() && column.isEnableRowEdit()>
            isEnableRowEdit: true,
    <#else>
            isEnableRowEdit: false,
    </#if>
    <#--  END:是否支持行编辑  -->
536 537 538 539 540 541 542
    <#--  BEGIN:是否启用  -->
    <#if column.getEnableCond?? && column.getEnableCond()??>
            enableCond: ${column.getEnableCond()?c} ,
    <#else>
            enableCond: 3 ,
    </#if>
    <#--  END:是否启用  -->
543
        },
544 545
  </#list>
</#if>
546 547
    ]

548 549 550 551
    /**
     * 表格模型集合
     *
     * @type {*}
KK's avatar
KK committed
552
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
553 554 555
     */
    public gridItemsModel: any[] = [];

tony001's avatar
tony001 committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
    /**
     * 是否启用分组
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public isEnableGroup:boolean = ${ctrl.isEnableGroup()?c};

    /**
     * 分组属性
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public groupAppField:string ="<#if ctrl.getGroupPSDEField()??>${ctrl.getGroupPSDEField().getCodeName()?lower_case}</#if>";

572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
    /**
     * 分组属性代码表标识
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public groupAppFieldCodelistTag:string ="<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>${ctrl.getGroupPSDEField().getPSCodeList().getCodeName()}</#if>";

    /**
     * 分组属性代码表类型
     * 
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public groupAppFieldCodelistType: string = "<#if ctrl.getGroupPSDEField()?? && ctrl.getGroupPSDEField().getPSCodeList?? && ctrl.getGroupPSDEField().getPSCodeList()??>${ctrl.getGroupPSDEField().getPSCodeList().getCodeListType()}</#if>";

tony001's avatar
tony001 committed
588 589 590 591 592 593 594 595
    /**
     * 分组模式
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public groupMode:string ="<#if ctrl.getGroupMode()??>${ctrl.getGroupMode()}</#if>";

596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611
    /**
     * 分组代码表标识
     * 
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public codelistTag: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeName()}</#if>";

    /**
     * 分组代码表类型
     * 
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public codelistType: string = "<#if ctrl.getGroupPSCodeList?? && ctrl.getGroupPSCodeList()??>${ctrl.getGroupPSCodeList().getCodeListType()}</#if>";

612 613 614 615 616 617
    /**
     * 获取界面行为权限状态
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getActionState(data:any){
618
        let tempActionModel:any = JSON.parse(JSON.stringify(this.actionModel));
tony001's avatar
tony001 committed
619 620
        let targetData:any = this.transformData(data);
        ViewTool.calcActionItemAuthState(targetData,tempActionModel,this.appUIService);
621 622 623
        return tempActionModel;
    }

624 625 626 627
    /**
     * 获取表格行模型
     *
     * @type {*}
KK's avatar
KK committed
628
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
629 630 631 632 633 634 635 636 637
     */
    public getGridRowModel(){
        return {
<#list ctrl.getPSDEGridEditItems() as edititem>
          ${edititem.getName()}: new FormItemModel(),
</#list>
        }
    }

638 639 640 641
    /**
     * 属性值规则
     *
     * @type {*}
KK's avatar
KK committed
642
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
643
     */
644 645 646 647 648 649 650 651 652 653 654 655 656 657
    public deRules(){
        return {
            <#if ctrl.getPSDEGridEditItemVRs?? && ctrl.getPSDEGridEditItemVRs()??>
            <#list ctrl.getPSDEGridEditItemVRs() as fideValueRule>
                <#if fideValueRule.getCheckMode?? && fideValueRule.getCheckMode()?? && fideValueRule.getCheckMode() != 2 && fideValueRule.getPSDEFValueRule?? && fideValueRule.getPSDEFValueRule()??>
                    <#assign  deRule = fideValueRule.getPSDEFValueRule()/>
                    <#if fideValueRule.getPSDEGridEditItemName?? && fideValueRule.getPSDEGridEditItemName()??>
                    ${fideValueRule.getPSDEGridEditItemName()}:[
                    <#if deRule.getPSDEFVRGroupCondition?? && deRule.getPSDEFVRGroupCondition()?? && deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions?? &&  deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions()??>
                    <#list deRule.getPSDEFVRGroupCondition().getPSDEFVRConditions() as condItem>
                        <@getDeRule condItem deRule appde/>
                    </#list>
                    </#if>],
                    </#if>
658
                </#if>
659
            </#list>
660
            </#if>
661 662
        };
    }
663 664 665 666 667 668 669

    /**
     * 值规则集合
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686
    public rules(){
        return {
            <#list ctrl.getPSDEGridEditItems() as edititem>
            ${edititem.getName()}: [
                { required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `<#if langbase??><#noparse>${</#noparse>this.$t('${langbase}.columns.${edititem.getName()?lower_case}')<#noparse>}</#noparse><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse><#else><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse></#if>`, trigger: 'change' },
                { required: <#if edititem.isAllowEmpty()>false<#else>true</#if>, validator: (rule:any, value:any, callback:any) => { return (rule.required && (value === null || value === undefined || value === "")) ? false : true;}, message: `<#if langbase??><#noparse>${</#noparse>this.$t('${langbase}.columns.${edititem.getName()?lower_case}')<#noparse>}</#noparse><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse><#else><#noparse>${</#noparse>this.$t('app.commonWords.valueNotEmpty')<#noparse>}</#noparse></#if>`, trigger: 'blur' },
            <#if ctrl.getPSDEGridEditItemVRs?? && ctrl.getPSDEGridEditItemVRs()??>
                <#list ctrl.getPSDEGridEditItemVRs() as fideValueRule>
                <#if fideValueRule.getPSDEGridEditItemName() == edititem.getName()>
                    <#if fideValueRule.getPSSysValueRule()??>
                    <#assign  valueRule = fideValueRule.getPSSysValueRule()/>
                    <#if valueRule.getRuleType?? && valueRule.getRuleType()??>
                        <#if valueRule.getRuleType() == "REG">
                { <#if valueRule.getRegExCode?? && valueRule.getRegExCode()??>pattern: /${valueRule.getRegExCode()}/</#if><#if valueRule.getRuleInfo?? &&  valueRule.getRuleInfo()??>, message: '${valueRule.getRuleInfo()}'</#if>, trigger: 'change' },
                        <#elseif valueRule.getRuleType() == "SCRIPT">
                { <#if valueRule.getScriptCode?? && valueRule.getScriptCode()??>validator: (rule:any, value:any, callback:any) => { ${valueRule.getScriptCode()} }</#if><#if valueRule.getRuleInfo?? &&  valueRule.getRuleInfo()??>, message: '${valueRule.getRuleInfo()}'</#if>, trigger: 'change' },
                        </#if>
687
                    </#if>
688 689 690 691 692 693
                    </#if>
                    <#if fideValueRule.getPSDEFValueRule()??>
                    <#assign  valueRule = fideValueRule.getPSDEFValueRule()/>
                        <#if fideValueRule.getPSDEGridEditItemName?? && fideValueRule.getPSDEGridEditItemName()??>
                {validator:(rule:any, value:any, callback:any)=>{return this.verifyDeRules("${fideValueRule.getPSDEGridEditItemName()}",this.deRules(),"AND",value).isPast},message: "<#if valueRule.getRuleInfo()??>${valueRule.getRuleInfo()}</#if>", trigger: 'blur' },
                        </#if>
694 695
                    </#if>
                </#if>
696 697 698
                </#list>
            </#if>
            ],
699
            </#list>
700
        }
701 702
    }

703 704 705 706 707 708 709 710
    /**
     * 表格行编辑项校验
     *
     * @param {string} property 属性名
     * @param {*} data 行数据
     * @param {number} rowIndex 行索引
     * @returns Promise<any>
     * 
KK's avatar
KK committed
711
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
712 713 714
     */
    public validate(property:string, data:any, rowIndex:number):Promise<any>{
        return new Promise((resolve, reject) => {
715
            this.$util.validateItem(property,data,this.rules()).then(()=>{
716 717 718 719 720 721 722 723 724 725 726 727 728
                this.gridItemsModel[rowIndex][property].setError(null);
                resolve(true);
            }).catch(({ errors, fields }) => {
                this.gridItemsModel[rowIndex][property].setError(errors[0].message);
                resolve(false);
            });
        });
    }

    /**
     * 校验所有修改过的编辑项
     *
     * @returns Promise<any>
KK's avatar
KK committed
729
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
730 731
     */
    public async validateAll(){
732
        this.errorMessages = [];
733 734
        let validateState = true;
        let index = -1;
735 736 737 738
        for (let item of this.items) {
            let tempMessage: string = '';
            index++;
            if (item.rowDataState === "create" || item.rowDataState === "update") {
739
                for (let property of Object.keys(this.rules())) {
740 741 742 743 744
                    if (!await this.validate(property, item, index)) {
                        validateState = false;
                        tempMessage = tempMessage + '<p>' + this.gridItemsModel[index][property].error + '<p>';
                    }
                }
745
            }
746
            this.errorMessages.push(tempMessage);
747 748 749 750
        }
        return validateState;
    }

751 752 753 754
    /**
     * 表格数据加载
     *
     * @param {*} [arg={}]
KK's avatar
KK committed
755
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
756
     */
Mosher's avatar
Mosher committed
757 758 759 760 761 762
    public async load(opt: any = {}, pageReset: boolean = false): Promise<any> {
        if (!this.fetchAction) {
            this.$Notice.error({
                title: this.$t("app.commonWords.wrong") as string,
                desc: "${view.getName()}" + (this.$t("app.gridpage.notConfig.fetchAction") as string),
            });
763 764
            return;
        }
Mosher's avatar
Mosher committed
765
        if (pageReset) {
766 767
            this.curPage = 1;
        }
Mosher's avatar
Mosher committed
768
        const arg: any = { ...opt };
769 770
        const page: any = {};
        if (this.isEnablePagingBar) {
Mosher's avatar
Mosher committed
771
            Object.assign(page, { page: this.curPage - 1, size: this.limit });
772
        }
Mosher's avatar
Mosher committed
773 774 775
        //  设置排序
        if (!this.isNoSort && !Object.is(this.minorSortDir, "") && !Object.is(this.minorSortPSDEF, "")) {
            const sort: string = this.minorSortPSDEF + "," + this.minorSortDir;
776 777
            Object.assign(page, { sort: sort });
        }
Mosher's avatar
Mosher committed
778 779
        //  清空selections
        if (this.selections && this.selections.length > 0) {
780
            this.selections = [];
Mosher's avatar
Mosher committed
781
            this.$emit("selectionchange", this.selections);
782
        }
783 784
        Object.assign(arg, page);
        const parentdata: any = {};
Mosher's avatar
Mosher committed
785
        this.$emit("beforeload", parentdata);
786
        Object.assign(arg, parentdata);
Mosher's avatar
Mosher committed
787 788 789 790 791 792 793 794 795 796 797 798 799 800
        let tempViewParams: any = parentdata.viewparams ? parentdata.viewparams : {};
        Object.assign(tempViewParams, Util.deepCopy(this.viewparams));
        Object.assign(arg, { viewparams: tempViewParams });
        const tempContext = Util.deepCopy(this.context);
        if (!(await this.handleCtrlEvents('onbeforeload', { context: tempContext, viewparams: arg }))) {
            return;
        }
        try {
            const response = await this.service.search(
                this.fetchAction,
                tempContext,
                arg,
                this.showBusyIndicator
            );
801
            if (!response.status || response.status !== 200) {
Mosher's avatar
Mosher committed
802
                //  加载失败
Mosher's avatar
Mosher committed
803
                if (!(await this.handleCtrlEvents('onloaderror', { data: response.data ? response.data : [] }))) {
Mosher's avatar
Mosher committed
804 805
                    return;
                }
806
                if (response.data && response.data.message) {
Mosher's avatar
Mosher committed
807 808 809 810
                    this.$Notice.error({
                        title: this.$t("app.commonWords.wrong") as string,
                        desc: response.data.message,
                    });
811
                }
Mosher's avatar
Mosher committed
812 813 814 815
                return response;
            }
            //  加载成功
            if (!(await this.handleCtrlEvents('onloadsuccess', { data: response.data, context: tempContext, viewparams: arg }))) {
816 817 818
                return;
            }
            const data: any = response.data;
819
            this.totalrow = response.total;
820
            this.items = JSON.parse(JSON.stringify(data));
821
            // 清空selections,gridItemsModel
822
            // this.selections = [];
823
            this.gridItemsModel = [];
Mosher's avatar
Mosher committed
824 825
            this.items.forEach(() => {
                this.gridItemsModel.push(this.getGridRowModel());
826
            });
Mosher's avatar
Mosher committed
827 828 829 830
            this.items.forEach((item: any) => {
                Object.assign(item, this.getActionState(item));
            });
            this.$emit("load", this.items);
831 832 833
            // 设置默认选中
            let _this = this;
            setTimeout(() => {
834
                //在导航视图中,如已有选中数据,则右侧展开已选中数据的视图,如无选中数据则默认选中第一条
Mosher's avatar
Mosher committed
835 836 837 838 839
                if (_this.isSelectFirstDefault) {
                    if (_this.selections && _this.selections.length > 0) {
                        _this.selections.forEach((select: any) => {
                            const index = _this.items.findIndex((item: any) => Object.is(item.srfkey, select.srfkey));
                            if (index != -1) {
840 841
                                _this.rowClick(_this.items[index]);
                            }
Mosher's avatar
Mosher committed
842 843
                        });
                    } else {
844 845
                        _this.rowClick(this.items[0]);
                    }
846
                }
Mosher's avatar
Mosher committed
847
                if (_this.selectedData) {
848 849 850
                    const refs: any = _this.$refs;
                    if (refs.multipleTable) {
                        refs.multipleTable.clearSelection();
Mosher's avatar
Mosher committed
851 852
                        JSON.parse(_this.selectedData).forEach((selection: any) => {
                            let selectedItem = _this.items.find((item: any) => {
853 854
                                return Object.is(item.srfkey, selection.srfkey);
                            });
Mosher's avatar
Mosher committed
855
                            if (selectedItem) {
856 857 858 859 860 861 862 863 864
                                _this.rowClick(selectedItem);
                            }
                        });
                    }
                }
            }, 300);
            <#if ctrl.getAggMode() == "ALL">
            this.getAggData();
            </#if>
tony001's avatar
tony001 committed
865
            <#if ctrl.isEnableGroup()>
866
            this.group();
tony001's avatar
tony001 committed
867
            </#if>
868 869 870
            this.$nextTick(() => {
                this.resetGridLayout();
            })
Mosher's avatar
Mosher committed
871 872 873
            return response;
        } catch (response: any) {
            //  加载失败
Mosher's avatar
Mosher committed
874
            if (!(await this.handleCtrlEvents('onloaderror', { data: response && response.data ? response.data : [] }))) {
875 876
                return;
            }
Mosher's avatar
Mosher committed
877 878 879 880 881 882 883 884 885
            if (response && response.status === 401) {
                return response;
            }
            this.$Notice.error({
                title: this.$t("app.commonWords.wrong") as string,
                desc: response.data && response.data.message ? response.data.message : "",
            });
            return response;
        }
886 887
    }

888 889 890 891 892 893 894 895
    /**
     * 重置表格布局(适配element高度变化)
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public resetGridLayout() {
    }

896 897 898 899 900
    /**
     * 删除
     *
     * @param {any[]} datas
     * @returns {Promise<any>}
KK's avatar
KK committed
901
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
902
     */
903
    public async remove(datas: any[]): Promise<any> {
Mosher's avatar
Mosher committed
904 905 906 907 908
        if (!this.removeAction) {
            this.$Notice.error({
                title: (this.$t('app.commonWords.wrong') as string),
                desc: '${view.getName()}' + (this.$t('app.gridpage.notConfig.removeAction') as string)
            });
909 910 911 912
            return;
        }
        let _datas:any[] = [];
        datas.forEach((record: any, index: number) => {
913
            if (Object.is(record.srfuf,"0")) {
914 915 916
                this.items.some((val: any, num: number) =>{
                    if(JSON.stringify(val) == JSON.stringify(record)){
                        this.items.splice(num,1);
917
                        this.gridItemsModel.splice(num,1);
918 919 920
                        return true;
                    }
                }); 
Mosher's avatar
Mosher committed
921
            } else {
922 923 924 925 926 927 928 929
               _datas.push(datas[index]);
            }
        });
        if (_datas.length === 0) {
            return;
        }
        let dataInfo = '';
        _datas.forEach((record: any, index: number) => {
930
            let srfmajortext = record.${ctrl.getPSAppDataEntity().getMajorPSAppDEField().getName()?lower_case};
931 932 933 934 935 936 937 938 939 940 941
            if (index < 5) {
                if (!Object.is(dataInfo, '')) {
                    dataInfo += '、';
                }
                dataInfo += srfmajortext;
            } else {
                return false;
            }
        });

        if (_datas.length < 5) {
942
            dataInfo = dataInfo + ' ' + (this.$t('app.gridpage.totle') as string) + _datas.length + (this.$t('app.gridpage.records') as string) + (this.$t('app.gridpage.data') as string);
943
        } else {
944
            dataInfo = ' ... ' + (this.$t('app.gridpage.totle') as string) + _datas.length + (this.$t('app.gridpage.records') as string) + (this.$t('app.gridpage.data') as string);
945 946
        }

Mosher's avatar
Mosher committed
947
        const removeData = async () => {
948 949 950 951
            let keys: any[] = [];
            _datas.forEach((data: any) => {
                keys.push(data.srfkey);
            });
WodahsOrez's avatar
WodahsOrez committed
952
            let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
953
            let _keys = keys.length > 1 ? keys : keys[0] ;
954
            const context:any = JSON.parse(JSON.stringify(this.context));
Mosher's avatar
Mosher committed
955 956 957 958 959 960 961
            try {
                if (!(await this.handleCtrlEvents('onbeforeremove', { data: _keys }))) {
                    return;
                }
                const response: any = await this.service.delete(_removeAction, Object.assign(context,{ ${ctrl.getPSAppDataEntity().codeName?lower_case}: _keys }),Object.assign({ ${ctrl.getPSAppDataEntity().codeName?lower_case}: _keys },{viewparams:this.viewparams}), this.showBusyIndicator);
                if (!response || response.status !== 200) {
                    if (!(await this.handleCtrlEvents('onremoveerror', { data: _keys }))) {
962 963
                        return;
                    }
Mosher's avatar
Mosher committed
964 965 966 967 968 969 970 971 972 973 974 975 976 977 978
                    this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.delDataFail') as string)+',' + response.info });
                    return;
                }
                if (!(await this.handleCtrlEvents('onremovesuccess', { data: response.data }))) {
                    return;
                }
                this.$Notice.success({ title: '', desc: (this.$t('app.gridpage.delSuccess') as string) });
                //删除items中已删除的项
                _datas.forEach((data: any) => {
                    this.items.some((item:any,index:number)=>{
                        if(Object.is(item.srfkey,data.srfkey)){
                            this.items.splice(index,1);
                            this.gridItemsModel.splice(index,1);
                            return true;
                        }
979 980
                    });
                });
Mosher's avatar
Mosher committed
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997
                this.totalrow -= _datas.length;
                this.$emit('remove', null);
                this.selections = [];
                return response;
            } catch (response: any) {
                if (!(await this.handleCtrlEvents('onremoveerror', { data: response ? response.data : [] }))) {
                    return;
                }
                if (response && response.status != 200) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
                    return response;
                }
                if (!response || !response.status || !response.data) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
                }
                return response;
            }
998 999 1000 1001
        }

        dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
        this.$Modal.confirm({
1002
            title: (this.$t('app.commonWords.warning') as string),
Mosher's avatar
Mosher committed
1003
            content: (this.$t('app.gridpage.confirmDel') as string) + ' ' + dataInfo + ','+(this.$t('app.gridpage.notRecoverable') as string),
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016
            onOk: () => {
                removeData();
            },
            onCancel: () => { }
        });
        return removeData;
    }


    /**
     * 批量添加
     *
     * @param {*} [arg={}]
KK's avatar
KK committed
1017
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1018
     */
1019
    public addBatch(arg: any = {}): void {
1020
        if(!this.fetchAction){
1021
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.fetchAction') as string) });
1022 1023 1024 1025 1026
            return;
        }
        if(!arg){
            arg = {};
        }
1027
        console.error((this.$t('app.gridpage.notBatch') as string));
1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047
        <#--  const post: Promise<any> = this.$http.post(this.fetchAction, arg, this.showBusyIndicator);
        post.then((response: any) => {
            if (response.ret !== 200) {
                this.$Notice.error({ title: '', desc: '批量添加失败,' + response.info });
                return;
            }
            this.load({});
            this.$emit('addbatch', null);
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            this.$Notice.error({ title: '', desc: '批量添加失败' });
        });  -->
    }

    /**
     * 数据导入
     *
     * @param {*} data
KK's avatar
KK committed
1048
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1049 1050 1051 1052 1053 1054 1055 1056 1057
     */
     public importExcel(data:any ={}):void{
        //导入excel
        const importDataModel:any ={
        <#if ctrl.getPSDEDataImport?? && ctrl.getPSDEDataImport()??>
        <#assign dataImport = ctrl.getPSDEDataImport() />
            importId:'${dataImport.getCodeName()}',
            serviceName:'${dataImport.getPSAppDataEntity().getCodeName()?lower_case}',
            appDeLogicName:'${dataImport.getPSAppDataEntity().getLogicName()}',
1058
            ignoreError: <#if dataImport.isIgnoreError?? && dataImport.isIgnoreError()>true<#else>false</#if>,
1059 1060 1061
            importData:{
            <#if dataImport.getPSDEDataImportItems()??>
            <#list dataImport.getPSDEDataImportItems() as dataImportItem>
1062
                "${dataImportItem.getName()}":{<#if dataImportItem.getPSCodeList()??><#assign codelist = dataImportItem.getPSCodeList()/>"codelist":{"type":"${codelist.getCodeListType()}","tag":"${codelist.getCodeName()}","isnumber":${codelist.isCodeItemValueNumber()?c}},</#if>"headername":"${dataImportItem.getCaption()}","isuniqueitem":${dataImportItem.isUniqueItem()?c},<#if dataImportItem.getPSAppDEField()??><#assign appDeField = dataImportItem.getPSDEField()/>"name":"${appDeField.getCodeName()?lower_case}","order":<#if appDeField.getImportOrder()??>${appDeField.getImportOrder()?c}</#if></#if>}<#if dataImportItem_has_next>,</#if>
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074
            </#list>
            </#if>
            }
        </#if>
        }
        if(Object.keys(importDataModel).length == 0){
            this.$Notice.warning({ 'title': (this.$t("app.utilview.warning") as string), 'desc': (this.$t("app.utilview.info") as string) });
            return;
        }
        const view:any ={
            viewname: 'app-data-upload',
            title: this.$t("app.utilview.importview"),
1075 1076
            width: 650,
            height: 500
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092
        }
        let container: Subject<any> = this.$appmodal.openModal(view, JSON.parse(JSON.stringify(this.context)), importDataModel);
        container.subscribe((result: any) => {
          if(Object.is(result.ret,'OK')){
            this.refresh(result.datas);
          }
      });
    }

<#assign hasDEExport = false />
<#if ctrl.getPSDEDataExport?? && ctrl.getPSDEDataExport()??>
  <#assign hasDEExport = true />
    /**
     * 所有导出列成员
     *
     * @type {any[]}
KK's avatar
KK committed
1093
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1094
     */
1095
    public allExportColumns: any[] = [
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113
        <#if ctrl.getPSDEDataExport().getPSDEDataExportItems()??>
        <#list ctrl.getPSDEDataExport().getPSDEDataExportItems() as column>
        {
            name: '${column.getName()?lower_case}',
            label: '${column.getCaption()}',
            langtag: '<#if langbase??>${langbase}.exportColumns.${column.getName()?lower_case}</#if>',
            show: true,
        },
        </#list>
        </#if>
    ]

</#if>

    /**
     * 数据导出
     *
     * @param {*} data
KK's avatar
KK committed
1114
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1115
     */
1116
    public exportExcel(data: any = {}): void {
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133
        // 导出Excel
        const doExport = async (_data:any) => {
            const tHeader: Array<any> = [];
            const filterVal: Array<any> = [];
<#if hasDEExport>
            this.allExportColumns.forEach((item: any) => {
<#else>
            this.allColumns.forEach((item: any) => {
</#if>
              item.show && item.label ? tHeader.push(this.$t(item.langtag)) : "";
              item.show && item.name ? filterVal.push(item.name) : "";
            });
            const data = await this.formatExcelData(filterVal, _data);
            this.$export.exportExcel().then((excel:any)=>{
                excel.export_json_to_excel({
                  header: tHeader, //表头 必填
                  data, //具体数据 必填
1134
                  filename: "${ctrl.getPSAppDataEntity().getLogicName()}"+(this.$t('app.gridpage.grid') as string), //非必填
1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166
                  autoWidth: true, //非必填
                  bookType: "xlsx" //非必填
                });
            }); 
        };
        const page: any = {};
        // 设置page,size
        if (Object.is(data.type, 'maxRowCount')) {
            Object.assign(page, { page: 0, size: data.maxRowCount });
        } else if (Object.is(data.type, 'activatedPage')) {
<#if hasDEExport>
            Object.assign(page, { page: this.curPage-1, size: this.limit });
<#else>
            try {
                doExport(JSON.parse(JSON.stringify(this.items)));
            } catch (error) {
                console.error(error);
            }
            return;
</#if>
        }
        // 设置排序
        if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
          const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
            Object.assign(page, { sort: sort });
        }
        const arg: any = {};
        Object.assign(arg, page);
        // 获取query,搜索表单,viewparams等父数据
        const parentdata: any = {};
        this.$emit('beforeload', parentdata);
        Object.assign(arg, parentdata);
1167 1168 1169
        let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{};
        Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams)));
        Object.assign(arg,{viewparams:tempViewParams});
1170 1171 1172 1173 1174 1175 1176
<#if hasDEExport>
        const post: Promise<any> = this.service.searchDEExportData(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
<#else>
        const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
</#if>
        post.then((response: any) => {
            if (!response || response.status !== 200) {
1177
                this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.exportFail') as string)+',' + response.info });
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
                return;
            }
            try {
                doExport(JSON.parse(JSON.stringify(response.data)));
            } catch (error) {
                console.error(error);
            }
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
1189
            this.$Notice.error({ title: '', desc: (this.$t('app.gridpage.exportFail') as string) });
1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
        });
    }


    /**
     * 导出数据格式化
     * 
     * @param {*} filterVal
     * @param {*} jsonData
     * @returns {[]}
KK's avatar
KK committed
1200
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1201 1202 1203
     */
    public async formatExcelData(filterVal:any, jsonData:any) {
        let codelistColumns:Array<any> = [
1204 1205 1206
<#if ctrl.getPSDEDataExport()?? && ctrl.getPSDEDataExport().getPSDEDataExportItems()??>
  <#list ctrl.getPSDEDataExport().getPSDEDataExportItems() as column>
     <#if column.getPSCodeList?? && column.getPSCodeList()??>
1207 1208
      <#assign codelist = column.getPSCodeList()>
      <#if codelist.getCodeListType() == 'STATIC' || codelist.getCodeListType() == 'DYNAMIC'>
1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226
            {
                name: '${column.getName()?lower_case}',
                srfkey: '${codelist.codeName}',
                codelistType : '${codelist.getCodeListType()}',
            <#if codelist.getOrMode() == 'STR'>
                textSeparator: '${codelist.textSeparator}',
                renderMode: 'string',
                valueSeparator: "${codelist.valueSeparator}",
            <#elseif codelist.getOrMode() == 'NUM'>
                renderMode: 'number',
                textSeparator: '${codelist.textSeparator}',
                valueSeparator: ',',
            <#else>
                renderMode: 'other',
                textSeparator: '、',
                valueSeparator: ',',
            </#if>
            },
1227
      </#if>
1228
     </#if>
1229
  </#list>
1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257
  <#else>
  <#if ctrl.getAllPSDEGridColumns()??>
    <#list ctrl.getAllPSDEGridColumns() as column>
     <#if (!column.isHideDefault() && column.getName() != '') && column.getPSCodeList?? && column.getPSCodeList()?? && column.getCLConvertMode() == 'FRONT'>
      <#assign codelist = column.getPSCodeList()>
      <#if codelist.getCodeListType() == 'STATIC' || codelist.getCodeListType() == 'DYNAMIC'>
            {
                name: '${column.getName()?lower_case}',
                srfkey: '${codelist.codeName}',
                codelistType : '${codelist.getCodeListType()}',
            <#if codelist.getOrMode() == 'STR'>
                textSeparator: '${codelist.textSeparator}',
                renderMode: 'string',
                valueSeparator: "${codelist.valueSeparator}",
            <#elseif codelist.getOrMode() == 'NUM'>
                renderMode: 'number',
                textSeparator: '${codelist.textSeparator}',
                valueSeparator: ',',
            <#else>
                renderMode: 'other',
                textSeparator: '、',
                valueSeparator: ',',
            </#if>
            },
      </#if>
     </#if>
    </#list>
  </#if>
1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282
</#if>
        ];
        let _this = this;
        for (const codelist of codelistColumns) {
          // 动态代码表处理
          if (Object.is(codelist.codelistType, "DYNAMIC")) {
              let items = await _this.codeListService.getItems(codelist.srfkey);
              jsonData.forEach((row:any)=>{
                  row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
              });
          // 静态处理
          } else if(Object.is(codelist.codelistType, "STATIC")){
              let items = await _this.$store.getters.getCodeListItems(codelist.srfkey);
              jsonData.forEach((row:any)=>{
                  row[codelist.name] = _this.getCodelistValue(items, row[codelist.name], codelist);
              });
          }
        }
        return jsonData.map((v:any) => filterVal.map((j:any) => v[j]))
    }   


    /**
     * 解析代码表和vlaue,设置items
     *
1283
     * @public
1284 1285 1286
     * @param {any[]} items 代码表数据
     * @param {*} value
     * @returns {*}
KK's avatar
KK committed
1287
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1288
     */
1289
    public getCodelistValue(items: any[], value: any, codelist: any,){
1290
        if(!value && value !== 0 && value !== false){
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335
            return this.$t('codelist.'+codelist.srfkey+'.empty');
        }
        if (items) {
            let result:any = [];
            if(Object.is(codelist.renderMode,"number")){
                items.map((_item: any, index: number)=>{
                    const nValue = parseInt((value as any), 10);
                    const codevalue = _item.value;
                    if((parseInt(codevalue, 10) & nValue) > 0){
                        result.push(_item);
                    } 
                });
            } else if(Object.is(codelist.renderMode,"string")){
                const arrayValue: Array<any> = (value as any).split(codelist.valueSeparator);
                arrayValue.map((value: any, index: number) => {
                    result.push([]);
                    let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
                    values.map((val:any ,num: number)=>{
                        const item = this.getItem(items, val, codelist); 
                        if(item){
                          result[index].push(item);
                        } 
                    });
                });
            } else {
                let values: any[] = Object.is(this.$util.typeOf(value), 'number') ? [value] : [...(value as any).split(codelist.valueSeparator)];
                values.map((value:any ,index: number)=>{
                    const item = this.getItem(items, value, codelist); 
                    if(item){
                      result.push(item);
                    } 
                });
            }
            // 设置items
            if(result.length != 0){
              return result.join(codelist.valueSeparator);
            }else{
              return value;
            }
        }
    }

    /**
     * 获取代码项
     *
1336
     * @public
1337 1338 1339
     * @param {any[]} items
     * @param {*} value
     * @returns {*}
KK's avatar
KK committed
1340
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1341
     */
1342
    public getItem(items: any[], value: any, codelist: any): any {
1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356
        const arr: Array<any> = items.filter(item => {return item.value == value});
        if (arr.length !== 1) {
            return undefined;
        }
        if(Object.is(codelist.codelistType,'STATIC')){
            return this.$t('codelist.'+codelist.srfkey+'.'+arr[0].value);
        }else{
            return arr[0].text;
        }
    }

    /**
     * 生命周期
     *
KK's avatar
KK committed
1357
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1358
     */
1359
    public created(): void {
1360 1361 1362 1363 1364 1365
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
KK's avatar
KK committed
1366
     *  @memberof ${srfclassname('${ctrl.codeName}')}Base
1367
     */    
1368 1369
    public afterCreated() {
        this.actualIsOpenEdit = this.isOpenEdit;
1370 1371 1372 1373 1374 1375 1376
        this.setColState();
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                if (Object.is('load', action)) {
1377
                    this.load(data,true);
1378 1379 1380 1381 1382 1383 1384 1385 1386
                }
                if (Object.is('remove', action)) {
                    this.remove(data);
                }
                if (Object.is('save', action)) {
                    this.save(data);
                }
            });
        }
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396
        if(AppCenterService && AppCenterService.getMessageCenter()){
            this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{
                if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){
                    return;
                }
                if(Object.is(action,'appRefresh')){
                    this.refresh([data]);
                }
            })
        }
1397 1398 1399 1400 1401
    }

    /**
     * vue 生命周期
     *
KK's avatar
KK committed
1402
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1403
     */
1404
    public destroyed() {
1405 1406 1407 1408 1409 1410
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
KK's avatar
KK committed
1411
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1412
     */
1413
    public afterDestroy() {
1414 1415 1416
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
1417 1418 1419
        if(this.appStateEvent){
            this.appStateEvent.unsubscribe();
        }
1420 1421 1422 1423 1424 1425 1426 1427 1428
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>
    }

    /**
     * 获取选中行胡数据
     *
     * @returns {any[]}
KK's avatar
KK committed
1429
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1430
     */
1431
    public getSelection(): any[] {
1432 1433 1434 1435 1436 1437 1438 1439
        return this.selections;
    }

    /**
     * 行双击事件
     *
     * @param {*} $event
     * @returns {void}
KK's avatar
KK committed
1440
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1441
     */
1442
    public rowDBLClick($event: any): void {
tony001's avatar
tony001 committed
1443
        // 分组行跳过
1444
        if($event && $event.children){
tony001's avatar
tony001 committed
1445 1446
            return;
        }
1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463
        if (!$event || this.actualIsOpenEdit || Object.is(this.gridRowActiveMode,0)) {
            return;
        }
        this.selections = [];
        this.selections.push(JSON.parse(JSON.stringify($event)));

        const refs: any = this.$refs;
        if (refs.multipleTable) {
            refs.multipleTable.clearSelection();
            refs.multipleTable.toggleRowSelection($event);
        }

        this.$emit('rowdblclick', this.selections);
        this.$emit('selectionchange', this.selections);
    }

    /**
tony001's avatar
tony001 committed
1464 1465 1466 1467 1468 1469
    * 合并分组行
    * 
    * @memberof ${srfclassname('${ctrl.codeName}')}Base
    */
    public arraySpanMethod({row, column, rowIndex, columnIndex} : any) {
        let allColumns:Array<any> = [<#if ctrl.getPSDEGridColumns()??><#list ctrl.getPSDEGridColumns() as singleColumn>'${singleColumn.getCodeName()}'<#if singleColumn_has_next>,</#if></#list></#if>];
1470
        if(row && row.children) {
1471 1472 1473 1474 1475
            if(columnIndex == (this.isSingleSelect ? 0:1)) {
                return [1, allColumns.length+1];
            } else if(columnIndex > (this.isSingleSelect ? 0:1)) {
                return [0,0];
            }
tony001's avatar
tony001 committed
1476 1477 1478
        }
    }

1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513
	/**
     * 分组方法
     * 
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public group(){
        if(Object.is(this.groupMode,"AUTO")){
            this.drawGroup();
        }else if(Object.is(this.groupMode,"CODELIST")){
            this.drawCodelistGroup();
        }
    }

    /**
     * 获取表格分组相关代码表
     * 
     * @param {string}  codelistType 代码表类型
     * @param {string}  codelistTag 代码表标识
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getGroupCodelist(codelistType: string,codelistTag:string){
        let codelist: Array<any> = [];
        // 动态代码表
        if (Object.is(codelistType, "DYNAMIC")) {
            this.codeListService.getItems(codelistTag).then((res: any)=>{
                codelist = res;
            }).catch((error: any) => {
                
            });
        // 静态代码表
        } else if(Object.is(codelistType, "STATIC")){
            codelist = this.$store.getters.getCodeListItems(codelistTag);
        }
        return codelist;
    }
1514

1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534
    /**
     * 根据分组代码表绘制分组列表
     * 
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public drawCodelistGroup(){
        if(!this.isEnableGroup) return;
        // 分组
        let allGroup: Array<any> = [];
        let allGroupField: Array<any> =[];
        let groupTree:Array<any> = [];
        allGroup = this.getGroupCodelist(this.codelistType,this.codelistTag);
        allGroupField = this.getGroupCodelist(this.groupAppFieldCodelistType,this.groupAppFieldCodelistTag);
        if(allGroup.length == 0){
            console.warn("分组数据无效");
        }
        allGroup.forEach((group: any,i: number)=>{
            let children:Array<any> = [];
            this.items.forEach((item: any,j: number)=>{
                if(allGroupField && allGroupField.length > 0){
1535
                    if(Object.is(group.label,item[this.groupAppField])){
1536 1537 1538 1539
                        item.groupById = Number((i+1) * 100 + (j+1) * 1);
                        item.group = '';
                        children.push(item);
                    }
1540
                }else if(Object.is(group.value,item[this.groupAppField])){
1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579
                    item.groupById = Number((i+1) * 100 + (j+1) * 1);
                    item.group = '';
                    children.push(item);
                }
            });
            const tree: any ={
                groupById: Number((i+1)*100),
                group: group.label,
                <#if ctrl.getPSDEGridColumns()??>
                <#list ctrl.getPSDEGridColumns() as singleColumn>
                <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "UAGRIDCOLUMN">
                <#if singleColumn.getPSDEUIActionGroup()?? && singleColumn.getPSDEUIActionGroup().getPSUIActions()??>
                <#list singleColumn.getPSDEUIActionGroup().getPSUIActions() as singleUIAction>
                ${singleUIAction.getCodeName()}:{
                    visabled: false
                },
                </#list>
                </#if>
                <#else>
                <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "DEFGRIDCOLUMN">
                <#if singleColumn.getPSDEUIAction?? && singleColumn.getPSDEUIAction()?? && singleColumn.getPSDEUIAction().getUIActionTag?? && singleColumn.getPSDEUIAction().getUIActionTag()??>
                ${singleColumn.getPSDEUIAction().getUIActionTag()}:{
                    visabled: false
                },
                </#if>
                ${singleColumn.getCodeName()}:'',
                </#if>
                </#if>
                </#list>
                </#if>
                children: children
            }
            groupTree.push(tree);
        });
        let child:Array<any> = [];
        this.items.forEach((item: any,index: number)=>{
            let i: number = 0;
            if(allGroupField && allGroupField.length > 0){
                i = allGroup.findIndex((group: any)=>Object.is(group.label,item[this.groupAppField]));
1580 1581
            }else{
                i = allGroup.findIndex((group: any)=>Object.is(group.value,item[this.groupAppField]));
1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631
            }
            if(i < 0){
                item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
                item.group = '';
                child.push(item);
            }
            if(i < 0){
                item.groupById = Number((allGroup.length+1) * 100 + (index+1) * 1);
                item.group = '';
                child.push(item);
            }
        })
        const Tree: any = {
            groupById: Number((allGroup.length+1)*100),
            group: this.$t('app.gridpage.other'),
            <#if ctrl.getPSDEGridColumns()??>
            <#list ctrl.getPSDEGridColumns() as singleColumn>
            <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "UAGRIDCOLUMN">
            <#if singleColumn.getPSDEUIActionGroup()?? && singleColumn.getPSDEUIActionGroup().getPSUIActions()??>
            <#list singleColumn.getPSDEUIActionGroup().getPSUIActions() as singleUIAction>
            ${singleUIAction.getCodeName()}:{
                visabled: false
            },
            </#list>
            </#if>
            <#else>
            <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "DEFGRIDCOLUMN">
            <#if singleColumn.getPSDEUIAction?? && singleColumn.getPSDEUIAction()?? && singleColumn.getPSDEUIAction().getUIActionTag?? && singleColumn.getPSDEUIAction().getUIActionTag()??>
            ${singleColumn.getPSDEUIAction().getUIActionTag()}:{
                visabled: false
            },
            </#if>
            ${singleColumn.getCodeName()}:'',
            </#if>
            </#if>
            </#list>
            </#if>
            children: child
        }
        if(child && child.length > 0){
            groupTree.push(Tree);
        }
        this.items = groupTree;
        if(this.actualIsOpenEdit) {
            for(let i = 0; i < this.items.length; i++) {
                this.gridItemsModel.push(this.getGridRowModel());
            }
        }
    }

tony001's avatar
tony001 committed
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642
    /**
     * 绘制分组
     * 
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public drawGroup(){
        if(!this.isEnableGroup) return;
        // 分组
        let allGroup: Array<any> = [];
        this.items.forEach((item: any)=>{
            if(item.hasOwnProperty(this.groupAppField)){
1643
                allGroup.push(item[this.groupAppField]);
tony001's avatar
tony001 committed
1644 1645 1646 1647
            }
        });
        let groupTree:Array<any> = [];
        allGroup = [...new Set(allGroup)];
1648 1649 1650
        if(allGroup.length == 0){
            console.warn("分组数据无效");
        }
tony001's avatar
tony001 committed
1651 1652 1653 1654
        // 组装数据
        allGroup.forEach((group: any, groupIndex: number)=>{
            let children:Array<any> = [];
            this.items.forEach((item: any,itemIndex: number)=>{
Shine-zwj's avatar
Shine-zwj committed
1655
                if(Object.is(group,item[this.groupAppField])){
1656
                    item.groupById = Number((groupIndex+1) * 100 + (itemIndex+1) * 1);
tony001's avatar
tony001 committed
1657 1658 1659 1660
                    item.group = '';
                    children.push(item);
                }
            });
1661
            group = group ? group : this.$t('app.gridpage.other');
tony001's avatar
tony001 committed
1662
            const tree: any ={
1663
                groupById: Number((groupIndex+1)*100),
tony001's avatar
tony001 committed
1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675
                group: group,
                <#if ctrl.getPSDEGridColumns()??>
                <#list ctrl.getPSDEGridColumns() as singleColumn>
                <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "UAGRIDCOLUMN">
                <#if singleColumn.getPSDEUIActionGroup()?? && singleColumn.getPSDEUIActionGroup().getPSUIActions()??>
                <#list singleColumn.getPSDEUIActionGroup().getPSUIActions() as singleUIAction>
                ${singleUIAction.getCodeName()}:{
                    visabled: false
                },
                </#list>
                </#if>
                <#else>
1676 1677 1678 1679 1680 1681
                <#if singleColumn.getColumnType()?? && singleColumn.getColumnType() == "DEFGRIDCOLUMN">
                <#if singleColumn.getPSDEUIAction?? && singleColumn.getPSDEUIAction()?? && singleColumn.getPSDEUIAction().getUIActionTag?? && singleColumn.getPSDEUIAction().getUIActionTag()??>
                ${singleColumn.getPSDEUIAction().getUIActionTag()}:{
                    visabled: false
                },
                </#if>
tony001's avatar
tony001 committed
1682 1683
                ${singleColumn.getCodeName()}:'',
                </#if>
1684
                </#if>
tony001's avatar
tony001 committed
1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700
                </#list>
                </#if>
                children: children,
            }
            groupTree.push(tree);
        });
        this.items = groupTree;
        if(this.actualIsOpenEdit) {
            for(let i = 0; i < this.items.length; i++) {
                this.gridItemsModel.push(this.getGridRowModel());
            }
        }
    }

    /**
     * 单个复选框选中
1701
     *
tony001's avatar
tony001 committed
1702 1703
     * @param {*} selection 所有选中行数据
     * @param {*} row 当前选中行数据
KK's avatar
KK committed
1704
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1705
     */
tony001's avatar
tony001 committed
1706
    public select(selection: any, row: any): void {
Mosher's avatar
Mosher committed
1707
        //  选中事件
Mosher's avatar
Mosher committed
1708
        this.handleCtrlEvents('onselectionchange', { data: [row] }).then((result: boolean) => {
Mosher's avatar
Mosher committed
1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726
            if (!result) {
                return;
            }
            if(this.groupAppField) {
                let isContain:boolean = selection.some((item:any) =>{
                    return  item == row;
                }) 
                // 是否选中当前行,选中为true,否则为false
                if(isContain) {
                    // 当前行为分组行
                    if(row.children && row.children.length > 0) {
                        this.toggleSelection(row.children, true);
                        row.children.forEach((children: any) => {
                            this.selections.push(children);
                        });
                    } else {
                        this.selections.push(row);
                    }
tony001's avatar
tony001 committed
1727
                } else {
Mosher's avatar
Mosher committed
1728 1729 1730 1731 1732 1733
                    if(row.children && row.children.length > 0) {
                        this.toggleSelection(row.children, false);
                        this.selections = this.computeCheckedData(this.selections, row.children);
                    } else {
                        this.selections = this.computeCheckedData(this.selections, row);
                    }
tony001's avatar
tony001 committed
1734
                }
Mosher's avatar
Mosher committed
1735
                this.selections = [...new Set(this.selections)]
tony001's avatar
tony001 committed
1736
            } else {
Mosher's avatar
Mosher committed
1737 1738
                if(!selection) {
                    return;
tony001's avatar
tony001 committed
1739
                }
Mosher's avatar
Mosher committed
1740
                this.selections = [...JSON.parse(JSON.stringify(selection))];
tony001's avatar
tony001 committed
1741
            }
Mosher's avatar
Mosher committed
1742 1743
            this.$emit('selectionchange', this.selections);
        });
1744 1745
    }

tony001's avatar
tony001 committed
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799
    /**
     * 计算当前选中数据
     *
     * @param {*} selectionArray 所有选中行数据
     * @param {*} cancelData 被取消选中行数据,分组行为数组,非分组行为对象
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public computeCheckedData(selectionArray: any[], cancelData: Array<any> | any) {
        let targetArray: Array<any> = [];
        //  分组行
        if(Array.isArray(cancelData)) {
            if(selectionArray && selectionArray.length > 0) {
                selectionArray.forEach((selection:any) =>{
                    let tempFlag:boolean = true;
                    cancelData.forEach((child:any) =>{
                        if(selection.groupById===child.groupById){
                            tempFlag = false;
                        }
                    })
                    if(tempFlag) targetArray.push(selection);
                })
            }
        } else {
        //  非分组行
            if(selectionArray && selectionArray.length > 0) {
                selectionArray.forEach((selection:any) =>{
                    let tempFlag:boolean = true;
                    if(selection.groupById===cancelData.groupById){
                        tempFlag = false;
                    }
                    if(tempFlag) targetArray.push(selection);
                })
            }
        }
        return targetArray;
    }

    /**
     * 设置非分组行checkbox选中状态
     *
     * @param {*} rows 选中数据数组
     * @param {boolean} flag 是否选中
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public toggleSelection(rows?: any, flag?: boolean) {
        if(rows) {
            rows.forEach((row:any) => {
                (this.$refs.multipleTable as any).toggleRowSelection(row, flag);
            });
        } else {
            (this.$refs.multipleTable as any).clearSelection();
        }
    }

1800 1801 1802 1803
    /**
     * 复选框数据全部选中
     *
     * @param {*} $event
KK's avatar
KK committed
1804
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1805
     */
tony001's avatar
tony001 committed
1806 1807 1808 1809 1810 1811
    public selectAll(selection: any): void {
        this.selections = [];   
        if(this.groupAppField) {
            let flag: boolean = true;
            if(selection && selection.length === this.items.length) {
                selection.forEach((element: any) => {
1812
                    if(element.children) {
tony001's avatar
tony001 committed
1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831
                        this.toggleSelection(element.children, flag);
                        element.children.forEach((children: any) => {
                            this.selections.push(children);
                        });
                    } else {
                        flag = false;
                    }
                });
            } else {
                flag = false;
            }
            if(!flag) {
                this.toggleSelection();
            }
        } else {
            if(!selection) {
                return;
            }
            this.selections = [...JSON.parse(JSON.stringify(selection))];
1832 1833 1834 1835
        }
        this.$emit('selectionchange', this.selections);
    }

1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846
    /**
     * 单元格单击隐藏提示框
     *
     * @memberof MainBase
     */
    public cellClick() {
        let el: any = document.getElementsByClassName('el-tooltip__popper')[0];
        if (el) {
            el.style.display = 'none';
        }
    }
1847 1848 1849 1850 1851 1852
    
    /**
     * 行单击选中
     *
     * @param {*} $event
     * @returns {void}
KK's avatar
KK committed
1853
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1854
     */
1855
    public rowClick($event: any, ifAlways: boolean = false): void {
tony001's avatar
tony001 committed
1856
        // 分组行跳过
1857
        if($event && $event.children){
tony001's avatar
tony001 committed
1858 1859
            return;
        }
1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871
        if (!ifAlways && (!$event || this.actualIsOpenEdit)) {
            return;
        }
        if(this.stopRowClick) {
            this.stopRowClick = false;
            return;
        }
        if(this.isSingleSelect){
            this.selections = [];
        }
        // 已选中则删除,没选中则添加
        let selectIndex = this.selections.findIndex((item:any)=>{
1872
            return Object.is(item.${ctrl.getPSAppDataEntity().getCodeName()?lower_case},$event.${ctrl.getPSAppDataEntity().getCodeName()?lower_case});
1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898
        });
        if (Object.is(selectIndex,-1)){
          this.selections.push(JSON.parse(JSON.stringify($event)));
        } else {
          this.selections.splice(selectIndex,1);
        }

        const refs: any = this.$refs;
        if (refs.multipleTable) {
            if(this.isSingleSelect){
                refs.multipleTable.clearSelection();
                refs.multipleTable.setCurrentRow($event);
            }else{
                refs.multipleTable.toggleRowSelection($event); 
            }
        }

        this.$emit('selectionchange', this.selections);
    }


    /**
     * 页面变化
     *
     * @param {*} $event
     * @returns {void}
KK's avatar
KK committed
1899
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1900
     */
1901
    public handlePageChange($event: any): void {
1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916
        if (!$event) {
            return;
        }
        if ($event === this.curPage) {
            return;
        }
        this.curPage = $event;
        this.load({});
    }

    /**
     * 分页条数变化
     *
     * @param {*} $event
     * @returns {void}
KK's avatar
KK committed
1917
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1918
     */
1919
    public handlePageSizeChange($event: any): void {
1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934
        if (!$event) {
            return;
        }
        if ($event === this.limit) {
            return;
        }
        this.limit = $event;
        if (this.curPage === 1) {
            this.load({});
        }
    }

    /**
     * 分页刷新
     *
KK's avatar
KK committed
1935
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1936
     */
1937
    public pageRefresh(): void {
1938
        this.load({});
1939 1940 1941 1942 1943 1944
    }

    /**
     * 排序变化
     *
     * @param {{ column: any, prop: any, order: any }} { column, prop, order }
KK's avatar
KK committed
1945
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1946
     */
1947
    public onSortChange({ column, prop, order }: { column: any, prop: any, order: any }): void {
1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961
        const dir = Object.is(order, 'ascending') ? 'asc' : Object.is(order, 'descending') ? 'desc' : '';
        if (Object.is(dir, this.minorSortDir) && Object.is(this.minorSortPSDEF, prop)) {
            return;
        }
        this.minorSortDir = dir;
        this.minorSortPSDEF = prop ? prop : '';
        this.load({});
    }

    /**
     * 表格行选中样式
     *
     * @param {{ row: any, rowIndex: any }} { row, rowIndex }
     * @returns {string}
KK's avatar
KK committed
1962
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1963
     */
1964
    public onRowClassName({ row, rowIndex }: { row: any, rowIndex: any }): string {
1965 1966 1967 1968 1969 1970 1971 1972 1973
        const index = this.selections.findIndex((select: any) => Object.is(select.srfkey, row.srfkey));
        return index !== -1 ? 'grid-row-select' : '';
    }

<#if ctrl.getAggMode() != "NONE">
    /**
     * 合计行绘制
     *
     * @param {any} param
KK's avatar
KK committed
1974
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
1975
     */
1976
    public getSummaries(param:any){
1977 1978 1979 1980 1981
    <#if ctrl.getAggMode() == "PAGE">
        const { columns, data } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
          if (index === 0) {
1982
            sums[index] = (this.$t('app.gridpage.sum') as string);
1983 1984
            return;
          }
1985 1986 1987 1988
            <#if ctrl.getPSDEGridColumns?? && ctrl.getPSDEGridColumns()??>
                <#list ctrl.getPSDEGridColumns() as columns >
                    <#if columns.getColumnType?? && columns.getColumnType() == "UAGRIDCOLUMN">
          if(column.columnKey && Object.is(column.columnKey,'${columns.getName()?lower_case}')){
1989 1990 1991
            sums[index] = '';
            return;
          }
1992 1993 1994
                    </#if>
                </#list>
            </#if>
1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008
          const values = data.map((item:any) => Number(item[column.property]));
          if (!values.every((value:any) => isNaN(value))) {
            <#if ctrl.getPSDEGridColumns()??>
            <#list ctrl.getPSDEGridColumns() as singleColumn>
            <#if singleColumn.getAggMode() == "SUM">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData = values.reduce((prev:any, curr:any) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
2009
                    sums[index] = tempData.toFixed(3);
2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020
                }
            <#elseif singleColumn.getAggMode() == "AVG">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData = values.reduce((prev:any, curr:any) => {
                        const value = Number(curr);
                        if (!isNaN(value)) {
                            return prev + curr;
                        } else {
                            return prev;
                        }
                    }, 0);
2021
                    sums[index] = (tempData/data.length).toFixed(2);
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058
                }
            <#elseif singleColumn.getAggMode() == "MAX">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData:any;
                    values.forEach((item:any) =>{
                    const value = Number(item);
                        if (!isNaN(value)) {
                            if(!tempData){
                                tempData = value;
                            }
                            if(value > tempData){
                                tempData = value;
                            }
                        }
                    });
                    sums[index] = tempData;
                }
            <#elseif singleColumn.getAggMode() == "MIN">
                if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                    let tempData:any;
                    values.forEach((item:any) =>{
                    const value = Number(item);
                        if (!isNaN(value)) {
                            if(!tempData){
                                tempData = value;
                            }
                            if(value < tempData){
                                tempData = value;
                            }
                        }
                    });
                    sums[index] = tempData;
                }
            </#if>
            </#list>
            </#if>
          } else {
2059
            sums[index] = '';
2060 2061 2062 2063 2064 2065 2066 2067
          }
        });
        return sums;
    <#elseif ctrl.getAggMode() == "ALL">
        const { columns } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
        if (index === 0) {
2068
            sums[index] = (this.$t('app.gridpage.sum') as string);
2069 2070 2071 2072 2073 2074
            return;
        }else if(index === (columns.length - 1)){
            sums[index] = '';
            return;
        }else{
        <#if ctrl.getPSDEGridColumns()??>
2075
            sums[index] = '';
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105
        <#list ctrl.getPSDEGridColumns() as singleColumn>
            <#if singleColumn.getAggMode() != "NONE">
            if(Object.is(column.property,'${singleColumn.getCodeName()?lower_case}')){
                const value = Number(this.remoteData.${singleColumn.getCodeName()?lower_case});
                if (!isNaN(value)) {
            <#if singleColumn.getAggMode() == "SUM">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "AVG">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "MAX">
                    sums[index] =  value;
            <#elseif singleColumn.getAggMode() == "MIN">
                    sums[index] =  value;
            </#if>
                }
            }
            </#if>
        </#list>
        </#if>
        }
        });
        return sums; 
    </#if>
      }
</#if>

<#if ctrl.getAggMode() == "ALL">
    /**
     * 远程获取合计行数据
     *
KK's avatar
KK committed
2106
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2107
     */
2108
    public getAggData(){
2109 2110
        this.service.getAggData(this.aggAction,JSON.parse(JSON.stringify(this.context)),this.showBusyIndicator).then((response:any) =>{
            if (!response.status || response.status !== 200) {
2111 2112
                if (response.data && response.data.message) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123
                }
                return;
            }
            this.remoteData = response.data;
            this.isDisplay = true;
        }).catch((response:any) =>{
            if (response && response.status === 401) {
                return;
            }
            this.remoteData = {};
            this.isDisplay = true;
2124
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data && response.data.message ? response.data.message : "" });
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134
        })
    }
</#if>

    /**
     * 界面行为
     *
     * @param {*} row
     * @param {*} tag
     * @param {*} $event
KK's avatar
KK committed
2135
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2136
     */
2137
	public uiAction(row: any, tag: any, $event: any) {
tony001's avatar
tony001 committed
2138
        // this.rowClick(row, true);
2139
        this.cellClick();
tony001's avatar
tony001 committed
2140
        $event.stopPropagation();
2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155
        <#if ctrl.getPSAppViewLogics()??>
        <#list ctrl.getPSAppViewLogics() as logic>
        <#if logic.getPSAppViewUIAction().getPSUIAction()??>
        <#assign action = logic.getPSAppViewUIAction().getPSUIAction()>
        if(Object.is('${action.getUIActionTag()}', tag)) {
            this.${logic.getName()}(row, tag, $event);
        }
        </#if>
        </#list>
        </#if>
    }

    /**
     * 设置列状态
     *
KK's avatar
KK committed
2156
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2157
     */
2158
    public setColState() {
tony001's avatar
tony001 committed
2159
		const _data: any = localStorage.getItem('${ctrl.getPSAppDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}');
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173
		if (_data) {
			let columns = JSON.parse(_data);
			columns.forEach((col: any) => {
				let column = this.allColumns.find((item) => Object.is(col.name, item.name));
				if (column) {
					Object.assign(column, col);
				}
			});
		}
    }

    /**
     * 列变化
     *
KK's avatar
KK committed
2174
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2175
     */
2176
    public onColChange() {
tony001's avatar
tony001 committed
2177
        localStorage.setItem('${ctrl.getPSAppDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}', JSON.stringify(this.allColumns));
2178 2179 2180 2181 2182 2183 2184
    }

    /**
     * 获取列状态
     *
     * @param {string} name
     * @returns {boolean}
KK's avatar
KK committed
2185
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2186
     */
2187
    public getColumnState(name: string): boolean {
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198
        let column = this.allColumns.find((col: any) =>
            Object.is(name, col.name)
        );
        return column.show ? true : false;
    }

    /**
     * 表格列是否自适应布局
     *
     * @readonly
     * @type {boolean}
KK's avatar
KK committed
2199
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2200 2201
     */
    get adaptiveState(): boolean {
tony001's avatar
tony001 committed
2202
        return !this.allColumns.find((column: any) => column.show && Object.is(column.unit, 'STAR'));
2203 2204 2205 2206 2207 2208
    }

    /**
     * 保存
     *
     * @param {*} $event
2209
     * @returns {Promise<any>}
KK's avatar
KK committed
2210
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2211
     */
2212
    public async save(args: any[], params?: any, $event?: any, xData?: any){
2213
        let _this = this;
2214
        // 拷贝模式
Mosher's avatar
Mosher committed
2215 2216 2217 2218 2219 2220
        if (
            _this.viewparams &&
            _this.viewparams.copymode &&
            Object.is(_this.viewparams.copymode,'true') &&
            _this.items && 
            _this.items.length >0) {
2221 2222 2223 2224
            for (const item of _this.items) {
                item.rowDataState = 'create';
            }
        }
Mosher's avatar
Mosher committed
2225
        if (_this.items && _this.items.length > 0) {
2226
            for (const item of _this.items) {
Mosher's avatar
Mosher committed
2227
                if (Object.is(item.rowDataState, 'update')) {
2228 2229 2230 2231
                    _this.updateDefault(item);
                }
            }
        }
2232
        if (!await this.validateAll()) {
Mosher's avatar
Mosher committed
2233
            if (this.errorMessages && this.errorMessages.length > 0) {
2234 2235 2236 2237
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: this.errorMessages[0] });
            } else {
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.rulesException') as string) });
            }
2238 2239 2240 2241 2242
            return [];
        }
        let successItems:any = [];
        let errorItems:any = [];
        let errorMessage:any = [];
Mosher's avatar
Mosher committed
2243 2244 2245
        if (!(await this.handleCtrlEvents('onbeforesave', { data: _this.items }))) {
            return;
        }
2246 2247
        for (const item of _this.items) {
            try {
Mosher's avatar
Mosher committed
2248 2249
                if (Object.is(item.rowDataState, 'create')) {
                    if (!this.createAction) {
2250
                        this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.createAction') as string) });
Mosher's avatar
Mosher committed
2251 2252 2253 2254 2255
                    } else {
                        Object.assign(item, { viewparams: this.viewparams });
                        const tempContext = Util.deepCopy(this.context);
                        let response = await this.service.add(this.createAction, tempContext, item, this.showBusyIndicator);
                        successItems.push(JSON.parse(JSON.stringify(response.data)));
2256
                    }
Mosher's avatar
Mosher committed
2257 2258
                }else if (Object.is(item.rowDataState, 'update')){
                    if (!this.updateAction) {
2259
                        this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: '${view.getName()}'+(this.$t('app.gridpage.notConfig.updateAction') as string) });
Mosher's avatar
Mosher committed
2260 2261 2262
                    } else {
                        Object.assign(item, { viewparams: this.viewparams });
                        const tempContext = Util.deepCopy(this.context);
2263
<#if de??>
2264
                        if(item.${appde.getCodeName()?lower_case}){
Mosher's avatar
Mosher committed
2265
                            Object.assign(tempContext, { ${appde.getCodeName()?lower_case}: item.${appde.getCodeName()?lower_case} });
2266
                        }
2267
</#if>
Mosher's avatar
Mosher committed
2268
                        let response = await this.service.update(this.updateAction, tempContext, item, this.showBusyIndicator);
2269 2270 2271 2272 2273 2274
                        successItems.push(JSON.parse(JSON.stringify(response.data)));
                    }
                }
            } catch (error) {
                errorItems.push(JSON.parse(JSON.stringify(item)));
                errorMessage.push(error);
2275
            }
2276 2277 2278
        }
        this.$emit('save', successItems);
        this.refresh([]);
2279
        if(errorItems.length === 0 && successItems.length > 0){
Mosher's avatar
Mosher committed
2280 2281 2282
            if (!(await this.handleCtrlEvents('onsavesuccess', { data: successItems }))) {
                return;
            }
2283
            this.$Notice.success({ title: '', desc: (this.$t('app.commonWords.saveSuccess') as string) });
Mosher's avatar
Mosher committed
2284 2285 2286 2287
        } else {
            if (!(await this.handleCtrlEvents('onsaveerror', { data: errorItems }))) {
                return;
            }
2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341
            errorItems.forEach((item: any, index: number) => {
                if(errorMessage[index] && errorMessage[index].data) {
                    if(Object.is(errorMessage[index].data.errorKey, 'DupCheck')) {
                        let errorProp: string = errorMessage[index].data.message.match(/\[[a-zA-Z]*\]/)[0];
                        let name: string = errorProp ? this.service.getNameByProp(errorProp.substr(1, errorProp.length-2)) : '';
                        if(name) {
                            let desc: any = this.allColumns.find((column: any) =>{
                                return Object.is(column.name, name);
                            });
                            this.$Notice.error({
                                title: (this.$t('app.commonWords.createFailed') as string),
                                desc: (desc ? desc.label : '') + " : " + item[name] + (this.$t('app.commonWords.isExist') as string) + '!',
                            });
                        } else {
                            this.$Notice.error({
                                title: (this.$t('app.commonWords.createFailed') as string),
                                desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
                            });
                        }
                    } else if(Object.is(errorMessage[index].data.errorKey, 'DuplicateKeyException')){
                        <#if ctrl.getAllPSDEGridColumns?? && ctrl.getAllPSDEGridColumns()??>
                            <#list ctrl.getAllPSDEGridColumns() as column>
                                <#if column.getPSAppDEField?? && column.getPSAppDEField()?? && column.getPSAppDEField().isKeyField() && appde.getKeyPSAppDEField()?? && appde.getKeyPSAppDEField().getCodeName() == column.getPSAppDEField().getCodeName()>
                                    <#assign columnKeyName = column.getName()?lower_case >
                                </#if>
                            </#list>
                        </#if>
                        <#if columnKeyName??>
                        let name: string = this.service.getNameByProp("${columnKeyName}");
                        if(name){
                            let desc: any = this.allColumns.find((column: any) =>{
                                return Object.is(column.name, name);
                            });
                            this.$Notice.error({
                                title: (this.$t('app.commonWords.createFailed') as string),
                                desc: (desc ? desc.label : '') + " : " + item[name] + (this.$t('app.commonWords.isExist') as string) + '!',
                            });
                        }
                        <#else>
                        this.$Notice.error({
                            title: (this.$t('app.commonWords.saveFailed') as string),
                            desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
                        });
                        </#if>
                    }else {
                        this.$Notice.error({
                            title: (this.$t('app.commonWords.saveFailed') as string),
                            desc: errorMessage[index].data.message?errorMessage[index].data.message:(this.$t('app.commonWords.sysException') as string),
                        });
                    }
                } else {
                    this.$Notice.error({ title: (this.$t('app.commonWords.saveFailed') as string), desc: (item[this.majorInfoColName]?item[this.majorInfoColName]:"") + (this.$t('app.commonWords.saveFailed') as string) + '!' });
                }
            });
2342 2343
        }
        return successItems;
2344 2345 2346 2347 2348 2349 2350
    }

    /**
     * 新建行
     *
     * @param {*} $event
     * @returns {void}
KK's avatar
KK committed
2351
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2352
     */
Mosher's avatar
Mosher committed
2353
    public async newRow(args: any[], params?: any, $event?: any, xData?: any): Promise<any> {
2354
        if(!this.loaddraftAction){
Mosher's avatar
Mosher committed
2355 2356 2357 2358
            this.$Notice.error({
                title: (this.$t('app.commonWords.wrong') as string),
                desc: '${view.getName()}' + (this.$t('app.gridpage.notConfig.loaddraftAction') as string)
            });
2359 2360 2361
            return;
        }
        let _this = this;
Mosher's avatar
Mosher committed
2362 2363 2364 2365 2366 2367 2368
        Object.assign(args[0], { viewparams: Util.deepCopy(this.viewparams) });
        try {
            //  加载草稿之前
            if (!(await this.handleCtrlEvents('onbeforeloaddraft', { data: args[0] }))) {
                return;
            }
            const response = await this.service.loadDraft(this.loaddraftAction, Util.deepCopy(this.context), args[0], this.showBusyIndicator);
2369
            if (!response.status || response.status !== 200) {
Mosher's avatar
Mosher committed
2370 2371 2372 2373
                //  加载草稿失败
                if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : {} }))) {
                    return;
                }
2374 2375
                if (response.data && response.data.message) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
2376
                }
Mosher's avatar
Mosher committed
2377 2378 2379 2380
                return response;
            }
            //  加载草稿成功
            if (!(await this.handleCtrlEvents('onloaddraftsuccess', { data: response.data }))) {
2381 2382 2383
                return;
            }
            const data = response.data;
tony001's avatar
tony001 committed
2384
            this.createDefault(data);
2385
            data.rowDataState = "create";
2386
            this.items.splice(0,0,data);
2387
            _this.gridItemsModel.push(_this.getGridRowModel());
Mosher's avatar
Mosher committed
2388 2389 2390 2391
            return response;
        } catch(response: any) {
            //  加载草稿失败
            if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response.data ? response.data : {} }))) {
2392 2393
                return;
            }
Mosher's avatar
Mosher committed
2394 2395 2396
            if (response && response.status === 401) {
                return response;
            }
2397
            if (!response || !response.status || !response.data) {
2398
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
2399 2400
                return;
            }
Mosher's avatar
Mosher committed
2401
        }
2402 2403 2404 2405 2406 2407 2408 2409
    }

    /**
     * 表格编辑项值变更
     *  
     * @param row 行数据
     * @param {{ name: string, value: any }} $event
     * @returns {void}
KK's avatar
KK committed
2410
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2411
     */
2412
    public onGridItemValueChange(row: any,$event: { name: string, value: any },rowIndex: number): void {
2413 2414 2415 2416 2417 2418 2419
        if (!$event) {
            return;
        }
        if (!$event.name || Object.is($event.name, '') || !row.hasOwnProperty($event.name)) {
            return;
        }
        row[$event.name] = $event.value;
2420
        this.gridEditItemChange(row, $event.name, $event.value, rowIndex);
2421 2422 2423 2424 2425
    }

    /**
     * 表格编辑项值变化
     *
2426
     * @public
2427 2428 2429 2430
     * @param row 行数据
     * @param property 列编辑项名
     * @param row 列编辑项值
     * @returns {void}
KK's avatar
KK committed
2431
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2432
     */
2433
    public gridEditItemChange(row: any, property: string, value: any, rowIndex: number){
2434
        row.rowDataState = row.rowDataState ? row.rowDataState : "update" ;
2435
        if(Object.is(row.rowDataState,"update")){
2436
            if(this.defaultUpdateItems.includes(property)){
2437 2438 2439
                row.hasUpdated = true;
            }
        }
2440
        this.curEditRowData = row;
2441
        this.resetGridData(row, property, rowIndex);
2442
        this.validate(property,row,rowIndex);
2443 2444 2445 2446 2447 2448
  <#if ctrl.getPSDEGridEditItems()??>
    <#list ctrl.getPSDEGridEditItems() as editItem>
      <#if editItem.getPSDEGridEditItemUpdate()??>
      <#assign itemUpdate=editItem.getPSDEGridEditItemUpdate()/>
        if(Object.is(property, '${editItem.name}')){
            const details: string[] = [<#list itemUpdate.getPSDEGEIUpdateDetails() as detail><#if detail_index gt 0>, </#if>'${detail.getPSDEGridColumnName()?lower_case}'</#list>];
2449
            this.updateGridEditItem('${itemUpdate.getPSAppDEMethod().getCodeName()}', row, details, ${itemUpdate.isShowBusyIndicator()?c});
2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463
        }
      </#if>
    </#list>
  </#if>
    }

    /**
     * 表格编辑项更新
     *
     * @param {string} mode 界面行为名称
     * @param {*} [data={}] 请求数据
     * @param {string[]} updateDetails 更新项
     * @param {boolean} [showloading] 是否显示加载状态
     * @returns {void}
KK's avatar
KK committed
2464
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2465
     */
2466
    public updateGridEditItem(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
2467 2468 2469
        if (!mode || (mode && Object.is(mode, ''))) {
            return;
        }
2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480
        <#if ctrl.getAllPSDEGridColumns?? && ctrl.getAllPSDEGridColumns()??>
          <#list ctrl.getAllPSDEGridColumns() as column>
            <#if column.getPSAppDEField?? && column.getPSAppDEField()?? && column.getPSAppDEField().isKeyField() && appde.getKeyPSAppDEField()?? && appde.getKeyPSAppDEField().getCodeName() == column.getPSAppDEField().getCodeName()>
                <#assign columnKeyName = column.getName()?lower_case >
            </#if>
          </#list>
        </#if>
        let tempContext: any = this.$util.deepCopy(this.context);
        <#if columnKeyName??>
        Object.is(tempContext, { ${appde.getCodeName()?lower_case}: data.${columnKeyName} });
        </#if>
2481 2482
        const arg: any = JSON.parse(JSON.stringify(data));
        Object.assign(arg,{viewparams:this.viewparams});
2483
        const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(tempContext)),arg, showloading);
2484 2485
        post.then((response: any) => {
            if (!response || response.status !== 200) {
2486
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.gridpage.formitemFailed') as string) });
2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503
                return;
            }
            const _data: any = response.data;
            if(!_data){
                return;
            }
            updateDetails.forEach((name: string) => {
                if (!_data.hasOwnProperty(name)) {
                    return;
                }
                data[name] = _data[name];
            });
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            if (!response || !response.status || !response.data) {
2504
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
2505 2506 2507 2508 2509 2510 2511 2512 2513 2514
                return;
            }
        });
    }

    /**
     * 获取对应行class
     *
     * @param {*} $args row 行数据,rowIndex 行索引
     * @returns {void}
KK's avatar
KK committed
2515
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
2516
     */
2517
    public getRowClassName(args:{row: any,rowIndex: number}){
2518 2519 2520 2521 2522
        let isSelected = this.selections.some((item:any)=>{
            return Object.is(item.${appde.getCodeName()?lower_case},args.row.${appde.getCodeName()?lower_case});
        });
        return isSelected ? "grid-selected-row" : "";
    }
tony001's avatar
tony001 committed
2523

2524
    /**
tony001's avatar
tony001 committed
2525
     * 获取对应单元格class
2526
     *
tony001's avatar
tony001 committed
2527
     * @param {*} $args row 行数据,column 列数据,rowIndex 行索引,columnIndex 列索引
2528 2529 2530 2531
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public getCellClassName(args:{row: any, column: any, rowIndex: number, columnIndex:number}){
tony001's avatar
tony001 committed
2532
        let className: string = '';
2533 2534 2535 2536 2537 2538
        if(args.column.property){
          let col = this.allColumns.find((item:any)=>{
              return Object.is(args.column.property,item.name);
          })
          if(col !== undefined){
              if(col.isEnableRowEdit && this.actualIsOpenEdit ){
tony001's avatar
tony001 committed
2539
                className += 'edit-cell ';
2540
              }
tony001's avatar
tony001 committed
2541 2542
          } else {
              className += 'info-cell';
2543
          }
2544
        }
tony001's avatar
tony001 committed
2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577
        if(this.groupAppField && args.columnIndex === 0 && !this.isSingleSelect) {
            if(args.row.children && args.row.children.length > 0) {
                className += this.computeGroupRow(args.row.children, args.row);
            }
        }
        return className;
    }

    /**
     * 计算分组行checkbox选中样式
     *
     * @param {*} rows 当前分组行下的所有数据
     * @returns {*} currentRow 当前分组行
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public computeGroupRow(rows: any[], currentRow: any) {
        let count: number = 0;
        this.selections.forEach((select: any) => {
            rows.forEach((row: any) => {
                if(row.groupById === select.groupById) {
                    count++;
                }
            })
        })
        if(count === rows.length) {
            (this.$refs.multipleTable as any).toggleRowSelection(currentRow, true);
            return 'cell-select-all ';
        } else if(count !== 0 && count < rows.length) {
            return 'cell-indeterminate '
        } else if(count === 0) {
            (this.$refs.multipleTable as any).toggleRowSelection(currentRow, false);
            return '';
        }
2578 2579
    }

tony001's avatar
tony001 committed
2580 2581 2582
    /**
     * 新建默认值
     * @param {*}  row 行数据
KK's avatar
KK committed
2583
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
tony001's avatar
tony001 committed
2584 2585
     */
    public createDefault(row: any){                    
2586
<#list ctrl.getPSDEGridEditItems() as editItem><#t>
2587
  <#if (editItem.getCreateDV?? || editItem.getCreateDVT??) && (editItem.getCreateDV()?? || editItem.getCreateDVT()??) && (editItem.getCreateDV() !="" || editItem.getCreateDVT() !="")><#t>
tony001's avatar
tony001 committed
2588
        if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}')) {
2589
    <#if !(editItem.getCreateDVT() == '')><#t>
2590 2591
      <#-- 网页请求 -->
      <#if editItem.getCreateDVT() == 'CONTEXT'>
tony001's avatar
tony001 committed
2592
            row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getCreateDV()}'];
2593 2594
      <#-- 用户全局对象 -->
      <#elseif editItem.getCreateDVT() == 'SESSION'>
tony001's avatar
tony001 committed
2595
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getCreateDV()}'];
2596 2597
      <#-- 当前应用数据 -->
      <#elseif editItem.getCreateDVT() == 'APPDATA'>
tony001's avatar
tony001 committed
2598
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getCreateDV()}'];
2599 2600
      <#-- 当前操作用户(名称) -->
      <#elseif editItem.getCreateDVT() == 'OPERATORNAME'>
tony001's avatar
tony001 committed
2601
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfusername'];
2602 2603
      <#-- 当前操作用户(编号) -->
      <#elseif editItem.getCreateDVT() == 'OPERATOR'>
tony001's avatar
tony001 committed
2604
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfuserid'];
2605 2606
      <#-- 当前时间 -->
      <#elseif editItem.getCreateDVT() == 'CURTIME'>
2607
            row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
2608 2609
      <#-- 数据对象属性 -->
      <#elseif editItem.getCreateDVT() == 'PARAM'>
2610
            row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("CREATE","${editItem.getCreateDV()}",row);
2611 2612
      </#if>
    <#else>
2613 2614
      <#-- 默认值 -->
        <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
tony001's avatar
tony001 committed
2615
            row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getCreateDV()}<#else>'${editItem.getCreateDV()}'</#if>;
2616
    </#if>
2617
        }
2618
  </#if>
2619 2620 2621 2622 2623 2624 2625 2626 2627 2628
</#list>
    }

    /**
     * 更新默认值
     * @param {*}  row 行数据
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public updateDefault(row: any){                    
<#list ctrl.getPSDEGridEditItems() as editItem><#t>
2629
  <#if (editItem.getUpdateDV?? || editItem.getUpdateDVT??) && (editItem.getUpdateDV()?? || editItem.getUpdateDVT()??) && (editItem.getUpdateDV() !="" || editItem.getUpdateDVT() !="")><#t>
2630
        if (row.hasOwnProperty('${editItem.getCodeName()?lower_case}') && !row.${editItem.getCodeName()?lower_case} && row.hasUpdated) {
2631
    <#if !(editItem.getUpdateDVT() == '')><#t>
2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649
      <#-- 网页请求 -->
      <#if editItem.getUpdateDVT() == 'CONTEXT'>
            row['${editItem.getCodeName()?lower_case}'] = this.viewparams['${editItem.getUpdateDV()}'];
      <#-- 用户全局对象 -->
      <#elseif editItem.getUpdateDVT() == 'SESSION'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getUpdateDV()}'];
      <#-- 当前应用数据 -->
      <#elseif editItem.getUpdateDVT() == 'APPDATA'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['${editItem.getUpdateDV()}'];
      <#-- 当前操作用户(名称) -->
      <#elseif editItem.getUpdateDVT() == 'OPERATORNAME'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfusername'];
      <#-- 当前操作用户(编号) -->
      <#elseif editItem.getUpdateDVT() == 'OPERATOR'>
            row['${editItem.getCodeName()?lower_case}'] = this.context['srfuserid'];
      <#-- 当前时间 -->
      <#elseif editItem.getUpdateDVT() == 'CURTIME'>
            row['${editItem.getCodeName()?lower_case}'] = this.$util.dateFormat(new Date());
2650 2651
      <#-- 数据对象属性 -->
      <#elseif editItem.getUpdateDVT() == 'PARAM'>
2652
            row['${editItem.getCodeName()?lower_case}'] = this.computeDefaultValueWithParam("UPDATE","${editItem.getUpdateDV()}",row);
2653 2654 2655
      </#if>
    <#else>
        <#-- 默认值 -->
2656 2657 2658
        <#assign datatype=srfjavatype(editItem.getPSAppDEField().getStdDataType())>
            row['${editItem.getCodeName()?lower_case}'] = <#if datatype=='BigInteger' || datatype=='Integer' || datatype=='Double' || datatype=='Decimal' || datatype=='Float' || datatype=='BigDecimal'>${editItem.getUpdateDV()}<#else>'${editItem.getUpdateDV()}'</#if>;
    </#if>
2659
        }
2660
  </#if>
2661
</#list>
tony001's avatar
tony001 committed
2662
    }
2663

2664 2665 2666
    /**
     * 计算数据对象类型的默认值
     * @param {string}  action 行为
2667 2668
     * @param {string}  param 默认值参数
     * @param {*}  data 当前行数据
2669 2670
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
2671
    public computeDefaultValueWithParam(action:string,param:string,data:any){
2672 2673 2674
        if(Object.is(action,"UPDATE")){
            const nativeData:any = this.service.getCopynativeData();
            if(nativeData && (nativeData instanceof Array) && nativeData.length >0){
2675 2676 2677 2678 2679 2680 2681 2682
                let targetData:any = nativeData.find((item:any) =>{
                    return item.${appde.getKeyPSAppDEField().getCodeName()?lower_case} === data.srfkey;
                })
                if(targetData){
                    return targetData[param]?targetData[param]:null;
                }else{
                    return null;
                }
2683 2684 2685 2686
            }else{
                return null;
            }
        }else{
2687
           return this.service.getRemoteCopyData()[param]?this.service.getRemoteCopyData()[param]:null;
2688 2689 2690
        }
    }

2691 2692 2693 2694 2695 2696 2697
    /**
     * 校验属性值规则
     *
     * @public
     * @param {{ name: string }} { name }
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
2698
    public verifyDeRules(name:string,rule:any = this.deRules(),op:string = "AND",value:any) :{isPast:boolean}{
2699 2700 2701 2702 2703 2704 2705 2706
        let falg:any = {};
        if(!rule || !rule[name]){
            return falg;
        }
        let opValue = op == 'AND'? true :false;
        let startOp = (val:boolean)=>{
            if(falg.isPast){
                if(opValue){
2707
                    falg.isPast = falg.isPast && val;
2708
                }else{
2709
                    falg.isPast = falg.isPast || val;
2710 2711 2712 2713 2714
                }
            }else{
                falg.isPast = val;
            }
        }
2715 2716 2717 2718 2719
        for(let i=0; i < rule[name].length; i++) {
            let item: any = rule[name][i];
            if((value === null || value === undefined || value === "") && (item.type != 'GROUP')){
                startOp(true);
                return falg;
2720
            }
2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755
            try {
                // 常规规则
               if(item.type == 'SIMPLE'){
                    startOp(!this.$verify.checkFieldSimpleRule(value,item.condOP,item.paramValue,item.ruleInfo,item.paramType,this.curEditRowData,item.isKeyCond));
                    falg.infoMessage = item.ruleInfo;
                    if(!falg.isPast) return falg;
                }
                // 数值范围
                if(item.type == 'VALUERANGE2'){
                    startOp( !this.$verify.checkFieldValueRangeRule(value,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond));
                    falg.infoMessage = item.ruleInfo;
                    if(!falg.isPast) return falg;
                }
                // 正则式
                if (item.type == "REGEX") {
                    startOp(!this.$verify.checkFieldRegExRule(value,item.regExCode,item.ruleInfo,item.isKeyCond));
                    falg.infoMessage = item.ruleInfo;
                    if(!falg.isPast) return falg;
                }
                // 长度
                if (item.type == "STRINGLENGTH") {
                    startOp(!this.$verify.checkFieldStringLengthRule(value,item.minValue,item.isIncludeMinValue,item.maxValue,item.isIncludeMaxValue,item.ruleInfo,item.isKeyCond)); 
                    falg.infoMessage = item.ruleInfo;
                    if(!falg.isPast) return falg;
                }
                // 系统值规则
                if(item.type == "SYSVALUERULE") {
                    startOp(!this.$verify.checkFieldSysValueRule(value,item.sysRule.regExCode,item.ruleInfo,item.isKeyCond));
                    falg.infoMessage = item.ruleInfo;
                    if(!falg.isPast) return falg;
                }
            } catch(error) {
                falg.infoMessage = item.ruleInfo;
                startOp(false);
                if(!falg.isPast) return falg;
2756 2757 2758
            }
            // 分组
            if(item.type == 'GROUP'){
2759
                falg = this.verifyDeRules('group',item,item.condOP?item.condOP:"AND",value)
2760 2761 2762 2763 2764
                if(item.isNotMode){
                   falg.isPast = !falg.isPast;
                }
            }
            
2765
        };
2766 2767 2768
        if(!falg.hasOwnProperty("isPast")){
            falg.isPast = true;
        }
2769
        if(!value && value != 0){
2770 2771 2772 2773 2774
           falg.isPast = true;
        }
        return falg;
    }

2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812
    /**
     * 工作流提交
     *
     * @param {*} [data={}]
     * @param {*} [localdata={}]
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public async submitbatch(data: any,localdata:any): Promise<any> {
        return new Promise((resolve: any, reject: any) => {
        const _this: any = this;
        const arg: any = data;
        const result: Promise<any> = this.service.submitbatch(_this.WFSubmitAction, JSON.parse(JSON.stringify(this.context)),arg,localdata,this.showBusyIndicator);
        result.then((response: any) => {
            if (!response || response.status !== 200) {
                if(response.data){
                    this.$Notice.error({ title: '', desc: (this.$t('app.formpage.workflow.submiterror') as string) + ', ' + response.data.message });
                }
                return;
            }
            this.$Notice.info({ title: '', desc: (this.$t('app.formpage.workflow.submitsuccess') as string) });
            resolve(response);
        }).catch((response: any) => {
            if (response && response.status && response.data) {
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
                reject(response);
                return;
            }
            if (!response || !response.status || !response.data) {
                this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
                reject(response);
                return;
            }
            reject(response);
        });
        })
    }

2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855
    /**
     * 获取表格列禁用状态
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public  getColumnDisabled(data:any,name:string){
        if(this.allColumns || Array.isArray(this.allColumns)){
            const curColumn:any = this.allColumns.find((item:any) =>{
                return item.name === name;
            })
            if(curColumn.hasOwnProperty('enableCond')){
                return data.srfuf == 1 ? (curColumn.enableCond & 2) !== 2 : (curColumn.enableCond & 1) !== 1
            }else{
                return false;
            }
        }
    }

    /**
     * 重置表格项值
     *
     * @param {*} row 当前行
     * @param {string} property 属性名
     * @param {number} rowIndex 行下标
     * @memberof ${srfclassname('${ctrl.codeName}')}Base
     */
    public resetGridData(row: any, property: string, rowIndex: number) {
<#if ctrl.getPSDEGridColumns?? && ctrl.getPSDEGridColumns()??>
        if(this.actualIsOpenEdit) {
    <#list ctrl.getPSDEGridColumns() as column>
        <#if column.getResetItemName?? && column.getResetItemName()??>
            if(Object.is(property, '${column.getResetItemName()}')) {
                this.onGridItemValueChange(row, {name: '${column.getName()}', value: null}, rowIndex);
                <#if column.getValueItemName?? && column.getValueItemName()?? && column.getValueItemName() != ''>
                this.onGridItemValueChange(row, {name: '${column.getValueItemName()}', value: null}, rowIndex);
                </#if>
            }
        </#if>
    </#list>
        }
</#if> 
    }

2856 2857 2858
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>