index.vue 8.0 KB

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