todayIncomeList.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274
  1. <template>
  2. <div class="todayIncomeList">
  3. <!-- 头部 -->
  4. <div class="header">
  5. <el-button class="back-btn" @click="goBack"> 返回 </el-button>
  6. <h2 class="title">今日可收益金额</h2>
  7. </div>
  8. <div class="table-box">
  9. <ProTable
  10. ref="proTable"
  11. :columns="columns"
  12. :request-api="getTableList"
  13. :init-param="initParam"
  14. :data-callback="dataCallback"
  15. :pagination="true"
  16. :height="tableHeight"
  17. >
  18. <!-- 表格操作 -->
  19. <template #operation="scope">
  20. <el-button type="primary" link @click="toDetail(scope.row)"> 查看详情 </el-button>
  21. </template>
  22. </ProTable>
  23. <el-dialog v-model="dialogVisible" title="详情" width="500px">
  24. <h2 class="orderInfo">
  25. {{ unposted.storeName }}
  26. </h2>
  27. <el-row class="couponRow">
  28. <el-col :span="12"> 实际收益: {{ ((unposted.money || 0) / 100).toFixed(2) }} </el-col>
  29. <el-col :span="12">
  30. {{ `技术服务费(${commissionRate}%):` }}:
  31. {{ unposted.commission != null ? (unposted.commission / 100).toFixed(2) : "--" }}
  32. </el-col>
  33. </el-row>
  34. <el-row class="couponRow">
  35. <el-col :span="12">
  36. 售价: {{ ((Number(unposted.money) + Number(unposted.commission)) / 100).toFixed(2) || "0.00" }}
  37. </el-col>
  38. </el-row>
  39. <h3 class="orderInfo">订单信息</h3>
  40. <div>
  41. <div class="couponRow">下单时间: {{ unposted.orderTime != null ? unposted.orderTime : "--" }}</div>
  42. <div class="couponRow">验券时间: {{ unposted.checkTime != null ? unposted.checkTime : "--" }}</div>
  43. <div class="couponRow">入账时间: {{ unposted.incomeTime != null ? unposted.incomeTime : "--" }}</div>
  44. </div>
  45. </el-dialog>
  46. </div>
  47. </div>
  48. </template>
  49. <script setup lang="tsx" name="voucherManagement">
  50. import { computed, onActivated, onMounted, reactive, ref, watch } from "vue";
  51. import { useRouter } from "vue-router";
  52. import type { FormInstance, FormRules } from "element-plus";
  53. import { ElMessage } from "element-plus";
  54. import ProTable from "@/components/ProTable/index.vue";
  55. import { ColumnProps, ProTableInstance } from "@/components/ProTable/interface";
  56. import { getGroupIncome } from "@/api/modules/homeEntry";
  57. import { ElMessageBox } from "element-plus/es";
  58. import { localGet } from "@/utils";
  59. const commissionRate = localGet("commissionRate") || "";
  60. const router = useRouter();
  61. const dialogVisible = ref(false);
  62. const unposted = ref<any>({});
  63. // 计算表格高度
  64. const tableHeight = ref<string>("calc(100vh - 200px)");
  65. const toDetail = (row: any) => {
  66. dialogVisible.value = true;
  67. unposted.value = row;
  68. };
  69. // 返回
  70. const goBack = () => {
  71. router.back();
  72. };
  73. // ProTable 实例(需要在使用它的地方之前定义)
  74. const proTable = ref<ProTableInstance>();
  75. // 表格配置项
  76. const columns = reactive<ColumnProps<any>[]>([
  77. {
  78. prop: "storeName",
  79. label: "商品名称"
  80. },
  81. {
  82. prop: "money",
  83. label: "实际收益",
  84. render: scope => {
  85. return ((scope.row.money || 0) / 100).toFixed(2) || "0.00";
  86. }
  87. },
  88. {
  89. prop: "price",
  90. label: "售价",
  91. render: scope => {
  92. return ((Number(scope.row.money) + Number(scope.row.commission)) / 100).toFixed(2) || "0.00";
  93. }
  94. },
  95. {
  96. prop: "commission",
  97. label: "技术服务费",
  98. render: scope => {
  99. return (scope.row.commission / 100).toFixed(2) || "0.00";
  100. }
  101. },
  102. { prop: "operation", label: "操作", fixed: "right", width: 330 }
  103. ]);
  104. // 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
  105. const initParam = reactive({
  106. storeId: localGet("createdId"),
  107. incomeType: 0,
  108. startTime: null,
  109. endTime: null
  110. });
  111. // 页面加载时触发查询
  112. onMounted(async () => {
  113. proTable.value?.getTableList();
  114. });
  115. // 从其他页面返回时触发查询
  116. onActivated(() => {
  117. proTable.value?.getTableList();
  118. });
  119. // dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
  120. // 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
  121. const commissionRate = ref("");
  122. const dataCallback = (data: any) => {
  123. commissionRate.value = data.commissionRate;
  124. return {
  125. list: data.incomeDetailsRecordVoList,
  126. total: data.data?.total || data.total || 0
  127. };
  128. };
  129. // 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
  130. // 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
  131. const getTableList = (params: any) => {
  132. // 获取当前日期,格式为 YYYY-MM-DD
  133. const today = new Date();
  134. const year = today.getFullYear();
  135. const month = String(today.getMonth() + 1).padStart(2, "0");
  136. const day = String(today.getDate()).padStart(2, "0");
  137. const currentDate = `${year}-${month}-${day}`;
  138. let newParams = JSON.parse(JSON.stringify(params));
  139. // 设置固定参数
  140. newParams.date = currentDate;
  141. newParams.incomeType = 1;
  142. // 确保分页参数存在
  143. newParams.page = params.page || params.pageNum || 1;
  144. newParams.size = params.size || params.pageSize || 10;
  145. return getGroupIncome(newParams);
  146. };
  147. </script>
  148. <style lang="scss" scoped>
  149. .todayIncomeList {
  150. display: flex;
  151. flex-direction: column;
  152. height: 100%;
  153. overflow: hidden;
  154. }
  155. .table-box {
  156. display: flex;
  157. flex: 1;
  158. flex-direction: column;
  159. overflow: hidden;
  160. :deep(.table-main) {
  161. display: flex;
  162. flex: 1;
  163. flex-direction: column;
  164. overflow: hidden;
  165. .el-table {
  166. flex: 1;
  167. overflow: hidden;
  168. }
  169. .el-table__body-wrapper {
  170. overflow-y: auto !important;
  171. }
  172. }
  173. }
  174. .header {
  175. position: relative;
  176. display: flex;
  177. align-items: center;
  178. padding: 15px;
  179. background: #ffffff;
  180. border-radius: 5px;
  181. box-shadow: 0 0 12px rgb(0 0 0 / 5%);
  182. .back-btn {
  183. padding: 8px 16px;
  184. font-size: 14px;
  185. color: #606266;
  186. background-color: #f5f7fa;
  187. border: 1px solid #dcdfe6;
  188. border-radius: 4px;
  189. &:hover {
  190. color: #409eff;
  191. background-color: #ecf5ff;
  192. border-color: #b3d8ff;
  193. }
  194. }
  195. .title {
  196. position: absolute;
  197. left: 50%;
  198. margin: 0;
  199. font-size: 18px;
  200. font-weight: bold;
  201. color: #333333;
  202. transform: translateX(-50%);
  203. }
  204. }
  205. // 在组件样式中添加
  206. .date-range {
  207. display: block; // 确保换行生效
  208. padding: 0 8px; // 可选:增加内边距
  209. word-wrap: break-word; // 长单词内换行
  210. white-space: normal; // 允许自然换行
  211. }
  212. .table-header-btn {
  213. .button {
  214. margin-bottom: 10px;
  215. }
  216. .tabs {
  217. :deep(.el-tabs__nav-wrap::after) {
  218. height: 0;
  219. }
  220. }
  221. }
  222. .orderInfo {
  223. padding-bottom: 20px;
  224. font-size: 18px;
  225. font-weight: bold;
  226. }
  227. .couponRow {
  228. padding-bottom: 20px;
  229. }
  230. .couponRow:last-child {
  231. padding-bottom: 0;
  232. }
  233. .reject-reason-content {
  234. padding: 20px 0;
  235. .reject-reason-item {
  236. display: flex;
  237. margin-bottom: 20px;
  238. &:last-child {
  239. margin-bottom: 0;
  240. }
  241. .reject-reason-label {
  242. flex-shrink: 0;
  243. min-width: 100px;
  244. font-size: 14px;
  245. font-weight: 500;
  246. color: #606266;
  247. }
  248. .reject-reason-value {
  249. flex: 1;
  250. font-size: 14px;
  251. color: #303133;
  252. word-break: break-word;
  253. &.reject-reason-text {
  254. min-height: 80px;
  255. padding: 12px;
  256. line-height: 1.6;
  257. white-space: pre-wrap;
  258. background-color: #f5f7fa;
  259. border-radius: 4px;
  260. }
  261. }
  262. }
  263. }
  264. </style>