team-achievement.php 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-user-info');
  4. ?>
  5. <com-list-page :crumbs="crumbs" id="application">
  6. <com-list-table
  7. ref="table"
  8. :api-params="apiParams"
  9. :search-list="searchList"
  10. @get-api-data="handleSetData"
  11. >
  12. <el-table-column prop="user_id" label="会员ID" align="center"></el-table-column>
  13. <el-table-column prop="user" label="会员" align="center">
  14. <template slot-scope="scope">
  15. <com-user-info :user="scope.row.user"></com-user-info>
  16. </template>
  17. </el-table-column>
  18. <el-table-column prop="order_no" label="订单号" align="center">
  19. <template slot-scope="scope">
  20. {{ scope.row.order.order_no }}
  21. </template>
  22. </el-table-column>
  23. <el-table-column prop="pay_money" label="支付金额" align="center">
  24. <template slot-scope="scope">
  25. {{ scope.row.order.pay_money.toFixed(2) }}
  26. </template>
  27. </el-table-column>
  28. <el-table-column prop="shipping_money" label="运费" align="center">
  29. <template slot-scope="scope">
  30. {{ scope.row.order.shipping_money.toFixed(2) }}
  31. </template>
  32. </el-table-column>
  33. <el-table-column prop="achievement" label="业绩" align="center">
  34. <template slot-scope="scope">
  35. {{ scope.row.order.achievement.toFixed(2) }}
  36. </template>
  37. </el-table-column>
  38. <el-table-column prop="pay_time" label="支付时间" align="center">
  39. <template slot-scope="scope">
  40. {{ scope.row.order.pay_time|dateTimeFormat('Y-m-d H:i:s') }}
  41. </template>
  42. </el-table-column>
  43. <el-table-column prop="created_at" label="下单时间" align="center">
  44. <template slot-scope="scope">
  45. {{ scope.row.order.created_at|dateTimeFormat('Y-m-d H:i:s') }}
  46. </template>
  47. </el-table-column>
  48. <el-table-column prop="created_at" label="操作" align="center">
  49. <template slot-scope="scope">
  50. <el-button type="text" size="mini" @click="lookDetail(scope.row.order_id)">订单详情</el-button>
  51. </template>
  52. </el-table-column>
  53. <!-- 统计 -->
  54. <template slot="statistics">
  55. <el-row :gutter="24" class="statistics-box">
  56. <el-col :span="8" v-for="(item, index) in statistic" :key="index">
  57. <el-statistic
  58. group-separator=","
  59. :precision="item.precision"
  60. :value="item.value"
  61. :title="item.title"
  62. ></el-statistic>
  63. </el-col>
  64. </el-row>
  65. </template>
  66. <template slot="header-left">
  67. <el-button type="primary" size="mini" @click="exportData" :loading="btnLoad" :disabled="btnLoad">导出全部</el-button>
  68. </template>
  69. </com-list-table>
  70. <!-- 订单详情 -->
  71. <el-dialog title="订单详情" :visible.sync="dialogVisible" width="80%" >
  72. <el-table :data="tableData" border style="width: 100%; max-height: 500px; overflow: hidden; scroll: hidden;">
  73. <el-table-column prop="id" label="编号" width="80" align='center'>
  74. </el-table-column>
  75. <el-table-column prop="order_no" label="订单号" align='center'>
  76. </el-table-column>
  77. <el-table-column prop="" label="商品名" align='center'>
  78. <template slot-scope="scope">
  79. {{ scope.row.detail[0].goods_name }}
  80. </template>
  81. </el-table-column>
  82. <el-table-column prop="" label="规格" align='center'>
  83. <template slot-scope="scope">
  84. <div class="detail-for">
  85. <div v-for="(item, index) in scope.row.detail" :key="index">
  86. {{ item.goods_attr_name}}
  87. </div>
  88. </div>
  89. </template>
  90. </el-table-column>
  91. <el-table-column prop="" label="购买数量" align='center'>
  92. <template slot-scope="scope">
  93. <div class="detail-for">
  94. <div v-for="(item, index) in scope.row.detail" :key="index">
  95. {{ item.num}}
  96. </div>
  97. </div>
  98. </template>
  99. </el-table-column>
  100. <el-table-column prop="" label="单价" align='center'>
  101. <template slot-scope="scope">
  102. <div class="detail-for">
  103. <div v-for="(item, index) in scope.row.detail" :key="index">
  104. {{ item.price}}
  105. </div>
  106. </div>
  107. </template>
  108. </el-table-column>
  109. <el-table-column prop="" label="支付金额" align='center'>
  110. <template slot-scope="scope">
  111. <div class="detail-for">
  112. <div v-for="(item, index) in scope.row.detail" :key="index">
  113. {{ item.goods_price}}
  114. </div>
  115. </div>
  116. </template>
  117. </el-table-column>
  118. </el-table>
  119. <div class="detail-center">
  120. <el-button type="primary" size="mini" @click="dialogVisible = false">返回</el-button>
  121. </div>
  122. </el-dialog>
  123. </com-list-page>
  124. <script>
  125. const application = new Vue({
  126. el: '#application',
  127. data: {
  128. uid: 0,
  129. name: '',
  130. levelList: [],
  131. searchList: [
  132. {
  133. key: 'keyword',
  134. title: '会员ID/昵称/手机号',
  135. type: 'text',
  136. },
  137. {
  138. key: 'date',
  139. title: '下单日期',
  140. type: 'date-picker',
  141. valueFormat: 'yyyy-MM-dd',
  142. },
  143. ],
  144. btnLoad: false,
  145. statistic: [
  146. {
  147. title: '粉丝订单数',
  148. value: 0,
  149. precision: 0,
  150. },
  151. {
  152. title: '粉丝订单金额',
  153. value: 0,
  154. precision: 2,
  155. },
  156. {
  157. title: '粉丝订单业绩',
  158. value: 0,
  159. precision: 2,
  160. },
  161. ],
  162. dialogVisible: false,
  163. tableData: [],
  164. },
  165. computed: {
  166. apiParams() {
  167. return {
  168. r: 'mall/statistics/team-achievement',
  169. uid: this.uid
  170. }
  171. },
  172. crumbs() {
  173. return [
  174. {
  175. title: '首页',
  176. router: 'mall/overview/index',
  177. },
  178. {
  179. title: '团队人数',
  180. router: 'mall/statistics/team-size',
  181. },
  182. {
  183. title: this.name + '的团队业绩',
  184. }
  185. ]
  186. },
  187. },
  188. created() {
  189. this.uid = getQuery('uid')
  190. this.name = getQuery('name')
  191. },
  192. methods: {
  193. handleSetData(data) {
  194. this.statistic[0].value = data.total_order_num
  195. this.statistic[1].value = data.total_pay_money
  196. this.statistic[2].value = data.total_pay_achievement
  197. },
  198. exportData() {
  199. let searchParams = JSON.stringify(this.$refs['table'].searchParams) == '{}'
  200. ? {}
  201. : this.$refs['table'].searchParams
  202. let params = {
  203. date: searchParams.date,
  204. uid: this.uid,
  205. }
  206. this.btnLoad = true;
  207. request({
  208. params: {
  209. r: 'mall/statistics/team-achievement-export'
  210. },
  211. data: {params},
  212. method: 'post',
  213. }).then(e => {
  214. if (e.data.code === 0) {
  215. this.$message.success(e.data.msg)
  216. } else {
  217. this.$message.error(e.data.msg)
  218. }
  219. this.btnLoad = false
  220. }).catch(e => {
  221. this.btnLoad = false
  222. this.$message.error('未知错误')
  223. })
  224. },
  225. lookDetail(id) {
  226. request({
  227. params: {
  228. r: 'mall/statistics/order-detail',
  229. order_id: id
  230. },
  231. method: 'get',
  232. }).then(e => {
  233. if (e.data.code === 0) {
  234. this.dialogVisible = true
  235. this.tableData = e.data.data
  236. } else {
  237. this.$message.error(e.data.msg)
  238. }
  239. }).catch(e => {
  240. this.$message.error('未知错误')
  241. })
  242. },
  243. }
  244. })
  245. </script>
  246. <style>
  247. .statistics-box {
  248. margin: 10px 0;
  249. }
  250. .detail-for {
  251. display: flex;
  252. flex-direction: column;
  253. align-items: center;
  254. justify-content: center;
  255. }
  256. .detail-center {
  257. display: flex;
  258. justify-content: center;
  259. margin-top: 20px;
  260. }
  261. </style>