agent-stock.vue 8.5 KB

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