index.vue 13 KB

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