fitProductlist.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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. this.pageNo = 1;
  182. var ajaxData = {
  183. shelfSn: this.shelfSn,
  184. pageNo: 1,
  185. pageSize: this.pageSize
  186. };
  187. if (this.keyword) {
  188. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  189. if (reg.test(this.keyword)) {
  190. ajaxData.productName=this.keyword.trim();
  191. }else{
  192. ajaxData.productCode=this.keyword.trim();
  193. }
  194. }
  195. if (this.isSortFlag == 0) {
  196. ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
  197. } else if (this.isSortFlag == 1) {
  198. ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
  199. } else {
  200. ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
  201. }
  202. this.sortShow = false;
  203. this.loadData(ajaxData);
  204. }
  205. },
  206. //到底部加载更多
  207. onReachBottom() {
  208. if (this.list.length < this.totalNum) {
  209. this.pageNo += 1;
  210. var ajaxData = {
  211. shelfSn: this.shelfSn,
  212. pageNo: this.pageNo,
  213. pageSize: this.pageSize
  214. };
  215. if (this.keyword) {
  216. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  217. if (reg.test(this.keyword)) {
  218. ajaxData.productName=this.keyword.trim();
  219. }else{
  220. ajaxData.productCode=this.keyword.trim();
  221. }
  222. }
  223. if (this.isSortFlag == 0) {
  224. ajaxData.orderBy = 'xvfp.scan_vin_date desc,xp.code asc';
  225. } else if (this.isSortFlag == 1) {
  226. ajaxData.orderBy = 'xvfp.in_stock_count desc,xp.code asc';
  227. } else {
  228. ajaxData.orderBy = 'xvfp.not_stock_count desc,xp.code asc';
  229. }
  230. this.loadData(ajaxData);
  231. } else {
  232. this.status = 'nomore';
  233. }
  234. }
  235. };
  236. </script>
  237. <style lang="less" scoped>
  238. .modal-box {
  239. background: #ffffff;
  240. padding: 20rpx;
  241. width: 100%;
  242. .searchBox {
  243. width: 100%;
  244. display: flex;
  245. align-items: center;
  246. .searchBox_l {
  247. width: 80%;
  248. border: 1rpx solid #e0e0e0;
  249. border-radius: 36rpx;
  250. box-sizing: border-box;
  251. }
  252. .searchBox_r {
  253. width: 19%;
  254. color: #666666;
  255. text-align: right;
  256. text {
  257. margin-right: 10rpx;
  258. }
  259. }
  260. }
  261. .listBox {
  262. width: 100%;
  263. display: flex;
  264. padding: 30rpx 0;
  265. border-bottom: 1rpx solid #e0e0e0;
  266. .listBox_l {
  267. width: 150rpx;
  268. height: 150rpx;
  269. overflow: hidden;
  270. border-radius: 20rpx;
  271. margin-right: 20rpx;
  272. image {
  273. width: 100%;
  274. height: 100%;
  275. }
  276. }
  277. .listBox_r {
  278. width: calc(100% - 170rpx);
  279. .type {
  280. color: #222;
  281. font-size: 32rpx;
  282. }
  283. .tit {
  284. margin: 10rpx 0;
  285. overflow: hidden;
  286. text-overflow: ellipsis;
  287. display: -webkit-box;
  288. -webkit-line-clamp: 1;
  289. -webkit-box-orient: vertical;
  290. }
  291. .bot {
  292. width: 100%;
  293. view {
  294. &:first-child {
  295. color: #999;
  296. text {
  297. color: green;
  298. margin: 0 10rpx;
  299. }
  300. }
  301. &:last-child {
  302. color: #999;
  303. text {
  304. color: red;
  305. margin: 0 10rpx;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. }
  312. // 弹窗样式
  313. .sortPopup {
  314. padding: 30rpx 20rpx;
  315. box-sizing: border-box;
  316. .sortList {
  317. width: 100%;
  318. height: 70rpx;
  319. text-align: center;
  320. line-height: 70rpx;
  321. border-radius: 60rpx;
  322. color: #333;
  323. margin-bottom: 30rpx;
  324. font-size: 26rpx;
  325. border: 1rpx solid #e0e0e0;
  326. }
  327. .butBox {
  328. margin-top: 100rpx;
  329. }
  330. .sortChecked {
  331. background-color: rgb(0, 122, 255);
  332. color: #ffffff;
  333. }
  334. }
  335. .emptyStyle {
  336. margin-top: 280rpx;
  337. }
  338. .u-size-medium {
  339. padding: 0 60rpx !important;
  340. }
  341. }
  342. </style>