feat: 优化初始化请求

This commit is contained in:
sudoooooo 2024-06-04 16:10:29 +08:00
parent 8a4cad1195
commit be9da7811d

View File

@ -25,7 +25,6 @@
</el-popover>
</template>
<script>
import { getSurveyHistory } from '@/management/api/survey'
import moment from 'moment'
@ -65,10 +64,9 @@ export default {
}
},
watch: {
surveyId: {
immediate: true,
visible: {
async handler(newVal) {
if (newVal) {
if (this.visible && newVal) {
this.fetchHis()
}
}
@ -76,7 +74,7 @@ export default {
currentTab: {
immediate: true,
async handler(newVal) {
if (newVal) {
if (this.visible && newVal) {
this.fetchHis()
}
}
@ -89,26 +87,32 @@ export default {
fetchHis() {
this.paneLoading = true
switch (this.currentTab) {
case 'daily':
getSurveyHistory({
surveyId: this.surveyId,
historyType: 'dailyHis'
}).then((dailyHis) => {
})
.then((dailyHis) => {
this.dailyHis = dailyHis.data || []
})
break;
.finally(() => {
this.paneLoading = false
})
break
case 'publish':
getSurveyHistory({
surveyId: this.surveyId,
historyType: 'publishHis'
}).then((publishHis) => {
})
.then((publishHis) => {
this.publishHis = publishHis.data || []
})
break;
}
.finally(() => {
this.paneLoading = false
})
break
}
}
}
}