VIEW-BASE.vue.ftl 7.4 KB
Newer Older
1 2 3
<#ibizinclude>
../@MACRO/LAYOUTPANEL_VIEW.template.ftl
</#ibizinclude>
4
// 基于 @VIEW/实体日历视图/VIEW-BASE.vue.ftl 生成
tony001's avatar
tony001 committed
5
<#assign import_block>
6
import CodeListService from "@/codelist/codelist-service";
tony001's avatar
tony001 committed
7 8 9 10 11 12
<#if view.getPSSysCounterRef?? && view.getPSSysCounterRef()?? && view.getPSSysCounterRef().getPSAppCounter()??>
<#assign appCounter = view.getPSSysCounterRef().getPSAppCounter() />
import  ${srfclassname('${appCounter.getCodeName()}')}CounterService  from '@/counter/${srffilepath2(appCounter.getCodeName())}/${srffilepath2(appCounter.getCodeName())}-counter';
</#if>
</#assign>

13 14 15 16
<#ibizinclude>
../@MACRO/VIEW_HEADER-BASE.vue.ftl
</#ibizinclude>

tony001's avatar
tony001 committed
17 18 19 20
<#assign mounted_block>
<#if view.isEnableQuickGroup()>_this.loadQuickGroupModel();</#if>
</#assign>

21 22 23
<#ibizinclude>
../@MACRO/VIEW_CONTENT-BASE.vue.ftl
</#ibizinclude>
tony001's avatar
tony001 committed
24 25 26 27 28

    /**
     * 搜索值
     *
     * @type {string}
29
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
30 31 32 33 34 35 36
     */
    public query: string = '';

    /**
     * 是否展开搜索表单
     *
     * @type {boolean}
37
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
38 39 40 41 42 43 44
     */
    public isExpandSearchForm: boolean = ${view.isExpandSearchForm()?c};

    /**
     * 快速搜索
     *
     * @param {*} $event
45
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
46 47 48 49 50 51 52 53 54 55 56 57
     */
    public onSearch($event: any): void {
        const refs: any = this.$refs;
        if (refs.calendar) {
            refs.calendar.refresh();
        }
    }

    /**
     * calendar 的 beforeload 事件
     *
     * @param {*} arg
58
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
59 60 61 62 63 64 65 66 67 68 69 70 71 72
     */
    public onBeforeLoad(arg: any){
        let _this:any = this;
        if (_this.viewparams && Object.keys(_this.viewparams).length > 0) {
            Object.assign(arg, _this.viewparams);
        }
        if (_this.$refs.searchform && _this.isExpandSearchForm) {
            Object.assign(arg, _this.$refs.searchform.getData());
        }
        if (_this && !_this.isExpandSearchForm) {
            Object.assign(arg, { query: _this.query });
        }
        // 快速分组和快速搜索栏
        let otherQueryParam:any = {};
73 74
        if(_this && (_this.quickGroupData as any)){
            Object.assign(otherQueryParam,_this.quickGroupData);
tony001's avatar
tony001 committed
75
        }
76 77
        if(_this && _this.quickFormData){
            Object.assign(otherQueryParam,_this.quickFormData);
tony001's avatar
tony001 committed
78 79 80 81 82 83 84 85
        }
        Object.assign(arg,{viewparams:otherQueryParam});
    }

    /**
     * searchform 部件 search 事件
     *
     * @param {*} $event
86
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
87 88 89 90 91 92 93 94 95
     */
    public searchform_search($event: any) {
        this.onSearch($event);
    }

    /**
     * searchform 部件 load 事件
     *
     * @param {*} $event
96
     * @memberof ${srfclassname('${view.name}')}Base
tony001's avatar
tony001 committed
97 98 99 100 101 102 103 104 105 106 107 108 109
     */
    public searchform_load($event: any) {
        this.onSearch($event);
    }

    <#if view.getPSSysCounterRef?? && view.getPSSysCounterRef()?? && view.getPSSysCounterRef().getPSAppCounter()??>
    <#assign appCounter = view.getPSSysCounterRef().getPSAppCounter() />
    /**
     * ${srfclassname('${appCounter.getCodeName()}')}CounterService计数器服务对象
     *
     * @type {${srfclassname('${appCounter.getCodeName()}')}CounterService}
     * @memberof ${srfclassname('${view.name}')}Base
     */
