index.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.taskList = []
  139. this.getSaleOrder()
  140. },
  141. searchClick() {
  142. this.init()
  143. },
  144. tabClick(type) {
  145. if(type == 1) {
  146. this.defaultIndex = this.getDefaultIndex(this.type1,this.statusColumns)
  147. this.statusShow = true
  148. }else {
  149. this.defaultIndex = this.getDefaultIndex(this.type2,this.dateColumns)
  150. this.dateShow = true
  151. }
  152. },
  153. getSaleOrder() {
  154. saleOrder(this.params)
  155. .then(res=>{
  156. if(res.code == 200) {
  157. this.status = 'loading';
  158. this.lastPage = Math.ceil(res.data.total * 1 / this.params.pageSize)
  159. if(this.params.currentPage < this.lastPage) {
  160. this.status = 'loadmore'
  161. }else {
  162. this.status = 'nomore'
  163. }
  164. this.taskList =[...this.taskList,...res.data.rows];
  165. }
  166. uni.hideLoading()
  167. })
  168. .catch(err=>{
  169. uni.hideLoading()
  170. })
  171. },
  172. stashClick() {
  173. this.defaultIndex = this.getDefaultIndex(this.cangName,this.stashColumns)
  174. this.stashShow = true
  175. },
  176. pickerConfirm(val) {
  177. this.cangName = val.value[0]
  178. this.stashShow = false
  179. },
  180. statusConfirm(val) {
  181. this.type1 = val.value[0].name
  182. this.params.status = val.value[0].id
  183. this.statusShow = false
  184. this.init()
  185. },
  186. dateConfirm(val) {
  187. this.type2 = val.value[0]
  188. this.dateShow = false
  189. let month = val.indexs[0]
  190. this.getLastDayOfMonth(month)
  191. this.init()
  192. },
  193. // 获取开始时间、结束时间
  194. getLastDayOfMonth(month) {
  195. let year = new Date().getFullYear()
  196. if(month !=0) {
  197. let monthStart = new Date(year, month, 0).getDate();
  198. this.params.beginTime = `${year}-${month}-01`
  199. this.params.endTime = `${year}-${month}-${monthStart}`
  200. }else {
  201. this.params.beginTime = ''
  202. this.params.endTime = ''
  203. }
  204. },
  205. // 获取picker默认index
  206. getDefaultIndex(val,list) {
  207. let arr = []
  208. let index = list[0].findIndex(item=>item.name == val)
  209. arr = [index]
  210. return arr
  211. },
  212. // 点击操作
  213. toOrderStartHandle(id) {
  214. orderStartHandle(id)
  215. .then(res=>{
  216. if(res.code == 200) {
  217. uni.navigateTo({
  218. url:`/pages/picking-task/delivery?id=${id}`
  219. })
  220. }
  221. })
  222. },
  223. // 出库
  224. toStorage(val) {
  225. this.toOrderStartHandle(val.id)
  226. },
  227. toDetail(val) {
  228. uni.navigateTo({
  229. url:`/pages/picking-task/detail?id=${val.id}`
  230. })
  231. }
  232. }
  233. }
  234. </script>
  235. <style lang="scss" scoped>
  236. .btn-right {
  237. display: flex;
  238. align-items: center;
  239. .cang-name {
  240. color: #0256FF;
  241. text-align: center;
  242. font-family: "PingFang SC";
  243. font-size: 28rpx;
  244. font-weight: 600;
  245. margin-right: 10rpx;
  246. }
  247. }
  248. .picking-task-page {
  249. min-height: 100vh;
  250. background: #F0F6FB;
  251. .container_main {
  252. .search-box {
  253. display: flex;
  254. align-items: center;
  255. padding: 0 32rpx;
  256. .scan-text {
  257. color: #333;
  258. font-family: "PingFang SC";
  259. font-size: 24rpx;
  260. font-weight: 400;
  261. margin-right: 20rpx;
  262. margin-left: 30rpx;
  263. }
  264. .scan-icon {
  265. width: 36rpx;
  266. height: 36rpx;
  267. background-color: #fff;
  268. border-radius: 50%;
  269. display: flex;
  270. align-items: center;
  271. justify-content: center;
  272. image {
  273. width: 24rpx;
  274. height: 24rpx;
  275. }
  276. }
  277. }
  278. .type-box {
  279. .type-item {
  280. width: 50%;
  281. height: 88rpx;
  282. display: flex;
  283. align-items: center;
  284. justify-content: center;
  285. .type-val {
  286. color: #000;
  287. font-family: "PingFang SC";
  288. font-size: 28rpx;
  289. font-weight: 400;
  290. margin-right: 10rpx;
  291. }
  292. }
  293. }
  294. .task-cont {
  295. padding: 0 24rpx;
  296. }
  297. }
  298. }
  299. </style>