forked from liweijie/education
课表调整小卡片逻辑优化
This commit is contained in:
@@ -360,7 +360,7 @@ export default {
|
|||||||
{ label: '已发回', value: 2 },
|
{ label: '已发回', value: 2 },
|
||||||
{ label: '已拒绝', value: 3 }
|
{ label: '已拒绝', value: 3 }
|
||||||
],
|
],
|
||||||
statCards: [],
|
statCards: this.createStatCards([0, 0, 0, 0]),
|
||||||
// 新增申请
|
// 新增申请
|
||||||
addVisible: false,
|
addVisible: false,
|
||||||
addLoading: false,
|
addLoading: false,
|
||||||
@@ -389,7 +389,10 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.loadYearOptions().then(() => this.loadList())
|
this.loadYearOptions().then(() => {
|
||||||
|
this.loadStatistics()
|
||||||
|
this.loadList()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
/* ---------- 年度下拉(数据来自 /semester/all) ---------- */
|
/* ---------- 年度下拉(数据来自 /semester/all) ---------- */
|
||||||
@@ -450,12 +453,10 @@ export default {
|
|||||||
const data = response.data || {}
|
const data = response.data || {}
|
||||||
this.tableData = data.records || []
|
this.tableData = data.records || []
|
||||||
this.total = data.total || 0
|
this.total = data.total || 0
|
||||||
this.refreshStatCards()
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.tableData = []
|
this.tableData = []
|
||||||
this.total = 0
|
this.total = 0
|
||||||
this.refreshStatCards()
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
@@ -473,18 +474,56 @@ export default {
|
|||||||
}
|
}
|
||||||
this.loadList()
|
this.loadList()
|
||||||
},
|
},
|
||||||
refreshStatCards() {
|
loadStatistics() {
|
||||||
const list = this.tableData
|
const baseParams = {
|
||||||
this.statCards = [
|
nd: this.defaultNd,
|
||||||
{ title: '本页申请', value: list.length, gradient: 'linear-gradient(135deg, #00875a 0%, #00b877 100%)', filter: undefined },
|
pageNum: 1,
|
||||||
{ title: '教研室待审批', value: list.filter(i => i.jyspzzt === 0).length, gradient: 'linear-gradient(135deg, #e6a23c 0%, #f8b04c 100%)', filter: 0 },
|
pageSize: 1
|
||||||
{ title: '教研室已同意', value: list.filter(i => i.jyspzzt === 1).length, gradient: 'linear-gradient(135deg, #409eff 0%, #66b1ff 100%)', filter: 1 },
|
}
|
||||||
{ title: '教研室已拒绝', value: list.filter(i => i.jyspzzt === 3).length, gradient: 'linear-gradient(135deg, #f56c6c 0%, #f78989 100%)', filter: 3 }
|
const statusFilters = [undefined, 0, 1, 3]
|
||||||
|
const requests = statusFilters.map(status => {
|
||||||
|
const params = Object.assign({}, baseParams)
|
||||||
|
if (status !== undefined) {
|
||||||
|
params.jyspzzt = status
|
||||||
|
}
|
||||||
|
return listScheduleAdjust(params)
|
||||||
|
.then(response => Number((response.data && response.data.total) || 0))
|
||||||
|
.catch(() => 0)
|
||||||
|
})
|
||||||
|
return Promise.all(requests).then(counts => {
|
||||||
|
this.statCards = this.createStatCards(counts)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
createStatCards(counts) {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
title: '本页申请',
|
||||||
|
value: counts[0],
|
||||||
|
gradient: 'linear-gradient(135deg, #00875a 0%, #00b877 100%)',
|
||||||
|
filter: undefined
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '教研室待审批',
|
||||||
|
value: counts[1],
|
||||||
|
gradient: 'linear-gradient(135deg, #e6a23c 0%, #f8b04c 100%)',
|
||||||
|
filter: 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '教研室已同意',
|
||||||
|
value: counts[2],
|
||||||
|
gradient: 'linear-gradient(135deg, #409eff 0%, #66b1ff 100%)',
|
||||||
|
filter: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '教研室已拒绝',
|
||||||
|
value: counts[3],
|
||||||
|
gradient: 'linear-gradient(135deg, #f56c6c 0%, #f78989 100%)',
|
||||||
|
filter: 3
|
||||||
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
handleStatClick(card) {
|
handleStatClick(card) {
|
||||||
if (card.filter === undefined) return
|
this.queryParams.jyspzzt = card.filter
|
||||||
this.queryParams.jyspzzt = this.queryParams.jyspzzt === card.filter ? undefined : card.filter
|
|
||||||
this.handleQuery()
|
this.handleQuery()
|
||||||
},
|
},
|
||||||
/* ---------- 新增申请 ---------- */
|
/* ---------- 新增申请 ---------- */
|
||||||
|
|||||||
Reference in New Issue
Block a user