fitProductlist.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326
  1. <template>
  2. <view class="modal-box">
  3. <view class="searchBox">
  4. <view class="searchBox_l">
  5. <u-search
  6. placeholder="请输入产品编码/产品名称"
  7. @change="getSearchCon"
  8. @search="getSearchCon"
  9. @custom="getSearchCon"
  10. @clear="clearSearch"
  11. v-model="keyword"
  12. bg-color="#fff"
  13. :action-style="searchStyle"
  14. ></u-search>
  15. </view>
  16. <view class="searchBox_r" @click="sortShow = true">
  17. <text>排序</text>
  18. <u-icon color="#666666" name="paixu" custom-prefix="iscm-icon"></u-icon>
  19. </view>
  20. </view>
  21. <view v-if="list.length > 0">
  22. <view class="listBox" v-for="(item, i) in list" :key="i">
  23. <view class="listBox_l"><image :src="item.images ? item.images : `../../static/${theme}/def_img@2x.png`" width="100%" height="100%"></image></view>
  24. <view class="listBox_r">
  25. <view class="type">{{ item.productCode }}</view>
  26. <view class="tit">{{ item.productName }}i</view>
  27. <view class="bot u-flex u-row-between">
  28. <view>
  29. 适配有货
  30. <text>{{ item.isStockCount || 0 }}</text>
  31. </view>
  32. <view>
  33. 适配无货
  34. <text>{{ item.notStockCount || 0 }}</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view style="padding: 20rpx 0;"><u-loadmore :status="status" /></view>
  40. </view>
  41. <view v-else class="emptyStyle"><u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="150" text="暂无匹配产品" mode="list"></u-empty></view>
  42. <!-- 排序弹窗 -->
  43. <u-popup v-model="sortShow" mode="right" width="60%">
  44. <view class="sortPopup">
  45. <view class="sortList" v-for="(item, i) in sortList" :key="i" :class="isSortFlag == i ? 'sortChecked' : ''" @click="chooseSort(i)">{{ item.name }}</view>
  46. <view class="butBox u-flex u-row-between">
  47. <u-button shape="circle" size="medium" @click="reset">重置</u-button>
  48. <u-button shape="circle" size="medium" type="primary" @click="handelSort">确定</u-button>
  49. </view>
  50. </view>
  51. </u-popup>
  52. </view>
  53. </template>
  54. <script>
  55. import { reportPage } from '@/api/vinLog';
  56. export default {
  57. data() {
  58. return {
  59. searchStyle: {
  60. border: '1rpx solid #189Dff',
  61. marginRight: '10rpx',
  62. borderRadius: '26rpx',
  63. color: '#189Dff',
  64. fontSize: '26rpx',
  65. padding: '4rpx 10rpx'
  66. },
  67. sortShow: false,
  68. keyword: '',
  69. sortList: [
  70. {
  71. id: 1,
  72. name: '最近一次VIN扫描时间降序'
  73. },
  74. {
  75. id: 2,
  76. name: '适配有货降序'
  77. },
  78. {
  79. id: 3,
  80. name: '适配无货降序'
  81. }
  82. ],
  83. isSortFlag: 0,
  84. list: [],
  85. shelfSn: '',
  86. pageNo: 1,
  87. pageSize: 10,
  88. noDataText: '暂无数据',
  89. status: 'loading',
  90. totalNum: 0,
  91. total: 0
  92. };
  93. },
  94. onLoad(options) {
  95. this.theme = getApp().globalData.theme;
  96. this.shelfSn = options.shelfSn;
  97. let ajaxData = {
  98. pageNo: this.pageNo,
  99. pageSize: this.pageSize,
  100. shelfSn: this.shelfSn
  101. };
  102. this.loadData(ajaxData);
  103. uni.setNavigationBarTitle({
  104. title: options.shelfName
  105. });
  106. },
  107. onBackPress(e) {
  108. if (this.sortShow) {
  109. this.sortShow = false;
  110. this.isSortFlag = 0;
  111. return true;
  112. }
  113. },
  114. methods: {
  115. // 获取数字货架列表
  116. loadData(params) {
  117. const _this = this;
  118. _this.status = 'loading';
  119. reportPage(params).then(res => {
  120. if (res.status == 200) {
  121. if (this.pageNo > 1) {
  122. this.list = this.list.concat(res.data.list || []);
  123. } else {
  124. this.list = res.data.list || [];
  125. }
  126. this.totalNum = res.data.count || 0;
  127. } else {
  128. this.list = [];
  129. this.totalNum = 0;
  130. this.noDataText = res.message;
  131. }
  132. this.status = 'loadmore';
  133. });
  134. },
  135. chooseSort(i) {
  136. this.isSortFlag = i;
  137. },
  138. reset() {
  139. this.isSortFlag = 0;
  140. let ajaxData = {
  141. pageNo: 1,
  142. pageSize: this.pageSize,
  143. shelfSn: this.shelfSn
  144. };
  145. this.loadData(ajaxData);
  146. },
  147. // 搜索
  148. getSearchCon() {
  149. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  150. var ajaxData = null;
  151. if (reg.test(this.keyword)) {
  152. //包含汉字
  153. ajaxData = {
  154. pageNo: 1,
  155. pageSize: this.pageSize,
  156. shelfSn: this.shelfSn,
  157. productName: this.keyword.trim()
  158. };
  159. } else {
  160. ajaxData = {
  161. pageNo: 1,
  162. pageSize: this.pageSize,
  163. shelfSn: this.shelfSn,
  164. productCode: this.keyword.trim()
  165. };
  166. }
  167. this.loadData(ajaxData);
  168. },
  169. // 清空搜索内容
  170. clearSearch() {
  171. this.keyword = '';
  172. this.reset();
  173. },
  174. handelSort() {
  175. var ajaxData = {
  176. shelfSn: this.shelfSn,
  177. pageNo: this.pageNo,
  178. pageSize: this.pageSize
  179. };
  180. if (this.keyword) {
  181. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  182. if (reg.test(this.keyword)) {
  183. ajaxData.productName=this.keyword.trim();
  184. }else{
  185. ajaxData.productCode=this.keyword.trim();
  186. }
  187. }
  188. if (this.isSortFlag == 0) {
  189. ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
  190. } else if (this.isSortFlag == 1) {
  191. ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
  192. } else {
  193. ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
  194. }
  195. this.sortShow = false;
  196. this.loadData(ajaxData);
  197. }
  198. },
  199. //到底部加载更多
  200. onReachBottom() {
  201. if (this.list.length < this.totalNum) {
  202. this.pageNo += 1;
  203. let ajaxData = {
  204. shelfSn: this.shelfSn,
  205. pageNo: this.pageNo,
  206. pageSize: this.pageSize
  207. };
  208. this.loadData(ajaxData);
  209. } else {
  210. this.status = 'nomore';
  211. }
  212. }
  213. };
  214. </script>
  215. <style lang="less" scoped>
  216. .modal-box {
  217. background: #ffffff;
  218. padding: 20rpx;
  219. width: 100%;
  220. .searchBox {
  221. width: 100%;
  222. display: flex;
  223. align-items: center;
  224. .searchBox_l {
  225. width: 80%;
  226. border: 1rpx solid #e0e0e0;
  227. border-radius: 36rpx;
  228. box-sizing: border-box;
  229. }
  230. .searchBox_r {
  231. width: 19%;
  232. color: #666666;
  233. text-align: right;
  234. text {
  235. margin-right: 10rpx;
  236. }
  237. }
  238. }
  239. .listBox {
  240. width: 100%;
  241. display: flex;
  242. padding: 30rpx 0;
  243. border-bottom: 1rpx solid #e0e0e0;
  244. .listBox_l {
  245. width: 150rpx;
  246. height: 150rpx;
  247. overflow: hidden;
  248. border-radius: 20rpx;
  249. margin-right: 20rpx;
  250. image {
  251. width: 100%;
  252. height: 100%;
  253. }
  254. }
  255. .listBox_r {
  256. width: calc(100% - 170rpx);
  257. .type {
  258. color: #222;
  259. font-size: 32rpx;
  260. }
  261. .tit {
  262. margin: 10rpx 0;
  263. overflow: hidden;
  264. text-overflow: ellipsis;
  265. display: -webkit-box;
  266. -webkit-line-clamp: 1;
  267. -webkit-box-orient: vertical;
  268. }
  269. .bot {
  270. width: 100%;
  271. view {
  272. &:first-child {
  273. color: #999;
  274. text {
  275. color: green;
  276. margin: 0 10rpx;
  277. }
  278. }
  279. &:last-child {
  280. color: #999;
  281. text {
  282. color: red;
  283. margin: 0 10rpx;
  284. }
  285. }
  286. }
  287. }
  288. }
  289. }
  290. // 弹窗样式
  291. .sortPopup {
  292. padding: 30rpx 20rpx;
  293. box-sizing: border-box;
  294. .sortList {
  295. width: 100%;
  296. height: 70rpx;
  297. text-align: center;
  298. line-height: 70rpx;
  299. border-radius: 60rpx;
  300. color: #333;
  301. margin-bottom: 30rpx;
  302. font-size: 26rpx;
  303. border: 1rpx solid #e0e0e0;
  304. }
  305. .butBox {
  306. margin-top: 100rpx;
  307. }
  308. .sortChecked {
  309. background-color: #189dff;
  310. color: #ffffff;
  311. }
  312. }
  313. .emptyStyle {
  314. margin-top: 280rpx;
  315. }
  316. .u-size-medium {
  317. padding: 0 60rpx !important;
  318. }
  319. }
  320. </style>