Browse Source

系统配置附件上传优化

wangwei 3 years ago
parent
commit
22a88d1037

+ 25 - 7
src/views/general/config/customComponents/ChooseModal.vue

@@ -12,17 +12,13 @@
       rowKey="id"
       @register="registerTable"
       :rowSelection="{ type: type === 'images' || type === 'files' ? 'checkbox' : 'radio' }"
-    >
-      <template #action="{ record, column }">
-        <TableAction :actions="createActions(record, column)" />
-      </template>
-    </BasicTable>
+    />
   </BasicModal>
 </template>
 <script lang="ts">
   import { defineComponent, onUpdated, ref, toRefs, unref } from 'vue';
   import { BasicModal, useModalInner } from '/@/components/Modal';
-  import { BasicTable, useTable, TableAction, TableActionType } from '/@/components/Table';
+  import { BasicTable, useTable, TableActionType } from '/@/components/Table';
   import { columns } from '../../attachment/data';
   import { useMessage } from '/@/hooks/web/useMessage';
   import { getAttachmentList } from '/@/api/sys/general';
@@ -32,7 +28,7 @@
     type: { type: String, default: '' },
   };
   export default defineComponent({
-    components: { BasicModal, BasicTable, TableAction },
+    components: { BasicModal, BasicTable },
     props,
     emits: ['register', 'checked'],
     setup(props, { emit }) {
@@ -44,6 +40,7 @@
       const [registerTable] = useTable({
         columns: columns,
         api: getAttachmentList,
+        beforeFetch: beforeFetch,
         showIndexColumn: false,
         bordered: true,
         maxHeight: 520,
@@ -57,6 +54,27 @@
         return tableAction;
       }
 
+      // 请求之前处理
+      function beforeFetch(params) {
+        // tab切换 暂时方法 图片
+        if (props.type === 'images' || props.type === 'image') {
+          if (!params.filter) {
+            params.filter = {};
+          }
+          params.op = {};
+          params.filter.imagetype = 'png,jpg,jpeg,gif';
+          params.op.imagetype = 'in';
+        }
+        // else if (props.type === 'files' || props.type === 'file') {
+        //   if (!params.filter) {
+        //     params.filter = {};
+        //   }
+        //   params.op = {};
+        //   params.filter.imagetype = 'txt,pdf,xls,xlsx,.webp';
+        //   params.op.imagetype = 'in';
+        // }
+      }
+
       async function handleSumbit() {
         const rows = await getTableAction().getSelectRows();
         if (rows.length) {

+ 1 - 1
src/views/general/config/customComponents/UploadFile.vue

@@ -97,7 +97,7 @@
         emit('change', state.fileUrls);
       }
       function checked(files) {
-        if (props.type === 'image') {
+        if (props.type === 'file') {
           state.fileUrls = files[0].url;
         } else {
           let urls: string[] = [];