receiptFormList.vue 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. <template>
  2. <view class="receipt-form-list">
  3. <!-- 头部按钮组 -->
  4. <view class="receipt-form-header">
  5. <u-button type="primary" size="mini" icon="plus" @click="handleAdd">新增收单信息</u-button>
  6. <u-button type="primary" size="mini" icon="share" @click="handleTransfer">去小葫芦线上支付</u-button>
  7. </view>
  8. <!-- 收单信息卡片列表 -->
  9. <view v-if="loading" class="loading_wrap">
  10. <u-loading-icon text="加载中" textSize="18"></u-loading-icon>
  11. </view>
  12. <view v-else-if="receiptFormList.length === 0" class="empty_wrap">
  13. <u-empty text="暂无收单数据"></u-empty>
  14. </view>
  15. <view v-else class="card_list">
  16. <view class="card_item" v-for="(row, index) in receiptFormList" :key="row.id">
  17. <view class="card_header">
  18. <view class="card_title">{{ row.item || '-' }}</view>
  19. <view class="card_actions">
  20. <u-button size="mini" type="text" @click="handleUpdate(row)">详情</u-button>
  21. <u-button size="mini" type="text" @click="handleDelete(row)" style="color: #f56c6c">删除</u-button>
  22. </view>
  23. </view>
  24. <view class="card_body">
  25. <view class="info_row">
  26. <view class="info_label">品牌:</view>
  27. <view class="info_value">{{ row.brand || '-' }}</view>
  28. </view>
  29. <view class="info_row">
  30. <view class="info_label">分单比例:</view>
  31. <view class="info_value">{{ row.splitRatio || '-' }}</view>
  32. </view>
  33. <view class="info_row">
  34. <view class="info_label">卖价:</view>
  35. <view class="info_value">¥{{ formatPrice(row.sellingPrice) }}</view>
  36. </view>
  37. <view class="info_row">
  38. <view class="info_label">业绩:</view>
  39. <view class="info_value highlight">¥{{ formatPrice(row.performance) }}</view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. <!-- 收单表单对话框 -->
  45. <u-popup v-model="dialogVisible" mode="center" :width="dialogWidth" border-radius="16">
  46. <view class="dialog_header">{{ dialogTitle }}</view>
  47. <view class="dialog_body">
  48. <receiptForm
  49. :receipt-detail="form"
  50. :send-form-id="sendFormId"
  51. :clue-id="clueId"
  52. @update-success="handleUpdateSuccess"
  53. ></receiptForm>
  54. </view>
  55. </u-popup>
  56. </view>
  57. </template>
  58. <script>
  59. import receiptForm from './receiptForm/index.vue'
  60. export default {
  61. name: 'ReceiptFormList',
  62. components: {
  63. receiptForm
  64. },
  65. props: {
  66. receiptDetail: {
  67. type: Object,
  68. default: () => {}
  69. },
  70. sendFormId: {
  71. type: [Number, String],
  72. required: true
  73. },
  74. clueId: {
  75. type: [Number, String],
  76. required: true
  77. }
  78. },
  79. data() {
  80. return {
  81. // 对话框控制
  82. dialogVisible: false,
  83. dialogTitle: '收单信息',
  84. dialogWidth: '860rpx',
  85. // 遮罩层
  86. loading: false,
  87. // 收单信息列表
  88. receiptFormList: [],
  89. // 表单参数
  90. form: {}
  91. }
  92. },
  93. methods: {
  94. /** 查询收单信息列表 */
  95. async getList() {
  96. this.loading = true
  97. try {
  98. const response = await uni.$u.api.listReceiptFormByOrderId(this.sendFormId)
  99. this.receiptFormList = response.data || []
  100. } catch (error) {
  101. uni.$u.toast(`获取列表失败:${error.message}`)
  102. this.receiptFormList = []
  103. } finally {
  104. this.loading = false
  105. }
  106. },
  107. // 格式化价格
  108. formatPrice(price) {
  109. if (!price && price !== 0) return '-'
  110. return Number(price).toFixed(2)
  111. },
  112. /** 去小葫芦线上支付按钮操作 */
  113. async handleTransfer() {
  114. try {
  115. const response = await uni.$u.api.saveOrderFileAndTransfer({
  116. id: this.sendFormId,
  117. clueId: this.clueId
  118. })
  119. uni.$u.toast(response.msg || '支付成功')
  120. } catch (error) {
  121. uni.$u.toast(`支付失败:${error.message}`)
  122. }
  123. },
  124. /** 新增按钮操作 */
  125. handleAdd() {
  126. this.reset()
  127. this.dialogTitle = '新增收单信息'
  128. this.dialogVisible = true
  129. },
  130. /** 修改按钮操作 */
  131. async handleUpdate(row) {
  132. this.reset()
  133. try {
  134. const response = await uni.$u.api.getReceiptForm(row.id)
  135. this.form = response.data
  136. this.dialogTitle = '修改收单信息'
  137. this.dialogVisible = true
  138. } catch (error) {
  139. uni.$u.toast(`获取详情失败:${error.message}`)
  140. }
  141. },
  142. // 处理更新成功事件
  143. handleUpdateSuccess() {
  144. this.dialogVisible = false
  145. this.getList()
  146. },
  147. /** 删除按钮操作 */
  148. handleDelete(row) {
  149. uni.showModal({
  150. title: '警告',
  151. content: '是否确认删除收单信息?',
  152. success: (res) => {
  153. if (res.confirm) {
  154. this.deleteRow(row.id)
  155. }
  156. }
  157. })
  158. },
  159. async deleteRow(id) {
  160. try {
  161. await uni.$u.api.delReceiptForm(id)
  162. uni.$u.toast('删除成功')
  163. this.getList()
  164. } catch (error) {
  165. uni.$u.toast(`删除失败:${error.message}`)
  166. }
  167. },
  168. /** 表单重置 */
  169. reset() {
  170. this.form = Object.assign({
  171. id: undefined,
  172. sendFormId: this.sendFormId,
  173. clueId: this.clueId,
  174. item: '',
  175. brand: '',
  176. needCheckCode: 1,
  177. code: '',
  178. tableFee: undefined,
  179. benefitFee: undefined,
  180. freight: undefined,
  181. checkCodeFee: undefined,
  182. totalCost: undefined,
  183. sellingPrice: undefined,
  184. performance: undefined,
  185. receiptRemark: '',
  186. repairAmount: undefined,
  187. grossPerformance: undefined,
  188. expressOrderNo: '',
  189. fileIds: ''
  190. }, this.receiptDetail)
  191. }
  192. },
  193. created() {
  194. this.getList()
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .receipt-form-list {
  200. padding: 0 20px 20px;
  201. }
  202. .receipt-form-header {
  203. margin-bottom: 16px;
  204. display: flex;
  205. gap: 10px;
  206. }
  207. .card_list {
  208. display: flex;
  209. flex-direction: column;
  210. gap: 16px;
  211. }
  212. .card_item {
  213. background-color: #fff;
  214. border-radius: 12px;
  215. padding: 20px;
  216. box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  217. }
  218. .card_header {
  219. display: flex;
  220. justify-content: space-between;
  221. align-items: center;
  222. margin-bottom: 16px;
  223. padding-bottom: 12px;
  224. border-bottom: 1px solid #f0f0f0;
  225. }
  226. .card_title {
  227. font-size: 18px;
  228. font-weight: bold;
  229. color: #202020;
  230. }
  231. .card_actions {
  232. display: flex;
  233. gap: 8px;
  234. }
  235. .card_body {
  236. display: flex;
  237. flex-direction: column;
  238. gap: 12px;
  239. }
  240. .info_row {
  241. display: flex;
  242. align-items: center;
  243. font-size: 14px;
  244. }
  245. .info_label {
  246. color: #666;
  247. min-width: 80px;
  248. font-weight: 500;
  249. }
  250. .info_value {
  251. color: #202020;
  252. flex: 1;
  253. &.highlight {
  254. color: #f56c6c;
  255. font-weight: bold;
  256. font-size: 16px;
  257. }
  258. }
  259. .loading_wrap,
  260. .empty_wrap {
  261. padding: 40px 20px;
  262. text-align: center;
  263. }
  264. .dialog_header {
  265. padding: 20px;
  266. font-size: 16px;
  267. font-weight: bold;
  268. text-align: center;
  269. border-bottom: 1px solid #e9ecef;
  270. }
  271. .dialog_body {
  272. padding: 0;
  273. }
  274. </style>