list.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. <template>
  2. <view>
  3. <zj-page-layout
  4. :hasFooter="true"
  5. :isScroll="true"
  6. :refresherTriggered="refresherTriggered"
  7. @refresherrefresh="refresherrefresh"
  8. >
  9. <template slot="header">
  10. <view class="tab-container">
  11. <u-tabs :scrollable="false" :lineWidth="30" :list="tabList" :current="curTab - 1" @click="changeTab"></u-tabs>
  12. </view>
  13. <view class="total"
  14. >当前完成进度:<text>{{ count.ycj || 0 }}</text
  15. >/{{ count.qb || 0 }}</view
  16. >
  17. </template>
  18. <view class="list-container">
  19. <view class="item" v-for="(item, index) in dataList" :key="index" @tap="toCollect(item)">
  20. <view class="top">
  21. <view class="name">设备{{ item.sort }}</view>
  22. <view class="right">{{ item.status | statusFilter }}</view>
  23. </view>
  24. <view class="main">
  25. <view class="row">
  26. <view class="label">产品机型</view>
  27. <view class="value">{{ item.productName || '' }}</view>
  28. </view>
  29. <view class="row">
  30. <view class="label">产品小类</view>
  31. <view class="value">{{ item.smallName || '' }}</view>
  32. </view>
  33. </view>
  34. </view>
  35. </view>
  36. <Loading :type="2" :loadStatus="loadStatus" :dataList="dataList" />
  37. <template slot="footer">
  38. <view class="footer-btn-group">
  39. <u-button
  40. text="提交全部采集"
  41. type="primary"
  42. size="large"
  43. @click="submitData"
  44. :disabled="isCollected"
  45. ></u-button>
  46. </view>
  47. </template>
  48. </zj-page-layout>
  49. </view>
  50. </template>
  51. <script>
  52. export default {
  53. filters: {
  54. statusFilter(val) {
  55. const MAP = {
  56. WAIT: '待采集',
  57. WAIT_SAVE: '待完善',
  58. OK: '已采集'
  59. }
  60. return MAP[val]
  61. }
  62. },
  63. data() {
  64. return {
  65. id: null,
  66. isCollected: false,
  67. tabList: [
  68. { name: '待采集', value: 1, badge: { value: 0 } },
  69. { name: '已采集', value: 2, badge: { value: 0 } }
  70. ],
  71. loadStatus: 0,
  72. curTab: 1,
  73. dataList: [],
  74. refresherTriggered: false,
  75. count: {}
  76. }
  77. },
  78. async onLoad({ id }) {
  79. this.id = id
  80. await this.getOrderDetail()
  81. await this.getCount()
  82. if (this.isCollected || this.count.wcj == 0) {
  83. this.curTab = 2
  84. }
  85. this.getList()
  86. this.crossPage.$on('refreshCollectList', async type => {
  87. console.log(type)
  88. await this.getOrderDetail()
  89. await this.getCount()
  90. if (type == 1) {
  91. this.curTab = 1
  92. }
  93. if (this.isCollected || this.count.wcj == 0) {
  94. this.curTab = 2
  95. }
  96. this.refreshList()
  97. })
  98. },
  99. onUnload() {
  100. this.crossPage.$off('refreshCollectList')
  101. },
  102. methods: {
  103. // 触发下拉刷新
  104. async refresherrefresh(e) {
  105. this.refresherTriggered = true
  106. this.getCount()
  107. this.refreshList()
  108. },
  109. // 获取详情
  110. async getOrderDetail() {
  111. return new Promise((resolve, reject) => {
  112. this.$api
  113. .post('/pg/order/base/detail', {
  114. orderBaseId: this.id
  115. })
  116. .then(res => {
  117. this.isCollected = res.data && res.data.isGather == 'YES'
  118. resolve(1)
  119. })
  120. })
  121. },
  122. async getCount() {
  123. return new Promise((resolve, reject) => {
  124. this.$api
  125. .post('/changeOrder/getOrderProductCount', {
  126. id: this.id
  127. })
  128. .then(res => {
  129. this.count = res.data
  130. this.tabList[0].badge.value = res.data.wcj
  131. this.tabList[1].badge.value = res.data.ycj
  132. resolve(1)
  133. })
  134. })
  135. },
  136. getList() {
  137. this.loadStatus = 1
  138. this.$api
  139. .post('/changeOrder/getOrderProduct', {
  140. id: this.id,
  141. status: this.curTab == 1 ? ['WAIT', 'WAIT_SAVE'] : 'OK'
  142. })
  143. .then(res => {
  144. this.loadStatus = 0
  145. this.dataList = res.data
  146. })
  147. .catch(() => {
  148. this.loadStatus = 2
  149. })
  150. .finally(() => {
  151. this.loadStatus = 0
  152. this.refresherTriggered = false
  153. })
  154. },
  155. changeTab(e) {
  156. this.curTab = e.value
  157. this.refreshList()
  158. },
  159. refreshList() {
  160. this.dataList = []
  161. this.getList()
  162. },
  163. toCollect(item) {
  164. this.$navToPage({
  165. // url: `/packageWorkorder/pages/infoCollect/form?oid=${this.id}&cid=${item.id}&isView=${this.isCollected ? 1 : 0}`
  166. url: `/packageWorkorder/pages/infoCollect/form?oid=${this.id}&cid=${item.id}&isView=0`
  167. })
  168. },
  169. // 提交全部采集
  170. async submitData() {
  171. const lo = await this.$getAddress()
  172. this.$api
  173. .post('/changeOrder/submitProductDetail', {
  174. orderBaseId: this.id,
  175. address: lo.address || ''
  176. })
  177. .then(res => {
  178. this.$successToast('提交成功')
  179. this.crossPage.$emit('refreshFeedbackForm', '')
  180. setTimeout(() => {
  181. this.$navToPage(
  182. {
  183. delta: 1
  184. },
  185. 'navigateBack'
  186. )
  187. }, 500)
  188. })
  189. }
  190. }
  191. }
  192. </script>
  193. <style lang="scss" scoped>
  194. .tab-container {
  195. background: #ffffff;
  196. }
  197. .total {
  198. text-align: right;
  199. color: $sec-font;
  200. padding: 30rpx;
  201. text {
  202. color: $theme-color;
  203. font-weight: 500;
  204. }
  205. }
  206. .list-container {
  207. padding: 1rpx 30rpx;
  208. .item {
  209. @include zj-card;
  210. margin-bottom: 30rpx;
  211. .top {
  212. padding: 0 30rpx;
  213. height: 100rpx;
  214. display: flex;
  215. align-items: center;
  216. justify-content: space-between;
  217. .name {
  218. font-size: 32rpx;
  219. font-weight: 500;
  220. display: flex;
  221. align-items: center;
  222. ::v-deep .u-badge {
  223. margin-left: 12rpx;
  224. }
  225. }
  226. .right {
  227. color: $theme-color;
  228. }
  229. }
  230. .main {
  231. padding: 30rpx;
  232. border-top: 1px solid #f5f5f5;
  233. .row {
  234. display: flex;
  235. align-items: center;
  236. justify-content: space-between;
  237. margin-top: 30rpx;
  238. &:first-child {
  239. margin-top: 0;
  240. }
  241. .label {
  242. color: $sec-font;
  243. }
  244. }
  245. }
  246. .bottom {
  247. padding: 0 30rpx;
  248. height: 100rpx;
  249. display: flex;
  250. align-items: center;
  251. justify-content: space-between;
  252. border-top: 1px solid #f5f5f5;
  253. .right {
  254. ::v-deep .u-button {
  255. height: 60rpx;
  256. }
  257. }
  258. }
  259. }
  260. }
  261. </style>