index.vue 19 KB

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