detail.vue 18 KB

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