CONTROL-BASE.vue.ftl 55.5 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<template>
<div class='grid' style="height:100%;">
    <#if ctrl.render?? || ctrl.getRender()??> 
    ${ctrl.render.code}
    <#else>
    <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>
        <#-- 表格聚合end -->
        :height="isEnablePagingBar && items.length > 0 ? 'calc(100% - 50px)' : '100%'"  
        :highlight-current-row ="isSingleSelect"
        :row-class-name="getRowClassName"
        @row-click="rowClick($event)"  
        @select-all="selectAll($event)"  
        @select="select($event)"  
        @row-class-name="onRowClassName($event)"  
        @row-dblclick="rowDBLClick($event)"  
        ref='multipleTable' :data="items" :show-header="!isHideHeader">
29 30
            <template slot="empty">
                无数据 
31
                <span class="quick-toolbar">
32 33 34 35 36 37
                <#if ctrl.getQuickPSDEToolbar?? && ctrl.getQuickPSDEToolbar()??>
                  <#assign quickToolbar = ctrl.getQuickPSDEToolbar()/>
                  <@ibizindent blank=12>
                  ${P.getCtrlCode(quickToolbar, 'CONTROL.html').code}
                  </@ibizindent>
                </#if>
38
                </span>
39
            </template>
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
            <template v-if="!isSingleSelect">
                <el-table-column align="center" type='selection' :width="checkboxColWidth"></el-table-column>
            </template>
            <#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>
    <#if ctrl.isEnablePagingBar()>
    <row class='grid-pagination' v-show="items.length > 0">
        <page class='pull-right' @on-change="pageOnChange($event)" 
            @on-page-size-change="onPageSizeChange($event)"
            :transfer="true" :total="totalrow"
            show-sizer :current="curPage" :page-size="limit"
            :page-size-opts="[10, 20, 30, 40, 50, 60, 70, 80, 90, 100]" show-elevator show-total>
            <span>
                <span class="page-column">
                    <poptip transfer placement="top-start">
                        <i-button icon="md-menu">{{$t('app.gridpage.choicecolumns')}}</i-button>
                        <div slot="content">
                            <template v-for="col in allColumns">
                                <div :key="col.name"><el-checkbox v-model="col.show" @change="onColChange()">{{$t(col.langtag)}}</el-checkbox></div>
                            </template>
                        </div>
                    </poptip>
                </span>
71
                <span v-if="selections.length > 0" class="batch-toolbar">
72 73 74 75 76 77 78
                <#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
                  <#assign batchToolbar = ctrl.getBatchPSDEToolbar()/>
                  <@ibizindent blank=12>
                  ${P.getCtrlCode(batchToolbar, 'CONTROL.html').code}
                  </@ibizindent>
                </#if>
                </span>
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
                <span class="page-button"><i-button icon="md-refresh" :title="$t('app.gridpage.refresh')" @click="pageRefresh()"></i-button></span>&nbsp;
                <span>
                    {{$t('app.gridpage.show')}}&nbsp;
                    <span>
                        <template v-if="items.length === 1">
                        1
                        </template>
                        <template v-else>
                            <span>{{(curPage - 1) * limit + 1}}&nbsp;-&nbsp;{{totalrow > curPage * limit ? curPage * limit : totalrow}}</span>
                        </template>
                    </span>&nbsp;
                    {{$t('app.gridpage.records')}},{{$t('app.gridpage.totle')}}&nbsp;{{totalrow}}&nbsp;{{$t('app.gridpage.records')}}
                </span>
            </span>
        </page>
    </row>
    </#if>
    </#if>
