agent-stock.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  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">
  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. <view class="nodata" v-else>暂无数据</view>
  34. </view>
  35. <u-loadmore v-if="datalist&&datalist.length" :status="loadStatus" bgColor="#f2f2f2"></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. pageSize: 10, //每页条数
  70. currentPage: 1, //当前页码
  71. totalPage: 0, //总页码数
  72. loadStatus: "loadmore"
  73. };
  74. },
  75. onLoad() {
  76. this.handleGetData();
  77. },
  78. methods: {
  79. scrollBottom(v) {
  80. console.log(v);
  81. this.loadStatus = 'loading';
  82. // 模拟数据加载
  83. setTimeout(() => {
  84. this.currentPage += 1;
  85. this.handleGetData();
  86. this.loadStatus = 'loadmore';
  87. }, 1000)
  88. },
  89. changeTab(index) {
  90. this.currentTab = index;
  91. if (this.currentTab == 0) {
  92. this.currenBrand = "";
  93. this.currentPattern = "";
  94. this.currentSpec = "";
  95. this.currentPage = 1;
  96. this.handleGetData();
  97. } else if (this.currentTab == 1) {
  98. this.showBrand = true
  99. } else if (this.currentTab == 2) {
  100. this.showpattern = true
  101. }
  102. },
  103. // 获取数据
  104. handleGetData() {
  105. uni.showLoading({
  106. title: "加载中"
  107. });
  108. var _this = this;
  109. request({
  110. url: '/app/appAgent/getStoreAgentStock',
  111. method: 'post',
  112. data: {
  113. storeId: "990289",
  114. pageSize: _this.pageSize,
  115. page: _this.currentPage,
  116. brand: _this.currenBrand,
  117. spec: _this.currentSpec,
  118. pattern: _this.currentPattern
  119. }
  120. }).then(res => {
  121. if (res.data.code == 0) {
  122. console.log(res)
  123. // 获取品牌列表
  124. _this.brandList = [];
  125. res.data.data.brandList.forEach(function(val, index) {
  126. _this.brandList.push({
  127. value: index,
  128. label: val
  129. });
  130. });
  131. // 获取花纹列表
  132. _this.patternList = [];
  133. res.data.data.patternList.forEach(function(val, index) {
  134. _this.patternList.push({
  135. value: index,
  136. label: val
  137. });
  138. });
  139. // 获取数据列表
  140. _this.datalist = res.data.data.list;
  141. _this.total = res.data.data.stock;
  142. _this.totalPage = res.data.data.totalPage;
  143. // 分页
  144. if(_this.currentPage<_this.totalPage){
  145. _this.loadStatus = "loadMore"
  146. }else{
  147. _this.loadStatus = "nomore"
  148. }
  149. } else {
  150. console.log(res)
  151. uni.showToast({
  152. title: res.data.msg,
  153. icon: "none",
  154. duration: _this.$store.state.showToastDuration
  155. });
  156. }
  157. }).catch(err => {
  158. console.log(err)
  159. uni.showToast({
  160. title: _this.$store.state.showServerErrorMsg,
  161. icon: "none",
  162. duration: _this.$store.state.showToastDuration
  163. });
  164. this.currentPage -= 1;
  165. }).finally(() => {
  166. setTimeout(() => {
  167. uni.hideLoading();
  168. this.loading = false;
  169. }, 1000)
  170. });
  171. },
  172. // 筛选品牌
  173. confirmBrand: function(v) {
  174. this.currenBrand = v[0].label;
  175. this.currentPage = 1;
  176. this.handleGetData();
  177. },
  178. // 筛选花纹
  179. confirmPattern: function(v) {
  180. this.currentPattern = v[0].label;
  181. this.currentPage = 1;
  182. this.handleGetData();
  183. },
  184. searchSpec: function() {
  185. if(this.currentSpec){
  186. this.currentPage = 1;
  187. this.handleGetData();
  188. }
  189. console.log(this.currentSpec)
  190. },
  191. inputFocus() {
  192. console.log(111);
  193. this.inputCustomStyle = {
  194. position: "absolute",
  195. zIndex: "100",
  196. width: "98%",
  197. margin: "6rpx 1%"
  198. };
  199. },
  200. inputBlur() {
  201. var _this = this;
  202. setTimeout(function() {
  203. _this.inputCustomStyle = {};
  204. }, 30)
  205. }
  206. },
  207. filters: {
  208. filterTotal: function(val) {
  209. var valText;
  210. if (val >= 10) {
  211. valText = "充足"
  212. } else {
  213. valText = "紧张"
  214. };
  215. return valText;
  216. }
  217. }
  218. }
  219. </script>
  220. <style lang="scss" scoped>
  221. .scroll-view-container{
  222. height: 100%;
  223. }
  224. .header {
  225. height: 400rpx;
  226. width: 100%;
  227. background: #0094FE;
  228. color: #fff;
  229. font-size: 28rpx;
  230. }
  231. .header-one {
  232. text-align: center;
  233. padding-top: 40rpx;
  234. }
  235. .header-one>text {
  236. font-size: 52rpx;
  237. }
  238. .content {
  239. display: flex;
  240. justify-content: space-between;
  241. width: 700rpx;
  242. margin-top: 80rpx;
  243. }
  244. .content-one {
  245. width: 690rpx;
  246. // height: 305rpx;
  247. background: #FFFFFF;
  248. color: #000;
  249. font-size: 24rpx;
  250. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  251. border-radius: 20px;
  252. margin: -100rpx auto 20rpx auto;
  253. min-height: calc(100% - 400rpx);
  254. }
  255. .content-one-view {
  256. width: 6rpx;
  257. height: 30rpx;
  258. background: #0292FD;
  259. position: relative;
  260. top: 20rpx;
  261. left: 30rpx;
  262. }
  263. .content-one-text {
  264. position: relative;
  265. top: -8rpx;
  266. left: 60rpx;
  267. font-size: 24rpx;
  268. font-weight: bold;
  269. color: #000;
  270. }
  271. .content-one-time {
  272. position: relative;
  273. top: -40rpx;
  274. left: 530rpx;
  275. font-size: 13rpx;
  276. color: #626262;
  277. }
  278. .content-two {
  279. display: flex;
  280. justify-content: space-between;
  281. font-size: 24rpx;
  282. color: #6A6A6A;
  283. margin-left: 30rpx;
  284. margin-right: 30rpx;
  285. padding-top: 25rpx;
  286. padding-bottom: 25rpx;
  287. }
  288. .wrap-flex {
  289. display: flex;
  290. }
  291. .nodata{
  292. padding: 48rpx;
  293. }
  294. </style>