index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523
  1. <template>
  2. <view class="page">
  3. <view class="page-container">
  4. <u-navbar class="nav-bar" title="库存管理" :autoBack="true" :placeholder="true" v-hideNav></u-navbar>
  5. <!-- 总资产成本区域 -->
  6. <view class="asset-header">
  7. <view class="asset-text-wrap">
  8. <view class="asset-title-con">
  9. <view class="asset-title">总资产成本(元)</view>
  10. <u-icon name="question-circle" size="14" color="#999999"></u-icon>
  11. </view>
  12. <text class="asset-value">{{ wareHouseCard.totalCost }}</text>
  13. </view>
  14. <view class="btn-group">
  15. <u-button type="success" shape="circle" plain size="mini" @click="openOrderList">开单记录</u-button>
  16. <order-list ref="orderListRef"></order-list>
  17. <u-button type="primary" shape="circle" plain size="mini" @click="navigateToFakeRegistration">假货登记</u-button>
  18. </view>
  19. </view>
  20. <view class="data-cards">
  21. <view class="card-item">
  22. <text class="card-label">今日上传</text>
  23. <text class="card-value">{{ wareHouseCard.uploadCostToday }}</text>
  24. </view>
  25. <view class="card-item">
  26. <text class="card-label">今日下架</text>
  27. <text class="card-value green">{{ wareHouseCard.outStockToday }}</text>
  28. </view>
  29. <view class="card-item">
  30. <text class="card-label">商品总数</text>
  31. <text class="card-value">{{ wareHouseCard.totalNum }}</text>
  32. </view>
  33. </view>
  34. <view class="search-wrapper">
  35. <u-search placeholder="搜索编号、名称、品牌..." v-model="searchString" bg-color="#f9fafb" border-radius="4rpx"
  36. :show-action="false" class="search-input-wrap" showAction @clear="handleSearch"
  37. @custom="handleSearch"></u-search>
  38. </view>
  39. <view class="category-tabs-wrap">
  40. <u-tabs :list="tabList" :is-scroll="true" active-color="#007aff" inactive-color="#666666" font-size="28rpx"
  41. keyName="dictLabel" border-bottom="none" @change="switchTab" class="u-tabs-custom"></u-tabs>
  42. </view>
  43. <view class="filter-bar">
  44. <view class="sort-btn" @click="sortPickerShow = true">
  45. <text class="sort-text">{{ curSortType.label }}</text>
  46. <u-icon name="arrow-down" size="12" color="#666666" class="sort-icon"></u-icon>
  47. <u-picker :show="sortPickerShow" :columns="sortColumns" keyName="label" @confirm="handleSortChange"
  48. @cancel="sortPickerShow = false"></u-picker>
  49. </view>
  50. <view class="price-layout-btn">
  51. <view class="price-btn" type="text" @click="priceVisibleChange">
  52. <u-icon :name="priceVisible ? 'eye' : 'eye-off'" size="18" color="#1890ff" class="price-icon"></u-icon>
  53. <text class="price-text">价格可见</text>
  54. </view>
  55. <view class="dept-btn" @click="recycleDeptClick">
  56. <image src="/static/icons/dept.png" mode="aspectFill"></image>
  57. </view>
  58. <ba-tree-picker :selectParent="true" ref="recycleDeptRef" :multiple='false' @select-change="deptSeletchang"
  59. border title="机构部门" :localdata="deptList" valueKey="deptId" textKey="deptName" childrenKey="children"
  60. :selectedValues="deptId" :personNames="deptName" />
  61. <view class="layout-btn" type="text" size="mini" @click="openSearchFilter">
  62. <image class="filter-icon" src="/static/icons/select.png" mode="aspectFill"></image>
  63. 筛选
  64. <!-- <u-icon name="grid" size="20" color="#666666"></u-icon> -->
  65. <!-- 筛选列 品牌、价格范围、位置、回收时间、回收人员、鉴定人员、商品属性 -->
  66. </view>
  67. <searchFilter ref="searchFilter" @confirm="handleSearch"></searchFilter>
  68. </view>
  69. </view>
  70. <scroll-view ref="scrollView" class="goods-list" scroll-y @scrolltolower="handleLoadMore" @scroll="handleScroll"
  71. enable-back-to-top>
  72. <view @click.stop="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList"
  73. :key="`goods-${goodsIndex}`">
  74. <u-swipe-action ref="swipeRef">
  75. <u-swipe-action-item :options="swipeOptions" @click="(e) => handleSwipeClick(e, goods, goodsIndex)">
  76. <view class="goods-info">
  77. <view class="goods-img-container">
  78. <image class="goods-img" :src="goods.imgUrl ? goods.imgUrl : '/static/no-img.png'" mode="aspectFill"
  79. lazy-load></image>
  80. <!-- <image class="goods-img" src="/static/no-img.png" mode="aspectFill" lazy-load></image> -->
  81. <view :class="['stock-indicator', goods.downStatus == '1' ? 'up-indicator' : 'down-indicator']">
  82. </view>
  83. </view>
  84. <view class="info-content">
  85. <view class="goods-brand">
  86. <view>
  87. {{ goods.dictLabel || '-' }}
  88. </view>
  89. <!-- <image v-if="goods.indentifyCode" src="../../static/icons/code.png"
  90. class="code-icon" mode="aspectFill" lazy-load></image>
  91. <view>
  92. {{ goods.indentifyCode || '' }}
  93. </view> -->
  94. </view>
  95. <text class="goods-name">型号:{{ goods.model || '-' }}</text>
  96. <text class="goods-name">编码:{{ goods.indentifyCode || '-' }}</text>
  97. <view class="price-group">
  98. <view class="price-item" v-if="isWareHouseRole">
  99. <text class="price-type">成本价</text>
  100. <text class="price">¥{{ priceVisible ? goods.costPrice || '-' : '****'
  101. }}</text>
  102. </view>
  103. <view class="price-item" v-if="isWareHouseRole">
  104. <text class="price-type">销售价</text>
  105. <text class="price sales">¥{{ priceVisible ? goods.salePrice || '-' : '****'
  106. }}</text>
  107. </view>
  108. <view class="price-item" v-if="isWareHouseRole">
  109. <text class="price-type">同行价</text>
  110. <text class="price">¥{{ priceVisible ? goods.peerPrice || '-' : '****'
  111. }}</text>
  112. </view>
  113. <view class="price-item">
  114. <text class="price-type">代理价</text>
  115. <text class="price">¥{{ priceVisible ? goods.agentPrice || '-' : '****'
  116. }}</text>
  117. </view>
  118. <view class="price-item" v-if="isWareHouseRole">
  119. <text class="price-type">实价</text>
  120. <text class="price">¥{{ priceVisible ? goods.actualPrice || '-' : '****'
  121. }}</text>
  122. </view>
  123. <view class="price-item" v-if="isWareHouseRole">
  124. <text class="price-type">指导价</text>
  125. <text class="price">¥{{ priceVisible ? goods.price || '-' : '****' }}</text>
  126. </view>
  127. </view>
  128. <!-- <view class="others">
  129. <view class="other-item stock" >得</view>
  130. <view class="other-item">得</view>
  131. <view class="other-item">得</view>
  132. </view> -->
  133. </view>
  134. <view class="more">
  135. <view @click.stop="showMoreOptions(goods)">
  136. <u-icon name="more-dot-fill" size="16" color="#666666"></u-icon>
  137. </view>
  138. <text class="goods-stock">数量:{{ goods.stock || 0 }}</text>
  139. </view>
  140. </view>
  141. <!-- 更多信息区域 -->
  142. <view class="more-info-container">
  143. <view class="more-info-header" @click.stop="toggleMoreInfo(goods)">
  144. <text class="more-info-title">更多信息</text>
  145. <u-icon :name="goods.showMoreInfo ? 'arrow-up' : 'arrow-down'" size="14" color="#666666"></u-icon>
  146. </view>
  147. <transition name="more-info">
  148. <view class="more-info-content" v-if="goods.showMoreInfo">
  149. <view class="info-row">
  150. <text class="info-label">回收时间:</text>
  151. <text class="info-value">{{ formatterTime(goods.recycleTime) }}</text>
  152. </view>
  153. <view class="info-row">
  154. <text class="info-label">入库时间:</text>
  155. <text class="info-value">{{ formatterTime(goods.warehouseDate) }}</text>
  156. </view>
  157. <view class="info-row">
  158. <text class="info-label">商品位置:</text>
  159. <text class="info-value">{{ goods.productPosition || '-' }}</text>
  160. </view>
  161. <view class="info-row">
  162. <text class="info-label">鉴定人员:</text>
  163. <text class="info-value">{{ goods.identifyingPerson || '-' }}</text>
  164. </view>
  165. <view class="info-row">
  166. <text class="info-label">回收人员:</text>
  167. <text class="info-value">{{ goods.recyclePerson || '-' }}</text>
  168. </view>
  169. <view class="info-row">
  170. <text class="info-label">是否入库:</text>
  171. <text class="info-value">{{ goods.stockStatus == '1' ? '已入库' : '未入库' }}</text>
  172. </view>
  173. <view class="info-row">
  174. <text class="info-label">付款方式:</text>
  175. <text class="info-value">{{ payFormatter(goods.payType) }}</text>
  176. </view>
  177. </view>
  178. </transition>
  179. </view>
  180. </u-swipe-action-item>
  181. </u-swipe-action>
  182. </view>
  183. </scroll-view>
  184. </view>
  185. <!-- 添加按钮 -->
  186. <view class="add-button" @click="handleEdit">
  187. <u-icon name="plus" size="36" color="#ffffff"></u-icon>
  188. </view>
  189. <moreInfo ref="moreInfoRef" :moreOptions="moreOptions" @confirm="handleMoreInfoConfirm"></moreInfo>
  190. </view>
  191. </template>
  192. <script>
  193. import searchFilter from './components/searchFilter.vue'
  194. import moreInfo from './components/moreInfo.vue'
  195. import { permissionCheck } from '../../utils/util.js'
  196. import orderList from './components/orderList/index.vue'
  197. import { paymentTabList } from './js/public.js'
  198. import jtimePickerPopup from '@/uni_modules/jtime-picker-popup/components/JTimePicker/JTimePicker.vue';
  199. export default {
  200. components: {
  201. searchFilter,
  202. moreInfo,
  203. orderList,
  204. jtimePickerPopup
  205. },
  206. data() {
  207. return {
  208. searchString: '',//搜索编号、名称、品牌...
  209. type: '',
  210. searchInfo: {},
  211. pageNum: 1,
  212. pageSize: 10,
  213. curSortType: {
  214. id: 4,
  215. label: '按入库最新',
  216. },
  217. wareHouseCard: {
  218. totalCost: '-',
  219. uploadCostToday: '-',
  220. outStockToday: '-',
  221. totalNum: '-'
  222. },
  223. tabList: [],
  224. goodsList: [
  225. // {
  226. // id:'123456754',//商品库存id
  227. // name:'Rolex',//商品名称
  228. // model:'Submariner Date 126610LN',//型号
  229. // costPrice:'12345',//成本价格
  230. // salesPrice:'12345',//销售价格
  231. // peerPrice:'12345',//同行价格
  232. // agentPrice:'12345',//代理价格
  233. // stock:'12345',//库存数量
  234. // imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
  235. // platform:[]//同步平台,此功能暂时不做,先定义一个字段
  236. // }
  237. ],
  238. sortPickerShow: false,
  239. sortColumns: [[
  240. {
  241. label: '按最久未下载',
  242. id: 1
  243. },
  244. {
  245. label: '按最近更新',
  246. id: 2
  247. },
  248. {
  249. label: '按最久更新',
  250. id: 3
  251. },
  252. {
  253. label: '按入库最新',
  254. id: 4
  255. },
  256. {
  257. label: '按入库最久',
  258. id: 5
  259. },
  260. {
  261. label: '按价格最高',
  262. id: 6
  263. },
  264. {
  265. label: '按价格最低',
  266. id: 7
  267. },
  268. ]],
  269. priceVisible: true,
  270. searchPopShow: false,
  271. total: 0,
  272. moreOptions: {},
  273. moreOptionsShow: false,
  274. isWareHouseRole: permissionCheck('WAREHOUSER', false),
  275. swipeOptions: [
  276. {
  277. text: '删除',
  278. style: {
  279. backgroundColor: '#f56c6c'
  280. }
  281. },
  282. ],
  283. isSwipeClick: false,
  284. deptList: [],
  285. deptId: '',
  286. deptName: '',
  287. // 保存页面状态
  288. pageState: {
  289. pageNum: 1,
  290. goodsList: [],
  291. total: 0,
  292. scrollTop: 0
  293. },
  294. paymentTabList: paymentTabList
  295. };
  296. },
  297. onLoad() {
  298. this.getTypeList();
  299. },
  300. methods: {
  301. toggleMoreInfo(goods) {
  302. this.$set(goods, 'showMoreInfo', !goods.showMoreInfo);
  303. },
  304. formatterTime(time) {
  305. if (!time) {
  306. return '-'
  307. }
  308. return this.$dayjs(time).format('YYYY-MM-DD')
  309. },
  310. payFormatter(payType) {
  311. return paymentTabList.find(item => item.value == payType)?.name || '-'
  312. },
  313. getDeptListAll() {
  314. const params = {
  315. isDept: 2
  316. }
  317. uni.$u.api.getDeptListAll(params).then(res => {
  318. if (res.data.length > 0) {
  319. this.deptList = res.data;
  320. } else {
  321. uni.$u.toast('暂无机构部门');
  322. }
  323. })
  324. },
  325. deptSeletchang(ids, names) {
  326. this.deptId = ids[0] || '';
  327. this.deptName = names[0] || '';
  328. this.handleSearch();
  329. },
  330. recycleDeptClick() {
  331. this.getDeptListAll();
  332. this.$refs.recycleDeptRef._show();
  333. },
  334. showMoreOptions(goods) {
  335. this.moreOptions = goods;
  336. this.$refs.moreInfoRef.showMoreInfo();
  337. },
  338. handleMoreInfoConfirm() {
  339. this.$refs.moreInfoRef.closeModal();
  340. },
  341. getTypeList() {
  342. this.$getDicts("crm_form_category").then(res => {
  343. this.tabList = [...res]
  344. this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
  345. })
  346. },
  347. getList() {
  348. uni.$u.api.wareHouseList({
  349. pageNum: this.pageNum,
  350. pageSize: this.pageSize,
  351. },
  352. {
  353. searchString: this.searchString,
  354. sortType: this.curSortType.id,
  355. type: this.type,
  356. deptId: this.deptId,
  357. deptName: this.deptName,
  358. ...this.searchInfo
  359. }).then(res => {
  360. if (this.pageNum == 1) {
  361. this.goodsList = res.rows;
  362. } else {
  363. this.goodsList = this.goodsList.concat(res.rows);
  364. }
  365. this.total = res.total;
  366. });
  367. },
  368. // 加载更多
  369. handleLoadMore() {
  370. console.log("加载更多");
  371. if (this.goodsList.length >= this.total) {
  372. uni.$u.toast("没有更多了");
  373. return;
  374. }
  375. this.pageNum++;
  376. this.getList();
  377. },
  378. handleSearch(info) {
  379. this.pageNum = 1;
  380. this.searchInfo = info;
  381. this.goodsList = [];
  382. this.getList();
  383. },
  384. switchTab(item) {
  385. this.type = item.dictValue;
  386. this.handleSearch();
  387. },
  388. clickItem(item) {
  389. if (this.isSwipeClick) {
  390. this.isSwipeClick = false;
  391. return;
  392. }
  393. // 如果是待入库商品,点击后跳转到添加页面补全信息
  394. if (item.stockStatus == '0') {
  395. this.handleEdit(item)
  396. } else {
  397. this.handleToDetail(item);
  398. }
  399. },
  400. handleSwipeClick(e, item, goodsIndex) {
  401. if (e.index == 0) {//删除
  402. this.isSwipeClick = true;
  403. if (!permissionCheck('WAREHOUSER')) return false
  404. uni.$u.api.wareHouseDelete({
  405. id: item.id
  406. }).then(() => {
  407. this.$refs.swipeRef[goodsIndex].closeOther()
  408. uni.$u.toast("删除成功");
  409. this.handleSearch();
  410. }).catch((err) => {
  411. uni.$u.toast(err);
  412. });
  413. }
  414. },
  415. handleToDetail(item) {
  416. uni.navigateTo({
  417. url: `/pages/wareHouse/components/detail?id=${item.id}`,
  418. });
  419. },
  420. handleEdit(item) {
  421. if (item.id) {
  422. uni.navigateTo({
  423. url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
  424. });
  425. } else {
  426. uni.navigateTo({
  427. url: `/pages/wareHouse/components/edit?formType=add`
  428. });
  429. }
  430. },
  431. // 获取仓库卡片数据
  432. getCard() {
  433. uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  434. if (res.code === 200) {
  435. this.wareHouseCard = res.data;
  436. }
  437. });
  438. },
  439. handleSortChange(e) {
  440. this.curSortType = e.value[0];
  441. this.sortPickerShow = false;
  442. this.handleSearch();
  443. },
  444. priceVisibleChange() {
  445. this.priceVisible = !this.priceVisible;
  446. },
  447. openSearchFilter() {
  448. this.$refs.searchFilter.open();
  449. },
  450. navigateToFakeRegistration() {
  451. uni.navigateTo({
  452. url: '/pages/wareHouse/components/fakeRegistration',
  453. });
  454. },
  455. openOrderList() {
  456. this.$refs.orderListRef.openList();
  457. },
  458. handleScroll(e) {
  459. this.pageState.scrollTop = e.detail.scrollTop;
  460. },
  461. // 保存当前页面状态
  462. savePageState() {
  463. this.pageState.pageNum = this.pageNum;
  464. this.pageState.goodsList = [...this.goodsList];
  465. this.pageState.total = this.total;
  466. },
  467. // 恢复页面状态
  468. restorePageState() {
  469. if (this.pageState.goodsList.length > 0) {
  470. this.pageNum = this.pageState.pageNum;
  471. this.goodsList = [...this.pageState.goodsList];
  472. this.total = this.pageState.total;
  473. this.$nextTick(() => {
  474. if (this.pageState.scrollTop > 0) {
  475. if (this.$refs.scrollView) {
  476. setTimeout(() => {
  477. try {
  478. this.$refs.scrollView.$el.scrollTop = this.pageState.scrollTop;
  479. } catch (e) {
  480. console.log('设置滚动位置失败:', e);
  481. }
  482. }, 100);
  483. }
  484. }
  485. });
  486. return true;
  487. }
  488. return false;
  489. },
  490. },
  491. onShow() {
  492. // 尝试恢复页面状态
  493. if (!this.restorePageState()) {
  494. // 如果没有保存的状态,重新加载第一页
  495. this.pageNum = 1;
  496. this.getList();
  497. }
  498. this.getCard();
  499. },
  500. onHide() {
  501. // 页面隐藏时保存状态
  502. this.savePageState();
  503. },
  504. onPullDownRefresh() {
  505. this.pageNum = 1;
  506. this.getList();
  507. this.getCard();
  508. uni.stopPullDownRefresh();
  509. },
  510. };
  511. </script>
  512. <style lang="scss" scoped>
  513. @import "./styles/index.scss";
  514. </style>