index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  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"></u-search>
  13. <view class="flex_box">
  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-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. import taskItem from '@/components/task-item/task-item.vue'
  48. import {purchaseInventory} from '@/common/request/apis/purchase'
  49. export default{
  50. components:{
  51. taskItem
  52. },
  53. data() {
  54. return {
  55. offsetTop:0,
  56. cangName:'鹏越中心仓',
  57. searchKey:'',
  58. type1:'全部',
  59. type2:'月份',
  60. stashShow:false,
  61. stashShow:false,
  62. statusShow:false,
  63. dateShow:false,
  64. stashColumns:[
  65. ['鹏越中心仓','美团中心仓']
  66. ],
  67. statusColumns:[
  68. [{
  69. name:'全部',
  70. id:''
  71. },{
  72. name:'待入库',
  73. id:'1'
  74. },{
  75. name:'入库中',
  76. id:'4'
  77. },{
  78. name:'已入库',
  79. id:'2'
  80. }]
  81. ],
  82. dateColumns:[
  83. ['全年','一月','二月','三月','四月','五月','六月','七月','八月','九月','十月','十一月','十二月']
  84. ],
  85. defaultIndex:[],
  86. defaultIndex2:[],
  87. defaultIndex3:[],
  88. taskList:[],
  89. params:{
  90. beginTime:'',
  91. endTime:'',
  92. number:'',
  93. status:'',
  94. pageNum:1,
  95. pageSize:10
  96. }
  97. }
  98. },
  99. onLoad() {
  100. let systemInfo = uni.getSystemInfoSync();
  101. let statusBarHeight = systemInfo.statusBarHeight;
  102. this.offsetTop = statusBarHeight + 40
  103. this.init()
  104. },
  105. methods:{
  106. init() {
  107. uni.showLoading()
  108. this.params.pageNum = 1
  109. this.getPurchaseInventory()
  110. },
  111. searchClick() {
  112. this.init()
  113. },
  114. tabClick(type) {
  115. if(type == 1) {
  116. this.defaultIndex = this.getDefaultIndex(this.type1,this.statusColumns)
  117. this.statusShow = true
  118. }else {
  119. this.defaultIndex = this.getDefaultIndex(this.type2,this.dateColumns)
  120. this.dateShow = true
  121. }
  122. },
  123. getPurchaseInventory() {
  124. purchaseInventory(this.params)
  125. .then(res=>{
  126. if(res.code == 200) {
  127. this.taskList = res.data.rows;
  128. }
  129. uni.hideLoading()
  130. })
  131. .catch(err=>{
  132. uni.hideLoading()
  133. })
  134. },
  135. stashClick() {
  136. this.defaultIndex = this.getDefaultIndex(this.cangName,this.stashColumns)
  137. this.stashShow = true
  138. },
  139. pickerConfirm(val) {
  140. this.cangName = val.value[0]
  141. this.stashShow = false
  142. },
  143. statusConfirm(val) {
  144. this.type1 = val.value[0].name
  145. this.params.status = val.value[0].id
  146. this.statusShow = false
  147. this.params.pageNum = 1
  148. this.getPurchaseInventory()
  149. },
  150. dateConfirm(val) {
  151. this.type2 = val.value[0]
  152. this.dateShow = false
  153. let month = val.indexs[0]
  154. this.getLastDayOfMonth(month)
  155. uni.showLoading()
  156. this.init()
  157. },
  158. // 获取开始时间、结束时间
  159. getLastDayOfMonth(month) {
  160. let year = new Date().getFullYear()
  161. if(month !=0) {
  162. let monthStart = new Date(year, month, 0).getDate();
  163. this.params.beginTime = `${year}-${month}-01`
  164. this.params.endTime = `${year}-${month}-${monthStart}`
  165. }else {
  166. this.params.beginTime = ''
  167. this.params.endTime = ''
  168. }
  169. },
  170. // 获取picker默认index
  171. getDefaultIndex(val,list) {
  172. let arr = []
  173. let index = list[0].findIndex(item=>item == val)
  174. arr = [index]
  175. return arr
  176. },
  177. // 入库
  178. toStorage(val) {
  179. uni.navigateTo({
  180. url:'/pages/purchase/put-storage'
  181. })
  182. },
  183. toDetail(val) {
  184. uni.navigateTo({
  185. url:`/pages/purchase/detail?id=${val.id}`
  186. })
  187. }
  188. }
  189. }
  190. </script>
  191. <style lang="scss" scoped>
  192. .btn-right {
  193. display: flex;
  194. align-items: center;
  195. .cang-name {
  196. color: #0256FF;
  197. text-align: center;
  198. font-family: "PingFang SC";
  199. font-size: 28rpx;
  200. font-weight: 600;
  201. margin-right: 10rpx;
  202. }
  203. }
  204. .picking-task-page {
  205. min-height: 100vh;
  206. background: #F0F6FB;
  207. .container_main {
  208. .search-box {
  209. display: flex;
  210. align-items: center;
  211. padding: 0 32rpx;
  212. .scan-text {
  213. color: #333;
  214. font-family: "PingFang SC";
  215. font-size: 24rpx;
  216. font-weight: 400;
  217. margin-right: 20rpx;
  218. margin-left: 30rpx;
  219. }
  220. .scan-icon {
  221. width: 36rpx;
  222. height: 36rpx;
  223. background-color: #fff;
  224. border-radius: 50%;
  225. display: flex;
  226. align-items: center;
  227. justify-content: center;
  228. image {
  229. width: 24rpx;
  230. height: 24rpx;
  231. }
  232. }
  233. }
  234. .type-box {
  235. .type-item {
  236. width: 50%;
  237. height: 88rpx;
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. .type-val {
  242. color: #000;
  243. font-family: "PingFang SC";
  244. font-size: 28rpx;
  245. font-weight: 400;
  246. margin-right: 10rpx;
  247. }
  248. }
  249. }
  250. .task-cont {
  251. padding: 0 24rpx;
  252. }
  253. }
  254. }
  255. </style>