ProfitShareReceiver.vue 15 KB

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