index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <!--
  2. * @Descripttion: 业绩统计
  3. * @version: 1.0
  4. * @Author: zzx
  5. * @Date: 2024-11-09 16:08:16
  6. * @LastEditors: zzx
  7. * @LastEditTime: 2025-02-19 16:08:16
  8. -->
  9. <template>
  10. <div class="app-container">
  11. <el-card class="filter-container" shadow="hover">
  12. <div>
  13. <i class="el-icon-search"></i>
  14. <span>筛选搜索</span>
  15. <el-button style="float: right" type="primary" @click="handleSearchList()" size="small">
  16. 查询搜索
  17. </el-button>
  18. <el-button style="float: right; margin-right: 15px" @click="handleResetSearch()" size="small">
  19. 重置
  20. </el-button>
  21. </div>
  22. <div style="margin-top: 15px">
  23. <el-form :inline="true" :model="listQuery" size="small" label-width="140px">
  24. <el-form-item label="分销员姓名:">
  25. <el-input v-model="listQuery.userName" class="input-width" placeholder="请输入用户名称"
  26. clearable></el-input>
  27. </el-form-item>
  28. <el-form-item label="分销员手机号:">
  29. <el-input v-model="listQuery.phone" class="input-width" placeholder="请输入手机号码"
  30. clearable></el-input>
  31. </el-form-item>
  32. </el-form>
  33. </div>
  34. </el-card>
  35. <el-card class="operate-container" shadow="hover">
  36. <div class="title">
  37. <div class="titleContent">
  38. <i class="el-icon-tickets"></i>
  39. <span>数据列表</span>
  40. <span class="tips">提现说明:限每月10号-15号提交提现申请,且只能提交一次</span>
  41. </div>
  42. <el-button class="ml10" type="info" size="small" :loading="downloadLoading" :disabled="exportDisabled" icon="el-icon-printer"
  43. @click="exportAllExcel">导出</el-button>
  44. </div>
  45. </el-card>
  46. <div class="table-container">
  47. <el-table ref="adminTable" :data="list" style="width: 100%" v-loading="listLoading" border>
  48. <el-table-column label="上级分销员手机号" align="center" prop="superiorsPhone">
  49. <template slot-scope="scope">
  50. {{ scope.row.superiorsPhone || '无上级' }}
  51. </template>
  52. </el-table-column>
  53. <el-table-column label="分销员层级" align="center" prop="">
  54. <template slot-scope="scope">
  55. <el-tag v-if="scope.row.type==2" type="success">一级</el-tag>
  56. <el-tag v-if="scope.row.type==3" type="warning">二级</el-tag>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="分销员姓名" align="center" prop="">
  60. <template slot-scope="scope">
  61. <span>{{ scope.row.userName || '--' }}</span>
  62. </template>
  63. </el-table-column>
  64. <el-table-column label="分销员手机号" align="center" prop="phone"></el-table-column>
  65. <!-- <el-table-column label="用户购券金额/元" align="center" prop="userTopAllMoney"></el-table-column> -->
  66. <!-- <el-table-column label="待清算金额/元" align="center" prop="unconsumedMoney"></el-table-column> -->
  67. <!-- <el-table-column label="用户退款金额/元" align="center" prop="userRefundAllMoney"></el-table-column> -->
  68. <el-table-column label="用户消费金额/元" align="center" prop="userConsumeAllMoney"></el-table-column>
  69. <el-table-column label="未提现佣金/元" align="center" prop="unWithdrawMoney"></el-table-column>
  70. <el-table-column label="待结算佣金/元" align="center">
  71. <template slot-scope="scope">
  72. {{ scope.row.unSettleAccountMoney || '0' }}
  73. </template>
  74. </el-table-column>
  75. <el-table-column label="已结算佣金/元" align="center">
  76. <template slot-scope="scope">
  77. {{ scope.row.settleAccountMoney || '0' }}
  78. </template>
  79. </el-table-column>
  80. <el-table-column label="操作" width="180" align="center">
  81. <template slot-scope="scope">
  82. <el-button v-if="isAdmin != 0" size="mini" type="warning" plain
  83. @click="withdrawApplyfor(scope.row)">
  84. 提现申请
  85. </el-button>
  86. </template>
  87. </el-table-column>
  88. </el-table>
  89. </div>
  90. <div class="pagination-container">
  91. <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
  92. layout="total, sizes,prev, pager, next,jumper" :current-page.sync="listQuery.pageNum"
  93. :page-size="listQuery.pageSize" :page-sizes="[10, 15, 20]" :total="total">
  94. </el-pagination>
  95. </div>
  96. <el-dialog title="提现申请" :visible.sync="forbiddenDialogVisible" width="40%" center>
  97. <el-descriptions border>
  98. <el-descriptions-item label="分销员姓名">{{ dialogQuery.userName }}</el-descriptions-item>
  99. <el-descriptions-item label="分销员手机号">{{ dialogQuery.phone }}</el-descriptions-item>
  100. <el-descriptions-item label="本次提现订单数/笔">{{ dialogQuery.orderCount || '--' }}</el-descriptions-item>
  101. <el-descriptions-item label="本次提现金额/元">{{ dialogQuery.unWithdrawMoney }}</el-descriptions-item>
  102. </el-descriptions>
  103. <div style="margin-top: 10px;font-size: 14px;color: #F4B01D ;">说明:提现的订单为今天( {{ new
  104. Date().toLocaleDateString() }}
  105. )之前</div>
  106. <span slot="footer" class="dialog-footer">
  107. <el-button @click="forbiddenDialogVisible = false" size="small">取 消</el-button>
  108. <el-button type="primary" @click="confirmRequest" :loading="requestLoading" size="small">确定</el-button>
  109. </span>
  110. </el-dialog>
  111. </div>
  112. </template>
  113. <script>
  114. import { performanceList, withdrawRequest } from "@/api/distribution";
  115. import { formatDate } from "@/utils/date";
  116. import FileSaver from 'file-saver';
  117. import XLSX from 'xlsx';
  118. const defaultListQuery = {
  119. pageNum: 1,
  120. pageSize: 10,
  121. userName: null,
  122. phone: null,
  123. startTime: '',
  124. endTime: ''
  125. };
  126. export default {
  127. name: "statistics",
  128. data() {
  129. return {
  130. exportDisabled: false,
  131. isAdmin: null,
  132. downloadLoading: false,
  133. requestLoading: false,
  134. date: "",
  135. listQuery: Object.assign({}, defaultListQuery),
  136. list: null,
  137. total: null,
  138. listLoading: false,
  139. forbiddenDialogVisible: false,
  140. dialogQuery: {}
  141. };
  142. },
  143. watch: {
  144. date(val) {
  145. if (val) {
  146. this.listQuery.startTime = Date.parse(val[0]);
  147. this.listQuery.endTime = Date.parse(val[1]);
  148. } else {
  149. this.listQuery.startTime = "";
  150. this.listQuery.endTime = "";
  151. }
  152. },
  153. },
  154. created() {
  155. this.isAdmin = localStorage.getItem("isAdmin");
  156. this.getList();
  157. },
  158. filters: {
  159. formatDateTime(time) {
  160. if (time == null || time === "") {
  161. return "N/A";
  162. }
  163. let date = new Date(time);
  164. return formatDate(date, "yyyy-MM-dd hh:mm:ss");
  165. },
  166. },
  167. methods: {
  168. // 跳转至记录列表
  169. // pushRecords(row) {
  170. // this.$router.push({
  171. // path: "/distribution/records",
  172. // query: {
  173. // adminUserId: row.adminUserId,
  174. // },
  175. // });
  176. // },
  177. // 导出
  178. exportAllExcel() {
  179. this.downloadLoading = true
  180. const allData = [];
  181. let query = JSON.parse(JSON.stringify(this.listQuery))
  182. query.pageSize = this.total
  183. query.page = 0
  184. performanceList(query).then(res => {
  185. this.downloadLoading = false
  186. if (res.code == 200) {
  187. allData.push(...res.data.list);
  188. this.exportExcel(allData);
  189. }
  190. });
  191. },
  192. // 导出数据处理
  193. exportExcel(r) {
  194. const data = r.map((item) => {
  195. return {
  196. "上级分销员手机号": item.superiorsPhone || '无上级',
  197. "分销员层级": item.type == 2 ? '一级' : '二级',
  198. "分销员姓名": item.userName|| '--',
  199. "分销员手机号": item.phone,
  200. "用户消费金额/元": item.userConsumeAllMoney,
  201. "未提现佣金/元": item.unWithdrawMoney,
  202. "待结算佣金/元": item.unSettleAccountMoney,
  203. "已结算佣金/元": item.settleAccountMoney,
  204. }
  205. })
  206. const worksheet = XLSX.utils.json_to_sheet(data);
  207. const workbook = { Sheets: { data: worksheet }, SheetNames: ['data'] };
  208. const excelBuffer = XLSX.write(workbook, { bookType: 'xlsx', type: 'array' });
  209. const blob = new Blob([excelBuffer], { type: 'application/octet-stream' });
  210. FileSaver.saveAs(blob, '分销统计表.xlsx');
  211. },
  212. // 结算申请
  213. withdrawApplyfor(row) {
  214. this.forbiddenDialogVisible = true;
  215. this.dialogQuery = row;
  216. },
  217. // 确认
  218. confirmRequest() {
  219. this.requestLoading = true;
  220. setTimeout(() => {
  221. this.requestLoading = false;
  222. },1000)
  223. withdrawRequest({ adminUserId: this.dialogQuery.adminUserId }).then(res => {
  224. if (res.code == 200) {
  225. this.$message({
  226. message: '操作成功',
  227. type: 'success'
  228. });
  229. this.forbiddenDialogVisible = false;
  230. this.getList();
  231. }
  232. })
  233. },
  234. handleResetSearch() {
  235. this.listQuery = Object.assign({}, defaultListQuery);
  236. },
  237. handleSearchList() {
  238. this.listQuery.pageNum = 1;
  239. this.getList();
  240. },
  241. handleSizeChange(val) {
  242. this.listQuery.pageNum = 1;
  243. this.listQuery.pageSize = val;
  244. this.getList();
  245. },
  246. handleCurrentChange(val) {
  247. this.listQuery.pageNum = val;
  248. this.getList();
  249. },
  250. getList() {
  251. this.listLoading = true;
  252. performanceList(this.listQuery).then((response) => {
  253. this.listLoading = false;
  254. this.list = response.data.list;
  255. this.total = response.data.total;
  256. if(this.list.length <= 0){
  257. this.exportDisabled = true;
  258. }else{
  259. this.exportDisabled = false;
  260. }
  261. });
  262. },
  263. },
  264. };
  265. </script>
  266. <style scoped lang="scss">
  267. .title {
  268. display: flex;
  269. align-items: center;
  270. justify-content: space-between;
  271. .titleContent {
  272. .tips {
  273. font-size: 13px;
  274. color: #ff0000;
  275. margin-left: 20px;
  276. }
  277. }
  278. }
  279. .pushRecords {
  280. color: #409EFF;
  281. cursor: pointer;
  282. }
  283. </style>