VIEW_HEADER-BASE.vue.ftl 10.3 KB
Newer Older
1 2 3
<#ibizinclude>
../../@NAVPARAMS/FUNC/PUBLIC.vue.ftl
</#ibizinclude>
ibizdev's avatar
ibizdev committed
4 5
<script lang='ts'>
import { Vue, Component, Prop, Provide, Emit, Watch } from 'vue-property-decorator';
KK's avatar
KK committed
6
import { Subject, Subscription } from 'rxjs';
ibizdev's avatar
ibizdev committed
7
import GlobalUiService from '@/global-ui-service/global-ui-service';
8 9 10
<#if view.isEnableQuickGroup?? && view.isEnableQuickGroup()?? && view.isEnableQuickGroup() == true>
import { CodeListService } from "@/ibiz-core";
</#if>
ibizdev's avatar
ibizdev committed
11 12 13
<#if appde??>
import ${srfclassname('${appde.getCodeName()}')}Service from '@/app-core/service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-service';
</#if>
14

ibizdev's avatar
ibizdev committed
15 16 17 18 19
<#if view.getPSAppViewEngines()??>
    <#list view.getPSAppViewEngines() as engine>
import ${engine.getEngineType()}Engine from '@engine/${engine.getEngineCat()?lower_case}/${srffilepath2(engine.getEngineType())}-engine';
    </#list>
</#if>
KK's avatar
KK committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
<#if view.getPSUIActions()??>
<#list view.getPSUIActions() as uiAction>
<#if uiAction.getPSAppDataEntity?? && uiAction.getPSAppDataEntity()??>
<#if uiAction.getPFLogicCodeType() == "WFBACKEND">
<#if uiAction.getPSAppWFVer?? && uiAction.getPSAppWFVer()??>
<#if !P.exists("importService", uiAction.getPSAppWFVer().getCodeName(), "")>
import ${srfclassname('${curAppEntity.getCodeName()}')}UIService from '@/ui-service/${srffilepath2(curAppEntity.getCodeName())}/${srffilepath2(curAppEntity.getCodeName())}-ui-action';
</#if>
</#if>
</#if>
</#if>
</#list>
</#if>
<#if appde??>
import ${srfclassname('${appde.getCodeName()}')}UIService from '@/ui-service/${srffilepath2(appde.getCodeName())}/${srffilepath2(appde.getCodeName())}-ui-action';
</#if>
ibizdev's avatar
ibizdev committed
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
<#if import_block??>
${import_block}
</#if>

@Component({
    components: {
    },
})
export default class ${srfclassname('${view.name}')}Base extends Vue {

    /**
     * 全局 ui 服务
     *
     * @type {GlobalUiService}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
52
    protected globaluiservice: GlobalUiService = new GlobalUiService();
ibizdev's avatar
ibizdev committed
53 54 55 56 57 58 59 60 61
<#if appde??>

    /**
     * 实体服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}Service}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected appEntityService: ${srfclassname('${appde.getCodeName()}')}Service = new ${srfclassname('${appde.getCodeName()}')}Service();
KK's avatar
KK committed
62 63 64 65 66 67 68 69

    /**
     * 实体UI服务对象
     *
     * @type ${srfclassname('${appde.getCodeName()}')}UIService
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public appUIService: ${srfclassname('${appde.getCodeName()}')}UIService = new ${srfclassname('${appde.getCodeName()}')}UIService(this.$store);
ibizdev's avatar
ibizdev committed
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
</#if>

    /**
     * 数据变化
     *
     * @param {*} val
     * @returns {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Emit() 
    protected viewDatasChange(val: any):any {
        return val;
    }

    /**
     * 视图上下文
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
90
    @Prop() protected _context!: string;
ibizdev's avatar
ibizdev committed
91 92 93 94 95 96 97

    /**
     * 视图参数
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
98
    @Prop() protected _viewparams!: string;
ibizdev's avatar
ibizdev committed
99 100 101 102 103 104 105

    /**
     * 视图默认使用
     *
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
106
    @Prop({ default: "routerView" }) protected viewDefaultUsage!: string;
ibizdev's avatar
ibizdev committed
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

	/**
	 * 视图标识
	 *
	 * @type {string}
	 * @memberof ${srfclassname('${view.name}')}Base
	 */
	protected viewtag: string = '${view.getId()}';

