index.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <com-list-page :crumbs="crumbs" id="application">
  2. <com-list-table
  3. ref="table"
  4. :api="'mall/download/index'"
  5. :search-list="searchList"
  6. @selection-change="handleSelectionChange"
  7. @get-api-data="handleGetApiData"
  8. >
  9. <el-table-column type="selection" width="55" :selectable="selectables"></el-table-column>
  10. <el-table-column prop="id" label="ID" width="100"> </el-table-column>
  11. <el-table-column prop="name" label="文件名称"></el-table-column>
  12. <el-table-column width='120' prop="type" label="类型">
  13. <template slot-scope="scope">
  14. {{type_list[scope.row.type]}}
  15. </template>
  16. </el-table-column>
  17. <el-table-column width='120' prop="num" label="数据量"></el-table-column>
  18. <el-table-column width='150' prop="status" label="状态">
  19. <template slot-scope="scope">
  20. {{status_list[scope.row.status]}}
  21. </template>
  22. </el-table-column>
  23. <el-table-column width='100' prop="size" label="文件大小">
  24. </el-table-column>
  25. <el-table-column width='180' prop="created_at" label="导出时间">
  26. <template slot-scope="scope">
  27. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  28. </template>
  29. </el-table-column>
  30. <el-table-column width='150' label="操作" align="right">
  31. <template slot-scope="scope">
  32. <el-button v-if="scope.row.status==2" type="text" :loading="btnLoad" size="mini" @click="download(scope.row.id)">
  33. 下载
  34. </el-button>
  35. <!-- <el-button v-if="scope.row.status==3" type="text" :loading="btnLoad" size="mini" circle style="margin-left: 10px;margin-top: 10px" @click="regenerate(scope.row.id)">
  36. <el-tooltip class="item" effect="dark" content="重新生成导出文件" placement="top">
  37. <el-button type="primary" size="mini" icon="el-icon-refresh-left" round></el-button>
  38. </el-tooltip>
  39. </el-button> -->
  40. <el-button v-if="scope.row.status==2||scope.row.status==3" type="text" :loading="btnLoad" size="mini" @click="handleDelete(scope.row.id)">
  41. 删除
  42. </el-button>
  43. </template>
  44. </el-table-column>
  45. <template slot="footer-button">
  46. <el-button @click="multipleDownload">批量下载</el-button>
  47. </template>
  48. </com-list-table>
  49. </com-list-page>
  50. <script>
  51. const application = new Vue({
  52. el: '#application',
  53. data: {
  54. crumbs: [{
  55. title: '首页',
  56. router: 'mall/overview/index',
  57. },
  58. {
  59. title: '下载',
  60. },
  61. {
  62. title: '下载中心',
  63. }
  64. ],
  65. categorys: {
  66. 'optimize': '功能优化',
  67. 'bug': 'BUG修复',
  68. 'others': '其他建议',
  69. },
  70. searchList: [
  71. {
  72. key: 'name',
  73. title: '文件名称',
  74. type: 'text',
  75. },
  76. {
  77. key: 'datetime',
  78. title: '导出时间',
  79. type: 'date-time-range',
  80. },
  81. ],
  82. type_list: {},
  83. status_list: {},
  84. multipleSelect: [],
  85. btnLoad: false,
  86. },
  87. methods: {
  88. handleGetApiData(data) {
  89. this.type_list = data.type_list
  90. this.status_list = data.status_list
  91. },
  92. download(id) {
  93. this.btnLoad = true;
  94. window.location.href = '/index.php?r=mall/download/down&download_id=' + id;
  95. this.btnLoad = false;
  96. },
  97. regenerate(id) {
  98. let self = this;
  99. self.btnLoad = true;
  100. request({
  101. params: {
  102. r: 'mall/download/regenerate',
  103. download_id: id,
  104. },
  105. method: 'get'
  106. }).then(e => {
  107. self.btnLoad = false;
  108. if (e.data.code === 0) {
  109. self.$message.success(e.data.msg);
  110. } else {
  111. self.$message.error(e.data.msg);
  112. }
  113. }).catch(e => {
  114. this.$refs.table.handleSearch()
  115. self.$message.error('网络错误');
  116. });
  117. },
  118. multipleDownload() {
  119. if (this.multipleSelect.length) {
  120. let val = this.multipleSelect;
  121. let download_ids = [];
  122. let for_num = val.length;
  123. for (let i = 0; i < for_num; i++) {
  124. if (val[i].status != 2) {
  125. // 选择了不可下载的文件
  126. this.$message.error('选择了不可导出的文件[' + val[i].name + '(ID:' + val[i].id + ')],请重新选择');
  127. return false;
  128. }
  129. download_ids.push(val[i].id);
  130. }
  131. window.location.href = '/index.php?r=mall/download/multiple-download&download_id=' + download_ids;
  132. } else {
  133. this.$message.error('请先选择要批量下载的文件');
  134. }
  135. },
  136. handleDelete(id) {
  137. this.btnLoad = true;
  138. this.$request({
  139. params: {
  140. r: 'mall/download/del',
  141. id: id,
  142. },
  143. }).then(e => {
  144. if (e.data.code == 0) {
  145. this.$message({
  146. message: e.data.msg,
  147. type: 'success'
  148. });
  149. this.btnLoad = false
  150. this.$refs.table.handleSearch()
  151. }
  152. }).catch(e => {});
  153. },
  154. selectables(row, index) {
  155. if (row.status == 2) {
  156. return true
  157. } else {
  158. return false;
  159. }
  160. },
  161. handleSelectionChange(val) {
  162. this.multipleSelect = []
  163. this.multipleSelect = val
  164. },
  165. },
  166. })
  167. </script>