stockQuery.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406
  1. <template>
  2. <view v-if="$accessCheck($Access.queryGetInventoryAll)">
  3. <view class="keyword-view clearfix">
  4. <!-- <u-search @clear="searchList" @search="searchList" @custom="searchList" :clearabled="true" placeholder="商品名称" v-model="keyword"></u-search> -->
  5. <view class="float_left">
  6. <u-search :show-action="false" @clear="searchList" @search="searchList" :clearabled="true" placeholder="商品名称" v-model="keyword"></u-search>
  7. </view>
  8. <view class="float_right" @click="openSel('search_show')"><text class="custom-icon custom-icon-shaixuan"></text></view>
  9. </view>
  10. <view class="main-view clearfix">
  11. <view class="left-view float_left">
  12. <scroll-view scroll-y="true" class="left-scroll">
  13. <view class="cate-li" :class="[!category_id ? 'cate-on' : '']" @click="changeCate(0)">全部</view>
  14. <view
  15. class="cate-li ellipsis"
  16. v-for="(item, index) in category_list"
  17. :key="index"
  18. @click="changeCate(item.id)"
  19. :class="[category_id === item.id ? 'cate-on' : '']"
  20. >
  21. {{ item.title }}
  22. </view>
  23. </scroll-view>
  24. </view>
  25. <view class="rigth-view float_left">
  26. <scroll-view scroll-y="true" class="rigth-scroll" @scrolltolower="moreGoods" :scroll-top="scrollTop">
  27. <view class="goods-li" v-for="(item, index) in goods_list" :key="index">
  28. <view class="goods-main clearfix">
  29. <image class="goods-img float_left" :src="item.images[0]" mode="aspectFill"></image>
  30. <view class="goods-info float_left">
  31. <view class="goods-name ellipsis">{{ item.materielName }}</view>
  32. <view class="goods-code">{{ item.materielCode }}</view>
  33. <view class="goods-code">{{ item.unitName }};{{ item.skuName }}</view>
  34. <view class="goods-code">{{ item.skuValue }}</view>
  35. <!-- <view class="goods-tag">
  36. <u-tag class="tag-li" mode="plain" size="mini" :text="item.categoryName" />
  37. <u-tag class="tag-li" mode="dark" size="mini" text="库存分步" />
  38. </view> -->
  39. </view>
  40. </view>
  41. <view class="num-ul">
  42. <view class="num-li">
  43. <view class="label">可售</view>
  44. {{ $utils.formatNub(item.inventoryNum) }}{{ item.unitName }}
  45. </view>
  46. <view class="num-li">
  47. <view class="label">占用</view>
  48. {{ $utils.formatNub(item.lockInventory) }}{{ item.unitName }}
  49. </view>
  50. <view class="num-li">
  51. <view class="label">换算</view>
  52. {{ item.skuNum }}
  53. </view>
  54. </view>
  55. </view>
  56. <u-loadmore v-if="goods_list.length" :status="load_status" />
  57. <view v-if="!goods_list.length" class="empty-view"><u-empty text="暂无商品" mode="favor"></u-empty></view>
  58. </scroll-view>
  59. </view>
  60. </view>
  61. <u-popup v-model="search_show" mode="right">
  62. <view class="search-pop">
  63. <view class="form-view">
  64. <u-form label-width="160rpx" label-position="left">
  65. <u-form-item label="库存状态">
  66. <view class="clearfix form-val" @click="openFrom">
  67. <text class="float_left ellipsis">{{ haveInventoryNum ? haveInventoryNum_name : '请选择' }}</text>
  68. <view class="float_right" @click.stop="clearValue()">
  69. <u-icon :name="!haveInventoryNum ? 'arrow-right' : 'close-circle-fill'" size="28" color="#999999"></u-icon>
  70. </view>
  71. </view>
  72. </u-form-item>
  73. </u-form>
  74. </view>
  75. <view class="search-btn">
  76. <view class="btn-li" @click="clearValue()">重置</view>
  77. <view class="btn-li" @click="searchList">确定</view>
  78. </view>
  79. </view>
  80. </u-popup>
  81. <u-select @confirm="fromChange" v-model="from_show" :list="order_status"></u-select>
  82. </view>
  83. </template>
  84. <script>
  85. export default {
  86. data() {
  87. return {
  88. load_status: 'nomore',
  89. tab_current: 0,
  90. status_list: [
  91. {
  92. label: '启用',
  93. value: 5
  94. },
  95. {
  96. label: '禁用',
  97. value: 4
  98. }
  99. ],
  100. category_list: [], // 分类列表
  101. category_id: '', // 分类id
  102. auditStatus: 2, // 审核状态
  103. isOption: '', // 是否是自选商品
  104. page: 1,
  105. pageSize: 10,
  106. total: 0,
  107. goods_list: [],
  108. brandId: '', //品牌
  109. brand_name: '',
  110. keyword: '', //关键词
  111. enableStatus: '', //上下架
  112. scrollTop: -1,
  113. search_show: false,
  114. haveInventoryNum: '',
  115. haveInventoryNum_name: '',
  116. from_show: false,
  117. order_status: [
  118. {
  119. label: '有库存',
  120. value: 5
  121. },
  122. {
  123. label: '无库存',
  124. value: 4
  125. }
  126. ]
  127. };
  128. },
  129. onLoad() {
  130. this.getAllCategory();
  131. },
  132. onShow() {
  133. this.page = 1;
  134. this.getInventoryAll();
  135. },
  136. methods: {
  137. // 重置搜索
  138. clearValue(params) {
  139. if (params) {
  140. this.haveInventoryNum = '';
  141. } else {
  142. this.haveInventoryNum = '';
  143. this.searchList();
  144. }
  145. },
  146. fromChange(e) {
  147. this.haveInventoryNum = e[0].value;
  148. this.haveInventoryNum_name = e[0].label;
  149. },
  150. openFrom() {
  151. this.from_show = true;
  152. },
  153. openSel(key) {
  154. this[key] = true;
  155. },
  156. // 获取所有商品分类
  157. getAllCategory() {
  158. this.$u.api
  159. .getAllCategory({
  160. enableStatus: 5
  161. })
  162. .then(res => {
  163. this.category_list = res.data;
  164. });
  165. },
  166. // 切换分类
  167. changeCate(id) {
  168. this.scrollTop = 0;
  169. this.$nextTick(function() {
  170. this.scrollTop = -1;
  171. });
  172. this.category_id = id;
  173. this.searchList();
  174. },
  175. // 滚动到底部,触发上拉加载
  176. moreGoods() {
  177. if (this.total / this.pageSize > this.page) {
  178. this.page += 1;
  179. this.getInventoryAll();
  180. }
  181. },
  182. searchList() {
  183. this.search_show = false;
  184. this.page = 1;
  185. this.getInventoryAll();
  186. },
  187. // 获取商品列表
  188. getInventoryAll() {
  189. this.load_status = 'loading';
  190. let params = {
  191. page: this.page,
  192. pageSize: this.pageSize,
  193. categoryId: this.category_id,
  194. materielName: this.keyword,
  195. warehouseId: '',
  196. haveInventoryNum: this.haveInventoryNum
  197. };
  198. this.$u.api.getInventoryAll(params).then(res => {
  199. if (this.page === 1) {
  200. this.goods_list = res.data;
  201. } else {
  202. this.goods_list = this.goods_list.concat(res.data);
  203. }
  204. this.total = res.pageTotal;
  205. this.load_status = this.$utils.loadStatus(this.page, this.pageSize, this.total);
  206. });
  207. }
  208. }
  209. };
  210. </script>
  211. <style scoped lang="scss">
  212. // .keyword-view {
  213. // background-color: #ffffff;
  214. // padding: 20rpx 24rpx;
  215. // .float_left {
  216. // width: 640rpx;
  217. // }
  218. // .float_right {
  219. // line-height: 64rpx;
  220. // width: 50rpx;
  221. // text-align: center;
  222. // color: #666666;
  223. // }
  224. // }
  225. .keyword-view {
  226. padding: 20rpx 24rpx 0;
  227. background-color: #ffffff;
  228. z-index: 9;
  229. padding-bottom: 20rpx;
  230. .float_left {
  231. width: 640rpx;
  232. }
  233. .float_right {
  234. line-height: 64rpx;
  235. width: 50rpx;
  236. text-align: center;
  237. color: #666666;
  238. }
  239. }
  240. .main-view {
  241. .left-view {
  242. width: 168rpx;
  243. background-color: #f7f8fa;
  244. .left-scroll {
  245. width: 100%;
  246. height: calc(100vh - 106rpx);
  247. .cate-li {
  248. line-height: 90rpx;
  249. padding-left: 36rpx;
  250. color: #666666;
  251. -webkit-line-clamp: 1;
  252. }
  253. .cate-on {
  254. background-color: #ffffff;
  255. color: #000000;
  256. position: relative;
  257. &::before {
  258. content: '';
  259. display: block;
  260. width: 6rpx;
  261. height: 20rpx;
  262. background-color: $uni-color-primary;
  263. position: absolute;
  264. left: 14rpx;
  265. top: 50%;
  266. transform: translateY(-50%);
  267. }
  268. }
  269. }
  270. }
  271. .rigth-view {
  272. width: calc(100% - 168rpx);
  273. background-color: #ffffff;
  274. .rigth-scroll {
  275. width: 100%;
  276. height: calc(100vh - 106rpx);
  277. .goods-li {
  278. padding: 20rpx;
  279. border-bottom: 1px solid #f5f5f5;
  280. position: relative;
  281. .goods-main {
  282. .goods-img {
  283. border-radius: 10rpx;
  284. width: 156rpx;
  285. height: 156rpx;
  286. margin-right: 20rpx;
  287. }
  288. .goods-info {
  289. width: 366rpx;
  290. .goods-name {
  291. -webkit-line-clamp: 1;
  292. }
  293. .goods-code {
  294. font-size: 24rpx;
  295. padding-top: 6rpx;
  296. }
  297. .goods-tag {
  298. padding: 10rpx 0;
  299. .tag-li {
  300. margin-right: 14rpx;
  301. }
  302. }
  303. .goods-num {
  304. color: #999999;
  305. font-size: 22rpx;
  306. text {
  307. padding-right: 10rpx;
  308. }
  309. }
  310. }
  311. }
  312. .num-ul {
  313. display: flex;
  314. padding-top: 20rpx;
  315. .num-li {
  316. font-size: 24rpx;
  317. line-height: 36rpx;
  318. flex: 3;
  319. text-align: center;
  320. position: relative;
  321. font-weight: bold;
  322. .label {
  323. font-weight: 400;
  324. color: #999999;
  325. }
  326. &::after {
  327. display: block;
  328. content: '';
  329. position: absolute;
  330. width: 1px;
  331. height: 60rpx;
  332. top: 50%;
  333. transform: translateY(-50%);
  334. right: 0;
  335. background-color: #eeeeee;
  336. }
  337. &:last-child {
  338. &::after {
  339. display: block;
  340. content: '';
  341. position: absolute;
  342. width: 1px;
  343. height: 50rpx;
  344. top: 50%;
  345. transform: translateY(-50%);
  346. right: 0;
  347. background-color: transparent;
  348. }
  349. }
  350. }
  351. }
  352. .more-btn {
  353. position: absolute;
  354. right: 20rpx;
  355. bottom: -120rpx;
  356. background-color: #ffffff;
  357. border-radius: 10rpx;
  358. padding: 0 20rpx;
  359. z-index: 9;
  360. box-shadow: 0px 3px 24rpx rgba(0, 0, 0, 0.1);
  361. .more-btn-li {
  362. font-size: 24rpx;
  363. line-height: 60rpx;
  364. text-align: center;
  365. border-bottom: 1px solid #f5f5f5;
  366. &:last-child {
  367. border: 0 none;
  368. }
  369. }
  370. }
  371. }
  372. }
  373. }
  374. }
  375. </style>