    /**
     * 视图上下文
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected context: any = {};

    /**
     * 视图参数
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected viewparams: any = {};

KK's avatar
KK committed
132 133 134 135 136 137 138 139
    /**
     * 是否为子视图
     *
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({ default: false }) protected isChildView?: boolean;

140 141 142 143 144 145 146
    /**
     * 标题状态
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public titleStatus :boolean = true;

147 148 149 150 151 152 153
    /**
     * 视图导航上下文
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
154
    protected navContext: any = {<#if view.getPSAppViewNavContexts?? && view.getPSAppViewNavContexts()??> <#list view.getPSAppViewNavContexts() as context>'${context.getKey()?lower_case}': '<#if context.isRawValue()>${context.getValue()}<#else>%${context.getValue()}%</#if>'<#if context_has_next>, </#if></#list> </#if>};
155 156 157 158 159 160 161 162

    /**
     * 视图导航参数
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
163
    protected navParam: any = {<#if view.getPSAppViewNavParams?? && view.getPSAppViewNavParams()??> <#list view.getPSAppViewNavParams() as param>'${param.getKey()?lower_case}': '<#if param.isRawValue()>${param.getValue()}<#else>%${param.getValue()}%</#if>'<#if param_has_next>, </#if></#list> </#if>};
164

ibizdev's avatar
ibizdev committed
165 166 167 168 169 170 171 172 173 174
    /**
     * 视图模型数据
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected model: any = {
        srfTitle: '<#if view.getTitle()??>${view.getTitle()}</#if>',
        srfCaption: '<#if view.getPSAppDataEntity()??>${view.getPSAppDataEntity().getCodeName()?lower_case}.views.${view.getPSDEViewCodeName()?lower_case}.caption<#else>app.views.${view.getCodeName()?lower_case}.caption</#if>',
        srfSubCaption: '<#if view.getSubCaption()??>${view.getSubCaption()}</#if>',
KK's avatar
KK committed
175
        dataInfo: '',
176
        viewname:'<#if view.getPSAppDataEntity()??>${view.getPSAppDataEntity().getCodeName()?lower_case}.${view.getPSDEViewCodeName()?lower_case}<#else>app.views.${view.getCodeName()?lower_case}</#if>',
KK's avatar
KK committed
177
    <#if view.getPSSysImage?? && view.getPSSysImage()??>
KK's avatar
KK committed
178
        iconcls: '${view.getPSSysImage().getImagePath()}',
179
        icon: '<@setIcon view />'
KK's avatar
KK committed
180 181 182 183
    <#else>
        iconcls: '',
        icon: ''
    </#if>
ibizdev's avatar
ibizdev committed
184 185 186 187 188 189 190 191 192 193 194 195
    }

    /**
     * 视图上下文变化
     *
     * @param {string} newVal
     * @param {string} oldVal
     * @memberof  ${srfclassname('${view.name}')}Base
     */
    @Watch('_context')
    on_context(newVal: string, oldVal: string) {
        const _this: any = this;
196
        this.parseViewParam();
ibizdev's avatar
ibizdev committed
197
        if (!Object.is(newVal, oldVal) && _this.engine) {
198
            this.$nextTick(()=>{_this.engine.load();})
ibizdev's avatar
ibizdev committed
199 200 201 202 203 204 205 206 207 208 209 210 211 212
        }
        <#if _context_block??>${_context_block}</#if>
    }

