index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519
  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-card
  47. :key="`${item.id}-${item.status}`"
  48. :columns="taskColumns"
  49. :formData="item"
  50. @handleClickField="handleClickField"
  51. >
  52. <!-- 状态 -->
  53. <view slot="rightTop">
  54. <u-tag
  55. v-if="item.status == 1"
  56. text="待入库"
  57. plain
  58. borderColor="rgba(255, 59, 29, 0.2)"
  59. color="#ff3b1d"
  60. bgColor="rgba(255, 59, 29, 0.2)"
  61. ></u-tag>
  62. <u-tag
  63. v-if="item.status == 6"
  64. text="待复核"
  65. plain
  66. borderColor="rgba(255, 59, 29, 0.2)"
  67. color="#ff3b1d"
  68. bgColor="rgba(255, 59, 29, 0.2)"
  69. ></u-tag>
  70. <u-tag
  71. v-if="item.status == 7"
  72. text="复核驳回"
  73. plain
  74. borderColor="rgba(255, 59, 29, 0.2)"
  75. color="#ff3b1d"
  76. bgColor="rgba(255, 59, 29, 0.2)"
  77. ></u-tag>
  78. <u-tag
  79. v-if="item.status == 3"
  80. text="部分入库"
  81. plain
  82. borderColor="rgba(0, 185, 123, 0.2)"
  83. color="#00b97b"
  84. bgColor="rgba(0, 185, 123, 0.2)"
  85. ></u-tag>
  86. <u-tag
  87. v-if="item.status == 2"
  88. text="已入库"
  89. plain
  90. borderColor="rgba(0, 185, 123, 0.2)"
  91. color="#00b97b"
  92. bgColor="rgba(0, 185, 123, 0.2)"
  93. ></u-tag>
  94. <u-tag
  95. v-if="item.status == 4"
  96. text="入库中"
  97. plain
  98. borderColor="rgba(245, 151, 1, 0.2)"
  99. color="#f57701"
  100. bgColor="rgba(245, 151, 1, 0.2)"
  101. ></u-tag>
  102. </view>
  103. <!-- 操作栏 -->
  104. <view slot="action" class="action-box">
  105. <view class="action-left-box" v-if="item.status == 7"
  106. >驳回原因:{{ item.reject }}</view
  107. >
  108. <view class="task-bottom">
  109. <view
  110. class="btn btn-1"
  111. @click="toStorage(item)"
  112. v-if="
  113. item.status == 1 || item.status == 4 || item.status == 7
  114. "
  115. >{{ item.status == 7 ? "重新入库" : "去入库" }}</view
  116. >
  117. <view class="btn btn-2" @click="toDetail(item)" v-else
  118. >详情</view
  119. >
  120. </view>
  121. </view>
  122. </task-card>
  123. </block>
  124. <u-loadmore v-if="taskList.length > 0" :status="status" />
  125. <u-empty
  126. mode="data"
  127. text="暂无内容"
  128. marginTop="60"
  129. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  130. v-if="taskList.length == 0"
  131. ></u-empty>
  132. </view>
  133. </view>
  134. <!-- 状态 -->
  135. <u-picker
  136. :show="statusShow"
  137. keyName="label"
  138. :defaultIndex="defaultIndex2"
  139. :columns="statusColumns"
  140. @confirm="statusConfirm"
  141. @cancel="statusShow = false"
  142. ></u-picker>
  143. <!-- 月份 -->
  144. <u-picker
  145. :show="dateShow"
  146. :defaultIndex="defaultIndex3"
  147. :columns="dateColumns"
  148. @confirm="dateConfirm"
  149. @cancel="dateShow = false"
  150. ></u-picker>
  151. </view>
  152. </template>
  153. <script>
  154. import taskCard from "@/components/task-card/task-card.vue";
  155. import {
  156. purchaseInventory,
  157. orderStartHandle,
  158. } from "@/common/request/apis/purchase";
  159. import { mapGetters } from "vuex";
  160. export default {
  161. components: {
  162. taskCard,
  163. },
  164. data() {
  165. return {
  166. offsetTop: 0,
  167. type1: "全部",
  168. type2: "月份",
  169. statusShow: false,
  170. dateShow: false,
  171. statusColumns: [
  172. [
  173. {
  174. label: "全部",
  175. id: "",
  176. },
  177. {
  178. label: "待入库",
  179. id: "1",
  180. },
  181. {
  182. label: "待复核",
  183. id: "6",
  184. },
  185. {
  186. label: "复核驳回",
  187. id: "7",
  188. },
  189. {
  190. label: "入库中",
  191. id: "4",
  192. },
  193. {
  194. label: "部分入库",
  195. id: "3",
  196. },
  197. {
  198. label: "已入库",
  199. id: "2",
  200. },
  201. ],
  202. ],
  203. dateColumns: [
  204. [
  205. "全年",
  206. "一月",
  207. "二月",
  208. "三月",
  209. "四月",
  210. "五月",
  211. "六月",
  212. "七月",
  213. "八月",
  214. "九月",
  215. "十月",
  216. "十一月",
  217. "十二月",
  218. ],
  219. ],
  220. taskColumns: [
  221. {
  222. title: "单据编号",
  223. key: "number",
  224. titleStyle: {
  225. color: "#333",
  226. fontSize: "28rpx",
  227. fontWeight: 500,
  228. },
  229. valueStyle: {
  230. color: "#333",
  231. fontSize: "28rpx",
  232. fontWeight: 500,
  233. },
  234. },
  235. {
  236. title: "供应商",
  237. key: "supplierName",
  238. },
  239. {
  240. title: "单据日期",
  241. key: "createTime",
  242. },
  243. {
  244. title: "货物总数",
  245. key: "goodsQuantity",
  246. span: 12,
  247. valueStyle: {
  248. color: "#0256ff",
  249. },
  250. },
  251. {
  252. title: "货物种类",
  253. key: "goodsTypeCount",
  254. span: 12,
  255. valueStyle: {
  256. color: "#0256ff",
  257. },
  258. },
  259. ],
  260. defaultIndex2: [],
  261. defaultIndex3: [],
  262. taskList: [],
  263. params: {
  264. beginTime: "",
  265. endTime: "",
  266. number: "",
  267. status: "",
  268. currentPage: 1,
  269. pageSize: 10,
  270. },
  271. status: "loadmore",
  272. lastPage: 1,
  273. };
  274. },
  275. computed: {
  276. ...mapGetters(["depotInfo"]),
  277. curDepotId() {
  278. return this.depotInfo ? this.depotInfo.id : "";
  279. },
  280. curDepotName() {
  281. return this.depotInfo ? this.depotInfo.depotName : "";
  282. },
  283. },
  284. onLoad() {
  285. let systemInfo = uni.getSystemInfoSync();
  286. let statusBarHeight = systemInfo.statusBarHeight;
  287. this.offsetTop = statusBarHeight + 40;
  288. this.init();
  289. },
  290. onShow() {
  291. uni.$on("scanFinish", (data) => {
  292. this.params.number = data;
  293. this.init();
  294. });
  295. if (uni.getStorageSync("orderRefresh")) {
  296. this.init();
  297. uni.removeStorageSync("orderRefresh");
  298. }
  299. },
  300. onHide() {
  301. uni.$off("scanFinish");
  302. },
  303. onUnload() {
  304. uni.$off("scanFinish");
  305. },
  306. onReachBottom() {
  307. if (this.params.currentPage < this.lastPage) {
  308. this.params.currentPage++;
  309. this.getPurchaseInventory();
  310. }
  311. },
  312. methods: {
  313. scanCode() {
  314. this.$scan.scanCode();
  315. },
  316. init() {
  317. uni.showLoading();
  318. this.params.currentPage = 1;
  319. this.taskList = [];
  320. this.getPurchaseInventory();
  321. },
  322. searchClick() {
  323. this.init();
  324. },
  325. tabClick(type) {
  326. switch (type) {
  327. case 1:
  328. this.statusShow = true;
  329. break;
  330. case 2:
  331. this.dateShow = true;
  332. break;
  333. default:
  334. break;
  335. }
  336. },
  337. getPurchaseInventory() {
  338. console.log("getPurchaseInventory======", this.params);
  339. purchaseInventory({ ...this.params, depotId: this.curDepotId })
  340. .then((res) => {
  341. if (res.code == 200) {
  342. this.status = "loading";
  343. this.lastPage = Math.ceil(
  344. (res.data.total * 1) / this.params.pageSize
  345. );
  346. if (this.params.currentPage < this.lastPage) {
  347. this.status = "loadmore";
  348. } else {
  349. this.status = "nomore";
  350. }
  351. this.taskList = [...this.taskList, ...res.data.rows];
  352. console.log("this.taskList=======", this.taskList);
  353. }
  354. uni.hideLoading();
  355. })
  356. .catch((err) => {
  357. uni.hideLoading();
  358. });
  359. },
  360. statusConfirm(val) {
  361. this.type1 = val.value[0].label;
  362. this.params.status = val.value[0].id;
  363. this.statusShow = false;
  364. this.init();
  365. },
  366. dateConfirm(val) {
  367. this.type2 = val.value[0];
  368. this.dateShow = false;
  369. let month = val.indexs[0];
  370. this.getLastDayOfMonth(month);
  371. this.init();
  372. },
  373. // 获取开始时间、结束时间
  374. getLastDayOfMonth(month) {
  375. let year = new Date().getFullYear();
  376. if (month != 0) {
  377. let monthStart = new Date(year, month, 0).getDate();
  378. this.params.beginTime = `${year}-${month}-01`;
  379. this.params.endTime = `${year}-${month}-${monthStart}`;
  380. } else {
  381. this.params.beginTime = "";
  382. this.params.endTime = "";
  383. }
  384. },
  385. // 入库
  386. toStorage(val) {
  387. uni.setStorageSync("orderRefresh", true);
  388. orderStartHandle(val.id).then((res) => {
  389. if (res.code == 200) {
  390. uni.navigateTo({
  391. url: `/pages/purchase/put-storage?id=${val.id}`,
  392. });
  393. }
  394. });
  395. },
  396. toDetail(val) {
  397. uni.navigateTo({
  398. url: `/pages/purchase/detail?id=${val.id}`,
  399. });
  400. },
  401. handleClickField(key, itemData) {
  402. console.log("key===", key);
  403. console.log("itemData===", itemData);
  404. if (
  405. itemData.status == 1 ||
  406. itemData.status == 4 ||
  407. itemData.status == 7
  408. ) {
  409. this.toStorage(itemData);
  410. } else {
  411. this.toDetail(itemData);
  412. }
  413. },
  414. },
  415. };
  416. </script>
  417. <style lang="scss" scoped>
  418. .picking-task-page {
  419. min-height: 100vh;
  420. background: #f0f6fb;
  421. .container_main {
  422. .search-box {
  423. display: flex;
  424. align-items: center;
  425. padding: 0 32rpx;
  426. .scan-text {
  427. color: #333;
  428. font-family: "PingFang SC";
  429. font-size: 24rpx;
  430. font-weight: 400;
  431. margin-right: 20rpx;
  432. margin-left: 30rpx;
  433. }
  434. .scan-icon {
  435. width: 36rpx;
  436. height: 36rpx;
  437. background-color: #fff;
  438. border-radius: 50%;
  439. display: flex;
  440. align-items: center;
  441. justify-content: center;
  442. image {
  443. width: 24rpx;
  444. height: 24rpx;
  445. }
  446. }
  447. }
  448. .type-box {
  449. .type-item {
  450. width: 50%;
  451. height: 88rpx;
  452. display: flex;
  453. align-items: center;
  454. justify-content: center;
  455. .type-val {
  456. color: #000;
  457. font-family: "PingFang SC";
  458. font-size: 28rpx;
  459. font-weight: 400;
  460. margin-right: 10rpx;
  461. }
  462. }
  463. }
  464. .task-cont {
  465. padding: 0 24rpx;
  466. }
  467. }
  468. }
  469. .action-box {
  470. padding-bottom: 24rpx;
  471. height: 80rpx;
  472. box-sizing: border-box;
  473. display: flex;
  474. align-items: center;
  475. justify-content: flex-end;
  476. width: 100%;
  477. }
  478. .action-left-box {
  479. color: #ff3b1d;
  480. font-family: "PingFang SC";
  481. font-size: 28rpx;
  482. font-weight: 400;
  483. width: 400rpx;
  484. overflow: hidden;
  485. white-space: nowrap;
  486. text-overflow: ellipsis;
  487. }
  488. .task-bottom {
  489. flex: 1;
  490. display: inline-flex;
  491. align-items: center;
  492. justify-content: flex-end;
  493. .btn {
  494. width: 144rpx;
  495. height: 56rpx;
  496. border-radius: 8rpx;
  497. font-size: 28rpx;
  498. line-height: 56rpx;
  499. text-align: center;
  500. margin-left: 12rpx;
  501. font-family: "PingFang SC";
  502. }
  503. .btn-1 {
  504. background: #0256ff;
  505. color: #fff;
  506. }
  507. .btn-2 {
  508. border: 1px solid #0256ff;
  509. background: rgba(2, 86, 255, 0.2);
  510. color: #0256ff;
  511. }
  512. }
  513. </style>