Browse Source

附件添加预览功能

董玉雪 10 months ago
parent
commit
5a4be4154c
1 changed files with 34 additions and 15 deletions
  1. 34 15
      src/common/components/sd-attachment.vue

+ 34 - 15
src/common/components/sd-attachment.vue

@@ -19,7 +19,7 @@
                   (`api/framework/v1/task-form-process/download-attachments/` + item.code)
                   (`api/framework/v1/task-form-process/download-attachments/` + item.code)
                     | sdResource
                     | sdResource
                 "
                 "
-                class="ant-upload-list-item-image"/></a
+                class="ant-upload-list-item-image" /></a
           ></div>
           ></div>
           <span class="ant-upload-list-item-actions"
           <span class="ant-upload-list-item-actions"
             ><a class="prebtnatt" @click="showEye">
             ><a class="prebtnatt" @click="showEye">
@@ -175,9 +175,9 @@
             <a-tooltip
             <a-tooltip
               v-if="
               v-if="
                 ['0', '-4'].includes(item.CatNum) &&
                 ['0', '-4'].includes(item.CatNum) &&
-                  computedFjList.length > 1 &&
-                  _sortable &&
-                  !formReadOnly
+                computedFjList.length > 1 &&
+                _sortable &&
+                !formReadOnly
               "
               "
               placement="right"
               placement="right"
               title="拖拽排序"
               title="拖拽排序"
@@ -186,6 +186,9 @@
                 <a-icon type="sd-swap"
                 <a-icon type="sd-swap"
               /></a>
               /></a>
             </a-tooltip>
             </a-tooltip>
+            <a-tooltip v-if="item.Completed && item.deletable" placement="top" title="预览">
+              <a-button icon="sd-desktop" type="link" @click="preview(item)" />
+            </a-tooltip>
           </div>
           </div>
         </a-list-item>
         </a-list-item>
       </sd-draggable>
       </sd-draggable>
@@ -339,7 +342,7 @@ export default {
      */
      */
     uploadable: {
     uploadable: {
       type: [Boolean, String],
       type: [Boolean, String],
-      default: function() {
+      default: function () {
         return !this.readOnly
         return !this.readOnly
       },
       },
     },
     },
@@ -348,7 +351,7 @@ export default {
      */
      */
     zwUploadable: {
     zwUploadable: {
       type: [Boolean, String],
       type: [Boolean, String],
-      default: function() {
+      default: function () {
         return !this.readOnly
         return !this.readOnly
       },
       },
     },
     },
@@ -357,7 +360,7 @@ export default {
      */
      */
     sortable: {
     sortable: {
       type: [Boolean, String],
       type: [Boolean, String],
-      default: function() {
+      default: function () {
         return !this.readOnly
         return !this.readOnly
       },
       },
     },
     },
@@ -366,7 +369,7 @@ export default {
      */
      */
     initValue: {
     initValue: {
       type: Array,
       type: Array,
-      default: function() {
+      default: function () {
         return this.webflow.FlowData?.processFormData.processFormPropertyValues.find((item) => {
         return this.webflow.FlowData?.processFormData.processFormPropertyValues.find((item) => {
           return item.value?.indexOf?.(this.groupId) > -1
           return item.value?.indexOf?.(this.groupId) > -1
         })?.attr?.attachments
         })?.attr?.attachments
@@ -377,7 +380,7 @@ export default {
      */
      */
     infoProperties: {
     infoProperties: {
       type: Object,
       type: Object,
-      default: function() {
+      default: function () {
         return (
         return (
           this.webflow.FlowData?.processFormData.processFormPropertyValues.find((item) => {
           this.webflow.FlowData?.processFormData.processFormPropertyValues.find((item) => {
             return item.value?.indexOf?.(this.groupId) > -1
             return item.value?.indexOf?.(this.groupId) > -1
@@ -430,12 +433,12 @@ export default {
     },
     },
     computedFjList: {
     computedFjList: {
       // 附件
       // 附件
-      get: function() {
+      get: function () {
         return this.attachmentsList.filter((item) =>
         return this.attachmentsList.filter((item) =>
           ['0', '-5', '-6'].includes(item.CatNum.toString())
           ['0', '-5', '-6'].includes(item.CatNum.toString())
         )
         )
       },
       },
-      set: function(newValue) {
+      set: function (newValue) {
         this.attachments = [
         this.attachments = [
           ...this.computedZwList,
           ...this.computedZwList,
           ...newValue,
           ...newValue,
@@ -542,10 +545,7 @@ export default {
     },
     },
     // 选择文件后上传、附件图标颜色
     // 选择文件后上传、附件图标颜色
     getIcon(fname) {
     getIcon(fname) {
-      const suffix = fname
-        .split('.')
-        .pop()
-        .toLowerCase()
+      const suffix = fname.split('.').pop().toLowerCase()
       if (['doc', 'docx'].includes(suffix)) {
       if (['doc', 'docx'].includes(suffix)) {
         return 'file-word'
         return 'file-word'
       }
       }
@@ -693,6 +693,25 @@ export default {
     filesChanged() {
     filesChanged() {
       this.$emit('change', this.attachments)
       this.$emit('change', this.attachments)
     },
     },
+    preview(file) {
+      const storeName = 'iamAttachment'
+      const fileId = file.Unid
+      axios
+        .get(`api/xcoa-mobile/v1/wps/preview/url/${storeName}/${fileId}`)
+        .then((_) => {
+          const data = _.data
+          console.log(data)
+          if (data.status === 'error') {
+            alert(data.message)
+          } else {
+            window.open(data.previewLink, '_blank')
+          }
+        })
+        .catch((e) => {
+          console.log('get preview url error', e)
+          alert('预览功能错误')
+        })
+    },
     DelFile(file) {
     DelFile(file) {
       Modal.confirm({
       Modal.confirm({
         title: `确认删除附件《${file.FileName}》?`,
         title: `确认删除附件《${file.FileName}》?`,