appOrderCountStats.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <template>
  2. <div class="app-container">
  3. <div class="app-content">
  4. <div class="title">App商城订单统计</div>
  5. <el-form class="search-form" :inline="true">
  6. <el-form-item label="公司名称" prop="companyId">
  7. <el-select
  8. style="width: 220px"
  9. filterable
  10. v-model="queryParams.companyId"
  11. placeholder="请选择公司名"
  12. clearable
  13. size="small"
  14. >
  15. <el-option
  16. v-for="item in companys"
  17. :key="item.companyId"
  18. :label="item.companyName"
  19. :value="item.companyId"
  20. />
  21. </el-select>
  22. </el-form-item>
  23. <el-form-item label="员工" prop="companyUserId">
  24. <el-select
  25. filterable
  26. v-model="queryParams.companyUserId"
  27. placeholder="请选择员工"
  28. clearable
  29. size="small"
  30. :disabled="!queryParams.companyId"
  31. >
  32. <el-option
  33. v-for="item in users"
  34. :key="item.userId"
  35. :label="item.nickName"
  36. :value="item.userId"
  37. />
  38. </el-select>
  39. </el-form-item>
  40. <el-form-item label="下单日期">
  41. <el-date-picker
  42. clearable
  43. size="small"
  44. style="width: 205.4px"
  45. v-model="dateRange"
  46. type="daterange"
  47. value-format="yyyy-MM-dd"
  48. start-placeholder="开始日期"
  49. end-placeholder="结束日期"
  50. />
  51. </el-form-item>
  52. <el-form-item>
  53. <el-button type="primary" icon="el-icon-search" @click="search">搜索</el-button>
  54. </el-form-item>
  55. </el-form>
  56. <div class="data-box">
  57. <div class="table-box">
  58. <el-table :data="tableData" border max-height="500" style="width: 100%">
  59. <el-table-column prop="category" label="订单类型" width="180" />
  60. <el-table-column prop="orderCount" label="订单数" />
  61. <el-table-column prop="orderAmount" label="订单总金额(元)" />
  62. <el-table-column prop="depositAmount" label="定金金额(元)" />
  63. <el-table-column prop="codAmount" label="物流代收金额(元)" />
  64. </el-table>
  65. </div>
  66. </div>
  67. </div>
  68. </div>
  69. </template>
  70. <script>
  71. import { getAppOrderCount } from "@/api/company/statistics";
  72. import { getUserList } from "@/api/company/companyUser"; // 使用 getUserList(companyId)
  73. import { getCompanyList } from "@/api/company/company";
  74. export default {
  75. name: "AppOrderCountStats",
  76. data() {
  77. return {
  78. // 仅保留必要查询参数
  79. queryParams: {
  80. companyId: null,
  81. companyUserId: null
  82. },
  83. companys: [], // 公司列表
  84. users: [], // 员工列表
  85. dateRange: [], // 日期范围
  86. tableData: [] // 表格数据
  87. };
  88. },
  89. watch: {
  90. // 公司变化时,重新加载员工
  91. 'queryParams.companyId'(newVal) {
  92. if (newVal) {
  93. this.queryParams.companyUserId = null;
  94. this.loadUsers();
  95. } else {
  96. this.users = [];
  97. this.queryParams.companyUserId = null;
  98. }
  99. }
  100. },
  101. created() {
  102. // 初始化公司下拉列表
  103. getCompanyList().then(response => {
  104. this.companys = response.data || [];
  105. });
  106. },
  107. methods: {
  108. // 根据 companyId 加载员工
  109. loadUsers() {
  110. const companyId = this.queryParams.companyId;
  111. if (!companyId) return;
  112. getUserList(companyId).then(res => {
  113. if (res.code === 200) {
  114. this.users = Array.isArray(res.data) ? res.data : [];
  115. } else {
  116. this.users = [];
  117. }
  118. }).catch(() => {
  119. this.users = [];
  120. });
  121. },
  122. // 搜索统计
  123. search() {
  124. const params = {
  125. companyId: this.queryParams.companyId,
  126. companyUserId: this.queryParams.companyUserId,
  127. startTime: this.dateRange?.[0] || undefined,
  128. endTime: this.dateRange?.[1] ? this.dateRange[1] + " 23:59:59" : undefined
  129. };
  130. getAppOrderCount(params).then(response => {
  131. const vo = response.data;
  132. // this.tableData = vo ? [vo] : [];
  133. this.tableData = response.data || []; // 直接赋值数组
  134. }).catch(() => {
  135. this.tableData = [];
  136. });
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="scss" scoped>
  142. .app-container {
  143. border: 1px solid #e6e6e6;
  144. padding: 12px;
  145. .app-content {
  146. background-color: white;
  147. .title {
  148. padding: 20px 30px 0px 30px;
  149. font-size: 18px;
  150. font-weight: bold;
  151. color: black;
  152. }
  153. .search-form {
  154. margin: 20px 30px 0px 30px;
  155. }
  156. .data-box {
  157. padding: 30px;
  158. background-color: rgb(255, 255, 255);
  159. height: 100%;
  160. .table-box {
  161. margin-top: 15px;
  162. }
  163. }
  164. }
  165. }
  166. </style>