default-searchform-base.vue 19.1 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4
<template>
    <i-form :model="this.data" class='app-search-form' ref='searchform' style="">
  <input style="display:none;"/>
  <row>
ibizdev's avatar
ibizdev committed
5
    <i-col span="20" class="form-content">
ibizdev's avatar
ibizdev committed
6
      <row>
ibizdev's avatar
ibizdev committed
7 8 9 10 11 12 13
                    <i-col v-show="detailsModel.n_personname_like.visible" :style="{}"  :lg="{ span: 24, offset: 0 }">
              <app-form-item name='n_personname_like' :itemRules="this.rules.n_personname_like" class='' :caption="$t('entities.wfuser.default_searchform.details.n_personname_like')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_personname_like.error" :isEmptyCaption="false" labelPos="LEFT"> 
              <input-box v-model="data.n_personname_like"  @enter="onEnter($event)"    :disabled="detailsModel.n_personname_like.disabled" type='text'  style="width:100px;"></input-box>
          </app-form-item>
          
          </i-col>
      </row>
ibizdev's avatar
ibizdev committed
14
    </i-col>
ibizdev's avatar
ibizdev committed
15
    <i-col span="4" class="search-button">
ibizdev's avatar
ibizdev committed
16 17 18 19 20 21 22 23 24
      <row v-show="Object.keys(data).length>0">
        <i-button class='search_reset'  size="default" type="primary"  @click="onSearch">{{$t('app.searchButton.search')}}</i-button>
        <i-button class='search_reset'  size="default"  @click="onReset">{{this.$t('app.searchButton.reset')}}</i-button>
      </row>
    </i-col>
  </row>
</i-form>
</template>
<script lang='tsx'>
25
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
ibizdev's avatar
ibizdev committed
26 27 28 29
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util } from '@/utils';
30
import NavDataService from '@/service/app/navdata-service';
31
import AppCenterService from "@service/app/app-center-service";
ibizdev's avatar
ibizdev committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
import WFUserService from '@/service/wfuser/wfuser-service';
import DefaultService from './default-searchform-service';

import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';


@Component({
    components: {
      
    }
})
export default class DefaultBase extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
50
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
51
     */
ibizdev's avatar
ibizdev committed
52
    @Prop() public name?: string;
ibizdev's avatar
ibizdev committed
53 54 55 56 57

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
58
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
59
     */
ibizdev's avatar
ibizdev committed
60
    @Prop() public viewState!: Subject<ViewState>;
ibizdev's avatar
ibizdev committed
61 62 63 64 65

    /**
     * 应用上下文
     *
     * @type {*}
66
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
67
     */
ibizdev's avatar
ibizdev committed
68
    @Prop() public context: any;
ibizdev's avatar
ibizdev committed
69 70 71 72 73

    /**
     * 视图参数
     *
     * @type {*}
74
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
75
     */
ibizdev's avatar
ibizdev committed
76
    @Prop() public viewparams: any;
ibizdev's avatar
ibizdev committed
77 78 79 80

    /**
     * 视图状态事件
     *
ibizdev's avatar
ibizdev committed
81
     * @public
ibizdev's avatar
ibizdev committed
82
     * @type {(Subscription | undefined)}
83
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
84
     */
ibizdev's avatar
ibizdev committed
85
    public viewStateEvent: Subscription | undefined;
ibizdev's avatar
ibizdev committed
86 87 88 89 90

    /**
     * 获取部件类型
     *
     * @returns {string}
91
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
92
     */
ibizdev's avatar
ibizdev committed
93
    public getControlType(): string {
ibizdev's avatar
ibizdev committed
94 95 96 97 98 99 100 101 102
        return 'SEARCHFORM'
    }



    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
103
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
104
     */    
ibizdev's avatar
ibizdev committed
105
    public counterServiceArray:Array<any> = [];
ibizdev's avatar
ibizdev committed
106 107 108 109 110

    /**
     * 建构部件服务对象
     *
     * @type {DefaultService}
111
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
112
     */
ibizdev's avatar
ibizdev committed
113
    public service: DefaultService = new DefaultService({ $store: this.$store });
