agent-stock.vue 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <template>
  2. <!-- 经销商库存页面 -->
  3. <scroll-view scroll-y @scrolltolower="scrollBottom" class="scroll-view-container">
  4. <view class="header">
  5. <view class="header-one">
  6. {{$t('agentStock.stockStatus')}}:<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)">{{ $t('agentStock.all') }}</u-button>
  10. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="changeTab(1)">{{ $t('agentStock.brand') }}</u-button>
  11. <u-button :custom-style="buttonCustomStyle" :hair-line="false" hover-class="none" @click="changeTab(2)">{{ $t('agentStock.pattern')}}</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="$t('agentStock.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="$('unified.nodata')" 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: this.$t('unified.Loading')
  84. });
  85. this.handleGetFilterData();
  86. this.handleGetData();
  87. },
  88. created() {
  89. uni.setNavigationBarTitle({
  90. title: this.$t('agentStock.title')
  91. });
  92. },
  93. methods: {
  94. scrollBottom(v) {
  95. if (this.loadStatus == "loadmore") {
  96. this.loadStatus = 'loading';
  97. uni.showLoading({
  98. title: this.$t('unified.Loading')
  99. });
  100. // 模拟数据加载
  101. this.first += 1;
  102. this.currentPage += 1;
  103. this.handleGetData();
  104. this.loadStatus = 'loadmore';
  105. }
  106. },
  107. changeTab(index) {
  108. this.currentTab = index;
  109. if (this.currentTab == 0) {
  110. this.currenBrand = "";
  111. this.currentPattern = "";
  112. this.currentSpec = "";
  113. this.first = 0;
  114. this.currentPage = 1;
  115. this.handleGetData();
  116. } else if (this.currentTab == 1) {
  117. this.showBrand = true
  118. } else if (this.currentTab == 2) {
  119. this.showpattern = true
  120. }
  121. },
  122. // 获取筛选条件
  123. handleGetFilterData: function() {
  124. var _this = this;
  125. request({
  126. url: '/app/appAgent/getStoreAgentCondition',
  127. }).then(res => {
  128. if (res.data.code == 0) {
  129. // 获取品牌列表
  130. _this.brandList = [];
  131. res.data.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.data.patterns.forEach(function(val, index) {
  140. _this.patternList.push({
  141. value: index,
  142. label: val
  143. });
  144. });
  145. } else {
  146. uni.showToast({
  147. title: res.data.msg,
  148. icon: "none",
  149. duration: _this.$store.state.showToastDuration
  150. });
  151. }
  152. }).catch(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: this.$t('unified.Loading')
  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. // 获取数据列表
  181. if (_this.first == 0) {
  182. _this.datalist = [];
  183. _this.datalist = _this.datalist.concat(res.data.data.stockInfo);
  184. _this.total = parseInt(res.data.data.count);
  185. _this.totalPage = Math.ceil(_this.total / _this.pageSize);
  186. } else {
  187. _this.datalist = _this.datalist.concat(res.data.data.stockInfo);
  188. };
  189. // 分页
  190. if (_this.currentPage < _this.totalPage) {
  191. _this.loadStatus = "loadmore"
  192. } else {
  193. _this.loadStatus = "nomore"
  194. }
  195. } else {
  196. uni.showToast({
  197. title: res.data.msg,
  198. icon: "none",
  199. duration: _this.$store.state.showToastDuration
  200. });
  201. }
  202. }).catch(err => {
  203. this.currentPage -= 1;
  204. }).finally(() => {
  205. setTimeout(() => {
  206. uni.hideLoading();
  207. this.loading = false;
  208. }, 1000)
  209. });
  210. },
  211. // 筛选品牌
  212. confirmBrand: function(v) {
  213. this.currenBrand = v[0].label;
  214. this.currentPage = 1;
  215. this.first = 0;
  216. this.handleGetData();
  217. },
  218. // 筛选花纹
  219. confirmPattern: function(v) {
  220. this.currentPattern = v[0].label;
  221. this.currentPage = 1;
  222. this.first = 0;
  223. this.handleGetData();
  224. },
  225. searchSpec: function() {
  226. if (this.currentSpec) {
  227. this.first = 0;
  228. this.currentPage = 1;
  229. this.handleGetData();
  230. }
  231. },
  232. inputFocus() {
  233. this.inputCustomStyle = {
  234. position: "absolute",
  235. zIndex: "100",
  236. width: "98%",
  237. margin: "6rpx 1%"
  238. };
  239. },
  240. inputBlur() {
  241. var _this = this;
  242. setTimeout(function() {
  243. _this.inputCustomStyle = {};
  244. }, 30)
  245. }
  246. },
  247. filters: {
  248. filterTotal: function(val) {
  249. var valText;
  250. if (val >= 10) {
  251. valText = this.$t('agentStock.status1')
  252. } else {
  253. valText = this.$t('agentStock.status2')
  254. };
  255. return valText;
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="scss" scoped>
  261. .scroll-view-container {
  262. height: 100%;
  263. }
  264. .header {
  265. height: 400rpx;
  266. width: 100%;
  267. background: #0094FE;
  268. color: #fff;
  269. font-size: 28rpx;
  270. }
  271. .header-one {
  272. text-align: center;
  273. padding-top: 40rpx;
  274. }
  275. .header-one>text {
  276. font-size: 52rpx;
  277. }
  278. .content {
  279. display: flex;
  280. justify-content: space-between;
  281. width: 700rpx;
  282. margin-top: 80rpx;
  283. }
  284. .content-one {
  285. width: 690rpx;
  286. // height: 305rpx;
  287. background: #FFFFFF;
  288. color: #000;
  289. font-size: 24rpx;
  290. box-shadow: 0px 0px 24px 0px rgba(101, 176, 249, 0.41);
  291. border-radius: 20px;
  292. margin: -100rpx auto 20rpx auto;
  293. min-height: calc(100% - 400rpx);
  294. }
  295. .content-one-view {
  296. width: 6rpx;
  297. height: 30rpx;
  298. background: #0292FD;
  299. position: relative;
  300. top: 20rpx;
  301. left: 30rpx;
  302. }
  303. .content-one-text {
  304. position: relative;
  305. top: -8rpx;
  306. left: 60rpx;
  307. font-size: 24rpx;
  308. font-weight: bold;
  309. color: #000;
  310. }
  311. .content-one-time {
  312. position: relative;
  313. top: -40rpx;
  314. left: 530rpx;
  315. font-size: 13rpx;
  316. color: #626262;
  317. }
  318. .content-two {
  319. display: flex;
  320. justify-content: space-between;
  321. font-size: 24rpx;
  322. color: #6A6A6A;
  323. margin-left: 30rpx;
  324. margin-right: 30rpx;
  325. padding-top: 25rpx;
  326. padding-bottom: 25rpx;
  327. }
  328. .wrap-flex {
  329. display: flex;
  330. }
  331. .nodata {
  332. padding: 48rpx;
  333. }
  334. </style>