refactor: 使用后端统计接口替换前端计算
This commit is contained in:
@@ -61,7 +61,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import {listProject} from '@/api/ccdiProject'
|
import {listProject, getStatusCounts} from '@/api/ccdiProject'
|
||||||
import SearchBar from './components/SearchBar'
|
import SearchBar from './components/SearchBar'
|
||||||
import ProjectTable from './components/ProjectTable'
|
import ProjectTable from './components/ProjectTable'
|
||||||
import QuickEntry from './components/QuickEntry'
|
import QuickEntry from './components/QuickEntry'
|
||||||
@@ -121,28 +121,30 @@ export default {
|
|||||||
/** 查询项目列表 */
|
/** 查询项目列表 */
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
// 使用真实API
|
|
||||||
listProject(this.queryParams).then(response => {
|
// 并行请求列表数据和状态统计
|
||||||
this.projectList = response.rows
|
Promise.all([
|
||||||
this.total = response.total
|
listProject(this.queryParams),
|
||||||
|
getStatusCounts()
|
||||||
|
]).then(([listResponse, countsResponse]) => {
|
||||||
|
// 处理列表数据
|
||||||
|
this.projectList = listResponse.rows
|
||||||
|
this.total = listResponse.total
|
||||||
|
|
||||||
|
// 处理状态统计
|
||||||
|
const counts = countsResponse.data
|
||||||
|
this.tabCounts = {
|
||||||
|
all: counts.all,
|
||||||
|
'0': counts.status0,
|
||||||
|
'1': counts.status1,
|
||||||
|
'2': counts.status2
|
||||||
|
}
|
||||||
|
|
||||||
this.loading = false
|
this.loading = false
|
||||||
// 计算标签页数量
|
|
||||||
this.calculateTabCounts()
|
|
||||||
}).catch(() => {
|
}).catch(() => {
|
||||||
this.loading = false
|
this.loading = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
/** 计算标签页数量 */
|
|
||||||
calculateTabCounts() {
|
|
||||||
// 注意:这里需要后端API返回所有状态的数量统计
|
|
||||||
// 目前暂时使用当前页的数据进行计算
|
|
||||||
this.tabCounts = {
|
|
||||||
all: this.total,
|
|
||||||
'0': this.projectList.filter(p => p.status === '0').length,
|
|
||||||
'1': this.projectList.filter(p => p.status === '1').length,
|
|
||||||
'2': this.projectList.filter(p => p.status === '2').length
|
|
||||||
}
|
|
||||||
},
|
|
||||||
/** 搜索按钮操作 */
|
/** 搜索按钮操作 */
|
||||||
handleQuery(queryParams) {
|
handleQuery(queryParams) {
|
||||||
if (queryParams) {
|
if (queryParams) {
|
||||||
|
|||||||
Reference in New Issue
Block a user