detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727
  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="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. },
  282. number: "",
  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.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. number: this.number,
  366. };
  367. console.log("getTaskStocktakingItemList======", params);
  368. const res = await taskStocktakingItemList(params);
  369. const { total, rows } = res.data;
  370. rows.forEach((item) => {
  371. if (item.imgName && item.imgName.length > 0) {
  372. item.imgNameArr = item.imgName.split(",");
  373. } else {
  374. item.imgNameArr = [];
  375. }
  376. });
  377. console.log("rows======", rows);
  378. this.goodsList = [...this.goodsList, ...rows];
  379. if (pageNum * pageSize < Number(total)) {
  380. this.pageNum++;
  381. this.loadStatus = "loadmore";
  382. } else {
  383. this.loadStatus = "nomore";
  384. }
  385. } catch (error) {}
  386. },
  387. // 任务详情
  388. async getTaskStocktakingDetail(taskId) {
  389. try {
  390. const res = await taskStocktakingDetail(taskId);
  391. this.inventoryInfo = res.data;
  392. } catch (error) {}
  393. },
  394. resetData() {
  395. this.pageNum = 1;
  396. this.goodsList = [];
  397. },
  398. async loadData(id, isRefresh = false) {
  399. if (isRefresh) {
  400. this.resetData();
  401. }
  402. try {
  403. this.getTaskStocktakingItemList(id);
  404. this.getTaskStocktakingDetail(id);
  405. } catch (error) {}
  406. },
  407. // 库位编辑
  408. handlePositionEdit(item) {
  409. this.actionPop.showCategoryPop = true;
  410. this.actionPop.activeGoodsItem = { ...item };
  411. this.actionPop.originalLocation = item.position;
  412. },
  413. async haandleComfirmLocation(val) {
  414. const activeGoodsItem = this.actionPop.activeGoodsItem;
  415. try {
  416. const params = {
  417. id: activeGoodsItem.id,
  418. materialItemId: activeGoodsItem.materialItemId,
  419. newPosition: val,
  420. };
  421. const res = await stocktaking(params);
  422. if (res.code === 200) {
  423. uni.$u.toast(res.msg);
  424. this.onRefresh();
  425. this.actionPop.showCategoryPop = false;
  426. } else {
  427. uni.$u.toast(res.data);
  428. }
  429. } catch (error) {}
  430. },
  431. handleCheck(item) {
  432. this.actionPop.showNumPop = true;
  433. this.actionPop.activeGoodsItem = { ...item };
  434. this.actionPop.maxCount = item.inventory;
  435. },
  436. async handleConfirmNum(val) {
  437. console.log(111223, val);
  438. const activeGoodsItem = this.actionPop.activeGoodsItem;
  439. console.log("activeGoodsItem========", activeGoodsItem);
  440. try {
  441. const params = {
  442. id: activeGoodsItem.id,
  443. materialItemId: activeGoodsItem.materialItemId,
  444. newInventory: val,
  445. };
  446. const res = await stocktaking(params);
  447. console.log("res----------", res);
  448. if (res.code === 200) {
  449. uni.$u.toast(res.msg);
  450. this.onRefresh();
  451. } else {
  452. uni.$u.toast(res.data);
  453. }
  454. } catch (error) {}
  455. },
  456. // 盘点提交
  457. submit() {},
  458. handleFilterConfirm(values) {
  459. console.log("handleFilterConfirm======", values);
  460. this.queryFilterValues = values;
  461. this.filterPopupVisible = false;
  462. this.onRefresh();
  463. },
  464. scanCode() {
  465. this.$scan.scanCode();
  466. },
  467. },
  468. };
  469. </script>
  470. <style lang="scss">
  471. .inventory-detail {
  472. min-height: 100vh;
  473. background-color: #f0f6fb;
  474. padding-bottom: 40rpx;
  475. .nav-right {
  476. padding: 0 24rpx;
  477. }
  478. .search-box {
  479. background-color: rgba(191, 200, 219, 0.2);
  480. margin: 0 32rpx;
  481. display: flex;
  482. align-items: center;
  483. justify-content: space-between;
  484. border-radius: 8rpx;
  485. ::v-deep .u-search__content {
  486. background-color: transparent !important;
  487. .u-search__content__input {
  488. background-color: transparent !important;
  489. }
  490. }
  491. .scan-icon {
  492. width: 100rpx;
  493. height: 100%;
  494. image {
  495. width: 40rpx;
  496. height: 40rpx;
  497. }
  498. }
  499. }
  500. .info-card {
  501. background-color: #fff;
  502. padding: 16rpx 32rpx;
  503. .info-item-box {
  504. display: flex;
  505. justify-content: space-between;
  506. }
  507. .info-item {
  508. display: flex;
  509. font-size: 28rpx;
  510. margin-bottom: 10rpx;
  511. &.page-title {
  512. color: #333;
  513. }
  514. .info-label {
  515. color: #999;
  516. margin-right: 8rpx;
  517. }
  518. .info-value {
  519. flex: 1;
  520. color: #999;
  521. }
  522. }
  523. .progress-box {
  524. .progress-label-box {
  525. display: flex;
  526. justify-content: space-between;
  527. }
  528. .progress-label {
  529. font-size: 28rpx;
  530. color: #999;
  531. display: block;
  532. margin-bottom: 16rpx;
  533. }
  534. .progress-bar-wrap {
  535. margin-bottom: 16rpx;
  536. }
  537. .progress-value {
  538. color: #999;
  539. font-size: 24rpx;
  540. display: block;
  541. text-align: right;
  542. }
  543. .finished-value {
  544. color: #4080ff;
  545. }
  546. }
  547. }
  548. .filter-wrap {
  549. display: flex;
  550. justify-content: flex-end;
  551. padding: 20rpx;
  552. .filter-btn {
  553. display: flex;
  554. align-items: center;
  555. border-radius: 8rpx;
  556. font-size: 24rpx;
  557. color: #333333;
  558. .icon {
  559. margin-left: 8rpx;
  560. width: 32rpx;
  561. height: 32rpx;
  562. }
  563. }
  564. }
  565. .goods-list {
  566. width: 710rpx;
  567. margin: 0 20rpx;
  568. border-radius: 16rpx;
  569. .goods-item {
  570. background-color: #fff;
  571. overflow: hidden;
  572. border-bottom: 1px solid #f5f6f7;
  573. .location-row {
  574. display: flex;
  575. align-items: center;
  576. padding: 24rpx 32rpx;
  577. gap: 40rpx;
  578. .location-left {
  579. display: flex;
  580. align-items: center;
  581. .location-label {
  582. font-size: 28rpx;
  583. color: #333;
  584. }
  585. .location-value {
  586. font-size: 28rpx;
  587. color: #4080ff;
  588. margin: 0 8rpx;
  589. }
  590. .icon {
  591. width: 32rpx;
  592. height: 32rpx;
  593. }
  594. }
  595. .category-text {
  596. font-size: 24rpx;
  597. color: #999;
  598. }
  599. }
  600. .goods-content {
  601. padding: 24rpx 32rpx;
  602. display: flex;
  603. .goods-image {
  604. width: 160rpx;
  605. flex-basis: 160rpx;
  606. height: 160rpx;
  607. border-radius: 8rpx;
  608. background-color: #f5f6f7;
  609. }
  610. .goods-info {
  611. display: flex;
  612. flex-wrap: wrap;
  613. flex: 1;
  614. margin-left: 24rpx;
  615. .half-w {
  616. width: 50%;
  617. }
  618. .goods-name {
  619. width: 100%;
  620. font-size: 28rpx;
  621. line-height: 1.4;
  622. color: #333;
  623. margin-bottom: 16rpx;
  624. }
  625. .goods-field {
  626. font-size: 24rpx;
  627. color: #666;
  628. margin-bottom: 16rpx;
  629. .field-label {
  630. color: #999;
  631. }
  632. .field-value {
  633. color: #666;
  634. }
  635. }
  636. }
  637. }
  638. .stock-row {
  639. display: grid;
  640. grid-template-columns: 50% 50%;
  641. width: 100%;
  642. padding: 24rpx;
  643. background-color: #f6f8fa;
  644. border-radius: 8rpx;
  645. .stock-item {
  646. display: flex;
  647. flex-direction: column;
  648. .stock-label {
  649. font-size: 24rpx;
  650. color: #999;
  651. margin-bottom: 20rpx;
  652. }
  653. .stock-value {
  654. font-size: 24rpx;
  655. color: #333;
  656. &-warning {
  657. color: #ff4e02;
  658. }
  659. }
  660. }
  661. }
  662. .action-row {
  663. padding: 0 32rpx 32rpx;
  664. display: flex;
  665. justify-content: flex-end;
  666. gap: 24rpx;
  667. .action-btn {
  668. height: 56rpx;
  669. padding: 0;
  670. margin-left: 20rpx;
  671. border: 0;
  672. }
  673. }
  674. }
  675. }
  676. }
  677. </style>