<#ibizinclude> ../../@MACRO/LANG_FUN.ftl </#ibizinclude> <#ibizinclude> ../@MACRO/CONTROL/LANGBASE.vue.ftl </#ibizinclude> <template> <#if ctrl.render??> ${ctrl.render.code} <#else> <div class="app-gantt"> <gantt-elastic v-if="tasks.length >0" :class="ganttClass<#if ctrl.getPSSysCss?? && ctrl.getPSSysCss()??><#assign singleCss = ctrl.getPSSysCss()> ${singleCss.getCssName()}</#if>" :tasks="tasks" :options="getOptions(this.locale)" :dynamic-style="dynamicStyle" @taskList-item-dblclick="taskClick" @task-item-expand="taskItemExpand"> </gantt-elastic> <div v-else class="app-data-empty">{{$t('<#if langbase??>${langbase}.nodata</#if>')}}</div> </div> </#if> </template> <#assign import_block> import GanttElastic from "ibiz-gantt-elastic/src/GanttElastic.vue"; </#assign> <#assign component_block> GanttElastic, </#assign> <#ibizinclude> ../@MACRO/CONTROL/CONTROL_HEADER-BASE.vue.ftl </#ibizinclude> /** * 显示处理提示 * * @type {boolean} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ @Prop({ default: true }) public showBusyIndicator?: boolean; /** * 部件行为--load * * @type {string} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ @Prop() public loadAction!: string; /** * 部件样式名 * * @public * @type {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public ganttClass: string = "gantt"; /** * 语言 * * @public * @type {string} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public locale: string = 'zh-CN'; /** * 语言资源 * * @public * @type {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public localeZH: any = { weekdays: ['星期一','星期二','星期三','星期四','星期五','星期六','星期日'], months: ['一月', '二月', '三月', '四月', '五月', '六月', '七月', '八月', '九月', '十月', '十一月', '十二月'], Now: "现在", "X-Scale": "时间颗粒度", "Display task list": "显示列表", "Before/After": "数据范围" } /** * 配置参数 * * @public * @type {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public options: any = { isflex: true, maxRows: 1000, dataType: 'treegrid', title: { label: "" }, header: { yScole: false, taskListWidth: false, }, calendar: { hour: { display: false } }, chart: { progress: { bar: false }, expander: { display: true }, }, taskList: { expander: { straight: false }, labelField: 'text', columns: [ <#if ctrl.getPSDETreeColumns()??> <#list ctrl.getPSDETreeColumns() as column> { label: '${column.getCaption()}', value: '<#if column.getName() == "begin">start<#else>${column.getName()}</#if>', render: (task: any) => { <#if column.render??> ${column.render.code} <#else> return this.getColumnValue(task, '<#if column.getName() == "begin">start<#else>${column.getName()}</#if>') </#if> }, <#if column.getName() == "text"> expander: true, </#if> width: <#if column.getWidth() gt 0>${column.getWidth()}<#else>100</#if>, <#if column.isHideDefault()> hidden: true, </#if> <#if column.getHeaderPSSysCss()??> headerCls: '${column.getHeaderPSSysCss().getCssName()}', </#if> <#if column.getCellPSSysCss()??> cellCls: '${column.getCellPSSysCss().getCssName()}', </#if> }, </#list> </#if> ] } }; /** * 样式 * * @public * @type {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public dynamicStyle: any = {}; /** * 日程事件集合 * * @public * @type {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public tasks: any[] = []; /** * 应用状态事件 * * @public * @type {(Subscription | undefined)} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public appStateEvent: Subscription | undefined; /** * 监听语言变化 * * @public * @memberof ${srfclassname('${ctrl.codeName}')}Base */ @Watch('$i18n.locale') public onLocaleChange(newval: any, val: any) { this.locale = newval; } /** * 获取列属性值 * * @public * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public getColumnValue(task: any, field: string) { <#if ctrl.getPSDETreeNodes()??> <#list ctrl.getPSDETreeNodes() as node> if(Object.is(task.id.split(';')[0], '${srfjavastring(node.getNodeType())}')) { <#if node.getPSDETreeNodeDataItems()??> <#list node.getPSDETreeNodeDataItems() as dataItem> <#if dataItem.getFrontPSCodeList()??> <#assign codelist = dataItem.getFrontPSCodeList()/> if (Object.is(field, '${dataItem.name}')) { let codelist: any[] = this.$store.getters.getCodeList('${codelist.getCodeName()}'); if(codelist) { return this.getCodeListItem(codelist, task[field]); } } </#if> </#list> </#if> return task[field]; } </#list> </#if> } /** * 获取代码项 * * @public * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public getCodeListItem(codelist: any, val: any) { for(let i = 0; i < codelist.items.length; i++) { if(Object.is(codelist.items[i].value, val)) { return codelist.items[i].text; } } return codelist.emptytext; } /** * 获取部件参数 * * @returns {any} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public getOptions() { if(Object.is(this.locale, 'zh-CN')) { return { locale: this.localeZH, ...this.options }; } return this.options; } /** * 搜索获取日程事件 * * @param {*} $event 日期信息 * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public load(task: any = {}) { const params: any = { srfnodeid: task && task.id ? task.id : "#", srfnodefilter: '' }; let tempViewParams:any = JSON.parse(JSON.stringify(this.viewparams)); let curNode:any = {}; Util.deepObjectMerge(curNode, task); let tempContext:any = this.computecurNodeContext(curNode); if(curNode && curNode.srfparentdename) { Object.assign(tempContext,{ srfparentdename: curNode.srfparentdename }); Object.assign(tempViewParams,{ srfparentdename: curNode.srfparentdename }); } if(curNode && curNode.srfparentkey) { Object.assign(tempContext,{ srfparentkey: curNode.srfparentkey }); Object.assign(tempViewParams,{ srfparentkey: curNode.srfparentkey }); } Object.assign(params,{viewparams:tempViewParams}); this.service.getNodes(tempContext,params).then((response: any) => { if (!response || response.status !== 200) { this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info }); return; } this.tasks = [...this.tasks, ...response.data]; response.data.forEach((item: any) => { if(!item.collapsed) { this.load(item); } }) this.$emit("load", this.tasks); }).catch((response: any) => { if (response && response.status === 401) { return; } this.$Notice.error({ title: (this.$t('app.commonWords.wrong') as string), desc: response.info }); }); } /** * 计算当前节点的上下文 * * @param {*} curNode 当前节点 * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public computecurNodeContext(curNode:any){ let tempContext:any = {}; if(curNode && curNode.data && curNode.data.srfappctx){ tempContext = JSON.parse(JSON.stringify(curNode.data.srfappctx)); }else{ tempContext = JSON.parse(JSON.stringify(this.context)); } return tempContext; } /** * 节点展开 * * @param {*} task 当前节点 * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public taskItemExpand(task: any) { if(!task.collapsed) { let index: number = this.tasks.findIndex((item: any) => Object.is(task.id, item.parentId)); if(index < 0) { this.load(task); } } } /** * 刷新 * * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public refresh(args?: any) { this.load(); } /** * 选中的数据 * * @returns {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public selections: any[] = []; /** * 获取多项数据 * * @returns {any[]} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public getDatas(): any[] { return this.selections; } /** * 获取单项树 * * @returns {*} * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public getData(): any { return null; } /** * vue 生命周期 * * @returns * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public created() { this.afterCreated(); } /** * 执行created后的逻辑 * * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public afterCreated() { this.locale = this.$i18n.locale; if(AppCenterService && AppCenterService.getMessageCenter()){ this.appStateEvent = AppCenterService.getMessageCenter().subscribe(({ name, action, data }) =>{ if(!Object.is(name,"${ctrl.getPSAppDataEntity().getCodeName()}")){ return; } if(Object.is(action,'appRefresh')){ this.refresh(); } }) } this.viewStateEvent = this.viewState.subscribe(({ tag, action, data }) => { if (!Object.is(tag, this.name)) { return; } if (Object.is('load', action)) { this.load(data); } }); } /** * 点击事件 * * @returns * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public taskClick({event, data}: {event: any, data: any}) { const _this: any = this; let key: string = data.id.split(';')[0]; if(_this[key + '_opendata'] instanceof Function) { _this[key + '_opendata']([data]); } } /** * vue 生命周期 * * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public destroyed() { this.afterDestroy(); } /** * 执行destroyed后的逻辑 * * @memberof ${srfclassname('${ctrl.codeName}')}Base */ public afterDestroy() { if(this.appStateEvent){ this.appStateEvent.unsubscribe(); } if(this.viewStateEvent){ this.viewStateEvent.unsubscribe(); } <#if destroyed_block??> ${destroyed_block} </#if> } <#ibizinclude> ../@MACRO/CONTROL/CONTROL_BOTTOM-BASE.vue.ftl </#ibizinclude> <#ibizinclude> ../@MACRO/CONTROL/CONTROL-BASE.style.ftl </#ibizinclude>