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

View File

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

View File

@@ -15,6 +15,7 @@
:custom-table-title="customTableTitle" :custom-table-title="customTableTitle"
:is-configurations="true" :is-configurations="true"
@edit="edit" @edit="edit"
:table-data="tableData"
> >
</backups-table> </backups-table>
</template> </template>
@@ -35,6 +36,9 @@
ref="backupsTable2" ref="backupsTable2"
:custom-table-title="customTableTitle2" :custom-table-title="customTableTitle2"
:is-configurations="false" :is-configurations="false"
key="backups2"
:table-data2="tableData2"
> >
</backups-table> </backups-table>
</template> </template>
@@ -60,7 +64,7 @@ export default {
url: '/sys/backup/list', url: '/sys/backup/list',
customTableTitle: [ 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.backupRetention'), prop: 'retention' },
{ label: this.$t('backup.last'), prop: 'last' }, { label: this.$t('backup.last'), prop: 'last' },
{ label: this.$t('backup.Enable'), prop: 'state' } { label: this.$t('backup.Enable'), prop: 'state' }
@@ -96,9 +100,56 @@ export default {
created () {}, created () {},
mounted () {}, mounted () {
this.getTableData()
},
methods: { 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) { edit (row) {
this.object = { ...row , this.object = { ...row ,
checkDay:'', checkDay:'',
@@ -115,7 +166,7 @@ export default {
}, },
closeRightBox (refresh) { closeRightBox (refresh) {
if (refresh) { if (refresh) {
this.$refs.backupsTable1.getTableData('backup') this.getTableData('backup')
} }
this.rightBoxshow = false this.rightBoxshow = false
}, },