spare-search-goods.vue 12 KB

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