mirror of
https://github.com/moshowgame/SpringBootCodeGenerator.git
synced 2025-12-26 05:48:33 +08:00
support switching historical data
This commit is contained in:
parent
004404ff27
commit
c2edc160b8
@ -60,6 +60,7 @@ const vm = new Vue({
|
||||
}
|
||||
},
|
||||
templates:[{}],
|
||||
historicalData:[],
|
||||
outputStr: "xxx",
|
||||
outputJson: {}
|
||||
},
|
||||
@ -73,6 +74,23 @@ const vm = new Vue({
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
},
|
||||
//switch HistoricalData
|
||||
switchHistoricalData: function (event) {
|
||||
const tableName = event.target.innerText.trim();
|
||||
console.log(tableName);
|
||||
if (window.sessionStorage){
|
||||
const valueSession = sessionStorage.getItem(tableName);
|
||||
vm.outputJson = JSON.parse(valueSession);
|
||||
console.log(valueSession);
|
||||
alert("切换历史记录成功:"+tableName);
|
||||
}else{
|
||||
alert("浏览器不支持sessionStorage");
|
||||
}
|
||||
vm.outputStr=vm.outputJson["plusentity"];
|
||||
$.outputArea.setValue(vm.outputStr);
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
},
|
||||
//request with formData to generate the code 根据参数生成代码
|
||||
generate : function(){
|
||||
//get value from codemirror
|
||||
@ -86,6 +104,25 @@ const vm = new Vue({
|
||||
//console.log(vm.outputStr);
|
||||
$.outputArea.setValue(vm.outputStr);
|
||||
$.outputArea.setSize('auto', 'auto');
|
||||
//add to historicalData
|
||||
const tableName = res.outputJson.tableName;
|
||||
//add new table only
|
||||
if(vm.historicalData.indexOf(tableName)<0){
|
||||
vm.historicalData.unshift(tableName);
|
||||
}
|
||||
//remove last record , if more than N
|
||||
if(vm.historicalData.length>9){
|
||||
vm.historicalData.splice(9,1);
|
||||
}
|
||||
//get and set to session data
|
||||
const valueSession = sessionStorage.getItem(tableName);
|
||||
//remove if exists
|
||||
if(valueSession!==undefined && valueSession!=null){
|
||||
sessionStorage.removeItem(tableName);
|
||||
}
|
||||
//set data to session
|
||||
sessionStorage.setItem(tableName,JSON.stringify(vm.outputJson));
|
||||
//console.log(vm.historicalData);
|
||||
});
|
||||
},
|
||||
copy : function (){
|
||||
@ -99,7 +136,7 @@ const vm = new Vue({
|
||||
}).then(function(res){
|
||||
//console.log(res.templates);
|
||||
vm.templates = JSON.parse(res.templates);
|
||||
console.log(vm.templates);
|
||||
// console.log(vm.templates);
|
||||
});
|
||||
},
|
||||
updated: function () {
|
||||
|
||||
@ -9,6 +9,9 @@
|
||||
/*.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{
|
||||
line-height : 10px;
|
||||
}*/
|
||||
.el-button-group-top {
|
||||
padding-top: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
@ -95,6 +98,14 @@
|
||||
<!--generate button-->
|
||||
<el-button type="primary" icon="el-icon-caret-right" @click="generate">生成</el-button>
|
||||
<el-button type="primary" icon="el-icon-document-copy" @click="copy" plain>复制</el-button>
|
||||
<span v-if="historicalData.length>0" >
|
||||
<el-button-group>
|
||||
<el-button type="primary" plain disabled round>历史记录</el-button>
|
||||
<span v-for="(item, index) in historicalData" :key="index">
|
||||
<el-button @click="switchHistoricalData" >{{item}}</el-button>
|
||||
</span>
|
||||
</el-button-group>
|
||||
</span>
|
||||
<hr>
|
||||
<!--templates area-->
|
||||
<el-form ref="form" :inline="true" :model="formData" label-width="100px" size="mini">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user