index.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <view class="picking-task-page">
  3. <u-navbar height="40px" title="拣货任务" bgColor="#F0F6FB" autoBack placeholder>
  4. <view class="u-nav-slot btn-right" slot="right" @click="stashClick">
  5. <view class="cang-name">{{cangName}}</view>
  6. <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
  7. </view>
  8. </u-navbar>
  9. <view class="container_main">
  10. <u-sticky :offsetTop="offsetTop" bgColor="#F0F6FB">
  11. <view class="search-box">
  12. <u-search placeholder="请输入单据编号" bgColor="#fff" shape="square" v-model="params.number" :showAction="false" @search="searchClick" @clear="searchClick"></u-search>
  13. <view class="flex_box" @click="scanCode">
  14. <view class="scan-text">扫描单据二维码</view>
  15. <view class="scan-icon">
  16. <image src="@/static/image/scan-icon.png" mode=""></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="type-box flex_box">
  21. <view class="type-item" @click="tabClick(1)">
  22. <view class="type-val">{{type1}}</view>
  23. <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
  24. </view>
  25. <view class="type-item" @click="tabClick(2)">
  26. <view class="type-val">{{type2}}</view>
  27. <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
  28. </view>
  29. </view>
  30. </u-sticky>
  31. <view class="task-cont">
  32. <block v-for="(item,i) in taskList" :key="i">
  33. <task-item :item="item" @toStorage="toStorage" @toDetail="toDetail"></task-item>
  34. </block>
  35. <u-loadmore v-if="taskList.length > 0" :status="status" />
  36. <u-empty mode="data" v-if="taskList.length == 0"></u-empty>
  37. </view>
  38. </view>
  39. <!-- 中心仓弹窗 -->
  40. <u-picker :show="stashShow" :defaultIndex="defaultIndex" :columns="stashColumns" @confirm="pickerConfirm" @cancel="stashShow= false"></u-picker>
  41. <!-- 状态 -->
  42. <u-picker :show="statusShow" keyName="name" :defaultIndex="defaultIndex2" :columns="statusColumns" @confirm="statusConfirm" @cancel="statusShow= false"></u-picker>
  43. <!-- 月份 -->
  44. <u-picker :show="dateShow" :defaultIndex="defaultIndex3" :columns="dateColumns" @confirm="dateConfirm" @cancel="dateShow= false"></u-picker>
  45. </view>
  46. </template>
  47. <script>
  48. var main, receiver, filter;
  49. var _codeQueryTag = false;
  50. import taskItem from '@/components/task-item/task-item.vue'
  51. import {saleOrder} from '@/common/request/apis/picking'
  52. import {orderStartHandle} from '@/common/request/apis/purchase'
  53. export default{
  54. components:{
  55. taskItem
  56. },
  57. data() {
  58. return {
  59. offsetTop:0,
  60. cangName:'鹏越中心仓',
  61. type1:'全部',
  62. type2:'月份',
  63. stashShow:false,
  64. statusShow:false,
  65. dateShow:false,
  66. stashColumns:[
  67. ['鹏越中心仓','美团中心仓']
  68. ],
  69. statusColumns:[
  70. [{
  71. name:'全部',
  72. id:''
  73. },{
  74. name:'待拣货',
  75. id:'1'
  76. },{
  77. name:'拣货中',
  78. id:'4'
  79. },{
  80. name:'已拣货',
  81. id:'2'
  82. }]
  83. ],
  84. dateColumns:[
  85. ['全年','一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
  86. ],
  87. defaultIndex:[],
  88. defaultIndex2:[],
  89. defaultIndex3:[],
  90. taskList:[],
  91. params:{
  92. beginTime:'',
  93. endTime:'',
  94. number:'',
  95. status:'',
  96. currentPage:1,
  97. pageSize:10
  98. },
  99. status:'loadmore',
  100. lastPage:1,
  101. }
  102. },
  103. onLoad() {
  104. let systemInfo = uni.getSystemInfoSync();
  105. let statusBarHeight = systemInfo.statusBarHeight;
  106. this.offsetTop = statusBarHeight + 40
  107. this.init()
  108. },
  109. onHide() {
  110. uni.$off('scanFinish')
  111. },
  112. onUnload() {
  113. uni.$off('scanFinish')
  114. },
  115. onReachBottom() {
  116. if(this.params.currentPage < this.lastPage) {
  117. this.params.currentPage ++
  118. this.getSaleOrder()
  119. }
  120. },
  121. onShow() {
  122. uni.$on('scanFinish',(data)=>{
  123. this.params.number = data
  124. this.init()
  125. })
  126. if(uni.getStorageSync('orderRefresh')) {
  127. this.init()
  128. uni.removeStorageSync('orderRefresh')
  129. }
  130. },
  131. methods:{
  132. scanCode() {
  133. this.$scan.scanCode()
  134. },
  135. init() {
  136. uni.showLoading()
  137. this.params.pageNum = 1
  138. this.getSaleOrder()
  139. },
  140. searchClick() {
  141. this.init()
  142. },
  143. tabClick(type) {
  144. if(type == 1) {
  145. this.defaultIndex = this.getDefaultIndex(this.type1,this.statusColumns)
  146. this.statusShow = true
  147. }else {
  148. this.defaultIndex = this.getDefaultIndex(this.type2,this.dateColumns)
  149. this.dateShow = true
  150. }
  151. },
  152. getSaleOrder() {
  153. saleOrder(this.params)
  154. .then(res=>{
  155. if(res.code == 200) {
  156. this.status = 'loading';
  157. this.lastPage = Math.ceil(res.data.total * 1 / this.params.pageSize)
  158. if(this.params.currentPage < this.lastPage) {
  159. this.status = 'loadmore'
  160. }else {
  161. this.status = 'nomore'
  162. }
  163. this.taskList =[...this.taskList,...res.data.rows];
  164. }
  165. uni.hideLoading()
  166. })
  167. .catch(err=>{
  168. uni.hideLoading()
  169. })
  170. },
  171. stashClick() {
  172. this.defaultIndex = this.getDefaultIndex(this.cangName,this.stashColumns)
  173. this.stashShow = true
  174. },
  175. pickerConfirm(val) {
  176. this.cangName = val.value[0]
  177. this.stashShow = false
  178. },
  179. statusConfirm(val) {
  180. this.type1 = val.value[0].name
  181. this.params.status = val.value[0].id
  182. this.statusShow = false
  183. this.init()
  184. },
  185. dateConfirm(val) {
  186. this.type2 = val.value[0]
  187. this.dateShow = false
  188. let month = val.indexs[0]
  189. this.getLastDayOfMonth(month)
  190. this.init()
  191. },
  192. // 获取开始时间、结束时间
  193. getLastDayOfMonth(month) {
  194. let year = new Date().getFullYear()
  195. if(month !=0) {
  196. let monthStart = new Date(year, month, 0).getDate();
  197. this.params.beginTime = `${year}-${month}-01`
  198. this.params.endTime = `${year}-${month}-${monthStart}`
  199. }else {
  200. this.params.beginTime = ''
  201. this.params.endTime = ''
  202. }
  203. },
  204. // 获取picker默认index
  205. getDefaultIndex(val,list) {
  206. let arr = []
  207. let index = list[0].findIndex(item=>item.name == val)
  208. arr = [index]
  209. return arr
  210. },
  211. // 点击操作
  212. toOrderStartHandle(id) {
  213. orderStartHandle(id)
  214. .then(res=>{
  215. if(res.code == 200) {
  216. uni.navigateTo({
  217. url:`/pages/picking-task/delivery?id=${id}`
  218. })
  219. }
  220. })
  221. },
  222. // 出库
  223. toStorage(val) {
  224. this.toOrderStartHandle(val.id)
  225. },
  226. toDetail(val) {
  227. uni.navigateTo({
  228. url:`/pages/picking-task/detail?id=${val.id}`
  229. })
  230. }
  231. }
  232. }
  233. </script>
  234. <style lang="scss" scoped>
  235. .btn-right {
  236. display: flex;
  237. align-items: center;
  238. .cang-name {
  239. color: #0256FF;
  240. text-align: center;
  241. font-family: "PingFang SC";
  242. font-size: 28rpx;
  243. font-weight: 600;
  244. margin-right: 10rpx;
  245. }
  246. }
  247. .picking-task-page {
  248. min-height: 100vh;
  249. background: #F0F6FB;
  250. .container_main {
  251. .search-box {
  252. display: flex;
  253. align-items: center;
  254. padding: 0 32rpx;
  255. .scan-text {
  256. color: #333;
  257. font-family: "PingFang SC";
  258. font-size: 24rpx;
  259. font-weight: 400;
  260. margin-right: 20rpx;
  261. margin-left: 30rpx;
  262. }
  263. .scan-icon {
  264. width: 36rpx;
  265. height: 36rpx;
  266. background-color: #fff;
  267. border-radius: 50%;
  268. display: flex;
  269. align-items: center;
  270. justify-content: center;
  271. image {
  272. width: 24rpx;
  273. height: 24rpx;
  274. }
  275. }
  276. }
  277. .type-box {
  278. .type-item {
  279. width: 50%;
  280. height: 88rpx;
  281. display: flex;
  282. align-items: center;
  283. justify-content: center;
  284. .type-val {
  285. color: #000;
  286. font-family: "PingFang SC";
  287. font-size: 28rpx;
  288. font-weight: 400;
  289. margin-right: 10rpx;
  290. }
  291. }
  292. }
  293. .task-cont {
  294. padding: 0 24rpx;
  295. }
  296. }
  297. }
  298. </style>