Przeglądaj źródła

feat(upload): upload改变值

gemercheung 3 lat temu
rodzic
commit
d651a8a238

+ 1 - 0
src/api/corporation/model.ts

@@ -6,6 +6,7 @@ export type PageParams = BasicPageParams;
 export interface updateCompanyParam {
   id: number;
   sceneLogo?: string;
+  floorLogo?: string;
 }
 export interface addDeiceParam {
   childNames: string | null;

+ 9 - 1
src/components/Cropper/src/CopperModal.vue

@@ -113,7 +113,7 @@
 <script lang="ts">
   import type { CropendResult, Cropper } from './typing';
 
-  import { defineComponent, ref } from 'vue';
+  import { defineComponent, ref, watchEffect } from 'vue';
   import CropperImage from './Cropper.vue';
   import { Space, Upload, Avatar, Tooltip } from 'ant-design-vue';
   import { useDesign } from '/@/hooks/web/useDesign';
@@ -126,6 +126,8 @@
 
   const props = {
     circled: { type: Boolean, default: true },
+    src: { type: String, default: '' },
+
     uploadApi: {
       type: Function as PropType<(params: apiFunParams) => Promise<any>>,
     },
@@ -148,6 +150,12 @@
       const [register, { closeModal, setModalProps }] = useModalInner();
       const { t } = useI18n();
 
+      watchEffect(() => {
+        if (props.src) {
+          src.value = props.src;
+        }
+      });
+
       // Block upload
       function handleBeforeUpload(file: File) {
         const reader = new FileReader();

+ 3 - 0
src/components/Cropper/src/CropperAvatar.vue

@@ -24,6 +24,7 @@
       @register="register"
       @uploadSuccess="handleUploadSuccess"
       :uploadApi="uploadApi"
+      :circled="circled"
       :src="sourceValue"
     />
   </div>
@@ -53,6 +54,7 @@
     showBtn: { type: Boolean, default: true },
     btnProps: { type: Object as PropType<ButtonProps> },
     btnText: { type: String, default: '' },
+    circled: { type: Boolean, default: true },
     uploadApi: { type: Function as PropType<({ file: Blob, name: string }) => Promise<void>> },
   };
 
@@ -109,6 +111,7 @@
         getClass,
         getImageWrapperStyle,
         getStyle,
+        circled: props.circled,
         handleUploadSuccess,
       };
     },

+ 1 - 1
src/components/Upload/src/BasicUpload.vue

@@ -77,7 +77,7 @@
       watch(
         () => props.value,
         (value = []) => {
-          fileList.value = isArray(value) ? value : [];
+          fileList.value = isArray(value) ? value.filter((i) => i) : [];
         },
         { immediate: true },
       );

+ 18 - 11
src/views/corporation/index.vue

@@ -35,14 +35,15 @@
           :uploadApi="uploadLogoApi"
           :value="record.bgMusic"
         /> -->
-        {{ record.bgMusic }}
+        {{}}
         <BasicUpload
           :maxSize="5"
           :maxNumber="1"
           @change="handleMusicUpload"
           :api="uploadLogoApi"
           class="my-5"
-          :accept="['mp3/*']"
+          :value="[record.bgMusic]"
+          :accept="['.mp3', '.wav']"
         />
       </template>
       <template #expirationTime="{ record }">
@@ -112,15 +113,16 @@
       const [registerSubaccountModal, { openModal: openSubaccountModal }] = useModal();
       const { t } = useI18n();
       const columns: BasicColumn[] = [
-        {
-          title: 'ID',
-          dataIndex: 'id',
-          fixed: 'left',
-          width: 80,
-        },
+        // {
+        //   title: 'ID',
+        //   dataIndex: 'id',
+        //   fixed: 'left',
+        //   width: 80,
+        // },
         {
           title: t('routes.corporation.enterpriseId'),
           dataIndex: 'userName',
+          fixed: 'left',
           width: 120,
         },
         {
@@ -154,15 +156,18 @@
         {
           title: t('routes.corporation.subNum'),
           dataIndex: 'subNum',
+          ellipsis: false,
           width: 80,
         },
         {
           title: t('routes.corporation.sceneNum'),
           dataIndex: 'sceneNum',
+          ellipsis: false,
           width: 80,
         },
         {
           title: t('routes.corporation.point'),
+          ellipsis: false,
           dataIndex: 'point',
           width: 80,
         },
@@ -207,14 +212,14 @@
         formConfig: searchForm,
         showTableSetting: true,
         tableSetting: { fullScreen: true },
-        showIndexColumn: false,
+        showIndexColumn: true,
         rowKey: 'id',
         //TODO
         fetchSetting: {
           pageField: 'pageNum',
           sizeField: 'pageSize',
           listField: 'list',
-          totalField: 'total',
+          totalField: 'totalCount',
         },
         actionColumn: {
           width: 160,
@@ -241,7 +246,9 @@
         //   record,
         // });
       }
-      function handleMusicUpload() {}
+      function handleMusicUpload(record: Recordable) {
+        console.log('handleMusicUpload', record);
+      }
       async function updateSceneLogo(record: Recordable, data: Result) {
         console.log('src', data.message);
         console.log('record', record);