Explorar el Código

fix: 修改需求定制

bill hace 2 años
padre
commit
b58dff8c60

+ 2 - 0
src/api/constant.ts

@@ -52,6 +52,8 @@ export const UPDATE_MEBER = '/smart-site/projectTeam/updateUser'
 
 // 标注
 export const GET_TAGGING_LIST = '/smart-site/marking/list'
+// 标注总览
+export const GET_TAGGING_TOTAL = '/smart-site/marking/count'
 
 // 角色
 export const GET_ROLE_LIST = '/smart-site/role/list'

+ 9 - 3
src/api/instance.ts

@@ -1,7 +1,13 @@
 import { axiosFactory } from './setup'
 import { message } from 'ant-design-vue'
 import { showLoading, hideLoading } from '@/components/loading'
-import { ResCode, ResCodeDesc, POST_LOGIN, GET_PROJECT } from './constant'
+import {
+  ResCode,
+  ResCodeDesc,
+  POST_LOGIN,
+  GET_PROJECT,
+  GET_TAGGING_TOTAL
+} from './constant'
 import { baseURL } from '@/env'
 import { router, RoutesName } from '@/router'
 
@@ -53,12 +59,12 @@ addResErrorHandler((response, data) => {
 
 addHook({
   before: config => {
-    if (config?.url !== GET_PROJECT) {
+    if (![GET_TAGGING_TOTAL, GET_PROJECT].includes(config?.url as any)) {
       showLoading()
     }
   },
   after: config => {
-    if (config?.url !== GET_PROJECT) {
+    if (![GET_TAGGING_TOTAL, GET_PROJECT].includes(config?.url as any)) {
       hideLoading()
     }
   }

+ 4 - 2
src/api/role.ts

@@ -38,8 +38,10 @@ export const fetchRoles = (
   >
 ) => axios.post<PageResult<Role>>(GET_ROLE_LIST, params)
 
-export const deleteRole = (roleId: Role['roleId'], projectId: Project['projectId']) =>
-  axios.post(DEL_ROLE, { roleId, projectId })
+export const deleteRole = (
+  roleId: Role['roleId'],
+  projectId: Project['projectId']
+) => axios.post(DEL_ROLE, { roleId, projectId })
 
 export const addRole = (
   projectId: Project['projectId'],

+ 24 - 1
src/api/tagging.ts

@@ -1,5 +1,5 @@
 import axios from './instance'
-import { GET_TAGGING_LIST } from './constant'
+import { GET_TAGGING_LIST, GET_TAGGING_TOTAL } from './constant'
 import type { PageResult, PageRequest, Project } from './'
 
 export enum TaggingStatus {
@@ -36,3 +36,26 @@ export type FetchTaggingsProps = PageRequest<{
 }>
 export const fetchTaggings = (params: FetchTaggingsProps) =>
   axios.post<PageResult<Tagging>>(GET_TAGGING_LIST, params)
+
+export type FetchTaggingsTotalResult = {
+  count: number
+  markingStatus: TaggingStatus
+}[]
+
+export const fetchTaggingsTotal = async (id: Project['projectId']) => {
+  const data = await axios.post<FetchTaggingsTotalResult>(GET_TAGGING_TOTAL, {
+    projectId: id
+  })
+  const totals: { [key in TaggingStatus]: number } = {
+    [TaggingStatus.pending]: 0,
+    [TaggingStatus.progress]: 0,
+    [TaggingStatus.solved]: 0,
+    [TaggingStatus.unsolved]: 0
+  }
+  data.forEach(item => {
+    if (item.markingStatus) {
+      totals[item.markingStatus] = item.count
+    }
+  })
+  return totals
+}

+ 1 - 0
src/style.scss

@@ -41,3 +41,4 @@ body .ant-dropdown {
 .warn {
   color: #FA5555 !important;
 }
+

+ 3 - 3
src/views/member/edit.vue

@@ -43,7 +43,7 @@
         label="成员名称"
         :rules="[
           { required: true, message: '请输入成员名称' },
-          { max: 50, message: '成员名称最多50字' },
+          { max: 50, message: '成员名称最多50字' }
         ]"
       >
         <a-input
@@ -67,7 +67,7 @@
       <a-form-item name="bindAccount" label="绑定手机号" :rules="[phoneRule]">
         <a-input
           v-model:value="editMember.bindAccount"
-          placeholder="请输入当前用户绑定的手机号"
+          placeholder="请输入用户手机号"
         />
       </a-form-item>
       <a-form-item
@@ -79,7 +79,7 @@
           v-model:value.trim="editMember.remark"
           :resize="false"
           style="height: 104px; resize: none"
-          placeholder="请输入备注,最多50字"
+          placeholder="请输入备注,最多200字"
         />
       </a-form-item>
     </a-form>

+ 7 - 2
src/views/member/list.vue

@@ -17,6 +17,7 @@
       :data-source="list"
       :columns="memberColumns"
       :pagination="pagination"
+      :scroll="{ x: '100%', y: 350 }"
     >
       <template #bodyCell="{ column, record }">
         <template v-if="column.key === 'action'">
@@ -33,7 +34,7 @@
 
 <script lang="ts" setup>
 import EditMember from './edit.vue'
-import { computed, reactive } from 'vue'
+import { computed, reactive, watch } from 'vue'
 import { BodyPanlHeader, BodyPanlBody } from '@/layout/panl'
 import { usePaging } from '@/hook'
 import { router } from '@/router'
@@ -65,7 +66,11 @@ const params = reactive({
 })
 
 const { list, pagination, updateList } = usePaging(fetchMembers, params)
-
+watch(
+  () => params.userName,
+  () => (pagination.current = 1),
+  { flush: 'sync' }
+)
 const setMember = (member?: Member) => {
   renderModal(EditMember, {
     member: member && {

+ 5 - 1
src/views/project/list.vue

@@ -73,7 +73,7 @@
 import InsertProject from './edit.vue'
 import { HeadPanl, BodyPanl } from '@/layout/panl'
 import { projectColumns } from './columns'
-import { computed, reactive, ref } from 'vue'
+import { computed, reactive, ref, watch } from 'vue'
 import { usePaging } from '@/hook'
 import { renderModal } from '@/helper'
 import { useProject, useUserStore } from '@/store'
@@ -124,6 +124,10 @@ const { list, pagination, updateList } = usePaging(
     auto: false
   }
 )
+watch(filterState, () => (pagination.current = 1), {
+  deep: true,
+  flush: 'sync'
+})
 
 const filterFromRef = ref<FormInstance>()
 const resetFilter = () => {

+ 1 - 1
src/views/role/edit.vue

@@ -60,7 +60,7 @@
             default-expand-all
             checkable
             :tree-data="menuTree"
-            @update:checked-keys="ids => (editRole.menuIds = ids as any)"
+            @update:checked-keys="(ids: number[]) => (editRole.menuIds = ids)"
           />
         </div>
       </a-form-item>

+ 7 - 1
src/views/role/list.vue

@@ -14,6 +14,7 @@
 
   <BodyPanlBody>
     <a-table
+      :scroll="{ x: '100%', y: 350 }"
       :data-source="list"
       :columns="roleColumns"
       :pagination="pagination"
@@ -32,7 +33,7 @@
 
 <script lang="ts" setup>
 import EditRole from './edit.vue'
-import { computed, reactive } from 'vue'
+import { computed, reactive, watch } from 'vue'
 import { BodyPanlHeader, BodyPanlBody } from '@/layout/panl'
 import { usePaging } from '@/hook'
 import { router } from '@/router'
@@ -73,6 +74,11 @@ const setRole = (role?: Role) => {
   })
 }
 
+watch(
+  () => params.roleName,
+  () => (pagination.current = 1),
+  { flush: 'sync' }
+)
 const delRoleHandler = (role: Role) => {
   Modal.confirm({
     content: '确定要删除此角色',

+ 7 - 3
src/views/scene/list.vue

@@ -16,6 +16,7 @@
       :data-source="filterScene"
       :columns="sceneColumns"
       :pagination="pagination"
+      :scroll="{ x: '100%', y: 350 }"
     >
       <template #bodyCell="{ column, text }">
         <template v-if="column.dataIndex === 'name'">
@@ -24,7 +25,7 @@
           </template>
           <a-popover v-else>
             <template #content>{{ text }}</template>
-            {{text.substring(0, maxNameLength)}}...
+            {{ text.substring(0, maxNameLength) }}...
           </a-popover>
         </template>
       </template>
@@ -34,7 +35,7 @@
 
 <script lang="ts" setup>
 import InsertScene from './insert.vue'
-import { computed, reactive, ref } from 'vue'
+import { computed, reactive, ref, watch, onDeactivated } from 'vue'
 import { BodyPanlHeader, BodyPanlBody } from '@/layout/panl'
 import { useProject } from '@/store'
 import { sceneColumns } from './columns'
@@ -57,7 +58,10 @@ const pagination = reactive({
     pagination.current = num
   }
 })
-
+onDeactivated(() => {
+  filterName.value = ''
+})
+watch(filterName, () => (pagination.current = 1), { flush: 'sync' })
 const insertScene = () => {
   renderModal(InsertScene, {
     showBim: !projectStore.current!.bimData,

+ 70 - 46
src/views/taggings/list.vue

@@ -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;