ソースを参照

Merge branch 'iteration-20240219' into jenkins-main

lex 1 年間 前
コミット
d8a09b5d99

+ 32 - 16
src/components/o-sticky/index.tsx

@@ -1,6 +1,7 @@
 import { useRect } from '@vant/use'
 import { defineComponent, nextTick, PropType } from 'vue'
 import styles from './index.module.less'
+import { useResizeObserver } from '@vueuse/core'
 
 export default defineComponent({
   emits: ['getHeight'],
@@ -44,24 +45,39 @@ export default defineComponent({
       this.divStyle.bottom = this.offsetBottom || '0px'
     }
 
-    nextTick(() => {
-      // 为了处理刚开始头部高度为0的情况
-      const { height } = useRect((this as any).$refs.div)
-      this.__initHeight(height)
+    try {
+      useResizeObserver((this as any).$refs.div2, (entries: any) => {
+        const entry = entries[0]
+        const { height } = entry.contentRect
+        // console.log(height, 'height')
+        if (Math.abs(height - this.heightV) > 1) {
+          setTimeout(() => {
+            this.__initHeight(height)
+          }, 10)
+        }
+      })
+    } catch {
+      //
+    }
 
-      setTimeout(() => {
-        const { height } = useRect((this as any).$refs.div)
-        this.__initHeight(height)
-      }, 200)
+    // nextTick(() => {
+    //   // 为了处理刚开始头部高度为0的情况
+    //   const { height } = useRect((this as any).$refs.div)
+    //   this.__initHeight(height)
 
-      // 为了处理头部第一次获取高度不对的问题
-      setTimeout(() => {
-        const { height } = useRect((this as any).$refs.div2)
-        if (height !== this.heightV && this.position === 'top') {
-          this.__initHeight(height)
-        }
-      }, 1000)
-    })
+    //   setTimeout(() => {
+    //     const { height } = useRect((this as any).$refs.div)
+    //     this.__initHeight(height)
+    //   }, 200)
+
+    //   // 为了处理头部第一次获取高度不对的问题
+    //   setTimeout(() => {
+    //     const { height } = useRect((this as any).$refs.div2)
+    //     if (height !== this.heightV && this.position === 'top') {
+    //       this.__initHeight(height)
+    //     }
+    //   }, 1000)
+    // })
   },
   methods: {
     __initHeight(height: any) {

+ 24 - 2
src/router/routes-teacher.ts

@@ -166,9 +166,31 @@ export default [
         meta: {
           title: '补助明细'
         }
+      },
+      {
+        path: '/school-photo',
+        name: 'school-photo',
+        component: () => import('@/school/orchestra/compontent/photo'),
+        meta: {
+          title: '乐团相册'
+        }
+      },
+      {
+        path: '/photo-detail',
+        name: 'photo-detail',
+        component: () => import('@/school/orchestra/compontent/photo-detail'),
+        meta: {
+          title: '相册详情'
+        }
+      },
+      {
+        path: '/orchestra-photo-create',
+        name: 'orchestra-photo-create',
+        component: () => import('@/school/orchestra/compontent/photo-create'),
+        meta: {
+          title: '创建相册'
+        }
       }
-
-      //unitDetail 选择阶段自测
     ]
   },
   ...rootRouter,

+ 10 - 14
src/school/orchestra/compontent/photo-create.tsx

@@ -4,31 +4,27 @@ import {
   ActionSheet,
   Button,
   closeToast,
-  Dialog,
   Field,
-  Image,
   List,
-  Popover,
   Popup,
   showConfirmDialog,
   showLoadingToast,
   showToast,
-  Space,
-  Sticky,
   Uploader
 } from 'vant'
 import { defineComponent, onMounted, reactive } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import styles from './photo.module.less'
-import iconPhoneDefaut from '../images/icon-photo-default.png'
+// import iconPhoneDefaut from '../images/icon-photo-default.png'
 import OHeader from '@/components/o-header'
 import OSticky from '@/components/o-sticky'
 import { getOssUploadUrl } from '@/state'
-import umiRequest from 'umi-request'
+// import umiRequest from 'umi-request'
 import { getUploadSign, onOnlyFileUpload } from '@/helpers/oss-file-upload'
+import { state as baseState } from '@/state'
 
 export default defineComponent({
-  name: 'phone',
+  name: 'phone-create',
   props: {
     height: {
       type: [String, Number],
@@ -68,7 +64,7 @@ export default defineComponent({
           return
         }
         if (state.selectType === 'add') {
-          await request.post('/api-school/orchestraPhotoAlbum/save', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/save', {
             data: {
               orchestraId: route.query.orchestraId,
               name: state.photoName,
@@ -82,7 +78,7 @@ export default defineComponent({
           state.photoName = null
           onSearch()
         } else {
-          await request.post('/api-school/orchestraPhotoAlbum/update', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/update', {
             data: {
               id: state.selectItem.id,
               orchestraId: route.query.orchestraId,
@@ -121,7 +117,7 @@ export default defineComponent({
       try {
         if (state.isLoading) return
         state.isLoading = true
-        const res = await request.post('/api-school/orchestraPhotoAlbum/page', {
+        const res = await request.post(baseState.platformApi + '/orchestraPhotoAlbum/page', {
           data: {
             ...state.params,
             orchestraId: route.query.orchestraId,
@@ -168,7 +164,7 @@ export default defineComponent({
         message: '您确认删除该相册吗?'
       }).then(async () => {
         try {
-          await request.post('/api-school/orchestraPhotoAlbum/remove', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/remove', {
             requestType: 'form',
             data: {
               id: state.selectItem.id
@@ -220,7 +216,7 @@ export default defineComponent({
         console.log(files, 'files')
         const file = files.file
         // 获取签名
-        // const signUrl = '/api-school/open/getUploadSign'
+        // const signUrl = baseState.platformApi + '/open/getUploadSign'
         // const tempName = file.name || ''
         // const fileName = '/orchestra/' + (tempName && tempName.replace(/ /gi, '_'))
         // const key = new Date().getTime() + fileName
@@ -291,7 +287,7 @@ export default defineComponent({
         })
         console.log(files, 'onSubmitPhoto')
 
-        await request.post('/api-school/orchestraPhoto/save', {
+        await request.post(baseState.platformApi + '/orchestraPhoto/save', {
           data: {
             orchestraId: route.query.orchestraId,
             orchestraPhotoAlbumId: route.query.parentId,

+ 23 - 7
src/school/orchestra/compontent/photo-detail.tsx

@@ -14,7 +14,7 @@ import {
   Popup,
   showDialog,
   showFailToast,
-  showImagePreview,
+  // showImagePreview,
   showLoadingToast,
   showSuccessToast,
   showToast,
@@ -24,14 +24,15 @@ import { computed, defineComponent, onMounted, reactive } from 'vue'
 import { useRoute } from 'vue-router'
 import styles from './photo-detail.module.less'
 import iconDelete from '../images/icon-delete.png'
-import umiRequest from 'umi-request'
+// import umiRequest from 'umi-request'
 import { getOssUploadUrl } from '@/state'
 import checkboxCheck from '../images/icon-red-active.png'
 import checkboxDefault from '../images/icon-red-default.png'
 import iconDown from '../images/icon-down.png'
-import html2canvas from 'html2canvas'
+// import html2canvas from 'html2canvas'
 import { promisefiyPostMessage } from '@/helpers/native-message'
 import { getUploadSign, onOnlyFileUpload } from '@/helpers/oss-file-upload'
+import { state as baseState } from '@/state'
 
 export default defineComponent({
   name: 'photo-detail',
@@ -46,6 +47,7 @@ export default defineComponent({
         loading: false,
         finished: false
       },
+      name: route.query.name || '',
       params: {
         page: 1,
         rows: 20
@@ -62,7 +64,7 @@ export default defineComponent({
       try {
         if (state.isLoading) return
         state.isLoading = true
-        const res = await request.post('/api-school/orchestraPhoto/page', {
+        const res = await request.post(baseState.platformApi + '/orchestraPhoto/page', {
           data: {
             ...state.params,
             orchestraPhotoAlbumId: route.query.photoId
@@ -171,7 +173,7 @@ export default defineComponent({
         })
         console.log(files, 'onSubmitPhoto')
 
-        await request.post('/api-school/orchestraPhoto/save', {
+        await request.post(baseState.platformApi + '/orchestraPhoto/save', {
           data: {
             orchestraPhotoAlbumId: route.query.photoId,
             fileUrl: files.join(',')
@@ -290,7 +292,7 @@ export default defineComponent({
       }).then(async () => {
         console.log(state.check, 'check')
         try {
-          await request.post('/api-school/orchestraPhoto/remove', {
+          await request.post(baseState.platformApi + '/orchestraPhoto/remove', {
             requestType: 'form',
             data: {
               ids: state.check.join(',')
@@ -321,14 +323,28 @@ export default defineComponent({
       })
     }
 
+    const getDetails = async () => {
+      try {
+        const { data } = await request.get(
+          baseState.platformApi + '/orchestraPhotoAlbum/detail/' + route.query.photoId
+        )
+        state.name = data.name || ''
+      } catch {
+        //
+      }
+    }
+
     onMounted(() => {
+      if (!state.name) {
+        getDetails()
+      }
       getList()
     })
 
     return () => (
       <div class={[styles.phoneDetail, !state.listState.dataShow && 'emptyRootContainer']}>
         <OSticky position="top">
-          <OHeader title={(route.query.name as any) || ''}>
+          <OHeader title={(state.name as any) || ''}>
             {{
               right: () =>
                 !state.isEdit && (

+ 30 - 1
src/school/orchestra/compontent/photo.module.less

@@ -45,6 +45,35 @@
   background: #FFF7F3;
 }
 
+
+.selectSchool {
+  height: 45px;
+
+  .icon {
+    width: 17px;
+    height: 17px;
+    margin-right: 6px;
+    flex-shrink: 0;
+  }
+
+  :global {
+    .van-cell__title {
+      overflow: hidden;
+      white-space: nowrap;
+      text-overflow: ellipsis;
+      font-size: 15px;
+      color: #333333;
+      font-weight: 500;
+    }
+
+    .van-cell__right-icon {
+      color: #333;
+      transform: rotate(90deg);
+      margin: 0 0 0 4px;
+    }
+  }
+}
+
 .btnGroup {
   display: flex;
   padding: 12px 12px 6px;
@@ -163,4 +192,4 @@
       top: 50px;
     }
   }
-}
+}

+ 48 - 40
src/school/orchestra/compontent/photo.tsx

@@ -20,9 +20,10 @@ import { defineComponent, onMounted, reactive } from 'vue'
 import { useRoute, useRouter } from 'vue-router'
 import styles from './photo.module.less'
 import iconPhoneDefaut from '../images/icon-photo-default.png'
-import iconOrchestra from '@/views/mine-orchestra/images/icon-or.png'
+import iconOrchestra from '../images/icon-school.png'
 import OSticky from '@/components/o-sticky'
 import OHeader from '@/components/o-header'
+import { state as baseState } from '@/state'
 
 export default defineComponent({
   name: 'phone',
@@ -65,19 +66,16 @@ export default defineComponent({
           return
         }
         if (state.selectType === 'add') {
-          await request.post('/api-school/orchestraPhotoAlbum/save', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/save', {
             data: {
               name: state.photoName
             }
           })
-          // setTimeout(() => {
-          //   showToast('添加成功')
-          // }, 100)
           state.status = false
           state.photoName = null
           onSearch()
         } else {
-          await request.post('/api-school/orchestraPhotoAlbum/update', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/update', {
             data: {
               id: state.selectItem.id,
               orchestraId: route.query.id,
@@ -87,17 +85,10 @@ export default defineComponent({
           state.status = false
           state.photoName = null
           onSearch()
-          // setTimeout(() => {
-          //   showToast('修改成功')
-          // }, 100)
         }
         state.status = false
         state.photoName = null
         onSearch()
-        // setTimeout(() => {
-        // state.photoName = null
-        // onSearch()
-        // }, 1100)
       } catch {
         //
       }
@@ -117,7 +108,7 @@ export default defineComponent({
       try {
         if (state.isLoading) return
         state.isLoading = true
-        const res = await request.post('/api-school/orchestraPhotoAlbum/page', {
+        const res = await request.post(baseState.platformApi + '/orchestraPhotoAlbum/page', {
           data: {
             ...state.params,
             schoolId: state.school.id
@@ -142,28 +133,28 @@ export default defineComponent({
       }
     }
 
-    // const getSchoolList = async () => {
-    //   try {
-    //     const res = await request.post('/api-school/school/page', {
-    //       data: {
-    //         page: 1,
-    //         rows: 999
-    //       }
-    //     })
-    //     if (Array.isArray(res.data?.rows)) {
-    //       state.schoolList = res.data.rows.map((n: any) => {
-    //         return {
-    //           name: n.name || '',
-    //           id: n.id || ''
-    //         }
-    //       })
-    //       const tmpSchool = sessionStorage.getItem('school-photo')
-    //       state.school = tmpSchool ? JSON.parse(tmpSchool) : state.schoolList[0] || {}
-    //     }
-    //   } catch {
-    //     //
-    //   }
-    // }
+    const getSchoolList = async () => {
+      try {
+        const res = await request.post(baseState.platformApi + '/school/page', {
+          data: {
+            page: 1,
+            rows: 999
+          }
+        })
+        if (Array.isArray(res.data?.rows)) {
+          state.schoolList = res.data.rows.map((n: any) => {
+            return {
+              name: n.name || '',
+              id: n.id || ''
+            }
+          })
+          const tmpSchool = sessionStorage.getItem('school-photo')
+          state.school = tmpSchool ? JSON.parse(tmpSchool) : state.schoolList[0] || {}
+        }
+      } catch {
+        //
+      }
+    }
 
     const onDetail = (item: any) => {
       sessionStorage.setItem('orchestra-detail-tab', 'photo')
@@ -194,7 +185,7 @@ export default defineComponent({
         message: '您确认删除该相册吗?'
       }).then(async () => {
         try {
-          await request.post('/api-school/orchestraPhotoAlbum/remove', {
+          await request.post(baseState.platformApi + '/orchestraPhotoAlbum/remove', {
             requestType: 'form',
             data: {
               id: state.selectItem.id
@@ -208,7 +199,9 @@ export default defineComponent({
     }
 
     onMounted(async () => {
-      // await getSchoolList()
+      if (baseState.platformType === 'TEACHER') {
+        await getSchoolList()
+      }
       await getList()
     })
     return () => (
@@ -218,6 +211,21 @@ export default defineComponent({
       >
         <OSticky position="top">
           <OHeader border={false} />
+          {baseState.platformType === 'TEACHER' && !!state.schoolList.length && (
+            <CellGroup inset style={{ marginTop: '12px' }}>
+              <Cell
+                class={styles.selectSchool}
+                center
+                isLink
+                onClick={() => (state.schoolStatus = true)}
+              >
+                {{
+                  icon: () => <img class={styles.icon} src={iconOrchestra} />,
+                  title: () => <div class="van-ellipsis">{state.school.name}</div>
+                }}
+              </Cell>
+            </CellGroup>
+          )}
           <div class={styles.btnGroup}>
             <Button
               icon="plus"
@@ -330,7 +338,7 @@ export default defineComponent({
           ]}
         />
 
-        {/* <Popup v-model:show={state.schoolStatus} position="bottom" round>
+        <Popup v-model:show={state.schoolStatus} position="bottom" round>
           <Picker
             columns={state.schoolList}
             columnsFieldNames={{ text: 'name', value: 'id' }}
@@ -347,7 +355,7 @@ export default defineComponent({
               onSearch()
             }}
           />
-        </Popup> */}
+        </Popup>
       </div>
     )
   }

BIN
src/school/orchestra/images/icon-school.png