<template>
    <i-form :model="this.data" class='app-search-form' ref='searchform' style="">
  <input style="display:none;"/>
  <row>
    <i-col span="20" class="form-content">
      <row>
                    <div style="height: 100%;display: flex;flex-direction: row;align-items: center;">
              <div  v-show="detailsModel.n_ibizordername_like.visible" :style="{}">
          <app-form-item name='n_ibizordername_like' :itemRules="this.rules.n_ibizordername_like" class='' :caption="$t('entities.ibizorder.uipart_0013_searchform.details.n_ibizordername_like')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_ibizordername_like.error" :isEmptyCaption="false" labelPos="LEFT"> 
              <input-box 
              v-model="data.n_ibizordername_like"  
              @enter="onEnter($event)"  
                
              :disabled="detailsModel.n_ibizordername_like.disabled" 
              type='text' 
              style="width:100px;">
          </input-box>
          
          </app-form-item>
          
          </div>
          <div  v-show="detailsModel.n_orderstate_eq.visible" :style="{}">
          <app-form-item name='n_orderstate_eq' :itemRules="this.rules.n_orderstate_eq" class='' :caption="$t('entities.ibizorder.uipart_0013_searchform.details.n_orderstate_eq')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_orderstate_eq.error" :isEmptyCaption="false" labelPos="LEFT"> 
              
           <dropdown-list 
              v-model="data.n_orderstate_eq" 
              :data="data" 
              :context="context"
              :viewparams="viewparams"
              :formState="formState" 
              :localContext ='{ }' 
              :localParam ='{ }' 
              :disabled="detailsModel.n_orderstate_eq.disabled" 
              valueType="string"
              tag='ORDERSTATE' 
              codelistType='STATIC'
              placeholder='请选择...' style="width:100px;">
           </dropdown-list>
          
          </app-form-item>
          
          </div>
          <div  v-show="detailsModel.n_ordertime_gt.visible" :style="{}">
          <app-form-item name='n_ordertime_gt' :itemRules="this.rules.n_ordertime_gt" class='' :caption="$t('entities.ibizorder.uipart_0013_searchform.details.n_ordertime_gt')" uiStyle="DEFAULT" :labelWidth="130" :isShowCaption="true" :error="detailsModel.n_ordertime_gt.error" :isEmptyCaption="false" labelPos="LEFT"> 
              <date-picker type="date" :transfer="true" format="yyyy-MM-dd"  :value="data.n_ordertime_gt" :disabled="detailsModel.n_ordertime_gt.disabled" style="min-width: 150px; width:100px;" @on-change="(val1, val2) => { this.data.n_ordertime_gt = val1 }"></date-picker>
          
          </app-form-item>
          
          </div>
          <div  v-show="detailsModel.n_ordertime_lt.visible" :style="{}">
          <app-form-item name='n_ordertime_lt' :itemRules="this.rules.n_ordertime_lt" class='' :caption="$t('entities.ibizorder.uipart_0013_searchform.details.n_ordertime_lt')" uiStyle="DEFAULT" :labelWidth="24" :isShowCaption="true" :error="detailsModel.n_ordertime_lt.error" :isEmptyCaption="false" labelPos="LEFT"> 
              <date-picker type="date" :transfer="true" format="yyyy-MM-dd"  :value="data.n_ordertime_lt" :disabled="detailsModel.n_ordertime_lt.disabled" style="min-width: 150px; width:100px;" @on-change="(val1, val2) => { this.data.n_ordertime_lt = val1 }"></date-picker>
          
          </app-form-item>
          
          </div>
          
          </div>
      </row>
    </i-col>
    <i-col span="4" class="search-button">
      <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'>
