Commit 5e98a7fe2b548f4690c27886538d3e3e8bd5b3d8

Authored by 周峰
1 parent 79d18b7b

上传apk成功

ant-design-vue-jeecg/src/views/system/monitor/ApkInfoList.vue
... ... @@ -38,7 +38,20 @@
38 38  
39 39 <!-- 操作按钮区域 -->
40 40 <div class="table-operator">
41   - <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
  41 + <a-upload
  42 + name="file"
  43 + :multiple="false"
  44 + :action="uploadAction"
  45 + :headers="tokenHeader"
  46 + :showUploadList="false"
  47 + :beforeUpload="beforeUpload"
  48 + @change="handleChange">
  49 + <a-button>
  50 + <a-icon type="upload"/>
  51 + 上传APK
  52 + </a-button>
  53 + </a-upload>
  54 + <!--<a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>-->
42 55 <a-button type="primary" icon="download" @click="handleExportXls('apk_info')">导出</a-button>
43 56 <a-upload name="file" :showUploadList="false" :multiple="false" :headers="tokenHeader" :action="importExcelUrl" @change="handleImportExcel">
44 57 <a-button type="primary" icon="import">导入</a-button>
... ... @@ -188,7 +201,8 @@
188 201 deleteBatch: "/monitor/apkinfo/deleteBatch",
189 202 exportXlsUrl: "/monitor/apkinfo/exportXls",
190 203 importExcelUrl: "monitor/apkinfo/importExcel",
191   -
  204 + upload: "/sys/common/upload",
  205 +
192 206 },
193 207 dictOptions:{},
194 208 superFieldList:[],
... ... @@ -198,11 +212,41 @@
198 212 this.getSuperFieldList();
199 213 },
200 214 computed: {
  215 + uploadAction() {
  216 + return window._CONFIG['domianURL'] + this.url.upload;
  217 + },
201 218 importExcelUrl: function(){
202 219 return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
203 220 },
204 221 },
205 222 methods: {
  223 + beforeUpload(file) {
  224 + var fileType = file.type;
  225 + if (fileType === 'image') {
  226 + if (fileType.indexOf('image') < 0) {
  227 + this.$message.warning('请上传图片');
  228 + return false;
  229 + }
  230 + } else if (fileType === 'file') {
  231 + if (fileType.indexOf('image') >= 0) {
  232 + this.$message.warning('请上传文件');
  233 + return false;
  234 + }
  235 + }
  236 + return true
  237 + },
  238 + handleChange(info) {
  239 + if (info.file.status === 'done') {
  240 + if (info.file.response.success) {
  241 + this.loadData()
  242 + this.$message.success(`${info.file.name} 上传成功!`);
  243 + } else {
  244 + this.$message.error(`${info.file.response.message}`);
  245 + }
  246 + } else if (info.file.status === 'error') {
  247 + this.$message.error(`${info.file.response.message}`);
  248 + }
  249 + },
206 250 initDictConfig(){
207 251 },
208 252 getSuperFieldList(){
... ...