index.vue 17 KB

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