import { Vue, Component, Prop, Provide, Emit, Watch, Model,Inject } from 'vue-property-decorator';
import { CreateElement } from 'vue';
import { Subject, Subscription } from 'rxjs';
import { ControlInterface } from '@/interface/control';
import { UIActionTool,Util,ViewTool } from '@/utils';
import NavDataService from '@/service/app/navdata-service';
import AppCenterService from "@service/app/app-center-service";
import IBIZOrderEntityService from '@/service/ibizorder/ibizorder-service';
import UIPART_0013Service from './uipart-0013-searchform-service';
import IBIZOrderUIService from '@/uiservice/ibizorder/ibizorder-ui-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 UIPART_0013Base extends Vue implements ControlInterface {

    /**
     * 名称
     *
     * @type {string}
     * @memberof UIPART_0013Base
     */
    @Prop() public name?: string;

    /**
     * 视图通讯对象
     *
     * @type {Subject<ViewState>}
     * @memberof UIPART_0013Base
     */
    @Prop() public viewState!: Subject<ViewState>;

    /**
     * 应用上下文
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    @Prop() public context!: any;

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    @Prop() public viewparams!: any;

    /**
     * 视图操作参数(父级)
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    @Prop() public pViewCtx!: any;

    /**
     * 视图操作参数
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    public viewCtx: any = {};

    /**
     * 监听视图操作参数变化
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    @Watch('pViewCtx', { immediate: true })
    public onViewCtxChange(newVal: any, oldVal: any) {
        Object.assign(this.viewCtx, newVal, { xData: this, ctrl: this });
    }

    /**
     * 视图状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof UIPART_0013Base
     */
    public viewStateEvent: Subscription | undefined;

    /**
     * 获取部件类型
     *
     * @returns {string}
     * @memberof UIPART_0013Base
     */
    public getControlType(): string {
        return 'SEARCHFORM'
    }



    /**
     * 计数器服务对象集合
     *
     * @type {Array<*>}
     * @memberof UIPART_0013Base
     */    
    public counterServiceArray:Array<any> = [];

    /**
     * 建构部件服务对象
     *
     * @type {UIPART_0013Service}
     * @memberof UIPART_0013Base
     */
    public service: UIPART_0013Service = new UIPART_0013Service({ $store: this.$store });

    /**
     * 实体服务对象
     *
     * @type {IBIZOrderService}
     * @memberof UIPART_0013Base
     */
    public appEntityService: IBIZOrderEntityService = new IBIZOrderEntityService({ $store: this.$store });
    


    /**
     * 转化数据
     *
     * @param {any} args
     * @memberof  UIPART_0013Base
     */
    public transformData(args: any) {
        let _this: any = this;
        if(_this.service && _this.service.handleRequestData instanceof Function && _this.service.handleRequestData('transform',_this.context,args)){
            return _this.service.handleRequestData('transform',_this.context,args)['data'];
        }
    }

    /**
     * 关闭视图
     *
     * @param {any} args
     * @memberof UIPART_0013Base
     */
    public closeView(args: any): void {
        let _this: any = this;
        _this.$emit('closeview', [args]);
    }

    /**
     *  计数器刷新
     *
     * @memberof UIPART_0013Base
     */
    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();
                }
            })
        }
    }
    /**
     *  处理部件事件
     *
     * @memberof UIPART_0013Base
     */
    public async handleCtrlEvents(eventName: string, args: any = {}): Promise<boolean> {
        const actionData = {
            data: this.getData() || {},
            context: Util.deepCopy(this.context),
            viewparams: Util.deepCopy(this.viewparams),
            xData: this
        }
        let result: boolean = true;
        Object.assign(actionData, args);
        if (!result) {
            return false;
        }
        this.$emit(eventName, actionData);
        return true;
    }




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

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

    /**
     * 显示处理提示
     *
     * @type {boolean}
     * @memberof UIPART_0013Base
     */
    @Prop({ default: true }) public showBusyIndicator?: boolean;
    
    /**
     * 部件行为--loaddraft
     *
     * @type {string}
     * @memberof UIPART_0013Base
     */
    @Prop() public loaddraftAction!: string;
    
    /**
     * 部件行为--load
     *
     * @type {string}
     * @memberof UIPART_0013Base
     */
    @Prop() public loadAction!: string;

    /**
     * 视图标识
     *
     * @type {string}
     * @memberof UIPART_0013Base
     */
    @Prop() public viewtag!: string;

    /**
     * 表单状态
     *
     * @type {Subject<any>}
     * @memberof UIPART_0013Base
     */
    public formState: Subject<any> = new Subject();

    /**
     * 忽略表单项值变化
     *
     * @type {boolean}
     * @memberof UIPART_0013Base
     */
    public ignorefieldvaluechange: boolean = false;

    /**
     * 数据变化
     *
     * @public
     * @type {Subject<any>}
     * @memberof UIPART_0013Base
     */
    public dataChang: Subject<any> = new Subject();

    /**
     * 视图状态事件
     *
     * @public
     * @type {(Subscription | undefined)}
     * @memberof UIPART_0013Base
     */
    public dataChangEvent: Subscription | undefined;

    /**
     * 原始数据
     *
     * @public
     * @type {*}
     * @memberof UIPART_0013Base
     */
    public oldData: any = {};

    /**
     * 表单数据对象
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    public data: any = {
        n_ibizordername_like: null,
        n_orderstate_eq: null,
        n_ordertime_gt: null,
        n_ordertime_lt: null,
    };

    /**
     * 详情模型集合
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    public detailsModel: any = {
        formpage1: new FormPageModel({ caption: '常规', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
, 
        n_ibizordername_like: new FormItemModel({ caption: '订单名称', detailType: 'FORMITEM', name: 'n_ibizordername_like', visible: true, isShowCaption: true, form: this,required:false, disabled: false, enableCond: 3 })
, 
        n_orderstate_eq: new FormItemModel({ caption: '订单状态', detailType: 'FORMITEM', name: 'n_orderstate_eq', visible: true, isShowCaption: true, form: this,required:false, disabled: false, enableCond: 3 })
, 
        n_ordertime_gt: new FormItemModel({ caption: '订单时间从', detailType: 'FORMITEM', name: 'n_ordertime_gt', visible: true, isShowCaption: true, form: this,required:false, disabled: false, enableCond: 3 })
, 
        n_ordertime_lt: new FormItemModel({ caption: '到', detailType: 'FORMITEM', name: 'n_ordertime_lt', visible: true, isShowCaption: true, form: this,required:false, disabled: false, enableCond: 3 })
, 
    };
    
    /**
     * 属性值规则
     *
     * @type {*}
     * @memberof UIPART_0013Base
     */
    public rules: any = {
        n_ibizordername_like: [
            { type: 'string', message: '订单名称 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '订单名称 值必须为字符串类型', trigger: 'blur' },
            { required: this.detailsModel.n_ibizordername_like.required, type: 'string', message: '订单名称 值不能为空', trigger: 'change' },
            { required: this.detailsModel.n_ibizordername_like.required, type: 'string', message: '订单名称 值不能为空', trigger: 'blur' },
        ],
        n_orderstate_eq: [
            { type: 'string', message: '订单状态 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '订单状态 值必须为字符串类型', trigger: 'blur' },
            { required: this.detailsModel.n_orderstate_eq.required, type: 'string', message: '订单状态 值不能为空', trigger: 'change' },
            { required: this.detailsModel.n_orderstate_eq.required, type: 'string', message: '订单状态 值不能为空', trigger: 'blur' },
        ],
        n_ordertime_gt: [
            { type: 'string', message: '订单时间从 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '订单时间从 值必须为字符串类型', trigger: 'blur' },
            { required: this.detailsModel.n_ordertime_gt.required, type: 'string', message: '订单时间从 值不能为空', trigger: 'change' },
            { required: this.detailsModel.n_ordertime_gt.required, type: 'string', message: '订单时间从 值不能为空', trigger: 'blur' },
        ],
        n_ordertime_lt: [
            { type: 'string', message: '到 值必须为字符串类型', trigger: 'change' },
            { type: 'string', message: '到 值必须为字符串类型', trigger: 'blur' },
            { required: this.detailsModel.n_ordertime_lt.required, type: 'string', message: '到 值不能为空', trigger: 'change' },
            { required: this.detailsModel.n_ordertime_lt.required, type: 'string', message: '到 值不能为空', trigger: 'blur' },
        ],
    }

    /**
     * 监控表单属性 n_ibizordername_like 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof UIPART_0013Base
     */
    @Watch('data.n_ibizordername_like')
    onN_ibizordername_likeChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'n_ibizordername_like', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 n_orderstate_eq 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof UIPART_0013Base
     */
    @Watch('data.n_orderstate_eq')
    onN_orderstate_eqChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'n_orderstate_eq', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 n_ordertime_gt 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof UIPART_0013Base
     */
    @Watch('data.n_ordertime_gt')
    onN_ordertime_gtChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'n_ordertime_gt', newVal: newVal, oldVal: oldVal });
    }

    /**
     * 监控表单属性 n_ordertime_lt 值
     *
     * @param {*} newVal
     * @param {*} oldVal
     * @memberof UIPART_0013Base
     */
    @Watch('data.n_ordertime_lt')
    onN_ordertime_ltChange(newVal: any, oldVal: any) {
        this.formDataChange({ name: 'n_ordertime_lt', newVal: newVal, oldVal: oldVal });
    }


    /**
     * 重置表单项值
     *
     * @public
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof UIPART_0013Base
     */
    public resetFormData({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
    }

    /**
     * 表单逻辑
     *
     * @public
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @memberof UIPART_0013Base
     */
    public formLogic({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
                





    }

    /**
     * 表单值变化
     *
     * @public
     * @param {{ name: string, newVal: any, oldVal: any }} { name, newVal, oldVal }
     * @returns {void}
     * @memberof UIPART_0013Base
     */
    public formDataChange({ name, newVal, oldVal }: { name: string, newVal: any, oldVal: any }): void {
        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));
    }

    /**
     * 表单加载完成
     *
     * @public
     * @param {*} [data={}]
     * @param {string} [action]
     * @memberof UIPART_0013Base
     */
    public onFormLoad(data: any = {},action:string): void {
        this.setFormEnableCond(data);
        this.fillForm(data,action);
        this.formLogic({ name: '', newVal: null, oldVal: null });
    }

    /**
     * 值填充
     *
     * @param {*} [_datas={}]
     * @param {string} [action]
     * @memberof UIPART_0013Base
     */
    public fillForm(_datas: any = {},action:string): void {
        this.ignorefieldvaluechange = true;
        Object.keys(_datas).forEach((name: string) => {
            if (this.data.hasOwnProperty(name)) {
                this.data[name] = _datas[name];
            }
        });
        if(Object.is(action,'loadDraft')){
            this.createDefault();
        }
        this.$nextTick(function () {
            this.ignorefieldvaluechange = false;
        })
    }

    /**
     * 设置表单项是否启用
     *
     * @public
     * @param {*} data
     * @memberof UIPART_0013Base
     */
    public setFormEnableCond(data: any): void {
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setEnableCond(data.srfuf);
        });
    }

    /**
     * 新建默认值
     * @memberof UIPART_0013Base
     */
    public createDefault(){                    
        if (this.data.hasOwnProperty('n_orderstate_eq')) {
          this.data['n_orderstate_eq'] = '10';
        }
        if (this.data.hasOwnProperty('n_ordertime_lt')) {
          this.data['n_ordertime_lt'] = this.$util.dateFormat(new Date());
        }
    }

    /**
     * 重置草稿表单状态
     *
     * @public
     * @memberof UIPART_0013Base
     */
    public resetDraftFormStates(): void {
        const form: any = this.$refs.form;
        if (form) {
            form.resetFields();
        }
    }

    /**
     * 重置校验结果
     *
     * @memberof UIPART_0013Base
     */
    public resetValidates(): void {
        Object.values(this.detailsModel).forEach((detail: any) => {
            if (!Object.is(detail.detailType, 'FORMITEM')) {
                return;
            }
            const formItem: FormItemModel = detail;
            formItem.setError('');
        });
    }

    /**
     * 填充校验结果 （后台）
     *
     * @param {any[]} fieldErrors
     * @memberof UIPART_0013Base
     */
    public fillValidates(fieldErrors: any[]): void {
        fieldErrors.forEach((error: any) => {
            const formItem: FormItemModel = this.detailsModel[error.field];
            if (!formItem) {
                return;
            }
            this.$nextTick(() => {
                formItem.setError(error.message);
            });
        });
    }

    /**
     * 表单校验状态
     *
     * @returns {boolean} 
     * @memberof UIPART_0013Base
     */
    public formValidateStatus(): boolean {
        const form: any = this.$refs.searchform;
        let validatestate: boolean = true;
        form.validate((valid: boolean) => {
            validatestate = valid ? true : false;
        });
        return validatestate
    }

    /**
     * 获取全部值
     *
     * @returns {*}
     * @memberof UIPART_0013Base
     */
    public getValues(): any {
        return this.data;
    }

    /**
     * 表单项值变更
     *
     * @param {{ name: string, value: any }} $event
     * @returns {void}
     * @memberof UIPART_0013Base
     */
    public onFormItemValueChange($event: { name: string, value: any }): void {
        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 UIPART_0013Base
     */
    public setDataItemValue(name: string, value: any): void {
        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 UIPART_0013Base
     */
    public groupUIActionClick($event: any): void {
        if (!$event) {
            return;
        }
        const item:any = $event.item;
    }

    /**
     * Vue声明周期(处理组件的输入属性)
     *
     * @memberof UIPART_0013Base
     */
    public created(): void {
        this.afterCreated();
    }

    /**
     * 执行created后的逻辑
     *
     *  @memberof UIPART_0013Base
     */    
    public afterCreated(){
        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 UIPART_0013Base
     */
    public destroyed() {
        this.afterDestroy();
    }

    /**
     * 执行destroyed后的逻辑
     *
     * @memberof UIPART_0013Base
     */
    public afterDestroy() {
        if (this.viewStateEvent) {
            this.viewStateEvent.unsubscribe();
        }
        if (this.dataChangEvent) {
            this.dataChangEvent.unsubscribe();
        }
    }

    /**
     * 自动加载
     *
     * @param {*} [arg={}]
     * @returns {void}
     * @memberof UIPART_0013Base
     */
    public autoLoad(arg: any = {}): void {
        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);
    }

    /**
     * 加载
     *
     * @public
     * @param {*} [opt={}]
     * @memberof UIPART_0013Base
     */
    public load(opt: any = {}): void {
        if(!this.loadAction){
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'IBIZOrderSF1GridView' + (this.$t('app.searchForm.notConfig.loadAction') as string) });
            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.$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: (this.$t('app.commonWords.wrong') as string), desc: (this.$t('app.commonWords.sysException') as string) });
                return;
            }

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

    /**
     * 加载草稿
     *
     * @param {*} [opt={}]
     * @memberof UIPART_0013Base
     */
    public async loadDraft(opt: any = {},mode?:string): Promise<any> {
        if(!this.loaddraftAction){
            this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: 'IBIZOrderSF1GridView' + (this.$t('app.searchForm.notConfig.loaddraftAction') as string) });
            return;
        }
        const arg: any = { ...opt } ;
        Object.assign(arg, { viewparams:this.viewparams });
        if (!(await this.handleCtrlEvents('onbeforeloaddraft', { data: arg }))) {
            return;
        }
        try {
            const response = await this.service.loadDraft(this.loaddraftAction,JSON.parse(JSON.stringify(this.context)), arg, this.showBusyIndicator);
            if (!response.status || response.status !== 200) {
                if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response && response.data ? response.data : arg }))) {
                    return;
                }
                if (response.data && response.data.message) {
                    this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.data.message });
                }
                return response;
            }
            if (!(await this.handleCtrlEvents('onloaddraftsuccess', { data: response.data }))) {
                return;
            }
            const data = response.data;
            this.resetDraftFormStates();
            this.onFormLoad(data,'loadDraft');
            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 });
            });
            return response;
        } catch(response: any) {
            if (!(await this.handleCtrlEvents('onloaddrafterror', { data: response && response.data ? response.data : arg }))) {
                return;
            }
            if (response && response.status === 401) {
                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) });
                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 UIPART_0013Base
     */
    public updateFormItems(mode: string, data: any = {}, updateDetails: string[], showloading?: boolean): void {
        
    }

    /**
     * 回车事件
     *
     * @param {*} $event
     * @memberof UIPART_0013Base
     */
    public onEnter($event: any): void {
        if (!this.formValidateStatus()) {
            return;
        }
        this.$emit('search', this.data);
    }

    /**
     * 搜索
     *
     * @memberof UIPART_0013Base
     */
    public onSearch() {
        if (!this.formValidateStatus()) {
            return;
        }
        this.handleCtrlEvents('onsearch', { }).then((result: boolean) => {
            if (result) {
                this.$emit('search', this.data);
            }
        })
    }

    /**
     * 重置
     *
     * @memberof UIPART_0013Base
     */
    public onReset() {
        this.handleCtrlEvents('onreset', { }).then((result: boolean) => {
            if (result) {
                this.loadDraft({},'RESET');
            }
        })
    }
}
</script>

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