|
|
@@ -56,127 +56,127 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { get } from '@/api/platform/file/attachment'
|
|
|
- import { downloadFile } from '@/business/platform/file/utils'
|
|
|
- import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
|
|
|
- import { fileTypes } from '@/business/platform/file/constants/fileTypes'
|
|
|
+import { get } from '@/api/platform/file/attachment'
|
|
|
+import { downloadFile } from '@/business/platform/file/utils'
|
|
|
+import { SYSTEM_URL, BASE_API } from '@/api/baseUrl'
|
|
|
+import { fileTypes } from '@/business/platform/file/constants/fileTypes'
|
|
|
|
|
|
- export default {
|
|
|
- props: {
|
|
|
- visible: {
|
|
|
- type: Boolean,
|
|
|
- default: false
|
|
|
- },
|
|
|
- id: String,
|
|
|
- data: [Object, String]
|
|
|
+export default {
|
|
|
+ props: {
|
|
|
+ visible: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
},
|
|
|
- data() {
|
|
|
- return {
|
|
|
- formName: 'attachmentForm',
|
|
|
- title: '系统附件明细',
|
|
|
- formLabelWidth: '120px',
|
|
|
- dialogVisible: this.visible,
|
|
|
- dialogLoading: false,
|
|
|
- filePreviewVisible: false,
|
|
|
- attachment: {
|
|
|
- fileName: '',
|
|
|
- typeId: '',
|
|
|
- fileType: '',
|
|
|
- filePath: '',
|
|
|
- createTime: '',
|
|
|
- storeType: '',
|
|
|
- totalBytes: '',
|
|
|
- ext: '',
|
|
|
- note: '',
|
|
|
- creatorName: ''
|
|
|
- },
|
|
|
- toolbars: [
|
|
|
- { key: 'primary', icon: 'ibps-icon-eye', label: '预览' },
|
|
|
- {
|
|
|
- key: 'download',
|
|
|
- icon: 'ibps-icon-download',
|
|
|
- label: '下载'
|
|
|
- },
|
|
|
- { key: 'cancel' }
|
|
|
- ],
|
|
|
- fileOption: {
|
|
|
- user: {}
|
|
|
- }
|
|
|
+ id: String,
|
|
|
+ data: [Object, String]
|
|
|
+ },
|
|
|
+ data () {
|
|
|
+ return {
|
|
|
+ formName: 'attachmentForm',
|
|
|
+ title: '系统附件明细',
|
|
|
+ formLabelWidth: '120px',
|
|
|
+ dialogVisible: this.visible,
|
|
|
+ dialogLoading: false,
|
|
|
+ filePreviewVisible: false,
|
|
|
+ attachment: {
|
|
|
+ fileName: '',
|
|
|
+ typeId: '',
|
|
|
+ fileType: '',
|
|
|
+ filePath: '',
|
|
|
+ createTime: '',
|
|
|
+ storeType: '',
|
|
|
+ totalBytes: '',
|
|
|
+ ext: '',
|
|
|
+ note: '',
|
|
|
+ creatorName: ''
|
|
|
+ },
|
|
|
+ toolbars: [
|
|
|
+ // { key: 'primary', icon: 'ibps-icon-eye', label: '预览' },
|
|
|
+ // {
|
|
|
+ // key: 'download',
|
|
|
+ // icon: 'ibps-icon-download',
|
|
|
+ // label: '下载'
|
|
|
+ // },
|
|
|
+ { key: 'cancel', label: '关闭' }
|
|
|
+ ],
|
|
|
+ fileOption: {
|
|
|
+ user: {}
|
|
|
}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ formId () {
|
|
|
+ return this.id
|
|
|
},
|
|
|
- computed: {
|
|
|
- formId() {
|
|
|
- return this.id
|
|
|
- },
|
|
|
- formData() {
|
|
|
- return this.data
|
|
|
+ formData () {
|
|
|
+ return this.data
|
|
|
+ }
|
|
|
+ },
|
|
|
+ watch: {
|
|
|
+ visible: {
|
|
|
+ handler: function (val, oldVal) {
|
|
|
+ this.dialogVisible = this.visible
|
|
|
+ console.log(this.data)
|
|
|
+ }
|
|
|
+ // immediate: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ created () {
|
|
|
+ this.getFormData()
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ handleActionEvent ({ key }) {
|
|
|
+ switch (key) {
|
|
|
+ case 'primary':
|
|
|
+ this.filePreview()
|
|
|
+ break
|
|
|
+ case 'download':
|
|
|
+ this.handleDownload()
|
|
|
+ break
|
|
|
+ case 'cancel':
|
|
|
+ this.closeDialog()
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
}
|
|
|
},
|
|
|
- watch: {
|
|
|
- visible: {
|
|
|
- handler: function (val, oldVal) {
|
|
|
- this.dialogVisible = this.visible
|
|
|
- console.log(this.data)
|
|
|
- }
|
|
|
- // immediate: true
|
|
|
+ handleDownload () {
|
|
|
+ downloadFile(this.attachment)
|
|
|
+ },
|
|
|
+ // 获取明细数据
|
|
|
+ getFormData () {
|
|
|
+ if (this.$utils.isEmpty(this.formId)) {
|
|
|
+ return
|
|
|
}
|
|
|
+ get({ attachmentId: this.formId }).then((response) => {
|
|
|
+ this.attachment = response.data
|
|
|
+ }).catch(() => {})
|
|
|
},
|
|
|
- created() {
|
|
|
- this.getFormData()
|
|
|
+ // 关闭当前窗口
|
|
|
+ closeDialog () {
|
|
|
+ this.$emit('close', false)
|
|
|
},
|
|
|
- methods: {
|
|
|
- handleActionEvent({ key }) {
|
|
|
- switch (key) {
|
|
|
- case 'primary':
|
|
|
- this.filePreview()
|
|
|
- break
|
|
|
- case 'download':
|
|
|
- this.handleDownload()
|
|
|
- break
|
|
|
- case 'cancel':
|
|
|
- this.closeDialog()
|
|
|
- break
|
|
|
- default:
|
|
|
- break
|
|
|
- }
|
|
|
- },
|
|
|
- handleDownload() {
|
|
|
- downloadFile(this.attachment)
|
|
|
- },
|
|
|
- // 获取明细数据
|
|
|
- getFormData() {
|
|
|
- if (this.$utils.isEmpty(this.formId)) {
|
|
|
- return
|
|
|
- }
|
|
|
- get({ attachmentId: this.formId }).then((response) => {
|
|
|
- this.attachment = response.data
|
|
|
- }).catch(() => {})
|
|
|
- },
|
|
|
- // 关闭当前窗口
|
|
|
- closeDialog() {
|
|
|
- this.$emit('close', false)
|
|
|
- },
|
|
|
- filePreview () {
|
|
|
- const { id, fileName, ext } = this.data
|
|
|
- if (fileTypes.images.includes(ext)) {
|
|
|
- this.$message.warning('图片附件请直接在列表预览!')
|
|
|
- return
|
|
|
- }
|
|
|
- this.fileOption.user.id = this.$store.getters.userId
|
|
|
- this.fileOption.user.name = this.$store.getters.name
|
|
|
- this.fileOption.url = BASE_API() + SYSTEM_URL() + `/file/download?attachmentId=${id}`
|
|
|
- this.fileOption.editUrl = BASE_API() + SYSTEM_URL() + `/file/editCallback?fileName=${fileName}&fileType=${ext}&id=${id}`
|
|
|
- this.fileOption.title = fileName
|
|
|
- this.fileOption.fileType = ext
|
|
|
- // console.log(this.fileOption)
|
|
|
- let routeData = this.$router.resolve({
|
|
|
- path: '/fileView',
|
|
|
- query: this.fileOption
|
|
|
- })
|
|
|
- window.open(routeData.href)
|
|
|
+ filePreview () {
|
|
|
+ const { id, fileName, ext } = this.data
|
|
|
+ if (fileTypes.images.includes(ext)) {
|
|
|
+ this.$message.warning('图片附件请直接在列表预览!')
|
|
|
+ return
|
|
|
}
|
|
|
+ this.fileOption.user.id = this.$store.getters.userId
|
|
|
+ this.fileOption.user.name = this.$store.getters.name
|
|
|
+ this.fileOption.url = BASE_API() + SYSTEM_URL() + `/file/download?attachmentId=${id}`
|
|
|
+ this.fileOption.editUrl = BASE_API() + SYSTEM_URL() + `/file/editCallback?fileName=${fileName}&fileType=${ext}&id=${id}`
|
|
|
+ this.fileOption.title = fileName
|
|
|
+ this.fileOption.fileType = ext
|
|
|
+ // console.log(this.fileOption)
|
|
|
+ const routeData = this.$router.resolve({
|
|
|
+ path: '/fileView',
|
|
|
+ query: this.fileOption
|
|
|
+ })
|
|
|
+ window.open(routeData.href)
|
|
|
}
|
|
|
}
|
|
|
+}
|
|
|
</script>
|
|
|
<style lang="scss">
|
|
|
.attachment-detail-dialog {
|