detail.vue 18 KB

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