receiptFormList.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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. }
  132. }
  133. </script>
  134. <style lang="scss" scoped>
  135. .receipt-form-list {
  136. padding: 20px 20px 20px;
  137. background: #f5f6f8;
  138. }
  139. .card_list {
  140. display: flex;
  141. flex-direction: column;
  142. gap: 16px;
  143. }
  144. .card_item {
  145. background-color: #fff;
  146. border-radius: 12px;
  147. padding: 20px;
  148. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  149. }
  150. .card_header {
  151. display: flex;
  152. justify-content: space-between;
  153. align-items: center;
  154. margin-bottom: 16px;
  155. padding-bottom: 12px;
  156. border-bottom: 1px solid #f0f0f0;
  157. }
  158. .card_title {
  159. font-size: 18px;
  160. font-weight: bold;
  161. color: #202020;
  162. }
  163. .card_actions {
  164. display: flex;
  165. gap: 8px;
  166. }
  167. .card_body {
  168. display: flex;
  169. flex-direction: column;
  170. gap: 12px;
  171. }
  172. .info_row {
  173. display: flex;
  174. align-items: center;
  175. font-size: 14px;
  176. }
  177. .info_label {
  178. color: #666;
  179. min-width: 80px;
  180. font-weight: 500;
  181. }
  182. .info_value {
  183. color: #202020;
  184. flex: 1;
  185. &.highlight {
  186. color: #f56c6c;
  187. font-weight: bold;
  188. font-size: 16px;
  189. }
  190. }
  191. .loading_wrap,
  192. .empty_wrap {
  193. padding: 40px 20px;
  194. text-align: center;
  195. }
  196. .dialog_header {
  197. padding: 20px;
  198. font-size: 16px;
  199. font-weight: bold;
  200. text-align: center;
  201. border-bottom: 1px solid #e9ecef;
  202. }
  203. .dialog_body {
  204. padding: 0;
  205. }
  206. </style>