detail.vue 18 KB

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