</div>
</template>
<#assign import_block>
import CodeListService from "@service/app/codelist-service";
</#assign>
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl
</#ibizinclude>

    /**
     * 代码表服务对象
     *
     * @type {CodeListService}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */  
    public codeListService:CodeListService = new CodeListService({ $store: this.$store });

    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getDatas(): any[] {
        return this.selections;
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public getData(): any {
        return this.selections[0];
    }

<#if view.getPSAppViewLogics?? && view.getPSAppViewLogics()??>
  <#list view.getPSAppViewLogics() as logic>
    <#if logic.getPFLogicCodeType() == 'APP_NEWDATA'>
    /**
     * 打开新建数据视图
     *
     * @type {any}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
143
    @Prop() public newdata: any;
144 145 146 147 148 149 150 151
    </#if>
    <#if logic.getPFLogicCodeType() == 'APP_OPENDATA'>
    /**
     * 打开编辑数据视图
     *
     * @type {any}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
152
    @Prop() public opendata: any;
153 154 155 156 157 158 159 160 161 162
    </#if>
  </#list>
</#if>

    /**
     * 显示处理提示
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
163
    @Prop({ default: true }) public showBusyIndicator?: boolean;
164 165 166 167 168 169 170

    /**
     * 部件行为--update
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
171
    @Prop() public updateAction!: string;
172 173 174 175 176 177 178
    
    /**
     * 部件行为--fetch
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
179
    @Prop() public fetchAction!: string;
180 181 182 183 184 185 186
    
    /**
     * 部件行为--remove
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
187
    @Prop() public removeAction!: string;
188 189 190 191 192 193 194
    
    /**
     * 部件行为--load
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
195
    @Prop() public loadAction!: string;
196 197 198 199 200 201 202
    
    /**
     * 部件行为--loaddraft
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
203
    @Prop() public loaddraftAction!: string;
204 205 206 207 208 209 210
    
    /**
     * 部件行为--create
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
211
    @Prop() public createAction!: string;
212 213 214 215 216 217 218

    /**
     * 当前页
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
219
    public curPage: number = 1;
220 221 222 223 224 225 226

    /**
     * 数据
     *
     * @type {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
227
    public items: any[] = [];
228 229 230 231 232 233 234

    /**
     * 是否支持分页
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
235
    public isEnablePagingBar: boolean = ${ctrl.isEnablePagingBar()?c};
236 237 238 239 240 241 242

    /**
     * 是否禁用排序
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
243
    public isNoSort: boolean = ${ctrl.isNoSort()?c};
244 245 246 247 248 249 250

    /**
     * 排序方向
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
251
    public minorSortDir: string = '<#if ctrl.getMinorSortDir()??>${ctrl.getMinorSortDir()}</#if>';
252 253 254 255 256 257 258

    /**
     * 排序字段
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
259
    public minorSortPSDEF: string = '<#if ctrl.getMinorSortPSDEF()??>${ctrl.getMinorSortPSDEF().getCodeName()?lower_case}</#if>';
260 261 262 263 264 265 266

    /**
     * 分页条数
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
267
    public limit: number = ${ctrl.getPagingSize()?c};
268 269 270 271 272 273 274

    /**
     * 是否显示标题
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
275
    public isHideHeader: boolean = ${ctrl.isHideHeader()?c};
276 277 278 279 280 281 282

    /**
     * 是否默认选中第一条数据
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
283
    @Prop({ default: false }) public isSelectFirstDefault!: boolean;
284 285 286 287 288 289 290

    /**
     * 是否单选
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
291
    @Prop() public isSingleSelect?: boolean;
292 293 294 295 296 297 298

    /**
     * 选中数据字符串
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
299
    @Prop() public selectedData?: string;
300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335

    /**
     * 选中值变化
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof MainTree
     */
    @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)}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
336
    @Prop({default: 2}) public gridRowActiveMode!: number;
337 338 339 340 341 342 343

    /**
     * 是否开启行编辑
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
344
    @Prop({default: false}) public isOpenEdit!: boolean;
345 346 347 348 349 350 351

    /**
     * 实际是否开启行编辑
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
352
    public actualIsOpenEdit: boolean = this.isOpenEdit;
353 354 355 356 357 358 359

    /**
     * 总条数
     *
     * @type {number}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
360
    public totalrow: number = 0;
361 362 363 364 365 366 367

    /**
     * 选中行数据
     *
     * @type {any[]}
     * @memberof Main
     */
368
    public selections: any[] = [];
369 370 371 372 373 374 375

    /**
     * 拦截行选中
     *
     * @type {boolean}
     * @memberof Main
     */
376
    public stopRowClick: boolean = false;
