fix : 修复多次调用接口及其它问题

This commit is contained in:
zhangxiaolong
2022-04-11 16:01:36 +08:00
parent 1ab110ad20
commit d2e47d836d
3 changed files with 85 additions and 98 deletions

View File

@@ -316,6 +316,7 @@ export default {
}
this.editBackup.nums = nums;
} else if (this.editBackup.type == 4) {
const nums = [];
this.editBackup.nums = [];
this.editBackup.checkDays.forEach((e, i) => {
@@ -441,15 +442,17 @@ export default {
this.checkDay = [];
if (this.editBackup.type == 3) {
this.editBackup.nums.forEach((e) => {
checkdays.push(e - 1);
if (e === -1) {
if (e == -1 ) {
checkdays.push(6);
}else{
checkdays.push(e - 1);
}
});
this.$set(this.editBackup, "checkDay", checkdays);
} else if (this.editBackup.type == 4) {
this.editBackup.nums.forEach((e) => {
if (e === -1) {
if (e == -1) {
checkdays.push(31);
} else {
checkdays.push(e - 1);
@@ -474,23 +477,6 @@ export default {
}
},
},
"editBackup.checkDay": {
deep: true,
handler(n) {
n.forEach((e, i) => {
if (e === 6) {
this.editBackup.checkDay[i] = -1;
}
});
const nums = [];
this.editBackup.nums = [];
this.editBackup.checkDay.forEach((e, i) => {
nums.push(Number(i) + 1);
});
this.editBackup.nums = nums;
},
},
"editBackup.datepicker": {
deep: true,
handler(n) {

View File

@@ -65,7 +65,7 @@
</template>
<script>
import { get, post ,put} from '@/http'
import { post ,put} from '@/http'
import lodash from 'lodash'
import bus from '@/libs/bus'
@@ -78,29 +78,31 @@ export default {
loading: Boolean,
customTableTitle: Array,
isConfigurations: Boolean,
tableData: Array,
tableData2: Array,
},
data () {
return {
tableData: [
{
retention: '',
state: '',
schedule: {
repeat: '',
stime: '',
type: '',
nums: []
}
}
],
tableData2: [
{
fileName: '',
time: '',
size: ''
}
]
// tableData: [
// {
// retention: '',
// state: '',
// schedule: {
// repeat: '',
// stime: '',
// type: '',
// nums: []
// }
// }
// ],
// tableData2: [
// {
// fileName: '',
// time: '',
// size: ''
// }
// ]
}
},
@@ -108,17 +110,13 @@ export default {
computed: {},
created () {},
mounted () {
this.getTableData()
},
methods: {
Restore(row){
put('/sys/backup/restore',{filename:row.fileName}).then(res=>{
if(res.code == 200){
this.getTableData('backup')
this.$emit('getTableData','backup')
}
})
},
@@ -133,57 +131,9 @@ export default {
getNum(item){
return bus.getNumStr(item)
},
async getTableData (item) {
if(!item){
await get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1? true :false
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
}
}
})
await post('/sys/backup/list').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
}else if(item == 'backup'){
get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1? true :false
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
}
}
})
this.$forceUpdate();
}else if(item == 'recent'){
post('/sys/backup/list').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
this.$forceUpdate();
}
},
backupNow (item) {
post('/sys/backup').then((res) => {
console.log(res)
// console.log(res)
})
},
edit () {

View File

@@ -15,6 +15,7 @@
:custom-table-title="customTableTitle"
:is-configurations="true"
@edit="edit"
:table-data="tableData"
>
</backups-table>
</template>
@@ -35,6 +36,9 @@
ref="backupsTable2"
:custom-table-title="customTableTitle2"
:is-configurations="false"
key="backups2"
:table-data2="tableData2"
>
</backups-table>
</template>
@@ -60,7 +64,7 @@ export default {
url: '/sys/backup/list',
customTableTitle: [
{ label: this.$t('backup.frequency'), prop: 'repeat' },
{ label: this.$t('backup.schedule'), prop: 'repeat' },
{ label: this.$t('backup.backupRetention'), prop: 'retention' },
{ label: this.$t('backup.last'), prop: 'last' },
{ label: this.$t('backup.Enable'), prop: 'state' }
@@ -96,9 +100,56 @@ export default {
created () {},
mounted () {},
mounted () {
this.getTableData()
},
methods: {
getTableData (item) {
if(!item){
this.$get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1? true :false
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
}
}
})
this.$post('/sys/backup/list').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
}else if(item == 'backup'){
this.$get('/sys/backup').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData[0].retention = res.data.retention
this.tableData[0].state = res.data.state == 1? true :false
for (const i in res.data.schedule) {
this.tableData[0].schedule[i] = res.data.schedule[i]
}
}
}
})
}else if(item == 'recent'){
this.$post('/sys/backup/list').then((res) => {
if (res.code === 200) {
if (res.data) {
this.tableData2 = res.data
}
}
})
}
},
edit (row) {
this.object = { ...row ,
checkDay:'',
@@ -115,7 +166,7 @@ export default {
},
closeRightBox (refresh) {
if (refresh) {
this.$refs.backupsTable1.getTableData('backup')
this.getTableData('backup')
}
this.rightBoxshow = false
},