versionupload.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <!--
  2. * @Title:
  3. * @Description: APP上传
  4. * @Author: swp
  5. * @Date: 2022-08-24 10:49:21
  6. * @LastEditors:
  7. * @LastEditTime: 2022-08-24 10:49:21
  8. -->
  9. <template>
  10. <div>
  11. <el-row>
  12. <el-col :span="24">
  13. <basic-container>
  14. <avue-form :option="debugOption" v-model="debugForm" />
  15. </basic-container>
  16. </el-col>
  17. </el-row>
  18. <el-row>
  19. <el-col :span="24">
  20. <basic-container>
  21. <el-upload ref="upload" :action="uploadUrl" :on-preview="handlePreview" :on-remove="handleRemove"
  22. :before-upload="beforeUpload" :on-error="onError" :on-success="onSuccess" :file-list="fileList"
  23. :on-progress="onProgress" :auto-upload="false" :multiple="false" limit="1" accept=".apk"
  24. :data="postData">
  25. <el-button slot="trigger" size="small" type="primary">选择APK文件</el-button>
  26. <el-button style="margin-left: 10px;" size="small" type="success" @click="submitUpload">开始上传
  27. </el-button>
  28. <div slot="tip" class="el-upload__tip">只能上传APK文件</div>
  29. </el-upload>
  30. </basic-container>
  31. </el-col>
  32. </el-row>
  33. </div>
  34. </template>
  35. <script>
  36. import { getToken } from "@/util/auth";
  37. import { validatenull } from "@/util/validate";
  38. export default {
  39. data() {
  40. return {
  41. fileName: '',
  42. editForm: {},
  43. editDialog: false,
  44. form: {},
  45. selectionList: [],
  46. query: {},
  47. loading: true,
  48. postData: {},
  49. uploadUrl: '',
  50. debugForm: {},
  51. debugOption: {
  52. labelWidth: 150,
  53. submitBtn: false,
  54. emptyBtn: false,
  55. column: [
  56. {
  57. label: 'APPID',
  58. prop: 'appId',
  59. type: 'input',
  60. span: 24,
  61. },
  62. {
  63. label: '版本号',
  64. prop: 'version',
  65. type: 'input',
  66. span: 24,
  67. },
  68. {
  69. label: '版本升级提示',
  70. prop: 'versionNote',
  71. type: 'input',
  72. span: 24,
  73. },
  74. ]
  75. }
  76. };
  77. },
  78. props: {
  79. visible: {
  80. tyep: [Boolean],
  81. default: false,
  82. },
  83. importLoading: {
  84. tyep: [Boolean],
  85. default: false,
  86. }
  87. },
  88. name: 'versionupload',
  89. created() {
  90. this.init();
  91. },
  92. methods: {
  93. init() {
  94. this.uploadUrl = this.getUploadUrl();
  95. },
  96. submitUpload() {
  97. if (validatenull(this.debugForm.appId) && validatenull(this.debugForm.version)) {
  98. this.$message.warning("请录入APPID和版本号!");
  99. return;
  100. }
  101. this.postData['appId'] = this.debugForm.appId;
  102. this.postData['version'] = this.debugForm.version;
  103. this.postData['versionNote'] = this.debugForm.versionNote;
  104. this.$refs.upload.submit();
  105. this.$message.success('已成功上传APK!')
  106. },
  107. handleRemove(file, fileList) {
  108. console.log(file, fileList);
  109. this.$message.success('handleRemove')
  110. },
  111. handlePreview(file) {
  112. console.log(file);
  113. this.$message.success('handlePreview')
  114. },
  115. beforeUpload(file) {
  116. console.log(file);
  117. this.$message.success('beforeUpload')
  118. return true;
  119. },
  120. getUploadUrl: function () {
  121. return `/api/galaxy-business/version/apk?${this.website.tokenHeader
  122. }=${getToken()}`;
  123. },
  124. onProgress(event, file, fileList) {
  125. console.log(file, fileList);
  126. this.$emit("update:importLoading", true);
  127. },
  128. onError(err, file, fileList) {
  129. console.log(file, fileList);
  130. this.$message.warning(err);
  131. },
  132. onSuccess(response, file, fileList) {
  133. console.log(response);
  134. console.log(file);
  135. console.log(fileList);
  136. this.$message.warning("提交成功");
  137. this.$refs.upload.clearFiles();
  138. this.$emit("update:importLoading", false);
  139. this.$emit("update:visible", false);
  140. },
  141. },
  142. };
  143. </script>
  144. <style>
  145. .mb0 {
  146. margin-top: 10;
  147. }
  148. </style>