fitProductlist.vue 8.1 KB

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