|
@@ -2,10 +2,14 @@
|
|
|
<BodyPanlHeader>
|
|
|
<div class="project-detail-body">
|
|
|
<a-radio-group v-model:value="type">
|
|
|
- <a-badge :count="Object.values(totals).reduce((t,c) => t + c,0)">
|
|
|
+ <a-badge :count="Object.values(totals).reduce((t, c) => t + c, 0)">
|
|
|
<a-radio-button value="all">所有</a-radio-button>
|
|
|
</a-badge>
|
|
|
- <a-badge v-for="option in types" :count="totals[option]">
|
|
|
+ <a-badge
|
|
|
+ v-for="(option, key) in types"
|
|
|
+ :key="key"
|
|
|
+ :count="totals[option]"
|
|
|
+ >
|
|
|
<a-radio-button :key="option" :value="option as any">
|
|
|
{{ TaggingStatusDesc[option] }}
|
|
|
</a-radio-button>
|
|
@@ -24,6 +28,7 @@
|
|
|
|
|
|
<BodyPanlBody>
|
|
|
<a-table
|
|
|
+ :scroll="{ x: '100%', y: 350 }"
|
|
|
:columns="materialColumns"
|
|
|
:data-source="materials"
|
|
|
:pagination="pagination"
|
|
@@ -31,7 +36,11 @@
|
|
|
<template #bodyCell="{ column, record }">
|
|
|
<template v-if="column.key === 'action'">
|
|
|
<div class="table-actions">
|
|
|
- <a target="_blank" :href="`smart-viewer.html?projectId=${record.projectId}&m=${record.num}`">查看</a>
|
|
|
+ <a
|
|
|
+ :href="`smart-viewer.html?projectId=${record.projectId}&m=${record.num}`"
|
|
|
+ target="_blank"
|
|
|
+ >查看</a
|
|
|
+ >
|
|
|
</div>
|
|
|
</template>
|
|
|
</template>
|
|
@@ -40,64 +49,79 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import { computed, onActivated, onDeactivated, reactive, ref, watch } from "vue";
|
|
|
-import { BodyPanlBody, BodyPanlHeader } from "@/layout/panl";
|
|
|
-import { useRealtime } from "@/hook";
|
|
|
-import { router } from "@/router";
|
|
|
-import { taggingColumns as baseColumns } from "./columns";
|
|
|
-import type { FetchTaggingsProps } from "@/api";
|
|
|
-import { fetchTaggings, TaggingStatus, TaggingStatusDesc } from "@/api";
|
|
|
+import {
|
|
|
+ computed,
|
|
|
+ onActivated,
|
|
|
+ onDeactivated,
|
|
|
+ reactive,
|
|
|
+ ref,
|
|
|
+ watch,
|
|
|
+ watchEffect
|
|
|
+} from 'vue'
|
|
|
+import { BodyPanlBody, BodyPanlHeader } from '@/layout/panl'
|
|
|
+import { useRealtime } from '@/hook'
|
|
|
+import { router } from '@/router'
|
|
|
+import { taggingColumns as baseColumns } from './columns'
|
|
|
+import type { FetchTaggingsProps } from '@/api'
|
|
|
+import {
|
|
|
+ fetchTaggings,
|
|
|
+ fetchTaggingsTotal,
|
|
|
+ TaggingStatus,
|
|
|
+ TaggingStatusDesc
|
|
|
+} from '@/api'
|
|
|
|
|
|
const materialColumns = [
|
|
|
...baseColumns,
|
|
|
{
|
|
|
- title: "操作",
|
|
|
- dataIndex: "action",
|
|
|
- key: "action"
|
|
|
+ title: '操作',
|
|
|
+ dataIndex: 'action',
|
|
|
+ key: 'action'
|
|
|
}
|
|
|
-];
|
|
|
+]
|
|
|
|
|
|
const types = [
|
|
|
TaggingStatus.pending,
|
|
|
TaggingStatus.progress,
|
|
|
TaggingStatus.unsolved,
|
|
|
TaggingStatus.solved
|
|
|
-];
|
|
|
-const type = ref<TaggingStatus | "all">("all");
|
|
|
-const filterName = ref("");
|
|
|
-const projectId = computed(() => Number(router.currentRoute.value.params.id));
|
|
|
+]
|
|
|
+const type = ref<TaggingStatus | 'all'>('all')
|
|
|
+const filterName = ref('')
|
|
|
+const projectId = computed(() => Number(router.currentRoute.value.params.id))
|
|
|
const pagination = reactive({
|
|
|
current: 1,
|
|
|
total: 0,
|
|
|
pageSize: 10,
|
|
|
onChange: (current: number) => {
|
|
|
- pagination.current = current;
|
|
|
- updateMaterials();
|
|
|
+ pagination.current = current
|
|
|
+ updateMaterials()
|
|
|
}
|
|
|
-});
|
|
|
+})
|
|
|
+watch(filterName, () => (pagination.current = 1), { flush: 'sync' })
|
|
|
|
|
|
const totals = ref({
|
|
|
[TaggingStatus.pending]: 0,
|
|
|
[TaggingStatus.progress]: 0,
|
|
|
[TaggingStatus.unsolved]: 0,
|
|
|
[TaggingStatus.solved]: 0
|
|
|
-});
|
|
|
+})
|
|
|
+watch(projectId, () => {
|
|
|
+ totals.value = {
|
|
|
+ [TaggingStatus.pending]: 0,
|
|
|
+ [TaggingStatus.progress]: 0,
|
|
|
+ [TaggingStatus.unsolved]: 0,
|
|
|
+ [TaggingStatus.solved]: 0
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+onDeactivated(() => {
|
|
|
+ filterName.value = ''
|
|
|
+})
|
|
|
|
|
|
let interval: number
|
|
|
onActivated(() => {
|
|
|
- interval = setInterval(() => {
|
|
|
- types.forEach(async type => {
|
|
|
- const params = {
|
|
|
- pageNum: 1,
|
|
|
- pageSize: 1,
|
|
|
- markingStatus: type,
|
|
|
- markingTitle: "",
|
|
|
- projectId: projectId.value
|
|
|
- };
|
|
|
- const result = await fetchTaggings(params);
|
|
|
- totals.value[type] = result.total;
|
|
|
- console.log(totals);
|
|
|
- });
|
|
|
+ interval = setInterval(async () => {
|
|
|
+ totals.value = await fetchTaggingsTotal(projectId.value)
|
|
|
}, 1000)
|
|
|
})
|
|
|
onDeactivated(() => {
|
|
@@ -110,19 +134,19 @@ const [materials, updateMaterials] = useRealtime(async () => {
|
|
|
projectId: projectId.value,
|
|
|
pageNum: pagination.current,
|
|
|
pageSize: pagination.pageSize
|
|
|
- };
|
|
|
- if (type.value !== "all") {
|
|
|
- params.markingStatus = type.value;
|
|
|
}
|
|
|
- const result = await fetchTaggings(params);
|
|
|
- pagination.total = result.total;
|
|
|
- if (type.value !== "all") {
|
|
|
- totals.value[type.value] = result.total;
|
|
|
+ if (type.value !== 'all') {
|
|
|
+ params.markingStatus = type.value
|
|
|
+ }
|
|
|
+ const result = await fetchTaggings(params)
|
|
|
+ pagination.total = result.total
|
|
|
+ if (type.value !== 'all') {
|
|
|
+ totals.value[type.value] = result.total
|
|
|
}
|
|
|
- return result.list;
|
|
|
-}, []);
|
|
|
+ return result.list
|
|
|
+}, [])
|
|
|
|
|
|
-watch(() => type.value + filterName.value, updateMaterials);
|
|
|
+watch(() => type.value + filterName.value, updateMaterials)
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss">
|
|
@@ -131,7 +155,7 @@ watch(() => type.value + filterName.value, updateMaterials);
|
|
|
}
|
|
|
|
|
|
.project-detail-body
|
|
|
-.ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
|
|
|
+ .ant-radio-button-wrapper-checked:not(.ant-radio-button-wrapper-disabled) {
|
|
|
z-index: auto;
|
|
|
border-left: 1px solid #2997ff !important;
|
|
|
margin-left: -1px;
|