ProfitShareReceiver.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <div class="profit-share-receiver">
  3. <!-- 搜索条件 -->
  4. <el-card class="search-card">
  5. <el-form :model="searchForm" label-width="100px" inline>
  6. <el-form-item label="订单号" style="width: 300px;">
  7. <el-input
  8. v-model="searchForm.order_no"
  9. placeholder="请输入订单号"
  10. clearable
  11. @keyup.enter="handleSearch"
  12. />
  13. </el-form-item>
  14. <el-form-item label="状态" style="width: 250px;">
  15. <el-select v-model="searchForm.status" placeholder="请选择状态" clearable style="width: 100%;">
  16. <el-option label="全部" value="" />
  17. <el-option label="待审核" value="1" />
  18. <el-option label="提交中" value="2" />
  19. <el-option label="验证通过" value="3" />
  20. <el-option label="验证失败" value="4" />
  21. <el-option label="绑定中" value="5" />
  22. <el-option label="绑定成功" value="6" />
  23. <el-option label="绑定失败" value="7" />
  24. </el-select>
  25. </el-form-item>
  26. <el-form-item>
  27. <el-button type="primary" @click="handleSearch">查询</el-button>
  28. <el-button @click="handleReset">重置</el-button>
  29. </el-form-item>
  30. </el-form>
  31. </el-card>
  32. <!-- 列表数据 -->
  33. <el-card class="table-card">
  34. <template #header>
  35. <div class="table-header">
  36. <div class="header-title">分账接收方列表</div>
  37. </div>
  38. </template>
  39. <el-table
  40. v-loading="loading"
  41. :data="tableData"
  42. border
  43. stripe
  44. >
  45. <el-table-column prop="id" label="ID" width="80" />
  46. <el-table-column prop="order_no" label="订单编号" min-width="180" />
  47. <el-table-column prop="receiver_name" label="接收方名称" min-width="120" />
  48. <el-table-column prop="receiver_no" label="接收方编号" min-width="150" />
  49. <el-table-column prop="acct_name" label="收款账户名称" min-width="120" />
  50. <el-table-column prop="acct_no" label="收款账户卡号" min-width="180" />
  51. <el-table-column prop="acct_type_code" label="收款账户账户类型" width="120">
  52. <template #default="{ row }">
  53. {{ getAccountTypeText(row.acct_type_code) }}
  54. </template>
  55. </el-table-column>
  56. <el-table-column prop="contact_mobile" label="联系手机号" width="120" />
  57. <el-table-column prop="status_text" label="状态" width="100" />
  58. <el-table-column prop="create_time" label="申请时间" width="180" />
  59. <el-table-column prop="fail_reason" label="失败原因" min-width="150" />
  60. <el-table-column label="操作" width="150" fixed="right">
  61. <template #default="{ row }">
  62. <el-button type="primary" size="small" @click="handleView(row)">详情</el-button>
  63. </template>
  64. </el-table-column>
  65. </el-table>
  66. <!-- 分页 -->
  67. <el-pagination
  68. v-model:current-page="pagination.page"
  69. v-model:page-size="pagination.limit"
  70. :total="pagination.total"
  71. :page-sizes="[10, 20, 50, 100]"
  72. layout="total, sizes, prev, pager, next, jumper"
  73. @size-change="handleSizeChange"
  74. @current-change="handleCurrentChange"
  75. class="pagination"
  76. />
  77. </el-card>
  78. <!-- 详情对话框 -->
  79. <el-dialog
  80. v-model="detailDialogVisible"
  81. title="分账接收方详情"
  82. width="600px"
  83. :before-close="handleCloseDetailDialog"
  84. >
  85. <el-form
  86. v-loading="detailLoading"
  87. :model="detailData"
  88. label-width="140px"
  89. label-position="left"
  90. >
  91. <el-form-item label="订单编号:">
  92. <span>{{ detailData.order_no }}</span>
  93. </el-form-item>
  94. <el-form-item label="分账接收方名称:">
  95. <span>{{ detailData.receiver_name }}</span>
  96. </el-form-item>
  97. <el-form-item label="接收方编号:">
  98. <span>{{ detailData.receiver_no }}</span>
  99. </el-form-item>
  100. <el-form-item label="联系手机号:">
  101. <span>{{ detailData.contact_mobile }}</span>
  102. </el-form-item>
  103. <el-form-item label="收款账户名称:">
  104. <span>{{ detailData.acct_name }}</span>
  105. </el-form-item>
  106. <el-form-item label="收款账户卡号:">
  107. <span>{{ detailData.acct_no }}</span>
  108. </el-form-item>
  109. <el-form-item label="收款账户账户类型:">
  110. <span>{{ getAccountTypeText(detailData.acct_type_code) }}</span>
  111. </el-form-item>
  112. <el-form-item label="收款账户证件类型:">
  113. <span>{{ getCertificateTypeText(detailData.acct_certificate_type) }}</span>
  114. </el-form-item>
  115. <el-form-item label="收款账户证件号:">
  116. <span>{{ detailData.acct_certificate_no }}</span>
  117. </el-form-item>
  118. <el-form-item label="收款账户开户行名称:">
  119. <span>{{ detailData.acct_open_bank_name }}</span>
  120. </el-form-item>
  121. <el-form-item label="提款类型:">
  122. <span>{{ getSettleTypeText(detailData.settle_type) }}</span>
  123. </el-form-item>
  124. <el-form-item label="状态:">
  125. <span>{{ detailData.status_text }}</span>
  126. </el-form-item>
  127. <el-form-item v-if="detailData.fail_reason" label="失败原因:">
  128. <span>{{ detailData.fail_reason }}</span>
  129. </el-form-item>
  130. <el-form-item label="申请时间:">
  131. <span>{{ detailData.create_time }}</span>
  132. </el-form-item>
  133. <el-form-item v-if="detailData.entrust_local_path" label="合作协议:">
  134. <el-link
  135. :href="detailData.entrust_local_full_url || detailData.entrust_local_path"
  136. target="_blank"
  137. type="primary"
  138. >
  139. 查看合作协议
  140. </el-link>
  141. </el-form-item>
  142. </el-form>
  143. <template #footer>
  144. <span class="dialog-footer">
  145. <el-button
  146. v-if="detailData.status === 1"
  147. type="success"
  148. @click="handleCreateApplication"
  149. :loading="applyLoading"
  150. >
  151. 分账接收方创建申请
  152. </el-button>
  153. <el-button
  154. v-if="detailData.status === 3"
  155. type="success"
  156. @click="handleBindApplication"
  157. :loading="applyLoading"
  158. >
  159. 分账关系绑定申请
  160. </el-button>
  161. <el-button @click="handleCloseDetailDialog">关闭</el-button>
  162. </span>
  163. </template>
  164. </el-dialog>
  165. </div>
  166. </template>
  167. <script>
  168. export default {
  169. name: 'ProfitShareReceiver',
  170. props: {
  171. axiosInstance: {
  172. type: Object,
  173. default: null
  174. }
  175. },
  176. data() {
  177. return {
  178. loading: false,
  179. detailLoading: false,
  180. applyLoading: false,
  181. searchForm: {
  182. order_no: '',
  183. status: ''
  184. },
  185. tableData: [],
  186. pagination: {
  187. page: 1,
  188. limit: 10,
  189. total: 0
  190. },
  191. detailDialogVisible: false,
  192. detailData: {}
  193. }
  194. },
  195. async created() {
  196. this.fetchData()
  197. },
  198. methods: {
  199. // 获取账户类型文本
  200. getAccountTypeText(code) {
  201. const accountTypes = {
  202. '57': '对公',
  203. '58': '对私'
  204. }
  205. return accountTypes[code] || code
  206. },
  207. // 获取证件类型文本
  208. getCertificateTypeText(code) {
  209. const certificateTypes = {
  210. '17': '身份证',
  211. '18': '护照',
  212. '19': '港澳居民来往内地通行证',
  213. '20': '台湾居民来往内地通行证'
  214. }
  215. return certificateTypes[code] || code
  216. },
  217. // 获取提款类型文本
  218. getSettleTypeText(code) {
  219. const settleTypes = {
  220. '01': '主动提款',
  221. '03': '交易自动结算'
  222. }
  223. return settleTypes[code] || code
  224. },
  225. // 获取列表数据
  226. async fetchData() {
  227. // 优先使用通过props传递的axios实例
  228. if (!this.axiosInstance) {
  229. this.$message.error('无法获取请求实例')
  230. return
  231. }
  232. this.loading = true
  233. try {
  234. const params = {
  235. page: this.pagination.page,
  236. limit: this.pagination.limit,
  237. order_no: this.searchForm.order_no,
  238. status: this.searchForm.status
  239. }
  240. const res = await this.axiosInstance.get('/lakala/profit_share_receiver', { params })
  241. if (res.code === 200) {
  242. // 根据接口返回结构调整数据处理
  243. this.tableData = res.page.data
  244. this.pagination.total = res.page.total
  245. this.pagination.limit = res.page.per_page
  246. } else {
  247. this.$message.error(res.msg || res.message || '获取数据失败')
  248. }
  249. } catch (error) {
  250. console.error('获取分账接收方列表失败:', error)
  251. this.$message.error('获取数据失败: ' + (error.message || '未知错误'))
  252. } finally {
  253. this.loading = false
  254. }
  255. },
  256. // 获取详情数据
  257. async fetchDetail(id) {
  258. if (!this.axiosInstance) {
  259. this.$message.error('无法获取请求实例')
  260. return
  261. }
  262. this.detailLoading = true
  263. try {
  264. const res = await this.axiosInstance.get(`/lakala/profit_share_receiver/${id}`)
  265. if (res.code === 200) {
  266. this.detailData = res.data
  267. // 处理合作协议文件路径
  268. if (this.detailData.entrust_local_path) {
  269. // 如果是相对路径,则拼接VITE_API_BASE_URL
  270. if (!this.detailData.entrust_local_path.startsWith('http')) {
  271. const { VITE_API_BASE_URL } = this.axiosInstance.defaults.baseURL ?
  272. { VITE_API_BASE_URL: this.axiosInstance.defaults.baseURL.replace('/admin', '') } :
  273. { VITE_API_BASE_URL: '' }
  274. this.detailData.entrust_local_full_url = VITE_API_BASE_URL + this.detailData.entrust_local_path
  275. } else {
  276. // 如果是绝对路径,直接使用
  277. this.detailData.entrust_local_full_url = this.detailData.entrust_local_path
  278. }
  279. }
  280. } else {
  281. this.$message.error(res.msg || res.message || '获取详情失败')
  282. }
  283. } catch (error) {
  284. console.error('获取分账接收方详情失败:', error)
  285. this.$message.error('获取详情失败: ' + (error.message || '未知错误'))
  286. } finally {
  287. this.detailLoading = false
  288. }
  289. },
  290. // 查询
  291. handleSearch() {
  292. this.pagination.page = 1
  293. this.fetchData()
  294. },
  295. // 重置
  296. handleReset() {
  297. this.searchForm = {
  298. order_no: '',
  299. status: ''
  300. }
  301. this.pagination.page = 1
  302. this.fetchData()
  303. },
  304. // 查看详情
  305. async handleView(row) {
  306. await this.fetchDetail(row.id)
  307. this.detailDialogVisible = true
  308. },
  309. // 关闭详情对话框
  310. handleCloseDetailDialog() {
  311. this.detailDialogVisible = false
  312. this.detailData = {}
  313. },
  314. // 分账接收方创建申请
  315. async handleCreateApplication() {
  316. if (!this.axiosInstance) {
  317. this.$message.error('无法获取请求实例')
  318. return
  319. }
  320. this.applyLoading = true
  321. try {
  322. const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/apply`)
  323. if (res.code === 200) {
  324. this.$message.success('分账接收方创建申请已提交')
  325. this.handleCloseDetailDialog()
  326. // 重新加载列表数据以更新状态
  327. await this.fetchData()
  328. } else {
  329. this.$message.error(res.msg || res.message || '申请提交失败')
  330. }
  331. } catch (error) {
  332. console.error('分账接收方创建申请失败:', error)
  333. this.$message.error('申请提交失败: ' + (error.message || '未知错误'))
  334. } finally {
  335. this.applyLoading = false
  336. }
  337. },
  338. // 分账关系绑定申请
  339. async handleBindApplication() {
  340. if (!this.axiosInstance) {
  341. this.$message.error('无法获取请求实例')
  342. return
  343. }
  344. this.applyLoading = true
  345. try {
  346. const res = await this.axiosInstance.put(`/lakala/profit_share_receiver/${this.detailData.id}/bind`)
  347. if (res.code === 200) {
  348. this.$message.success('分账关系绑定申请已提交')
  349. this.handleCloseDetailDialog()
  350. // 重新加载列表数据以更新状态
  351. await this.fetchData()
  352. } else {
  353. this.$message.error(res.msg || res.message || '申请提交失败')
  354. }
  355. } catch (error) {
  356. console.error('分账关系绑定申请失败:', error)
  357. this.$message.error('申请提交失败: ' + (error.message || '未知错误'))
  358. } finally {
  359. this.applyLoading = false
  360. }
  361. },
  362. // 分页相关
  363. handleSizeChange(val) {
  364. this.pagination.limit = val
  365. this.pagination.page = 1
  366. this.fetchData()
  367. },
  368. handleCurrentChange(val) {
  369. this.pagination.page = val
  370. this.fetchData()
  371. }
  372. }
  373. }
  374. </script>
  375. <style scoped>
  376. .profit-share-receiver {
  377. padding: 20px;
  378. }
  379. .search-card {
  380. margin-bottom: 20px;
  381. }
  382. .table-card {
  383. margin-bottom: 20px;
  384. }
  385. .table-header {
  386. display: flex;
  387. justify-content: space-between;
  388. align-items: center;
  389. }
  390. .header-title {
  391. font-size: 16px;
  392. font-weight: bold;
  393. }
  394. .pagination {
  395. margin-top: 20px;
  396. text-align: right;
  397. }
  398. </style>