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