377 378 379 380 381 382 383 384

    <#if ctrl.getAggMode() == "ALL">
    /**
     * 表格聚合行为
     *
     * @type {string}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
385
    public aggAction:string ='<#if ctrl.getAggPSDEAction()??>${ctrl.getAggPSDEAction().getCodeName()}</#if>';
386 387 388 389 390 391 392

    /**
     * 远程数据
     *
     * @type {any}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
393
    public remoteData:any = {};
394 395
    </#if>

396 397 398 399 400 401 402 403 404 405
    <#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>

406 407 408 409 410 411
    /**
     * 表格是否显示
     *
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
412
    public isDisplay:boolean = <#if ctrl.getAggMode() == "ALL">false<#else>true</#if>;
413 414 415 416 417 418 419

    /**
     * 部件刷新
     *
     * @param {any[]} args
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
420
    public refresh(args: any[]): void {
421 422 423 424 425 426 427 428 429
        this.load();
    }

    /**
    * 选项框列宽
    *
    * @type {number}
    * @memberof AppIndex
    */
430
    public checkboxColWidth: number = <#if app.getPSApplicationUI()??>${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.CHECKCOLWIDTH',50)}<#else>50</#if>;
431 432 433 434 435 436 437

    /**
     * 是否允许拖动列宽
     *
     * @type {boolean}
     * @memberof AppEmbedPicker
     */
438 439
    public isDragendCol: boolean = <#if app.getPSApplicationUI()??>${app.getPSApplicationUI().getPFStyleParam('EL-TABLE.ISDRAGENDCOL',false)?c}<#else>false</#if>;
    <#--  public isDragendCol: boolean = true;  -->