ibizdev's avatar
ibizdev committed
114 115 116 117 118

    /**
     * 实体服务对象
     *
     * @type {WFUserService}
119
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
120
     */
ibizdev's avatar
ibizdev committed
121
    public appEntityService: WFUserService = new WFUserService({ $store: this.$store });
ibizdev's avatar
ibizdev committed
122 123 124 125 126 127 128
    


    /**
     * 关闭视图
     *
     * @param {any} args
129
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
130
     */
ibizdev's avatar
ibizdev committed
131
    public closeView(args: any): void {
ibizdev's avatar
ibizdev committed
132 133 134 135 136 137 138
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
139
     * @memberof DefaultBase
ibizdev's avatar
ibizdev committed
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
     */
    public counterRefresh(){
        const _this:any =this;
        if(_this.counterServiceArray && _this.counterServiceArray.length >0){
            _this.counterServiceArray.forEach((item:any) =>{
                if(item.refreshData && item.refreshData instanceof Function){
                    item.refreshData();
                }
            })
        }
    }


    /**
     * 获取多项数据
     *
     * @returns {any[]}
     * @memberof DefaultBase
     */
    public getDatas(): any[] {
        return [this.data];
    }

    /**
     * 获取单项树
     *
     * @returns {*}
     * @memberof DefaultBase
     */
    public getData(): any {
        return this.data;
    }

    /**
     * 显示处理提示
     *
     * @type {boolean}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
179
    @Prop({ default: true }) public showBusyIndicator?: boolean;
ibizdev's avatar
ibizdev committed
180 181 182 183 184 185 186
    
    /**
     * 部件行为--loaddraft
     *
     * @type {string}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
187
    @Prop() public loaddraftAction!: string;
ibizdev's avatar
ibizdev committed
188 189 190 191 192 193 194
    
    /**
     * 部件行为--load
     *
     * @type {string}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
195
    @Prop() public loadAction!: string;
ibizdev's avatar
ibizdev committed
196 197 198 199 200 201 202

    /**
     * 视图标识
     *
     * @type {string}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
203
    @Prop() public viewtag!: string;
ibizdev's avatar
ibizdev committed
204 205 206 207 208 209 210

    /**
     * 表单状态
     *
     * @type {Subject<any>}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
211
    public formState: Subject<any> = new Subject();
ibizdev's avatar
ibizdev committed
212 213 214 215 216 217 218

    /**
     * 忽略表单项值变化
     *
     * @type {boolean}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
219
    public ignorefieldvaluechange: boolean = false;
ibizdev's avatar
ibizdev committed
220 221 222 223

    /**
     * 数据变化
     *
ibizdev's avatar
ibizdev committed
224
     * @public
ibizdev's avatar
ibizdev committed
225 226 227
     * @type {Subject<any>}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
228
    public dataChang: Subject<any> = new Subject();
ibizdev's avatar
ibizdev committed
229 230 231 232

    /**
     * 视图状态事件
     *
ibizdev's avatar
ibizdev committed
233
     * @public
ibizdev's avatar
ibizdev committed
234 235 236
     * @type {(Subscription | undefined)}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
237
    public dataChangEvent: Subscription | undefined;
ibizdev's avatar
ibizdev committed
238 239 240 241

    /**
     * 原始数据
     *
ibizdev's avatar
ibizdev committed
242
     * @public
ibizdev's avatar
ibizdev committed
243 244 245
     * @type {*}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
246
    public oldData: any = {};
ibizdev's avatar
ibizdev committed
247 248 249 250 251 252 253

    /**
     * 表单数据对象
     *
     * @type {*}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
254
    public data: any = {
ibizdev's avatar
ibizdev committed
255
        n_personname_like: null,
ibizdev's avatar
ibizdev committed
256 257 258 259 260 261 262 263
    };

    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
264
    public rules: any = {
ibizdev's avatar
ibizdev committed
265 266 267 268 269 270
        n_personname_like: [
            { type: 'string', message: '用户名称(文本包含(%)) 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '用户名称(文本包含(%)) 值必须为字符串类型', trigger: 'blur' },
            { required: false, type: 'string', message: '用户名称(文本包含(%)) 值不能为空', trigger: 'change' },
            { required: false, type: 'string', message: '用户名称(文本包含(%)) 值不能为空', trigger: 'blur' },
        ],
ibizdev's avatar
ibizdev committed
271 272 273 274 275 276 277 278
    }

    /**
     * 详情模型集合
     *
     * @type {*}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
279
    public detailsModel: any = {
ibizdev's avatar
ibizdev committed
280
        formpage1: new FormPageModel({ caption: '常规条件', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
ibizdev's avatar
ibizdev committed
281 282
, 
        n_personname_like: new FormItemModel({ caption: '用户名称(文本包含(%))', detailType: 'FORMITEM', name: 'n_personname_like', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
ibizdev's avatar
ibizdev committed
283 284 285
, 
    };

ibizdev's avatar
ibizdev committed
286 287 288 289 290 291 292 293 294 295 296 297
    /**
     * 监控表单属性 n_personname_like 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof DefaultBase
     */
    @Watch('data.n_personname_like')
    onN_personname_likeChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'n_personname_like', newVal: newVal, oldVal: oldVal });
    }

