index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. <template>
  2. <a-card :bordered="false">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="关键词" name="searchKey">
  7. <a-input v-model:value="searchFormState.searchKey" placeholder="请输入关键词订单号、标题、描述" />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-form-item label="支付平台" name="payPlatform">
  12. <a-select
  13. v-model:value="searchFormState.payPlatform"
  14. placeholder="请选择支付平台"
  15. :options="payPlatformOptions"
  16. />
  17. </a-form-item>
  18. </a-col>
  19. <a-col :span="6">
  20. <a-form-item label="支付状态" name="payStatus">
  21. <a-select
  22. v-model:value="searchFormState.payStatus"
  23. placeholder="请选择支付状态"
  24. :options="payStatusOptions"
  25. />
  26. </a-form-item>
  27. </a-col>
  28. <a-col :span="6" v-show="advanced">
  29. <a-form-item label="是否有退款" name="hasRefund">
  30. <a-select
  31. v-model:value="searchFormState.hasRefund"
  32. placeholder="请选择是否有退款"
  33. :options="hasRefundOptions"
  34. />
  35. </a-form-item>
  36. </a-col>
  37. <a-col :span="6" v-show="advanced">
  38. <a-form-item label="支付时间" name="payTime">
  39. <a-range-picker v-model:value="searchFormState.payTime" show-time valueFormat="YYYY-MM-DD HH:mm:ss"/>
  40. </a-form-item>
  41. </a-col>
  42. <a-col :span="6" v-show="advanced">
  43. <a-form-item label="创建时间" name="createTime">
  44. <a-range-picker v-model:value="searchFormState.createTime" show-time valueFormat="YYYY-MM-DD HH:mm:ss"/>
  45. </a-form-item>
  46. </a-col>
  47. <a-col :span="6">
  48. <a-button type="primary" @click="table.refresh(true)">查询</a-button>
  49. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  50. <a @click="toggleAdvanced" style="margin-left: 8px">
  51. {{ advanced ? '收起' : '展开' }}
  52. <component :is="advanced ? 'up-outlined' : 'down-outlined'" />
  53. </a>
  54. </a-col>
  55. </a-row>
  56. </a-form>
  57. <s-table
  58. ref="table"
  59. :columns="columns"
  60. :data="loadData"
  61. :alert="options.alert.show"
  62. bordered
  63. :row-key="(record) => record.id"
  64. :tool-config="toolConfig"
  65. :row-selection="options.rowSelection"
  66. >
  67. <template #operator class="table-operator">
  68. <a-space>
  69. <xn-batch-Button
  70. :selectedRowKeys="selectedRowKeys"
  71. icon="redo-outlined"
  72. buttonName="批量同步"
  73. buttonType="primary"
  74. @batchCallBack="orderBatchSync"
  75. />
  76. <xn-batch-Button
  77. :selectedRowKeys="selectedRowKeys"
  78. icon="close-outlined"
  79. buttonName="批量关闭"
  80. @batchCallBack="orderBatchClose"
  81. />
  82. <xn-batch-Button
  83. :selectedRowKeys="selectedRowKeys"
  84. icon="delete-outlined"
  85. buttonDanger
  86. buttonName="批量删除"
  87. @batchCallBack="deleteBatchPayOrder"
  88. />
  89. </a-space>
  90. </template>
  91. <template #bodyCell="{ column, record }">
  92. <template v-if="column.dataIndex === 'payPlatform'">
  93. {{ $TOOL.dictTypeData('PAY_PLATFORM', record.payPlatform) }}
  94. </template>
  95. <template v-if="column.dataIndex === 'payStatus'">
  96. {{ $TOOL.dictTypeData('PAY_STATUS', record.payStatus) }}
  97. </template>
  98. <template v-if="column.dataIndex === 'hasRefund'">
  99. {{ dictTypeData(record.hasRefund) }}
  100. </template>
  101. <template v-if="column.dataIndex === 'action'">
  102. <a-space>
  103. <a-button type="link" size="small" @click="orderSync(record)"> 同步 </a-button>
  104. <a-divider type="vertical" />
  105. <a-popconfirm title="确定要删除吗?" placement="topRight" @confirm="deletePayOrder(record)">
  106. <a-button type="link" danger size="small">删除</a-button>
  107. </a-popconfirm>
  108. <a-divider type="vertical" />
  109. <a-dropdown>
  110. <a class="ant-dropdown-link">
  111. 更多
  112. <DownOutlined />
  113. </a>
  114. <template #overlay>
  115. <a-menu>
  116. <a-menu-item>
  117. <a @click="doDetailsListRef.onOpen(record)">订单明细</a>
  118. </a-menu-item>
  119. <a-menu-item>
  120. <a @click="doRefundFormRef.onOpen(record)">退款详情</a>
  121. </a-menu-item>
  122. <a-menu-item>
  123. <a-popconfirm title="确定要关闭吗?" placement="topRight" @confirm="orderClose(record)">
  124. <a>关闭订单</a>
  125. </a-popconfirm>
  126. </a-menu-item>
  127. </a-menu>
  128. </template>
  129. </a-dropdown>
  130. </a-space>
  131. </template>
  132. </template>
  133. </s-table>
  134. </a-card>
  135. <do-refund-form ref="doRefundFormRef" @successful="table.refresh()" />
  136. <do-details-list ref="doDetailsListRef" />
  137. </template>
  138. <script setup name="orderIndex">
  139. import tool from '@/utils/tool'
  140. import orderApi from '@/api/pay/orderApi'
  141. import DoRefundForm from './doRefundForm.vue'
  142. import DoDetailsList from './doDetailsList.vue'
  143. let searchFormState = reactive({})
  144. const searchFormRef = ref()
  145. const table = ref()
  146. const doRefundFormRef = ref()
  147. const doDetailsListRef = ref()
  148. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  149. // 查询区域显示更多控制
  150. const advanced = ref(false)
  151. const toggleAdvanced = () => {
  152. advanced.value = !advanced.value
  153. }
  154. const columns = [
  155. {
  156. title: '商户订单号',
  157. dataIndex: 'outTradeNo',
  158. ellipsis: true
  159. },
  160. {
  161. title: '支付订单号',
  162. dataIndex: 'tradeNo',
  163. ellipsis: true
  164. },
  165. {
  166. title: '订单标题',
  167. dataIndex: 'subject',
  168. ellipsis: true
  169. },
  170. {
  171. title: '订单金额',
  172. dataIndex: 'orderAmount',
  173. width: 100,
  174. sorter: true
  175. },
  176. {
  177. title: '支付金额',
  178. dataIndex: 'payAmount',
  179. width: 100,
  180. sorter: true
  181. },
  182. {
  183. title: '支付平台',
  184. width: 100,
  185. dataIndex: 'payPlatform'
  186. },
  187. {
  188. title: '支付状态',
  189. width: 100,
  190. dataIndex: 'payStatus'
  191. },
  192. {
  193. title: '是否有退款',
  194. width: 100,
  195. dataIndex: 'hasRefund'
  196. },
  197. {
  198. title: '支付时间',
  199. dataIndex: 'payTime',
  200. sorter: true,
  201. ellipsis: true
  202. },
  203. {
  204. title: '创建时间',
  205. dataIndex: 'createTime',
  206. sorter: true,
  207. ellipsis: true
  208. },
  209. {
  210. title: '操作',
  211. dataIndex: 'action',
  212. align: 'center',
  213. width: '220px'
  214. }
  215. ]
  216. // 是否有退款枚举
  217. const hasRefundOptions = [
  218. {
  219. label: '是',
  220. value: 'Y'
  221. },
  222. {
  223. label: '否',
  224. value: 'N'
  225. }
  226. ]
  227. // 翻译是否有退款
  228. const dictTypeData = (value) => {
  229. return hasRefundOptions.find((f) => f.value === value).label
  230. }
  231. const selectedRowKeys = ref([])
  232. // 列表选择配置
  233. const options = {
  234. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  235. alert: {
  236. show: false,
  237. clear: () => {
  238. selectedRowKeys.value = ref([])
  239. }
  240. },
  241. rowSelection: {
  242. onChange: (selectedRowKey, selectedRows) => {
  243. selectedRowKeys.value = selectedRowKey
  244. }
  245. }
  246. }
  247. const loadData = (parameter) => {
  248. const searchFormParam = JSON.parse(JSON.stringify(searchFormState))
  249. // payTime范围查询条件重载
  250. if (searchFormParam.payTime) {
  251. searchFormParam.startPayTime = searchFormParam.payTime[0]
  252. searchFormParam.endPayTime = searchFormParam.payTime[1]
  253. delete searchFormParam.payTime
  254. }
  255. // createTime范围查询条件重载
  256. if (searchFormParam.createTime) {
  257. searchFormParam.startCreateTime = searchFormParam.createTime[0]
  258. searchFormParam.endCreateTime = searchFormParam.createTime[1]
  259. delete searchFormParam.createTime
  260. }
  261. return orderApi.orderPage(Object.assign(parameter, searchFormParam)).then((data) => {
  262. return data
  263. })
  264. }
  265. // 重置
  266. const reset = () => {
  267. searchFormRef.value.resetFields()
  268. table.value.refresh(true)
  269. }
  270. // 删除
  271. const deletePayOrder = (record) => {
  272. let params = [
  273. {
  274. id: record.id
  275. }
  276. ]
  277. orderApi.orderDelete(params).then(() => {
  278. table.value.refresh(true)
  279. })
  280. }
  281. // 批量删除
  282. const deleteBatchPayOrder = (params) => {
  283. orderApi.orderDelete(params).then(() => {
  284. table.value.clearRefreshSelected()
  285. })
  286. }
  287. // 同步
  288. const orderSync = (record) => {
  289. const params = [
  290. {
  291. id: record.id
  292. }
  293. ]
  294. orderApi.orderSync(params).then(() => {
  295. table.value.clearRefreshSelected()
  296. })
  297. }
  298. // 批量同步
  299. const orderBatchSync = (params) => {
  300. orderApi.orderSync(params).then(() => {
  301. table.value.clearRefreshSelected()
  302. })
  303. }
  304. // 关闭
  305. const orderClose = (record) => {
  306. const params = [
  307. {
  308. id: record.id
  309. }
  310. ]
  311. orderApi.orderClose(params).then(() => {
  312. table.value.clearRefreshSelected()
  313. })
  314. }
  315. // 批量关闭
  316. const orderBatchClose = (params) => {
  317. orderApi.orderClose(params).then(() => {
  318. table.value.clearRefreshSelected()
  319. })
  320. }
  321. const payPlatformOptions = tool.dictList('PAY_PLATFORM')
  322. const payStatusOptions = tool.dictList('PAY_STATUS')
  323. </script>