440 441 442 443 444 445 446

    /**
     * 所有列成员
     *
     * @type {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
447
    public allColumns: any[] = [
448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466
        <#if ctrl.getAllPSDEGridColumns()??>
        <#list ctrl.getAllPSDEGridColumns() as column>
        {
            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>,
            util: '${column.getWidthUnit()}'
        },
        </#list>
        </#if>
    ]

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
467
    public rules: any = {
468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
        <#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 edititem.getCaption?? && edititem.getCaption()??>'${edititem.getCaption()} 值不能为空'<#else>'值不能为空'</#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 edititem.getCaption?? && edititem.getCaption()??>'${edititem.getCaption()} 值不能为空'<#else>'值不能为空'</#if>, trigger: 'blur' },
          <#if ctrl.getPSGEIDEFValueRules?? && ctrl.getPSGEIDEFValueRules()??>
            <#list ctrl.getPSGEIDEFValueRules() as fideValueRule>
              <#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>
                </#if>
              </#if>          
            </#list>
          </#if>
        ],
        </#list>
    }

    /**
     * 表格数据加载
     *
     * @param {*} [arg={}]
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
496
    public load(opt: any = {}, pageReset: boolean = false): void {
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
        if(!this.fetchAction){
            this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格fetchAction参数未配置' });
            return;
        }
        if(pageReset){
            this.curPage = 1;
        }
        const arg: any = {...opt};
        const page: any = {};
        if (this.isEnablePagingBar) {
            Object.assign(page, { page: this.curPage-1, size: this.limit });
        }
        // 设置排序
        if (!this.isNoSort && !Object.is(this.minorSortDir, '') && !Object.is(this.minorSortPSDEF, '')) {
            const sort: string = this.minorSortPSDEF+","+this.minorSortDir;
            Object.assign(page, { sort: sort });
        }
        Object.assign(arg, page);
        const parentdata: any = {};
        this.$emit('beforeload', parentdata);
        Object.assign(arg, parentdata);
518 519 520
        let tempViewParams:any = parentdata.viewparams?parentdata.viewparams:{};
        Object.assign(tempViewParams,JSON.parse(JSON.stringify(this.viewparams)));
        Object.assign(arg,{viewparams:tempViewParams});
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
        const post: Promise<any> = this.service.search(this.fetchAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
        post.then((response: any) => {
            if (!response.status || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: '错误', desc: response.errorMessage });
                }
                return;
            }
            const data: any = response.data;
            this.totalrow = response.total;
            this.items = JSON.parse(JSON.stringify(data));
            // 清空selections
            this.selections = [];
            this.$emit('load', this.items);
            // 设置默认选中
            let _this = this;
            setTimeout(() => {
                if(_this.isSelectFirstDefault){
                  _this.rowClick(_this.items[0]);
                }
                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);
                            }
                        });
                    }
                }
            }, 300);
            <#if ctrl.getAggMode() == "ALL">
            this.getAggData();
            </#if>
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            this.$Notice.error({ title: '错误', desc: response.errorMessage });
        });
    }

    /**
     * 删除
     *
     * @param {any[]} datas
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
574
    public async remove(datas: any[]): Promise<any> {
575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618
        if(!this.removeAction){
            this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格removeAction参数未配置' });
            return;
        }
        let _datas:any[] = [];
        datas.forEach((record: any, index: number) => {
            if (!record.srfkey) {
                this.items.some((val: any, num: number) =>{
                    if(JSON.stringify(val) == JSON.stringify(record)){
                        this.items.splice(num,1);
                        return true;
                    }
                }); 
            }else{
               _datas.push(datas[index]);
            }
        });
        if (_datas.length === 0) {
            return;
        }
        let dataInfo = '';
        _datas.forEach((record: any, index: number) => {
            let srfmajortext = record.${ctrl.getPSAppDataEntity().getMajorPSAppDEField().getCodeName()?lower_case};
            if (index < 5) {
                if (!Object.is(dataInfo, '')) {
                    dataInfo += '、';
                }
                dataInfo += srfmajortext;
            } else {
                return false;
            }
        });

        if (_datas.length < 5) {
            dataInfo = dataInfo + ' 共' + _datas.length + '条数据';
        } else {
            dataInfo = dataInfo + '...' + ' 共' + _datas.length + '条数据';
        }

        const removeData = () => {
            let keys: any[] = [];
            _datas.forEach((data: any) => {
                keys.push(data.srfkey);
            });
WodahsOrez's avatar
WodahsOrez committed
619
            let _removeAction = keys.length > 1 ? 'removeBatch' : this.removeAction ;
WodahsOrez's avatar
WodahsOrez committed
620
            let _keys = keys.length > 1 ? keys : keys[0] ;
621
            const context:any = JSON.parse(JSON.stringify(this.context));
WodahsOrez's avatar
WodahsOrez committed
622
            const post: Promise<any> = 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);
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677
            return new Promise((resolve: any, reject: any) => {
                post.then((response: any) => {
                    if (!response || response.status !== 200) {
                        this.$Notice.error({ title: '', desc: '删除数据失败,' + response.info });
                        return;
                    } else {
                        this.$Notice.success({ title: '', desc: '删除成功!' });
                    }
                    //删除items中已删除的项
                    console.log(this.items);
                    _datas.forEach((data: any) => {
                      this.items.some((item:any,index:number)=>{
                        if(Object.is(item.srfkey,data.srfkey)){
                          this.items.splice(index,1);
                                return true;
                            }
                        });
                    });
                    this.totalrow -= _datas.length;
                    this.$emit('remove', null);
                    this.selections = [];
                    resolve(response);
                }).catch((response: any) => {
                    if (response && response.status === 401) {
                        return;
                    }
                    if (!response || !response.status || !response.data) {
                        this.$Notice.error({ title: '错误', desc: '系统异常' });
                        reject(response);
                        return;
                    }
                    reject(response);
                });
            });
        }

        dataInfo = dataInfo.replace(/[null]/g, '').replace(/[undefined]/g, '');
        this.$Modal.confirm({
            title: '警告',
            content: '确认要删除 ' + dataInfo + ',删除操作将不可恢复?',
            onOk: () => {
                removeData();
            },
            onCancel: () => { }
        });
        return removeData;
    }


    /**
     * 批量添加
     *
     * @param {*} [arg={}]
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
678
    public addBatch(arg: any = {}): void {
679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752
        if(!this.fetchAction){
            this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格fetchAction参数未配置' });
            return;
        }
        if(!arg){
            arg = {};
        }
        console.error("批量添加未实现");
        <#--  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
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
     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()}',
            importData:{
            <#if dataImport.getPSDEDataImportItems()??>
            <#list dataImport.getPSDEDataImportItems() as dataImportItem>
            "${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>
            </#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"),
            width: 900,
            height: 700
        }
        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[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
753
    public allExportColumns: any[] = [
754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773
        <#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
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
774
    public exportExcel(data: any = {}): void {
775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879
        // 导出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, //具体数据 必填
                  filename: "${ctrl.getPSAppDataEntity().getLogicName()}表", //非必填
                  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);
<#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) {
                this.$Notice.error({ title: '', desc: '数据导出失败,' + response.info });
                return;
            }
            try {
                doExport(JSON.parse(JSON.stringify(response.data)));
            } catch (error) {
                console.error(error);
            }
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            this.$Notice.error({ title: '', desc: '数据导出失败' });
        });
    }


    /**
     * 导出数据格式化
     * 
     * @param {*} filterVal
     * @param {*} jsonData
     * @returns {[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    public async formatExcelData(filterVal:any, jsonData:any) {
        let codelistColumns:Array<any> = [
<#if hasDEExport>
  <#assign exportItems = ctrl.getPSDEDataExport().getPSDEDataExportItems() />
<#else>
  <#assign exportItems = ctrl.getAllPSDEGridColumns() />
</#if>
<#if exportItems??>
  <#list exportItems as column>
    <#if (hasDEExport || (!column.isHideDefault() && column.getName() != '')) && column.getCodeList?? && column.getCodeList()?? && 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}',
880
            valueSeparator: ',',
881 882 883
          <#else>
            renderMode: 'other',
            textSeparator: '、',
884
            valueSeparator: ',',
885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914
          </#if>
          },
      </#if>
    </#if>
  </#list>
</#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
     *
915
     * @public
916 917 918 919 920
     * @param {any[]} items 代码表数据
     * @param {*} value
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
921
    public getCodelistValue(items: any[], value: any, codelist: any,){
922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967
        if(!value){
            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;
            }
        }
    }

    /**
     * 获取代码项
     *
968
     * @public
969 970 971 972 973
     * @param {any[]} items
     * @param {*} value
     * @returns {*}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
974
    public getItem(items: any[], value: any, codelist: any): any {
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990
        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;
        }
    }

    /**
     * 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
991
    public created(): void {
992 993 994 995 996 997 998 999
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof ${srfclassname('${ctrl.codeName}')}
     */    
