浏览代码

开发上传excel表的功能

vothin 2 年之前
父节点
当前提交
caa2878999
共有 2 个文件被更改,包括 42 次插入12 次删除
  1. 1 0
      languages/zh-CN.js
  2. 41 12
      src/views/ncs-orginazition/components/partInfoEdit.vue

+ 1 - 0
languages/zh-CN.js

@@ -146,6 +146,7 @@ module.exports = {
     byEvent: '按事件',
     export: '导出',
     icon: '图标',
+    excelUpload: '上传excel表',
     play: '播放',
     pause: '暂停',
     noFile: '文件不存在,无法播放'

+ 41 - 12
src/views/ncs-orginazition/components/partInfoEdit.vue

@@ -511,19 +511,39 @@
               </el-form-item>
             </el-col>
           </el-row>
-          <el-form-item :label="this.$t('action.icon')">
-            <el-upload
-                class="avatar-uploader"
-                :action="`${uploadurl}?scene=avatar`"
-                :show-file-list="false"
-                :on-success="uploaded"
-                :before-upload="handleShopLogoBefore"
-            >
-              <img v-if="imageUrl" :src="imageUrl" class="avatar">
-              <i v-else class="el-icon-plus avatar-uploader-icon" />
-            </el-upload>
-          </el-form-item>
 
+          <el-row>
+            <el-col :span="8">
+              <el-form-item :label="this.$t('action.icon')">
+                <el-upload
+                    class="avatar-uploader"
+                    :action="`${uploadurl}?scene=avatar`"
+                    :show-file-list="false"
+                    :on-success="uploaded"
+                    :before-upload="handleShopLogoBefore"
+                >
+                  <img v-if="imageUrl" :src="imageUrl" class="avatar">
+                  <i v-else class="el-icon-plus avatar-uploader-icon" />
+                </el-upload>
+              </el-form-item>
+            </el-col>
+
+            <el-col :span="8">
+              <el-form-item :label="this.$t('action.excelUpload')">
+                <el-upload
+                    class="avatar-uploader"
+                    :action="`${excelUpload}`"
+                    :show-file-list="false"
+                    :on-success="excelUploaded"
+                    :before-upload="handleExcelBefore"
+                    :limit="1"
+                >
+                  <el-button size="small" type="primary">{{ this.$t('action.uploadFile') }}</el-button>
+                </el-upload>
+                <el-link :href="excelUploadDemo" type="primary" target="_blank" icon="el-icon-download" :underline="false">excel表格模板</el-link>
+              </el-form-item>
+            </el-col>
+          </el-row>
         </fieldset>
 
         <el-form-item align="center" class="margin-top-sm">
@@ -578,6 +598,8 @@ export default {
       otherHostDevice: [],
       uploadurl: serverUrl + '/ncs/upload/uploadFile',
       imageUrl: '',
+      excelUpload: serverUrl + '/ncs/excel/' + this.partId + '/',
+      excelUploadDemo: serverUrl + '/upload/excel/demo/excel_demo.xlsx'
     }
   },
   async mounted() {
@@ -870,6 +892,13 @@ export default {
         reader.readAsDataURL(file)
       })
     },
+    excelUploaded(res) {
+      console.log(res)
+    },
+    handleExcelBefore(file) {
+      console.log(file.type)
+
+    }
   }
 }
 </script>