index.vue 12 KB

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