index.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  1. <style>
  2. .set-el-button {
  3. padding: 0 !important;
  4. border: 0;
  5. margin: 0 5px;
  6. }
  7. .sort-input {
  8. width: 100%;
  9. background-color: #F3F5F6;
  10. height: 32px;
  11. }
  12. .sort-input span {
  13. height: 32px;
  14. width: 100%;
  15. line-height: 32px;
  16. display: inline-block;
  17. padding: 0 10px;
  18. font-size: 13px;
  19. }
  20. .sort-input .el-input__inner {
  21. height: 32px;
  22. line-height: 32px;
  23. background-color: #F3F5F6;
  24. float: left;
  25. padding: 0 10px;
  26. border: 0;
  27. }
  28. .table-body {
  29. padding: 20px;
  30. background-color: #fff;
  31. }
  32. .table-info .el-button {
  33. padding: 0 !important;
  34. border: 0;
  35. margin: 0 5px;
  36. }
  37. .input-item {
  38. display: inline-block;
  39. width: 250px;
  40. margin: 0 0 20px;
  41. }
  42. .input-item .el-input__inner {
  43. border-right: 0;
  44. }
  45. .input-item .el-input__inner:hover {
  46. border: 1px solid #dcdfe6;
  47. border-right: 0;
  48. outline: 0;
  49. }
  50. .input-item .el-input__inner:focus {
  51. border: 1px solid #dcdfe6;
  52. border-right: 0;
  53. outline: 0;
  54. }
  55. .input-item .el-input-group__append {
  56. background-color: #fff;
  57. border-left: 0;
  58. width: 10%;
  59. padding: 0;
  60. }
  61. .input-item .el-input-group__append .el-button {
  62. padding: 0;
  63. }
  64. .input-item .el-input-group__append .el-button {
  65. margin: 0;
  66. }
  67. </style>
  68. <div id="app" v-cloak>
  69. <el-card shadow="never" style="border:0" body-style="background-color: #f3f3f3;padding: 10px 0 0;">
  70. <div slot="header">
  71. <span>下载中心</span>
  72. </div>
  73. <div class="table-body">
  74. <el-form :inline="true" :model="search_data" size="small" class="demo-form-inline">
  75. <el-form-item label="导出时间">
  76. <el-date-picker style="margin-top: 1px;" @change="changeTime" v-model="datetime"
  77. type="datetimerange" value-format="yyyy-MM-dd HH:mm:ss" range-separator="至"
  78. start-placeholder="开始日期" end-placeholder="结束日期"
  79. :default-time="['00:00:00', '23:59:59']" clearable></el-date-picker>
  80. </el-form-item>
  81. <el-form-item label="">
  82. <el-input placeholder="请输入文件名称" v-model="search_data.name" clearable></el-input>
  83. </el-form-item>
  84. <el-form-item>
  85. <el-button type="primary" @click="search">搜索</el-button>
  86. <el-button type="primary" @click="multipleDownload">批量下载</el-button>
  87. <el-button type="danger" @click="clearSearch" v-if="show_clear_search_btn">清除条件</el-button>
  88. </el-form-item>
  89. </el-form>
  90. <el-table v-loading="loading" border :data="list" style="width: 100%;margin-bottom: 15px"
  91. @selection-change="handleSelectionChange">
  92. <el-table-column type="selection" width="55" :selectable="selectables"></el-table-column>
  93. <el-table-column prop="id" label="ID" width="100"></el-table-column>
  94. <el-table-column prop="name" width="280" label="文件名称"></el-table-column>
  95. <el-table-column width='120' prop="type" label="类型">
  96. <template slot-scope="scope">
  97. {{type_list[scope.row.type]}}
  98. </template>
  99. </el-table-column>
  100. <el-table-column width='180' prop="num" label="数据量"></el-table-column>
  101. <el-table-column width='150' prop="status" label="状态">
  102. <template slot-scope="scope">
  103. {{status_list[scope.row.status]}}
  104. </template>
  105. </el-table-column>
  106. <el-table-column width='180' prop="size" label="文件大小">
  107. </el-table-column>
  108. <el-table-column width='280' prop="created_at" label="导出时间">
  109. <template slot-scope="scope">
  110. {{scope.row.created_at|dateTimeFormat('Y-m-d H:i:s')}}
  111. </template>
  112. </el-table-column>
  113. <el-table-column label="操作" width="280">
  114. <template slot-scope="scope">
  115. <el-button v-if="scope.row.status==2" type="text" size="mini" circle
  116. style="margin-left: 10px;margin-top: 10px" @click="download(scope.row.id)">
  117. <el-tooltip class="item" effect="dark" content="下载" placement="top">
  118. <el-button type="primary" size="mini" icon="el-icon-download" round></el-button>
  119. </el-tooltip>
  120. </el-button>
  121. <!-- <el-button v-if="scope.row.status==3" type="text" size="mini" circle style="margin-left: 10px;margin-top: 10px" @click="regenerate(scope.row.id)">
  122. <el-tooltip class="item" effect="dark" content="重新生成导出文件" placement="top">
  123. <el-button type="primary" size="mini" icon="el-icon-refresh-left" round></el-button>
  124. </el-tooltip>
  125. </el-button> -->
  126. <el-button v-if="scope.row.status==2||scope.row.status==3"
  127. style="margin-left: 10px;margin-top: 10px" type="text" class="set-el-button"
  128. size="mini" circle @click="handleDelete(scope.row.id)">
  129. <el-tooltip class="item" effect="dark" content="删除" placement="top">
  130. <el-button type="primary" size="mini" icon="el-icon-delete" round></el-button>
  131. </el-tooltip>
  132. </el-button>
  133. </template>
  134. </el-table-column>
  135. </el-table>
  136. <el-pagination v-if="pagination" :page-size="page_size" style="display: inline-block;float: right;"
  137. background @current-change="pageChange" layout="prev, pager, next"
  138. :total="pagination.totalCount">
  139. </el-pagination>
  140. </div>
  141. </el-card>
  142. </div>
  143. <script>
  144. const app = new Vue({
  145. el: '#app',
  146. data() {
  147. return {
  148. loading: false,
  149. list: [],
  150. type_list: Object,
  151. status_list: Object,
  152. name: '',
  153. pagination: null,
  154. page: 1,
  155. page_size: 10,
  156. page_count: 1,
  157. search_data: { // 筛选条件
  158. name: null,
  159. start: null,
  160. end: null,
  161. },
  162. datetime: [],
  163. multipleSelect: [],
  164. };
  165. },
  166. computed: {
  167. show_clear_search_btn: function () {
  168. return !isEmpty(this.search_data.start) || !isEmpty(this.search_data.end) || !isEmpty(this.search_data.name);
  169. }
  170. },
  171. methods: {
  172. //分页
  173. pageChange(page) {
  174. this.page = page;
  175. this.loadData({});
  176. },
  177. // 根据参数获取请求信息
  178. loadData(search_data) {
  179. this.loading = true;
  180. request({
  181. params: {
  182. r: 'store/client/download/index',
  183. name: search_data.name,
  184. start: search_data.start,
  185. end: search_data.end,
  186. page: this.page,
  187. },
  188. }).then(e => {
  189. this.loading = false;
  190. if (e.data.code === 0) {
  191. this.list = e.data.data.list;
  192. this.type_list = e.data.data.type_list;
  193. this.status_list = e.data.data.status_list;
  194. this.pagination = e.data.data.pagination;
  195. this.page_size = e.data.data.page_size;
  196. this.page_count = e.data.data.page_count;
  197. } else {
  198. this.listLoading = false;
  199. this.$message({
  200. message: e.data.msg,
  201. type: 'error'
  202. });
  203. }
  204. }).catch(e => {
  205. this.listLoading = false;
  206. });
  207. },
  208. handleDelete(id) {
  209. this.$request({
  210. params: {
  211. r: 'store/client/download/del',
  212. id: id,
  213. },
  214. }).then(e => {
  215. if (e.data.code == 0) {
  216. this.$message({
  217. message: e.data.msg,
  218. type: 'success'
  219. });
  220. location.reload();
  221. }
  222. }).catch(e => {
  223. });
  224. },
  225. download(id) {
  226. window.location.href = '/index.php?r=store/client/download/download&download_id=' + id;
  227. },
  228. search() {
  229. this.loadData(this.search_data);
  230. },
  231. clearSearch() {
  232. this.search_data.start = null;
  233. this.search_data.end = null;
  234. this.search_data.name = null;
  235. this.datetime = [];
  236. this.loadData({});
  237. },
  238. changeTime(e) {
  239. this.search_data.start = e[0]
  240. this.search_data.end = e[1]
  241. },
  242. handleSelectionChange(val) {
  243. this.multipleSelect = [];
  244. this.multipleSelect = val;
  245. },
  246. multipleDownload() {
  247. if (this.multipleSelect.length) {
  248. let val = this.multipleSelect;
  249. let download_ids = [];
  250. let for_num = val.length;
  251. for (let i = 0; i < for_num; i++) {
  252. if (val[i].status !== 2) {
  253. this.$message.error('选择了不可导出的文件[' + val[i].name + '(ID:' + val[i].id + ')],请重新选择');
  254. return false;
  255. }
  256. download_ids.push(val[i].id);
  257. }
  258. window.location.href = '/index.php?r=store/client/download/download-all&download_id=' + download_ids;
  259. } else {
  260. this.$message.error('请先选择要批量下载的文件');
  261. }
  262. },
  263. selectables(row, index) {
  264. if (row.status == 2) {
  265. return true
  266. } else {
  267. return false;
  268. }
  269. }
  270. },
  271. created() {
  272. this.loadData({});
  273. }
  274. })
  275. </script>