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. <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" @confirm="handleMoreInfoConfirm"></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. handleMoreInfoConfirm() {
  247. this.$refs.moreInfoRef.closeModal();
  248. },
  249. getTypeList() {
  250. this.$getDicts("crm_form_category").then(res => {
  251. this.tabList = [...res]
  252. this.tabList.unshift({ dictLabel: "全部", dictValue: '' })
  253. })
  254. },
  255. getList() {
  256. uni.$u.api.wareHouseList({
  257. pageNum: this.pageNum,
  258. pageSize: this.pageSize,
  259. },
  260. {
  261. searchString: this.searchString,
  262. sortType: this.curSortType.id,
  263. type: this.type,
  264. ...this.searchInfo
  265. }).then(res => {
  266. if (this.pageNum == 1) {
  267. this.goodsList = res.rows;
  268. } else {
  269. this.goodsList = this.goodsList.concat(res.rows);
  270. }
  271. this.total = res.total;
  272. });
  273. },
  274. // 加载更多
  275. handleLoadMore() {
  276. console.log("加载更多");
  277. if (this.goodsList.length >= this.total) {
  278. uni.$u.toast("没有更多了");
  279. return;
  280. }
  281. this.pageNum++;
  282. this.getList();
  283. },
  284. handleSearch(info) {
  285. this.pageNum = 1;
  286. this.searchInfo = info;
  287. this.goodsList = [];
  288. this.getList();
  289. },
  290. switchTab(item) {
  291. this.type = item.dictValue;
  292. this.handleSearch();
  293. },
  294. clickItem(item) {
  295. if (this.isSwipeClick) {
  296. this.isSwipeClick = false;
  297. return;
  298. }
  299. // 如果是待入库商品,点击后跳转到添加页面补全信息
  300. if (item.stockStatus == '0') {
  301. this.handleEdit(item)
  302. } else {
  303. this.handleToDetail(item);
  304. }
  305. },
  306. handleSwipeClick(e, item,goodsIndex) {
  307. if (e.index == 0) {//删除
  308. this.isSwipeClick = true;
  309. if(!permissionCheck('WAREHOUSER')) return false
  310. uni.$u.api.wareHouseDelete({
  311. id: item.id
  312. }).then(() => {
  313. this.$refs.swipeRef[goodsIndex].closeOther()
  314. uni.$u.toast("删除成功");
  315. this.handleSearch();
  316. }).catch((err) => {
  317. uni.$u.toast(err);
  318. });
  319. }
  320. },
  321. handleToDetail(item) {
  322. uni.navigateTo({
  323. url: `/pages/wareHouse/components/detail?id=${item.id}`,
  324. });
  325. },
  326. handleEdit(item) {
  327. if (item.id) {
  328. uni.navigateTo({
  329. url: `/pages/wareHouse/components/edit?formType=edit&id=${item.id}`
  330. });
  331. } else {
  332. uni.navigateTo({
  333. url: `/pages/wareHouse/components/edit?formType=add`
  334. });
  335. }
  336. },
  337. // 获取仓库卡片数据
  338. getCard() {
  339. uni.$u.api.getWareHouseCard({ userId: this.$store.state.user.userInfo.userId }).then(res => {
  340. if (res.code === 200) {
  341. this.wareHouseCard = res.data;
  342. }
  343. });
  344. },
  345. handleSortChange(e) {
  346. this.curSortType = e.value[0];
  347. this.sortPickerShow = false;
  348. this.handleSearch();
  349. },
  350. priceVisibleChange() {
  351. this.priceVisible = !this.priceVisible;
  352. },
  353. openSearchFilter() {
  354. this.$refs.searchFilter.open();
  355. },
  356. navigateToFakeRegistration() {
  357. uni.navigateTo({
  358. url: '/pages/wareHouse/components/fakeRegistration',
  359. });
  360. },
  361. openOrderList() {
  362. this.$refs.orderListRef.openList();
  363. },
  364. },
  365. onShow() {
  366. this.pageNum = 1;
  367. this.getList();
  368. this.getCard();
  369. },
  370. onPullDownRefresh() {
  371. this.pageNum = 1;
  372. this.getList();
  373. this.getCard();
  374. uni.stopPullDownRefresh();
  375. },
  376. };
  377. </script>
  378. <style lang="scss" scoped>
  379. @import "./styles/index.scss";
  380. </style>