index.vue 16 KB

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