detail.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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. pageNum: 1,
  265. pageSize: 10,
  266. inventoryInfo: {},
  267. loadStatus: "loadmore", //加载前值为loadmore,加载中为loading,没有数据为nomore
  268. goodsList: [],
  269. filterPopupVisible: false,
  270. queryFilterValues: {
  271. statusList: [], //盘点状态
  272. userIdList: [], // 盘点负责人id
  273. categoryIdList: [], // 类目
  274. positionList: [], // 库位
  275. },
  276. number: "",
  277. actionPop: {
  278. // 盘点数量弹框状态
  279. showNumPop: false,
  280. minCount: 0,
  281. maxCount: 9,
  282. activeGoodsItem: null,
  283. // 警告提示弹框状态
  284. errorShow: false,
  285. errorText: "是否提交盘点?",
  286. // 修改库位弹框状态
  287. showCategoryPop: false,
  288. originalLocation: "",
  289. },
  290. };
  291. },
  292. computed: {
  293. getProgressPercentage() {
  294. return (
  295. (this.inventoryInfo.finishCount / this.inventoryInfo.materialCount) *
  296. 100
  297. );
  298. },
  299. isEdit() {
  300. return this.pageType === "1";
  301. },
  302. ...mapGetters(["userInfo"]),
  303. },
  304. onLoad(opt) {
  305. let systemInfo = uni.getSystemInfoSync();
  306. let statusBarHeight = systemInfo.statusBarHeight;
  307. this.offsetTop = statusBarHeight + 40;
  308. console.log("222222", opt);
  309. this.pageType = opt.pageType;
  310. this.taskId = opt.id;
  311. this.loadData(opt.id);
  312. },
  313. onShow() {
  314. uni.$on("scanFinish", (data) => {
  315. this.number = data;
  316. this.onRefresh();
  317. });
  318. },
  319. onHide() {
  320. uni.$off("scanFinish");
  321. },
  322. onUnload() {
  323. uni.$off("scanFinish");
  324. },
  325. onPullDownRefresh() {
  326. // 下拉刷新
  327. this.onRefresh();
  328. },
  329. onReachBottom() {
  330. // 触底加载更多
  331. this.onLoadMore();
  332. },
  333. methods: {
  334. getGoodsInventoryStatusInfo,
  335. async onRefresh() {
  336. try {
  337. await this.loadData(this.taskId, true);
  338. } finally {
  339. uni.stopPullDownRefresh();
  340. }
  341. },
  342. async onLoadMore() {
  343. if (this.loadStatus !== "loadmore") return;
  344. this.loadStatus = "loading";
  345. try {
  346. await this.loadData(this.taskId);
  347. } catch (e) {
  348. this.loadStatus = "loadmore";
  349. }
  350. },
  351. // 商品列表
  352. async getTaskStocktakingItemList(taskId) {
  353. try {
  354. const pageNum = this.pageNum;
  355. const pageSize = this.pageSize;
  356. const params = {
  357. taskId,
  358. ...this.queryFilterValues,
  359. number: this.number,
  360. };
  361. console.log("getTaskStocktakingItemList======", params);
  362. const res = await taskStocktakingItemList(params);
  363. const { total, rows } = res.data;
  364. rows.forEach((item) => {
  365. if (item.imgName && item.imgName.length > 0) {
  366. item.imgNameArr = item.imgName.split(",");
  367. } else {
  368. item.imgNameArr = [];
  369. }
  370. });
  371. console.log("rows======", rows);
  372. this.goodsList = [...this.goodsList, ...rows];
  373. if (pageNum * pageSize < Number(total)) {
  374. this.pageNum++;
  375. this.loadStatus = "loadmore";
  376. } else {
  377. this.loadStatus = "nomore";
  378. }
  379. } catch (error) {}
  380. },
  381. // 任务详情
  382. async getTaskStocktakingDetail(taskId) {
  383. try {
  384. const res = await taskStocktakingDetail(taskId);
  385. this.inventoryInfo = res.data;
  386. } catch (error) {}
  387. },
  388. resetData() {
  389. this.pageNum = 1;
  390. this.goodsList = [];
  391. },
  392. async loadData(id, isRefresh = false) {
  393. if (isRefresh) {
  394. this.resetData();
  395. }
  396. try {
  397. this.getTaskStocktakingItemList(id);
  398. this.getTaskStocktakingDetail(id);
  399. } catch (error) {}
  400. },
  401. // 库位编辑
  402. handlePositionEdit(item) {
  403. this.actionPop.showCategoryPop = true;
  404. this.actionPop.activeGoodsItem = { ...item };
  405. this.actionPop.originalLocation = item.position;
  406. },
  407. async haandleComfirmLocation(val) {
  408. const activeGoodsItem = this.actionPop.activeGoodsItem;
  409. try {
  410. const params = {
  411. id: activeGoodsItem.id,
  412. materialItemId: activeGoodsItem.materialItemId,
  413. newPosition: val,
  414. };
  415. const res = await stocktaking(params);
  416. if (res.code === 200) {
  417. uni.$u.toast(res.msg);
  418. this.onRefresh();
  419. this.actionPop.showCategoryPop = false;
  420. } else {
  421. uni.$u.toast(res.data);
  422. }
  423. } catch (error) {}
  424. },
  425. handleCheck(item) {
  426. this.actionPop.showNumPop = true;
  427. this.actionPop.activeGoodsItem = { ...item };
  428. this.actionPop.maxCount = item.inventory;
  429. },
  430. async handleConfirmNum(val) {
  431. console.log(111223, val);
  432. const activeGoodsItem = this.actionPop.activeGoodsItem;
  433. console.log("activeGoodsItem========", activeGoodsItem);
  434. try {
  435. const params = {
  436. id: activeGoodsItem.id,
  437. materialItemId: activeGoodsItem.materialItemId,
  438. newInventory: val,
  439. };
  440. const res = await stocktaking(params);
  441. console.log("res----------", res);
  442. if (res.code === 200) {
  443. uni.$u.toast(res.msg);
  444. this.onRefresh();
  445. } else {
  446. uni.$u.toast(res.data);
  447. }
  448. } catch (error) {}
  449. },
  450. // 盘点提交
  451. submit() {},
  452. handleFilterConfirm(values) {
  453. console.log("handleFilterConfirm======", values);
  454. this.queryFilterValues = values;
  455. this.filterPopupVisible = false;
  456. this.onRefresh();
  457. },
  458. scanCode() {
  459. this.$scan.scanCode();
  460. },
  461. },
  462. };
  463. </script>
  464. <style lang="scss">
  465. .inventory-detail {
  466. min-height: 100vh;
  467. background-color: #f0f6fb;
  468. padding-bottom: 40rpx;
  469. .nav-right {
  470. padding: 0 24rpx;
  471. }
  472. .search-box {
  473. background-color: rgba(191, 200, 219, 0.2);
  474. margin: 0 32rpx;
  475. display: flex;
  476. align-items: center;
  477. justify-content: space-between;
  478. border-radius: 8rpx;
  479. ::v-deep .u-search__content {
  480. background-color: transparent !important;
  481. .u-search__content__input {
  482. background-color: transparent !important;
  483. }
  484. }
  485. .scan-icon {
  486. width: 100rpx;
  487. height: 100%;
  488. image {
  489. width: 40rpx;
  490. height: 40rpx;
  491. }
  492. }
  493. }
  494. .info-card {
  495. background-color: #fff;
  496. padding: 16rpx 32rpx;
  497. .info-item-box {
  498. display: flex;
  499. justify-content: space-between;
  500. }
  501. .info-item {
  502. display: flex;
  503. font-size: 28rpx;
  504. margin-bottom: 10rpx;
  505. &.page-title {
  506. color: #333;
  507. }
  508. .info-label {
  509. color: #999;
  510. margin-right: 8rpx;
  511. }
  512. .info-value {
  513. flex: 1;
  514. color: #999;
  515. }
  516. }
  517. .progress-box {
  518. .progress-label-box {
  519. display: flex;
  520. justify-content: space-between;
  521. }
  522. .progress-label {
  523. font-size: 28rpx;
  524. color: #999;
  525. display: block;
  526. margin-bottom: 16rpx;
  527. }
  528. .progress-bar-wrap {
  529. margin-bottom: 16rpx;
  530. }
  531. .progress-value {
  532. color: #999;
  533. font-size: 24rpx;
  534. display: block;
  535. text-align: right;
  536. }
  537. .finished-value {
  538. color: #4080ff;
  539. }
  540. }
  541. }
  542. .filter-wrap {
  543. display: flex;
  544. justify-content: flex-end;
  545. padding: 20rpx;
  546. .filter-btn {
  547. display: flex;
  548. align-items: center;
  549. border-radius: 8rpx;
  550. font-size: 24rpx;
  551. color: #333333;
  552. .icon {
  553. margin-left: 8rpx;
  554. width: 32rpx;
  555. height: 32rpx;
  556. }
  557. }
  558. }
  559. .goods-list {
  560. width: 710rpx;
  561. margin: 0 20rpx;
  562. border-radius: 16rpx;
  563. .goods-item {
  564. background-color: #fff;
  565. overflow: hidden;
  566. border-bottom: 1px solid #f5f6f7;
  567. .location-row {
  568. display: flex;
  569. align-items: center;
  570. padding: 24rpx 32rpx;
  571. gap: 40rpx;
  572. .location-left {
  573. display: flex;
  574. align-items: center;
  575. .location-label {
  576. font-size: 28rpx;
  577. color: #333;
  578. }
  579. .location-value {
  580. font-size: 28rpx;
  581. color: #4080ff;
  582. margin: 0 8rpx;
  583. }
  584. .icon {
  585. width: 32rpx;
  586. height: 32rpx;
  587. }
  588. }
  589. .category-text {
  590. font-size: 24rpx;
  591. color: #999;
  592. }
  593. }
  594. .goods-content {
  595. padding: 24rpx 32rpx;
  596. display: flex;
  597. .goods-image {
  598. width: 160rpx;
  599. flex-basis: 160rpx;
  600. height: 160rpx;
  601. border-radius: 8rpx;
  602. background-color: #f5f6f7;
  603. }
  604. .goods-info {
  605. display: flex;
  606. flex-wrap: wrap;
  607. flex: 1;
  608. margin-left: 24rpx;
  609. .half-w {
  610. width: 50%;
  611. }
  612. .goods-name {
  613. width: 100%;
  614. font-size: 28rpx;
  615. line-height: 1.4;
  616. color: #333;
  617. margin-bottom: 16rpx;
  618. }
  619. .goods-field {
  620. font-size: 24rpx;
  621. color: #666;
  622. margin-bottom: 16rpx;
  623. .field-label {
  624. color: #999;
  625. }
  626. .field-value {
  627. color: #666;
  628. }
  629. }
  630. }
  631. }
  632. .stock-row {
  633. display: grid;
  634. grid-template-columns: 50% 50%;
  635. width: 100%;
  636. padding: 24rpx;
  637. background-color: #f6f8fa;
  638. border-radius: 8rpx;
  639. .stock-item {
  640. display: flex;
  641. flex-direction: column;
  642. .stock-label {
  643. font-size: 24rpx;
  644. color: #999;
  645. margin-bottom: 20rpx;
  646. }
  647. .stock-value {
  648. font-size: 24rpx;
  649. color: #333;
  650. &-warning {
  651. color: #ff4e02;
  652. }
  653. }
  654. }
  655. }
  656. .action-row {
  657. padding: 0 32rpx 32rpx;
  658. display: flex;
  659. justify-content: flex-end;
  660. gap: 24rpx;
  661. .action-btn {
  662. height: 56rpx;
  663. padding: 0;
  664. margin-left: 20rpx;
  665. border: 0;
  666. }
  667. }
  668. }
  669. }
  670. }
  671. </style>