index.vue 9.7 KB

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