fitProductlist.vue 7.7 KB

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