ibizdev's avatar
ibizdev committed
298 299 300 301

    /**
     * 重置表单项值
     *
ibizdev's avatar
ibizdev committed
302
     * @public
ibizdev's avatar
ibizdev committed
303 304 305
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
306
    public resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
ibizdev's avatar
ibizdev committed
307 308 309 310 311
    }

    /**
     * 表单逻辑
     *
ibizdev's avatar
ibizdev committed
312
     * @public
ibizdev's avatar
ibizdev committed
313 314 315
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
316
    public formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
ibizdev's avatar
ibizdev committed
317 318
                

ibizdev's avatar
ibizdev committed
319

ibizdev's avatar
ibizdev committed
320 321 322 323 324
    }

    /**
     * 表单值变化
     *
ibizdev's avatar
ibizdev committed
325
     * @public
ibizdev's avatar
ibizdev committed
326 327 328 329
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @returns {void}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
330
    public formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
ibizdev's avatar
ibizdev committed
331 332 333 334 335 336 337 338 339 340 341
        if (this.ignorefieldvaluechange) {
            return;
        }
        this.resetFormData({ name: name, newVal: newVal, oldVal: oldVal });
        this.formLogic({ name: name, newVal: newVal, oldVal: oldVal });
        this.dataChang.next(JSON.stringify(this.data));
    }

    /**
     * 表单加载完成
     *
ibizdev's avatar
ibizdev committed
342
     * @public
ibizdev's avatar
ibizdev committed
343 344 345
     * @param {*} [data={}]
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
346
    public onFormLoad(data: any = {}): void {
ibizdev's avatar
ibizdev committed
347 348 349 350 351 352 353 354 355 356 357
        this.setFormEnableCond(data);
        this.fillForm(data);
        this.formLogic({ name: '', newVal: null, oldVal: null });
    }

    /**
     * 值填充
     *
     * @param {*} [_datas={}]
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
358
    public fillForm(_datas: any = {}): void {
ibizdev's avatar
ibizdev committed
359 360 361 362 363 364 365 366 367 368 369 370 371 372
        this.ignorefieldvaluechange = true;
        Object.keys(_datas).forEach((name: string) => {
            if (this.data.hasOwnProperty(name)) {
                this.data[name] = _datas[name];
            }
        });
        this.$nextTick(function () {
            this.ignorefieldvaluechange = false;
        })
    }

    /**
     * 设置表单项是否启用
     *
ibizdev's avatar
ibizdev committed
373
     * @public
ibizdev's avatar
ibizdev committed
374 375 376
     * @param {*} data
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
377
    public setFormEnableCond(data: any): void {
ibizdev's avatar
ibizdev committed
378 379 380 381 382 383 384 385 386 387 388 389
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setEnableCond(data.srfuf);
        });
    }

    /**
     * 重置草稿表单状态
     *
ibizdev's avatar
ibizdev committed
390
     * @public
ibizdev's avatar
ibizdev committed
391 392
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
393
    public resetDraftFormStates(): void {
ibizdev's avatar
ibizdev committed
394 395 396 397 398 399 400 401 402 403 404
        const form: any = this.$refs.form;
        if (form) {
            form.resetFields();
        }
    }

    /**
     * 重置校验结果
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
405
    public resetValidates(): void {
ibizdev's avatar
ibizdev committed
406 407 408 409 410 411 412 413 414 415 416 417 418 419 420
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setError('');
        });
    }

    /**
     * 填充校验结果 (后台)
     *
     * @param {any[]} fieldErrors
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
421
    public fillValidates(fieldErrors: any[]): void {
ibizdev's avatar
ibizdev committed
422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438
        fieldErrors.forEach((error: any) => {
            const formItem: FormItemModel = this.detailsModel[error.field];
            if (!formItem) {
                return;
            }
            this.$nextTick(() => {
                formItem.setError(error.message);
            });
        });
    }

    /**
     * 表单校验状态
     *
     * @returns {boolean} 
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
439
    public formValidateStatus(): boolean {
ibizdev's avatar
ibizdev committed
440 441 442 443 444 445 446 447 448 449 450 451 452 453
        const form: any = this.$refs.searchform;
        let validatestate: boolean = true;
        form.validate((valid: boolean) => {
            validatestate = valid ? true : false;
        });
        return validatestate
    }

    /**
     * 获取全部值
     *
     * @returns {*}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
454
    public getValues(): any {
ibizdev's avatar
ibizdev committed
455 456 457 458 459 460 461 462 463 464
        return this.data;
    }

    /**
     * 表单项值变更
     *
     * @param {{ name: string, value: any }} $event
     * @returns {void}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
465
    public onFormItemValueChange($event: { name: string, value: any }): void {
ibizdev's avatar
ibizdev committed
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482
        if (!$event) {
            return;
        }
        if (!$event.name || Object.is($event.name, '') || !this.data.hasOwnProperty($event.name)) {
            return;
        }
        this.data[$event.name] = $event.value;
    }

    /**
     * 设置数据项值
     *
     * @param {string} name
     * @param {*} value
     * @returns {void}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
483
    public setDataItemValue(name: string, value: any): void {
ibizdev's avatar
ibizdev committed
484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500
        if (!name || Object.is(name, '') || !this.data.hasOwnProperty(name)) {
            return;
        }
        if (Object.is(this.data[name], value)) {
            return;
        }
        this.data[name] = value;
    }



    /**
     * 分组界面行为事件
     *
     * @param {*} $event
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
501
    public groupUIActionClick($event: any): void {
ibizdev's avatar
ibizdev committed
502 503 504 505 506 507 508 509 510 511 512
        if (!$event) {
            return;
        }
        const item:any = $event.item;
    }

    /**
     * Vue声明周期(处理组件的输入属性)
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
513
    public created(): void {
ibizdev's avatar
ibizdev committed
514 515 516 517 518 519 520 521
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof DefaultBase
     */    
