index.vue 7.3 KB

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