index.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  1. <template>
  2. <view class="picking-task-page">
  3. <u-navbar
  4. height="40px"
  5. title="采购入库"
  6. bgColor="#F0F6FB"
  7. autoBack
  8. placeholder
  9. >
  10. <view class="u-nav-slot depot-label" slot="right">
  11. <view class="name">{{ curDepotName }}</view>
  12. </view>
  13. </u-navbar>
  14. <view class="container_main">
  15. <u-sticky :offsetTop="offsetTop" bgColor="#F0F6FB">
  16. <view class="search-box">
  17. <u-search
  18. placeholder="请输入单据编号"
  19. bgColor="#fff"
  20. shape="square"
  21. v-model="params.number"
  22. :showAction="false"
  23. @search="searchClick"
  24. @clear="searchClick"
  25. ></u-search>
  26. <view class="flex_box" @click="scanCode">
  27. <view class="scan-text">扫描单据二维码</view>
  28. <view class="scan-icon">
  29. <image src="@/static/image/scan-icon.png" mode=""></image>
  30. </view>
  31. </view>
  32. </view>
  33. <view class="type-box flex_box">
  34. <view class="type-item" @click="tabClick(1)">
  35. <view class="type-val">{{ type1 }}</view>
  36. <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
  37. </view>
  38. <view class="type-item" @click="tabClick(2)">
  39. <view class="type-val">{{ type2 }}</view>
  40. <u-icon name="arrow-down-fill" color="#999999" size="12"></u-icon>
  41. </view>
  42. </view>
  43. </u-sticky>
  44. <view class="task-cont">
  45. <block v-for="(item, i) in taskList" :key="`${item.id}-${item.status}`">
  46. <task-item
  47. :item="item"
  48. @toStorage="toStorage"
  49. @toDetail="toDetail"
  50. type="caigou"
  51. ></task-item>
  52. </block>
  53. <u-loadmore v-if="taskList.length > 0" :status="status" />
  54. <u-empty
  55. mode="data"
  56. text="暂无内容"
  57. marginTop="60"
  58. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  59. v-if="taskList.length == 0"
  60. ></u-empty>
  61. </view>
  62. </view>
  63. <!-- 状态 -->
  64. <u-picker
  65. :show="statusShow"
  66. keyName="label"
  67. :defaultIndex="defaultIndex2"
  68. :columns="statusColumns"
  69. @confirm="statusConfirm"
  70. @cancel="statusShow = false"
  71. ></u-picker>
  72. <!-- 月份 -->
  73. <u-picker
  74. :show="dateShow"
  75. :defaultIndex="defaultIndex3"
  76. :columns="dateColumns"
  77. @confirm="dateConfirm"
  78. @cancel="dateShow = false"
  79. ></u-picker>
  80. </view>
  81. </template>
  82. <script>
  83. import taskItem from "@/components/task-item/task-item.vue";
  84. import {
  85. purchaseInventory,
  86. orderStartHandle,
  87. } from "@/common/request/apis/purchase";
  88. import { mapGetters } from "vuex";
  89. export default {
  90. components: {
  91. taskItem,
  92. },
  93. data() {
  94. return {
  95. offsetTop: 0,
  96. type1: "全部",
  97. type2: "月份",
  98. statusShow: false,
  99. dateShow: false,
  100. statusColumns: [
  101. [
  102. {
  103. label: "全部",
  104. id: "",
  105. },
  106. {
  107. label: "待入库",
  108. id: "1",
  109. },
  110. {
  111. label: "入库中",
  112. id: "4",
  113. },
  114. {
  115. label: "已入库",
  116. id: "2",
  117. },
  118. ],
  119. ],
  120. dateColumns: [
  121. [
  122. "全年",
  123. "一月",
  124. "二月",
  125. "三月",
  126. "四月",
  127. "五月",
  128. "六月",
  129. "七月",
  130. "八月",
  131. "九月",
  132. "十月",
  133. "十一月",
  134. "十二月",
  135. ],
  136. ],
  137. defaultIndex2: [],
  138. defaultIndex3: [],
  139. taskList: [],
  140. params: {
  141. beginTime: "",
  142. endTime: "",
  143. number: "",
  144. status: "",
  145. currentPage: 1,
  146. pageSize: 10,
  147. },
  148. status: "loadmore",
  149. lastPage: 1,
  150. };
  151. },
  152. computed: {
  153. ...mapGetters(["depotInfo"]),
  154. curDepotId() {
  155. return this.depotInfo ? this.depotInfo.id : "";
  156. },
  157. curDepotName() {
  158. return this.depotInfo ? this.depotInfo.depotName : "";
  159. },
  160. },
  161. onLoad() {
  162. let systemInfo = uni.getSystemInfoSync();
  163. let statusBarHeight = systemInfo.statusBarHeight;
  164. this.offsetTop = statusBarHeight + 40;
  165. this.init();
  166. },
  167. onShow() {
  168. uni.$on("scanFinish", (data) => {
  169. this.params.number = data;
  170. this.init();
  171. });
  172. if (uni.getStorageSync("orderRefresh")) {
  173. this.init();
  174. uni.removeStorageSync("orderRefresh");
  175. }
  176. },
  177. onHide() {
  178. uni.$off("scanFinish");
  179. },
  180. onUnload() {
  181. uni.$off("scanFinish");
  182. },
  183. onReachBottom() {
  184. if (this.params.currentPage < this.lastPage) {
  185. this.params.currentPage++;
  186. this.getPurchaseInventory();
  187. }
  188. },
  189. methods: {
  190. scanCode() {
  191. this.$scan.scanCode();
  192. },
  193. init() {
  194. uni.showLoading();
  195. this.params.currentPage = 1;
  196. this.taskList = [];
  197. this.getPurchaseInventory();
  198. },
  199. searchClick() {
  200. this.init();
  201. },
  202. // 点击操作
  203. toOrderStartHandle(id, status) {
  204. orderStartHandle(id).then((res) => {
  205. if (res.code == 200) {
  206. uni.navigateTo({
  207. url: `/pages/purchase/put-storage?id=${id}&status=${status}`,
  208. });
  209. }
  210. });
  211. },
  212. tabClick(type) {
  213. switch (type) {
  214. case 1:
  215. this.statusShow = true;
  216. break;
  217. case 2:
  218. this.dateShow = true;
  219. break;
  220. default:
  221. break;
  222. }
  223. },
  224. getPurchaseInventory() {
  225. console.log("getPurchaseInventory======", this.params);
  226. purchaseInventory({ ...this.params, depotId: this.curDepotId })
  227. .then((res) => {
  228. if (res.code == 200) {
  229. this.status = "loading";
  230. this.lastPage = Math.ceil(
  231. (res.data.total * 1) / this.params.pageSize
  232. );
  233. if (this.params.currentPage < this.lastPage) {
  234. this.status = "loadmore";
  235. } else {
  236. this.status = "nomore";
  237. }
  238. this.taskList = [...this.taskList, ...res.data.rows];
  239. console.log("this.taskList=======", this.taskList);
  240. }
  241. uni.hideLoading();
  242. })
  243. .catch((err) => {
  244. uni.hideLoading();
  245. });
  246. },
  247. statusConfirm(val) {
  248. this.type1 = val.value[0].label;
  249. this.params.status = val.value[0].id;
  250. this.statusShow = false;
  251. this.init();
  252. },
  253. dateConfirm(val) {
  254. this.type2 = val.value[0];
  255. this.dateShow = false;
  256. let month = val.indexs[0];
  257. this.getLastDayOfMonth(month);
  258. this.init();
  259. },
  260. // 获取开始时间、结束时间
  261. getLastDayOfMonth(month) {
  262. let year = new Date().getFullYear();
  263. if (month != 0) {
  264. let monthStart = new Date(year, month, 0).getDate();
  265. this.params.beginTime = `${year}-${month}-01`;
  266. this.params.endTime = `${year}-${month}-${monthStart}`;
  267. } else {
  268. this.params.beginTime = "";
  269. this.params.endTime = "";
  270. }
  271. },
  272. // 入库
  273. toStorage(val) {
  274. this.toOrderStartHandle(val.id, val.status);
  275. },
  276. toDetail(val) {
  277. uni.navigateTo({
  278. url: `/pages/purchase/detail?id=${val.id}&status=${val.status}`,
  279. });
  280. },
  281. },
  282. };
  283. </script>
  284. <style lang="scss" scoped>
  285. .picking-task-page {
  286. min-height: 100vh;
  287. background: #f0f6fb;
  288. .container_main {
  289. .search-box {
  290. display: flex;
  291. align-items: center;
  292. padding: 0 32rpx;
  293. .scan-text {
  294. color: #333;
  295. font-family: "PingFang SC";
  296. font-size: 24rpx;
  297. font-weight: 400;
  298. margin-right: 20rpx;
  299. margin-left: 30rpx;
  300. }
  301. .scan-icon {
  302. width: 36rpx;
  303. height: 36rpx;
  304. background-color: #fff;
  305. border-radius: 50%;
  306. display: flex;
  307. align-items: center;
  308. justify-content: center;
  309. image {
  310. width: 24rpx;
  311. height: 24rpx;
  312. }
  313. }
  314. }
  315. .type-box {
  316. .type-item {
  317. width: 50%;
  318. height: 88rpx;
  319. display: flex;
  320. align-items: center;
  321. justify-content: center;
  322. .type-val {
  323. color: #000;
  324. font-family: "PingFang SC";
  325. font-size: 28rpx;
  326. font-weight: 400;
  327. margin-right: 10rpx;
  328. }
  329. }
  330. }
  331. .task-cont {
  332. padding: 0 24rpx;
  333. }
  334. }
  335. }
  336. </style>