fitProductlist.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  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.inStockCount || 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 hover-class="none" shape="circle" size="medium" @click="reset">重置</u-button>
  48. <u-button hover-class="none" :custom-style="customBtnStyle" shape="circle" size="medium" @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. shelfName: '',
  87. pageNo: 1,
  88. pageSize: 10,
  89. noDataText: '暂无数据',
  90. status: 'loading',
  91. totalNum: 0,
  92. total: 0,
  93. theme:'',
  94. customBtnStyle: { // 自定义按钮样式
  95. borderColor: this.$config('primaryColor'),
  96. backgroundColor: this.$config('primaryColor'),
  97. color: '#fff'
  98. },
  99. };
  100. },
  101. onLoad(options) {
  102. this.theme = getApp().globalData.theme;
  103. this.shelfSn = options.shelfSn;
  104. this.shelfName = options.shelfName;
  105. let ajaxData = {
  106. pageNo: this.pageNo,
  107. pageSize: this.pageSize,
  108. shelfSn: this.shelfSn
  109. };
  110. this.loadData(ajaxData);
  111. },
  112. onReady() {
  113. uni.setNavigationBarTitle({
  114. title: this.shelfName
  115. })
  116. },
  117. onBackPress(e) {
  118. if (this.sortShow) {
  119. this.sortShow = false;
  120. this.isSortFlag = 0;
  121. return true;
  122. }
  123. },
  124. methods: {
  125. // 获取数字货架列表
  126. loadData(params) {
  127. const _this = this;
  128. _this.status = 'loading';
  129. reportPage(params).then(res => {
  130. if (res.status == 200) {
  131. if (this.pageNo > 1) {
  132. this.list = this.list.concat(res.data.list || []);
  133. } else {
  134. this.list = res.data.list || [];
  135. }
  136. this.totalNum = res.data.count || 0;
  137. } else {
  138. this.list = [];
  139. this.totalNum = 0;
  140. this.noDataText = res.message;
  141. }
  142. this.status = 'loadmore';
  143. });
  144. },
  145. chooseSort(i) {
  146. this.isSortFlag = i;
  147. },
  148. reset() {
  149. this.isSortFlag = 0;
  150. this.pageNo = 1;
  151. let ajaxData = {
  152. pageNo: 1,
  153. pageSize: this.pageSize,
  154. shelfSn: this.shelfSn
  155. };
  156. this.loadData(ajaxData);
  157. },
  158. // 搜索
  159. getSearchCon() {
  160. this.pageNo = 1;
  161. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  162. var ajaxData = null;
  163. if (reg.test(this.keyword)) {
  164. //包含汉字
  165. ajaxData = {
  166. pageNo: 1,
  167. pageSize: this.pageSize,
  168. shelfSn: this.shelfSn,
  169. productName: this.keyword.trim()
  170. };
  171. } else {
  172. ajaxData = {
  173. pageNo: 1,
  174. pageSize: this.pageSize,
  175. shelfSn: this.shelfSn,
  176. productCode: this.keyword.trim()
  177. };
  178. }
  179. this.loadData(ajaxData);
  180. },
  181. // 清空搜索内容
  182. clearSearch() {
  183. this.keyword = '';
  184. this.reset();
  185. },
  186. handelSort() {
  187. this.pageNo = 1;
  188. var ajaxData = {
  189. shelfSn: this.shelfSn,
  190. pageNo: 1,
  191. pageSize: this.pageSize
  192. };
  193. if (this.keyword) {
  194. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  195. if (reg.test(this.keyword)) {
  196. ajaxData.productName=this.keyword.trim();
  197. }else{
  198. ajaxData.productCode=this.keyword.trim();
  199. }
  200. }
  201. if (this.isSortFlag == 0) {
  202. ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
  203. } else if (this.isSortFlag == 1) {
  204. ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
  205. } else {
  206. ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
  207. }
  208. this.sortShow = false;
  209. this.loadData(ajaxData);
  210. }
  211. },
  212. //到底部加载更多
  213. onReachBottom() {
  214. if (this.list.length < this.totalNum) {
  215. this.pageNo += 1;
  216. var ajaxData = {
  217. shelfSn: this.shelfSn,
  218. pageNo: this.pageNo,
  219. pageSize: this.pageSize
  220. };
  221. if (this.keyword) {
  222. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  223. if (reg.test(this.keyword)) {
  224. ajaxData.productName=this.keyword.trim();
  225. }else{
  226. ajaxData.productCode=this.keyword.trim();
  227. }
  228. }
  229. if (this.isSortFlag == 0) {
  230. ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
  231. } else if (this.isSortFlag == 1) {
  232. ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
  233. } else {
  234. ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
  235. }
  236. this.loadData(ajaxData);
  237. } else {
  238. this.status = 'nomore';
  239. }
  240. }
  241. };
  242. </script>
  243. <style lang="less" scoped>
  244. .modal-box {
  245. background: #ffffff;
  246. padding: 20rpx;
  247. width: 100%;
  248. .searchBox {
  249. width: 100%;
  250. display: flex;
  251. align-items: center;
  252. .searchBox_l {
  253. width: 80%;
  254. border: 1rpx solid #e0e0e0;
  255. border-radius: 36rpx;
  256. box-sizing: border-box;
  257. }
  258. .searchBox_r {
  259. width: 19%;
  260. color: #666666;
  261. text-align: right;
  262. text {
  263. margin-right: 10rpx;
  264. }
  265. }
  266. }
  267. .listBox {
  268. width: 100%;
  269. display: flex;
  270. padding: 30rpx 0;
  271. border-bottom: 1rpx solid #e0e0e0;
  272. .listBox_l {
  273. width: 150rpx;
  274. height: 150rpx;
  275. overflow: hidden;
  276. border-radius: 20rpx;
  277. margin-right: 20rpx;
  278. image {
  279. width: 100%;
  280. height: 100%;
  281. }
  282. }
  283. .listBox_r {
  284. width: calc(100% - 170rpx);
  285. .type {
  286. color: #222;
  287. font-size: 32rpx;
  288. }
  289. .tit {
  290. margin: 10rpx 0;
  291. overflow: hidden;
  292. text-overflow: ellipsis;
  293. display: -webkit-box;
  294. -webkit-line-clamp: 1;
  295. -webkit-box-orient: vertical;
  296. }
  297. .bot {
  298. width: 100%;
  299. view {
  300. &:first-child {
  301. color: #999;
  302. text {
  303. color: green;
  304. margin: 0 10rpx;
  305. }
  306. }
  307. &:last-child {
  308. color: #999;
  309. text {
  310. color: red;
  311. margin: 0 10rpx;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. }
  318. // 弹窗样式
  319. .sortPopup {
  320. padding: 30rpx 20rpx;
  321. box-sizing: border-box;
  322. .sortList {
  323. width: 100%;
  324. height: 70rpx;
  325. text-align: center;
  326. line-height: 70rpx;
  327. border-radius: 60rpx;
  328. color: #333;
  329. margin-bottom: 30rpx;
  330. font-size: 26rpx;
  331. border: 1rpx solid #e0e0e0;
  332. }
  333. .butBox {
  334. margin-top: 100rpx;
  335. }
  336. .sortChecked {
  337. background-color: rgb(0, 122, 255);
  338. color: #ffffff;
  339. }
  340. }
  341. .emptyStyle {
  342. margin-top: 280rpx;
  343. }
  344. .u-size-medium {
  345. padding: 0 60rpx !important;
  346. }
  347. }
  348. </style>