ProfitShareReceiver.vue 16 KB

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