agent-stock.vue 6.9 KB

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