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

<#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
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<#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
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<#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
46
    protected globaluiservice: GlobalUiService = new GlobalUiService();
ibizdev's avatar
ibizdev committed
47 48 49 50 51 52 53 54 55
<#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
56 57 58 59 60 61 62 63

    /**
     * 实体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
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
</#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
84
    @Prop() protected _context!: string;
ibizdev's avatar
ibizdev committed
85 86 87 88 89 90 91

    /**
     * 视图参数
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
92
    @Prop() protected _viewparams!: string;
ibizdev's avatar
ibizdev committed
93 94 95 96 97 98 99

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

	/**
	 * 视图标识
	 *
	 * @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
126 127 128 129 130 131 132 133
    /**
     * 是否为子视图
     *
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({ default: false }) protected isChildView?: boolean;

134 135 136 137 138 139 140
    /**
     * 标题状态
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public titleStatus :boolean = true;

141 142 143 144 145 146 147
    /**
     * 视图导航上下文
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
148
    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>};
149 150 151 152 153 154 155 156

    /**
     * 视图导航参数
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
157
    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>};
158

ibizdev's avatar
ibizdev committed
159 160 161 162 163 164 165 166 167 168
    /**
     * 视图模型数据
     *
     * @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
169
        dataInfo: '',
KK's avatar
KK committed
170
    <#if view.getPSSysImage?? && view.getPSSysImage()??>
KK's avatar
KK committed
171 172
        iconcls: '${view.getPSSysImage().getImagePath()}',
        icon: '${view.getPSSysImage().getCssClass()}'
KK's avatar
KK committed
173 174 175 176
    <#else>
        iconcls: '',
        icon: ''
    </#if>
ibizdev's avatar
ibizdev committed
177 178 179 180 181 182 183 184 185 186 187 188
    }

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

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

209 210 211 212 213 214 215 216 217 218 219 220
    /**
     * 设置工具栏状态
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
    public setViewTitleStatus(){
        const thirdPartyName = this.$store.getters.getThirdPartyName();
        if(thirdPartyName){
            this.titleStatus = false;
        }
    }

ibizdev's avatar
ibizdev committed
221 222 223 224 225 226 227 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
    /**
     * 容器模型
     *
     * @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();
253 254 255 256 257 258 259 260 261


    /**
     * 是否显示标题
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({default:true}) protected showTitle?: boolean;
ibizdev's avatar
ibizdev committed
262 263 264 265 266 267 268 269 270
<#--  工具栏模型:BEGIN  -->
<#list view.getAllPSControls() as ctrl>

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

KK's avatar
KK committed
271 272 273 274 275 276 277
    /**
     * 工具栏模型集合名
     *
     * @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
278 279 280 281 282
    /**
     * 解析视图参数
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
283
    protected parseViewParam(): void {
284 285 286
        const { context, param } = this.$viewTool.formatNavigateViewParam(this, ${view.isPSDEView()?c});
        this.context = { ...context };
        this.viewparams = { ...param }
ibizdev's avatar
ibizdev committed
287 288 289 290 291 292 293 294 295 296 297 298
    }
<#--  移动端参数:BEGIN  -->

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

    /**
     * 下拉刷新
     *
     * @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>
    }
323
</#if>
ibizdev's avatar
ibizdev committed
324 325
<#--  视图是否支持下拉刷新:END  -->
<#--  移动端参数:END  -->