ProfitShareOrder.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <div class="profit-share-apply">
  3. <!-- 搜索条件 -->
  4. <el-card class="search-card">
  5. <el-form :model="searchForm" label-width="140px" inline>
  6. <el-form-item label="商户分账指令流水号">
  7. <el-input
  8. v-model="searchForm.out_separate_no"
  9. placeholder="请输入商户分账指令流水号"
  10. clearable
  11. @keyup.enter="handleSearch"
  12. />
  13. </el-form-item>
  14. <el-form-item label="分账状态">
  15. <el-select v-model="searchForm.status" placeholder="请选择分账状态" clearable>
  16. <el-option label="全部" value="" />
  17. <el-option label="待处理" value="PENDING" />
  18. <el-option label="处理中" value="PROCESSING" />
  19. <el-option label="已受理" value="ACCEPTED" />
  20. <el-option label="成功" value="SUCCESS" />
  21. <el-option label="失败" value="FAIL" />
  22. </el-select>
  23. </el-form-item>
  24. <el-form-item>
  25. <el-button type="primary" @click="handleSearch">查询</el-button>
  26. <el-button @click="handleReset">重置</el-button>
  27. </el-form-item>
  28. </el-form>
  29. </el-card>
  30. <!-- 列表数据 -->
  31. <el-card class="table-card">
  32. <template #header>
  33. <div class="table-header">
  34. <div class="header-title">分账申请记录列表</div>
  35. </div>
  36. </template>
  37. <el-table
  38. v-loading="loading"
  39. :data="tableData"
  40. border
  41. stripe
  42. >
  43. <el-table-column prop="out_separate_no" label="商户分账指令流水号" min-width="200" />
  44. <el-table-column prop="user_id" label="用户ID" width="100" />
  45. <el-table-column prop="total_amt" label="订单金额(分)" width="120">
  46. <template #default="{ row }">
  47. {{ formatAmount(row.total_amt) }}
  48. </template>
  49. </el-table-column>
  50. <el-table-column prop="recv_no" label="分账接收方编号" width="150" />
  51. <el-table-column prop="status" label="分账状态" width="100">
  52. <template #default="{ row }">
  53. {{ getStatusText(row.status) }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="fail_reason" label="分账失败原因" min-width="150" />
  57. <el-table-column prop="create_time" label="创建时间" width="180" />
  58. <el-table-column prop="update_time" label="更新时间" width="180" />
  59. <el-table-column label="操作" width="150" fixed="right">
  60. <template #default="{ row }">
  61. <el-button type="primary" size="small" @click="handleView(row)">详情</el-button>
  62. </template>
  63. </el-table-column>
  64. </el-table>
  65. <!-- 分页 -->
  66. <el-pagination
  67. v-model:current-page="pagination.page"
  68. v-model:page-size="pagination.limit"
  69. :total="pagination.total"
  70. :page-sizes="[10, 20, 50, 100]"
  71. layout="total, sizes, prev, pager, next, jumper"
  72. @size-change="handleSizeChange"
  73. @current-change="handleCurrentChange"
  74. class="pagination"
  75. />
  76. </el-card>
  77. <!-- 详情对话框 -->
  78. <el-dialog
  79. v-model="detailDialogVisible"
  80. title="分账申请详情"
  81. width="600px"
  82. :before-close="handleCloseDetailDialog"
  83. >
  84. <el-form
  85. v-loading="detailLoading"
  86. :model="detailData"
  87. label-width="160px"
  88. label-position="left"
  89. >
  90. <el-form-item label="商户分账指令流水号:">
  91. <span>{{ detailData.out_separate_no }}</span>
  92. </el-form-item>
  93. <el-form-item label="用户ID:">
  94. <span>{{ detailData.user_id }}</span>
  95. </el-form-item>
  96. <el-form-item label="订单金额(分):">
  97. <span>{{ formatAmount(detailData.total_amt) }}</span>
  98. </el-form-item>
  99. <el-form-item label="分账接收方编号:">
  100. <span>{{ detailData.recv_no }}</span>
  101. </el-form-item>
  102. <el-form-item label="分账状态:">
  103. <span>{{ getStatusText(detailData.status) }}</span>
  104. </el-form-item>
  105. <el-form-item v-if="detailData.fail_reason" label="分账失败原因:">
  106. <span>{{ detailData.fail_reason }}</span>
  107. </el-form-item>
  108. <el-form-item label="创建时间:">
  109. <span>{{ detailData.create_time }}</span>
  110. </el-form-item>
  111. <el-form-item label="更新时间:">
  112. <span>{{ detailData.update_time }}</span>
  113. </el-form-item>
  114. </el-form>
  115. <template #footer>
  116. <span class="dialog-footer">
  117. <el-button @click="handleCloseDetailDialog">关闭</el-button>
  118. </span>
  119. </template>
  120. </el-dialog>
  121. </div>
  122. </template>
  123. <script>
  124. export default {
  125. name: "ProfitShareOrder",
  126. props: {
  127. axiosInstance: {
  128. type: Object,
  129. default: null
  130. }
  131. },
  132. data() {
  133. return {
  134. loading: false,
  135. detailLoading: false,
  136. searchForm: {
  137. out_separate_no: '',
  138. status: ''
  139. },
  140. tableData: [],
  141. pagination: {
  142. page: 1,
  143. limit: 10,
  144. total: 0
  145. },
  146. detailDialogVisible: false,
  147. detailData: {}
  148. }
  149. },
  150. async created() {
  151. this.fetchData()
  152. },
  153. methods: {
  154. // 格式化金额显示
  155. formatAmount(amount) {
  156. return amount || amount === 0 ? amount : '-';
  157. },
  158. // 获取分账状态文本
  159. getStatusText(status) {
  160. const statusMap = {
  161. 'PENDING': '待处理',
  162. 'PROCESSING': '处理中',
  163. 'ACCEPTED': '已受理',
  164. 'SUCCESS': '成功',
  165. 'FAIL': '失败'
  166. }
  167. return statusMap[status] || status
  168. },
  169. // 获取列表数据
  170. async fetchData() {
  171. if (!this.axiosInstance) {
  172. this.$message.error('无法获取请求实例')
  173. return
  174. }
  175. this.loading = true
  176. try {
  177. const params = {
  178. page: this.pagination.page,
  179. limit: this.pagination.limit,
  180. out_separate_no: this.searchForm.out_separate_no,
  181. status: this.searchForm.status
  182. }
  183. const res = await this.axiosInstance.get('/lakala/profit_share_order', { params })
  184. if (res.code === 200) {
  185. this.tableData = res.page.data
  186. this.pagination.total = res.page.total
  187. this.pagination.limit = res.page.per_page
  188. } else {
  189. this.$message.error(res.msg || res.message || '获取数据失败')
  190. }
  191. } catch (error) {
  192. console.error('获取分账申请记录列表失败:', error)
  193. this.$message.error('获取数据失败: ' + (error.message || '未知错误'))
  194. } finally {
  195. this.loading = false
  196. }
  197. },
  198. // 获取详情数据
  199. async fetchDetail(id) {
  200. if (!this.axiosInstance) {
  201. this.$message.error('无法获取请求实例')
  202. return
  203. }
  204. this.detailLoading = true
  205. try {
  206. const res = await this.axiosInstance.get(`/lakala/profit_share_order/${id}`)
  207. if (res.code === 200) {
  208. this.detailData = res.data
  209. } else {
  210. this.$message.error(res.msg || res.message || '获取详情失败')
  211. }
  212. } catch (error) {
  213. console.error('获取分账申请详情失败:', error)
  214. this.$message.error('获取详情失败: ' + (error.message || '未知错误'))
  215. } finally {
  216. this.detailLoading = false
  217. }
  218. },
  219. // 查询
  220. handleSearch() {
  221. this.pagination.page = 1
  222. this.fetchData()
  223. },
  224. // 重置
  225. handleReset() {
  226. this.searchForm = {
  227. out_separate_no: '',
  228. status: ''
  229. }
  230. this.pagination.page = 1
  231. this.fetchData()
  232. },
  233. // 查看详情
  234. async handleView(row) {
  235. await this.fetchDetail(row.id)
  236. this.detailDialogVisible = true
  237. },
  238. // 关闭详情对话框
  239. handleCloseDetailDialog() {
  240. this.detailDialogVisible = false
  241. this.detailData = {}
  242. },
  243. // 分页相关
  244. handleSizeChange(val) {
  245. this.pagination.limit = val
  246. this.pagination.page = 1
  247. this.fetchData()
  248. },
  249. handleCurrentChange(val) {
  250. this.pagination.page = val
  251. this.fetchData()
  252. }
  253. }
  254. }
  255. </script>
  256. <style scoped>
  257. .profit-share-apply {
  258. padding: 20px;
  259. }
  260. .search-card {
  261. margin-bottom: 20px;
  262. }
  263. .table-card {
  264. margin-bottom: 20px;
  265. }
  266. .table-header {
  267. display: flex;
  268. justify-content: space-between;
  269. align-items: center;
  270. }
  271. .header-title {
  272. font-size: 16px;
  273. font-weight: bold;
  274. }
  275. .pagination {
  276. margin-top: 20px;
  277. text-align: right;
  278. }
  279. </style>