bystore.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. <template>
  2. <div class="app-container">
  3. <el-form :model="queryParams" ref="queryForm" @submit.native.prevent :inline="true" v-show="showSearch" label-width="100px">
  4. <el-form-item label="统计日期" prop="dateRange">
  5. <el-date-picker
  6. v-model="dateRange"
  7. type="date"
  8. placeholder="统计日期"
  9. value-format="yyyy-MM-dd"
  10. />
  11. </el-form-item>
  12. <el-form-item>
  13. <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
  14. <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
  15. <el-button type="warning" @click="handleSync" v-if="userInfoVO.userType == '00'">同步当日统计</el-button>
  16. </el-form-item>
  17. </el-form>
  18. <el-row :gutter="10" class="mb8">
  19. <el-col :span="1.5">
  20. <el-button
  21. type="warning"
  22. plain
  23. icon="el-icon-download"
  24. @click="handleExport"
  25. v-hasPermi="['settlement:store:statistics:export']"
  26. >导出</el-button>
  27. </el-col>
  28. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  29. </el-row>
  30. <el-table v-loading="loading" :data="statisticsList" border>
  31. <!-- 基本信息 -->
  32. <el-table-column label="统计日期" align="center" prop="day" width="100">
  33. <template slot-scope="scope">
  34. {{ parseDay(scope.row.day) }}
  35. </template>
  36. </el-table-column>
  37. <el-table-column label="统计门店" align="center" prop="day" width="100">
  38. <template slot-scope="scope">
  39. {{ scope.row.storeName }}
  40. </template>
  41. </el-table-column>
  42. <!-- 总计统计 -->
  43. <el-table-column label="总计" align="center">
  44. <el-table-column label="订单总数" align="center" width="100">
  45. <template slot-scope="scope">
  46. {{ scope.row.clothOrderCount + scope.row.goodsOrderCount }}
  47. </template>
  48. </el-table-column>
  49. <el-table-column label="订单总额" align="center" width="120">
  50. <template slot-scope="scope">
  51. {{ (scope.row.clothOrderAmount + scope.row.goodsOrderAmount).toFixed(2) }}
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="总支付金额" align="center" width="120">
  55. <template slot-scope="scope">
  56. {{ calculateTotalPayAmount(scope.row) }}
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="总退款金额" align="center" width="120">
  60. <template slot-scope="scope">
  61. {{ calculateTotalRefundAmount(scope.row) }}
  62. </template>
  63. </el-table-column>
  64. </el-table-column>
  65. <!-- 洗衣订单统计 -->
  66. <el-table-column label="洗衣订单" align="center">
  67. <el-table-column label="订单数" align="center" prop="clothOrderCount" width="90" />
  68. <el-table-column label="衣物件数" align="center" prop="clothCount" width="90" />
  69. <el-table-column label="订单总额" align="center" prop="clothOrderAmount" width="100" />
  70. <el-table-column label="支付金额" align="center">
  71. <el-table-column label="微信支付" align="center" prop="clothWechatAmount" width="100" />
  72. <el-table-column label="支付宝" align="center" prop="clothAlipayAmount" width="100" />
  73. <el-table-column label="现金" align="center" prop="clothCashAmount" width="100" />
  74. <el-table-column label="会员卡" align="center" prop="clothMemberAmount" width="100" />
  75. </el-table-column>
  76. <el-table-column label="退款金额" align="center">
  77. <el-table-column label="微信退款" align="center" prop="clothWechatRefundAmount" width="100" />
  78. <el-table-column label="支付宝退款" align="center" prop="clothAlipayRefundAmount" width="100" />
  79. <el-table-column label="现金退款" align="center" prop="clothCashRefundAmount" width="100" />
  80. <el-table-column label="会员卡退款" align="center" prop="clothMemberRefundAmount" width="100" />
  81. </el-table-column>
  82. </el-table-column>
  83. <!-- 商品订单统计 -->
  84. <el-table-column label="商品订单" align="center">
  85. <el-table-column label="订单数" align="center" prop="goodsOrderCount" width="90" />
  86. <el-table-column label="订单总额" align="center" prop="goodsOrderAmount" width="100" />
  87. <el-table-column label="支付金额" align="center">
  88. <el-table-column label="微信支付" align="center" prop="goodsWechatAmount" width="100" />
  89. <el-table-column label="支付宝" align="center" prop="goodsAlipayAmount" width="100" />
  90. <el-table-column label="现金" align="center" prop="goodsCashAmount" width="100" />
  91. <el-table-column label="会员卡" align="center" prop="goodsMemberAmount" width="100" />
  92. </el-table-column>
  93. <el-table-column label="退款金额" align="center">
  94. <el-table-column label="微信退款" align="center" prop="goodsWechatRefundAmount" width="100" />
  95. <el-table-column label="支付宝退款" align="center" prop="goodsAlipayRefundAmount" width="100" />
  96. <el-table-column label="现金退款" align="center" prop="goodsCashRefundAmount" width="100" />
  97. <el-table-column label="会员卡退款" align="center" prop="goodsMemberRefundAmount" width="100" />
  98. </el-table-column>
  99. </el-table-column>
  100. </el-table>
  101. <pagination
  102. v-show="total > 0"
  103. :total="total"
  104. :page.sync="queryParams.pageNum"
  105. :limit.sync="queryParams.pageSize"
  106. @pagination="getList"
  107. />
  108. </div>
  109. </template>
  110. <script>
  111. import { listStatistics, listStatisticsByStore, exportStatistics, orderStaticsSync } from '@/api/settlement/statistics'
  112. export default {
  113. name: "StoreStatistics",
  114. data() {
  115. return {
  116. // 遮罩层
  117. userInfoVO: { },
  118. loading: false,
  119. // 显示搜索条件
  120. showSearch: true,
  121. // 总条数
  122. total: 0,
  123. // 统计列表数据
  124. statisticsList: [],
  125. // 日期范围
  126. dateRange: '',
  127. // 查询参数
  128. queryParams: {
  129. pageNum: 1,
  130. pageSize: 10,
  131. startDate: undefined,
  132. endDate: undefined
  133. }
  134. };
  135. },
  136. created() {
  137. // 设置默认日期范围为最近14天
  138. const end = new Date();
  139. const start = new Date();
  140. start.setTime(start.getTime());
  141. this.dateRange = this.parseTime(start, '{y}-{m}-{d}');
  142. this.userInfoVO = this.getUserInfo()
  143. this.getList();
  144. },
  145. methods: {
  146. /** 查询统计列表 */
  147. getList() {
  148. this.loading = true;
  149. if (this.dateRange) {
  150. this.queryParams.startDate = this.dateRange;
  151. } else {
  152. this.queryParams.startDate = undefined;
  153. }
  154. listStatisticsByStore(this.queryParams).then(response => {
  155. this.statisticsList = response.rows;
  156. this.total = response.total;
  157. this.loading = false;
  158. });
  159. },
  160. /** 搜索按钮操作 */
  161. handleQuery() {
  162. this.queryParams.pageNum = 1;
  163. this.getList();
  164. },
  165. /** 重置按钮操作 */
  166. resetQuery() {
  167. this.dateRange = [];
  168. this.resetForm("queryForm");
  169. this.handleQuery();
  170. },
  171. handleSync(){
  172. orderStaticsSync().then(response => {
  173. this.getList();
  174. });
  175. },
  176. /** 导出按钮操作 */
  177. handleExport() {
  178. const queryParams = { ...this.queryParams };
  179. if (this.dateRange && this.dateRange.length > 0) {
  180. queryParams.startDate = this.dateRange[0];
  181. queryParams.endDate = this.dateRange[1];
  182. }
  183. this.$confirm('是否确认导出所有统计数据项?', "警告", {
  184. confirmButtonText: "确定",
  185. cancelButtonText: "取消",
  186. type: "warning"
  187. }).then(() => {
  188. this.$download('/mapi/settlement/store/statistics/export', queryParams);
  189. });
  190. },
  191. // 解析日期显示
  192. parseDay(day) {
  193. if (!day) return '';
  194. const str = day.toString();
  195. return `${str.substring(0, 4)}-${str.substring(4, 6)}-${str.substring(6, 8)}`;
  196. },
  197. // 计算总支付金额
  198. calculateTotalPayAmount(row) {
  199. const clothPay = (row.clothWechatAmount || 0) +
  200. (row.clothAlipayAmount || 0) +
  201. (row.clothCashAmount || 0) +
  202. (row.clothMemberAmount || 0);
  203. const goodsPay = (row.goodsWechatAmount || 0) +
  204. (row.goodsAlipayAmount || 0) +
  205. (row.goodsCashAmount || 0) +
  206. (row.goodsMemberAmount || 0);
  207. return (clothPay + goodsPay).toFixed(2);
  208. },
  209. // 计算总退款金额
  210. calculateTotalRefundAmount(row) {
  211. const clothRefund = (row.clothWechatRefundAmount || 0) +
  212. (row.clothAlipayRefundAmount || 0) +
  213. (row.clothCashRefundAmount || 0) +
  214. (row.clothMemberRefundAmount || 0);
  215. const goodsRefund = (row.goodsWechatRefundAmount || 0) +
  216. (row.goodsAlipayRefundAmount || 0) +
  217. (row.goodsCashRefundAmount || 0) +
  218. (row.goodsMemberRefundAmount || 0);
  219. return (clothRefund + goodsRefund).toFixed(2);
  220. }
  221. }
  222. };
  223. </script>
  224. <style scoped>
  225. .el-table .warning-row {
  226. background: oldlace;
  227. }
  228. .el-table .success-row {
  229. background: #f0f9eb;
  230. }
  231. </style>