refund.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <template>
  2. <cl-crud ref="Crud">
  3. <cl-row>
  4. <cl-filter-group :items="items" :data="filterParam" :reset-btn="true" />
  5. <cl-export-btn :columns="Table?.columns" />
  6. </cl-row>
  7. <cl-row>
  8. <cl-table ref="Table" :contextMenu="[]">
  9. </cl-table>
  10. </cl-row>
  11. <cl-row>
  12. <cl-flex1 />
  13. <!-- 分页控件 -->
  14. <cl-pagination />
  15. </cl-row>
  16. </cl-crud>
  17. </template>
  18. <script lang="ts" name="dj-refund" setup>
  19. import { useCrud, useTable, useUpsert } from "@cool-vue/crud";
  20. import { useCool } from "/@/cool";
  21. import { ref } from "vue";
  22. import dayjs from "dayjs";
  23. import { checkPerm } from "/$/base";
  24. import { ElMessage } from "element-plus";
  25. const { service } = useCool();
  26. const filterParam = ref({
  27. createTime: [
  28. dayjs().format("YYYY-MM-DD ") + "00:00:00",
  29. dayjs().format("YYYY-MM-DD ") + "23:59:59"
  30. ]
  31. });
  32. const items = ref<ClForm.Item[]>([
  33. {
  34. label: "订单号",
  35. prop: "orderNo",
  36. component: {
  37. name: "el-input"
  38. }
  39. },
  40. {
  41. label: "商户订单号",
  42. prop: "outOrderNo",
  43. component: {
  44. name: "el-input"
  45. }
  46. },
  47. {
  48. label: "交易号",
  49. prop: "traceNo",
  50. component: {
  51. name: "el-input"
  52. }
  53. },
  54. {
  55. label: "退款订单号",
  56. prop: "refundNo",
  57. component: {
  58. name: "el-input"
  59. }
  60. },
  61. {
  62. label: "退款交易号",
  63. prop: "RefundTraceNo",
  64. component: {
  65. name: "el-input"
  66. }
  67. },
  68. {
  69. label: "商户号",
  70. prop: "mchId",
  71. component: {
  72. name: "el-input"
  73. },
  74. hidden: !checkPerm(service.dj.order.permission.mch)
  75. },
  76. {
  77. label: "退款状态",
  78. prop: "status",
  79. component: {
  80. name: "el-select",
  81. props: {
  82. clearable: true
  83. },
  84. options: [
  85. {
  86. label: "退款中",
  87. value: 0
  88. },
  89. {
  90. label: "退款成功",
  91. value: 1
  92. },
  93. {
  94. label: "退款失败",
  95. value: 2
  96. }
  97. ]
  98. }
  99. },
  100. {
  101. label: "日期范围",
  102. prop: "createTime",
  103. component: {
  104. name: "el-date-picker",
  105. props: {
  106. style: { width: "360px" },
  107. type: "datetimerange",
  108. unlinkPanels: true,
  109. valueFormat: "YYYY-MM-DD HH:mm:ss",
  110. shortcuts: [
  111. {
  112. text: '今天',
  113. value: () => {
  114. return [dayjs().startOf('day'), dayjs().endOf('day')]
  115. }
  116. },
  117. {
  118. text: '昨天',
  119. value: () => {
  120. return [dayjs().subtract(1, 'day').startOf('day'), dayjs().subtract(1, 'day').endOf('day')]
  121. }
  122. },
  123. {
  124. text: '近三天',
  125. value: () => {
  126. return [dayjs().subtract(2, 'day').startOf('day'), dayjs().endOf('day')]
  127. }
  128. },
  129. {
  130. text: '近七天',
  131. value: () => {
  132. return [dayjs().subtract(6, 'day').startOf('day'), dayjs().endOf('day')]
  133. }
  134. },
  135. {
  136. text: '近一个月',
  137. value: () => {
  138. return [dayjs().startOf('month'), dayjs().endOf('month')]
  139. }
  140. },
  141. ],
  142. onChange() { }
  143. }
  144. }
  145. }
  146. ]);
  147. // cl-table
  148. const Table = useTable({
  149. columns: [
  150. { label: "#", type: "index" },
  151. { prop: "orderNo", label: "订单号", showOverflowTooltip: true, width: 120 },
  152. { prop: "refundNo", label: "退款订单号", showOverflowTooltip: true, width: 120 },
  153. {
  154. prop: "mchId", label: "商户号", hidden: !checkPerm(service.dj.order.permission.mch), showOverflowTooltip: true, width: 120
  155. },
  156. {
  157. prop: "amount",
  158. label: "退款金额",
  159. width: 90,
  160. formatter(row) {
  161. return (+row.amount).toFixed(2);
  162. }
  163. },
  164. {
  165. prop: "charge",
  166. label: "手续费",
  167. width: 90,
  168. formatter(row) {
  169. return (+row.charge).toFixed(2);
  170. }
  171. },
  172. { prop: "currency", label: "货币单位", width: 90 },
  173. {
  174. prop: "code", label: "通道编码", hidden: !checkPerm(service.dj.order.permission.code), width: 90
  175. },
  176. {
  177. prop: "status",
  178. label: "订单状态",
  179. width: 90,
  180. dict: [
  181. { label: "退款中", value: 0, color: "#909399" },
  182. { label: "退款成功", value: 1, color: "#67C23A" },
  183. { label: "退款失败", value: 2, color: "#F56C6C" }
  184. ],
  185. },
  186. { prop: "createTime", label: "创建时间", width: 155 },
  187. { prop: "reson", label: "退款原因", showOverflowTooltip: true, width: 120 },
  188. {
  189. prop: "date",
  190. label: "退款时间",
  191. width: 155,
  192. component: { name: "cl-date-text", props: { format: "YYYY-MM-DD HH:mm:ss" } }
  193. },
  194. { prop: "refundTraceNo", label: "退款交易号", showOverflowTooltip: true, width: 120 },
  195. { prop: "outOrderNo", label: "商户订单号", showOverflowTooltip: true, width: 120 },
  196. { prop: "traceNo", label: "交易号", showOverflowTooltip: true, width: 120 },
  197. { prop: "remark", label: "备注", showOverflowTooltip: true, width: 120 },
  198. {
  199. type: "op",
  200. width: 120,
  201. buttons({ scope }) {
  202. return [
  203. {
  204. label: "API查单",
  205. type: "primary",
  206. async onClick({ scope }: any) {
  207. try {
  208. const data = await service.dj.refund.query({ id: scope.row.id });
  209. if (+data.status === 2) {
  210. ElMessage.error("订单退款失败,已刷新状态!");
  211. Crud.value?.refresh();
  212. } else if (+data.status === 1) {
  213. ElMessage.success("订单退款成功,已刷新状态!");
  214. Crud.value?.refresh();
  215. } else {
  216. ElMessage.warning("订单仍在处理中,请稍后查询");
  217. }
  218. } catch (e: any) {
  219. ElMessage.warning(e.message);
  220. }
  221. }
  222. }
  223. ];
  224. }
  225. }
  226. ]
  227. });
  228. // cl-crud
  229. const Crud = useCrud(
  230. {
  231. service: service.dj.refund
  232. },
  233. (app) => {
  234. app.refresh(filterParam.value);
  235. }
  236. );
  237. </script>