detail.vue 17 KB

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