index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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" text="暂无内容" marginTop="60" icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png" v-if="taskList.length == 0"></u-empty>
  37. </view>
  38. </view>
  39. <!-- 中心仓弹窗 -->
  40. <u-picker :show="stashShow" keyName="label" :defaultIndex="defaultIndex" :columns="stashColumns" @confirm="pickerConfirm" @cancel="stashShow= false"></u-picker>
  41. <!-- 状态 -->
  42. <u-picker :show="statusShow" keyName="label" :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, depotSpinnerList} 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. statusColumns:[
  67. [{
  68. label:'全部',
  69. id:''
  70. },{
  71. label:'待入库',
  72. id:'1'
  73. },{
  74. label:'入库中',
  75. id:'4'
  76. },{
  77. label:'已入库',
  78. id:'2'
  79. }]
  80. ],
  81. dateColumns:[
  82. ['全年','一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
  83. ],
  84. defaultIndex:[],
  85. defaultIndex2:[],
  86. defaultIndex3:[],
  87. taskList:[],
  88. params:{
  89. beginTime:'',
  90. endTime:'',
  91. number:'',
  92. status:'',
  93. currentPage:1,
  94. pageSize:10
  95. },
  96. status:'loadmore',
  97. lastPage:1,
  98. }
  99. },
  100. onLoad() {
  101. let systemInfo = uni.getSystemInfoSync();
  102. let statusBarHeight = systemInfo.statusBarHeight;
  103. this.offsetTop = statusBarHeight + 40
  104. this.init()
  105. this.getDepotSpinnerList()
  106. },
  107. onShow() {
  108. uni.$on('scanFinish',(data)=>{
  109. this.params.number = data
  110. this.init()
  111. })
  112. if(uni.getStorageSync('orderRefresh')) {
  113. this.init()
  114. uni.removeStorageSync('orderRefresh')
  115. }
  116. },
  117. onHide() {
  118. uni.$off('scanFinish')
  119. },
  120. onUnload() {
  121. uni.$off('scanFinish')
  122. },
  123. onReachBottom() {
  124. if(this.params.currentPage < this.lastPage) {
  125. this.params.currentPage ++
  126. this.getPurchaseInventory()
  127. }
  128. },
  129. methods:{
  130. getDepotSpinnerList() {
  131. depotSpinnerList()
  132. .then(res=>{
  133. if(res.code == 200) {
  134. this.stashColumns = [res.data]
  135. this.cangName = res.data[0].label
  136. this.$store.commit('setcangName', this.cangName)
  137. }
  138. })
  139. },
  140. scanCode() {
  141. this.$scan.scanCode()
  142. },
  143. init() {
  144. uni.showLoading()
  145. this.params.currentPage = 1
  146. this.taskList = []
  147. this.getPurchaseInventory()
  148. },
  149. searchClick() {
  150. this.init()
  151. },
  152. // 点击操作
  153. toOrderStartHandle(id) {
  154. orderStartHandle(id)
  155. .then(res=>{
  156. if(res.code == 200) {
  157. uni.navigateTo({
  158. url:`/pages/purchase/put-storage?id=${id}`
  159. })
  160. }
  161. })
  162. },
  163. tabClick(type) {
  164. if(type == 1) {
  165. this.defaultIndex = this.getDefaultIndex(this.type1,this.statusColumns)
  166. this.statusShow = true
  167. }else {
  168. this.defaultIndex = this.getDefaultIndex(this.type2,this.dateColumns)
  169. this.dateShow = true
  170. }
  171. },
  172. getPurchaseInventory() {
  173. purchaseInventory(this.params)
  174. .then(res=>{
  175. if(res.code == 200) {
  176. this.status = 'loading';
  177. this.lastPage = Math.ceil(res.data.total * 1 / this.params.pageSize)
  178. if(this.params.currentPage < this.lastPage) {
  179. this.status = 'loadmore'
  180. }else {
  181. this.status = 'nomore'
  182. }
  183. this.taskList =[...this.taskList,...res.data.rows];
  184. }
  185. uni.hideLoading()
  186. })
  187. .catch(err=>{
  188. uni.hideLoading()
  189. })
  190. },
  191. stashClick() {
  192. this.defaultIndex = this.getDefaultIndex(this.cangName,this.stashColumns)
  193. this.stashShow = true
  194. },
  195. pickerConfirm(val) {
  196. this.cangName = val.value[0].label
  197. this.stashShow = false
  198. this.$store.commit('setcangName', this.cangName)
  199. },
  200. statusConfirm(val) {
  201. this.type1 = val.value[0].label
  202. this.params.status = val.value[0].id
  203. this.statusShow = false
  204. this.init()
  205. },
  206. dateConfirm(val) {
  207. this.type2 = val.value[0]
  208. this.dateShow = false
  209. let month = val.indexs[0]
  210. this.getLastDayOfMonth(month)
  211. this.init()
  212. },
  213. // 获取开始时间、结束时间
  214. getLastDayOfMonth(month) {
  215. let year = new Date().getFullYear()
  216. if(month !=0) {
  217. let monthStart = new Date(year, month, 0).getDate();
  218. this.params.beginTime = `${year}-${month}-01`
  219. this.params.endTime = `${year}-${month}-${monthStart}`
  220. }else {
  221. this.params.beginTime = ''
  222. this.params.endTime = ''
  223. }
  224. },
  225. // 获取picker默认index
  226. getDefaultIndex(val,list) {
  227. let arr = []
  228. let index = list[0].findIndex(item=>item == val)
  229. arr = [index]
  230. return arr
  231. },
  232. // 入库
  233. toStorage(val) {
  234. this.toOrderStartHandle(val.id)
  235. },
  236. toDetail(val) {
  237. uni.navigateTo({
  238. url:`/pages/purchase/detail?id=${val.id}`
  239. })
  240. }
  241. }
  242. }
  243. </script>
  244. <style lang="scss" scoped>
  245. .btn-right {
  246. display: flex;
  247. align-items: center;
  248. .cang-name {
  249. color: #0256FF;
  250. text-align: center;
  251. font-family: "PingFang SC";
  252. font-size: 28rpx;
  253. font-weight: 600;
  254. margin-right: 10rpx;
  255. }
  256. }
  257. .picking-task-page {
  258. min-height: 100vh;
  259. background: #F0F6FB;
  260. .container_main {
  261. .search-box {
  262. display: flex;
  263. align-items: center;
  264. padding: 0 32rpx;
  265. .scan-text {
  266. color: #333;
  267. font-family: "PingFang SC";
  268. font-size: 24rpx;
  269. font-weight: 400;
  270. margin-right: 20rpx;
  271. margin-left: 30rpx;
  272. }
  273. .scan-icon {
  274. width: 36rpx;
  275. height: 36rpx;
  276. background-color: #fff;
  277. border-radius: 50%;
  278. display: flex;
  279. align-items: center;
  280. justify-content: center;
  281. image {
  282. width: 24rpx;
  283. height: 24rpx;
  284. }
  285. }
  286. }
  287. .type-box {
  288. .type-item {
  289. width: 50%;
  290. height: 88rpx;
  291. display: flex;
  292. align-items: center;
  293. justify-content: center;
  294. .type-val {
  295. color: #000;
  296. font-family: "PingFang SC";
  297. font-size: 28rpx;
  298. font-weight: 400;
  299. margin-right: 10rpx;
  300. }
  301. }
  302. }
  303. .task-cont {
  304. padding: 0 24rpx;
  305. }
  306. }
  307. }
  308. </style>