detail.vue 17 KB

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