cfort 2 лет назад
Родитель
Сommit
27a950779b

+ 35 - 19
src/business/platform/file/attachment/selector.vue

@@ -232,8 +232,8 @@ export default {
             this.handleInput()
         },
         /**
-             * 初始化数据
-             */
+         * 初始化数据
+         */
         initData () {
             const data = this.getArrayValue(this.value)
             this.selectorValue = this.multiple ? [] : {}
@@ -274,8 +274,8 @@ export default {
             }
         },
         /**
-             * 获得数组数据
-             */
+         * 获得数组数据
+         */
         getArrayValue (value, bindId) {
             if (this.$utils.isEmpty(value)) {
                 return []
@@ -377,8 +377,8 @@ export default {
             }
         },
         /**
-             * 通过ID获取数据
-             */
+         * 通过ID获取数据
+         */
         getDataInfo (id) {
             if (TRANSFER_DATA === 'transfer') {
                 this.getTransferData(id)
@@ -492,8 +492,8 @@ export default {
             }
         },
         /**
-             * 处理删除
-             */
+         * 处理删除
+         */
         handleRemove (index) {
             if (this.multiple) {
                 this.selectorValue.splice(index, 1)
@@ -503,17 +503,33 @@ export default {
             this.handleInput()
         },
         /**
-             * 处理下载
-             */
+         * 处理下载
+         */
         handleDownload (index) {
             downloadFile(this.multiple ? this.selectorValue[index] : this.selectorValue)
         },
         /**
-             * 处理预览
-             */
+         * 处理预览
+         */
         handlePreview (index) {
             this.attachment = this.multiple ? this.selectorValue[index] : this.selectorValue
-            if (supportFileTypes.includes(this.attachment.ext)) {
+            if (this.attachment.ext === 'pdf') {
+                this.$nextTick(() => {
+                    // this.$refs.viewer.load(this.url)
+                    const newTab = window.open()
+                    const link = newTab.document.createElement('link')
+                    const url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + this.attachment.id
+                    link.rel = 'shortcut icon'
+                    link.type = 'image/x-icon'
+                    link.href = 'favicon.ico'
+                    // newTab.document.write('<link rel="icon" type="image/x-icon" href="favicon.ico">')
+                    newTab.document.write(`<title>文件预览页-${this.attachment.fileName}</title>`)
+                    newTab.document.write('<style>body { margin: 0px; }</style>')
+                    newTab.document.head.appendChild(link)
+                    newTab.document.write(`<iframe src="${this.$baseUrl}lib/pdfjs-dist/web/viewer.html?file=${encodeURIComponent(url)}" style="width:100%; height:100%;" frameborder="0";>`)
+                    // this.closeDialog()
+                })
+            } else if (supportFileTypes.includes(this.attachment.ext)) {
                 this.getPreview(index)
             } else {
                 this.$message.closeAll()
@@ -521,8 +537,8 @@ export default {
             }
         },
         /**
-             * 处理预览
-             */
+         * 处理预览
+         */
         getPreview (index) {
             // 1、获取文件数据 及下载流接口
             // 下载地址
@@ -536,8 +552,8 @@ export default {
             this.filePreviewVisible = true
         },
         /**
-             *  确定
-             */
+         *  确定
+         */
         handleSelectorActionEvent (buttonKey, data) {
             if (this.uploadType === 'default' && this.$utils.isNotEmpty(this.limit) && this.multiple && this.limit < data.length) {
                 this.$message({
@@ -569,8 +585,8 @@ export default {
             this.$emit('callback', this.selectorValue)
         },
         /**
-             * 文件上传
-             */
+         * 文件上传
+         */
         httpRequest (options) {
             return uploadFile(options.file, {})
         },

+ 101 - 101
src/business/platform/form/formbuilder/right-aside/editors/editor-field-attachment.vue

@@ -1,116 +1,116 @@
 <template>
-    <div class="panel panel-default bowen-options">
-        <div class="panel-heading">参数设置</div>
-        <div class="panel-body">
+  <div class="panel panel-default bowen-options">
+    <div class="panel-heading">参数设置</div>
+    <div class="panel-body">
 
-            <el-form-item>
-                <template slot="label">文件编辑:</template>
-                <el-radio-group v-model="fieldOptions.operation_status">
-                    <el-radio label="none">不操作</el-radio>
-                    <!-- <el-radio label="saveDel">替换</el-radio> -->
-                    <el-radio label="saveAdd">新增</el-radio>
-                    <el-radio label="fileTraining">培训</el-radio>
-                </el-radio-group>
-                </br>
-                用编辑的文件'替换'原文件
-                </br>
-                或通过选择文件模板,'新增'文件
-            </el-form-item>
+      <el-form-item>
+        <template slot="label">文件编辑:</template>
+        <el-radio-group v-model="fieldOptions.operation_status">
+         <el-radio label="none" >不操作</el-radio>
+          <!-- <el-radio label="saveDel">替换</el-radio> -->
+          <el-radio label="saveAdd" >新增</el-radio>
+           </el-radio-group>
+           </br>
+           用编辑的文件'替换'原文件
+           </br>
+           或通过选择文件模板,'新增'文件
+      </el-form-item>
 
-            <el-form-item>
-                <template slot="label">是否多选<help-tip prop="multiple" /></template>
-                <el-switch
-                    v-model="fieldOptions.multiple"
-                    @change="setDefaultValue"
-                />
-            </el-form-item>
-            <el-form-item v-if="fieldOptions.multiple" label-width="120px">
-                <template slot="label">
-                    <div class="ibps-ellipsis">最大上传数量<help-tip prop="fileQuantity" /></div>
-                </template>
-                <el-input-number v-model="fieldOptions.max_file_quantity" :min="1" style="width:100%;" />
-            </el-form-item>
-            <el-form-item label-width="120px">
-                <template slot="label">
-                    <div class="ibps-ellipsis">文件大小(单个)<help-tip prop="fileSize" /></div>
-                </template>
-                <el-input v-model="fieldOptions.max_file_size" placeholder="文件大小(单个)">
-                    <template slot="append">M</template>
-                </el-input>
-            </el-form-item>
-            <el-form-item>
-                <template slot="label">上传类型 <help-tip prop="fileType" /></template>
-                <el-select v-model="fieldOptions.media_type" style="width:100%;">
-                    <el-option value="" label="不限制" />
-                    <el-option v-for="fileType in fileTypeOptions" :key="fileType.value" :value="fileType.value" :label="fileType.label" />
-                </el-select>
-                <el-input v-if="fieldOptions.media_type==='custom'" v-model="media" type="textarea" rows="1" resize="none" autosize placeholder="自定义文件类型,逗号[,]分割" style="padding-top:5px;" />
-            </el-form-item>
 
-            <el-form-item>
-                <template slot="label">
-                    允许下载
-                </template>
-                <el-switch v-model="fieldOptions.download" />
-            </el-form-item>
-            <el-form-item>
-                <template slot="label">上传方式<help-tip prop="uploadType" /></template>
-                <el-select v-model="fieldOptions.uploadType" style="width:100%;">
-                    <el-option
-                        v-for="item in uploadTypeOptions"
-                        :key="item.value"
-                        :value="item.value"
-                        :label="item.label"
-                    />
-                </el-select>
-            </el-form-item>
-            <el-form-item>
-                <template slot="label">存储格式<help-tip prop="fileStore" /></template>
-                <el-select v-model="fieldOptions.store" style="width:100%;">
-                    <el-option
-                        v-for="store in fileStoreOptions"
-                        :key="store.value"
-                        :value="store.value"
-                        :label="store.label"
-                    />
-                </el-select>
-            </el-form-item>
-        </div>
+      <el-form-item>
+        <template slot="label">是否多选<help-tip prop="multiple" /></template>
+        <el-switch
+          v-model="fieldOptions.multiple"
+          @change="setDefaultValue"
+        />
+      </el-form-item>
+      <el-form-item v-if="fieldOptions.multiple" label-width="120px">
+        <template slot="label">
+          <div class="ibps-ellipsis">最大上传数量<help-tip prop="fileQuantity" /></div>
+        </template>
+        <el-input-number v-model="fieldOptions.max_file_quantity" :min="1" style="width:100%;" />
+      </el-form-item>
+      <el-form-item label-width="120px">
+        <template slot="label">
+          <div class="ibps-ellipsis">文件大小(单个)<help-tip prop="fileSize" /></div>
+        </template>
+        <el-input v-model="fieldOptions.max_file_size" placeholder="文件大小(单个)">
+          <template slot="append">M</template>
+        </el-input>
+      </el-form-item>
+      <el-form-item>
+        <template slot="label">上传类型 <help-tip prop="fileType" /></template>
+        <el-select v-model="fieldOptions.media_type" style="width:100%;">
+          <el-option value="" label="不限制" />
+          <el-option v-for="fileType in fileTypeOptions" :key="fileType.value" :value="fileType.value" :label="fileType.label" />
+        </el-select>
+        <el-input v-if="fieldOptions.media_type==='custom'" v-model="media" type="textarea" rows="1" resize="none" autosize placeholder="自定义文件类型,逗号[,]分割" style="padding-top:5px;" />
+      </el-form-item>
+
+      <el-form-item>
+        <template slot="label">
+          允许下载
+        </template>
+        <el-switch v-model="fieldOptions.download" />
+      </el-form-item>
+      <el-form-item>
+        <template slot="label">上传方式<help-tip prop="uploadType" /></template>
+        <el-select v-model="fieldOptions.uploadType" style="width:100%;">
+          <el-option
+            v-for="item in uploadTypeOptions"
+            :key="item.value"
+            :value="item.value"
+            :label="item.label"
+          />
+        </el-select>
+      </el-form-item>
+      <el-form-item>
+        <template slot="label">存储格式<help-tip prop="fileStore" /></template>
+        <el-select v-model="fieldOptions.store" style="width:100%;">
+          <el-option
+            v-for="store in fileStoreOptions"
+            :key="store.value"
+            :value="store.value"
+            :label="store.label"
+          />
+        </el-select>
+      </el-form-item>
     </div>
+  </div>
 </template>
 <script>
 import { fileTypeOptions, fileStoreOptions, uploadTypeOptions } from '@/business/platform/form/constants/fieldOptions'
 import EditorMixin from '../mixins/editor'
 
 export default {
-    mixins: [EditorMixin],
-    data () {
-        return {
-            fileTypeOptions,
-            fileStoreOptions,
-            uploadTypeOptions,
-            media: ''
-        }
-    },
-    computed: {
-        mediaValue: {
-            get () {
-                return this.fieldOptions.media || ''
-            },
-            set (val) {
-                this.fieldItem.field_options.media = this.media = val
-            }
-        }
-    },
-    watch: {
-        media: {
-            handler (val, oldVal) {
-                if (val !== oldVal) {
-                    this.mediaValue = this.fieldItem.field_options.media = val || ''
-                }
-            },
-            immediate: true
+  mixins: [EditorMixin],
+  data() {
+    return {
+      fileTypeOptions,
+      fileStoreOptions,
+      uploadTypeOptions,
+      media: ''
+    }
+  },
+  computed: {
+    mediaValue: {
+      get() {
+        return this.fieldOptions.media || ''
+      },
+      set(val) {
+        this.fieldItem.field_options.media = this.media = val
+      }
+    }
+  },
+  watch: {
+    media: {
+      handler(val, oldVal) {
+        if (val !== oldVal) {
+          this.mediaValue = this.fieldItem.field_options.media = val || ''
         }
+      },
+      immediate: true
     }
+  }
 }
 </script>

+ 1 - 1
src/business/platform/form/formrender/dynamic-form/dynamic-form-field.vue

@@ -998,7 +998,7 @@ export default {
     },
     methods: {
         handleRadioChange (val) {
-            if (this.dataModel === val && this.fieldOptions.uncheck == true) {
+            if (this.dataModel === val && this.fieldOptions.uncheck === true) {
                 this.dataModel = null
             } else {
                 this.dataModel = val

+ 7 - 2
src/utils/common.js

@@ -12,7 +12,10 @@ import { bpmTaskSave } from '@/api/platform/bpmn/bpmTask'
 import { onlyOfficeToPdf, generateUUID } from '@/api/platform/form/seal'
 import { downloadFile as download } from '@/business/platform/file/utils'
 import { removeFormData } from '@/api/platform/data/dataTemplate'
-import utils from '@/utils/action'
+// 引入工具类
+import Utils from '@/utils/util'
+import ActionUtils from '@/utils/action'
+import AuthUtils from '@/utils/auth'
 
 // base64解码
 const decode = str => decodeURIComponent(window.atob(str).split('').map(c => `%${`00${c.charCodeAt(0).toString(16)}`.slice(-2)}`).join(''))
@@ -173,5 +176,7 @@ export default {
     download,
     removeFormData,
     replaceNullWithEmpty,
-    utils
+    Utils,
+    ActionUtils,
+    AuthUtils
 }

+ 263 - 249
src/views/platform/file/attachment/list.vue

@@ -47,7 +47,7 @@
         </div>
         <div v-if="filePreviewVisible2">
             <file-preview
-                :optionFile="file"
+                :option-file="file"
                 :visible="filePreviewVisible2"
                 @close="visible => filePreviewVisible2 = visible"
             />
@@ -56,278 +56,292 @@
 </template>
 
 <script>
-    import { queryPageList, deleteFile } from '@/api/platform/file/attachment'
-    import { downloadFile } from '@/business/platform/file/utils'
-    import ActionUtils from '@/utils/action'
-    import FixHeight from '@/mixins/height'
-    import IbpsUploader from '@/business/platform/file/uploader'
-    import FilePreview from '@/business/platform/file/file-preview'
-    import { fileTypes } from '@/business/platform/file/constants/fileTypes'
-    import Detail from './detail'
-    import ModifyName from './modify-name'
-    import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
+import { queryPageList, deleteFile } from '@/api/platform/file/attachment'
+import { downloadFile } from '@/business/platform/file/utils'
+import ActionUtils from '@/utils/action'
+import FixHeight from '@/mixins/height'
+import IbpsUploader from '@/business/platform/file/uploader'
+import FilePreview from '@/business/platform/file/file-preview'
+import { fileTypes } from '@/business/platform/file/constants/fileTypes'
+import Detail from './detail'
+import ModifyName from './modify-name'
+import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
 
-    export default {
-        components: {
-            IbpsUploader,
-            FilePreview,
-            Detail,
-            ModifyName
-        },
-        mixins: [FixHeight],
-        data() {
-            const extType = [
-                'txt',
-                'pdf',
-                'doc',
-                'docx',
-                'xls',
-                'xlsx',
-                'ppt',
-                'pptx',
-                'wps',
-                'jpg',
-                'jpeg',
-                'png',
-                'gif',
-                'mp3',
-                'mp4'
-            ]
-            return {
-                dialogFormVisible: false, // 弹窗
-                modifyNameVisible: false,
-                detailVisible: false,
-                filePreviewVisible: false,
-                filePreviewVisible2: false,
-                editId: '', // 编辑dialog需要使用
-                pkKey: 'id', // 主键  如果主键不是pk需要传主键
-                detailData: '',
-                file: {
-                    fileName: '',
-                    url: '',
-                    editUrl: '',
-                    title: '',
-                    fileType: ''
-                },
-                loading: true,
-                height: document.clientHeight,
+export default {
+    components: {
+        IbpsUploader,
+        FilePreview,
+        Detail,
+        ModifyName
+    },
+    mixins: [FixHeight],
+    data () {
+        const extType = [
+            'txt',
+            'pdf',
+            'doc',
+            'docx',
+            'xls',
+            'xlsx',
+            'ppt',
+            'pptx',
+            'wps',
+            'jpg',
+            'jpeg',
+            'png',
+            'gif',
+            'mp3',
+            'mp4'
+        ]
+        return {
+            dialogFormVisible: false, // 弹窗
+            modifyNameVisible: false,
+            detailVisible: false,
+            filePreviewVisible: false,
+            filePreviewVisible2: false,
+            editId: '', // 编辑dialog需要使用
+            pkKey: 'id', // 主键  如果主键不是pk需要传主键
+            detailData: '',
+            file: {
+                fileName: '',
+                url: '',
+                editUrl: '',
+                title: '',
+                fileType: ''
+            },
+            loading: true,
+            height: document.clientHeight,
 
-                listData: [],
-                pagination: {},
-                sorts: {},
-                listConfig: {
-                    toolbars: [
+            listData: [],
+            pagination: {},
+            sorts: {},
+            listConfig: {
+                toolbars: [
+                    {
+                        key: 'search'
+                    },
+                    {
+                        key: 'upLoad',
+                        label: '上传',
+                        icon: 'ibps-icon-upload'
+                    },
+                    {
+                        key: 'remove'
+                    }
+                ],
+                searchForm: {
+                    forms: [
+                        { prop: 'Q^file_name_^SL', label: '文件名' },
+                        { prop: 'Q^creator_name_^SL', label: '上传者' },
+                        { prop: 'Q^ext_^SL', label: '扩展名' },
                         {
-                            key: 'search'
-                        },
+                            prop: [
+                                'Q^create_time_^DL',
+                                'Q^create_time_^DG'
+                            ],
+                            label: '创建时间',
+                            fieldType: 'daterange'
+                        }
+                    ]
+                },
+                // 表格字段配置
+                columns: [
+                    { prop: 'fileName', label: '文件名' },
+                    {
+                        prop: 'createTime',
+                        label: '创建时间',
+                        dateFormat: 'yyyy-MM-dd HH:mm:ss'
+                    },
+                    { prop: 'ext', label: '扩展名' },
+                    {
+                        prop: 'totalBytes',
+                        label: '总字节数',
+                        filter: 'numberFormatter'
+                    },
+                    { prop: 'creatorName', label: '上传者' }
+                ],
+                rowHandle: {
+                    actions: [
                         {
-                            key: 'upLoad',
-                            label: '上传',
-                            icon: 'ibps-icon-upload'
+                            key: 'preview',
+                            label: '预览',
+                            icon: 'ibps-icon-eye',
+                            hidden: (row, index) => {
+                                if (extType.includes(row.ext)) return false
+                                return true
+                            }
                         },
                         {
-                            key: 'remove'
-                        }
-                    ],
-                    searchForm: {
-                        forms: [
-                            { prop: 'Q^file_name_^SL', label: '文件名' },
-                            { prop: 'Q^creator_name_^SL', label: '上传者' },
-                            { prop: 'Q^ext_^SL', label: '扩展名' },
-                            {
-                                prop: [
-                                    'Q^create_time_^DL',
-                                    'Q^create_time_^DG'
-                                ],
-                                label: '创建时间',
-                                fieldType: 'daterange'
-                            }
-                        ]
-                    },
-                    // 表格字段配置
-                    columns: [
-                        { prop: 'fileName', label: '文件名' },
+                            key: 'modifyName',
+                            label: '修改文件名',
+                            icon: 'ibps-icon-eraser'
+                        },
                         {
-                            prop: 'createTime',
-                            label: '创建时间',
-                            dateFormat: 'yyyy-MM-dd HH:mm:ss'
+                            key: 'detail',
+                            icon: 'ibps-icon-detail'
                         },
-                        { prop: 'ext', label: '扩展名' },
                         {
-                            prop: 'totalBytes',
-                            label: '总字节数',
-                            filter: 'numberFormatter'
+                            key: 'download',
+                            label: '下载',
+                            icon: 'ibps-icon-download'
                         },
-                        { prop: 'creatorName', label: '上传者' }
-                    ],
-                    rowHandle: {
-                        actions: [
-                            {
-                                key: 'preview',
-                                label: '预览',
-                                icon: 'ibps-icon-eye',
-                                hidden: (row, index) => {
-                                    if (extType.includes(row.ext)) return false
-                                    return true
-                                }
-                            },
-                            {
-                                key: 'modifyName',
-                                label: '修改文件名',
-                                icon: 'ibps-icon-eraser'
-                            },
-                            {
-                                key: 'detail',
-                                icon: 'ibps-icon-detail'
-                            },
-                            {
-                                key: 'download',
-                                label: '下载',
-                                icon: 'ibps-icon-download'
-                            },
-                            {
-                                key: 'remove'
-                            }
-                        ]
-                    }
+                        {
+                            key: 'remove'
+                        }
+                    ]
                 }
             }
+        }
+    },
+    created () {
+        this.loadData()
+    },
+    methods: {
+        // 加载数据
+        loadData () {
+            this.loading = true
+            queryPageList(this.getSearcFormData()).then((response) => {
+                ActionUtils.handleListData(this, response.data)
+                this.loading = false
+            }).catch(() => {
+                this.loading = false
+            })
         },
-        created() {
+        /**
+         * 获取格式化参数
+         */
+        getSearcFormData () {
+            return ActionUtils.formatParams(
+                this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {},
+                this.pagination,
+                this.sorts
+            )
+        },
+        /**
+         * 处理分页事件
+         */
+        handlePaginationChange (page) {
+            ActionUtils.setPagination(this.pagination, page)
             this.loadData()
         },
-        methods: {
-            // 加载数据
-            loadData() {
-                this.loading = true
-                queryPageList(this.getSearcFormData()).then((response) => {
-                    ActionUtils.handleListData(this, response.data)
-                    this.loading = false
-                }).catch(() => {
-                    this.loading = false
-                })
-            },
-            /**
-             * 获取格式化参数
-             */
-            getSearcFormData() {
-                return ActionUtils.formatParams(
-                    this.$refs['crud'] ? this.$refs['crud'].getSearcFormData() : {},
-                    this.pagination,
-                    this.sorts
-                )
-            },
-            /**
-             * 处理分页事件
-             */
-            handlePaginationChange(page) {
-                ActionUtils.setPagination(this.pagination, page)
-                this.loadData()
-            },
-            /**
-             * 处理排序
-             */
-            handleSortChange(sort) {
-                ActionUtils.setSorts(this.sorts, sort)
-                this.loadData()
-            },
-            /**
-             * 查询
-             */
-            search() {
-                this.loadData()
-            },
-            /**
-             * 处理按钮事件
-             */
-            handleAction(command, position, selection, data) {
-                switch (command) {
-                    case 'search': // 查询
-                        ActionUtils.setFirstPagination(this.pagination)
-                        this.search()
-                        break
-                    case 'upLoad': // 添加
-                        this.handleUpload()
-                        break
-                    case 'modifyName': // 修改文件名
-                        ActionUtils.selectedRecord(selection).then((id) => {
-                            this.handleModify(id)
-                            this.file.fileName = data.fileName
-                            // console.log(this.file.fileName)
-                        })
-                        break
-                    case 'detail': // 明细
-                        ActionUtils.selectedRecord(selection).then((id) => {
-                            this.handleDetail(id)
-                            this.detailData = data
+        /**
+         * 处理排序
+         */
+        handleSortChange (sort) {
+            ActionUtils.setSorts(this.sorts, sort)
+            this.loadData()
+        },
+        /**
+         * 查询
+         */
+        search () {
+            this.loadData()
+        },
+        /**
+         * 处理按钮事件
+         */
+        handleAction (command, position, selection, data) {
+            switch (command) {
+                case 'search': // 查询
+                    ActionUtils.setFirstPagination(this.pagination)
+                    this.search()
+                    break
+                case 'upLoad': // 添加
+                    this.handleUpload()
+                    break
+                case 'modifyName': // 修改文件名
+                    ActionUtils.selectedRecord(selection).then((id) => {
+                        this.handleModify(id)
+                        this.file.fileName = data.fileName
+                        // console.log(this.file.fileName)
+                    })
+                    break
+                case 'detail': // 明细
+                    ActionUtils.selectedRecord(selection).then((id) => {
+                        this.handleDetail(id)
+                        this.detailData = data
+                    })
+                    break
+                case 'preview': // 预览
+                    console.log('ext:', data.ext)
+                    if (fileTypes.images.includes(data.ext)) {
+                        this.file = data
+                        this.filePreviewVisible2 = false
+                        this.filePreviewVisible = true
+                    } else if (data.ext === 'pdf' || data.ext === 'PDF') {
+                        this.$nextTick(() => {
+                            const newTab = window.open()
+                            const link = newTab.document.createElement('link')
+                            const url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + data.id
+                            link.rel = 'shortcut icon'
+                            link.type = 'image/x-icon'
+                            link.href = 'favicon.ico'
+                            // newTab.document.write('<link rel="icon" type="image/x-icon" href="favicon.ico">')
+                            newTab.document.write(`<title>文件预览页-${data.fileName}</title>`)
+                            newTab.document.write('<style>body { margin: 0px; }</style>')
+                            newTab.document.head.appendChild(link)
+                            newTab.document.write(`<iframe src="${this.$baseUrl}lib/pdfjs-dist/web/viewer.html?file=${encodeURIComponent(url)}" style="width:100%; height:100%;" frameborder="0";>`)
                         })
-                        break
-                    case 'preview': // 预览
-                        console.log('ext:', data.ext)
-                        if (fileTypes.images.includes(data.ext)) {
-                            this.file = data
-                            this.filePreviewVisible2 = false
-                            this.filePreviewVisible = true
-                            break
-                        }
+                    } else {
                         this.file.url = BASE_API() + SYSTEM_URL() + `/file/download?attachmentId=${data.id}`
                         this.file.editUrl = BASE_API() + SYSTEM_URL() + `/file/editCallback?fileName=${data.fileName}&fileType=${data.ext}&id=${data.id}`
                         this.file.title = data.fileName // 文件名称
-                        this.file.fileType = data.ext //类型
+                        this.file.fileType = data.ext // 类型
                         this.filePreviewVisible = false
                         this.filePreviewVisible2 = true
-                        break
-                    case 'download': //  下载
-                        this.handleDownload(data)
-                        break
-                    case 'remove': // 删除
-                        ActionUtils.removeRecord(selection).then((ids) => {
-                            this.handleRemove(ids)
-                        }).catch(() => {})
-                        break
-                    default:
-                        break
-                }
-            },
-            /**
-             * 上传
-             */
-            handleUpload(id = '') {
-                this.editId = id
-                this.dialogFormVisible = true
-            },
-            uploaderAction(data) {
-                this.dialogFormVisible = false
-                this.search()
-            },
-            /**
-             * 修改文件名
-             */
-            handleModify(id = '') {
-                this.editId = id
-                this.modifyNameVisible = true
-            },
-            /**
-             * 处理明细
-             */
-            handleDetail(id = '') {
-                this.editId = id
-                this.detailVisible = true
-            },
-            /**
-             * 处理删除
-             */
-            handleRemove(ids) {
-                deleteFile({ attachmentIds: ids }).then(() => {
-                    ActionUtils.removeSuccessMessage()
-                    this.search()
-                }).catch(() => {})
-            },
-            handleDownload(data) {
-                downloadFile(data)
+                    }
+                    break
+                case 'download': // 下载
+                    this.handleDownload(data)
+                    break
+                case 'remove': // 删除
+                    ActionUtils.removeRecord(selection).then((ids) => {
+                        this.handleRemove(ids)
+                    }).catch(() => {})
+                    break
+                default:
+                    break
             }
+        },
+        /**
+         * 上传
+         */
+        handleUpload (id = '') {
+            this.editId = id
+            this.dialogFormVisible = true
+        },
+        uploaderAction (data) {
+            this.dialogFormVisible = false
+            this.search()
+        },
+        /**
+         * 修改文件名
+         */
+        handleModify (id = '') {
+            this.editId = id
+            this.modifyNameVisible = true
+        },
+        /**
+         * 处理明细
+         */
+        handleDetail (id = '') {
+            this.editId = id
+            this.detailVisible = true
+        },
+        /**
+         * 处理删除
+         */
+        handleRemove (ids) {
+            deleteFile({ attachmentIds: ids }).then(() => {
+                ActionUtils.removeSuccessMessage()
+                this.search()
+            }).catch(() => {})
+        },
+        handleDownload (data) {
+            downloadFile(data)
         }
     }
+}
 </script>
 <style lang="scss">
     .attachment-uploader-dialog {