OrderDetailView.vue 7.8 KB

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