spare-store.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466
  1. <template>
  2. <view>
  3. <view class="u-wrap">
  4. <view class="fixed-box">
  5. <!-- 搜索 -->
  6. <view class="d-flex a-center mt-3 search ">
  7. <view class="pl-3 flex1">
  8. <u-input v-model="keyword" placeholder="名称/规格/原厂编号" :clearable="false" />
  9. </view>
  10. <view @click="search" class="main-linear d-flex a-center text-color-white f-size-26 j-center search-txt">
  11. 搜索</view>
  12. </view>
  13. <!-- 筛选 -->
  14. <view class="d-flex j-end a-center flex1 my3 screen-box">
  15. <view class="ml-3 line1" style="" @click="handleScreen">
  16. <text style="color: #535B67;">类型筛选</text>
  17. <image src="/static/images/select.png" class="ml-1 w20"></image>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="page-view">
  22. <view class="class-item">
  23. <view class="item-container">
  24. <!-- 列表 -->
  25. <view class="d-flex list-box border-radius-3 p3 mb-2" v-for="item in listData" :key="item.id">
  26. <view class="left d-flex j-center a-center mr-2">
  27. <image v-if="item.image" :src="$BaseTool.UserUtil.getFileUrl(item.image)" class="bg-color-light img"></image>
  28. <image v-else :src="spare_default" class="bg-color-light img"></image>
  29. </view>
  30. <view class="right d-flex f-column flex1">
  31. <view class="f-size-30 f-weight-6 one-ellipsis">{{ item.name }}</view>
  32. <view class="f-size-22 text-color-9 my2 one-ellipsis">
  33. {{ item.no }} / {{ item.ggxh }}
  34. </view>
  35. <view class="f-size-20 ">
  36. <text class="main-color-text mr-1 list-box-item">{{ selectTypeName }}</text>
  37. </view>
  38. <view class="d-flex j-between a-center mt-1 text-color-6">
  39. <text>单价:¥{{ $BaseTool.Amount.formatter(item.initialValue) }} </text>
  40. <text>当前库存:{{ item.num }} </text>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <!-- 弹出层 -->
  48. <u-popup v-model="show" mode="right" width="600rpx" safe-area-inset-bottom>
  49. <view class="mx2 py3 popup" style="padding-bottom: 120rpx;">
  50. <view class="wrap">
  51. <view class="f-size-30 f-weight-6 py3">一级类别</view>
  52. <view class="d-flex f-wrap a-center box">
  53. <block v-for="item in parentTypeList" :key="item.id">
  54. <view class="col3">
  55. <view class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelect(item)" :class="active == item.id?&quot;item_s&quot;:&quot;&quot;">{{ item.name }}
  56. </view>
  57. </view>
  58. </block>
  59. </view>
  60. </view>
  61. <view class="wrap">
  62. <view class="f-size-30 f-weight-6 py3">二级类别</view>
  63. <view class="d-flex f-wrap a-center box">
  64. <block v-for="item in middleTypeList" :key="item.id">
  65. <view class="col3">
  66. <view class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelectTwo(item)" :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 class="d-flex j-center a-center border-radius-1 mb-2 py1 item f-size-22" @click="handleSelectThree(item)" :class="activeThree == item.id?&quot;item_s&quot;:&quot;&quot;">
  78. {{ item.name }}</view>
  79. </view>
  80. </block>
  81. </view>
  82. </view>
  83. <!-- 按钮 -->
  84. <view class="d-flex j-around a-center p-fixed left0 right0 bottom0 bg-color-white py2 button-box">
  85. <view @click="resetSelect()" class="main-color-text d-flex a-center j-center f-size-30" style="">重置</view>
  86. <view @click="search()" class="main-linear text-color-white d-flex a-center j-center f-size-30">确认</view>
  87. </view>
  88. </view>
  89. </u-popup>
  90. </view>
  91. </view>
  92. </template>
  93. <script>
  94. import spareDefault from '@/static/images/spare_default.png'
  95. export default {
  96. data() {
  97. return {
  98. goods: [],
  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: spareDefault,
  116. parentTypeList: [],
  117. middleTypeList: [],
  118. childTypeList: [],
  119. storeId: null,
  120. spareId: null,
  121. spareName: null,
  122. price: 0,
  123. num: 0,
  124. loadMore: true,
  125. show: false
  126. }
  127. },
  128. onLoad(option) {
  129. // this.storeId = JSON.parse(decodeURIComponent(option.storeId))
  130. if (this.parentTypeList.length == 0) {
  131. this.$Http
  132. .querySpareType({
  133. filter: 1
  134. })
  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. .getSpareBomRecordPage({
  169. pageNum: that.page,
  170. pageSize: that.limit,
  171. typeId: that.typeId,
  172. keyword: that.keyword,
  173. dataScope: {
  174. sortBy: 'desc',
  175. sortName: 'bom.created_time'
  176. }
  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. })
  190. },
  191. handleSelect(item) {
  192. this.active = item.id
  193. this.parentTypeId = item.id
  194. this.parentTypeName = item.name
  195. this.selectTypeName = this.parentTypeName
  196. this.typeId = item.id
  197. this.$Http
  198. .querySpareType({
  199. filter: 2,
  200. parentId: item.id,
  201. dataScope: {
  202. sortBy: 'desc',
  203. sortName: 'name'
  204. }
  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.typeId = item.id
  219. this.$Http
  220. .querySpareType({
  221. filter: 2,
  222. parentId: item.id,
  223. dataScope: {
  224. sortBy: 'desc',
  225. sortName: 'name'
  226. }
  227. })
  228. .then(res => {
  229. this.childTypeList = res.data
  230. })
  231. },
  232. handleSelectThree(item) {
  233. this.activeThree = item.id
  234. this.childTypeId = item.id
  235. this.childTypeName = item.name
  236. this.selectTypeName = this.childTypeName
  237. this.typeId = item.id
  238. },
  239. search() {
  240. this.page = 1
  241. this.show = false
  242. this.loadMore = true
  243. this.listData = []
  244. this.initData()
  245. },
  246. resetSelect() {
  247. this.parentTypeId = ''
  248. this.middleTypeId = ''
  249. this.childTypeId = ''
  250. this.parentTypeName = ''
  251. this.middleTypeName = ''
  252. this.childTypeName = ''
  253. this.typeId = ''
  254. this.active = 0
  255. this.activeTwo = 0
  256. this.activeThree = 0
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .fixed-box {
  263. position: fixed;
  264. left: 0;
  265. right: 0;
  266. background-color: #fff;
  267. padding: 0 16px;
  268. z-index: 1000;
  269. }
  270. .u-wrap {
  271. .list-box {
  272. box-shadow: 5rpx 5rpx 10rpx rgba(0, 0, 0, 0.2);
  273. width: 100%;
  274. .img {
  275. width: 120rpx;
  276. height: 120rpx;
  277. border-radius: 50%;
  278. }
  279. &-item {
  280. padding: 2rpx 15rpx;
  281. border-radius: 10rpx;
  282. background-color: #ffeae5;
  283. color: #fa5445;
  284. }
  285. }
  286. .search {
  287. border-radius: 50rpx;
  288. height: 70rpx;
  289. width: 100%;
  290. border: 1px solid #0082ff;
  291. &-txt {
  292. height: 70rpx;
  293. border-radius: 50rpx;
  294. width: 120rpx;
  295. }
  296. }
  297. .screen-box {
  298. .line1 {
  299. background-color: #f2f3f4;
  300. padding: 3rpx 20rpx;
  301. border-radius: 10rpx;
  302. }
  303. .w20 {
  304. width: 20rpx;
  305. height: 16rpx;
  306. }
  307. }
  308. }
  309. .u-wrap {
  310. height: calc(100vh);
  311. /* #ifdef H5 */
  312. height: calc(100vh - var(--window-top));
  313. /* #endif */
  314. display: flex;
  315. flex-direction: column;
  316. }
  317. .u-search-box {
  318. padding: 18rpx 30rpx;
  319. }
  320. .u-menu-wrap {
  321. flex: 1;
  322. display: flex;
  323. overflow: hidden;
  324. }
  325. .u-search-inner {
  326. background-color: rgb(234, 234, 234);
  327. border-radius: 100rpx;
  328. display: flex;
  329. align-items: center;
  330. padding: 10rpx 16rpx;
  331. }
  332. .u-search-text {
  333. font-size: 26rpx;
  334. color: $u-tips-color;
  335. margin-left: 10rpx;
  336. }
  337. .u-tab-view {
  338. width: 200rpx;
  339. height: 100%;
  340. }
  341. .u-tab-item {
  342. height: 110rpx;
  343. background: #f6f6f6;
  344. box-sizing: border-box;
  345. display: flex;
  346. align-items: center;
  347. justify-content: center;
  348. font-size: 26rpx;
  349. color: #444;
  350. font-weight: 400;
  351. line-height: 1;
  352. }
  353. .u-tab-item-active {
  354. position: relative;
  355. color: #000;
  356. font-size: 30rpx;
  357. font-weight: 600;
  358. background: #fff;
  359. }
  360. .u-tab-view {
  361. height: 100%;
  362. }
  363. .right-box {
  364. background-color: rgb(250, 250, 250);
  365. }
  366. .page-view {
  367. margin-top: 90px;
  368. padding: 16rpx;
  369. }
  370. .class-item {
  371. margin-bottom: 30rpx;
  372. background-color: #fff;
  373. padding: 16rpx;
  374. border-radius: 8rpx;
  375. }
  376. .item-title {
  377. font-size: 26rpx;
  378. color: $u-main-color;
  379. font-weight: bold;
  380. }
  381. .item-menu-name {
  382. font-weight: normal;
  383. font-size: 24rpx;
  384. color: $u-main-color;
  385. }
  386. .item-container {
  387. display: flex;
  388. flex-wrap: wrap;
  389. }
  390. .thumb-box {
  391. width: 33.333333%;
  392. display: flex;
  393. align-items: center;
  394. justify-content: center;
  395. flex-direction: column;
  396. margin-top: 20rpx;
  397. }
  398. .item-menu-image {
  399. width: 120rpx;
  400. height: 120rpx;
  401. }
  402. .main-linear {
  403. background-color: #0082ff;
  404. }
  405. .popup {
  406. .button-box {
  407. view {
  408. width: 230rpx;
  409. height: 80rpx;
  410. border-radius: 50rpx;
  411. }
  412. view.main-color-text {
  413. border: 1px solid #0082ff;
  414. color: #0082ff;
  415. }
  416. }
  417. .box {
  418. .item {
  419. width: 90%;
  420. background-color: #f2f3f4;
  421. color: #0f1021;
  422. height: 70rpx;
  423. }
  424. .item_s {
  425. width: 90%;
  426. background-color: #0082ff;
  427. color: #ffffff;
  428. height: 70rpx;
  429. }
  430. }
  431. }
  432. </style>