fitProductlist.vue 8.5 KB

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