RedPig97's avatar
RedPig97 committed
110
    public ${appCounter.getCodeName()?lower_case}counterservice: ${srfclassname('${appCounter.getCodeName()}')}CounterService = new ${srfclassname('${appCounter.getCodeName()}')}CounterService({ context:this.context,viewparams:this.viewparams });
tony001's avatar
tony001 committed
111 112 113 114 115 116 117 118 119 120
    </#if>

<#if view.isEnableQuickGroup()>

    /**
     * 代码表服务对象
     *
     * @type {CodeListService}
     * @memberof ${srfclassname('${view.name}')}Base
     */  
RedPig97's avatar
RedPig97 committed
121
    public codeListService:CodeListService = new CodeListService();
tony001's avatar
tony001 committed
122 123 124 125 126 127

    /**
     * 快速分组数据对象
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
128
    public quickGroupData:any;
tony001's avatar
tony001 committed
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168

    /**
     * 快速分组是否有抛值
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public isEmitQuickGroupValue:boolean = false;

    /**
     * 快速分组模型
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public quickGroupModel:Array<any> = [];

    /**
     * 加载快速分组模型
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public loadQuickGroupModel(){
        <#if view.getQuickGroupPSCodeList()??>
        <#assign codelist=view.getQuickGroupPSCodeList() />
        let quickGroupCodeList:any = {tag:'${codelist.codeName}',codelistType:'${codelist.getCodeListType()}'};
        if(quickGroupCodeList.tag && Object.is(quickGroupCodeList.codelistType,"STATIC")){
            const codelist = this.$store.getters.getCodeList(quickGroupCodeList.tag);
            if (codelist) {
                this.quickGroupModel = [...this.handleDynamicData(JSON.parse(JSON.stringify(codelist.items)))];
            } else {
                <#noparse>console.log(`----${quickGroupCodeList.tag}----代码表不存在`);</#noparse>
            }
        }else if(quickGroupCodeList.tag && Object.is(quickGroupCodeList.codelistType,"DYNAMIC")){
            this.codeListService.getItems(quickGroupCodeList.tag,{},{}).then((res:any) => {
                this.quickGroupModel = res;
            }).catch((error:any) => {
                <#noparse>console.log(`----${quickGroupCodeList.tag}----代码表不存在`);</#noparse>
            });
        }
        </#if>
    }
169
    
tony001's avatar
tony001 committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
    /**
     * 处理快速分组模型动态数据部分(%xxx%)
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public handleDynamicData(inputArray:Array<any>){
        if(inputArray.length >0){
            inputArray.forEach((item:any) =>{
               if(item.data && Object.keys(item.data).length >0){
                   Object.keys(item.data).forEach((name:any) =>{
                        let value: any = item.data[name];
                        if (value && typeof(value)=='string' && value.startsWith('%') && value.endsWith('%')) {
                            const key = (value.substring(1, value.length - 1)).toLowerCase();
                            if (this.context[key]) {
                                value = this.context[key];
                            } else if(this.viewparams[key]){
                                value = this.viewparams[key];
                            }
                        }
                        item.data[name] = value;
                   })
               }
            })
        }
        return inputArray;
    }

    /**
     * 快速分组值变化
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
202
    public quickGroupValueChange($event:any){
203
        if($event){
204
            this.quickGroupData = $event.data;
tony001's avatar
tony001 committed
205 206 207 208 209 210 211 212 213 214 215 216 217 218
            if(this.isEmitQuickGroupValue){
                this.onSearch($event);
            }
        }
        this.isEmitQuickGroupValue = true;
    }
</#if>
<#if view.getQuickPSDESearchForm()??>

    /**
     * 快速搜索栏数据对象
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
219
    public quickFormData:any;
tony001's avatar
tony001 committed
220 221 222 223 224 225

    /**
     * 快速搜索栏值变化
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
226 227
    public quickFormValueChange($event:any){
        this.quickFormData = $event;
tony001's avatar
tony001 committed
228 229 230 231
        this.onSearch($event);
    }
</#if>

232 233 234 235 236 237 238
<#ibizinclude>
../@MACRO/VIEW_BOTTOM-BASE.vue.ftl
</#ibizinclude>

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