ProfitShareReceiver.vue 15 KB

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