index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322
  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. <u-icon name="more-dot-fill" size="16" color="#666666" @click="showMoreOptions(goods)"></u-icon>
  97. <text class="goods-stock">数量:{{ goods.stock}}</text>
  98. </view>
  99. </view>
  100. </scroll-view>
  101. </view>
  102. <!-- 添加按钮 -->
  103. <view class="add-button" @click="handleEdit">
  104. <u-icon name="plus" size="36" color="#ffffff"></u-icon>
  105. </view>
  106. <!-- <moreInfo ref="moreInfoRef" :moreOptions="moreOptions"></moreInfo> -->
  107. </view>
  108. </template>
  109. <script>
  110. import searchFilter from './components/searchFilter.vue'
  111. import moreInfo from './components/moreInfo.vue'
  112. export default {
  113. components: {
  114. searchFilter,
  115. moreInfo,
  116. },
  117. data() {
  118. return {
  119. searchString:'',//搜索编号、名称、品牌...
  120. type:'',
  121. searchInfo:{},
  122. pageNum:1,
  123. pageSize:10,
  124. curSortType:{
  125. id:4,
  126. label: '按入库最新',
  127. },
  128. wareHouseCard:{
  129. totalCost: '-',
  130. uploadCostToday: '-',
  131. outStockToday: '-',
  132. totalNum: '-'
  133. },
  134. tabList: [],
  135. goodsList: [
  136. // {
  137. // id:'123456754',//商品库存id
  138. // name:'Rolex',//商品名称
  139. // model:'Submariner Date 126610LN',//型号
  140. // costPrice:'12345',//成本价格
  141. // salesPrice:'12345',//销售价格
  142. // peerPrice:'12345',//同行价格
  143. // agentPrice:'12345',//代理价格
  144. // stock:'12345',//库存数量
  145. // imgUrl:'https://xiaohulu-crm.oss-cn-shanghai.aliyuncs.com/crm/2026/01/06/1767677335839-1767677330379.jpg',//商品图片
  146. // platform:[]//同步平台,此功能暂时不做,先定义一个字段
  147. // }
  148. ],
  149. sortPickerShow: false,
  150. sortColumns: [[
  151. {
  152. label:'按最久未下载',
  153. id:1
  154. },
  155. {
  156. label:'按最近更新',
  157. id:2
  158. },
  159. {
  160. label:'按最久更新',
  161. id:3
  162. },
  163. {
  164. label:'按入库最新',
  165. id:4
  166. },
  167. {
  168. label:'按入库最久',
  169. id:5
  170. },
  171. {
  172. label:'按价格最高',
  173. id:6
  174. },
  175. {
  176. label:'按价格最低',
  177. id:7
  178. },
  179. ]],
  180. priceVisible:true,
  181. searchPopShow:false,
  182. total:0,
  183. moreOptions:{},
  184. moreOptionsShow:false,
  185. };
  186. },
  187. onLoad() {
  188. this.getTypeList();
  189. },
  190. methods: {
  191. showMoreOptions(goods){
  192. this.moreOptions = goods;
  193. this.$refs.moreInfoRef.showMoreInfo();
  194. },
  195. getTypeList(){
  196. this.$getDicts("crm_form_category").then(res => {
  197. this.tabList = [...res]
  198. this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
  199. })
  200. },
  201. uploadTestAfter(info){
  202. console.log(info);
  203. info.file.forEach(item=>{
  204. uni.$u.api.uploadFile(item.url).then((res) => {
  205. uni.$u.toast("文件上传成功");
  206. }).catch(() => {
  207. uni.$u.toast("上传文件失败");
  208. })
  209. })
  210. },
  211. getList(){
  212. uni.$u.api.wareHouseList({
  213. pageNum: this.pageNum,
  214. pageSize: this.pageSize,
  215. },
  216. {
  217. searchString:this.searchString,
  218. sortType:this.curSortType.id,
  219. type:this.type,
  220. ...this.searchInfo
  221. }).then(res => {
  222. if(this.pageNum == 1){
  223. this.goodsList = res.rows;
  224. }else{
  225. this.goodsList = this.goodsList.concat(res.rows);
  226. }
  227. this.total = res.total;
  228. });
  229. },
  230. // 加载更多
  231. handleLoadMore() {
  232. console.log("加载更多");
  233. if(this.goodsList.length >= this.total){
  234. uni.$u.toast("没有更多了");
  235. return;
  236. }
  237. this.pageNum++;
  238. this.getList();
  239. },
  240. handleSearch(info){
  241. this.pageNum = 1;
  242. this.searchInfo = info;
  243. this.goodsList = [];
  244. this.getList();
  245. },
  246. switchTab(item) {
  247. this.type = item.dictValue;
  248. this.handleSearch();
  249. },
  250. clickItem(item){
  251. // 如果是待入库商品,点击后跳转到添加页面补全信息
  252. if(item.stockStatus === '0'){
  253. this.handleEdit(item)
  254. }else{
  255. this.handleToDetail(item);
  256. }
  257. },
  258. handleToDetail(item) {
  259. uni.navigateTo({
  260. url: `/pages/wareHouse/components/detail?id=${item.id}`,
  261. });
  262. },
  263. handleEdit(item) {
  264. if(item.id){
  265. uni.navigateTo({
  266. url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
  267. });
  268. }else{
  269. uni.navigateTo({
  270. url: `/pages/wareHouse/components/edit?formType=add`
  271. });
  272. }
  273. },
  274. // 获取仓库卡片数据
  275. getCard() {
  276. uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  277. if (res.code === 200) {
  278. this.wareHouseCard = res.data;
  279. }
  280. });
  281. },
  282. handleSortChange(e){
  283. this.curSortType = e.value[0];
  284. this.sortPickerShow = false;
  285. this.handleSearch();
  286. },
  287. priceVisibleChange(){
  288. this.priceVisible = !this.priceVisible;
  289. },
  290. openSearchFilter(){
  291. this.$refs.searchFilter.open();
  292. },
  293. navigateToFakeRegistration() {
  294. uni.navigateTo({
  295. url: '/pages/wareHouse/components/fakeRegistration',
  296. });
  297. },
  298. },
  299. onShow() {
  300. this.pageNum = 1;
  301. this.getList();
  302. this.getCard();
  303. },
  304. onPullDownRefresh() {
  305. this.pageNum = 1;
  306. this.getList();
  307. this.getCard();
  308. uni.stopPullDownRefresh();
  309. },
  310. };
  311. </script>
  312. <style lang="scss" scoped>
  313. @import "./styles/index.scss";
  314. </style>