index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. <template>
  2. <view>
  3. <uni-segmented-control :current="current" :values="tabList" @clickItem="tabClick" styleType="text" activeColor="#ffaa00" />
  4. <view class="content">
  5. <view style="margin-top: 10rpx;">
  6. <uni-list :border="true">
  7. <uni-swipe-action v-for="(item,index) in dataList" :key="index">
  8. <!-- 全部 -->
  9. <uni-swipe-action-item v-if="current === 0" :right-options="getOpts(item.ddzt)" :disabled="item.ddzt === '4'" :show="isOpened"
  10. :auto-close="false" @click="bindClick(item)">
  11. <uni-list-item :title="item.cpName" :note="'下单人:' + item.shxm + ' 单价:' + item.je + '元'" :thumb="item.tx" thumb-size="lg"
  12. :rightText="transDictLabel(dicts.WL007,item.ddzt)" link="navigateTo" :to="`/pages/order/add?item=`+JSON.stringify(item)">
  13. </uni-list-item>
  14. </uni-swipe-action-item>
  15. <!-- 待接单/待派单/进行时/完成 -->
  16. <uni-swipe-action-item v-else-if="current == item.ddzt" :right-options="getOpts(item.ddzt)" :disabled="item.ddzt === '4'" :show="isOpened"
  17. :auto-close="false" @click="bindClick(item)">
  18. <uni-list-item :title="item.cpName" :note="'下单人:' + item.shxm + ' 单价:' + item.je + '元'" :thumb="item.tx" thumb-size="lg"
  19. :rightText="transDictLabel(dicts.WL007,item.ddzt)" link="navigateTo" :to="`/pages/order/add?item=`+JSON.stringify(item)">
  20. </uni-list-item>
  21. </uni-swipe-action-item>
  22. </uni-swipe-action>
  23. </uni-list>
  24. </view>
  25. <uni-load-more :status="status" :content-text="contentText" @clickLoadMore="clickLoadMore" />
  26. </view>
  27. <uni-fab :pattern="pattern" :horizontal="horizontal" :vertical="vertical" @fabClick="fabClick"></uni-fab>
  28. </view>
  29. </template>
  30. <script>
  31. import { listDdjy, updateDdjy } from '@/api/order.js'
  32. import config from '@/config.js'
  33. import { decryptRowData_ECB } from '@/common/sm4.js'
  34. export default {
  35. data() {
  36. return {
  37. dicts: {
  38. WL007: [],
  39. },
  40. isOpened: 'none',
  41. tabList: ['全部', '待接单', '待派单', '进行中', '已完成'],
  42. current: 0,
  43. horizontal: 'right',
  44. vertical: 'bottom',
  45. pattern: {
  46. buttonColor: '#ffaa00',
  47. iconColor: '#fff'
  48. },
  49. status: 'more',
  50. contentText: {
  51. contentdown: '查看更多>',
  52. contentrefresh: '加载中...',
  53. contentnomore: '没有更多了'
  54. },
  55. queryParams: {
  56. pageNum: 1,
  57. pageSize: 10,
  58. },
  59. total: 0,
  60. dataList: [],
  61. }
  62. },
  63. created() {
  64. this.getDictList(Object.keys(this.dicts), this.dicts)
  65. this.getList()
  66. },
  67. onPullDownRefresh() {
  68. this.queryParams.pageNum = 1
  69. this.getList(true)
  70. },
  71. methods: {
  72. getList(isClear) {
  73. isClear ? this.dataList = [] : ''
  74. listDdjy(this.queryParams).then(res => {
  75. this.dataList = res.rows
  76. this.dataList.forEach(e => {
  77. e.tx = e.tx ? config.baseUrl + e.tx : config.baseUrl + config.head;
  78. })
  79. this.total = res.total
  80. this.total > this.dataList.length ? this.status = 'more' : this.status = 'noMore'
  81. })
  82. setTimeout(function() {
  83. uni.stopPullDownRefresh();
  84. }, 1000);
  85. },
  86. tabClick(e) {
  87. if (this.current != e.currentIndex) {
  88. this.current = e.currentIndex;
  89. }
  90. },
  91. fabClick() {
  92. uni.navigateTo({
  93. url: '/pages/order/add'
  94. })
  95. },
  96. bindClick(e) {
  97. this.isOpened = 'none'
  98. const params = {
  99. id: e.id,
  100. ddzt: Number(e.ddzt) + 1
  101. }
  102. updateDdjy(params).then(res => {
  103. if (res.code === 200) {
  104. uni.showToast({
  105. title: `保存成功!`,
  106. duration: 2000,
  107. success: (res) => {
  108. this.getList(true)
  109. }
  110. })
  111. }
  112. })
  113. },
  114. clickLoadMore(e) {
  115. if (this.total > this.dataList.length) {
  116. this.status = 'loading'
  117. this.form.pageNum += 1
  118. this.getList()
  119. }
  120. },
  121. getOpts(ddzt) {
  122. let options = [{ text: '完成', style: { backgroundColor: '#F56C6C' } }]
  123. switch (ddzt) {
  124. case '1':
  125. options[0].text = '接单'
  126. break;
  127. case '2':
  128. options[0].text = '派单'
  129. break;
  130. case '3':
  131. options[0].text = '完成'
  132. break;
  133. }
  134. return options
  135. },
  136. }
  137. }
  138. </script>
  139. <style>
  140. </style>