VIEW_HEADER-BASE.vue.ftl 7.9 KB
Newer Older
ibizdev's avatar
ibizdev committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
<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>

<#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
31
    protected globaluiservice: GlobalUiService = new GlobalUiService();
ibizdev's avatar
ibizdev committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
<#if appde??>

    /**
     * 实体服务对象
     *
     * @type {${srfclassname('${appde.getCodeName()}')}Service}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    protected appEntityService: ${srfclassname('${appde.getCodeName()}')}Service = new ${srfclassname('${appde.getCodeName()}')}Service();
</#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
61
    @Prop() protected _context!: string;
ibizdev's avatar
ibizdev committed
62 63 64 65 66 67 68

    /**
     * 视图参数
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
69
    @Prop() protected _viewparams!: string;
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 90 91 92 93 94 95 96 97 98 99 100 101 102

    /**
     * 视图默认使用
     *
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({ default: true }) protected viewDefaultUsage!: boolean;

	/**
	 * 视图标识
	 *
	 * @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 = {};

103 104 105 106 107 108 109
    /**
     * 视图导航上下文
     *
     * @protected
     * @type {*}
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
110
    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>};
111 112 113 114 115 116 117 118

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

ibizdev's avatar
ibizdev committed
121 122 123 124 125 126 127 128 129 130
    /**
     * 视图模型数据
     *
     * @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
131
        dataInfo: '',
KK's avatar
KK committed
132
    <#if view.getPSSysImage?? && view.getPSSysImage()??>
KK's avatar
KK committed
133 134
        iconcls: '${view.getPSSysImage().getImagePath()}',
        icon: '${view.getPSSysImage().getCssClass()}'
KK's avatar
KK committed
135 136 137 138
    <#else>
        iconcls: '',
        icon: ''
    </#if>
ibizdev's avatar
ibizdev committed
139 140 141 142 143 144 145 146 147 148 149 150
    }

    /**
     * 视图上下文变化
     *
     * @param {string} newVal
     * @param {string} oldVal
     * @memberof  ${srfclassname('${view.name}')}Base
     */
    @Watch('_context')
    on_context(newVal: string, oldVal: string) {
        const _this: any = this;
151
        this.parseViewParam();
ibizdev's avatar
ibizdev committed
152
        if (!Object.is(newVal, oldVal) && _this.engine) {
153
            this.$nextTick(()=>{_this.engine.load();})
ibizdev's avatar
ibizdev committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167
        }
        <#if _context_block??>${_context_block}</#if>
    }

    /**
     * 视图参数变化
     *
     * @param {string} newVal
     * @param {string} oldVal
     * @returns
     * @memberof IBizChart
     */
    @Watch('_viewparams')
    on_viewparams(newVal: string, oldVal: string) {
168
        this.parseViewParam();
ibizdev's avatar
ibizdev committed
169 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 202
    }

    /**
     * 容器模型
     *
     * @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();
203 204 205 206 207 208 209 210 211


    /**
     * 是否显示标题
     *
     * @type {string}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    @Prop({default:true}) protected showTitle?: boolean;
ibizdev's avatar
ibizdev committed
212 213 214 215 216 217 218 219 220 221 222 223 224 225
<#--  工具栏模型:BEGIN  -->
<#list view.getAllPSControls() as ctrl>

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

    /**
     * 解析视图参数
     *
     * @memberof ${srfclassname('${view.name}')}Base
     */
zcdtk's avatar
zcdtk committed
226
    protected parseViewParam(): void {
227 228 229
        const { context, param } = this.$viewTool.formatNavigateViewParam(this, ${view.isPSDEView()?c});
        this.context = { ...context };
        this.viewparams = { ...param }
ibizdev's avatar
ibizdev committed
230 231 232 233 234 235 236 237 238 239 240 241
    }
<#--  移动端参数:BEGIN  -->

    /**
     * 是否显示返回按钮
     *
     * @readonly
     * @type {boolean}
     * @memberof ${srfclassname('${view.name}')}Base
     */
    get isShowBackButton(): boolean {
        // 存在路由,非路由使用,嵌入
KK's avatar
KK committed
242
        if (!this.viewDefaultUsage) {
ibizdev's avatar
ibizdev committed
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
            return false;
        }
        return true;
    }
<#--  视图是否支持下拉刷新:BEGIN  -->
<#if view.isEnablePullDownRefresh?? && view.isEnablePullDownRefresh()>

    /**
     * 下拉刷新
     *
     * @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>
    }
</#if>
<#--  视图是否支持下拉刷新:END  -->
<#--  移动端参数:END  -->