report_business.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <template>
  2. <div>
  3. <div style="text-align: right;margin-bottom: 10px">
  4. <el-button @click="exportList" class="export-excel" type="primary">导出报表</el-button>
  5. </div>
  6. <div class="table">
  7. <el-table
  8. v-if="tableData.length"
  9. border
  10. style="width: 100%"
  11. :data="tableData"
  12. >
  13. <el-table-column
  14. v-for="(prop, index) of tableProps"
  15. :key="index"
  16. :prop="prop"
  17. :label="tableHeaders[index]"
  18. >
  19. <template slot-scope="scope">
  20. <el-button
  21. type="text"
  22. v-if="prop === 'project_amount'"
  23. @click="clickProject(scope.row,1)"
  24. >{{ scope.row[prop] }}
  25. </el-button>
  26. <el-button
  27. type="text"
  28. v-else-if="prop === 'cloud_amount'"
  29. @click="clickProject(scope.row,2)"
  30. >{{ scope.row[prop] }}
  31. </el-button>
  32. <el-button
  33. type="text"
  34. v-else-if="prop === 'hire_amount'"
  35. @click="clickProject(scope.row,3)"
  36. >{{ scope.row[prop] }}
  37. </el-button>
  38. <el-button
  39. type="text"
  40. v-else-if="prop === 'vip_amount'"
  41. @click="clickProject(scope.row,4)"
  42. >{{ scope.row[prop] }}
  43. </el-button>
  44. <el-button
  45. type="text"
  46. v-else-if="prop === 'verify_amount'"
  47. @click="clickProject(scope.row,5)"
  48. >{{ scope.row[prop] }}
  49. </el-button>
  50. <el-button
  51. type="text"
  52. v-else-if="prop === 'contact_amount'"
  53. @click="clickProject(scope.row,6)"
  54. >{{ scope.row[prop] }}
  55. </el-button>
  56. <span v-else>{{ scope.row[prop] }}</span>
  57. </template>
  58. </el-table-column>
  59. </el-table>
  60. </div>
  61. <div>
  62. <el-pagination
  63. @current-change="getTableData"
  64. :current-page.sync="pageInfo.page"
  65. :page-size="pageInfo.size"
  66. layout="total, prev, pager, next"
  67. :total="pageInfo.total"
  68. ></el-pagination>
  69. </div>
  70. </div>
  71. </template>
  72. <script>
  73. export default {
  74. data() {
  75. return {
  76. pageInfo: {
  77. page: 1,
  78. size: 20,
  79. total: 0,
  80. },
  81. // 列表头显示内容
  82. tableHeaders: [],
  83. // 列表头字段
  84. tableProps: [],
  85. // 列表数据
  86. tableData: []
  87. };
  88. },
  89. mounted() {
  90. this.getTableData();
  91. },
  92. methods: {
  93. // 获取列表数据
  94. async getTableData() {
  95. this.tableData = [];
  96. const res = await this.$post("/api/admin/ReportForm/index", {
  97. id: 'IncomeData'
  98. });
  99. let data = res.data;
  100. this.tableData = data.list;
  101. this.pageInfo.total = Number(data.total);
  102. this.pageInfo.page = data.totalPage;
  103. this.setTitles(data.titles);
  104. },
  105. async exportList() {
  106. let url = window.location.host + "/api/admin/ReportForm/export?id=IncomeData";
  107. window.location.href = "http://" + url;
  108. },
  109. setTitles(title) {
  110. for (let i in title) {
  111. this.tableProps.push(i);
  112. this.tableHeaders.push(title[i]);
  113. }
  114. },
  115. clickProject(row, type) {
  116. let product_type = 2;
  117. let path = "/main/project_form";
  118. let arr = [11,12,55];
  119. switch (type) {
  120. case 1:
  121. product_type = 2;
  122. break;
  123. case 2:
  124. product_type = 9;
  125. break;
  126. case 3:
  127. product_type = 4;
  128. break;
  129. case 4:
  130. product_type = 11;
  131. break;
  132. case 5:
  133. product_type = 12;
  134. break;
  135. case 6:
  136. product_type = 55;
  137. break;
  138. }
  139. if(arr.includes(product_type)){
  140. path = "/main/orders"
  141. }
  142. //2020-10-1 00:00:00
  143. let date = row.month;
  144. if (!date || date.length < 6) {
  145. this.$message.error('时间格式不正确');
  146. return;
  147. }
  148. let year = date.substring(0, 4);
  149. let month = date.substring(4, 6);
  150. let data = {
  151. product_type: product_type,
  152. start_time: this.beginTime(year, month),
  153. end_time: this.lastTime(year, month)
  154. };
  155. this.$router.push({path: path, query: data});
  156. },
  157. beginTime(year, month) {
  158. if (month.length <= 1) {
  159. let month = "0" + month;
  160. }
  161. let startTime = year + '-' + month + '-' + "01" + " 00:00:00";
  162. return startTime;
  163. },
  164. lastTime(year, month) {
  165. if (month.length <= 1) {
  166. let month = "0" + month;
  167. }
  168. let day = new Date(year, month, 0);
  169. let lastdate = year + '-' + month + '-' + day.getDate();
  170. let lastTime = lastdate + " 23:59:59";
  171. return lastTime;
  172. }
  173. }
  174. };
  175. </script>
  176. <style scoped>
  177. .table {
  178. height: calc(100% - 80px);
  179. }
  180. </style>