index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324
  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. <u-button class="view-btn" type="text" size="mini" @click="navigateToFakeRegistration">假货登记</u-button>
  15. </view>
  16. <view class="data-cards">
  17. <view class="card-item">
  18. <text class="card-label">今日上传</text>
  19. <text class="card-value">{{ wareHouseCard.uploadCostToday }}</text>
  20. </view>
  21. <view class="card-item">
  22. <text class="card-label">今日下架</text>
  23. <text class="card-value green">{{ wareHouseCard.outStockToday }}</text>
  24. </view>
  25. <view class="card-item">
  26. <text class="card-label">商品总数</text>
  27. <text class="card-value">{{ wareHouseCard.totalNum }}</text>
  28. </view>
  29. </view>
  30. <!-- <u-upload @afterRead="uploadTestAfter" name="1" multiple :maxCount="10"></u-upload> -->
  31. <view class="search-wrapper">
  32. <u-search placeholder="搜索编号、名称、品牌..." v-model="searchString" bg-color="#f9fafb" border-radius="4rpx"
  33. :show-action="false" class="search-input-wrap" showAction @clear="handleSearch" @custom="handleSearch"></u-search>
  34. </view>
  35. <view class="category-tabs-wrap">
  36. <u-tabs :list="tabList" :is-scroll="true" active-color="#007aff" inactive-color="#666666" font-size="28rpx" keyName="dictLabel"
  37. border-bottom="none" @change="switchTab" class="u-tabs-custom"></u-tabs>
  38. </view>
  39. <view class="filter-bar">
  40. <view class="sort-btn" @click="sortPickerShow = true">
  41. <text class="sort-text">{{ curSortType.label }}</text>
  42. <u-icon name="arrow-down" size="12" color="#666666" class="sort-icon"></u-icon>
  43. <u-picker :show="sortPickerShow" :columns="sortColumns" keyName="label" @confirm="handleSortChange" @cancel="sortPickerShow = false"></u-picker>
  44. </view>
  45. <view class="price-layout-btn">
  46. <view class="price-btn" type="text" @click="priceVisibleChange">
  47. <u-icon :name="priceVisible ? 'eye' : 'eye-off'" size="18" color="#1890ff" class="price-icon"></u-icon>
  48. <text class="price-text">价格可见</text>
  49. </view>
  50. <view class="layout-btn" type="text" size="mini" @click="openSearchFilter">
  51. <u-icon name="grid" size="20" color="#666666"></u-icon>
  52. <!-- 筛选列 品牌、价格范围、位置、回收时间、回收人员、鉴定人员、商品属性 -->
  53. </view>
  54. <searchFilter ref="searchFilter" @confirm="handleSearch"></searchFilter>
  55. </view>
  56. </view>
  57. <scroll-view class="goods-list" scroll-y @scrolltolower="handleLoadMore" enable-back-to-top>
  58. <view @click="clickItem(goods)" class="goods-item" v-for="(goods, goodsIndex) in goodsList" :key="`goods-${goodsIndex}`">
  59. <view class="goods-img-container">
  60. <image class="goods-img" :src="goods.imgUrl ? goods.imgUrl : '/static/no-img.png'" mode="aspectFill" lazy-load></image>
  61. <!-- <image class="goods-img" src="/static/no-img.png" mode="aspectFill" lazy-load></image> -->
  62. <view :class="['stock-indicator', goods.downStatus == '1' ? 'up-indicator' : 'down-indicator']"></view>
  63. </view>
  64. <view class="goods-info">
  65. <text class="goods-brand">{{ goods.dictLabel || '' }}</text>
  66. <text class="goods-name">{{ goods.model || '' }}</text>
  67. <view class="price-group">
  68. <view class="price-items">
  69. <view class="price-item">
  70. <text class="price-type">成本价</text>
  71. <text class="price">¥{{ priceVisible ? goods.costPrice || '-' : '****' }}</text>
  72. </view>
  73. <view class="price-item">
  74. <text class="price-type">销售价</text>
  75. <text class="price sales">¥{{ priceVisible ? goods.salePrice || '-' : '****' }}</text>
  76. </view>
  77. </view>
  78. <view class="price-items">
  79. <view class="price-item">
  80. <text class="price-type">同行价</text>
  81. <text class="price">¥{{ priceVisible ? goods.peerPrice || '-' : '****' }}</text>
  82. </view>
  83. <view class="price-item">
  84. <text class="price-type">代理价</text>
  85. <text class="price">¥{{ priceVisible ? goods.agentPrice || '-' : '****' }}</text>
  86. </view>
  87. </view>
  88. </view>
  89. <!-- <view class="others">
  90. <view class="other-item stock" >得</view>
  91. <view class="other-item">得</view>
  92. <view class="other-item">得</view>
  93. </view> -->
  94. </view>
  95. <view class="more">
  96. <view @click.stop="showMoreOptions(goods)">
  97. <u-icon name="more-dot-fill" size="16" color="#666666"></u-icon>
  98. </view>
  99. <text class="goods-stock">数量:{{ goods.stock}}</text>
  100. </view>
  101. </view>
  102. </scroll-view>
  103. </view>
  104. <!-- 添加按钮 -->
  105. <view class="add-button" @click="handleEdit">
  106. <u-icon name="plus" size="36" color="#ffffff"></u-icon>
  107. </view>
  108. <moreInfo ref="moreInfoRef" :moreOptions="moreOptions"></moreInfo>
  109. </view>
  110. </template>
  111. <script>
  112. import searchFilter from './components/searchFilter.vue'
  113. import moreInfo from './components/moreInfo.vue'
  114. export default {
  115. components: {
  116. searchFilter,
  117. moreInfo,
  118. },
  119. data() {
  120. return {
  121. searchString:'',//搜索编号、名称、品牌...
  122. type:'',
  123. searchInfo:{},
  124. pageNum:1,
  125. pageSize:10,
  126. curSortType:{
  127. id:4,
  128. label: '按入库最新',
  129. },
  130. wareHouseCard:{
  131. totalCost: '-',
  132. uploadCostToday: '-',
  133. outStockToday: '-',
  134. totalNum: '-'
  135. },
  136. tabList: [],
  137. goodsList: [
  138. // {
  139. // id:'123456754',//商品库存id
  140. // name:'Rolex',//商品名称
  141. // model:'Submariner Date 126610LN',//型号
  142. // costPrice:'12345',//成本价格
  143. // salesPrice:'12345',//销售价格
  144. // peerPrice:'12345',//同行价格
  145. // agentPrice:'12345',//代理价格
  146. // stock:'12345',//库存数量
  147. // imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
  148. // platform:[]//同步平台,此功能暂时不做,先定义一个字段
  149. // }
  150. ],
  151. sortPickerShow: false,
  152. sortColumns: [[
  153. {
  154. label:'按最久未下载',
  155. id:1
  156. },
  157. {
  158. label:'按最近更新',
  159. id:2
  160. },
  161. {
  162. label:'按最久更新',
  163. id:3
  164. },
  165. {
  166. label:'按入库最新',
  167. id:4
  168. },
  169. {
  170. label:'按入库最久',
  171. id:5
  172. },
  173. {
  174. label:'按价格最高',
  175. id:6
  176. },
  177. {
  178. label:'按价格最低',
  179. id:7
  180. },
  181. ]],
  182. priceVisible:true,
  183. searchPopShow:false,
  184. total:0,
  185. moreOptions:{},
  186. moreOptionsShow:false,
  187. };
  188. },
  189. onLoad() {
  190. this.getTypeList();
  191. },
  192. methods: {
  193. showMoreOptions(goods){
  194. this.moreOptions = goods;
  195. this.$refs.moreInfoRef.showMoreInfo();
  196. },
  197. getTypeList(){
  198. this.$getDicts("crm_form_category").then(res => {
  199. this.tabList = [...res]
  200. this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
  201. })
  202. },
  203. uploadTestAfter(info){
  204. console.log(info);
  205. info.file.forEach(item=>{
  206. uni.$u.api.uploadFile(item.url).then((res) => {
  207. uni.$u.toast("文件上传成功");
  208. }).catch(() => {
  209. uni.$u.toast("上传文件失败");
  210. })
  211. })
  212. },
  213. getList(){
  214. uni.$u.api.wareHouseList({
  215. pageNum: this.pageNum,
  216. pageSize: this.pageSize,
  217. },
  218. {
  219. searchString:this.searchString,
  220. sortType:this.curSortType.id,
  221. type:this.type,
  222. ...this.searchInfo
  223. }).then(res => {
  224. if(this.pageNum == 1){
  225. this.goodsList = res.rows;
  226. }else{
  227. this.goodsList = this.goodsList.concat(res.rows);
  228. }
  229. this.total = res.total;
  230. });
  231. },
  232. // 加载更多
  233. handleLoadMore() {
  234. console.log("加载更多");
  235. if(this.goodsList.length >= this.total){
  236. uni.$u.toast("没有更多了");
  237. return;
  238. }
  239. this.pageNum++;
  240. this.getList();
  241. },
  242. handleSearch(info){
  243. this.pageNum = 1;
  244. this.searchInfo = info;
  245. this.goodsList = [];
  246. this.getList();
  247. },
  248. switchTab(item) {
  249. this.type = item.dictValue;
  250. this.handleSearch();
  251. },
  252. clickItem(item){
  253. // 如果是待入库商品,点击后跳转到添加页面补全信息
  254. if(item.stockStatus === '0'){
  255. this.handleEdit(item)
  256. }else{
  257. this.handleToDetail(item);
  258. }
  259. },
  260. handleToDetail(item) {
  261. uni.navigateTo({
  262. url: `/pages/wareHouse/components/detail?id=${item.id}`,
  263. });
  264. },
  265. handleEdit(item) {
  266. if(item.id){
  267. uni.navigateTo({
  268. url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
  269. });
  270. }else{
  271. uni.navigateTo({
  272. url: `/pages/wareHouse/components/edit?formType=add`
  273. });
  274. }
  275. },
  276. // 获取仓库卡片数据
  277. getCard() {
  278. uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  279. if (res.code === 200) {
  280. this.wareHouseCard = res.data;
  281. }
  282. });
  283. },
  284. handleSortChange(e){
  285. this.curSortType = e.value[0];
  286. this.sortPickerShow = false;
  287. this.handleSearch();
  288. },
  289. priceVisibleChange(){
  290. this.priceVisible = !this.priceVisible;
  291. },
  292. openSearchFilter(){
  293. this.$refs.searchFilter.open();
  294. },
  295. navigateToFakeRegistration() {
  296. uni.navigateTo({
  297. url: '/pages/wareHouse/components/fakeRegistration',
  298. });
  299. },
  300. },
  301. onShow() {
  302. this.pageNum = 1;
  303. this.getList();
  304. this.getCard();
  305. },
  306. onPullDownRefresh() {
  307. this.pageNum = 1;
  308. this.getList();
  309. this.getCard();
  310. uni.stopPullDownRefresh();
  311. },
  312. };
  313. </script>
  314. <style lang="scss" scoped>
  315. @import "./styles/index.scss";
  316. </style>