OrderDetailView.vue 7.8 KB

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