detail.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <view class="inventory-detail">
  3. <!-- 导航栏 -->
  4. <u-navbar
  5. :title="inventoryInfo.taskName"
  6. :autoBack="true"
  7. fixed
  8. safe-area-inset-top
  9. placeholder
  10. >
  11. <template #right>
  12. <view class="nav-right">
  13. <u-icon name="search" size="20" color="#333"></u-icon>
  14. </view>
  15. </template>
  16. </u-navbar>
  17. <u-sticky bgColor="#F5F6F7" :offsetTop="offsetTop">
  18. <!-- 基本信息 吸顶 -->
  19. <view class="info-card">
  20. <view class="info-item page-title">
  21. {{ inventoryInfo.taskName }}
  22. </view>
  23. <view class="info-item-box">
  24. <view class="info-item">
  25. <text class="info-label">盘点单号:</text>
  26. <text class="info-value">{{ inventoryInfo.number }}</text>
  27. </view>
  28. <view class="info-item">
  29. <text class="info-label">盘点人:</text>
  30. <text class="info-value">{{ inventoryInfo.creatorName }}</text>
  31. </view>
  32. </view>
  33. <view class="progress-box">
  34. <view class="progress-label-box">
  35. <text class="progress-label"> 盘点进度 </text>
  36. <text class="progress-value"
  37. ><text class="finished-value">{{
  38. inventoryInfo.finishCount
  39. }}</text
  40. >/{{ inventoryInfo.materialCount }}</text
  41. >
  42. </view>
  43. <view class="progress-bar-wrap">
  44. <u-line-progress
  45. :percentage="getProgressPercentage"
  46. height="6"
  47. :show-text="false"
  48. activeColor="#4080FF"
  49. >
  50. </u-line-progress>
  51. </view>
  52. </view>
  53. </view>
  54. <!-- 筛选按钮 -->
  55. <view class="filter-wrap">
  56. <view class="filter-btn" @click="filterPopupVisible = true">
  57. <text>筛选</text>
  58. <image
  59. src="@/static/image/saixuan-icon.png"
  60. mode=""
  61. class="icon"
  62. ></image>
  63. </view>
  64. </view>
  65. </u-sticky>
  66. <!-- 商品列表 -->
  67. <view class="goods-list">
  68. <view class="goods-item" v-for="(item, index) in goodsList" :key="index">
  69. <view class="location-row">
  70. <view class="location-left">
  71. <text class="location-label">库位:</text>
  72. <text class="location-value">{{ item.position }}</text>
  73. <image
  74. src="@/static/image/bianji-icon.png"
  75. mode=""
  76. class="icon"
  77. @click="handlePositionEdit(item)"
  78. ></image>
  79. </view>
  80. <text class="category-text">{{ item.categoryName }}</text>
  81. </view>
  82. <view class="goods-content">
  83. <image
  84. class="goods-image"
  85. :src="item.image"
  86. mode="aspectFill"
  87. ></image>
  88. <view class="goods-info">
  89. <text class="goods-name u-line-2">{{ item.materialName }}</text>
  90. <view class="goods-field half-w">
  91. <text class="field-label">规格:</text>
  92. <text class="field-value">{{ item.standard }}</text>
  93. </view>
  94. <view class="goods-field half-w">
  95. <text class="field-label">盘点人:</text>
  96. <text class="field-value">{{ item.createName }}</text>
  97. </view>
  98. <view class="goods-field">
  99. <text class="field-label">盘点时间:</text>
  100. <text class="field-value">{{ item.operTime }}</text>
  101. </view>
  102. <view class="stock-row">
  103. <view class="stock-item">
  104. <text class="stock-label">系统库存</text>
  105. <text class="stock-value"
  106. >{{ item.inventory }}{{ item.commodityUnit }}</text
  107. >
  108. </view>
  109. <view class="stock-item">
  110. <text class="stock-label">已盘库存</text>
  111. <text
  112. class="stock-value"
  113. :class="
  114. Number(item.newInventory || 0) > 0
  115. ? 'stock-value-warning'
  116. : ''
  117. "
  118. >{{
  119. Number(item.newInventory || 0) === 0
  120. ? "未盘"
  121. : `${Number(item.newInventory || 0)}${item.commodityUnit}`
  122. }}</text
  123. >
  124. </view>
  125. </view>
  126. </view>
  127. </view>
  128. <view class="action-row">
  129. <u-button
  130. v-if="item.status === 1"
  131. type="primary"
  132. text="盘点"
  133. :customStyle="customBtnStyle"
  134. :disabled="!isEdit"
  135. @click="handleCheck(item)"
  136. class="action-btn"
  137. ></u-button>
  138. <u-button
  139. v-else
  140. type="primary"
  141. text="重新盘点"
  142. :disabled="!isEdit"
  143. :customStyle="customBtnStyle"
  144. @click="handleCheck(item)"
  145. class="action-btn"
  146. >
  147. </u-button>
  148. <u-tag
  149. text="盘亏"
  150. type="error"
  151. plain
  152. plainFill
  153. v-if="item.status === 3"
  154. >
  155. </u-tag>
  156. <u-tag
  157. text="盘盈"
  158. type="error"
  159. plain
  160. plainFill
  161. v-if="item.status === 4"
  162. >
  163. </u-tag>
  164. </view>
  165. </view>
  166. <!-- 加载更多 -->
  167. <u-loadmore :status="loadStatus" @loadmore="onLoadMore" />
  168. </view>
  169. <!-- 过滤条件弹框 -->
  170. <InventoryFilterPopup
  171. :show.sync="filterPopupVisible"
  172. :defaultValues="queryFilterValues"
  173. @confirm="handleFilterConfirm"
  174. :taskId="taskId"
  175. />
  176. <!-- 盘点数量 -->
  177. <actionNumPopup
  178. :show.sync="actionPop.showNumPop"
  179. :min-count="actionPop.minCount"
  180. :max-count="actionPop.maxCount"
  181. @confirm="handleConfirmNum"
  182. />
  183. <!-- 修改库位 -->
  184. <categoryPopup
  185. :show.sync="actionPop.showCategoryPop"
  186. :original-location="actionPop.originalLocation"
  187. @confirm="haandleComfirmLocation"
  188. />
  189. <error-pop
  190. v-model="actionPop.errorShow"
  191. isCenter
  192. cancelBtnText="取消"
  193. confirmBtnText="确定"
  194. @close="actionPop.errorShow = false"
  195. @confirm="submit"
  196. :content="actionPop.errorText"
  197. ></error-pop>
  198. </view>
  199. </template>
  200. <script>
  201. import InventoryFilterPopup from "./components/inventoryFilterPopup.vue";
  202. import actionNumPopup from "./components/actionNumPopup.vue";
  203. import categoryPopup from "./components/categoryPopup.vue";
  204. import errorPop from "@/components/error-pop/error-pop.vue";
  205. import { getGoodsInventoryStatusInfo } from "./utils/index.js";
  206. import {
  207. taskStocktakingDetail,
  208. taskStocktakingItemList,
  209. stocktaking,
  210. } from "@/common/request/apis/inventoryTask";
  211. import { mapGetters } from "vuex";
  212. export default {
  213. components: {
  214. InventoryFilterPopup,
  215. actionNumPopup,
  216. errorPop,
  217. categoryPopup,
  218. },
  219. data() {
  220. return {
  221. offsetTop: 0,
  222. pageType: "1", // 1:去盘点,可操作 2:盘点详情
  223. taskId: "", //任务id
  224. customBtnStyle: {
  225. width: "144rpx",
  226. height: "56rpx",
  227. borderRadius: "28rpx",
  228. fontSize: "32rpx",
  229. borderRadius: "8rpx",
  230. },
  231. pageTitle: "2025年中心仓第三季度食品盘点",
  232. pageNum: 1,
  233. pageSize: 10,
  234. inventoryInfo: {
  235. code: "2024202244",
  236. operator: "刘双秀",
  237. progress: 105,
  238. total: 604,
  239. },
  240. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  241. goodsList: [],
  242. filterPopupVisible: false,
  243. queryFilterValues: {
  244. statusList: [], //盘点状态
  245. userIdList: [], // 盘点负责人id
  246. categoryIdList: [], // 类目
  247. positionList: [], // 库位
  248. },
  249. actionPop: {
  250. // 盘点数量弹框状态
  251. showNumPop: false,
  252. minCount: 0,
  253. maxCount: 9,
  254. activeGoodsItem: null,
  255. // 警告提示弹框状态
  256. errorShow: false,
  257. errorText: "是否提交盘点?",
  258. // 修改库位弹框状态
  259. showCategoryPop: false,
  260. originalLocation: "",
  261. },
  262. };
  263. },
  264. computed: {
  265. getProgressPercentage() {
  266. return (
  267. (this.inventoryInfo.finishCount / this.inventoryInfo.materialCount) *
  268. 100
  269. );
  270. },
  271. isEdit() {
  272. return this.pageType === "1";
  273. },
  274. ...mapGetters(["userInfo"]),
  275. },
  276. onLoad(opt) {
  277. let systemInfo = uni.getSystemInfoSync();
  278. let statusBarHeight = systemInfo.statusBarHeight;
  279. this.offsetTop = statusBarHeight + 40;
  280. console.log("222222", opt);
  281. this.pageType = opt.pageType;
  282. this.taskId = opt.id;
  283. this.loadData(opt.id);
  284. },
  285. onPullDownRefresh() {
  286. // 下拉刷新
  287. this.onRefresh();
  288. },
  289. onReachBottom() {
  290. // 触底加载更多
  291. this.onLoadMore();
  292. },
  293. methods: {
  294. getGoodsInventoryStatusInfo,
  295. async onRefresh() {
  296. try {
  297. await this.loadData(this.taskId, true);
  298. } finally {
  299. uni.stopPullDownRefresh();
  300. }
  301. },
  302. async onLoadMore() {
  303. if (this.loadStatus !== "loadmore") return;
  304. this.loadStatus = "loading";
  305. try {
  306. await this.loadData(this.taskId);
  307. } catch (e) {
  308. this.loadStatus = "loadmore";
  309. }
  310. },
  311. // 商品列表
  312. async getTaskStocktakingItemList(taskId) {
  313. try {
  314. const pageNum = this.pageNum;
  315. const pageSize = this.pageSize;
  316. const params = {
  317. taskId,
  318. ...this.queryFilterValues,
  319. };
  320. const res = await taskStocktakingItemList(params);
  321. const { total, rows } = res.data;
  322. this.goodsList = [...this.goodsList, ...rows];
  323. if (pageNum * pageSize < Number(total)) {
  324. this.pageNum++;
  325. this.loadStatus = "loadmore";
  326. } else {
  327. this.loadStatus = "nomore";
  328. }
  329. console.log("taskStocktakingItemList======", res);
  330. } catch (error) {}
  331. },
  332. // 任务详情
  333. async getTaskStocktakingDetail(taskId) {
  334. try {
  335. const res = await taskStocktakingDetail(taskId);
  336. console.log("taskStocktakingDetail======", res);
  337. this.inventoryInfo = res.data;
  338. } catch (error) {}
  339. },
  340. resetData() {
  341. this.pageNum = 1;
  342. this.goodsList = [];
  343. },
  344. async loadData(id, isRefresh = false) {
  345. if (isRefresh) {
  346. this.resetData();
  347. }
  348. try {
  349. this.getTaskStocktakingItemList(id);
  350. this.getTaskStocktakingDetail(id);
  351. } catch (error) {}
  352. },
  353. // 库位编辑
  354. handlePositionEdit(item) {
  355. this.actionPop.showCategoryPop = true;
  356. this.actionPop.activeGoodsItem = { ...item };
  357. this.actionPop.originalLocation = item.position;
  358. console.log("handlePositionEdit======", item);
  359. console.log("userInfo======", this.userInfo);
  360. },
  361. async haandleComfirmLocation(val) {
  362. console.log("haandleComfirmLocation======", val);
  363. const activeGoodsItem = this.actionPop.activeGoodsItem;
  364. try {
  365. const params = {
  366. id: activeGoodsItem.id,
  367. materialItemId: activeGoodsItem.materialItemId,
  368. newPosition: val,
  369. };
  370. const res = await stocktaking(params);
  371. console.log("res----------", res);
  372. if (res.code === 200) {
  373. uni.$u.toast(res.msg);
  374. this.onRefresh();
  375. this.actionPop.showCategoryPop = false;
  376. } else {
  377. uni.$u.toast(res.data);
  378. }
  379. } catch (error) {}
  380. },
  381. handleCheck(item) {
  382. this.actionPop.showNumPop = true;
  383. this.actionPop.activeGoodsItem = { ...item };
  384. this.actionPop.maxCount = item.inventory;
  385. },
  386. async handleConfirmNum(val) {
  387. console.log(111223, val);
  388. const activeGoodsItem = this.actionPop.activeGoodsItem;
  389. console.log("activeGoodsItem========", activeGoodsItem);
  390. try {
  391. const params = {
  392. id: activeGoodsItem.id,
  393. materialItemId: activeGoodsItem.materialItemId,
  394. newInventory: val,
  395. };
  396. const res = await stocktaking(params);
  397. console.log("res----------", res);
  398. if (res.code === 200) {
  399. uni.$u.toast(res.msg);
  400. this.onRefresh();
  401. } else {
  402. uni.$u.toast(res.data);
  403. }
  404. } catch (error) {}
  405. },
  406. // 盘点提交
  407. submit() {},
  408. handleFilterConfirm(values) {
  409. console.log("handleFilterConfirm======", values);
  410. this.queryFilterValues = values;
  411. this.filterPopupVisible = false;
  412. this.onRefresh();
  413. },
  414. },
  415. };
  416. </script>
  417. <style lang="scss">
  418. .inventory-detail {
  419. min-height: 100vh;
  420. background-color: #f0f6fb;
  421. padding-bottom: 40rpx;
  422. .nav-right {
  423. padding: 0 24rpx;
  424. }
  425. .info-card {
  426. background-color: #fff;
  427. padding: 16rpx 32rpx;
  428. .info-item-box {
  429. display: flex;
  430. justify-content: space-between;
  431. }
  432. .info-item {
  433. display: flex;
  434. font-size: 28rpx;
  435. margin-bottom: 10rpx;
  436. &.page-title {
  437. color: #333;
  438. }
  439. .info-label {
  440. color: #999;
  441. margin-right: 8rpx;
  442. }
  443. .info-value {
  444. flex: 1;
  445. color: #999;
  446. }
  447. }
  448. .progress-box {
  449. .progress-label-box {
  450. display: flex;
  451. justify-content: space-between;
  452. }
  453. .progress-label {
  454. font-size: 28rpx;
  455. color: #999;
  456. display: block;
  457. margin-bottom: 16rpx;
  458. }
  459. .progress-bar-wrap {
  460. margin-bottom: 16rpx;
  461. }
  462. .progress-value {
  463. color: #999;
  464. font-size: 24rpx;
  465. display: block;
  466. text-align: right;
  467. }
  468. .finished-value {
  469. color: #4080ff;
  470. }
  471. }
  472. }
  473. .filter-wrap {
  474. display: flex;
  475. justify-content: flex-end;
  476. padding: 20rpx;
  477. .filter-btn {
  478. display: flex;
  479. align-items: center;
  480. border-radius: 8rpx;
  481. font-size: 24rpx;
  482. color: #333333;
  483. .icon {
  484. margin-left: 8rpx;
  485. width: 32rpx;
  486. height: 32rpx;
  487. }
  488. }
  489. }
  490. .goods-list {
  491. width: 710rpx;
  492. margin: 0 20rpx;
  493. border-radius: 16rpx;
  494. .goods-item {
  495. background-color: #fff;
  496. overflow: hidden;
  497. border-bottom: 1px solid #f5f6f7;
  498. .location-row {
  499. display: flex;
  500. align-items: center;
  501. padding: 24rpx 32rpx;
  502. gap: 40rpx;
  503. .location-left {
  504. display: flex;
  505. align-items: center;
  506. .location-label {
  507. font-size: 28rpx;
  508. color: #333;
  509. }
  510. .location-value {
  511. font-size: 28rpx;
  512. color: #4080ff;
  513. margin: 0 8rpx;
  514. }
  515. .icon {
  516. width: 32rpx;
  517. height: 32rpx;
  518. }
  519. }
  520. .category-text {
  521. font-size: 24rpx;
  522. color: #999;
  523. }
  524. }
  525. .goods-content {
  526. padding: 24rpx 32rpx;
  527. display: flex;
  528. .goods-image {
  529. width: 160rpx;
  530. flex-basis: 160rpx;
  531. height: 160rpx;
  532. border-radius: 8rpx;
  533. background-color: #f5f6f7;
  534. }
  535. .goods-info {
  536. display: flex;
  537. flex-wrap: wrap;
  538. flex: 1;
  539. margin-left: 24rpx;
  540. .half-w {
  541. width: 50%;
  542. }
  543. .goods-name {
  544. width: 100%;
  545. font-size: 28rpx;
  546. line-height: 1.4;
  547. color: #333;
  548. margin-bottom: 16rpx;
  549. }
  550. .goods-field {
  551. font-size: 24rpx;
  552. color: #666;
  553. margin-bottom: 16rpx;
  554. .field-label {
  555. color: #999;
  556. }
  557. .field-value {
  558. color: #666;
  559. }
  560. }
  561. }
  562. }
  563. .stock-row {
  564. display: grid;
  565. grid-template-columns: 50% 50%;
  566. width: 100%;
  567. padding: 24rpx;
  568. background-color: #f6f8fa;
  569. border-radius: 8rpx;
  570. .stock-item {
  571. display: flex;
  572. flex-direction: column;
  573. .stock-label {
  574. font-size: 24rpx;
  575. color: #999;
  576. margin-bottom: 20rpx;
  577. }
  578. .stock-value {
  579. font-size: 24rpx;
  580. color: #333;
  581. &-warning {
  582. color: #ff4e02;
  583. }
  584. }
  585. }
  586. }
  587. .action-row {
  588. padding: 0 32rpx 32rpx;
  589. display: flex;
  590. justify-content: flex-end;
  591. gap: 24rpx;
  592. .action-btn {
  593. width: 144rpx;
  594. height: 56rpx;
  595. padding: 0;
  596. &-secondary {
  597. background-color: transparent;
  598. border-color: #ff9900;
  599. color: #ff9900;
  600. }
  601. }
  602. }
  603. }
  604. }
  605. }
  606. </style>