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

+ 123 - 123
src/business/platform/bpmn/form/dialog.vue

@@ -1,140 +1,140 @@
 <template>
-  <el-dialog
-    :visible.sync="dialogVisible"
-    :close-on-click-modal="false"
-    :close-on-press-escape="false"
-    class="bpmn-formrenderer-dialog"
-    fullscreen
-    destroy-on-close
-    append-to-body
-    v-if="orderOpen"
-    @open="loadFormData"
-    @close="closeDialog"
-  >
-    <bpmn-formrender
-      ref="bpmnFormrender"
-      :def-id="defId"
-      :pro-inst-id="proInstId"
-      :flowName ="title"
-      :processName="processName"
-      :task-id="taskId"
-      :waiJian="waiJian"
-      :instance-id="instanceId"
-      :task-change-id="taskChangeId"
-      :copy-flow="copyFlow"
-      :addDataCont = "addDataCont"
-      @close="closeDialog"
-      @callback="handleCallback"
-    />
-  </el-dialog>
+    <el-dialog
+        v-if="orderOpen"
+        :visible.sync="dialogVisible"
+        :close-on-click-modal="false"
+        :close-on-press-escape="false"
+        class="bpmn-formrenderer-dialog"
+        fullscreen
+        destroy-on-close
+        append-to-body
+        @open="loadFormData"
+        @close="closeDialog"
+    >
+        <bpmn-formrender
+            ref="bpmnFormrender"
+            :def-id="defId"
+            :pro-inst-id="proInstId"
+            :flow-name="title"
+            :process-name="processName"
+            :task-id="taskId"
+            :wai-jian="waiJian"
+            :instance-id="instanceId"
+            :task-change-id="taskChangeId"
+            :copy-flow="copyFlow"
+            :add-data-cont="addDataCont"
+            @close="closeDialog"
+            @callback="handleCallback"
+        />
+    </el-dialog>
 </template>
 <script>
 import BpmnFormrender from './index'
 export default {
-  components: {
-    BpmnFormrender
-  },
-  props: {
-    visible: {
-      type: Boolean,
-      default: false
+    components: {
+        BpmnFormrender
     },
-    defId: { // 流程定义ID
-      type: String
+    props: {
+        visible: {
+            type: Boolean,
+            default: false
+        },
+        defId: { // 流程定义ID
+            type: String
+        },
+        proInstId: { // 草稿流程实例ID
+            type: String
+        },
+        instanceId: { // 流程实例ID
+            type: String
+        },
+        taskId: { // 流程任务ID
+            type: String
+        },
+        title: {
+            type: String
+        },
+        taskChangeId: { // 转办代理任务ID
+            type: String
+        },
+        copyFlow: { // 是否复制流程
+            type: Boolean,
+            default: false
+        },
+        addDataCont: { // 新增参数
+            type: Object
+        },
+        waiJian: { // 新增参数
+            type: String
+        },
+        processName: { // 流程名称
+            type: String,
+            default: ''
+        }
     },
-    proInstId: { // 草稿流程实例ID
-      type: String
+    data () {
+        return {
+            dialogVisible: this.visible,
+            dialogWidth: '80%',
+            orderOpen: true
+        }
     },
-    instanceId: { // 流程实例ID
-      type: String
+    watch: {
+        visible: {
+            handler: function (val, oldVal) {
+                this.dialogVisible = this.visible
+            },
+            immediate: true
+        }
     },
-    taskId: { // 流程任务ID
-      type: String
+    created () {
+        this.orderOpen = true
     },
-    title:{
-      type:String
+    beforeDestroy () {
+        this.orderOpen = false
     },
-    taskChangeId: { // 转办代理任务ID
-      type: String
-    },
-    copyFlow: { // 是否复制流程
-      type: Boolean,
-      default: false
-    },
-    addDataCont: { // 新增参数
-      type: Object
-    },
-    waiJian: { // 新增参数
-      type: String
-    },
-    processName: { // 流程名称
-        type: String,
-        default: ''
-    }
-  },
-  data() {
-    return {
-      dialogVisible: this.visible,
-      dialogWidth:'80%',
-      orderOpen:true
-    }
-  },
-  watch: {
-    visible: {
-      handler: function(val, oldVal) {
-        this.dialogVisible = this.visible
-      },
-      immediate: true
+    methods: {
+        loadFormData () {
+            this.$nextTick(() => {
+                this.$refs.bpmnFormrender.loadFormData()
+            })
+        },
+        handleCallback (data) {
+            const this_ = this
+            setTimeout(() => {
+                this_.$emit('callback', data)
+            }, 1300)
+        },
+        // 关闭当前窗口
+        closeDialog () {
+            this.$emit('close', false)
+        }
     }
-  },
-  created() {
-    this.orderOpen = true
-  },
-  beforeDestroy() {
-     this.orderOpen = false
-  },
-  methods: {
-    loadFormData() {
-      this.$nextTick(() => {
-        this.$refs.bpmnFormrender.loadFormData()
-      })
-    },
-    handleCallback(data) {
-      let this_ = this
-       setTimeout(() => {
-       this_.$emit('callback', data)
-       }, 1300)
-    },
-    // 关闭当前窗口
-    closeDialog() {
-      this.$emit('close', false)
-    }
-  }
 }
 </script>
 <style lang="scss">
-  .bpmn-formrenderer-dialog{
-    .el-dialog__header{
-      padding: 0;
-      border-bottom:0;
-    }
-    .el-dialog__body {
-      padding: 0;
-    }
-     .el-dialog__headerbtn{
-      z-index: 99999;
-    }
-    @media print {
-      .dynamic-form{
-        margin-top:0 !important;
-      }
-      .el-dialog__headerbtn {
-        display: none !important;
-      }
-      .hidden-print{
-        padding: 0;
-        margin:  0;
-      }
+    .bpmn-formrenderer-dialog{
+        .el-dialog__header{
+            padding: 0;
+            border-bottom:0;
+        }
+        .el-dialog__body {
+            padding: 0;
+        }
+        .el-dialog__headerbtn{
+            z-index: 99999;
+        }
+        @media print {
+            .dynamic-form{
+                margin-top:0 !important;
+            }
+            .el-dialog__headerbtn {
+                display: none !important;
+            }
+            .hidden-print{
+                padding: 0;
+                margin:  0;
+            }
+        }
     }
-  }
 </style>

+ 1 - 1
src/business/platform/data/components/search-form/index.vue

@@ -345,7 +345,7 @@ export default {
          * 获取参数
          */
         getSearcFormData () {
-             const { params, nameParams, datePrefix, format } = this
+            const { params, nameParams, datePrefix, format } = this
             // TODO: 过滤多余筛选条件数据
             // const allKey = Object.keys(params)
             const formattedForm = {

+ 528 - 512
src/business/platform/file/attachment/selector.vue

@@ -36,572 +36,588 @@
             <file-preview
                 :file="attachment"
                 :visible="filePreviewVisible"
-                :optionFile="optionFileView"
+                :option-file="optionFileView"
                 @close="visible => filePreviewVisible = visible"
             />
         </div>
 
-        <div class="divShow" v-if="showFile">
-            <fView :optionFile="optionFile" @updateFile="updateFile" />
+        <div v-if="showFile" class="divShow">
+            <fView :option-file="optionFile" @updateFile="updateFile" />
         </div>
     </div>
 </template>
 <script>
-    import { get, transfer, uploadFile } from '@/api/platform/file/attachment'
-    import { downloadFile } from '@/business/platform/file/utils'
-    import { remoteRequest, remoteTransRequest } from '@/utils/remote'
-    import IbpsFileAttachmentSelector from './index'
-    import IbpsUploaderSelectorDialog from '@/business/platform/file/uploader'
-    import FilePreview from '@/business/platform/file/file-preview'
-    import { supportFileTypes } from '@/components/ibps-file-viewer/constants'
-    import { TRANSFER_DATA } from '@/constant'
-    import fView from './editFile/fView.vue'
-    import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
+import { get, transfer, uploadFile } from '@/api/platform/file/attachment'
+import { downloadFile } from '@/business/platform/file/utils'
+import { remoteRequest, remoteTransRequest } from '@/utils/remote'
+import IbpsFileAttachmentSelector from './index'
+import IbpsUploaderSelectorDialog from '@/business/platform/file/uploader'
+import FilePreview from '@/business/platform/file/file-preview'
+import { supportFileTypes } from '@/components/ibps-file-viewer/constants'
+import { TRANSFER_DATA } from '@/constant'
+import fView from './editFile/fView.vue'
+import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
 
-    export default {
-        components: {
-            IbpsFileAttachmentSelector,
-            IbpsUploaderSelectorDialog,
-            FilePreview,
-            fView
-        },
-        inject: {
-            elForm: {
-                default: ''
-            },
-            elFormItem: {
-                default: ''
+export default {
+    components: {
+        IbpsFileAttachmentSelector,
+        IbpsUploaderSelectorDialog,
+        FilePreview,
+        fView
+    },
+    inject: {
+        elForm: {
+            default: ''
+        },
+        elFormItem: {
+            default: ''
+        }
+    },
+    props: {
+        value: {
+            type: [String, Number, Array, Object]
+        },
+        mediaType: String,
+        media: String,
+        store: {
+            // 存储类型,json: json字符串,id: 只存储id,array: 存储数组数据,arrayId: 字符串类型。
+            type: String,
+            default: 'id',
+            validator: function (value) {
+                return (['json', 'id', 'array', 'arrayId', 'bind'].indexOf(value) !== -1)
             }
         },
-        props: {
-            value: {
-                type: [String, Number, Array, Object]
-            },
-            mediaType: String,
-            media: String,
-            store: {
-                // 存储类型,json: json字符串,id: 只存储id,array: 存储数组数据,arrayId: 字符串类型。
-                type: String,
-                default: 'id',
-                validator: function (value) {
-                    return (['json', 'id', 'array', 'arrayId', 'bind'].indexOf(value) !== -1)
-                }
-            },
-            storeSeparator: {
-                // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
-                type: String,
-                default: ','
-            },
-            placeholder: {
-                // 输入框占位文本
-                type: String,
-                default: '请选择附件'
-            },
-            multiple: {
-                // 是否多选
-                type: Boolean,
-                default: false
-            },
-            limit: {
-                // 最大允许上传个数
-                type: Number
-            },
-            // 类型,
-            accept: String,
-            fileExt: {
-                type: Array,
-                default: () => []
-            },
-            disabled: {
-                // 禁用
-                type: Boolean,
-                default: false
-            },
-            readonly: {
-                // 只读
-                type: Boolean,
-                default: false
-            },
-            operation_status: {
-                //编辑
-                type: String,
-                default: 'none'
-            },
-            download: {
-                // 允许下载
-                type: Boolean,
-                default: true
-            },
-            preview: {
-                // 允许预览
-                type: Boolean,
-                default: true
-            },
-            fileSize: {
-                // 上传尺寸
-                type: Number
-            },
-            labelKey: {
-                type: String,
-                default: 'fileName'
-            },
-            valueKey: {
-                type: String,
-                default: 'id'
-            },
-            uploadType: {
-                // 上传方式 ( default:直接打开上传,attachment:ibps上传附件打开上传 )
-                type: String,
-                default: 'attachment'
-            },
-            showExtName: {
-                type: Boolean,
-                default: true
+        storeSeparator: {
+            // 存储值分割符,对应[多选]有效,对于设置字符串类型的分隔符
+            type: String,
+            default: ','
+        },
+        placeholder: {
+            // 输入框占位文本
+            type: String,
+            default: '请选择附件'
+        },
+        multiple: {
+            // 是否多选
+            type: Boolean,
+            default: false
+        },
+        limit: {
+            // 最大允许上传个数
+            type: Number
+        },
+        // 类型,
+        accept: String,
+        fileExt: {
+            type: Array,
+            default: () => []
+        },
+        disabled: {
+            // 禁用
+            type: Boolean,
+            default: false
+        },
+        readonly: {
+            // 只读
+            type: Boolean,
+            default: false
+        },
+        operation_status: {
+            // 编辑
+            type: String,
+            default: 'none'
+        },
+        download: {
+            // 允许下载
+            type: Boolean,
+            default: true
+        },
+        preview: {
+            // 允许预览
+            type: Boolean,
+            default: true
+        },
+        fileSize: {
+            // 上传尺寸
+            type: Number
+        },
+        labelKey: {
+            type: String,
+            default: 'fileName'
+        },
+        valueKey: {
+            type: String,
+            default: 'id'
+        },
+        uploadType: {
+            // 上传方式 ( default:直接打开上传,attachment:ibps上传附件打开上传 )
+            type: String,
+            default: 'attachment'
+        },
+        showExtName: {
+            type: Boolean,
+            default: true
+        }
+    },
+    data () {
+        return {
+            selectorVisible: false,
+            selectorValue: this.multiple ? [] : {},
+            reselect: false, // 重新选择
+            selectorMultiple: this.multiple,
+            index: -1,
+            cacheData: {},
+            attachment: {},
+            filePreviewVisible: false,
+            acceptType: '',
+            showFile: false,
+            file: '',
+            optionFile: {},
+            optionFileView: {}
+        }
+    },
+    computed: {
+        items () {
+            if (this.$utils.isEmpty(this.selectorValue)) return []
+            if (this.multiple) {
+                return this.selectorValue.map(data => {
+                    return data[this.labelKey] + this.getExtName(data)
+                })
+            } else {
+                return [this.selectorValue[this.labelKey] + this.getExtName(this.selectorValue)]
             }
         },
-        data() {
+        uploadStyle () {
+            const { width, height } = this
             return {
-                selectorVisible: false,
-                selectorValue: this.multiple ? [] : {},
-                reselect: false, // 重新选择
-                selectorMultiple: this.multiple,
-                index: -1,
-                cacheData: {},
-                attachment: {},
-                filePreviewVisible: false,
-                acceptType: '',
-                showFile: false,
-                file: '',
-                optionFile: {},
-                optionFileView: {}
+                width: `${width}px`,
+                height: `${height}px`,
+                lineHeight: `${height}px`,
+                display: 'inline'
+            }
+        }
+    },
+    watch: {
+        value (val) {
+            if (this.$utils.isEmpty(this.value)) {
+                this.selectorValue = []
+            } else if (val) {
+                this.initData()
             }
         },
-        computed: {
-            items() {
-                if (this.$utils.isEmpty(this.selectorValue)) return []
-                if (this.multiple) {
-                    return this.selectorValue.map(data => {
-                        return data[this.labelKey] + this.getExtName(data)
-                    })
+        mediaType: {
+            handler: function (val, oldVal) {
+                if (val === 'custom') {
+                    var arr = this.media.split(',')
+                    const accept = '.' + arr.join(',').replace(/,/g, ',.')
+                    this.acceptType = accept
                 } else {
-                    return [ this.selectorValue[this.labelKey] + this.getExtName(this.selectorValue) ]
+                    this.acceptType = this.accept
                 }
             },
-            uploadStyle() {
-                const { width, height } = this
-                return {
-                    width: `${width}px`,
-                    height: `${height}px`,
-                    lineHeight: `${height}px`,
-                    display: 'inline'
-                }
+            immediate: true
+        }
+    },
+    mounted () {
+        this.initData()
+    },
+    methods: {
+        // 替换对应的文件 id  this.optionFile.data.index  为点击编辑时记录的下表号
+        updateFile (data) {
+            if (this.multiple) {
+                this.selectorValue[this.optionFile.data.index].id = data
+            } else {
+                this.selectorValue.id = data
             }
+            this.handleInput()
         },
-        watch: {
-            value(val) {
-                if (this.$utils.isEmpty(this.value)) {
-                    this.selectorValue = []
-                } else if (val) {
-                    this.initData()
-                }
-            },
-            mediaType: {
-                handler: function (val, oldVal) {
-                    if (val === 'custom') {
-                        var arr = this.media.split(',')
-                        const accept = '.' + arr.join(',').replace(/,/g, ',.')
-                        this.acceptType = accept
-                    } else {
-                        this.acceptType = this.accept
-                    }
-                },
-                immediate: true
+        /**
+         * 初始化数据
+         */
+        initData () {
+            const data = this.getArrayValue(this.value)
+            this.selectorValue = this.multiple ? [] : {}
+            if (this.$utils.isEmpty(data)) {
+                return
             }
+            data.forEach(v => {
+                if (this.cacheData[v]) {
+                    this.setSelectorValue(v)
+                } else {
+                    this.getDataInfo(v)
+                }
+            })
         },
-        mounted() {
-            this.initData()
+        setCacheData () {
+            if (this.$utils.isEmpty(this.selectorValue)) return
+            const data = this.multiple ? this.selectorValue : [this.selectorValue]
+            data.forEach(v => {
+                this.cacheData[v[this.valueKey]] = v
+            })
         },
-        methods: {
-            // 替换对应的文件 id  this.optionFile.data.index  为点击编辑时记录的下表号
-            updateFile(data) {
-                if (this.multiple) {
-                    this.selectorValue[this.optionFile.data.index].id = data
+        setSelectorValue (v) {
+            if (this.multiple) {
+                this.selectorValue.push(this.cacheData[v])
+            } else {
+                this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
+            }
+        },
+        /**
+         * 获得数组数据
+         */
+        getArrayValue (value, bindId) {
+            if (this.$utils.isEmpty(value)) {
+                return []
+            }
+            if (this.store === 'json') {
+                // json
+                return this.parseJsonData(value)
+            } else if (this.store === 'id') {
+                // id
+                // 可能是json数据[之前存储的josn格式]
+                if (this.$utils.isJSON(value)) {
+                    return this.parseJsonData(value)
                 } else {
-                    this.selectorValue.id = data
+                    return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
                 }
-                this.handleInput()
-            },
-            /**
-             * 初始化数据
-             */
-            initData() {
-                const data = this.getArrayValue(this.value)
-                this.selectorValue = this.multiple ? [] : {}
-                if (this.$utils.isEmpty(data)) {
-                    return
+            } else if (this.store === 'bind') {
+                // 绑定id
+                if (this.$utils.isEmpty(bindId)) {
+                    return []
                 }
-                data.forEach(v => {
-                    if (this.cacheData[v]) {
-                        this.setSelectorValue(v)
-                    } else {
-                        this.getDataInfo(v)
-                    }
+                return bindId.split(this.storeSeparator)
+            } else {
+                // array
+                return value.map(d => {
+                    return d[this.valueKey]
                 })
-            },
-            setCacheData() {
-                if (this.$utils.isEmpty(this.selectorValue)) return
-                const data = this.multiple ? this.selectorValue : [this.selectorValue]
-                data.forEach(v => {
-                    this.cacheData[v[this.valueKey]] = v
-                })
-            },
-            setSelectorValue(v) {
-                if (this.multiple) {
-                    this.selectorValue.push(this.cacheData[v])
+            }
+        },
+        parseJsonData (value) {
+            try {
+                const data = this.$utils.parseData(value)
+                const result = []
+                if (Array.isArray(data)) {
+                    data.forEach(d => {
+                        const node = d[this.valueKey]
+                        if (node) result.push(node)
+                    })
                 } else {
-                    this.selectorValue = JSON.parse(JSON.stringify(this.cacheData[v]))
-                }
-            },
-            /**
-             * 获得数组数据
-             */
-            getArrayValue(value, bindId) {
-                if (this.$utils.isEmpty(value)) {
-                    return []
-                }
-                if (this.store === 'json') {
-                    // json
-                    return this.parseJsonData(value)
-                } else if (this.store === 'id') {
-                    // id
-                    // 可能是json数据[之前存储的josn格式]
-                    if (this.$utils.isJSON(value)) {
-                        return this.parseJsonData(value)
+                    if (this.$utils.isPlainObject(data)) {
+                        result.push(data[this.valueKey])
                     } else {
-                        return this.$utils.isString(value) ? value.split(this.storeSeparator) : []
-                    }
-                } else if (this.store === 'bind') {
-                    // 绑定id
-                    if (this.$utils.isEmpty(bindId)) {
-                        return []
+                        const realData = this.$utils.isString(value) ? value.split(this.storeSeparator) : []
+                        realData.forEach(v => { result.push(v) })
                     }
-                    return bindId.split(this.storeSeparator)
-                } else {
-                    // array
-                    return value.map(d => {
-                        return d[this.valueKey]
-                    })
                 }
-            },
-            parseJsonData(value) {
-                try {
-                    const data = this.$utils.parseData(value)
-                    const result = []
-                    if (Array.isArray(data)) {
-                        data.forEach(d => {
-                            const node = d[this.valueKey]
-                            if (node) result.push(node)
-                        })
-                    } else {
-                        if (this.$utils.isPlainObject(data)) {
-                            result.push(data[this.valueKey])
-                        } else {
-                            const realData = this.$utils.isString(value) ? value.split(this.storeSeparator) : []
-                            realData.forEach(v => { result.push(v) })
-                        }
-                    }
-                    return result
-                } catch (error) {
-                    console.warn(error)
-                    return []
+                return result
+            } catch (error) {
+                console.warn(error)
+                return []
+            }
+        },
+        getStoreValue (value) {
+            const res = []
+            if (this.store === 'json') {
+                // json
+                if (this.$utils.isEmpty(value)) {
+                    return ''
                 }
-            },
-            getStoreValue(value) {
-                const res = []
-                if (this.store === 'json') {
-                    // json
-                    if (this.$utils.isEmpty(value)) {
-                        return ''
-                    }
-                    if (this.multiple) {
-                        value.forEach(v => {
-                            const o = {}
-                            o[this.valueKey] = v[this.valueKey]
-                            o[this.labelKey] = v[this.labelKey]
-                            res.push(o)
-                        })
-                        return JSON.stringify(res)
-                    } else {
-                        const o = {}
-                        o[this.valueKey] = value[this.valueKey]
-                        o[this.labelKey] = value[this.labelKey]
-                        return JSON.stringify(o)
-                    }
-                } else if (this.store === 'id') {
-                    if (this.$utils.isEmpty(value)) {
-                        return ''
-                    }
-                    if (this.multiple) {
-                        value.forEach(v => {
-                            res.push(v[this.valueKey])
-                        })
-                    } else {
-                        res.push(value[this.valueKey])
-                    }
-                    return res.join(this.storeSeparator)
-                } else if (this.store === 'bind') {
-                    // 绑定id
-                    const res = []
-                    const bindIdValue = []
+                if (this.multiple) {
                     value.forEach(v => {
-                        bindIdValue.push(v[this.valueKey])
-                        res.push(v[this.labelKey])
+                        const o = {}
+                        o[this.valueKey] = v[this.valueKey]
+                        o[this.labelKey] = v[this.labelKey]
+                        res.push(o)
                     })
-                    this.bindIdValue = bindIdValue.join(this.storeSeparator)
-
-                    return res.join(this.storeSeparator)
+                    return JSON.stringify(res)
                 } else {
-                    // 数组 array
-                    return value || []
+                    const o = {}
+                    o[this.valueKey] = value[this.valueKey]
+                    o[this.labelKey] = value[this.labelKey]
+                    return JSON.stringify(o)
                 }
-            },
-            /**
-             * 通过ID获取数据
-             */
-            getDataInfo(id) {
-                if (TRANSFER_DATA === 'transfer') {
-                    this.getTransferData(id)
-                } else {
-                    this.getRemoteData(id)
+            } else if (this.store === 'id') {
+                if (this.$utils.isEmpty(value)) {
+                    return ''
                 }
-            },
-            getTransferData(id) {
-                remoteTransRequest('attachment', id).then(idset => {
-                    const ids = Array.from(idset)
-                    remoteRequest('attachmentIds', ids, () => {
-                        return this.getRemoteTransFunc(ids)
-                    }).then(response => {
-                        const responseData = response.data
-                        const data = responseData[id]
-                        this.setRemoteData(data)
-                    }).catch(() => {})
-                })
-            },
-            getRemoteTransFunc(ids) {
-                return new Promise((resolve, reject) => {
-                    transfer({ ids: ids }).then(response => {
-                        resolve(response)
-                    }).catch((error) => {
-                        reject(error)
+                if (this.multiple) {
+                    value.forEach(v => {
+                        res.push(v[this.valueKey])
                     })
+                } else {
+                    res.push(value[this.valueKey])
+                }
+                return res.join(this.storeSeparator)
+            } else if (this.store === 'bind') {
+                // 绑定id
+                const res = []
+                const bindIdValue = []
+                value.forEach(v => {
+                    bindIdValue.push(v[this.valueKey])
+                    res.push(v[this.labelKey])
                 })
-            },
-            getRemoteData(id) {
-                remoteRequest('attachment' + this.valueKey, id, () => {
-                    return this.getRemoteByIdFunc(id)
+                this.bindIdValue = bindIdValue.join(this.storeSeparator)
+
+                return res.join(this.storeSeparator)
+            } else {
+                // 数组 array
+                return value || []
+            }
+        },
+        /**
+         * 通过ID获取数据
+         */
+        getDataInfo (id) {
+            if (TRANSFER_DATA === 'transfer') {
+                this.getTransferData(id)
+            } else {
+                this.getRemoteData(id)
+            }
+        },
+        getTransferData (id) {
+            remoteTransRequest('attachment', id).then(idset => {
+                const ids = Array.from(idset)
+                remoteRequest('attachmentIds', ids, () => {
+                    return this.getRemoteTransFunc(ids)
                 }).then(response => {
-                    const data = response.data
+                    const responseData = response.data
+                    const data = responseData[id]
                     this.setRemoteData(data)
                 }).catch(() => {})
-            },
-            getRemoteByIdFunc(id) {
-                return new Promise((resolve, reject) => {
-                    get({ attachmentId: id }).then(response => {
-                        resolve(response)
-                    }).catch(() => {})
+            })
+        },
+        getRemoteTransFunc (ids) {
+            return new Promise((resolve, reject) => {
+                transfer({ ids: ids }).then(response => {
+                    resolve(response)
+                }).catch((error) => {
+                    reject(error)
                 })
-            },
-            setRemoteData(data) {
-                if (this.$utils.isNotEmpty(data)) {
-                    this.cacheData[data[this.valueKey]] = data
-                    this.setSelectorValue(data[this.valueKey])
-                }
-            },
-            getExtName(data) {
-                if (!data) {
-                    return ''
-                }
-                if (this.showExtName && data['ext']) {
-                    return '.' + data['ext']
-                }
+            })
+        },
+        getRemoteData (id) {
+            remoteRequest('attachment' + this.valueKey, id, () => {
+                return this.getRemoteByIdFunc(id)
+            }).then(response => {
+                const data = response.data
+                this.setRemoteData(data)
+            }).catch(() => {})
+        },
+        getRemoteByIdFunc (id) {
+            return new Promise((resolve, reject) => {
+                get({ attachmentId: id }).then(response => {
+                    resolve(response)
+                }).catch(() => {})
+            })
+        },
+        setRemoteData (data) {
+            if (this.$utils.isNotEmpty(data)) {
+                this.cacheData[data[this.valueKey]] = data
+                this.setSelectorValue(data[this.valueKey])
+            }
+        },
+        getExtName (data) {
+            if (!data) {
                 return ''
-            },
-            // 事件处理
-            handleActionEvent(action, index, data, type) {
-                this.index = index
-                switch (action) {
-                    case 'select': // 选择
-                        this.selectorVisible = true
-                        this.selectorMultiple = this.multiple
-                        this.reselect = false
-                        this.showFile = false
-                        break
-                    case 'reselect': // 重新选择
-                        this.selectorVisible = true
-                        this.selectorMultiple = false
-                        this.reselect = true
-                        this.showFile = false
-                        break
-                    case 'remove': // 删除
-                        this.handleRemove(index)
-                        this.$refs['attachmentSelector'].init()
-                        break
-                    case 'download': // 下载
-                        this.handleDownload(index)
-                        break
-                    case 'preview': // 预览
-                        this.handlePreview(index)
-                        break
-                    case 'confirm': // 默认上传选择文件
-                        this.handleSelectorActionEvent(action, index)
-                        break
-                    case 'edit': // 编辑
-                        this.handleEdit(index, data, type)
-                        break
-                }
-            },
-            // 处理编辑文件
-            handleEdit(index, data, type) {
-                //1、获取文件数据 及下载流接口
-                this.optionFile.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + data.id
-                this.optionFile.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + data.fileName + '&fileType=' + data.ext + '&type=' + type + '&id=' + data.id
-                this.optionFile.title = data.fileName // 文件名称
-                this.optionFile.fileType = data.ext // 类型
-                this.optionFile.data = data //记录编制的位置,需要替换。
-                this.optionFile.data.index = index
-                //2、显示编辑位置,提交后进行保存
-                if (this.showFile) {
-                    //重复打开,进行刷新子组件
+            }
+            if (this.showExtName && data['ext']) {
+                return '.' + data['ext']
+            }
+            return ''
+        },
+        // 事件处理
+        handleActionEvent (action, index, data, type) {
+            this.index = index
+            switch (action) {
+                case 'select': // 选择
+                    this.selectorVisible = true
+                    this.selectorMultiple = this.multiple
+                    this.reselect = false
                     this.showFile = false
-                } else {
-                    this.showFile = true
-                    // this.timer = setInterval((num)=>{
-                    //     this. test = true
-                    // },10000)
-                }
-            },
-            /**
-             * 处理删除
-             */
-            handleRemove(index) {
-                if (this.multiple) {
-                    this.selectorValue.splice(index, 1)
-                } else {
-                    this.selectorValue = {} //当前为清空
-                }
-                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)) {
-                    this.getPreview(index)
-                } else {
-                    this.$message.closeAll()
-                    this.$message.warning('暂不支持该文件类型预览')
-                }
-            },
-            /**
-             * 处理预览
-             */
-            getPreview(index) {
-                //1、获取文件数据 及下载流接口
-                //下载地址
-                this.optionFileView.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + this.attachment.id
-                // 回调接口url
-                this.optionFileView.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + this.attachment.fileName + '&fileType=' + this.attachment.ext
-                this.optionFileView.title = this.attachment.fileName // 文件名称
-                this.optionFileView.fileType = this.attachment.ext // 类型
-                this.optionFileView.data = this.attachment // 记录编制的位置,需要替换。
-                this.optionFileView.data.index = index
-                // this.optionFileView.previewType = this.pdfPreviewType
-                this.filePreviewVisible = true
-            },
-            /**
-             *  确定
-             */
-            handleSelectorActionEvent(buttonKey, data) {
-                if (this.uploadType === 'default' && this.$utils.isNotEmpty(this.limit) && this.multiple && this.limit < data.length) {
-                    this.$message({
-                        type: 'warning'
-                    })
+                    break
+                case 'reselect': // 重新选择
+                    this.selectorVisible = true
+                    this.selectorMultiple = false
+                    this.reselect = true
+                    this.showFile = false
+                    break
+                case 'remove': // 删除
+                    this.handleRemove(index)
                     this.$refs['attachmentSelector'].init()
-                    return
-                }
-                switch (buttonKey) {
-                    case 'confirm': // 确定
-                        this.selectorVisible = false
-                        if (this.reselect) {
-                            if (this.multiple) {
-                                this.selectorValue.splice(this.index, 1, data)
-                            } else {
-                                this.selectorValue = data
-                            }
+                    break
+                case 'download': // 下载
+                    this.handleDownload(index)
+                    break
+                case 'preview': // 预览
+                    this.handlePreview(index)
+                    break
+                case 'confirm': // 默认上传选择文件
+                    this.handleSelectorActionEvent(action, index)
+                    break
+                case 'edit': // 编辑
+                    this.handleEdit(index, data, type)
+                    break
+            }
+        },
+        // 处理编辑文件
+        handleEdit (index, data, type) {
+            // 1、获取文件数据 及下载流接口
+            this.optionFile.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + data.id
+            this.optionFile.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + data.fileName + '&fileType=' + data.ext + '&type=' + type + '&id=' + data.id
+            this.optionFile.title = data.fileName // 文件名称
+            this.optionFile.fileType = data.ext // 类型
+            this.optionFile.data = data // 记录编制的位置,需要替换。
+            this.optionFile.data.index = index
+            // 2、显示编辑位置,提交后进行保存
+            if (this.showFile) {
+                // 重复打开,进行刷新子组件
+                this.showFile = false
+            } else {
+                this.showFile = true
+                // this.timer = setInterval((num)=>{
+                //     this. test = true
+                // },10000)
+            }
+        },
+        /**
+         * 处理删除
+         */
+        handleRemove (index) {
+            if (this.multiple) {
+                this.selectorValue.splice(index, 1)
+            } else {
+                this.selectorValue = {} // 当前为清空
+            }
+            this.handleInput()
+        },
+        /**
+         * 处理下载
+         */
+        handleDownload (index) {
+            downloadFile(this.multiple ? this.selectorValue[index] : this.selectorValue)
+        },
+        /**
+         * 处理预览
+         */
+        handlePreview (index) {
+            this.attachment = this.multiple ? this.selectorValue[index] : this.selectorValue
+            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()
+                this.$message.warning('暂不支持该文件类型预览')
+            }
+        },
+        /**
+         * 处理预览
+         */
+        getPreview (index) {
+            // 1、获取文件数据 及下载流接口
+            // 下载地址
+            this.optionFileView.url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + this.attachment.id
+            // 回调接口url
+            this.optionFileView.editUrl = BASE_API() + SYSTEM_URL() + '/file/editCallback?fileName=' + this.attachment.fileName + '&fileType=' + this.attachment.ext
+            this.optionFileView.title = this.attachment.fileName // 文件名称
+            this.optionFileView.fileType = this.attachment.ext // 类型
+            this.optionFileView.data = this.attachment // 记录编制的位置,需要替换。
+            this.optionFileView.data.index = index
+            // this.optionFileView.previewType = this.pdfPreviewType
+            this.filePreviewVisible = true
+        },
+        /**
+         *  确定
+         */
+        handleSelectorActionEvent (buttonKey, data) {
+            if (this.uploadType === 'default' && this.$utils.isNotEmpty(this.limit) && this.multiple && this.limit < data.length) {
+                this.$message({
+                    type: 'warning'
+                })
+                this.$refs['attachmentSelector'].init()
+                return
+            }
+            switch (buttonKey) {
+                case 'confirm': // 确定
+                    this.selectorVisible = false
+                    if (this.reselect) {
+                        if (this.multiple) {
+                            this.selectorValue.splice(this.index, 1, data)
                         } else {
                             this.selectorValue = data
                         }
-                        this.setCacheData()
-                        this.handleInput()
-                        break
-                }
-            },
-            handleInput() {
-                this.$emit('input', this.getStoreValue(this.selectorValue))
-                // 提供一个返回实体,提供调用
-                this.$emit('callback', this.selectorValue)
-            },
-            /**
-             * 文件上传
-             */
-            httpRequest(options) {
-                return uploadFile(options.file, {})
-            },
-            handleDelete(file, selectorValue) {
-                this.selectorValue = selectorValue
-            },
-            handleSuccess(response, file, selectorValue) {
-                this.selectorValue = selectorValue.map(item => {
-                    item.isActive = false
-                    return item
+                    } else {
+                        this.selectorValue = data
+                    }
+                    this.setCacheData()
+                    this.handleInput()
+                    break
+            }
+        },
+        handleInput () {
+            this.$emit('input', this.getStoreValue(this.selectorValue))
+            // 提供一个返回实体,提供调用
+            this.$emit('callback', this.selectorValue)
+        },
+        /**
+         * 文件上传
+         */
+        httpRequest (options) {
+            return uploadFile(options.file, {})
+        },
+        handleDelete (file, selectorValue) {
+            this.selectorValue = selectorValue
+        },
+        handleSuccess (response, file, selectorValue) {
+            this.selectorValue = selectorValue.map(item => {
+                item.isActive = false
+                return item
+            })
+        },
+        handleChange (file, selectorValue) {
+            this.selectorValue = selectorValue
+        },
+        // 图片上传数量限制
+        handlePicAmount (files, selectorValue) {
+            if (this.multiple && this.limit) {
+                this.$message.closeAll()
+                this.$message({
+                    message: `图片上传上限${this.limit}张`,
+                    type: 'warning'
                 })
-            },
-            handleChange(file, selectorValue) {
-                this.selectorValue = selectorValue
-            },
-            // 图片上传数量限制
-            handlePicAmount(files, selectorValue) {
-                if (this.multiple && this.limit) {
-                    this.$message.closeAll()
-                    this.$message({
-                        message: `图片上传上限${this.limit}张`,
-                        type: 'warning'
-                    })
-                }
-            },
-            // 格式、大小限制
-            beforeUpload(file) {
-                const isType = this.accept ? file.type.includes(this.accept) : true
-                if (!isType) {
-                    this.$message.closeAll()
-                    this.$message.error(`上传图片的格式为${this.accept}`)
-                }
-                const isLimitSize = this.size ? (file.size / 1024 / 1024 < this.size) : true
-                if (!isLimitSize) {
-                    this.$message.closeAll()
-                    this.$message.error(`上传图片的大小不能超过 ${this.size}M!`)
-                }
-                return isLimitSize && isType
             }
+        },
+        // 格式、大小限制
+        beforeUpload (file) {
+            const isType = this.accept ? file.type.includes(this.accept) : true
+            if (!isType) {
+                this.$message.closeAll()
+                this.$message.error(`上传图片的格式为${this.accept}`)
+            }
+            const isLimitSize = this.size ? (file.size / 1024 / 1024 < this.size) : true
+            if (!isLimitSize) {
+                this.$message.closeAll()
+                this.$message.error(`上传图片的大小不能超过 ${this.size}M!`)
+            }
+            return isLimitSize && isType
         }
     }
+}
 </script>
 <style scoped>
     .divShow {

+ 35 - 21
src/views/platform/bpmn/bpmInstHis/record/component/testingRecord.vue

@@ -28,7 +28,7 @@
                     @change="search"
                 />
             </div>
-            <el-button class="btn" type="primary" @click="search"> <i class="ibps-icon-search"></i>查询 </el-button>
+            <el-button class="btn" type="primary" @click="search"> <i class="ibps-icon-search" />查询 </el-button>
         </div>
         <div class="table-container">
             <el-table
@@ -42,29 +42,29 @@
                 @sort-change="sortChange"
             >
                 <!-- <el-table-column type="selection" width="55"></el-table-column> -->
-                <el-table-column prop="he_tong_bian_hao_" label="合同编号" sortable width="110"></el-table-column>
-                <el-table-column prop="wei_tuo_bian_hao_" label="委托单号" sortable width="110"></el-table-column>
-                <el-table-column prop="bao_gao_bian_hao_" label="报告编号" sortable width="120"></el-table-column>
-                <el-table-column prop="run_qian_lu_jing_" label="版本号" width="100"></el-table-column>
+                <el-table-column prop="he_tong_bian_hao_" label="合同编号" sortable width="110" />
+                <el-table-column prop="wei_tuo_bian_hao_" label="委托单号" sortable width="110" />
+                <el-table-column prop="bao_gao_bian_hao_" label="报告编号" sortable width="120" />
+                <el-table-column prop="run_qian_lu_jing_" label="版本号" width="100" />
                 <!-- <el-table-column prop="wei_tuo_fang_" label="委托单位"></el-table-column> -->
                 <!-- <el-table-column prop="wan_cheng_shi_jia" label="委托日期" width="100"></el-table-column> -->
-                <el-table-column prop="yang_pin_bian_hao" label="样品编号" sortable width="120"></el-table-column>
-                <el-table-column prop="yang_pin_ming_che" label="样品名称" sortable width="150"></el-table-column>
-                <el-table-column prop="song_jian_" label="送检单位" width="150"></el-table-column>
-                <el-table-column prop="song_jian_shi_jia" label="送检日期" sortable width="120"></el-table-column>
+                <el-table-column prop="yang_pin_bian_hao" label="样品编号" sortable width="120" />
+                <el-table-column prop="yang_pin_ming_che" label="样品名称" sortable width="150" />
+                <el-table-column prop="song_jian_" label="送检单位" width="150" />
+                <el-table-column prop="song_jian_shi_jia" label="送检日期" sortable width="120" />
                 <el-table-column label="检测时间" width="100">
                     <template slot-scope="scope">{{ getTestTime(scope.row) }}</template>
                 </el-table-column>
-                <el-table-column prop="gai_zhang_jian_pd" label="检测项目" minWidth="200"></el-table-column>
+                <el-table-column prop="gai_zhang_jian_pd" label="检测项目" min-width="200" />
                 <el-table-column label="操作" align="left" width="100">
                     <template slot-scope="scope">
                         <el-popover placement="left" width="150" trigger="click">
-                            <div slot="reference" class="more"><i class="el-icon-caret-bottom"></i>查阅</div>
+                            <div slot="reference" class="more"><i class="el-icon-caret-bottom" />查阅</div>
                             <template v-for="(item, index) in reportList">
                                 <!-- 检测记录 -->
                                 <div v-if="item.key === 'testing'">
                                     <el-popover placement="left" width="300" trigger="click" :visible="visibleKey === item.key">
-                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getTesting')"><i class="ibps-icon-folder"></i> {{ item.name }}</div>
+                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getTesting')"><i class="ibps-icon-folder" /> {{ item.name }}</div>
                                         <div class="three-item">
                                             <div v-for="i in testingList" :key="i.id" class="operate-item" @click="consult(i)">
                                                 {{ i.projectName }}
@@ -74,18 +74,18 @@
                                 </div>
                                 <div v-else-if="item.key === 'file'">
                                     <el-popover placement="left" width="300" trigger="click" :visible="visibleKey === item.key">
-                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getFile')"><i class="ibps-icon-folder"></i> {{ item.name }}</div>
+                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getFile')"><i class="ibps-icon-folder" /> {{ item.name }}</div>
                                         <div class="three-item">
                                             <div v-for="(project, index) in fileList" :key="index">
                                                 <div class="project-name">{{ project.projectName }}</div>
                                                 <div v-for="file in project.files" :key="file.id" class="operate-item">
                                                     <div class="file-item">
-                                                        <i class="ibps-icon-file-text-o"></i>
+                                                        <i class="ibps-icon-file-text-o" />
                                                         <el-tooltip effect="dark" placement="top">
                                                             <div slot="content">{{ file.fileName }}.{{ file.ext }}</div>
                                                             <span @click="preview(file)">{{ file.fileName }}.{{ file.ext }}</span>
                                                         </el-tooltip>
-                                                        <i v-if="hasRole" class="el-icon-download" @click="download(file)"></i>
+                                                        <i v-if="hasRole" class="el-icon-download" @click="download(file)" />
                                                     </div>
                                                 </div>
                                             </div>
@@ -94,22 +94,22 @@
                                 </div>
                                 <div v-else-if="item.key === 'report'">
                                     <el-popover placement="left" width="300" trigger="click" :visible="visibleKey === item.key">
-                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getFile')"><i class="ibps-icon-folder"></i> {{ item.name }}</div>
+                                        <div slot="reference" class="operate-item" @click="visablePopover(scope.row, item.key, 'getFile')"><i class="ibps-icon-folder" /> {{ item.name }}</div>
                                         <div class="three-item">
                                             <div v-for="i in reportFileList" :key="i.id" class="operate-item">
                                                 <div class="file-item">
-                                                    <i class="ibps-icon-file-text-o"></i>
+                                                    <i class="ibps-icon-file-text-o" />
                                                     <el-tooltip effect="dark" placement="top">
                                                         <div slot="content">{{ i.fileName }}.{{ i.ext }}</div>
                                                         <span @click="preview(i)">{{ i.fileName }}.{{ i.ext }}</span>
                                                     </el-tooltip>
-                                                    <i v-if="hasRole" class="el-icon-download" @click="download(i)"></i>
+                                                    <i v-if="hasRole" class="el-icon-download" @click="download(i)" />
                                                 </div>
                                             </div>
                                         </div>
                                     </el-popover>
                                 </div>
-                                <div v-else :key="index" class="operate-item" @click="alertReport(item.path, scope.row[item.key])"><i class="ibps-icon-file-text"></i> {{ item.name }}</div>
+                                <div v-else :key="index" class="operate-item" @click="alertReport(item.path, scope.row[item.key])"><i class="ibps-icon-file-text" /> {{ item.name }}</div>
                             </template>
                         </el-popover>
                     </template>
@@ -137,7 +137,7 @@
                 :total="total"
                 @size-change="handleSizeChange"
                 @current-change="handleCurrentChange"
-            ></el-pagination>
+            />
         </div>
         <image-viewer
             v-if="fileType === 'image'"
@@ -374,7 +374,7 @@ export default {
                         files: fileInfo.filter(k => [i.fu_tu_id_, i.wen_dang_fu_jian_, i.kuai_zhao_fu_jian].filter(i => i).join(',').includes(k.id))
                     }))
                     if (addFileId.length) {
-                        this.fileList.push({    
+                        this.fileList.push({
                             projectName: '新增附件',
                             files: fileInfo.filter(k => addFileId.includes(k.id))
                         })
@@ -432,6 +432,20 @@ export default {
                 this.zIndex = PopupManager.getZIndex()
                 this.fileUrl = previewFile(file.id)
                 this.fileType = 'image'
+            } else if (file.ext === 'pdf' || file.ext === 'PDF') {
+                this.$nextTick(() => {
+                    const newTab = window.open()
+                    const link = newTab.document.createElement('link')
+                    const url = BASE_API() + SYSTEM_URL() + '/file/download?attachmentId=' + file.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>文件预览页-${file.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";>`)
+                })
             } else {
                 this.getOption(file)
                 this.openWindow()

+ 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 {