index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  40. <SvgIcon name="ele-Search"/>
  41. 查询
  42. </el-button>
  43. </el-form>
  44. <el-table
  45. border
  46. stripe="stripe"
  47. :height="state.tableData.height"
  48. highlight-current-row
  49. current-row-key="id"
  50. row-key="id"
  51. @on-row-click="handleRowClick('view',$event)"
  52. :data="state.tableData.data"
  53. v-loading="state.tableData.loading">
  54. <template #empty>
  55. <el-empty></el-empty>
  56. </template>
  57. <el-table-column
  58. v-for="field in state.columns"
  59. :key="field.prop"
  60. :type="field.type"
  61. :label="field.label"
  62. :column-key="field.prop"
  63. :width="field.width"
  64. :min-width="field.minWidth"
  65. :fixed="field.fixed"
  66. :sortable="field.sortable"
  67. :show-overflow-tooltip="!field.fixed&&field.width>150">
  68. <template #default="{row}">
  69. <template v-if="field.type==='expand'">
  70. <div class="order-detail">
  71. <el-table
  72. border
  73. :data="row.detail"
  74. stripe="stripe">
  75. <el-table-column width="120" label="服务项目" prop="name"></el-table-column>
  76. </el-table>
  77. </div>
  78. </template>
  79. <template v-else-if="field.prop==='stationName'">
  80. <div class="text-align-center cursor-pointer" @click="handleGotoSplitPage(row)">
  81. <el-button link type="primary" >{{ row.stationId }}</el-button>
  82. <hr>
  83. <el-button link type="primary" >{{ row.stationName }}</el-button>
  84. </div>
  85. </template>
  86. <template v-else-if="field.prop==='type'">
  87. <ext-d-label type="Object.type" :model-value="row[field.prop]"></ext-d-label>
  88. </template>
  89. <template v-else-if="['availableBalance','withdrawnAmount','withdrawnFrozenAmount'].includes(field.prop)">
  90. {{ u.fmt.fmtMoney(row[field.prop]) }}
  91. </template>
  92. <template v-else-if="field.prop==='idleRemainTime'||field.prop==='operationRemainTime'">
  93. {{ u.fmt.fmtDuration(row[field.prop]) }}
  94. </template>
  95. <template v-else-if="['createTime','updateTime'].includes(field.prop)">
  96. {{ u.fmt.fmtDateTime(row[field.prop]) }}
  97. </template>
  98. <template v-else-if="field.prop=='action'">
  99. <el-text class="cursor-pointer" type="primary" @click="handleWithdrawApplyClick(row)">提现申请</el-text>
  100. </template>
  101. <template v-else>
  102. <div>{{ row[field.prop] }}</div>
  103. </template>
  104. </template>
  105. </el-table-column>
  106. </el-table>
  107. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  108. </el-card>
  109. </div>
  110. </template>
  111. <script setup lang="ts" name="adminStationAccount">
  112. import {reactive, onMounted, onBeforeMount, ref, nextTick, onBeforeUnmount} from 'vue';
  113. import {$body, $get} from "/@/utils/request";
  114. import u from '/@/utils/u'
  115. import {Msg} from "/@/utils/message";
  116. import ExtPage from '/@/components/form/ExtPage.vue'
  117. import {useRouter} from "vue-router";
  118. const router = useRouter();
  119. import mittBus from '/@/utils/mitt';
  120. import {ElButton} from 'element-plus'
  121. import ExtSelect from "/@/components/form/ExtSelect.vue";
  122. //定义引用
  123. const queryRef = ref();
  124. //定义变量
  125. const state = reactive({
  126. formQuery: {},
  127. pageQuery: {
  128. pageNum: 1,
  129. pageSize: 10,
  130. total: 0
  131. },
  132. tableData: {
  133. height: 500,
  134. data: [] as Array<any>,
  135. loading: false
  136. },
  137. importConfig: {},
  138. exportConfig: {},
  139. columns: [
  140. // {type: 'selection', width: 60, align: 'center', fixed: 'left'},
  141. // {label: '站点ID', width: 100,prop: 'stationId', query: true, type: 'text', resizable: true},
  142. {label: '站点名称', width: 200, prop: 'stationName', query: true, type: 'text', resizable: true},
  143. {label: '可提现金额(元)', width: 180, prop: 'availableBalance', query: true, type: '', resizable: true},
  144. {label: '已提现金额(元)', width: 180, prop: 'withdrawnAmount', query: true, type: '', resizable: true},
  145. {label: '提现中金额(元)', width: 180, prop: 'withdrawnFrozenAmount', query: true, type: '', resizable: true},
  146. {label: '创建时间', width: 180, prop: 'createTime', query: true, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDate(val)}},
  147. {label: '更新时间', width: 180, prop: 'updateTime', query: true, sortable: 'custom', type: 'datetime', resizable: true, conf: {format: (val: any) => u.fmt.fmtDate(val)}},
  148. {
  149. label: '操作', prop: 'action', type: 'render', width: 180, align: 'center', fixed: 'right',
  150. }
  151. ],
  152. })
  153. // 监听双向绑定 modelValue 的变化
  154. // watch(
  155. // () => state.pageIndex,
  156. // () => {
  157. //
  158. // }
  159. // );
  160. //生命周期钩子
  161. onBeforeMount(() => {
  162. })
  163. onMounted(() => {
  164. loadData();
  165. nextTick(() => {
  166. let bodyHeight = document.body.clientHeight;
  167. let queryHeight = queryRef.value.$el.clientHeight;
  168. state.tableData.height = bodyHeight - queryHeight - 320
  169. })
  170. mittBus.on("stationAccount.refresh", () => {
  171. loadData();
  172. })
  173. });
  174. onBeforeUnmount(() => {
  175. mittBus.off("stationAccount.refresh")
  176. })
  177. const handleGotoSplitPage = (row: any) => {
  178. router.push(`/financeSR?stationId=${row.stationId}`)
  179. }
  180. //region 方法区
  181. // 初始化表格数据
  182. const loadData = (refresh: boolean = false) => {
  183. if (refresh) {
  184. state.pageQuery.pageNum = 1;
  185. }
  186. state.tableData.loading = true;
  187. $body(`/finance/stationAccounts`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  188. let {list, count} = res;
  189. state.tableData.data = list;
  190. state.pageQuery.total = count;
  191. state.tableData.loading = false;
  192. }).catch(e => {
  193. console.error(e)
  194. state.tableData.loading = false;
  195. })
  196. };
  197. // 打开详情页弹窗
  198. const handleWithdrawApplyClick = ( row: any) => {
  199. Msg.confirm(`确认执行本操作吗?`,'提现申请').then(()=>{
  200. Msg.prompt(`请输入提现金额(单位:元)`, '提现申请',
  201. {
  202. draggable: true,
  203. type: 'primary',
  204. }
  205. ).then((res: any) => {
  206. let {value, action} = res;
  207. console.log(res)
  208. let v =value;
  209. if (action === 'confirm') {
  210. if(!(v != null && v !== '' && !Number.isNaN(Number(v)))){
  211. Msg.message("请输入有效的提现金额,否则无法发起本操作",'error')
  212. return
  213. }
  214. Msg.showLoading(`请等待`);
  215. $body(`finance/applyWithdrawn`,{stationId:row.stationId,amount:Number(value)*100}).then(()=>{
  216. Msg.message("提现已发起")
  217. Msg.hideLoading()
  218. loadData(true)
  219. }).catch(e=>{
  220. Msg.hideLoading()
  221. })
  222. }
  223. })
  224. })
  225. };
  226. // 删除点击
  227. const handleRowDelete = (row: any) => {
  228. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  229. $get(`/stationAccount/delete/${row.id}`).then(() => {
  230. Msg.message("删除成功", 'success')
  231. }).catch(() => {
  232. Msg.message("删除失败", 'error')
  233. })
  234. });
  235. };
  236. //endregion
  237. // 暴露变量
  238. // defineExpose({
  239. // loadData,
  240. // });
  241. </script>