agent-stock.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361
  1. <template>
  2. <!-- 经销商库存页面 -->
  3. <scroll-view scroll-y @scrolltolower="scrollBottom" class="scroll-view-container">
  4. <view class="header">
  5. <view class="header-one">
  6. 库存是否充足:<text>{{total | filterTotal}}</text>
  7. </view>
  8. <view class="content">
  9. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="changeTab(0)">全部</u-button>
  10. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="changeTab(1)">品牌</u-button>
  11. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="changeTab(2)">花纹</u-button>
  12. <u-select style=" color: #fff;" v-model="showBrand" :list="brandList" @confirm="confirmBrand"></u-select>
  13. <u-select style=" color: #fff;" v-model="showpattern" :list="patternList" @confirm="confirmPattern"></u-select>
  14. <!-- <u-calendar style=" color: #fff;" v-model="showDate" :mode="mode"></u-calendar> -->
  15. <u-search :show-action="true" v-model="currentSpec" :animation="true" @custom="searchSpec" @search="searchSpec"
  16. :style="inputCustomStyle" @focus="inputFocus" @blur="inputBlur" placeholder="请输入规格"></u-search>
  17. </view>
  18. </view>
  19. <view class="content-one">
  20. <template v-if="datalist&&datalist.length">
  21. <view class="content-two" v-for="(item,index) in datalist" :key="index" v-cloak>
  22. <view>
  23. {{ item.brand }}
  24. </view>
  25. <view>
  26. {{ item.maktx}}
  27. </view>
  28. <view>
  29. {{ item.stock | filterTotal }}
  30. </view>
  31. </view>
  32. </template>
  33. <u-empty v-else text="暂无数据" mode="list"></u-empty>
  34. </view>
  35. <u-loadmore v-if="datalist&&datalist.length" :status="loadStatus" bgColor="#f2f2f2" :load-text="loadText"></u-loadmore>
  36. </scroll-view>
  37. </template>
  38. <script>
  39. import {
  40. request
  41. } from '@/common/request/request';
  42. require("promise.prototype.finally").shim();
  43. export default {
  44. data() {
  45. return {
  46. buttonCustomStyle: {
  47. border: "none",
  48. background: "#0094FE",
  49. color: "#ffffff"
  50. },
  51. total: 0, //总库存数
  52. datalist: null,
  53. // 品牌信息
  54. brandList: null,
  55. currenBrand: "", // 选中品牌
  56. showBrand: false,
  57. // 花纹信息
  58. patternList: null,
  59. currentPattern: "", // 选中花纹
  60. showpattern: false,
  61. // 规格信息
  62. currentSpec: "",
  63. inputCustomStyle: {},
  64. // 选中tab
  65. currentTab: 0,
  66. // showDate: false,
  67. // mode: 'date',
  68. // 分页信息
  69. first: 0,
  70. pageSize: 20, //每页条数
  71. currentPage: 1, //当前页码
  72. totalPage: 0, //总页码数
  73. loadStatus: "loadmore",
  74. loadText: {
  75. loadmore: '轻轻上拉',
  76. loading: '努力加载中',
  77. nomore: '没有更多啦'
  78. }
  79. };
  80. },
  81. onLoad() {
  82. uni.showLoading({
  83. title: "加载中"
  84. });
  85. this.handleGetFilterData();
  86. this.handleGetData();
  87. },
  88. methods: {
  89. scrollBottom(v) {
  90. if (this.loadStatus == "loadmore") {
  91. this.loadStatus = 'loading';
  92. uni.showLoading({
  93. title: "加载中"
  94. });
  95. // 模拟数据加载
  96. this.first += 1;
  97. this.currentPage += 1;
  98. this.handleGetData();
  99. this.loadStatus = 'loadmore';
  100. }
  101. },
  102. changeTab(index) {
  103. this.currentTab = index;
  104. if (this.currentTab == 0) {
  105. this.currenBrand = "";
  106. this.currentPattern = "";
  107. this.currentSpec = "";
  108. this.first = 0;
  109. this.currentPage = 1;
  110. this.handleGetData();
  111. } else if (this.currentTab == 1) {
  112. this.showBrand = true
  113. } else if (this.currentTab == 2) {
  114. this.showpattern = true
  115. }
  116. },
  117. // 获取筛选条件
  118. handleGetFilterData: function() {
  119. var _this = this;
  120. request({
  121. url: '/app/appAgent/getStoreAgentCondition',
  122. }).then(res => {
  123. if (res.data.code == 0) {
  124. // 获取品牌列表
  125. _this.brandList = [];
  126. res.data.data.data.brands.forEach(function(val, index) {
  127. _this.brandList.push({
  128. value: index,
  129. label: val
  130. });
  131. });
  132. // 获取花纹列表
  133. _this.patternList = [];
  134. res.data.data.data.patterns.forEach(function(val, index) {
  135. _this.patternList.push({
  136. value: index,
  137. label: val
  138. });
  139. });
  140. } else {
  141. uni.showToast({
  142. title: res.data.msg,
  143. icon: "none",
  144. duration: _this.$store.state.showToastDuration
  145. });
  146. }
  147. }).catch(err => {
  148. this.currentPage -= 1;
  149. }).finally(() => {
  150. setTimeout(() => {
  151. uni.hideLoading();
  152. this.loading = false;
  153. }, 1000)
  154. });
  155. },
  156. // 获取数据
  157. handleGetData() {
  158. uni.showLoading({
  159. title: "加载中"
  160. });
  161. var _this = this;
  162. request({
  163. url: '/app/appAgent/getStoreAgentStock',
  164. method: 'post',
  165. data: {
  166. storeId:_this.$store.state.storeInfo.storeId,
  167. pagesize: _this.pageSize,
  168. page: _this.currentPage,
  169. brand: _this.currenBrand,
  170. spec: _this.currentSpec,
  171. pattern: _this.currentPattern
  172. }
  173. }).then(res => {
  174. if (res.data.code == 0) {
  175. // 获取数据列表
  176. if (_this.first == 0) {
  177. _this.datalist = [];
  178. _this.datalist = _this.datalist.concat(res.data.data.stockInfo);
  179. _this.total = parseInt(res.data.data.count);
  180. _this.totalPage = Math.ceil(_this.total / _this.pageSize);
  181. } else {
  182. _this.datalist = _this.datalist.concat(res.data.data.stockInfo);
  183. };
  184. // 分页
  185. if (_this.currentPage < _this.totalPage) {
  186. _this.loadStatus = "loadmore"
  187. } else {
  188. _this.loadStatus = "nomore"
  189. }
  190. } else {
  191. uni.showToast({
  192. title: res.data.msg,
  193. icon: "none",
  194. duration: _this.$store.state.showToastDuration
  195. });
  196. }
  197. }).catch(err => {
  198. this.currentPage -= 1;
  199. }).finally(() => {
  200. setTimeout(() => {
  201. uni.hideLoading();
  202. this.loading = false;
  203. }, 1000)
  204. });
  205. },
  206. // 筛选品牌
  207. confirmBrand: function(v) {
  208. this.currenBrand = v[0].label;
  209. this.currentPage = 1;
  210. this.first = 0;
  211. this.handleGetData();
  212. },
  213. // 筛选花纹
  214. confirmPattern: function(v) {
  215. this.currentPattern = v[0].label;
  216. this.currentPage = 1;
  217. this.first = 0;
  218. this.handleGetData();
  219. },
  220. searchSpec: function() {
  221. if (this.currentSpec) {
  222. this.first = 0;
  223. this.currentPage = 1;
  224. this.handleGetData();
  225. }
  226. },
  227. inputFocus() {
  228. this.inputCustomStyle = {
  229. position: "absolute",
  230. zIndex: "100",
  231. width: "98%",
  232. margin: "6rpx 1%"
  233. };
  234. },
  235. inputBlur() {
  236. var _this = this;
  237. setTimeout(function() {
  238. _this.inputCustomStyle = {};
  239. }, 30)
  240. }
  241. },
  242. filters: {
  243. filterTotal: function(val) {
  244. var valText;
  245. if (val >= 10) {
  246. valText = "充足"
  247. } else {
  248. valText = "紧张"
  249. };
  250. return valText;
  251. }
  252. }
  253. }
  254. </script>
  255. <style lang="scss" scoped>
  256. .scroll-view-container {
  257. height: 100%;
  258. }
  259. .header {
  260. height: 400rpx;
  261. width: 100%;
  262. background: #0094FE;
  263. color: #fff;
  264. font-size: 28rpx;
  265. }
  266. .header-one {
  267. text-align: center;
  268. padding-top: 40rpx;
  269. }
  270. .header-one>text {
  271. font-size: 52rpx;
  272. }
  273. .content {
  274. display: flex;
  275. justify-content: space-between;
  276. width: 700rpx;
  277. margin-top: 80rpx;
  278. }
  279. .content-one {
  280. width: 690rpx;
  281. // height: 305rpx;
  282. background: #FFFFFF;
  283. color: #000;
  284. font-size: 24rpx;
  285. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  286. border-radius: 20px;
  287. margin: -100rpx auto 20rpx auto;
  288. min-height: calc(100% - 400rpx);
  289. }
  290. .content-one-view {
  291. width: 6rpx;
  292. height: 30rpx;
  293. background: #0292FD;
  294. position: relative;
  295. top: 20rpx;
  296. left: 30rpx;
  297. }
  298. .content-one-text {
  299. position: relative;
  300. top: -8rpx;
  301. left: 60rpx;
  302. font-size: 24rpx;
  303. font-weight: bold;
  304. color: #000;
  305. }
  306. .content-one-time {
  307. position: relative;
  308. top: -40rpx;
  309. left: 530rpx;
  310. font-size: 13rpx;
  311. color: #626262;
  312. }
  313. .content-two {
  314. display: flex;
  315. justify-content: space-between;
  316. font-size: 24rpx;
  317. color: #6A6A6A;
  318. margin-left: 30rpx;
  319. margin-right: 30rpx;
  320. padding-top: 25rpx;
  321. padding-bottom: 25rpx;
  322. }
  323. .wrap-flex {
  324. display: flex;
  325. }
  326. .nodata {
  327. padding: 48rpx;
  328. }
  329. </style>