spare-search.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="u-wrap">
  3. <view class="fixed-box">
  4. <!-- 搜索 -->
  5. <view class="d-flex a-center mt-3 search ">
  6. <view class="pl-3 flex1">
  7. <u-input v-model="keyword" placeholder="名称/规格/原厂编号" :clearable="false" />
  8. </view>
  9. <view @click="search" class="main-linear d-flex a-center text-color-white f-size-26 j-center search-txt">
  10. 搜索</view>
  11. </view>
  12. <!-- 筛选 -->
  13. <view class="d-flex j-end a-center flex1 my3 screen-box">
  14. <view class="ml-3 line1" style="" @click="handleScreen">
  15. <text style="color: #535B67;">类型筛选</text>
  16. <image src="/static/images/select.png" class="ml-1 w20"></image>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="page-view">
  21. <view class="class-item">
  22. <view class="item-container">
  23. <!-- 列表 -->
  24. <view @click="handleBack(item)" class="d-flex list-box border-radius-3 p3 mb-2" v-for="item in listData" :key="item.id">
  25. <view class="left d-flex j-center a-center mr-2">
  26. <image :src="item.image" class="bg-color-light img"></image>
  27. </view>
  28. <view class="right d-flex f-column">
  29. <view class="f-size-30 f-weight-6 one-ellipsis">{{ item.spareName }}</view>
  30. <view class="f-size-22 text-color-9 my2 one-ellipsis">
  31. {{ item.no }} / {{ item.ggxh }} / {{ item.num }}
  32. </view>
  33. <view class="f-size-20 ">
  34. <text class="main-color-text mr-1 list-box-item">{{ selectTypeName }}</text>
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. <!-- 弹出层 -->
  42. <u-popup v-model="show" mode="right" width="600rpx" safe-area-inset-bottom>
  43. <view class="mx2 py3 popup" style="padding-bottom: 120rpx;">
  44. <view class="wrap">
  45. <view class="f-size-30 f-weight-6 py3">一级类别</view>
  46. <view class="d-flex f-wrap a-center box">
  47. <block v-for="item in parentTypeList" :key="item.id">
  48. <view class="col3">
  49. <view
  50. class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22"
  51. @click="handleSelect(item)"
  52. :class="active == item.id?&quot;item_s&quot;:&quot;&quot;">{{ item.name }}
  53. </view>
  54. </view>
  55. </block>
  56. </view>
  57. </view>
  58. <view class="wrap">
  59. <view class="f-size-30 f-weight-6 py3">二级类别</view>
  60. <view class="d-flex f-wrap a-center box">
  61. <block v-for="item in middleTypeList" :key="item.id">
  62. <view class="col3">
  63. <view
  64. class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22"
  65. @click="handleSelectTwo(item)"
  66. :class="activeTwo == item.id?&quot;item_s&quot;:&quot;&quot;">
  67. {{ item.name }}</view>
  68. </view>
  69. </block>
  70. </view>
  71. </view>
  72. <view class="wrap">
  73. <view v-if="childTypeList.length > 0" class="f-size-30 f-weight-6 py3">三级类别</view>
  74. <view class="d-flex f-wrap a-center box">
  75. <block v-for="item in childTypeList" :key="item.id">
  76. <view class="col3">
  77. <view
  78. class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22"
  79. @click="handleSelectThree(item)"
  80. :class="activeThree == item.id?&quot;item_s&quot;:&quot;&quot;">
  81. {{ item.name }}</view>
  82. </view>
  83. </block>
  84. </view>
  85. </view>
  86. <!-- 按钮 -->
  87. <view class="d-flex j-around a-center p-fixed left0 right0 bottom0 bg-color-white py2 button-box">
  88. <view @click="resetSelect()" class="main-color-text d-flex a-center j-center f-size-30" style="">重置</view>
  89. <view @click="search()"class="main-linear text-color-white d-flex a-center j-center f-size-30">确认</view>
  90. </view>
  91. </view>
  92. </u-popup>
  93. </view>
  94. </template>
  95. <script>
  96. export default {
  97. data() {
  98. return {
  99. keyword: '',
  100. selectTypeName: '',
  101. listData: [],
  102. status: 'loadmore',
  103. page: 1,
  104. active: 0,
  105. activeTwo: 0,
  106. activeThree: 0,
  107. limit: 20,
  108. parentTypeId: '',
  109. middleTypeId: '',
  110. childTypeId: '',
  111. parentTypeName: '',
  112. middleTypeName: '',
  113. childTypeName: '',
  114. typeId: '',
  115. spare_default: '/static/images/spare_default.png',
  116. parentTypeList: [],
  117. middleTypeList: [],
  118. childTypeList: [],
  119. storeId: null,
  120. spareId: null,
  121. spareName: null,
  122. formName: null,
  123. price: 0,
  124. num: 0,
  125. loadMore: true,
  126. show: false
  127. }
  128. },
  129. onLoad(option) {
  130. this.storeId = JSON.parse(decodeURIComponent(option.storeId))
  131. this.formName = JSON.parse(decodeURIComponent(option.formName))
  132. if (this.parentTypeList.length == 0) {
  133. this.$Http.querySpareType({
  134. filter: 1
  135. }).then(res => {
  136. this.parentTypeList = res.data
  137. this.parentTypeId = this.parentTypeList[0].id
  138. this.selectTypeName = this.parentTypeList[0].name
  139. this.initData()
  140. })
  141. }
  142. },
  143. onPullDownRefresh() {
  144. // 请求结束取消刷新
  145. this.page = 1;
  146. this.loadMore = true;
  147. this.listData = [];
  148. this.initData();
  149. uni.stopPullDownRefresh();
  150. },
  151. onReachBottom() {
  152. if (this.loadMore) {
  153. this.page++;
  154. this.initData();
  155. }
  156. },
  157. methods: {
  158. /* handleSelect(item) {
  159. item.selected = !item.selected
  160. }, */
  161. handleScreen() {
  162. this.show = true
  163. },
  164. initData() {
  165. const that = this
  166. that.status = 'loading'
  167. this.$Http
  168. .getSpareStorePage({
  169. pageNum: that.page,
  170. pageSize: that.limit,
  171. num: that.num,
  172. storeId: that.storeId,
  173. parentTypeId: that.parentTypeId,
  174. middleTypeId: that.middleTypeId,
  175. childTypeId: that.childTypeId,
  176. keyword: that.keyword
  177. })
  178. .then((res) => {
  179. const data = res.data.rows;
  180. if (data && data.length > 0 && data.length < that.limit) {
  181. that.status = 'nomore';
  182. that.loadMore = false;
  183. } else if (data.length == that.limit) {
  184. that.status = 'loadmore';
  185. } else {
  186. that.status = 'nomore';
  187. }
  188. that.listData = data;
  189. that.listData.forEach(item => {
  190. item.image = (item.image == null ? that.spare_default : item.image)
  191. })
  192. })
  193. },
  194. handleSelect(item) {
  195. this.active = item.id
  196. this.parentTypeId = item.id
  197. this.parentTypeName = item.name
  198. this.selectTypeName = this.parentTypeName
  199. this.$Http.querySpareType({
  200. filter: 2,
  201. parentId: item.id,
  202. dataScope: {
  203. sortBy: 'desc',
  204. sortName: 'name'
  205. }
  206. }).then(res => {
  207. this.middleTypeList = res.data
  208. this.middleTypeId = null
  209. this.activeTwo = 0
  210. this.childTypeList = []
  211. })
  212. },
  213. handleSelectTwo(item) {
  214. this.activeTwo = item.id
  215. this.middleTypeId = item.id
  216. this.middleTypeName = item.name
  217. this.selectTypeName = this.middleTypeName
  218. this.$Http.querySpareType({
  219. filter: 2,
  220. parentId: item.id,
  221. dataScope: {
  222. sortBy: 'desc',
  223. sortName: 'name'
  224. }
  225. }).then(res => {
  226. this.childTypeList = res.data
  227. })
  228. },
  229. handleSelectThree(item) {
  230. this.activeThree = item.id
  231. this.childTypeId = item.id
  232. this.childTypeName = item.name
  233. this.selectTypeName = this.childTypeName
  234. },
  235. search() {
  236. this.page = 1;
  237. this.show = false
  238. this.loadMore = true;
  239. this.listData = [];
  240. this.initData();
  241. },
  242. resetSelect() {
  243. this.parentTypeId = ''
  244. this.middleTypeId = ''
  245. this.childTypeId = ''
  246. this.parentTypeName = ''
  247. this.middleTypeName = ''
  248. this.childTypeName = ''
  249. this.active = 0
  250. this.activeTwo = 0
  251. this.activeThree = 0
  252. },
  253. handleBack(item) {
  254. const that = this;
  255. uni.showModal({
  256. title: '提示',
  257. content: '确认选择?',
  258. success: function (res) {
  259. if (res.confirm) {
  260. that.spareId = item.spareId
  261. that.price = item.price
  262. that.spareName = item.spareName + '--' + item.ggxh + '--' + item.num
  263. const pages = getCurrentPages();
  264. const prevPage = pages[pages.length - 2];
  265. console.log('prevPage: ' + prevPage)
  266. prevPage.backSpareId = that.spareId
  267. prevPage.backSpareName = that.spareName
  268. prevPage.backFormName = that.formName
  269. prevPage.backPrice = that.price
  270. uni.navigateBack(1)
  271. }
  272. }
  273. });
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. .fixed-box {
  280. position: fixed;
  281. left: 0;
  282. right: 0;
  283. background-color: #fff;
  284. padding: 0 16px;
  285. z-index: 1000;
  286. }
  287. .u-wrap {
  288. .list-box {
  289. box-shadow: 5rpx 5rpx 10rpx rgba(0, 0, 0, .2);
  290. width: 100%;
  291. .img {
  292. width: 120rpx;
  293. height: 120rpx;
  294. border-radius: 50%;
  295. }
  296. &-item {
  297. padding: 2rpx 15rpx;
  298. border-radius: 10rpx;
  299. background-color: #FFEAE5;
  300. color: #FA5445;
  301. }
  302. }
  303. .search {
  304. border-radius: 50rpx;
  305. height: 70rpx;
  306. width: 100%;
  307. border: 1px solid #0082ff;
  308. &-txt {
  309. height: 70rpx;
  310. border-radius: 50rpx;
  311. width: 120rpx;
  312. }
  313. }
  314. .screen-box {
  315. .line1 {
  316. background-color: #F2F3F4;
  317. padding: 3rpx 20rpx;
  318. border-radius: 10rpx;
  319. }
  320. .w20 {
  321. width: 20rpx;
  322. height: 16rpx;
  323. }
  324. }
  325. }
  326. .u-wrap {
  327. height: calc(100vh);
  328. /* #ifdef H5 */
  329. height: calc(100vh - var(--window-top));
  330. /* #endif */
  331. display: flex;
  332. flex-direction: column;
  333. }
  334. .u-search-box {
  335. padding: 18rpx 30rpx;
  336. }
  337. .u-menu-wrap {
  338. flex: 1;
  339. display: flex;
  340. overflow: hidden;
  341. }
  342. .u-search-inner {
  343. background-color: rgb(234, 234, 234);
  344. border-radius: 100rpx;
  345. display: flex;
  346. align-items: center;
  347. padding: 10rpx 16rpx;
  348. }
  349. .u-search-text {
  350. font-size: 26rpx;
  351. color: $u-tips-color;
  352. margin-left: 10rpx;
  353. }
  354. .u-tab-view {
  355. width: 200rpx;
  356. height: 100%;
  357. }
  358. .u-tab-item {
  359. height: 110rpx;
  360. background: #f6f6f6;
  361. box-sizing: border-box;
  362. display: flex;
  363. align-items: center;
  364. justify-content: center;
  365. font-size: 26rpx;
  366. color: #444;
  367. font-weight: 400;
  368. line-height: 1;
  369. }
  370. .u-tab-item-active {
  371. position: relative;
  372. color: #000;
  373. font-size: 30rpx;
  374. font-weight: 600;
  375. background: #fff;
  376. }
  377. .u-tab-view {
  378. height: 100%;
  379. }
  380. .right-box {
  381. background-color: rgb(250, 250, 250);
  382. }
  383. .page-view {
  384. margin-top: 90px;
  385. padding: 16rpx;
  386. }
  387. .class-item {
  388. margin-bottom: 30rpx;
  389. background-color: #fff;
  390. padding: 16rpx;
  391. border-radius: 8rpx;
  392. }
  393. .item-title {
  394. font-size: 26rpx;
  395. color: $u-main-color;
  396. font-weight: bold;
  397. }
  398. .item-menu-name {
  399. font-weight: normal;
  400. font-size: 24rpx;
  401. color: $u-main-color;
  402. }
  403. .item-container {
  404. display: flex;
  405. flex-wrap: wrap;
  406. }
  407. .thumb-box {
  408. width: 33.333333%;
  409. display: flex;
  410. align-items: center;
  411. justify-content: center;
  412. flex-direction: column;
  413. margin-top: 20rpx;
  414. }
  415. .item-menu-image {
  416. width: 120rpx;
  417. height: 120rpx;
  418. }
  419. .main-linear {
  420. background-color: #0082ff;
  421. }
  422. .popup {
  423. .button-box {
  424. view {
  425. width: 230rpx;
  426. height: 80rpx;
  427. border-radius: 50rpx;
  428. }
  429. view.main-color-text {
  430. border: 1px solid #0082ff;
  431. color: #0082ff;
  432. }
  433. }
  434. .box {
  435. .item {
  436. width: 90%;
  437. background-color: #f2f3f4;
  438. color: #0f1021;
  439. height: 70rpx;
  440. }
  441. .item_s {
  442. width: 90%;
  443. background-color: #0082ff;
  444. color: #FFFFFF;
  445. height: 70rpx;
  446. }
  447. }
  448. }
  449. </style>