index.vue 14 KB

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