lilei 1 yıl önce
ebeveyn
işleme
fda33cfeb8

+ 5 - 0
package-lock.json

@@ -15710,6 +15710,11 @@
         "is-plain-obj": "^1.0.0"
       }
     },
+    "sortablejs": {
+      "version": "1.15.0",
+      "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.15.0.tgz",
+      "integrity": "sha512-bv9qgVMjUMf89wAvM6AxVvS/4MX3sPeN0+agqShejLU5z5GX4C75ow1O2e5k4L6XItUyAK3gH6AxSbXrOM5e8w=="
+    },
     "source-list-map": {
       "version": "2.0.1",
       "resolved": "https://registry.npmjs.org/source-list-map/-/source-list-map-2.0.1.tgz",

+ 2 - 1
package.json

@@ -28,7 +28,9 @@
     "mockjs2": "1.0.7",
     "moment": "^2.24.0",
     "nprogress": "^0.2.0",
+    "pdfjs-dist": "2.5.207",
     "screenfull": "^5.1.0",
+    "sortablejs": "^1.15.0",
     "v-runtime-template": "^1.10.0",
     "v-viewer": "^1.6.4",
     "viser-vue": "^2.4.6",
@@ -38,7 +40,6 @@
     "vue-cropper": "0.4.9",
     "vue-easytable": "^2.27.1",
     "vue-ls": "^3.2.1",
-    "pdfjs-dist": "2.5.207",
     "vue-pdf-signature": "^4.2.6",
     "vue-piczoom": "^1.0.6",
     "vue-quill-editor": "^3.0.6",

+ 29 - 3
src/components/UploadFile/index.vue

@@ -22,12 +22,15 @@
       </div>
     </a-upload>
     <a-modal :visible="previewVisible" :footer="null" centered :maskClosable="false" @cancel="handleCancel">
+      <div style="height: 30px;">预览</div>
       <video v-if="fileType=='video/mp4'" controls="controls" style="width: 100%" :src="previewImage" />
       <img v-else alt="example" style="width: 100%" :src="previewImage" />
     </a-modal>
   </div>
 </template>
 <script>
+import Sortable from 'sortablejs'
+import { moveElement } from '@/libs/tools'
 export default {
   name: 'Upload',
   props: {
@@ -101,6 +104,24 @@ export default {
       }
     }
   },
+  created(){
+    let _this = this
+    this.$nextTick(()=>{
+      let el = document.querySelector('.ant-upload-list-picture-card');
+      let sortable = Sortable.create(el,{
+        onEnd:function(evt){
+          console.log(evt.oldIndex,evt.newIndex)
+          const a =_this.formatFile()
+          console.log(a.split(','))
+          const ret = moveElement(a.split(','),evt.oldIndex,evt.newIndex)
+          console.log(ret)
+           
+          _this.$emit('change', ret.join(','))
+          _this.$emit('input', ret.join(','))
+        }
+      });
+    })
+  },
   methods: {
     setFileList (a) {
       const temp = []
@@ -174,7 +195,7 @@ export default {
         if (file.status == 'error' || file.status == 'done') {
           this.$message.error(file.response.message || '上传失败,请重试!')
           this.$emit('remove')
-          return
+          // return
         }
       }
       this.fileList = this.validaFile(file, fileList)
@@ -204,7 +225,7 @@ export default {
               }
             }
           })
-          console.log(temp)
+          // console.log(temp)
           obj = JSON.stringify(temp)
         }
       }
@@ -216,7 +237,7 @@ export default {
         return []
       }
       // console.log(file, filesList, this.beforeUpload(file, 0))
-      if (!this.beforeUpload(file, 0) && file.status != 'removed') {
+      if (!this.beforeUpload(file, 0) && file.status != 'removed' || file.status == 'error') {
         const index = filesList.findIndex(item => item.uid == file.uid)
         filesList.splice(index, 1)
       }
@@ -306,6 +327,11 @@ export default {
       max-height:860px;
       text-align:center;
   }
+/deep/.ant-modal-close-x{
+        height: 35px;
+        line-height: 35px;
+        width: 35px;
+      }
  /deep/.ant-modal-body video{
     width: 90% !important;
   }

+ 6 - 0
src/libs/tools.js

@@ -505,4 +505,10 @@ export const removeEmptyStr = function(str){
     return strs;
   }
   return '';
+}
+// 移动数组项
+export const moveElement = function (arr, fromIndex, toIndex) {
+  const element = arr.splice(fromIndex, 1)[0];
+  arr.splice(toIndex, 0, element);
+  return arr;
 }

+ 1 - 0
src/views/productManagement/productInfo/edit.vue

@@ -363,6 +363,7 @@ export default {
     },
     // 产品图片上传
     changeImage (file) {
+      console.log(file.split(","))
       this.form.productMsg = file
     },
     validateQrCode (rule, value, callback) {