瀏覽代碼

优化上传PDF文件控件为上传PDF、JPG、PNG文件控件,以及相关功能整改

Rockery 3 年之前
父節點
當前提交
b9f989ccd8

+ 4 - 4
src/components/RocFormItemImgPdfUpload/index.vue

@@ -3,7 +3,7 @@
  * @Author: Rockery
  * @Date: 2022-02-28 11:31:41
  * @LastEditors: Rockery
- * @LastEditTime: 2022-02-28 17:11:13
+ * @LastEditTime: 2022-03-01 17:23:09
  * @FilePath: \party_construct_web\src\components\RocFormItemImgPdfUpload\index.vue
  * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
 -->
@@ -25,21 +25,21 @@
       v-model="currentValue"
       :is-disabled="isDisabled"
       :upload-file-title="formItemLabel"
-    ></roc-img-pdf-file-upload>
+    />
 
     <roc-vue-img-dialog
       v-if="imgDialogVisible"
       :visible.sync="imgDialogVisible"
       :dialog-title="viewImgFileObj.fileName"
       :img-url="viewImgFileObj.filePath"
-    ></roc-vue-img-dialog>
+    />
 
     <roc-vue-pdf-dialog
       v-if="pdfDialogVisible"
       :visible.sync="pdfDialogVisible"
       :dialog-title="viewPdfFileObj.fileName"
       :pdf-url="viewPdfFileObj.filePath"
-    ></roc-vue-pdf-dialog>
+    />
 
     <!-- 更新文件对话框 -->
     <el-dialog

+ 9 - 9
src/components/RocImgFileUpload/index.vue

@@ -3,7 +3,7 @@
  * @Author: Rockery
  * @Date: 2021-12-27 11:19:47
  * @LastEditors: Rockery
- * @LastEditTime: 2022-02-28 11:25:40
+ * @LastEditTime: 2022-03-01 17:46:31
  * @FilePath: \party_construct_web\src\components\RocImgFileUpload\index.vue
  * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
 -->
@@ -40,12 +40,7 @@
         size="small"
         @click="submitRocImgFileUploadClick"
       >上传文件</el-button>
-      <el-button
-        v-if="isSelect"
-        type="info"
-        size="small"
-        @click="removeRocImgFileUploadClick"
-      >移除文件</el-button>
+      <el-button v-if="isSelect" type="info" size="small" @click="removeRocImgFileUploadClick">移除文件</el-button>
     </div>
   </div>
 </template>
@@ -129,7 +124,7 @@ export default {
      * 文件上传预处理
      */
     handleRocImgFileUploadBeforeUpload(file) {
-      if(!['image/png', 'image/jpeg'].includes(file.type || '')){
+      if (!['image/png', 'image/jpeg'].includes(file.type || '')) {
         this.$refs.rocImgFileUploadRef.clearFiles();
         this.msgError(`${this.fileTitle}格式错误,请上传类型格式为jpg或png的图片文件!`);
         return;
@@ -168,7 +163,7 @@ export default {
      */
     handleRocImgFileUploadOnchange(file, fileList) {
       if (file.status === 'ready') {
-        if(!['image/png', 'image/jpeg'].includes((file.raw || {}).type || '')){
+        if (!['image/png', 'image/jpeg'].includes((file.raw || {}).type || '')) {
           this.$refs.rocImgFileUploadRef.clearFiles();
           this.isSelect = false;
           this.msgError(`${this.fileTitle}格式错误,请上传类型格式为jpg或png的图片文件!`);
@@ -179,6 +174,11 @@ export default {
         this.$emit('input', '');
       } else if (file.status === 'success') {
         this.isUploadSuccess = true;
+      } else if (file.status === 'fail') {
+        this.isUploadSuccess = false;
+        this.isSelect = false;
+        this.$emit('input', '');
+        this.msgError(`上传失败!`);
       } else {
         this.isUploadSuccess = false;
         this.isSelect = false;

+ 9 - 2
src/components/RocImgPdfFileUpload/index.vue

@@ -3,7 +3,7 @@
  * @Author: Rockery
  * @Date: 2021-12-20 09:16:41
  * @LastEditors: Rockery
- * @LastEditTime: 2022-02-28 16:50:05
+ * @LastEditTime: 2022-03-01 17:46:07
  * @FilePath: \party_construct_web\src\components\RocImgPdfFileUpload\index.vue
  * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
 -->
@@ -58,12 +58,14 @@
     <roc-vue-img-dialog
       v-if="imgDialogVisible"
       :visible.sync="imgDialogVisible"
+      :dialog-title="'图片(' + successResp.name + ')文件预览'"
       :imgUrl="successResp.successUrl"
     ></roc-vue-img-dialog>
 
     <roc-vue-pdf-dialog
       v-if="pdfDialogVisible"
       :visible.sync="pdfDialogVisible"
+      :dialog-title="'PDF(' + successResp.name + ')文件预览'"
       :pdfUrl="successResp.successUrl"
     ></roc-vue-pdf-dialog>
   </div>
@@ -211,12 +213,17 @@ export default {
           this.msgError(`${this.fileTitle}格式错误,请上传类型格式为PDF、JPG、PNG的文件!`);
           return;
         }
-
         this.isSelect = true;
         this.isUploadSuccess = false;
         this.$emit('input', '');
       } else if (file.status === 'success') {
         this.isUploadSuccess = true;
+      } else if (file.status === 'fail') {
+        this.isUploadSuccess = false;
+        this.isSelect = false;
+        this.fileType = '';
+        this.$emit('input', '');
+        this.msgError(`上传失败!`);
       } else {
         this.isUploadSuccess = false;
         this.isSelect = false;

+ 5 - 0
src/components/RocPdfFileUpload/index.vue

@@ -192,6 +192,11 @@ export default {
         this.$emit('input', '');
       } else if (file.status === 'success') {
         this.isUploadSuccess = true;
+      } else if (file.status === 'fail') {
+        this.isUploadSuccess = false;
+        this.isSelect = false;
+        this.$emit('input', '');
+        this.msgError(`上传失败!`);
       } else {
         this.isUploadSuccess = false;
         this.isSelect = false;

+ 4 - 4
src/components/RocVueImgDialog/index.vue

@@ -1,9 +1,9 @@
 <!--
- * @Description: Img文件预览弹框
+ * @Description: 图片文件预览
  * @Author: Rockery
  * @Date: 2021-12-13 17:40:22
  * @LastEditors: Rockery
- * @LastEditTime: 2022-02-28 11:17:31
+ * @LastEditTime: 2022-03-01 17:34:06
  * @FilePath: \party_construct_web\src\components\RocVueImgDialog\index.vue
  * @Copyright: Copyright (c) 2016~2021 Rockery(1113269755@qq.com)
 -->
@@ -13,7 +13,7 @@
     <el-dialog
       :title="dialogTitle"
       :visible.sync="currentVisible"
-      width="650px"
+      width="50%"
       append-to-body
       class="rocvueimgdialog-dialog"
       @close="handleCloseDialogClick"
@@ -55,7 +55,7 @@ export default {
     dialogTitle: {
       type: String,
       required: false,
-      default: 'Img文件预览'
+      default: '图片文件预览'
     },
     // Img文件访问路径
     imgUrl: {

File diff suppressed because it is too large
+ 217 - 449
src/components/UpdatePartyDevelop/index.vue