index.vue 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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: #fff;
  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. <!-- <el-input-->
  30. <!-- v-model="state.formQuery.username"-->
  31. <!-- placeholder="用户名"-->
  32. <!-- clearable-->
  33. <!-- @blur="loadData(true)"-->
  34. <!-- class="wd150 mr10">-->
  35. <!-- </el-input>-->
  36. <el-input
  37. v-model="state.formQuery.mobilePhone"
  38. placeholder="手机号"
  39. clearable
  40. @blur="loadData(true)"
  41. class="wd150 mr10">
  42. </el-input>
  43. <!-- <ext-d-select-->
  44. <!-- v-model="state.formQuery.status"-->
  45. <!-- placeholder="状态"-->
  46. <!-- type="User.status"-->
  47. <!-- clearable-->
  48. <!-- @on-change="loadData(true)"-->
  49. <!-- class="wd150 mr10"/>-->
  50. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  51. <SvgIcon name="ele-Search"/>
  52. 查询
  53. </el-button>
  54. </el-form>
  55. <el-table
  56. border
  57. stripe="stripe"
  58. :height="state.tableData.height"
  59. highlight-current-row
  60. current-row-key="id"
  61. row-key="id"
  62. :data="state.tableData.data"
  63. v-loading="state.tableData.loading"
  64. @selection-change="handleTableSelectionChange"
  65. @sort-change="handleTableSortChange">
  66. <template #empty>
  67. <el-empty></el-empty>
  68. </template>
  69. <el-table-column
  70. v-for="field in state.tableData.columns"
  71. :key="field.prop"
  72. :label="field.label"
  73. :column-key="field.prop"
  74. :width="field.width"
  75. :min-width="field.minWidth"
  76. :fixed="field.fixed"
  77. :sortable="field.sortable"
  78. :show-overflow-tooltip="!field.fixed&&field.width>150"
  79. >
  80. <template #default="{row}">
  81. <template v-if="['rechargeAmount','totalMoney','refundAmount','balance','frozenAmount','payAmount','discountAmount','refundDiscountAmount'].includes(field.prop)">
  82. {{ u.fmt.fmtMoney(row[field.prop]) }}
  83. </template>
  84. <template v-else-if="'status'===field.prop">
  85. <ext-d-label type="User.status" v-model="row[field.prop]"/>
  86. </template>
  87. <template v-else-if="'rechargeTimes'===field.prop">
  88. <div class="flex w100 flex-justify-around hp">
  89. <span> <el-button link type="primary" @click="handleGotoRecharge(row)">{{row[field.prop]}} <SvgIcon name="ele-Link" class="hc"></SvgIcon></el-button></span>
  90. </div>
  91. </template>
  92. <template v-else-if="'chargeTimes'===field.prop">
  93. <div class="flex w100 flex-justify-around hp">
  94. <span> <el-button link type="primary" @click="handleGotoCharge(row)">{{row[field.prop]}} <SvgIcon name="ele-Link" class="hc"></SvgIcon></el-button></span>
  95. </div>
  96. </template>
  97. <template v-else-if="'refundTimes'===field.prop">
  98. <div class="flex w100 flex-justify-around hp">
  99. <span> <el-button link type="primary" @click="handleGotoRefund(row)">{{row[field.prop]}} <SvgIcon name="ele-Link" class="hc"></SvgIcon></el-button></span>
  100. </div>
  101. </template>
  102. <template v-else>
  103. <div>{{ row[field.prop] }}</div>
  104. </template>
  105. </template>
  106. </el-table-column>
  107. </el-table>
  108. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  109. </el-card>
  110. </div>
  111. <AdminUserDialog ref="adminUserDialogRef" @refresh="loadData(true)"/>
  112. </template>
  113. <script setup lang="ts" name="AdminUserList">
  114. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  115. import {$body, $get} from "/@/utils/request";
  116. import {Msg} from "/@/utils/message";
  117. import u from "/@/utils/u"
  118. import {useRouter} from "vue-router";
  119. const router = useRouter();
  120. import ExtPage from '/@/components/form/ExtPage.vue'
  121. import mittBus from '/@/utils/mitt';
  122. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  123. import ExtDSelect from "/@/components/form/ExtDSelect.vue";
  124. const AdminUserDialog = defineAsyncComponent(() => import("/@/views/admin/account/detail.vue"));
  125. //定义引用
  126. const queryRef = ref();
  127. const adminUserDialogRef = ref();
  128. //定义变量
  129. const state = reactive({
  130. formQuery: {},
  131. pageQuery: {
  132. pageNum: 1,
  133. pageSize: 10,
  134. total: 0
  135. },
  136. tableData: {
  137. height: 500,
  138. data: [] as Array<any>,
  139. loading: false,
  140. columns: [
  141. {label: '用户ID',width: 200, prop: 'userId', resizable: true, fixed: 'left'},
  142. {label: '归属站点',width: 200, prop: 'stationName', resizable: true, fixed: 'left'},
  143. {label: '手机号', width: 120, prop: 'mobilePhone', resizable: true, fixed: 'left'},
  144. {label: '余额', width: 80, prop: 'balance', resizable: true, fixed: 'left'},
  145. {label: '冻结余额', width: 90, prop: 'frozenAmount', resizable: true, fixed: 'left'},
  146. {label: '状态', width: 80, prop: 'status', align: 'center'},
  147. {label: '注册时间', width: 160, prop: 'registerTime', resizable: true},
  148. {label: '充值次数', width: 90, prop: 'rechargeTimes', resizable: true},
  149. {label: '充值金额', width: 90, prop: 'rechargeAmount', resizable: true},
  150. {label: '退款次数', width: 90, prop: 'refundTimes', resizable: true},
  151. {label: '退款金额', width: 90, prop: 'refundAmount', resizable: true},
  152. {label: '充电次数', width: 90, prop: 'chargeTimes', resizable: true},
  153. {label: '总电量/度', width: 100, prop: 'totalPower', resizable: true},
  154. {label: '订单总额', width: 100, prop: 'totalMoney', resizable: true},
  155. {label: '实付总额', width: 100, prop: 'payAmount', resizable: true},
  156. {label: '优惠总额', width: 100, prop: 'discountAmount', resizable: true},
  157. {label: '退款扣除优惠', width: 125, prop: 'refundDiscountAmount', resizable: true},
  158. // {
  159. // label: '操作', prop: 'action', width: 180, align: 'center', fixed: 'right',
  160. // }
  161. ],
  162. },
  163. })
  164. // 监听双向绑定 modelValue 的变化
  165. // watch(
  166. // () => state.pageNum,
  167. // () => {
  168. //
  169. // }
  170. // );
  171. //生命周期钩子
  172. onBeforeMount(() => {
  173. })
  174. onMounted(() => {
  175. loadData();
  176. nextTick(() => {
  177. let bodyHeight = document.body.clientHeight;
  178. let queryHeight = queryRef.value.$el.clientHeight;
  179. state.tableData.height = bodyHeight - queryHeight - 320
  180. })
  181. mittBus.on("adminUser.refresh", () => {
  182. loadData();
  183. })
  184. });
  185. onBeforeUnmount(() => {
  186. mittBus.off("adminUser.refresh")
  187. })
  188. //region 方法区
  189. // 初始化表格数据
  190. const loadData = (refresh: boolean = false) => {
  191. if (refresh) {
  192. state.pageQuery.pageNum = 1;
  193. }
  194. state.tableData.loading = true;
  195. $get(`/custom/listUser`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  196. let {list, total} = res;
  197. state.tableData.data = list;
  198. state.pageQuery.total = total;
  199. state.tableData.loading = false;
  200. }).catch(e => {
  201. //console.error(e)
  202. state.tableData.loading = false;
  203. })
  204. };
  205. const handleGotoRecharge=(row:any)=>{
  206. let url = router.resolve(`/finance?mobilePhone=${row.mobilePhone}`);
  207. window.open(url.href, '_blank');
  208. }
  209. const handleGotoCharge=(row:any)=>{
  210. let url = router.resolve(`/ordering?mobilePhone=${row.mobilePhone}`);
  211. window.open(url.href, '_blank');
  212. }
  213. const handleGotoRefund=(row:any)=>{
  214. let url = router.resolve(`/refund?mobilePhone=${row.mobilePhone}`);
  215. window.open(url.href, '_blank');
  216. }
  217. // 打开修改用户弹窗
  218. const onRowClick = (type: string, row: any) => {
  219. adminUserDialogRef.value.open(type, row);
  220. };
  221. // 删除用户
  222. const onRowDel = (row: any) => {
  223. Msg.confirm(`此操作将永久删除:『${row.name}』,是否继续?`).then(() => {
  224. $get(`/adminUser/delete/${row.id}`).then(() => {
  225. Msg.message("删除成功", 'success')
  226. }).catch(() => {
  227. Msg.message("删除失败", 'error')
  228. })
  229. });
  230. };
  231. const handleTableSelectionChange = (selection: any) => {
  232. //console.log("handleTableSelectionChange>>", selection)
  233. // emit("on-check-change", selection)
  234. }
  235. const handleTableSortChange = (column, prop, order) => {
  236. //console.log("handleTableSortChange>>", column, prop, order)
  237. // emit("on-sort-change", column)
  238. }
  239. //endregion
  240. // 暴露变量
  241. // defineExpose({
  242. // loadData,
  243. // });
  244. </script>