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