index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384
  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="layout-btn" type="text" size="mini" @click="openSearchFilter">
  59. <u-icon name="grid" size="20" color="#666666"></u-icon>
  60. <!-- 筛选列 品牌、价格范围、位置、回收时间、回收人员、鉴定人员、商品属性 -->
  61. </view>
  62. <searchFilter ref="searchFilter" @confirm="handleSearch"></searchFilter>
  63. </view>
  64. </view>
  65. <scroll-view class="goods-list" scroll-y @scrolltolower="handleLoadMore" enable-back-to-top>
  66. <view @click.stop="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList"
  67. :key="`goods-${goodsIndex}`">
  68. <u-swipe-action ref="swipeRef">
  69. <u-swipe-action-item :options="swipeOptions" @click="(e) => handleSwipeClick(e, goods, goodsIndex)">
  70. <view class="goods-info">
  71. <view class="goods-img-container">
  72. <image class="goods-img" :src="goods.imgUrl ? goods.imgUrl : '/static/no-img.png'"
  73. mode="aspectFill" lazy-load></image>
  74. <!-- <image class="goods-img" src="/static/no-img.png" mode="aspectFill" lazy-load></image> -->
  75. <view
  76. :class="['stock-indicator', goods.downStatus == '1' ? 'up-indicator' : 'down-indicator']">
  77. </view>
  78. </view>
  79. <view class="info-content">
  80. <view class="goods-brand">
  81. <view>
  82. {{ goods.dictLabel || '' }}
  83. </view>
  84. <image v-if="goods.indentifyCode" src="../../static/icons/code.png"
  85. class="code-icon" mode="aspectFill" lazy-load></image>
  86. <view>
  87. {{ goods.indentifyCode || '' }}
  88. </view>
  89. </view>
  90. <text class="goods-name">{{ goods.model || '' }}</text>
  91. <view class="price-group">
  92. <view class="price-item" v-if="isWareHouseRole">
  93. <text class="price-type">成本价</text>
  94. <text class="price">¥{{ priceVisible ? goods.costPrice || '-' : '****'
  95. }}</text>
  96. </view>
  97. <view class="price-item" v-if="isWareHouseRole">
  98. <text class="price-type">销售价</text>
  99. <text class="price sales">¥{{ priceVisible ? goods.salePrice || '-' : '****'
  100. }}</text>
  101. </view>
  102. <view class="price-item" v-if="isWareHouseRole">
  103. <text class="price-type">同行价</text>
  104. <text class="price">¥{{ priceVisible ? goods.peerPrice || '-' : '****'
  105. }}</text>
  106. </view>
  107. <view class="price-item">
  108. <text class="price-type">代理价</text>
  109. <text class="price">¥{{ priceVisible ? goods.agentPrice || '-' : '****'
  110. }}</text>
  111. </view>
  112. <view class="price-item" v-if="isWareHouseRole">
  113. <text class="price-type">实价</text>
  114. <text class="price">¥{{ priceVisible ? goods.actualPrice || '-' : '****'
  115. }}</text>
  116. </view>
  117. <view class="price-item" v-if="isWareHouseRole">
  118. <text class="price-type">指导价</text>
  119. <text class="price">¥{{ priceVisible ? goods.price || '-' : '****' }}</text>
  120. </view>
  121. </view>
  122. <!-- <view class="others">
  123. <view class="other-item stock" >得</view>
  124. <view class="other-item">得</view>
  125. <view class="other-item">得</view>
  126. </view> -->
  127. </view>
  128. <view class="more">
  129. <view @click.stop="showMoreOptions(goods)">
  130. <u-icon name="more-dot-fill" size="16" color="#666666"></u-icon>
  131. </view>
  132. <text class="goods-stock">数量:{{ goods.stock || 0 }}</text>
  133. </view>
  134. </view>
  135. </u-swipe-action-item>
  136. </u-swipe-action>
  137. </view>
  138. </scroll-view>
  139. </view>
  140. <!-- 添加按钮 -->
  141. <view class="add-button" @click="handleEdit">
  142. <u-icon name="plus" size="36" color="#ffffff"></u-icon>
  143. </view>
  144. <moreInfo ref="moreInfoRef" :moreOptions="moreOptions"></moreInfo>
  145. </view>
  146. </template>
  147. <script>
  148. import searchFilter from './components/searchFilter.vue'
  149. import moreInfo from './components/moreInfo.vue'
  150. import { permissionCheck } from '../../utils/util.js'
  151. import orderList from './components/orderList/index.vue'
  152. export default {
  153. components: {
  154. searchFilter,
  155. moreInfo,
  156. orderList,
  157. },
  158. data() {
  159. return {
  160. searchString: '',//搜索编号、名称、品牌...
  161. type: '',
  162. searchInfo: {},
  163. pageNum: 1,
  164. pageSize: 10,
  165. curSortType: {
  166. id: 4,
  167. label: '按入库最新',
  168. },
  169. wareHouseCard: {
  170. totalCost: '-',
  171. uploadCostToday: '-',
  172. outStockToday: '-',
  173. totalNum: '-'
  174. },
  175. tabList: [],
  176. goodsList: [
  177. // {
  178. // id:'123456754',//商品库存id
  179. // name:'Rolex',//商品名称
  180. // model:'Submariner Date 126610LN',//型号
  181. // costPrice:'12345',//成本价格
  182. // salesPrice:'12345',//销售价格
  183. // peerPrice:'12345',//同行价格
  184. // agentPrice:'12345',//代理价格
  185. // stock:'12345',//库存数量
  186. // imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
  187. // platform:[]//同步平台,此功能暂时不做,先定义一个字段
  188. // }
  189. ],
  190. sortPickerShow: false,
  191. sortColumns: [[
  192. {
  193. label: '按最久未下载',
  194. id: 1
  195. },
  196. {
  197. label: '按最近更新',
  198. id: 2
  199. },
  200. {
  201. label: '按最久更新',
  202. id: 3
  203. },
  204. {
  205. label: '按入库最新',
  206. id: 4
  207. },
  208. {
  209. label: '按入库最久',
  210. id: 5
  211. },
  212. {
  213. label: '按价格最高',
  214. id: 6
  215. },
  216. {
  217. label: '按价格最低',
  218. id: 7
  219. },
  220. ]],
  221. priceVisible: true,
  222. searchPopShow: false,
  223. total: 0,
  224. moreOptions: {},
  225. moreOptionsShow: false,
  226. isWareHouseRole: permissionCheck('WAREHOUSER', false),
  227. swipeOptions: [
  228. {
  229. text: '删除',
  230. style: {
  231. backgroundColor: '#f56c6c'
  232. }
  233. },
  234. ],
  235. isSwipeClick: false,
  236. };
  237. },
  238. onLoad() {
  239. this.getTypeList();
  240. },
  241. methods: {
  242. showMoreOptions(goods) {
  243. this.moreOptions = goods;
  244. this.$refs.moreInfoRef.showMoreInfo();
  245. },
  246. getTypeList() {
  247. this.$getDicts("crm_form_category").then(res => {
  248. this.tabList = [...res]
  249. this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
  250. })
  251. },
  252. getList() {
  253. uni.$u.api.wareHouseList({
  254. pageNum: this.pageNum,
  255. pageSize: this.pageSize,
  256. },
  257. {
  258. searchString: this.searchString,
  259. sortType: this.curSortType.id,
  260. type: this.type,
  261. ...this.searchInfo
  262. }).then(res => {
  263. if (this.pageNum == 1) {
  264. this.goodsList = res.rows;
  265. } else {
  266. this.goodsList = this.goodsList.concat(res.rows);
  267. }
  268. this.total = res.total;
  269. });
  270. },
  271. // 加载更多
  272. handleLoadMore() {
  273. console.log("加载更多");
  274. if (this.goodsList.length >= this.total) {
  275. uni.$u.toast("没有更多了");
  276. return;
  277. }
  278. this.pageNum++;
  279. this.getList();
  280. },
  281. handleSearch(info) {
  282. this.pageNum = 1;
  283. this.searchInfo = info;
  284. this.goodsList = [];
  285. this.getList();
  286. },
  287. switchTab(item) {
  288. this.type = item.dictValue;
  289. this.handleSearch();
  290. },
  291. clickItem(item) {
  292. if (this.isSwipeClick) {
  293. this.isSwipeClick = false;
  294. return;
  295. }
  296. // 如果是待入库商品,点击后跳转到添加页面补全信息
  297. if (item.stockStatus == '0') {
  298. this.handleEdit(item)
  299. } else {
  300. this.handleToDetail(item);
  301. }
  302. },
  303. handleSwipeClick(e, item,goodsIndex) {
  304. if (e.index == 0) {//删除
  305. this.isSwipeClick = true;
  306. uni.$u.api.wareHouseDelete({
  307. id: item.id
  308. }).then(() => {
  309. this.$refs.swipeRef[goodsIndex].closeOther()
  310. uni.$u.toast("删除成功");
  311. this.handleSearch();
  312. }).catch((err) => {
  313. uni.$u.toast(err);
  314. });
  315. }
  316. },
  317. handleToDetail(item) {
  318. uni.navigateTo({
  319. url: `/pages/wareHouse/components/detail?id=${item.id}`,
  320. });
  321. },
  322. handleEdit(item) {
  323. if (item.id) {
  324. uni.navigateTo({
  325. url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
  326. });
  327. } else {
  328. uni.navigateTo({
  329. url: `/pages/wareHouse/components/edit?formType=add`
  330. });
  331. }
  332. },
  333. // 获取仓库卡片数据
  334. getCard() {
  335. uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  336. if (res.code === 200) {
  337. this.wareHouseCard = res.data;
  338. }
  339. });
  340. },
  341. handleSortChange(e) {
  342. this.curSortType = e.value[0];
  343. this.sortPickerShow = false;
  344. this.handleSearch();
  345. },
  346. priceVisibleChange() {
  347. this.priceVisible = !this.priceVisible;
  348. },
  349. openSearchFilter() {
  350. this.$refs.searchFilter.open();
  351. },
  352. navigateToFakeRegistration() {
  353. uni.navigateTo({
  354. url: '/pages/wareHouse/components/fakeRegistration',
  355. });
  356. },
  357. openOrderList() {
  358. this.$refs.orderListRef.openList();
  359. },
  360. },
  361. onShow() {
  362. this.pageNum = 1;
  363. this.getList();
  364. this.getCard();
  365. },
  366. onPullDownRefresh() {
  367. this.pageNum = 1;
  368. this.getList();
  369. this.getCard();
  370. uni.stopPullDownRefresh();
  371. },
  372. };
  373. </script>
  374. <style lang="scss" scoped>
  375. @import "./styles/index.scss";
  376. </style>