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" type="caigou"></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. import taskItem from '@/components/task-item/task-item.vue'
  49. import {purchaseInventory, orderStartHandle} from '@/common/request/apis/purchase'
  50. export default{
  51. components:{
  52. taskItem
  53. },
  54. data() {
  55. return {
  56. offsetTop:0,
  57. cangName:'鹏越中心仓',
  58. searchKey:'',
  59. type1:'全部',
  60. type2:'月份',
  61. stashShow:false,
  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. currentPage:1,
  96. pageSize:10
  97. },
  98. status:'loadmore',
  99. lastPage:1,
  100. }
  101. },
  102. onLoad() {
  103. let systemInfo = uni.getSystemInfoSync();
  104. let statusBarHeight = systemInfo.statusBarHeight;
  105. this.offsetTop = statusBarHeight + 40
  106. this.init()
  107. },
  108. onShow() {
  109. uni.$on('scanFinish',(data)=>{
  110. this.params.number = data
  111. this.init()
  112. })
  113. if(uni.getStorageSync('orderRefresh')) {
  114. this.init()
  115. uni.removeStorageSync('orderRefresh')
  116. }
  117. },
  118. onHide() {
  119. uni.$off('scanFinish')
  120. },
  121. onUnload() {
  122. uni.$off('scanFinish')
  123. },
  124. onReachBottom() {
  125. if(this.params.currentPage < this.lastPage) {
  126. this.params.currentPage ++
  127. this.getPurchaseInventory()
  128. }
  129. },
  130. methods:{
  131. scanCode() {
  132. this.$scan.scanCode()
  133. },
  134. init() {
  135. uni.showLoading()
  136. this.params.currentPage = 1
  137. this.taskList = []
  138. this.getPurchaseInventory()
  139. },
  140. searchClick() {
  141. this.init()
  142. },
  143. // 点击操作
  144. toOrderStartHandle(id) {
  145. orderStartHandle(id)
  146. .then(res=>{
  147. if(res.code == 200) {
  148. uni.navigateTo({
  149. url:`/pages/purchase/put-storage?id=${id}`
  150. })
  151. }
  152. })
  153. },
  154. tabClick(type) {
  155. if(type == 1) {
  156. this.defaultIndex = this.getDefaultIndex(this.type1,this.statusColumns)
  157. this.statusShow = true
  158. }else {
  159. this.defaultIndex = this.getDefaultIndex(this.type2,this.dateColumns)
  160. this.dateShow = true
  161. }
  162. },
  163. getPurchaseInventory() {
  164. purchaseInventory(this.params)
  165. .then(res=>{
  166. if(res.code == 200) {
  167. this.status = 'loading';
  168. this.lastPage = Math.ceil(res.data.total * 1 / this.params.pageSize)
  169. if(this.params.currentPage < this.lastPage) {
  170. this.status = 'loadmore'
  171. }else {
  172. this.status = 'nomore'
  173. }
  174. this.taskList =[...this.taskList,...res.data.rows];
  175. }
  176. uni.hideLoading()
  177. })
  178. .catch(err=>{
  179. uni.hideLoading()
  180. })
  181. },
  182. stashClick() {
  183. this.defaultIndex = this.getDefaultIndex(this.cangName,this.stashColumns)
  184. this.stashShow = true
  185. },
  186. pickerConfirm(val) {
  187. this.cangName = val.value[0]
  188. this.stashShow = false
  189. },
  190. statusConfirm(val) {
  191. this.type1 = val.value[0].name
  192. this.params.status = val.value[0].id
  193. this.statusShow = false
  194. this.init()
  195. },
  196. dateConfirm(val) {
  197. this.type2 = val.value[0]
  198. this.dateShow = false
  199. let month = val.indexs[0]
  200. this.getLastDayOfMonth(month)
  201. this.init()
  202. },
  203. // 获取开始时间、结束时间
  204. getLastDayOfMonth(month) {
  205. let year = new Date().getFullYear()
  206. if(month !=0) {
  207. let monthStart = new Date(year, month, 0).getDate();
  208. this.params.beginTime = `${year}-${month}-01`
  209. this.params.endTime = `${year}-${month}-${monthStart}`
  210. }else {
  211. this.params.beginTime = ''
  212. this.params.endTime = ''
  213. }
  214. },
  215. // 获取picker默认index
  216. getDefaultIndex(val,list) {
  217. let arr = []
  218. let index = list[0].findIndex(item=>item == val)
  219. arr = [index]
  220. return arr
  221. },
  222. // 入库
  223. toStorage(val) {
  224. this.toOrderStartHandle(val.id)
  225. },
  226. toDetail(val) {
  227. uni.navigateTo({
  228. url:`/pages/purchase/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>