فهرست منبع

improve: 上传

From-wh 2 سال پیش
والد
کامیت
7e6c8d9a68

+ 2 - 2
template/admin/src/api/setting.js

@@ -1126,9 +1126,9 @@ export function codeCrud(data) {
 /**
 /**
  * @description 扫码上传链接获取
  * @description 扫码上传链接获取
  */
  */
-export function scanUploadQrcode() {
+export function scanUploadQrcode(pid) {
   return request({
   return request({
-    url: `file/scan_upload/qrcode`,
+    url: `file/scan_upload/qrcode?pid=${pid}`,
     method: 'get',
     method: 'get',
   });
   });
 }
 }

+ 36 - 15
template/admin/src/components/uploadImg/index.vue

@@ -1,11 +1,12 @@
 <template>
 <template>
-  <div>
+  <div v-if="uploadModal">
     <el-dialog
     <el-dialog
       title="上传图片"
       title="上传图片"
       append-to-body
       append-to-body
       :modal-append-to-body="false"
       :modal-append-to-body="false"
       :visible.sync="uploadModal"
       :visible.sync="uploadModal"
       width="1024px"
       width="1024px"
+      :fullscreen="!isPage"
       @closed="closed"
       @closed="closed"
     >
     >
       <div class="main" v-loading="loading">
       <div class="main" v-loading="loading">
@@ -57,7 +58,7 @@
                     @dragend="handleDragEnd($event, file)"
                     @dragend="handleDragEnd($event, file)"
                   >
                   >
                     <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
                     <img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
-                    <i class="el-icon-error btndel" @click="handleRemove(file)" />
+                    <i class="el-icon-error btndel" @click="handleWebRemove(file)" />
                   </div>
                   </div>
                 </el-upload>
                 </el-upload>
                 <div class="tips">建议上传图片最大宽度750px,不超过3MB;仅支持jpeg、png格式</div>
                 <div class="tips">建议上传图片最大宽度750px,不超过3MB;仅支持jpeg、png格式</div>
@@ -82,7 +83,7 @@
             </div>
             </div>
           </template>
           </template>
         </el-form>
         </el-form>
-        <div class="code-image" v-show="ruleForm.type == 2">
+        <div class="code-image" v-if="ruleForm.type == 2">
           <div class="left">
           <div class="left">
             <div class="code" ref="qrCodeUrl"></div>
             <div class="code" ref="qrCodeUrl"></div>
             <el-cascader
             <el-cascader
@@ -109,7 +110,7 @@
                 @dragend="handleDragEnd($event, item)"
                 @dragend="handleDragEnd($event, item)"
               >
               >
                 <img :src="item.att_dir" />
                 <img :src="item.att_dir" />
-                <i class="el-icon-error btndel" @click="handleRemove(index)" />
+                <i class="el-icon-error btndel" @click="handleWebRemove(item)" />
               </div>
               </div>
             </div>
             </div>
           </div>
           </div>
@@ -140,6 +141,21 @@ export default {
         return [];
         return [];
       },
       },
     },
     },
