agent-stock.vue 8.7 KB

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