index.vue 19 KB

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