ProfitShareReceiver.vue 14 KB

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