OrderDetailView.vue 7.8 KB

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