OrderDetailView.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <view class="order-detail-view">
  3. <!-- 页面切换 -->
  4. <view class="page-item" v-show="activeIndex === 0">
  5. <PageOne :order-detail="orderDetail" :order-id="orderId" :current-receipt="currentReceipt" @next="handleNext" />
  6. </view>
  7. <view class="page-item" v-show="activeIndex === 1">
  8. <PageTwo :order-detail="orderDetail" :order-id="orderId" :current-receipt="currentReceipt"
  9. :follow-up-list="followUpList" @next="handleNext" @update-file-ids="handleUpdateFileIds"
  10. @price-updated="$emit('price-updated')" />
  11. </view>
  12. <view class="page-item" v-show="activeIndex === 2">
  13. <PageThree :order-detail="orderDetail" :order-id="orderId" :current-receipt="currentReceipt" @next="handleNext"
  14. @save="handleNeedSave" @confirm-pay="handleConfirmPay" @update-file-ids="handleUpdateFileIds"
  15. @price-updated="$emit('price-updated')" ref="pageThreeRef" />
  16. </view>
  17. <view class="page-item" v-show="activeIndex === 3">
  18. <PageFour :order-detail="orderDetail" :current-receipt="currentReceipt" @next="handleNext"
  19. @confirm-warehouse="handleConfirmWarehouse" />
  20. </view>
  21. <!-- 页面导航 -->
  22. <ul class="page-navigation">
  23. <li v-for="(tab, index) in tabs" :key="index" :class="{ 'active': activeIndex === index }"
  24. @click="handleTabClick(index)">
  25. {{ tab }}
  26. </li>
  27. </ul>
  28. </view>
  29. </template>
  30. <script>
  31. import PageOne from './PageOne.vue'
  32. import PageTwo from './PageTwo.vue'
  33. import PageThree from './PageThree.vue'
  34. import PageFour from './PageFour.vue'
  35. export default {
  36. name: 'OrderDetailView',
  37. components: {
  38. PageOne,
  39. PageTwo,
  40. PageThree,
  41. PageFour
  42. },
  43. props: {
  44. orderDetail: {
  45. type: Object,
  46. default: () => ({})
  47. },
  48. topInfo: {
  49. type: Object,
  50. default: () => ({})
  51. },
  52. orderId: {
  53. type: String,
  54. default: ''
  55. },
  56. currentReceipt: {
  57. type: Object,
  58. default: () => ({})
  59. }
  60. },
  61. data() {
  62. return {
  63. activeIndex: 0,
  64. tabs: ['一', '二', '三', '四'],
  65. // 表单数据
  66. formData: {
  67. formOne: {},
  68. formTwo: {},
  69. formThree: {},
  70. formFour: {}
  71. },
  72. pageThreeForm: {},
  73. fileIds: '',
  74. // 跟进记录
  75. followUpList: []
  76. }
  77. },
  78. watch: {
  79. orderDetail: {
  80. handler(newVal) {
  81. if (newVal && newVal.clueId) {
  82. this.loadFollowUpList()
  83. }
  84. },
  85. deep: true,
  86. immediate: true
  87. }
  88. },
  89. methods: {
  90. /**
  91. * 加载跟进记录
  92. */
  93. async loadFollowUpList() {
  94. try {
  95. const res = await uni.$u.api.getDuplicateOrderFollowListByClueId({
  96. clueId: this.orderDetail.clueId
  97. })
  98. const data = res.data || {}
  99. const followUpList = []
  100. for (const key in data) {
  101. followUpList.push(...(data[key] || []))
  102. }
  103. this.followUpList = followUpList
  104. } catch (error) {
  105. console.error('获取跟进记录失败:', error)
  106. uni.$u.toast('获取跟进记录失败')
  107. }
  108. },
  109. /**
  110. * 处理下一步
  111. */
  112. handleNext({ nowPage, form }) {
  113. this.activeIndex++
  114. if (nowPage) {
  115. this.formData[nowPage] = form
  116. }
  117. // 当切换到第三页时,更新第三页的图片列表
  118. if (nowPage === 'formTwo' && this.$refs.pageThreeRef) {
  119. this.$refs.pageThreeRef.refreshImageList()
  120. }
  121. },
  122. /**
  123. * 处理保存
  124. */
  125. handleNeedSave({ nowPage, form, fileIds }) {
  126. this.pageThreeForm = form
  127. this.fileIds = fileIds
  128. },
  129. /**
  130. * 处理确认支付
  131. */
  132. async handleConfirmPay() {
  133. try {
  134. const response = await uni.$u.api.saveOrderFileAndTransfer({
  135. id: this.orderId,
  136. clueId: this.orderDetail.clueId
  137. })
  138. uni.$u.toast(response.msg || '支付成功')
  139. } catch (error) {
  140. console.error('支付失败:', error)
  141. uni.$u.toast(`支付失败:${error}`)
  142. //支付失败回滚支付信息
  143. await uni.$u.api.updateClueOrderForm({
  144. id: this.orderDetail.id,
  145. paymentMethod: ''
  146. })
  147. }
  148. },
  149. /**
  150. * 处理确认入库
  151. */
  152. async handleConfirmWarehouse({ warehouseInfo }) {
  153. try {
  154. const params = {
  155. searchValue: this.orderDetail.searchValue,
  156. createBy: this.orderDetail.createBy,
  157. createTime: this.orderDetail.createTime,
  158. updateBy: this.orderDetail.updateBy,
  159. updateTime: this.orderDetail.updateTime,
  160. params: this.orderDetail.params,
  161. id: this.currentReceipt.id,
  162. sendFormId: this.orderId,
  163. clueId: this.orderDetail.clueId,
  164. item: warehouseInfo.item || '',
  165. code: warehouseInfo.codeStorage || '',
  166. phone: this.orderDetail.phone,
  167. tableFee: warehouseInfo.watchPrice || '',
  168. benefitFee: warehouseInfo.benefitFee || '',
  169. freight: warehouseInfo.freight || '',
  170. checkCodeFee: warehouseInfo.checkCodeFee || '',
  171. receiptRemark: `${warehouseInfo.remarks || ''};${warehouseInfo.uploadedImage || ''}`,
  172. repairAmount: warehouseInfo.repairAmount || '',
  173. grossPerformance: warehouseInfo.grossPerformance || '',
  174. expressOrderNo: warehouseInfo.expressOrderNo || '',
  175. fileIds: this.fileIds,
  176. customerServiceName: warehouseInfo.customerServiceName || '1',
  177. deptId: this.orderDetail.deptId,
  178. category: warehouseInfo.category || this.orderDetail.category,
  179. delFlag: this.orderDetail.delFlag,
  180. idCard: this.pageThreeForm.idNumber || '',
  181. paymentMethod: '小葫芦线上支付',
  182. bankCardNumber: this.pageThreeForm.bankAccount || '',
  183. bankName: this.pageThreeForm.bankName || '',
  184. customName: this.pageThreeForm.customName || ''
  185. }
  186. if (this.currentReceipt.id) {
  187. await uni.$u.api.updateReceiptForm(params)
  188. } else {
  189. await uni.$u.api.addReceiptForm(params)
  190. }
  191. uni.$u.toast('入库成功')
  192. } catch (error) {
  193. console.error('入库失败:', error)
  194. uni.$u.toast('入库失败')
  195. }
  196. },
  197. /**
  198. * 处理标签点击
  199. */
  200. handleTabClick(index) {
  201. this.activeIndex = index
  202. // 切换到第三页时刷新图片列表
  203. if (index === 2 && this.$refs.pageThreeRef) {
  204. this.$refs.pageThreeRef.refreshImageList()
  205. }
  206. },
  207. /**
  208. * 更新 fileIds
  209. */
  210. handleUpdateFileIds(fileIds) {
  211. if (this.currentReceipt) {
  212. this.$set(this.currentReceipt, 'fileIds', fileIds)
  213. this.fileIds = fileIds
  214. }
  215. }
  216. }
  217. }
  218. </script>
  219. <style scoped lang="scss">
  220. .order-detail-view {
  221. padding: 20rpx;
  222. min-height: calc(100vh - 200rpx);
  223. }
  224. .page-item {
  225. width: 100%;
  226. }
  227. .page-navigation {
  228. position: fixed;
  229. right: 20rpx;
  230. top: 40%;
  231. display: flex;
  232. flex-direction: column;
  233. align-items: center;
  234. justify-content: center;
  235. list-style: none;
  236. color: #000;
  237. font-size: 20rpx;
  238. font-weight: 800;
  239. z-index: 100;
  240. li {
  241. opacity: 0.7;
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. background-color: #fff;
  246. border-radius: 50%;
  247. width: 70rpx;
  248. height: 70rpx;
  249. line-height: 70rpx;
  250. text-align: center;
  251. margin-bottom: 20rpx;
  252. transition: all 0.3s ease-in-out;
  253. font-weight: 800;
  254. box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  255. cursor: pointer;
  256. &.active {
  257. color: #fff;
  258. opacity: 1;
  259. background-color: rgb(37 99 235 / 1);
  260. }
  261. &:hover {
  262. opacity: 0.9;
  263. transform: scale(1.05);
  264. }
  265. }
  266. }
  267. </style>