提交 d3a39fd7 编写于 作者: RedPig97's avatar RedPig97

update: 动态表格列优化

上级 4b894675
...@@ -92,6 +92,9 @@ ${ctrl.render.code} ...@@ -92,6 +92,9 @@ ${ctrl.render.code}
</template> </template>
</div> </div>
</poptip> </poptip>
<i-button class="config-button" @click="saveDynaConfig">{{$t('app.gridpage.saveconfig')}}</i-button>
<i-button class="config-button" @click="resetDynaConfig">{{$t('app.gridpage.resetconfig')}}</i-button>
</span>
</span> </span>
<#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??> <#if ctrl.getBatchPSDEToolbar?? && ctrl.getBatchPSDEToolbar()??>
<span v-if="selections.length > 0" class="batch-toolbar"> <span v-if="selections.length > 0" class="batch-toolbar">
...@@ -586,6 +589,14 @@ ${gridColumn.getName()} ...@@ -586,6 +589,14 @@ ${gridColumn.getName()}
</#if> </#if>
] ]
/**
* 重置表格列模型缓存
*
* @type {any[]}
* @memberof MainBase
*/
public resetColModel: any[] = [];
/** /**
* 表格模型集合 * 表格模型集合
* *
...@@ -2134,6 +2145,7 @@ ${gridColumn.getName()} ...@@ -2134,6 +2145,7 @@ ${gridColumn.getName()}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public setColState() { public setColState() {
this.resetColModel = Util.deepCopy(this.allColumns);
const viewParams: any = Util.deepCopy(this.viewparams); const viewParams: any = Util.deepCopy(this.viewparams);
Object.assign(viewParams,{utilServiceName: 'grid_dynaconfig', modelid: '${sys.getCodeName()?lower_case}_${app.getCodeName()?lower_case}_${view.getCodeName()?lower_case}_grid_${ctrl.getCodeName()?lower_case}'}); Object.assign(viewParams,{utilServiceName: 'grid_dynaconfig', modelid: '${sys.getCodeName()?lower_case}_${app.getCodeName()?lower_case}_${view.getCodeName()?lower_case}_grid_${ctrl.getCodeName()?lower_case}'});
const post = this.service.loadModel('grid_dynaconfig', this.context, viewParams); const post = this.service.loadModel('grid_dynaconfig', this.context, viewParams);
...@@ -2178,18 +2190,6 @@ ${gridColumn.getName()} ...@@ -2178,18 +2190,6 @@ ${gridColumn.getName()}
* @memberof ${srfclassname('${ctrl.codeName}')}Base * @memberof ${srfclassname('${ctrl.codeName}')}Base
*/ */
public onColChange() { public onColChange() {
const viewParams: any = Util.deepCopy(this.viewparams);
Object.assign(viewParams,{utilServiceName: 'grid_dynaconfig', modelid: '${sys.getCodeName()?lower_case}_${app.getCodeName()?lower_case}_${view.getCodeName()?lower_case}_grid_${ctrl.getCodeName()?lower_case}', model: this.allColumns});
const post = this.service.saveModel('grid_dynaconfig', this.context, viewParams);
post.then((response: any) => {
if (response.status == 200) {
console.log('保存动态表格列模型成功!');
}
localStorage.setItem('dynaconfig_main_grid', JSON.stringify(this.allColumns));
}).catch(() => {
console.log('保存动态表格列模型失败!');
localStorage.setItem('dynaconfig_main_grid', JSON.stringify(this.allColumns));
});
localStorage.setItem('${ctrl.getPSAppDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}', JSON.stringify(this.allColumns)); localStorage.setItem('${ctrl.getPSAppDataEntity().getName()?lower_case}_${ctrl.getCodeName()?lower_case}_${ctrl.name}', JSON.stringify(this.allColumns));
} }
...@@ -2207,6 +2207,49 @@ ${gridColumn.getName()} ...@@ -2207,6 +2207,49 @@ ${gridColumn.getName()}
return column.show ? true : false; return column.show ? true : false;
} }
/**
* 保存动态表格配置
*
* @memberof MainBase
*/
public saveDynaConfig() {
const viewParams: any = Util.deepCopy(this.viewparams);
Object.assign(viewParams,{utilServiceName: 'grid_dynaconfig', modelid: '${sys.getCodeName()?lower_case}_${app.getCodeName()?lower_case}_${view.getCodeName()?lower_case}_grid_${ctrl.getCodeName()?lower_case}', model: this.allColumns});
const post = this.service.saveModel('grid_dynaconfig', this.context, viewParams);
post.then((response: any) => {
if (response.status == 200) {
this.$Message.success(this.$t('app.gridpage.message.saveconfigsuccess'));
} else {
this.$Message.error(this.$t('app.gridpage.message.saveconfigerror'));
}
}).catch(() => {
this.$Message.error(this.$t('app.gridpage.message.saveconfigerror'));
});
}
/**
* 重置动态表格配置
*
* @memberof MainBase
*/
public resetDynaConfig() {
this.allColumns = Util.deepCopy(this.resetColModel);
const viewParams: any = Util.deepCopy(this.viewparams);
Object.assign(viewParams,{utilServiceName: 'grid_dynaconfig', modelid: '${sys.getCodeName()?lower_case}_${app.getCodeName()?lower_case}_${view.getCodeName()?lower_case}_grid_${ctrl.getCodeName()?lower_case}', model: this.allColumns});
const post = this.service.saveModel('grid_dynaconfig', this.context, viewParams);
post.then((response: any) => {
if (response.status == 200) {
this.$Message.success(this.$t('app.gridpage.message.resetconfigsuccess'));
} else {
this.$Message.success(this.$t('app.gridpage.message.resetconfigerror'));
}
localStorage.setItem('dynaconfig_main_grid', JSON.stringify(this.allColumns));
}).catch(() => {
this.$Message.success(this.$t('app.gridpage.message.resetconfigerror'));
localStorage.setItem('dynaconfig_main_grid', JSON.stringify(this.allColumns));
});
}
/** /**
* 表格列是否自适应布局 * 表格列是否自适应布局
* *
......
...@@ -92,6 +92,9 @@ ...@@ -92,6 +92,9 @@
.page-column { .page-column {
position: absolute; position: absolute;
left: 0; left: 0;
.config-button {
margin-left: 8px;
}
} }
.batch-toolbar{ .batch-toolbar{
position: absolute; position: absolute;
......
...@@ -47,6 +47,8 @@ function getAppLocale(){ ...@@ -47,6 +47,8 @@ function getAppLocale(){
}, },
gridpage: { gridpage: {
choicecolumns: "Choice columns", choicecolumns: "Choice columns",
saveconfig: "Save the current configuration",
resetconfig: "Restoring default Settings",
refresh: "refresh", refresh: "refresh",
show: "Show", show: "Show",
records: "records", records: "records",
...@@ -61,6 +63,12 @@ function getAppLocale(){ ...@@ -61,6 +63,12 @@ function getAppLocale(){
updateAction: "The view table updateaction parameter is not configured", updateAction: "The view table updateaction parameter is not configured",
loaddraftAction: "The view table loadtrafaction parameter is not configured", loaddraftAction: "The view table loadtrafaction parameter is not configured",
}, },
message: {
saveconfigsuccess: "Configuration saved successfully!",
saveconfigerror: "Failed to save configuration!",
resetconfigsuccess: "Reset configuration succeeded!",
resetconfigerror: "Reset configuration failed!",
},
data: "Data", data: "Data",
delDataFail: "Failed to delete data", delDataFail: "Failed to delete data",
delSuccess: "Delete successfully!", delSuccess: "Delete successfully!",
......
...@@ -47,6 +47,8 @@ function getAppLocale(){ ...@@ -47,6 +47,8 @@ function getAppLocale(){
}, },
gridpage: { gridpage: {
choicecolumns: "选择列", choicecolumns: "选择列",
saveconfig: "保存当前配置",
resetconfig: "恢复默认配置",
refresh: "刷新", refresh: "刷新",
show: "显示", show: "显示",
records: "条", records: "条",
...@@ -61,6 +63,12 @@ function getAppLocale(){ ...@@ -61,6 +63,12 @@ function getAppLocale(){
updateAction: "视图表格updateAction参数未配置", updateAction: "视图表格updateAction参数未配置",
loaddraftAction: "视图表格loaddraftAction参数未配置", loaddraftAction: "视图表格loaddraftAction参数未配置",
}, },
message: {
saveconfigsuccess: "保存配置成功!",
saveconfigerror: "保存配置失败!",
resetconfigsuccess: "重置配置成功!",
resetconfigerror: "重置配置失败!",
},
data: "数据", data: "数据",
delDataFail: "删除数据失败", delDataFail: "删除数据失败",
delSuccess: "删除成功!", delSuccess: "删除成功!",
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册