    /**
     * 视图参数变化
     *
     * @param {string} newVal
     * @param {string} oldVal
     * @returns
     * @memberof IBizChart
     */
    @Watch('_viewparams')
    on_viewparams(newVal: string, oldVal: string) {
213
        this.parseViewParam();
ibizdev's avatar
ibizdev committed
214 215
    }

216 217 218 219 220 221 222 223 224 225 226 227
    /**
     * 设置工具栏状态
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public setViewTitleStatus(){
        const thirdPartyName = this.$store.getters.getThirdPartyName();
        if(thirdPartyName){
            this.titleStatus = false;
        }
    }

ibizdev's avatar
ibizdev committed
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259
    /**
     * 容器模型
     *
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected containerModel: any = {
<#if view.getPSControls()??>
    <#list view.getPSControls() as ctrl>
        view_${ctrl.name}: { name: '${ctrl.name}', type: '${ctrl.getControlType()}' },
    </#list>
</#if>
<#if view.isPickupView() || (view.getViewType?? && (view.getViewType() == 'DEOPTVIEW' || view.getViewType() == 'DEWFSTARTVIEW' || view.getViewType() == 'DEWFACTIONVIEW'))>
        view_okbtn: { name: 'okbtn', type: 'button', text: '确定', disabled: true },
        view_cancelbtn: { name: 'cancelbtn', type: 'button', text: '取消', disabled: false },
        view_leftbtn: { name: 'leftbtn', type: 'button', text: '左移', disabled: true },
        view_rightbtn: { name: 'rightbtn', type: 'button', text: '右移', disabled: true },
        view_allleftbtn: { name: 'allleftbtn', type: 'button', text: '全部左移', disabled: true },
        view_allrightbtn: { name: 'allrightbtn', type: 'button', text: '全部右移', disabled: true },
</#if>
<#if view.getPSWorkflow?? && view.getPSWorkflow()??>
        wflinks: [],
</#if>
    };

    /**
     * 视图状态订阅对象
     *
     * @type {Subject<{action: string, data: any}>}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected viewState: Subject<ViewState> = new Subject();
260 261 262 263 264 265 266 267 268


    /**
     * 是否显示标题
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({default:true}) protected showTitle?: boolean;
ibizdev's avatar
ibizdev committed
269 270 271 272 273 274 275 276 277
<#--  工具栏模型:BEGIN  -->
<#list view.getAllPSControls() as ctrl>

    <#if ctrl.getControlType() == 'TOOLBAR'>
${P.getCtrlCode(ctrl, 'CONTROL.vue').code}
    </#if>
</#list>
<#--  工具栏模型:END  -->

KK's avatar
KK committed
278 279 280 281 282 283 284
    /**
     * 工具栏模型集合名
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public toolbarModelList:any = [<#list view.getAllPSControls() as ctrl><#if ctrl.getControlType() == 'TOOLBAR'>'${ctrl.name?lower_case}Models',</#if></#list>]

ibizdev's avatar
ibizdev committed
285 286 287 288 289
    /**
     * 解析视图参数
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
290
    protected parseViewParam(): void {
KK's avatar
KK committed
291
        const { context, param } = this.$viewTool.formatNavigateViewParam(this, <#if view.isPSDEView() && view.getViewType()  != 'DEMOBEDITVIEW9' &&  view.getViewType()!= 'DEMOBMEDITVIEW9'>true<#else>false</#if>);
292 293
        this.context = { ...context };
        this.viewparams = { ...param }
ibizdev's avatar
ibizdev committed
294 295 296 297 298 299 300 301 302 303 304 305
    }
<#--  移动端参数:BEGIN  -->

    /**
     * 是否显示返回按钮
     *
     * @readonly
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    get isShowBackButton(): boolean {
        // 存在路由,非路由使用,嵌入
306
        if (this.viewDefaultUsage === "indexView") {
ibizdev's avatar
ibizdev committed
307 308 309 310 311
            return false;
        }
        return true;
    }
<#--  视图是否支持下拉刷新:BEGIN  -->
312
<#if view.isEnablePullDownRefresh?? && view.isEnablePullDownRefresh()>
ibizdev's avatar
ibizdev committed
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329

    /**
     * 下拉刷新
     *
     * @param {*} $event
     * @returns {Promise<any>}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public async pullDownToRefresh($event: any): Promise<any> {
    <#if pullDownToRefreshLogic??>
        ${pullDownToRefreshLogic}<#t/>
    <#else>
        setTimeout(() => {
            $event.srcElement.complete();
        }, 2000);
    </#if>
    }
330
</#if>
ibizdev's avatar
ibizdev committed
331 332
<#--  视图是否支持下拉刷新:END  -->
<#--  移动端参数:END  -->