settlement.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218
  1. <style scoped lang="scss">
  2. .system-container {
  3. :deep(.el-card__body) {
  4. display: flex;
  5. flex-direction: column;
  6. justify-content: space-between;
  7. flex: 1;
  8. overflow: auto;
  9. .el-table {
  10. flex: 1;
  11. }
  12. }
  13. }
  14. .page-content {
  15. margin-bottom: 20px;
  16. }
  17. .page-pager {
  18. background-color: var(--el-color-white);
  19. height: 24px;
  20. }
  21. </style>
  22. <template>
  23. <div class="system-container layout-padding">
  24. <el-card shadow="hover" class="layout-padding-auto">
  25. <el-form
  26. :model="state.formQuery"
  27. ref="queryRef"
  28. size="default" label-width="0px" class="mt5 mb5">
  29. <ext-select
  30. v-model="state.formQuery.stationId"
  31. placeholder="站点"
  32. url="washStation/list"
  33. url-method="post"
  34. label-key="stationName"
  35. value-key="stationId"
  36. data-key="list"
  37. clearable
  38. class="wd200 ml10"/>
  39. <el-input
  40. v-model="state.formQuery.settlementPeriod"
  41. placeholder="结算周期 如 2026-05"
  42. clearable
  43. class="wd200 ml10"/>
  44. <el-select
  45. v-model="state.formQuery.status"
  46. placeholder="状态"
  47. clearable
  48. class="wd150 ml10">
  49. <el-option label="全部" value=""/>
  50. <el-option label="待结算" value="0"/>
  51. <el-option label="已结算" value="1"/>
  52. <el-option label="异常结算" value="2"/>
  53. </el-select>
  54. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  55. <SvgIcon name="ele-Search"/>
  56. 查询
  57. </el-button>
  58. <el-button class="ml10" plain size="default" type="warning" @click="handleTriggerSettlement">
  59. <SvgIcon name="ele-Money"/>
  60. 手动触发结算
  61. </el-button>
  62. </el-form>
  63. <el-table
  64. border
  65. stripe="stripe"
  66. :height="state.tableData.height"
  67. :data="state.tableData.data"
  68. v-loading="state.tableData.loading">
  69. <template #empty>
  70. <el-empty></el-empty>
  71. </template>
  72. <el-table-column
  73. v-for="field in state.columns"
  74. :key="field.prop"
  75. :label="field.label"
  76. :column-key="field.prop"
  77. :width="field.width"
  78. :min-width="field.minWidth"
  79. :fixed="field.fixed"
  80. :sortable="field.sortable"
  81. :show-overflow-tooltip="!field.fixed&&field.width>150">
  82. <template #default="{row}">
  83. <template v-if="field.prop==='status'">
  84. <el-tag :type="getStatusType(row.status)" size="small">
  85. {{ getStatusLabel(row.status) }}
  86. </el-tag>
  87. </template>
  88. <template v-else-if="['openingPendingBalance','totalRecharge','totalRefund','totalCrossIncome','totalCrossExpend','platformFeeBase','platformFee','settlementAmount','closingPendingBalance'].includes(field.prop)">
  89. {{ u.fmt.fmtMoney(row[field.prop]) }}
  90. </template>
  91. <template v-else-if="['createTime','updateTime'].includes(field.prop)">
  92. {{ u.fmt.fmtDateTime(row[field.prop]) }}
  93. </template>
  94. <template v-else>
  95. <div>{{ row[field.prop] }}</div>
  96. </template>
  97. </template>
  98. </el-table-column>
  99. </el-table>
  100. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  101. </el-card>
  102. </div>
  103. </template>
  104. <script setup lang="ts" name="adminFinanceSettlement">
  105. import {reactive, onMounted, ref, nextTick} from 'vue';
  106. import {$body} from "/@/utils/request";
  107. import u from '/@/utils/u'
  108. import {Msg} from "/@/utils/message";
  109. import ExtPage from '/@/components/form/ExtPage.vue'
  110. import ExtSelect from "/@/components/form/ExtSelect.vue";
  111. const queryRef = ref();
  112. const state = reactive({
  113. formQuery: {
  114. stationId: '',
  115. settlementPeriod: '',
  116. status: ''
  117. },
  118. pageQuery: {
  119. pageNum: 1,
  120. pageSize: 10,
  121. total: 0
  122. },
  123. tableData: {
  124. height: 500,
  125. data: [] as Array<any>,
  126. loading: false
  127. },
  128. columns: [
  129. {label: '站点名称', width: 180, prop: 'stationName', resizable: true},
  130. {label: '结算周期', width: 120, prop: 'settlementPeriod', resizable: true},
  131. {label: '期初余额(元)', width: 150, prop: 'openingPendingBalance', resizable: true},
  132. {label: '总充值(元)', width: 140, prop: 'totalRecharge', resizable: true},
  133. {label: '总退款(元)', width: 140, prop: 'totalRefund', resizable: true},
  134. {label: '跨店收入(元)', width: 140, prop: 'totalCrossIncome', resizable: true},
  135. {label: '跨店支出(元)', width: 140, prop: 'totalCrossExpend', resizable: true},
  136. {label: '平台费基数(元)', width: 150, prop: 'platformFeeBase', resizable: true},
  137. {label: '平台费(元)', width: 130, prop: 'platformFee', resizable: true},
  138. {label: '结算金额(元)', width: 150, prop: 'settlementAmount', resizable: true},
  139. {label: '期末余额(元)', width: 150, prop: 'closingPendingBalance', resizable: true},
  140. {label: '状态', width: 100, prop: 'status', resizable: true},
  141. {label: '备注', width: 180, prop: 'remark', resizable: true},
  142. {label: '创建时间', width: 180, prop: 'createTime', resizable: true},
  143. ],
  144. })
  145. onMounted(() => {
  146. loadData();
  147. nextTick(() => {
  148. let bodyHeight = document.body.clientHeight;
  149. let queryHeight = queryRef.value.$el.clientHeight;
  150. state.tableData.height = bodyHeight - queryHeight - 320
  151. })
  152. });
  153. const loadData = (refresh: boolean = false) => {
  154. if (refresh) {
  155. state.pageQuery.pageNum = 1;
  156. }
  157. state.tableData.loading = true;
  158. $body(`/finance/settlementRecords`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  159. let {list, total} = res;
  160. state.tableData.data = list || [];
  161. state.pageQuery.total = total || 0;
  162. state.tableData.loading = false;
  163. }).catch(e => {
  164. console.error(e)
  165. state.tableData.loading = false;
  166. })
  167. };
  168. const handleTriggerSettlement = () => {
  169. Msg.confirm(`确认手动触发本月结算吗?`, '手动结算').then(() => {
  170. Msg.showLoading(`结算执行中...`);
  171. $body(`finance/triggerSettlement`, {}).then(() => {
  172. Msg.message("结算已完成");
  173. Msg.hideLoading();
  174. loadData(true);
  175. }).catch(e => {
  176. Msg.hideLoading();
  177. })
  178. })
  179. };
  180. const getStatusLabel = (status: number) => {
  181. const map: Record<number, string> = {
  182. 0: '待结算',
  183. 1: '已结算',
  184. 2: '异常结算'
  185. };
  186. return map[status] || String(status);
  187. };
  188. const getStatusType = (status: number): any => {
  189. const map: Record<number, string> = {
  190. 0: 'info',
  191. 1: 'success',
  192. 2: 'danger'
  193. };
  194. return map[status] || 'info';
  195. };
  196. </script>