split-record.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <script setup lang="ts">
  2. import { reactive, onMounted, ref, nextTick } from "vue";
  3. import { getSplitRecordList } from "@/api/finance";
  4. import { getStationList } from "@/api/station";
  5. import { useRenderIcon } from "@/components/ReIcon/src/hooks";
  6. import { ExtDLabel, ExtDSelect } from "@/components/ExtForm";
  7. defineOptions({
  8. name: "AdminFinanceSplitRecord"
  9. });
  10. const queryRef = ref();
  11. const tableRef = ref();
  12. const state = reactive({
  13. formQuery: {
  14. stationId: "",
  15. tradeNo: "",
  16. type: ""
  17. },
  18. pageQuery: {
  19. pageNum: 1,
  20. pageSize: 10,
  21. total: 0
  22. },
  23. stationOptions: [] as Array<{ stationId: string; stationName: string }>,
  24. tableData: {
  25. height: 500,
  26. data: [] as Array<any>,
  27. loading: false,
  28. columns: [
  29. { label: "入账站点ID/名称", prop: "toStationId", width: 200 },
  30. { label: "出账站点ID/名称", prop: "fromStationId", width: 200 },
  31. { label: "分账交易金额(元)", prop: "amount", width: 180 },
  32. { label: "分账交易流水号", prop: "tradeNo", width: 280 },
  33. { label: "交易类型", prop: "type", width: 130 },
  34. { label: "创建时间", prop: "createTime", width: 180 },
  35. { label: "更新时间", prop: "updateTime", width: 180 }
  36. ]
  37. }
  38. });
  39. onMounted(() => {
  40. loadStationOptions();
  41. loadData();
  42. nextTick(() => {
  43. const bodyHeight = document.body.clientHeight;
  44. const queryHeight = queryRef.value?.$el?.clientHeight || 0;
  45. state.tableData.height = bodyHeight - queryHeight - 280;
  46. });
  47. });
  48. const loadStationOptions = () => {
  49. getStationList({ pageSize: 1000 }).then((res: any) => {
  50. const { list } = res || {};
  51. state.stationOptions = list || [];
  52. });
  53. };
  54. const loadData = (refresh: boolean = false) => {
  55. if (refresh) {
  56. state.pageQuery.pageNum = 1;
  57. }
  58. state.tableData.loading = true;
  59. getSplitRecordList({ ...state.formQuery, ...state.pageQuery })
  60. .then((res: any) => {
  61. const { list, total } = res || {};
  62. state.tableData.data = list || [];
  63. state.pageQuery.total = total || 0;
  64. })
  65. .catch(() => {
  66. state.tableData.data = [];
  67. })
  68. .finally(() => {
  69. state.tableData.loading = false;
  70. });
  71. };
  72. const handleSizeChange = (size: number) => {
  73. state.pageQuery.pageSize = size;
  74. loadData(true);
  75. };
  76. const handleCurrentChange = (page: number) => {
  77. state.pageQuery.pageNum = page;
  78. loadData();
  79. };
  80. const handleSearch = () => {
  81. loadData(true);
  82. };
  83. const handleReset = () => {
  84. state.formQuery = {
  85. stationId: "",
  86. tradeNo: "",
  87. type: ""
  88. };
  89. loadData(true);
  90. };
  91. const formatMoney = (value: number) => {
  92. if (value === null || value === undefined) return "0.00";
  93. return (value / 100).toFixed(2);
  94. };
  95. </script>
  96. <template>
  97. <div class="page-container">
  98. <el-card shadow="hover">
  99. <el-form
  100. ref="queryRef"
  101. :model="state.formQuery"
  102. inline
  103. class="search-form"
  104. >
  105. <el-form-item label="站点">
  106. <el-select
  107. v-model="state.formQuery.stationId"
  108. placeholder="选择站点"
  109. clearable
  110. filterable
  111. @change="handleSearch"
  112. >
  113. <el-option
  114. v-for="item in state.stationOptions"
  115. :key="item.stationId"
  116. :label="item.stationName"
  117. :value="item.stationId"
  118. />
  119. </el-select>
  120. </el-form-item>
  121. <el-form-item label="交易流水号">
  122. <el-input
  123. v-model="state.formQuery.tradeNo"
  124. placeholder="请输入交易流水号"
  125. clearable
  126. @keyup.enter="handleSearch"
  127. />
  128. </el-form-item>
  129. <el-form-item label="分账类型">
  130. <ExtDSelect
  131. v-model="state.formQuery.type"
  132. type="SplitRecord.type"
  133. placeholder="请选择分账类型"
  134. @on-change="handleSearch"
  135. />
  136. </el-form-item>
  137. <el-form-item>
  138. <el-button
  139. type="primary"
  140. :icon="useRenderIcon('ri/search-line')"
  141. @click="handleSearch"
  142. >
  143. 查询
  144. </el-button>
  145. <el-button
  146. :icon="useRenderIcon('ri/refresh-line')"
  147. @click="handleReset"
  148. >
  149. 重置
  150. </el-button>
  151. </el-form-item>
  152. </el-form>
  153. <el-table
  154. ref="tableRef"
  155. v-loading="state.tableData.loading"
  156. :data="state.tableData.data"
  157. :height="state.tableData.height"
  158. border
  159. stripe
  160. >
  161. <template #empty>
  162. <el-empty description="暂无数据" />
  163. </template>
  164. <el-table-column
  165. v-for="col in state.tableData.columns"
  166. :key="col.prop"
  167. :prop="col.prop"
  168. :label="col.label"
  169. :width="col.width"
  170. show-overflow-tooltip
  171. >
  172. <template #default="{ row }">
  173. <template v-if="col.prop === 'toStationId'">
  174. <div class="station-name-cell">
  175. <div class="station-id">{{ row.toStationId }}</div>
  176. <el-divider direction="horizontal" />
  177. <div class="station-name">{{ row.toStationName }}</div>
  178. </div>
  179. </template>
  180. <template v-else-if="col.prop === 'fromStationId'">
  181. <div class="station-name-cell">
  182. <div class="station-id">{{ row.fromStationId }}</div>
  183. <el-divider direction="horizontal" />
  184. <div class="station-name">{{ row.fromStationName }}</div>
  185. </div>
  186. </template>
  187. <template v-else-if="col.prop === 'amount'">
  188. <span class="money">¥{{ formatMoney(row.amount) }}</span>
  189. </template>
  190. <template v-else-if="col.prop === 'type'">
  191. <ExtDLabel type="SplitRecord.type" :model-value="row.type" />
  192. </template>
  193. <template v-else>
  194. {{ row[col.prop] }}
  195. </template>
  196. </template>
  197. </el-table-column>
  198. </el-table>
  199. <div class="pagination-container">
  200. <el-pagination
  201. v-model:current-page="state.pageQuery.pageNum"
  202. v-model:page-size="state.pageQuery.pageSize"
  203. :total="state.pageQuery.total"
  204. :page-sizes="[10, 20, 50, 100]"
  205. layout="total, sizes, prev, pager, next, jumper"
  206. @size-change="handleSizeChange"
  207. @current-change="handleCurrentChange"
  208. />
  209. </div>
  210. </el-card>
  211. </div>
  212. </template>
  213. <style scoped lang="scss">
  214. .page-container {
  215. padding: 15px;
  216. }
  217. .search-form {
  218. margin-bottom: 15px;
  219. }
  220. .pagination-container {
  221. display: flex;
  222. justify-content: flex-end;
  223. margin-top: 15px;
  224. }
  225. .station-name-cell {
  226. text-align: center;
  227. .station-id {
  228. color: #909399;
  229. font-size: 12px;
  230. }
  231. .station-name {
  232. font-weight: 500;
  233. }
  234. .el-divider {
  235. margin: 4px 0;
  236. }
  237. }
  238. .money {
  239. font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
  240. color: #f56c6c;
  241. font-weight: 500;
  242. }
  243. </style>