fitProductlist.vue 8.7 KB

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