ProfitShareReceiver.vue 13 KB

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