Explorar el Código

fix: 修改bug

bill hace 2 años
padre
commit
db626ff635

+ 7 - 3
src/api/instance.ts

@@ -28,8 +28,13 @@ export const gotoLogin = () => {
   router.push({ name: RoutesName.login })
 }
 
+let firstNow = 0
 const tokenInvalid = () => {
-  message.error(ResCodeDesc[ResCode.TOKEN_INVALID])
+  const currentNow = Date.now()
+  if (currentNow - firstNow > 5000) {
+    firstNow = Date.now()
+    message.error(ResCodeDesc[ResCode.TOKEN_INVALID])
+  }
   gotoLogin()
 }
 
@@ -39,8 +44,7 @@ addReqErrorHandler(err => {
 })
 
 addResErrorHandler((response, data) => {
-  console.log(response)
-  if (!response || !response.data || response.status !== 200) {
+  if (response && response.status && response.status !== 200) {
     message.error('服务错误,请稍后再试')
   } else if (data) {
     const msg =

+ 1 - 0
src/api/project.ts

@@ -59,6 +59,7 @@ export const BimStatusDesc = {
 export type Bim = {
   bimId: number
   bimLocalFilePath: string
+  userName: string
   bimName: string
   bimOssFilePath: string
   bimServiceId: null

+ 1 - 0
src/api/scene.ts

@@ -41,6 +41,7 @@ export interface Scene {
   type: SceneType
   status: SceneStatus
   phone: string
+  bind: boolean
 }
 
 export type Scenes = Scene[]

BIN
src/assets/images/un-project-pic.png


+ 2 - 0
src/components.d.ts

@@ -33,10 +33,12 @@ declare module '@vue/runtime-core' {
     ATabPane: typeof import('ant-design-vue/es')['TabPane']
     ATabs: typeof import('ant-design-vue/es')['Tabs']
     ATextarea: typeof import('ant-design-vue/es')['Textarea']
+    ATooltip: typeof import('ant-design-vue/es')['Tooltip']
     AUpload: typeof import('ant-design-vue/es')['Upload']
     DataList: typeof import('./components/data-list/index.vue')['default']
     DeleteOutlined: typeof import('@ant-design/icons-vue')['DeleteOutlined']
     DownOutlined: typeof import('@ant-design/icons-vue')['DownOutlined']
+    EasyText: typeof import('./components/easyText/index.vue')['default']
     List: typeof import('./components/list/index.vue')['default']
     Loading: typeof import('./components/loading/index.vue')['default']
     RouterLink: typeof import('vue-router')['RouterLink']

+ 30 - 0
src/components/easyText/index.vue

@@ -0,0 +1,30 @@
+<template>
+  <a-tooltip v-if="isOverflow" placement="topLeft">
+    <template #title>
+      <span>{{ content }}</span>
+    </template>
+    {{ easyContent }}
+  </a-tooltip>
+  <template v-else>
+    {{ content }}
+  </template>
+</template>
+
+<script setup lang="ts">
+import { computed } from 'vue'
+
+defineOptions<{ name: 'easyText' }>()
+const props = withDefaults(
+  defineProps<{ content: string; maxLen?: number }>(),
+  {
+    maxLen: 50
+  }
+)
+
+const isOverflow = computed(() => props.content.length > props.maxLen)
+const easyContent = computed(() =>
+  isOverflow.value
+    ? props.content.substring(0, props.maxLen) + '...'
+    : props.content
+)
+</script>

+ 9 - 4
src/components/upload/index.vue

@@ -1,5 +1,10 @@
 <template>
-  <a-upload :file-list="[]" :multiple="false" :before-upload="onBeforeUpload">
+  <a-upload
+    :file-list="[]"
+    :multiple="false"
+    :before-upload="onBeforeUpload"
+    :accept="extnames.map(ext => `.${ext}`).join(',')"
+  >
     <a-button type="primary" :disabled="disabled || !!file">
       <upload-outlined></upload-outlined>
       上传
@@ -61,10 +66,10 @@ const extxTip = computed(
 const onBeforeUpload: UploadProps['beforeUpload'] = file => {
   const ext = getExtname(file.name)?.toLocaleLowerCase()
 
-  if (file.size > maxMB.value) {
-    message.error(`最大支持上传${maxSizeTip.value}`)
-  } else if (!ext || !extnames.value.includes(ext)) {
+  if (!ext || !extnames.value.includes(ext)) {
     message.error(`仅支持${extxTip.value}文件格式`)
+  } else if (file.size > maxMB.value) {
+    message.error(`最大支持上传${maxSizeTip.value}`)
   } else {
     emit('update:file', file)
   }

+ 3 - 3
src/store/project.ts

@@ -57,13 +57,13 @@ export const useProject = defineStore('project', {
           {
             id: bimData.bimId,
             name: bimData.bimName,
+            phone: bimData.userName,
             title: bimData.bimName,
             sceneName: bimData.bimName,
             thumb: bimData.bimOssFilePath,
             createTime: bimData.createTime,
             type: BinType,
-            status: bimData.bimStatus,
-            phone: ''
+            status: bimData.bimStatus
           },
           ...scenes
         ]
@@ -86,7 +86,7 @@ export const useProject = defineStore('project', {
     async delete(id?: Project['projectId']) {
       if ((id = id || this.current?.projectId)) {
         await deleteProject(id)
-        await this.updateCurrent(id)
+        this.current = null
       }
     },
     async update(data: PartialPart<UpdateProjectData, 'projectId'>) {

+ 2 - 1
src/views/project/columns.ts

@@ -1,6 +1,7 @@
 import { h } from 'vue'
 import { ProjectStatusDesc, ProjectStatus } from '@/api'
 import { router, RoutesName } from '@/router'
+import unProjectPic from '@/assets/images/un-project-pic.png'
 
 import type { SimpleProject } from '@/api'
 import type { ColumnsType } from 'ant-design-vue/es/table'
@@ -29,7 +30,7 @@ export const projectColumns: ColumnsType<SimpleProject> = [
         width: '60px',
         height: '60px'
       }
-      return h('img', { src: record.projectImg, style })
+      return h('img', { src: record.projectImg || unProjectPic, style })
     }
   },
   {

+ 1 - 1
src/views/project/detailed.vue

@@ -113,7 +113,7 @@ const updateProject = async () => {
     project: projectStore.current!,
     async onSave({ projectImg, bimFile, ...data }) {
       const img =
-        typeof projectImg !== 'string'
+        projectImg && typeof projectImg !== 'string'
           ? await uploadFile(projectImg as File)
           : projectImg
 

+ 9 - 2
src/views/record/columns.ts

@@ -1,3 +1,6 @@
+import EasyText from '@/components/easyText/index.vue'
+import { h } from 'vue'
+
 import type { Record } from '@/api'
 import type { ColumnsType } from 'ant-design-vue/es/table'
 
@@ -5,7 +8,8 @@ export const recordColumns: ColumnsType<Record> = [
   {
     title: '序列',
     dataIndex: 'logId',
-    key: 'logId'
+    key: 'logId',
+    customRender: ({ index }) => index + 1
   },
   {
     title: '项目名称',
@@ -15,7 +19,10 @@ export const recordColumns: ColumnsType<Record> = [
   {
     title: '备注',
     dataIndex: 'logMsg',
-    key: 'logMsg'
+    key: 'logMsg',
+    customRender({ record }) {
+      return h(EasyText, { content: record.logMsg, maxLen: 50 })
+    }
   },
   {
     title: '操作人',

+ 5 - 1
src/views/scene/select-scenes.vue

@@ -12,6 +12,9 @@
     :columns="sceneColumns"
     :pagination="pagination"
     :row-selection="{
+      getCheckboxProps: (scene: Scene) => ({
+        disabled: scene.bind && !defaultTypeNums[params.type].some(num => scene.num === num)
+      }),
       selectedRowKeys: typeNums[params.type],
       onChange: changeSelectNums
     }"
@@ -25,7 +28,7 @@ import { reactive } from 'vue'
 import { fetchScenes, SceneType, SceneTypeDesc } from '@/api'
 import { usePaging } from '@/hook'
 
-import type { SelectTypeScenes } from '@/store'
+import type { SelectTypeScenes, Scene } from '@/store'
 
 defineOptions<{ name: 'select-scene-list' }>()
 
@@ -46,6 +49,7 @@ const tabOptions = [SceneType.SWKJ, SceneType.SWKK, SceneType.SWSS].map(
   })
 )
 
+const defaultTypeNums = { ...props.typeNums }
 const params = reactive({ type: SceneType.SWSS })
 const { list, pagination } = usePaging(fetchScenes, params)