index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="check-page">
  3. <u-navbar height="40px" title="盘点" bgColor="#fff" autoBack placeholder>
  4. <view class="u-nav-slot depot-label" slot="right" @click="stashClick">
  5. <view class="name">{{ curDepotName }}</view>
  6. </view>
  7. </u-navbar>
  8. <view class="container_main">
  9. <u-sticky :offsetTop="offsetTop" bgColor="#fff">
  10. <view class="search-box">
  11. <u-search
  12. placeholder="请输入单据编号或名称"
  13. shape="square"
  14. v-model="query.number"
  15. :showAction="false"
  16. :clearabled="true"
  17. @search="handleSearch"
  18. @clear="handleSearch"
  19. ></u-search>
  20. </view>
  21. <view class="type-box">
  22. <u-tabs
  23. :list="tabList"
  24. :inactiveStyle="{ color: '#000', fontSize: '28rpx' }"
  25. :activeStyle="{ color: '#000', fontSize: '28rpx' }"
  26. lineColor="#0256FF"
  27. lineWidth="66rpx"
  28. @click="tabClick"
  29. >
  30. </u-tabs>
  31. </view>
  32. </u-sticky>
  33. <view class="content-box">
  34. <view class="content-box-val">
  35. <check-item
  36. v-for="item in list"
  37. :key="`${item.id}-${item.taskStatus}`"
  38. :info="item"
  39. @btnClick="handleBtnClick"
  40. ></check-item>
  41. </view>
  42. <u-empty
  43. mode="data"
  44. text="暂无内容"
  45. marginTop="60"
  46. icon="https://xiangli-erp.oss-cn-hangzhou.aliyuncs.com/APP/no-notifcations.png"
  47. v-if="list.length == 0"
  48. ></u-empty>
  49. <!-- 加载更多 -->
  50. <u-loadmore
  51. v-if="list.length > 0"
  52. :status="loadStatus"
  53. @loadmore="onLoadMore"
  54. />
  55. </view>
  56. </view>
  57. <error-pop
  58. v-model="actionPop.errorShow"
  59. isCenter
  60. cancelBtnText="取消"
  61. confirmBtnText="确定"
  62. @close="actionPop.errorShow = false"
  63. @confirm="submit"
  64. :content="actionPop.errorText"
  65. ></error-pop>
  66. </view>
  67. </template>
  68. <script>
  69. import checkItem from "./components/check-item.vue";
  70. import errorPop from "@/components/error-pop/error-pop.vue";
  71. import {
  72. taskStocktakingList,
  73. startTask,
  74. taskComplete,
  75. taskStocktakingDetail,
  76. } from "@/common/request/apis/inventoryTask";
  77. import { taskStatusList } from "../inventory-task/utils/index.js";
  78. import { mapGetters } from "vuex";
  79. export default {
  80. components: {
  81. checkItem,
  82. errorPop,
  83. },
  84. data() {
  85. return {
  86. offsetTop: 0,
  87. tabList: taskStatusList,
  88. query: {
  89. number: "",
  90. status: "",
  91. },
  92. currentPage: 1,
  93. pageSize: 10,
  94. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  95. list: [],
  96. activeTaskId: null,
  97. actionPop: {
  98. // 警告提示弹框状态
  99. errorShow: false,
  100. submitActionFlag: false,
  101. errorText: "是否提交盘点?",
  102. },
  103. startTaskId: null,
  104. toStock: false, //是否跳转盘点
  105. // 中心仓
  106. cangName: "",
  107. };
  108. },
  109. computed: {
  110. ...mapGetters(["depotInfo"]),
  111. curDepotId() {
  112. return this.depotInfo ? this.depotInfo.id : "";
  113. },
  114. curDepotName() {
  115. return this.depotInfo ? this.depotInfo.depotName : "";
  116. },
  117. },
  118. onLoad() {
  119. let systemInfo = uni.getSystemInfoSync();
  120. let statusBarHeight = systemInfo.statusBarHeight;
  121. this.offsetTop = statusBarHeight + 40;
  122. this.loadData();
  123. },
  124. onShow() {
  125. if (this.startTaskId) {
  126. let index = this.list.findIndex((item) => item.id == this.startTaskId);
  127. this.list[index].taskStatus = 2;
  128. this.startTaskId = null;
  129. }
  130. },
  131. onPullDownRefresh() {
  132. // 下拉刷新
  133. this.onRefresh();
  134. },
  135. onReachBottom() {
  136. // 触底加载更多
  137. this.onLoadMore();
  138. },
  139. methods: {
  140. async onRefresh() {
  141. try {
  142. await this.loadData(true);
  143. } finally {
  144. uni.stopPullDownRefresh();
  145. }
  146. },
  147. async onLoadMore() {
  148. if (this.loadStatus !== "loadmore") return;
  149. this.loadStatus = "loading";
  150. try {
  151. await this.loadData();
  152. } catch (e) {
  153. this.loadStatus = "loadmore";
  154. }
  155. },
  156. async loadData(isRefresh = false) {
  157. if (isRefresh) {
  158. this.currentPage = 1;
  159. this.list = [];
  160. }
  161. try {
  162. this.loadStatus = "loading";
  163. const currentPage = this.currentPage;
  164. const pageSize = this.pageSize;
  165. const params = {
  166. currentPage,
  167. pageSize,
  168. ...this.query,
  169. depotId: this.curDepotId,
  170. };
  171. console.log("params=====", params);
  172. const res = await taskStocktakingList(params);
  173. const { rows, total } = res.data;
  174. this.list = [...this.list, ...rows];
  175. if (currentPage * pageSize < Number(total)) {
  176. this.currentPage++;
  177. this.loadStatus = "loadmore";
  178. } else {
  179. this.loadStatus = "nomore";
  180. }
  181. } catch (error) {}
  182. },
  183. tabClick({ index }) {
  184. this.query.status = this.tabList[index].value;
  185. this.loadData(true);
  186. },
  187. handleSearch(value) {
  188. this.loadData(true);
  189. },
  190. // 前往盘点任务详情
  191. handleBtnClick(data) {
  192. console.log(11111, data);
  193. // params.id--->任务id params.btnName--->按钮label
  194. const { btnName } = data;
  195. switch (btnName) {
  196. case "详情":
  197. uni.navigateTo({
  198. url: `/pages/inventory-task/taskDetail?id=${data.id}`,
  199. });
  200. break;
  201. case "去盘点":
  202. startTask(data.id).then((res) => {
  203. if (res.code === 200) {
  204. uni.navigateTo({
  205. url: `/pages/inventory-task/detail?id=${data.id}&pageType=1`,
  206. });
  207. this.startTaskId = data.id;
  208. } else {
  209. uni.$u.toast(res.data);
  210. }
  211. });
  212. break;
  213. case "去提交":
  214. taskStocktakingDetail(data.id).then((res) => {
  215. let { finishCount, materialCount } = res.data;
  216. const a = Number(finishCount || 0);
  217. const b = Number(materialCount || 0);
  218. this.activeTaskId = data.id;
  219. this.actionPop.errorShow = true;
  220. if (a === b) {
  221. // 进度100%
  222. this.actionPop.errorText = "是否提交盘点?";
  223. this.actionPop.submitActionFlag = true;
  224. } else {
  225. this.actionPop.errorText = "尚有货物未完成盘点,请先去盘点";
  226. this.actionPop.submitActionFlag = false;
  227. this.toStock = true;
  228. }
  229. });
  230. break;
  231. }
  232. },
  233. resetErrorPopData() {
  234. this.actionPop.errorShow = false;
  235. this.actionPop.submitActionFlag = false;
  236. this.actionPop.errorShow = "";
  237. },
  238. submit() {
  239. if (this.actionPop.submitActionFlag) {
  240. taskComplete(this.activeTaskId).then((res) => {
  241. this.resetErrorPopData();
  242. if (res.code === 200) {
  243. uni.$u.toast(res.msg);
  244. this.actionPop.errorShow = false;
  245. this.onRefresh();
  246. } else {
  247. uni.$u.toast(res.data);
  248. }
  249. });
  250. } else {
  251. this.resetErrorPopData();
  252. if (this.toStock) {
  253. this.toStock = false;
  254. this.actionPop.errorShow = false;
  255. uni.navigateTo({
  256. url: `/pages/inventory-task/detail?id=${this.activeTaskId}&pageType=1`,
  257. });
  258. }
  259. }
  260. },
  261. },
  262. };
  263. </script>
  264. <style lang="scss" scoped>
  265. .check-page {
  266. min-height: 100vh;
  267. background-color: #f0f6fb;
  268. .container_main {
  269. .search-box {
  270. background-color: rgba(191, 200, 219, 0.2);
  271. margin: 0 32rpx;
  272. display: flex;
  273. align-items: center;
  274. justify-content: space-between;
  275. border-radius: 8rpx;
  276. ::v-deep .u-search__content {
  277. background-color: transparent !important;
  278. .u-search__content__input {
  279. background-color: transparent !important;
  280. }
  281. }
  282. .scan-icon {
  283. width: 100rpx;
  284. height: 100%;
  285. image {
  286. width: 40rpx;
  287. height: 40rpx;
  288. }
  289. }
  290. }
  291. .content-box {
  292. padding: 24rpx;
  293. &-val {
  294. border-radius: 16rpx 16rpx 0 0;
  295. overflow: hidden;
  296. }
  297. }
  298. }
  299. }
  300. </style>