1000
    public afterCreated(){
1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
        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)) {
                    this.load(data);
                }
                if (Object.is('remove', action)) {
                    this.remove(data);
                }
                if (Object.is('save', action)) {
                    this.save(data);
                }
            });
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1025
    public destroyed() {
1026 1027 1028 1029 1030 1031 1032 1033
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1034
    public afterDestroy() {
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        <#if destroyed_block??>
        ${destroyed_block}
        </#if>
    }

    /**
     * 获取选中行胡数据
     *
     * @returns {any[]}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1049
    public getSelection(): any[] {
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059
        return this.selections;
    }

    /**
     * 行双击事件
     *
     * @param {*} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1060
    public rowDBLClick($event: any): void {
1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083
        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);
    }

    /**
     * 复选框数据选中
     *
     * @param {*} $event
     * @returns {void}
     * @memberof  ${srfclassname('${ctrl.codeName}')}
     */
1084
    public select($event: any): void {
1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098
        if (!$event) {
            return;
        }
        this.selections = [];
        this.selections = [...JSON.parse(JSON.stringify($event))];
        this.$emit('selectionchange', this.selections);
    }

    /**
     * 复选框数据全部选中
     *
     * @param {*} $event
     * @memberof  ${srfclassname('${ctrl.codeName}')}
     */
1099
    public selectAll($event: any): void {
1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115
        if (!$event) {
            return;
        }
        this.selections = [];
        this.selections = [...JSON.parse(JSON.stringify($event))];
        this.$emit('selectionchange', this.selections);
    }

    
    /**
     * 行单击选中
     *
     * @param {*} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1116
    public rowClick($event: any, ifAlways: boolean = false): void {
1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157
        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)=>{
            return Object.is(item.${ctrl.getPSDataEntity().getName()?lower_case},$event.${ctrl.getPSDataEntity().getName()?lower_case});
        });
        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}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1158
    public pageOnChange($event: any): void {
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175
        if (!$event) {
            return;
        }
        if ($event === this.curPage) {
            return;
        }
        this.curPage = $event;
        this.load({});
    }

    /**
     * 分页条数变化
     *
     * @param {*} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1176
    public onPageSizeChange($event: any): void {
1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193
        if (!$event) {
            return;
        }
        if ($event === this.limit) {
            return;
        }
        this.limit = $event;
        if (this.curPage === 1) {
            this.load({});
        }
    }

    /**
     * 分页刷新
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1194
    public pageRefresh(): void {
1195 1196 1197 1198 1199 1200 1201 1202 1203
        this.load({});
    }

    /**
     * 排序变化
     *
     * @param {{ column: any, prop: any, order: any }} { column, prop, order }
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1204
    public onSortChange({ column, prop, order }: { column: any, prop: any, order: any }): void {
1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220
        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}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1221
    public onRowClassName({ row, rowIndex }: { row: any, rowIndex: any }): string {
1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232
        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
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1233
    public getSummaries(param:any){
1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 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 1283 1284 1285 1286 1287 1288 1289 1290 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 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358
    <#if ctrl.getAggMode() == "PAGE">
        const { columns, data } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
          if (index === 0) {
            sums[index] = '合计';
            return;
          }
          if(index === (columns.length - 1)){
            sums[index] = '';
            return;
          }
          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);
                    sums[index] = tempData;
                }
            <#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);
                    sums[index] = tempData/data.length;
                }
            <#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 {
            sums[index] = 'N/A';
          }
        });
        return sums;
    <#elseif ctrl.getAggMode() == "ALL">
        const { columns } = param;
        const sums:Array<any> = [];
        columns.forEach((column:any, index:number) => {
        if (index === 0) {
            sums[index] = '合计';
            return;
        }else if(index === (columns.length - 1)){
            sums[index] = '';
            return;
        }else{
        <#if ctrl.getPSDEGridColumns()??>
            sums[index] = 'N/A';
        <#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">
    /**
     * 远程获取合计行数据
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1359
    public getAggData(){
1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387
        this.service.getAggData(this.aggAction,JSON.parse(JSON.stringify(this.context)),this.showBusyIndicator).then((response:any) =>{
            if (!response.status || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: '错误', desc: response.errorMessage });
                }
                return;
            }
            this.remoteData = response.data;
            this.isDisplay = true;
        }).catch((response:any) =>{
            if (response && response.status === 401) {
                return;
            }
            this.remoteData = {};
            this.isDisplay = true;
            this.$Notice.error({ title: '错误', desc: response.errorMessage });
        })
    }
</#if>

    /**
     * 界面行为
     *
     * @param {*} row
     * @param {*} tag
     * @param {*} $event
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1388
	public uiAction(row: any, tag: any, $event: any) {
1389
        // this.rowClick(row, true);
1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406
        <#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>
    }

    /**
     * 设置列状态
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1407
    public setColState() {
1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424
		const _data: any = localStorage.getItem('${ctrl.getPSDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}');
		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);
				}
			});
		}
    }

    /**
     * 列变化
     *
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1425
    public onColChange() {
1426 1427 1428 1429 1430 1431 1432 1433 1434 1435
        localStorage.setItem('${ctrl.getPSDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}', JSON.stringify(this.allColumns));
    }

    /**
     * 获取列状态
     *
     * @param {string} name
     * @returns {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1436
    public getColumnState(name: string): boolean {
1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460
        let column = this.allColumns.find((col: any) =>
            Object.is(name, col.name)
        );
        return column.show ? true : false;
    }

    /**
     * 表格列是否自适应布局
     *
     * @readonly
     * @type {boolean}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
    get adaptiveState(): boolean {
        return !this.allColumns.find((column: any) => column.show && Object.is(column.util, 'STAR'));
    }

    /**
     * 保存
     *
     * @param {*} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1461
    public save(args: any[], params?: any, $event?: any, xData?: any): void {
1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 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
        let _this = this;
        let promises:any = [];
        _this.items.forEach((item:any)=>{
            if(!item.rowDataState){
                return;
            } else if(Object.is(item.rowDataState, 'create')){
                if(!this.createAction){
                    this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格createAction参数未配置' });
                    return;
                }
                Object.assign(item,{viewparams:this.viewparams});
                promises.push(this.service.add(this.createAction, JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
            }else if(Object.is(item.rowDataState, 'update')){
                if(!this.updateAction){
                    this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格updateAction参数未配置' });
                    return;
                }
                Object.assign(item,{viewparams:this.viewparams});
<#if de??>
                if(item.${appde.getCodeName()?lower_case}){
                    Object.assign(this.context,{${appde.getCodeName()?lower_case}:item.${appde.getCodeName()?lower_case}})
                }
</#if>
                promises.push(this.service.add(this.updateAction,JSON.parse(JSON.stringify(this.context)),item, this.showBusyIndicator));
            }
        });
        Promise.all(promises).then((response: any) => {
            this.$emit('save', response);
            this.$Notice.success({ title: '', desc: '保存成功!' });
            this.refresh([]);
        }).catch((response: any) => {
            this.$Notice.error({ title: '错误', desc: '系统异常' });
        });
    }

<#if ctrl.isEnableRowEdit()>
    /**
     * 新建行
     *
     * @param {*} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1505
    public newRow(args: any[], params?: any, $event?: any, xData?: any): void {
1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521
        if(!this.loaddraftAction){
            this.$Notice.error({ title: '错误', desc: '${view.getName()}视图表格loaddraftAction参数未配置' });
            return;
        }
        let _this = this;
        Object.assign(args[0],{viewparams:this.viewparams});
        let post: Promise<any> = this.service.loadDraft(this.loaddraftAction, JSON.parse(JSON.stringify(this.context)), args[0], this.showBusyIndicator);
        post.then((response: any) => {
            if (!response.status || response.status !== 200) {
                if (response.errorMessage) {
                    this.$Notice.error({ title: '错误', desc: response.errorMessage });
                }
                return;
            }
            const data = response.data;
            data.rowDataState = "create";
1522
            _this.items.push(data);
1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            if (!response || !response.status || !response.data) {
                this.$Notice.error({ title: '错误', desc: '系统异常' });
                return;
            }
        });
    }

    /**
     * 表格编辑项值变更
     *  
     * @param row 行数据
     * @param {{ name: string, value: any }} $event
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1542
    public onGridItemValueChange(row: any,$event: { name: string, value: any }): void {
1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555
        if (!$event) {
            return;
        }
        if (!$event.name || Object.is($event.name, '') || !row.hasOwnProperty($event.name)) {
            return;
        }
        row[$event.name] = $event.value;
        this.gridEditItemChange(row, $event.name, $event.value);
    }

    /**
     * 表格编辑项值变化
     *
1556
     * @public
1557 1558 1559 1560 1561 1562
     * @param row 行数据
     * @param property 列编辑项名
     * @param row 列编辑项值
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1563
    public gridEditItemChange(row: any, property: string, value: any){
1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587
        row.rowDataState = row.rowDataState ? row.rowDataState : "update" ;
  <#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>];
            this.updateGridEditItem('${itemUpdate.codeName}', row, details, ${itemUpdate.isShowBusyIndicator()?c});
        }
      </#if>
    </#list>
  </#if>
    }

    /**
     * 表格编辑项更新
     *
     * @param {string} mode 界面行为名称
     * @param {*} [data={}] 请求数据
     * @param {string[]} updateDetails 更新项
     * @param {boolean} [showloading] 是否显示加载状态
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1588
    public updateGridEditItem(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
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
        if (!mode || (mode && Object.is(mode, ''))) {
            return;
        }
        const arg: any = JSON.parse(JSON.stringify(data));
        Object.assign(arg,{viewparams:this.viewparams});
        const post: Promise<any> = this.service.frontLogic(mode,JSON.parse(JSON.stringify(this.context)),arg, showloading);
        post.then((response: any) => {
            if (!response || response.status !== 200) {
                this.$Notice.error({ title: '错误', desc: '表单项更新失败' });
                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) {
                this.$Notice.error({ title: '错误', desc: '系统异常' });
                return;
            }
        });
    }
</#if>

    /**
     * 获取对应行class
     *
     * @param {*} $args row 行数据,rowIndex 行索引
     * @returns {void}
     * @memberof ${srfclassname('${ctrl.codeName}')}
     */
1629
    public getRowClassName(args:{row: any,rowIndex: number}){
1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641
        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" : "";
    }
<#ibizinclude>
../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl
</#ibizinclude>

<#ibizinclude>
../@MACRO/CONTROL/CONTROL-BASE.style.ftl
</#ibizinclude>