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