index.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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="i">
  46. <task-item
  47. :item="item"
  48. @toStorage="toStorage"
  49. @toDetail="toDetail"
  50. :key="`${item.id}-${item.status}`"
  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.vue";
  84. import { saleOrder } from "@/common/request/apis/picking";
  85. import { orderStartHandle } from "@/common/request/apis/purchase";
  86. import { mapGetters } from "vuex";
  87. export default {
  88. components: {
  89. taskItem,
  90. },
  91. data() {
  92. return {
  93. offsetTop: 0,
  94. type1: "全部",
  95. type2: "月份",
  96. statusShow: false,
  97. dateShow: false,
  98. statusColumns: [
  99. [
  100. {
  101. label: "全部",
  102. id: "",
  103. },
  104. {
  105. label: "待拣货",
  106. id: "1",
  107. },
  108. {
  109. label: "拣货中",
  110. id: "4",
  111. },
  112. {
  113. label: "已拣货",
  114. id: "2",
  115. },
  116. ],
  117. ],
  118. dateColumns: [
  119. [
  120. "全年",
  121. "一月",
  122. "二月",
  123. "三月",
  124. "四月",
  125. "五月",
  126. "六月",
  127. "七月",
  128. "八月",
  129. "九月",
  130. "十月",
  131. "十一月",
  132. "十二月",
  133. ],
  134. ],
  135. defaultIndex2: [],
  136. defaultIndex3: [],
  137. taskList: [],
  138. params: {
  139. beginTime: "",
  140. endTime: "",
  141. number: "",
  142. status: "",
  143. currentPage: 1,
  144. pageSize: 10,
  145. },
  146. status: "loadmore",
  147. lastPage: 1,
  148. };
  149. },
  150. computed: {
  151. ...mapGetters(["depotInfo"]),
  152. curDepotId() {
  153. return this.depotInfo ? this.depotInfo.id : "";
  154. },
  155. curDepotName() {
  156. return this.depotInfo ? this.depotInfo.depotName : "";
  157. },
  158. },
  159. onLoad() {
  160. let systemInfo = uni.getSystemInfoSync();
  161. let statusBarHeight = systemInfo.statusBarHeight;
  162. this.offsetTop = statusBarHeight + 40;
  163. this.init();
  164. },
  165. onHide() {
  166. uni.$off("scanFinish");
  167. },
  168. onUnload() {
  169. uni.$off("scanFinish");
  170. },
  171. onReachBottom() {
  172. if (this.params.currentPage < this.lastPage) {
  173. this.params.currentPage++;
  174. this.getSaleOrder();
  175. }
  176. },
  177. onShow() {
  178. uni.$on("scanFinish", (data) => {
  179. this.params.number = data;
  180. this.init();
  181. });
  182. if (uni.getStorageSync("orderRefresh")) {
  183. this.init();
  184. uni.removeStorageSync("orderRefresh");
  185. }
  186. },
  187. methods: {
  188. scanCode() {
  189. this.$scan.scanCode();
  190. },
  191. init() {
  192. uni.showLoading();
  193. this.params.currentPage = 1;
  194. this.taskList = [];
  195. this.getSaleOrder();
  196. },
  197. searchClick() {
  198. this.init();
  199. },
  200. tabClick(type) {
  201. switch (type) {
  202. case 1:
  203. this.statusShow = true;
  204. break;
  205. case 2:
  206. this.dateShow = true;
  207. break;
  208. default:
  209. break;
  210. }
  211. },
  212. getSaleOrder() {
  213. saleOrder({ ...this.params, depotId: this.curDepotId })
  214. .then((res) => {
  215. if (res.code == 200) {
  216. this.status = "loading";
  217. this.lastPage = Math.ceil(
  218. (res.data.total * 1) / this.params.pageSize
  219. );
  220. if (this.params.currentPage < this.lastPage) {
  221. this.status = "loadmore";
  222. } else {
  223. this.status = "nomore";
  224. }
  225. this.taskList = [...this.taskList, ...res.data.rows];
  226. console.log("taskList========", res.data.rows);
  227. }
  228. uni.hideLoading();
  229. })
  230. .catch((err) => {
  231. uni.hideLoading();
  232. });
  233. },
  234. statusConfirm(val) {
  235. this.type1 = val.value[0].label;
  236. this.params.status = val.value[0].id;
  237. this.statusShow = false;
  238. this.init();
  239. },
  240. dateConfirm(val) {
  241. this.type2 = val.value[0];
  242. this.dateShow = false;
  243. let month = val.indexs[0];
  244. this.getLastDayOfMonth(month);
  245. this.init();
  246. },
  247. // 获取开始时间、结束时间
  248. getLastDayOfMonth(month) {
  249. let year = new Date().getFullYear();
  250. if (month != 0) {
  251. let monthStart = new Date(year, month, 0).getDate();
  252. this.params.beginTime = `${year}-${month}-01`;
  253. this.params.endTime = `${year}-${month}-${monthStart}`;
  254. } else {
  255. this.params.beginTime = "";
  256. this.params.endTime = "";
  257. }
  258. },
  259. // 获取picker默认index
  260. getDefaultIndex(val, list) {
  261. let arr = [];
  262. let index = list[0].findIndex((item) => item.label == val);
  263. arr = [index];
  264. return arr;
  265. },
  266. // 点击操作
  267. toOrderStartHandle(id) {
  268. orderStartHandle(id).then((res) => {
  269. if (res.code == 200) {
  270. uni.navigateTo({
  271. url: `/pages/picking-task/delivery?id=${id}`,
  272. });
  273. }
  274. });
  275. },
  276. // 出库
  277. toStorage(val) {
  278. this.toOrderStartHandle(val.id);
  279. },
  280. toDetail(val) {
  281. console.log(val, "val");
  282. uni.navigateTo({
  283. url: `/pages/picking-task/detail?id=${val.id}`,
  284. });
  285. },
  286. },
  287. };
  288. </script>
  289. <style lang="scss" scoped>
  290. .picking-task-page {
  291. min-height: 100vh;
  292. background: #f0f6fb;
  293. .container_main {
  294. .search-box {
  295. display: flex;
  296. align-items: center;
  297. padding: 0 32rpx;
  298. .scan-text {
  299. color: #333;
  300. font-family: "PingFang SC";
  301. font-size: 24rpx;
  302. font-weight: 400;
  303. margin-right: 20rpx;
  304. margin-left: 30rpx;
  305. }
  306. .scan-icon {
  307. width: 36rpx;
  308. height: 36rpx;
  309. background-color: #fff;
  310. border-radius: 50%;
  311. display: flex;
  312. align-items: center;
  313. justify-content: center;
  314. image {
  315. width: 24rpx;
  316. height: 24rpx;
  317. }
  318. }
  319. }
  320. .type-box {
  321. .type-item {
  322. width: 50%;
  323. height: 88rpx;
  324. display: flex;
  325. align-items: center;
  326. justify-content: center;
  327. .type-val {
  328. color: #000;
  329. font-family: "PingFang SC";
  330. font-size: 28rpx;
  331. font-weight: 400;
  332. margin-right: 10rpx;
  333. }
  334. }
  335. }
  336. .task-cont {
  337. padding: 0 24rpx;
  338. }
  339. }
  340. }
  341. </style>