receiptFormList.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. <template>
  2. <view class="receipt-form-list">
  3. <view v-if="loading" class="loading_wrap">
  4. <u-loading-icon text="加载中" textSize="18"></u-loading-icon>
  5. </view>
  6. <view v-else-if="receiptFormList.length === 0" class="empty_wrap">
  7. <u-empty text="暂无收单数据"></u-empty>
  8. </view>
  9. <view v-else class="card_list">
  10. <view class="card_item" v-for="(row) in receiptFormList" :key="row.id" >
  11. <view class="card_header">
  12. <view class="card_title">{{ row.item || '-' }}</view>
  13. <view class="card_actions">
  14. <u-button size="mini" type="error" @click="handleDelete(row)" icon="trash"></u-button>
  15. </view>
  16. </view>
  17. <view class="card_body" @click="handleUpdate(row)">
  18. <view class="info_row">
  19. <view class="info_label">品牌:</view>
  20. <view class="info_value">{{ row.brand || '-' }}</view>
  21. </view>
  22. <view class="info_row">
  23. <view class="info_label">分单比例:</view>
  24. <view class="info_value">{{ row.splitRatio || '-' }}</view>
  25. </view>
  26. <view class="info_row">
  27. <view class="info_label">卖价:</view>
  28. <view class="info_value">¥{{ formatPrice(row.sellingPrice) }}</view>
  29. </view>
  30. <view class="info_row">
  31. <view class="info_label">业绩:</view>
  32. <view class="info_value highlight">¥{{ formatPrice(row.performance) }}</view>
  33. </view>
  34. </view>
  35. </view>
  36. </view>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. name: 'ReceiptFormList',
  42. props: {
  43. receiptDetail: {
  44. type: Object,
  45. default: () => {}
  46. },
  47. sendFormId: {
  48. type: [Number, String],
  49. required: true
  50. },
  51. clueId: {
  52. type: [Number, String],
  53. required: true
  54. }
  55. },
  56. data() {
  57. return {
  58. // 遮罩层
  59. loading: false,
  60. // 收单信息列表
  61. receiptFormList: [],
  62. // 表单参数
  63. form: {}
  64. }
  65. },
  66. methods: {
  67. /** 查询收单信息列表 */
  68. async getList() {
  69. this.loading = true
  70. try {
  71. const response = await uni.$u.api.listReceiptFormByOrderId(this.sendFormId)
  72. this.receiptFormList = response.data || []
  73. } catch (error) {
  74. uni.$u.toast(`获取列表失败:${error.message}`)
  75. this.receiptFormList = []
  76. } finally {
  77. this.loading = false
  78. }
  79. },
  80. // 格式化价格
  81. formatPrice(price) {
  82. if (!price && price !== 0) return '-'
  83. return Number(price).toFixed(2)
  84. },
  85. /** 去小葫芦线上支付按钮操作 */
  86. async handleTransfer() {
  87. try {
  88. const response = await uni.$u.api.saveOrderFileAndTransfer({
  89. id: this.sendFormId,
  90. clueId: this.clueId
  91. })
  92. uni.$u.toast(response.msg || '支付成功')
  93. } catch (error) {
  94. uni.$u.toast(`支付失败:${error.message}`)
  95. }
  96. },
  97. /** 修改按钮操作 */
  98. async handleUpdate(row) {
  99. uni.navigateTo({
  100. url: `/pages/receiptForm/index?orderId=${this.sendFormId}&clueId=${this.clueId}&receiptId=${row.id}`,
  101. });
  102. },
  103. // 处理更新成功事件
  104. handleUpdateSuccess() {
  105. this.getList()
  106. },
  107. /** 删除按钮操作 */
  108. handleDelete(row) {
  109. uni.showModal({
  110. title: '警告',
  111. content: '是否确认删除收单信息?',
  112. success: (res) => {
  113. if (res.confirm) {
  114. this.deleteRow(row.id)
  115. }
  116. }
  117. })
  118. },
  119. async deleteRow(id) {
  120. try {
  121. await uni.$u.api.delReceiptForm(id)
  122. uni.$u.toast('删除成功')
  123. this.getList()
  124. } catch (error) {
  125. uni.$u.toast(`删除失败:${error.message}`)
  126. }
  127. },
  128. },
  129. created() {
  130. this.getList();
  131. uni.$on('addReceiptFormSuccess',()=>{
  132. this.getList();
  133. });
  134. },
  135. beforeDestroy(){
  136. uni.$off('addReceiptFormSuccess');
  137. }
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .receipt-form-list {
  142. padding: 20px 20px 20px;
  143. background: #f5f6f8;
  144. }
  145. .card_list {
  146. display: flex;
  147. flex-direction: column;
  148. gap: 16px;
  149. }
  150. .card_item {
  151. background-color: #fff;
  152. border-radius: 12px;
  153. padding: 20px;
  154. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  155. }
  156. .card_header {
  157. display: flex;
  158. justify-content: space-between;
  159. align-items: center;
  160. margin-bottom: 16px;
  161. padding-bottom: 12px;
  162. border-bottom: 1px solid #f0f0f0;
  163. }
  164. .card_title {
  165. font-size: 18px;
  166. font-weight: bold;
  167. color: #202020;
  168. }
  169. .card_actions {
  170. display: flex;
  171. gap: 8px;
  172. }
  173. .card_body {
  174. display: flex;
  175. flex-direction: column;
  176. gap: 12px;
  177. }
  178. .info_row {
  179. display: flex;
  180. align-items: center;
  181. font-size: 14px;
  182. }
  183. .info_label {
  184. color: #666;
  185. min-width: 80px;
  186. font-weight: 500;
  187. }
  188. .info_value {
  189. color: #202020;
  190. flex: 1;
  191. &.highlight {
  192. color: #f56c6c;
  193. font-weight: bold;
  194. font-size: 16px;
  195. }
  196. }
  197. .loading_wrap,
  198. .empty_wrap {
  199. padding: 40px 20px;
  200. text-align: center;
  201. }
  202. .dialog_header {
  203. padding: 20px;
  204. font-size: 16px;
  205. font-weight: bold;
  206. text-align: center;
  207. border-bottom: 1px solid #e9ecef;
  208. }
  209. .dialog_body {
  210. padding: 0;
  211. }
  212. </style>