index.vue 18 KB

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