+    categoryId: {
+      default: '',
+    },
+    isPage: {
+      default: false,
+    },
+  },
+  watch: {
+    categoryId: {
+      handler(newVal) {
+        this.ruleForm.region = newVal;
+        console.log('diaole ');
+      },
+      immediate: true,
+    },
   },
   },
   data() {
   data() {
     return {
     return {
@@ -150,14 +166,14 @@ export default {
         'Authori-zation': 'Bearer ' + getCookies('token'),
         'Authori-zation': 'Bearer ' + getCookies('token'),
       },
       },
       uploadData: {},
       uploadData: {},
-      props: { label: 'title', value: 'id', multiple: false, checkStrictly: true, lazy: true, lazyLoad: this.loadData },
+      props: { checkStrictly: true, emitPath: false, label: 'title', value: 'id' },
       disabled: false,
       disabled: false,
       ruleForm: {
       ruleForm: {
         type: 0,
         type: 0,
+        region: '',
         imgList: [],
         imgList: [],
       },
       },
       rules: { type: [{ required: true, message: '请选择活动资源', trigger: 'change' }] },
       rules: { type: [{ required: true, message: '请选择活动资源', trigger: 'change' }] },
-      treeId: '',
       qrcode: '',
       qrcode: '',
       scanToken: '',
       scanToken: '',
       limit: 20,
       limit: 20,
@@ -169,6 +185,9 @@ export default {
   methods: {
   methods: {
     closed() {
     closed() {
       this.ruleForm.type = 0;
       this.ruleForm.type = 0;
+      this.ruleForm.region = 0;
+      this.scanToken = '';
+      this.webImgUrl = '';
       this.ruleForm.imgList = [];
       this.ruleForm.imgList = [];
       scanUploadCode().then((res) => {});
       scanUploadCode().then((res) => {});
     },
     },
@@ -180,7 +199,7 @@ export default {
       }
       }
     },
     },
     scanUploadQrcode() {
     scanUploadQrcode() {
-      scanUploadQrcode().then((res) => {
+      scanUploadQrcode(this.ruleForm.region).then((res) => {
         this.creatQrCode(res.data.url);
         this.creatQrCode(res.data.url);
         this.scanToken = res.data.url;
         this.scanToken = res.data.url;
       });
       });
@@ -205,7 +224,7 @@ export default {
     async submitUpload() {
     async submitUpload() {
       if (this.ruleForm.type == 0) {
       if (this.ruleForm.type == 0) {
         this.uploadData = {
         this.uploadData = {
-          pid: this.treeId,
+          pid: this.ruleForm.region,
         };
         };
         if (this.ruleForm.imgList.length) {
         if (this.ruleForm.imgList.length) {
           if (this.loading) return;
           if (this.loading) return;
@@ -228,7 +247,7 @@ export default {
         if (urls.length) {
         if (urls.length) {
           if (this.loading) return;
           if (this.loading) return;
           this.loading = true;
           this.loading = true;
-          onlineUpload({ pid: this.treeId, images: urls })
+          onlineUpload({ pid: this.ruleForm.region, images: urls })
             .then((res) => {
             .then((res) => {
               this.$Message.success('上传成功');
               this.$Message.success('上传成功');
               this.$emit('uploadSuccess');
               this.$emit('uploadSuccess');
@@ -244,7 +263,7 @@ export default {
         let attId = this.ruleForm.imgList.map((e) => {
         let attId = this.ruleForm.imgList.map((e) => {
           return e.att_id;
           return e.att_id;
         });
         });
-        moveApi({ pid: this.treeId, images: attId }).then((res) => {
+        moveApi({ pid: this.ruleForm.region, images: attId }).then((res) => {
           this.$Message.success('上传成功');
           this.$Message.success('上传成功');
           this.$emit('uploadSuccess');
           this.$emit('uploadSuccess');
           this.uploadModal = false;
           this.uploadModal = false;
@@ -255,7 +274,7 @@ export default {
       return new Promise((resolve, reject) => {
       return new Promise((resolve, reject) => {
         const formData = new FormData();
         const formData = new FormData();
         formData.append('file', file);
         formData.append('file', file);
-        formData.append('pid', this.treeId);
+        formData.append('pid', this.ruleForm.region);
         fileUpload(formData)
         fileUpload(formData)
           .then((res) => {
           .then((res) => {
             if (res.status == 200) {
             if (res.status == 200) {
@@ -288,13 +307,16 @@ export default {
         correctLevel: QRCode.CorrectLevel.H,
         correctLevel: QRCode.CorrectLevel.H,
       });
       });
     },
     },
-    handleRemove(file) {
+    handleWebRemove(file) {
       console.log(file);
       console.log(file);
       let index = this.ruleForm.imgList.findIndex((e) => {
       let index = this.ruleForm.imgList.findIndex((e) => {
-        e.url == file.url;
+        return e.url == file.url;
       });
       });
       this.ruleForm.imgList.splice(index, 1);
       this.ruleForm.imgList.splice(index, 1);
     },
     },
+    handleRemove(index) {
+      this.ruleForm.imgList.splice(index, 1);
+    },
     handlePictureCardPreview(file) {
     handlePictureCardPreview(file) {
       this.dialogImageUrl = file.url;
       this.dialogImageUrl = file.url;
       this.dialogVisible = true;
       this.dialogVisible = true;
@@ -334,8 +356,7 @@ export default {
         .catch((res) => {});
         .catch((res) => {});
     },
     },
     handleChange(e) {
     handleChange(e) {
-      console.log(e, e.length == 1 ? e[0] : e[e.length - 1]);
-      this.treeId = e[e.length - 1];
+      if (this.ruleForm.type == 2) this.scanUploadQrcode();
     },
     },
     // 移动
     // 移动
     handleDragStart(e, item) {
     handleDragStart(e, item) {

+ 7 - 9
template/admin/src/components/uploadPictures/index.vue

@@ -1,5 +1,5 @@
 <template>
 <template>
-  <div class="Modal">
+  <div class="Modal" :class="{ 'fill-window': !isPage }">
     <div class="colLeft">
     <div class="colLeft">
       <div class="Nav">
       <div class="Nav">
         <!-- <div class="input">
         <!-- <div class="input">
@@ -70,7 +70,7 @@
             <el-cascader
             <el-cascader
               v-model="pids"
               v-model="pids"
               placeholder="图片移动至"
               placeholder="图片移动至"
-              style="width: 50%"
+              style="width: 150px"
               class="treeSel"
               class="treeSel"
               :options="treeData2"
               :options="treeData2"
               :props="{ checkStrictly: true, emitPath: false, label: 'title', value: 'id' }"
               :props="{ checkStrictly: true, emitPath: false, label: 'title', value: 'id' }"
@@ -85,7 +85,7 @@
               v-model="fileData.real_name"
               v-model="fileData.real_name"
               placeholder="请输入图片名"
               placeholder="请输入图片名"
               size="small"
               size="small"
-              style="width: 50%"
+              style="width: 150px"
             >
             >
               <i slot="suffix" class="el-icon-search el-input__icon" @click="getFileList"></i>
               <i slot="suffix" class="el-icon-search el-input__icon" @click="getFileList"></i>
             </el-input>
             </el-input>
@@ -203,7 +203,7 @@
         </div>
         </div>
       </div>
       </div>
     </div>
     </div>
-    <uploadImg ref="upload" @uploadSuccess="uploadSuccess"></uploadImg>
+    <uploadImg ref="upload" :isPage="isPage" :categoryId="treeId" :categoryList="treeData" @uploadSuccess="uploadSuccess"></uploadImg>
     <div class="images" v-show="false" v-viewer="{ movable: false }">
     <div class="images" v-show="false" v-viewer="{ movable: false }">
       <img v-for="src in pictrueList" :src="src.att_dir" :key="src.att_id" />
       <img v-for="src in pictrueList" :src="src.att_dir" :key="src.att_id" />
     </div>
     </div>
@@ -386,10 +386,6 @@ export default {
     searchImg() {},
     searchImg() {},
     // 移动分类
     // 移动分类
     getMove() {
     getMove() {
-      if (!this.ids.toString()) {
-        this.$Message.warning('请先选择图片');
-        return;
-      }
       let data = {
       let data = {
         pid: this.pids,
         pid: this.pids,
         images: this.ids.toString(),
         images: this.ids.toString(),
@@ -903,7 +899,9 @@ export default {
   height: 100%;
   height: 100%;
   background: #fff !important;
   background: #fff !important;
 }
 }
-
+.fill-window {
+  height: 100vh;
+}
 .colLeft {
 .colLeft {
   padding-right: 0 !important;
   padding-right: 0 !important;
   height: 100%;
   height: 100%;

+ 1 - 0
template/admin/src/pages/app/upload/index.vue

@@ -68,6 +68,7 @@ export default {
   created() {
   created() {
     this.token = this.$route.query.token;
     this.token = this.$route.query.token;
     this.pid = this.$route.query.pid;
     this.pid = this.$route.query.pid;
+    this.pid = this.$route.query.pid;
     document.title = '手机端扫码上传';
     document.title = '手机端扫码上传';
   },
   },
   methods: {
   methods: {