index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. <ext-d-select
  30. v-model="state.formQuery.status"
  31. placeholder="退款状态"
  32. clearable
  33. type="Refund.status"
  34. @on-change="loadData(true)"
  35. class="wd150 mr10">
  36. </ext-d-select>
  37. <!-- <ext-d-select
  38. v-model="state.formQuery.fundsAccount"
  39. placeholder="资金账户"
  40. clearable
  41. type="Refund.account"
  42. @on-change="loadData(true)"
  43. class="wd150 mr10">
  44. </ext-d-select>-->
  45. <el-input
  46. v-model="state.formQuery.mobilePhone"
  47. placeholder="手机号"
  48. clearable
  49. @blur="loadData(true)"
  50. class="wd150 mr10">
  51. </el-input>
  52. <!-- <el-input
  53. v-model="state.formQuery.outRefundNo"
  54. placeholder="商户退款单号"
  55. clearable
  56. @blur="loadData(true)"
  57. class="wd150 mr10">
  58. </el-input>-->
  59. <el-input
  60. v-model="state.formQuery.outTradeNo"
  61. placeholder="商户订单号"
  62. clearable
  63. @blur="loadData(true)"
  64. class="wd150 mr10">
  65. </el-input>
  66. <!-- <el-input
  67. v-model="state.formQuery.refundId"
  68. placeholder="微信支付退款单号"
  69. clearable
  70. @blur="loadData(true)"
  71. class="wd150 mr10">
  72. </el-input>-->
  73. <el-input
  74. v-model="state.formQuery.transactionId"
  75. placeholder="微信支付订单号"
  76. clearable
  77. @blur="loadData(true)"
  78. class="wd150 mr10">
  79. </el-input>
  80. <el-button class="ml10" plain size="default" type="success" @click="loadData(true)">
  81. <SvgIcon name="ele-Search"/>
  82. 查询
  83. </el-button>
  84. </el-form>
  85. <el-table
  86. border
  87. stripe="stripe"
  88. :height="state.tableData.height"
  89. highlight-current-row
  90. current-row-key="id"
  91. row-key="id"
  92. :data="state.tableData.data"
  93. v-loading="state.tableData.loading"
  94. @selection-change="handleTableSelectionChange"
  95. @sort-change="handleTableSortChange">
  96. <template #empty>
  97. <el-empty></el-empty>
  98. </template>
  99. <el-table-column
  100. v-for="field in state.tableData.columns"
  101. :key="field.prop"
  102. :label="field.label"
  103. :column-key="field.prop"
  104. :width="field.width"
  105. :min-width="field.minWidth"
  106. :fixed="field.fixed"
  107. :sortable="field.sortable"
  108. :show-overflow-tooltip="!field.fixed&&field.width>150"
  109. >
  110. <template #default="{row}">
  111. <template v-if="field.prop==='expand'">
  112. <p style="padding-left: 2em;" v-html="row[field.prop]"></p>
  113. </template>
  114. <template v-else-if="'total'===field.prop">
  115. {{u.fmt.fmtMoney(row[field.prop])}}
  116. </template>
  117. <template v-else-if="'refund'===field.prop">
  118. {{u.fmt.fmtMoney(row[field.prop])}}
  119. </template>
  120. <template v-else-if="'discountAmount'===field.prop">
  121. {{u.fmt.fmtMoney(row[field.prop])}}
  122. </template>
  123. <template v-else-if="'status'===field.prop">
  124. <ext-d-label type="Refund.status" v-model="row[field.prop]"/>
  125. </template>
  126. <template v-else-if="'action'===field.prop">
  127. <el-button
  128. v-if="row.status==='NEW' && !row.isOverdue"
  129. size="small"
  130. plain
  131. type="warning"
  132. @click="onRefundClick(row)">
  133. 退款
  134. </el-button>
  135. <el-button
  136. v-if="row.status==='NEW' && row.isOverdue"
  137. size="small"
  138. plain
  139. type="danger"
  140. @click="onManualRefundClick(row)">
  141. 线下退款
  142. </el-button>
  143. </template>
  144. <template v-else>
  145. <div>{{ row[field.prop] }}</div>
  146. </template>
  147. </template>
  148. </el-table-column>
  149. </el-table>
  150. <ext-page class="page-pager" v-model:value="state.pageQuery" @change="loadData(false)"/>
  151. </el-card>
  152. </div>
  153. </template>
  154. <script setup lang="ts" name="RefundLogList">
  155. import {defineAsyncComponent, reactive, onMounted, onBeforeMount, ref, getCurrentInstance, nextTick, onBeforeUnmount} from 'vue';
  156. import {$body, $get} from "/@/utils/request";
  157. import {Msg} from "/@/utils/message";
  158. import u from "/@/utils/u"
  159. import {useRoute} from "vue-router";
  160. const route = useRoute();
  161. import ExtPage from '/@/components/form/ExtPage.vue'
  162. import mittBus from '/@/utils/mitt';
  163. import ExtDSelect from "/@/components/form/ExtDSelect.vue";
  164. import ExtDLabel from "/@/components/form/ExtDLabel.vue";
  165. //定义引用
  166. const queryRef = ref();
  167. //定义变量
  168. const state = reactive({
  169. formQuery: {
  170. status:'NEW'
  171. },
  172. pageQuery: {
  173. pageNum: 1,
  174. pageSize: 10,
  175. total: 0
  176. },
  177. tableData: {
  178. height: 500,
  179. data: [] as Array<any>,
  180. loading: false,
  181. columns: [
  182. {label: '退款记录ID', prop: 'refundLogId', width: 105, resizable: true,fixed:'left'},
  183. {label: '商户退款单号', prop: 'outRefundNo', width: 130, resizable: true,fixed:'left'},
  184. {label: '商户订单号', prop: 'outTradeNo', width: 130, resizable: true,fixed:'left'},
  185. {label: '手机号', prop: 'mobilePhone', width: 120, resizable: true,fixed:'left'},
  186. // {label: '退款渠道', prop: 'channel', width: 150,resizable: true},
  187. {label: '退款状态', prop: 'status', resizable: true, width: 120},
  188. {label: '申请时间', prop: 'createTime', sortable: 'custom', resizable: true, width: 160},
  189. {label: '退款成功时间', prop: 'successTime', sortable: 'custom', resizable: true, width: 160},
  190. {label: '充值时间', prop: 'rechargeTime', sortable: 'custom', resizable: true, width: 160},
  191. {label: '原充值订单金额', prop: 'total', resizable: true, width: 140},
  192. {label: '退款申请金额', prop: 'refund', resizable: true, width: 120},
  193. {label: '优惠金额', prop: 'discountAmount', resizable: true, width: 90},
  194. // {label: '用户支付币种', prop: 'currency', resizable: true, width: 120},
  195. // {label: '资金账户', prop: 'fundsAccount', resizable: true, width: 120},
  196. {label: '退款原因', prop: 'reason', resizable: true, width: 120},
  197. // {label: '微信支付退款单号', prop: 'outRefundNo', resizable: true, width: 150},
  198. // {label: '微信支付订单号', prop: 'outTradeNo', resizable: true, width: 150},
  199. {label: '退款入账账户', prop: 'userReceivedAccount', resizable: true, width: 120},
  200. {label: '操作人', prop: 'adminUsername', resizable: true, width: 120},
  201. {
  202. label: '操作', prop: 'action', width: 110, align: 'center', fixed: 'right',
  203. }
  204. ],
  205. },
  206. })
  207. // 监听双向绑定 modelValue 的变化
  208. // watch(
  209. // () => state.pageIndex,
  210. // () => {
  211. //
  212. // }
  213. // );
  214. //生命周期钩子
  215. onBeforeMount(() => {
  216. })
  217. onMounted(() => {
  218. let query = route.query;
  219. console.log(route.params, route.query)
  220. if (query.mobilePhone) {
  221. state.formQuery.mobilePhone = query.mobilePhone;
  222. }
  223. loadData();
  224. nextTick(() => {
  225. let bodyHeight = document.body.clientHeight;
  226. let queryHeight = queryRef.value.$el.clientHeight;
  227. state.tableData.height = bodyHeight - queryHeight - 320
  228. })
  229. mittBus.on("refundLog.refresh", () => {
  230. loadData();
  231. })
  232. });
  233. onBeforeUnmount(() => {
  234. mittBus.off("refundLog.refresh")
  235. })
  236. //region 方法区
  237. // 初始化表格数据
  238. const loadData = (refresh: boolean = false) => {
  239. if (refresh) {
  240. state.pageQuery.pageNum = 1;
  241. }
  242. state.tableData.loading = true;
  243. $get(`/finance/listRefundLog`, {...state.formQuery, ...state.pageQuery}).then((res: any) => {
  244. let {list, total} = res;
  245. state.tableData.data = list;
  246. state.pageQuery.total = total;
  247. state.tableData.loading = false;
  248. }).catch(e => {
  249. console.error(e)
  250. state.tableData.loading = false;
  251. })
  252. };
  253. // 打开修改用户弹窗
  254. const onRefundClick = ( row: any) => {
  255. // if(row.status){
  256. // return;
  257. // }
  258. Msg.confirm(
  259. `<div style="line-height: 2; font-size: 14px;">` +
  260. `<div style="font-weight: bold; color: #409EFF; font-size: 15px; margin-bottom: 10px;">【退款确认】</div>` +
  261. `<div style="margin: 8px 0;"><span style="color: #606266;">用户手机:</span><span style="font-weight: 500;">${row.mobilePhone}</span></div>` +
  262. `<div style="margin: 8px 0;"><span style="color: #606266;">退款金额:</span><span style="font-weight: 500; color: #F56C6C;">${u.fmt.fmtMoney(row.refund)}</span></div>` +
  263. `<div style="margin: 8px 0;"><span style="color: #606266;">申请时间:</span><span style="font-weight: 500;">${row.createTime ? row.createTime.replace('T', ' ') : '无'}</span></div>` +
  264. `<div style="margin: 15px 0; padding: 10px; background-color: #ECF5FF; border-radius: 4px; border-left: 3px solid #409EFF;">` +
  265. `<div style="color: #409EFF;">请确认是否执行微信退款操作?</div>` +
  266. `</div>` +
  267. `</div>`
  268. ).then(()=>{
  269. $get(`/finance/customWxRefund/${row.refundLogId}`).then((res: any) => {
  270. Msg.message(`操作已提交`)
  271. loadData(true)
  272. }).catch(e => {
  273. console.error(e)
  274. })
  275. })
  276. };
  277. // 手动确认退款(线下退款)
  278. const onManualRefundClick = (row: any) => {
  279. Msg.confirm(
  280. `<div style="line-height: 2; font-size: 14px;">` +
  281. `<div style="font-weight: bold; color: #E6A23C; font-size: 15px; margin-bottom: 10px;">【重要提醒】请确认已完成线下退款操作!</div>` +
  282. `<div style="margin: 8px 0;"><span style="color: #606266;">用户手机:</span><span style="font-weight: 500;">${row.mobilePhone}</span></div>` +
  283. `<div style="margin: 8px 0;"><span style="color: #606266;">退款金额:</span><span style="font-weight: 500; color: #F56C6C;">${u.fmt.fmtMoney(row.refund)}</span></div>` +
  284. `<div style="margin: 8px 0;"><span style="color: #606266;">充值时间:</span><span style="font-weight: 500;">${row.rechargeTime ? row.rechargeTime.replace('T', ' ') : '无'}</span></div>` +
  285. `<div style="margin: 15px 0; padding: 10px; background-color: #FDF6EC; border-radius: 4px; border-left: 3px solid #E6A23C;">` +
  286. `<div style="color: #E6A23C; margin-bottom: 5px;">该订单已超过365天退款时限</div>` +
  287. `<div style="color: #909399;">请确认已通过线下方式完成实际退款</div>` +
  288. `</div>` +
  289. `</div>`,
  290. '线下退款确认',
  291. {
  292. confirmButtonText: '确认已完成线下退款',
  293. cancelButtonText: '取消',
  294. type: 'warning'
  295. }
  296. ).then(() => {
  297. $get(`/finance/manualConfirmRefund/${row.refundLogId}`).then((res: any) => {
  298. Msg.message(`线下退款确认成功`)
  299. loadData(true)
  300. }).catch(e => {
  301. console.error(e)
  302. Msg.message(`操作失败:${e.message}`, 'error')
  303. })
  304. }).catch(() => {
  305. // 用户取消操作
  306. });
  307. };
  308. const handleTableSelectionChange = (selection: any) => {
  309. console.log("handleTableSelectionChange>>", selection)
  310. // emit("on-check-change", selection)
  311. }
  312. const handleTableSortChange = (column: any, prop: any, order: any) => {
  313. console.log("handleTableSortChange>>", column, prop, order)
  314. // emit("on-sort-change", column)
  315. }
  316. //endregion
  317. // 暴露变量
  318. // defineExpose({
  319. // loadData,
  320. // });
  321. </script>