detail.vue 18 KB

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