commissionFormList.vue 2.5 KB

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