index.vue 6.6 KB

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