commissionFormList.vue 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <template>
  2. <view class="commission-form-list">
  3. <!-- 分成信息卡片列表 -->
  4. <view v-if="loading" class="loading_wrap">
  5. <u-loading-icon text="加载中" textSize="18"></u-loading-icon>
  6. </view>
  7. <view v-else-if="commissionList.length === 0" class="empty_wrap">
  8. <u-empty text="暂无分成数据"></u-empty>
  9. </view>
  10. <view v-else class="card_list">
  11. <commission-item v-for="(row) in commissionList" :key="row.id" :item="row" :type="'2'"
  12. @click.native="handleEdit(row)"></commission-item>
  13. </view>
  14. </view>
  15. </template>
  16. <script>
  17. import commissionItem from "@/pages/order/components/commission/commissionItem.vue";
  18. export default {
  19. name: 'CommissionFormList',
  20. components: {
  21. commissionItem
  22. },
  23. props: {
  24. sendFormId: {
  25. type: [Number, String],
  26. required: true
  27. },
  28. clueId: {
  29. type: [Number, String],
  30. required: true
  31. }
  32. },
  33. data() {
  34. return {
  35. commissionList: [],
  36. loading: false
  37. }
  38. },
  39. methods: {
  40. async getList() {
  41. this.loading = true
  42. try {
  43. const data = {
  44. sendFormId: this.sendFormId,
  45. type: '1'
  46. }
  47. const res = await uni.$u.api.selectCommissionList({}, data);
  48. this.commissionList = res.rows || []
  49. } catch (error) {
  50. uni.$u.toast('获取分成列表失败')
  51. } finally {
  52. this.loading = false
  53. }
  54. },
  55. handleEdit(row) {
  56. // 跳转到编辑分成页面
  57. uni.navigateTo({
  58. url: `/pages/commissionForm/index?sendFormId=${this.sendFormId}&clueId=${this.clueId}&id=${row.id}`
  59. })
  60. },
  61. handleDelete(id) {
  62. uni.showModal({
  63. title: '警告',
  64. content: '确定要删除这条分成记录吗?删除后将无法恢复!',
  65. confirmButtonText: '确定删除',
  66. cancelButtonText: '取消',
  67. success: (res) => {
  68. if (res.confirm) {
  69. this.deleteRow(id)
  70. }
  71. }
  72. })
  73. },
  74. async deleteRow(id) {
  75. try {
  76. await uni.$u.api.clueCommissionForm.remove([id])
  77. uni.$u.toast('删除成功')
  78. this.getList()
  79. } catch (error) {
  80. uni.$u.toast('删除失败,请稍后重试')
  81. }
  82. },
  83. // 外部调用获取列表
  84. getListByExternal() {
  85. this.getList()
  86. }
  87. },
  88. created() {
  89. this.getList();
  90. uni.$on('addCommissionSuccess', () => {
  91. this.getList();
  92. });
  93. },
  94. beforeUnmount() {
  95. uni.$off('addCommissionSuccess');
  96. },
  97. }
  98. </script>
  99. <style lang="scss" scoped>
  100. .commission-form-list {
  101. padding: 20px 20px 20px;
  102. background: #f5f6f8;
  103. }
  104. .commission-header {
  105. margin-bottom: 16px;
  106. }
  107. .loading_wrap,
  108. .empty_wrap {
  109. padding: 40px 20px;
  110. text-align: center;
  111. }
  112. </style>