ibizdev's avatar
ibizdev committed
522
    public afterCreated(){
ibizdev's avatar
ibizdev committed
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545
        if (this.viewState) {
            this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => {
                if (!Object.is(tag, this.name)) {
                    return;
                }
                if (Object.is('autoload', action)) {
                    this.autoLoad(data);
                }
                if (Object.is('load', action)) {
                    this.load(data);
                }
                if (Object.is('loaddraft', action)) {
                    this.loadDraft(data);
                }
            });
        }
    }

    /**
     * vue 生命周期
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
546
    public destroyed() {
ibizdev's avatar
ibizdev committed
547 548 549 550 551 552 553 554
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
555
    public afterDestroy() {
ibizdev's avatar
ibizdev committed
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        if (this.dataChangEvent) {
            this.dataChangEvent.unsubscribe();
        }
    }

    /**
     * 自动加载
     *
     * @param {*} [arg={}]
     * @returns {void}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
571
    public autoLoad(arg: any = {}): void {
ibizdev's avatar
ibizdev committed
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
        if (arg.srfkey && !Object.is(arg.srfkey, '')) {
            Object.assign(arg, { srfkey: arg.srfkey });
            this.load(arg);
            return;
        }
        if (arg.srfkeys && !Object.is(arg.srfkeys, '')) {
            Object.assign(arg, { srfkey: arg.srfkeys });
            this.load(arg);
            return;
        }
        this.loadDraft(arg);
    }

    /**
     * 加载
     *
ibizdev's avatar
ibizdev committed
588
     * @public
ibizdev's avatar
ibizdev committed
589 590 591
     * @param {*} [opt={}]
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
592
    public load(opt: any = {}): void {
ibizdev's avatar
ibizdev committed
593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
        if(!this.loadAction){
            this.$Notice.error({ title: '错误', desc: 'WFUserGridView视图搜索表单loadAction参数未配置' });
            return;
        }
        const arg: any = { ...opt };
        Object.assign(arg,{viewparams:this.viewparams});
        const get: Promise<any> = this.service.get(this.loadAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
        get.then((response: any) => {
            if (response && response.status === 200) {
                const data = response.data;
                this.onFormLoad(data);
                this.$emit('load', data);
                this.$nextTick(() => {
                    this.formState.next({ type: 'load', data: data });
                });
            }
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            if (!response || !response.status || !response.data) {
                this.$Notice.error({ title: '错误', desc: '系统异常' });
                return;
            }

            const { data: _data } = response;
            this.$Notice.error({ title: _data.title, desc: _data.message });
        });
    }

    /**
     * 加载草稿
     *
     * @param {*} [opt={}]
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
629
    public loadDraft(opt: any = {},mode?:string): void {
ibizdev's avatar
ibizdev committed
630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690
        if(!this.loaddraftAction){
            this.$Notice.error({ title: '错误', desc: 'WFUserGridView视图搜索表单loaddraftAction参数未配置' });
            return;
        }
        const arg: any = { ...opt } ;
        Object.assign(arg,{viewparams:this.viewparams});
        let post: Promise<any> = this.service.loadDraft(this.loaddraftAction,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 = response.data;
            this.resetDraftFormStates();
            this.onFormLoad(data);
            setTimeout(() => {
                const form: any = this.$refs.form;
                if (form) {
                    form.fields.forEach((field: any) => {
                        field.validateMessage = "";
                        field.validateState = "";
                        field.validateStatus = false;
                    });
                }
            });
            if(Object.is(mode,'RESET')){
                if (!this.formValidateStatus()) {
                    return;
                }
            }
            this.$emit('load', data);
            this.$nextTick(() => {
                this.formState.next({ type: 'load', data: data });
            });
        }).catch((response: any) => {
            if (response && response.status === 401) {
                return;
            }
            if (!response || !response.status || !response.data) {
                this.$Notice.error({ title: '错误', desc: '系统异常' });
                return;
            }

            const { data: _data } = response;
            this.$Notice.error({ title: _data.title, desc: _data.message });
        });
    }

    /**
     * 表单项更新
     *
     * @param {string} mode 界面行为名称
     * @param {*} [data={}] 请求数据
     * @param {string[]} updateDetails 更新项
     * @param {boolean} [showloading] 是否显示加载状态
     * @returns {void}
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
691
    public updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
ibizdev's avatar
ibizdev committed
692 693 694 695 696 697 698 699 700
        
    }

    /**
     * 回车事件
     *
     * @param {*} $event
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
701
    public onEnter($event: any): void {
ibizdev's avatar
ibizdev committed
702 703 704
        if (!this.formValidateStatus()) {
            return;
        }
ibizdev's avatar
ibizdev committed
705
        this.$emit('search', this.data);
ibizdev's avatar
ibizdev committed
706 707 708 709 710 711 712
    }

    /**
     * 搜索
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
713
    public onSearch() {
ibizdev's avatar
ibizdev committed
714 715 716
        if (!this.formValidateStatus()) {
            return;
        }
ibizdev's avatar
ibizdev committed
717
        this.$emit('search', this.data);
ibizdev's avatar
ibizdev committed
718 719 720 721 722 723 724
    }

    /**
     * 重置
     *
     * @memberof DefaultBase
     */
ibizdev's avatar
ibizdev committed
725
    public onReset() {
ibizdev's avatar
ibizdev committed
726 727 728 729 730 731 732 733
        this.loadDraft({},'RESET');
    }
}
</script>

<style lang='less'>
@import './default-searchform.less';
</style>