moreShelfProduct.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="moreShelfPart flex flex_column">
  3. <view class="moreShelfPart-search">
  4. <u-search
  5. placeholder="请输入关键字查询"
  6. v-model="queryWord"
  7. :show-action="isGobleSearch"
  8. @focus="isGobleSearch=true"
  9. @blur="searchPart"
  10. @custom="searchPart"
  11. @search="searchPart"
  12. @clear="searchPart"
  13. :action-style="{'color': '#fff', 'font-size': '24upx', 'background-color': '#57a3f3', 'border-radius': '6upx', 'padding': '12upx 0'}">
  14. </u-search>
  15. </view>
  16. <view class="moreShelfPart-body">
  17. <scroll-view
  18. class="nav-right"
  19. scroll-y
  20. @scrolltolower="onreachBottom">
  21. <!-- vin适配配件 -->
  22. <view>
  23. <view class="nav-right-title">该车适配</view>
  24. <view class="nav-right-item" v-for="(item, index) in vinPartList" :key="item.id">
  25. <view class="uni-col-2">
  26. <u-image :src="item.images+'?x-oss-process=image/resize,m_fixed,h_120,w_120,color_ffffff'" @click="viewImg(item)" border-radius="30" width="120" height="120" bg-color="#EBEBEB" ></u-image>
  27. </view>
  28. <view class="item-info uni-col-10">
  29. <view class="item-name">
  30. <text>{{item.name}}</text>
  31. </view>
  32. <view class="item-detail">
  33. <view class="nav-right-item-btns flex align_center justify_between">
  34. <view>
  35. <text class="item-detail-text">{{item.code}}</text>
  36. </view>
  37. <view>
  38. <u-button :throttle-time="100" class="item-btn" v-if="!item.checked" type="primary" :style="{background:'#1283d4'}" shape="circle" size="mini" @click="choosePart(item)">选择</u-button>
  39. <u-button :throttle-time="100" class="item-btn" v-else type="success" shape="circle" size="mini" @click="choosePart(item,0)">已选择</u-button>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. <view v-if="vinPartList&&vinPartList.length==0">
  46. <u-empty v-if="vinstatus!='loading'" :src="`/static/nodata.png`" icon-size="120" text="暂无配件" mode="list" :margin-top="30"></u-empty>
  47. </view>
  48. <view style="padding: 20upx;" v-if="vinstatus=='loading'" >
  49. <u-loadmore :status="vinstatus" />
  50. </view>
  51. </view>
  52. <!-- 其它配件 -->
  53. <view class="nav-right-title" style="margin-top: 20rpx;">其它配件</view>
  54. <view class="nav-right-item" v-for="(item, index) in partList" :key="item.id">
  55. <view class="uni-col-2">
  56. <u-image :src="item.images+'?x-oss-process=image/resize,m_fixed,h_120,w_120,color_ffffff'" @click="viewImg(item)" border-radius="30" width="120" height="120" bg-color="#EBEBEB" ></u-image>
  57. </view>
  58. <view class="item-info uni-col-10">
  59. <view class="item-name">
  60. <text>{{item.name}}</text>
  61. </view>
  62. <view class="item-detail">
  63. <view class="nav-right-item-btns flex align_center justify_between">
  64. <view>
  65. <text class="item-detail-text">{{item.code}}</text>
  66. </view>
  67. <view>
  68. <u-button :throttle-time="100" class="item-btn" v-if="!item.checked" type="primary" :style="{background:'#1283d4'}" shape="circle" size="mini" @click="choosePart(item)">选择</u-button>
  69. <u-button :throttle-time="100" class="item-btn" v-else type="success" shape="circle" size="mini" @click="choosePart(item,1)">已选择</u-button>
  70. </view>
  71. </view>
  72. </view>
  73. </view>
  74. </view>
  75. <view v-if="partList&&partList.length==0">
  76. <u-empty v-if="status!='loading'" :src="`/static/nodata.png`" icon-size="240" :text="noDataText" mode="list" :margin-top="50"></u-empty>
  77. </view>
  78. <view style="padding: 20upx;" v-if="total>pageSize || status=='loading'">
  79. <u-loadmore :status="status" />
  80. </view>
  81. </scroll-view>
  82. </view>
  83. <view class="moreShelfPart-footer">
  84. 您可以选择更多数字货架上暂时没有库存的配件进行临配
  85. </view>
  86. </view>
  87. </template>
  88. <script>
  89. import { getShelfProductList, getShelfProductType, queryPartCodeByVin, getShelfQueryList } from '@/api/shelf'
  90. export default {
  91. data() {
  92. return {
  93. queryWord: '',
  94. isGobleSearch: false,
  95. vinPartList: [],
  96. partList: [],
  97. pageNo:1,
  98. pageSize: 10,
  99. vinCode: [],
  100. vinNumber: '',
  101. total: 0, // 列表总数
  102. noDataText: '暂无配件',
  103. status: 'loading',
  104. vinstatus: 'loading'
  105. }
  106. },
  107. onLoad(opts) {
  108. this.vinNumber = opts.vinNumber
  109. if(this.vinNumber){
  110. this.getCarCodeByVin()
  111. }else{
  112. this.vinstatus = 'nomore'
  113. this.getShelfProductList()
  114. }
  115. },
  116. methods: {
  117. viewImg(item){
  118. uni.previewImage({
  119. urls: [item.images]
  120. })
  121. },
  122. clearSearch(){
  123. this.queryWord = ''
  124. this.pageNo = 1
  125. this.partList = []
  126. },
  127. // 搜索配件
  128. searchPart(){
  129. this.getShelfProductList()
  130. },
  131. getCarCodeByVin(){
  132. queryPartCodeByVin({vinNumber:this.vinNumber}).then(res => {
  133. console.log(res,'this.vinCode')
  134. if(res.status == 200){
  135. this.vinCode = res.data
  136. this.getVinShelfPartList()
  137. this.getShelfProductList()
  138. }
  139. })
  140. },
  141. // 根据客户vin查询该车可用数字货架中的配件
  142. getVinShelfPartList(){
  143. let params = {
  144. queryWord: this.queryWord,
  145. partsClsId: '',
  146. vin: this.vinNumber,
  147. codeList: this.vinCode,
  148. currentInven:0
  149. }
  150. this.vinstatus = 'loading'
  151. getShelfQueryList(params).then(res => {
  152. console.log(res,'getVinShelfPartList')
  153. this.vinPartList = res.data.length ? this.fiterChecked(res.data) : []
  154. this.vinstatus = 'nomore'
  155. })
  156. },
  157. // 获取数字货架配件列表
  158. getShelfProductList(){
  159. const _this = this
  160. let params = {
  161. pageNo: this.pageNo,
  162. pageSize: this.pageSize,
  163. excludeCodeList: this.vinCode,
  164. queryWord: this.queryWord,
  165. currentInven:0
  166. }
  167. console.log(params)
  168. _this.status = 'loading'
  169. getShelfProductList(params).then(res => {
  170. uni.hideLoading()
  171. console.log(res,'获取数字货架配件列表')
  172. if(res.status == 200){
  173. let list = res.data.list
  174. console.log(list)
  175. if (list && list.length>0){
  176. // 分页 拼接数据
  177. if (_this.pageNo != 1) {
  178. _this.partList = _this.partList ? _this.partList.concat(this.fiterChecked(list)) : this.fiterChecked(list)
  179. } else {
  180. _this.partList = this.fiterChecked(list)
  181. }
  182. this.total = res.data.count
  183. console.log(_this.status)
  184. if (_this.partList.length == res.data.count) {
  185. _this.status = 'nomore'
  186. } else {
  187. _this.status = 'loadmore'
  188. }
  189. console.log(_this.status)
  190. } else {
  191. console.log(_this.status)
  192. _this.partList = list || []
  193. this.total = 0
  194. _this.status = 'nomore'
  195. }
  196. console.log(_this.status)
  197. _this.noDataText = '暂无配件'
  198. }else{
  199. _this.status = 'loadmore'
  200. _this.partList = []
  201. _this.total = 0
  202. _this.noDataText = res.message ? res.message : '网络似乎出错了,请稍后再试'
  203. }
  204. })
  205. },
  206. // 加载更多
  207. onreachBottom () {
  208. if(this.partList.length < this.total ){
  209. if(this.isGobleSearch&&this.queryWord==''){
  210. return
  211. }
  212. this.pageNo++
  213. this.getShelfProductList()
  214. }else{
  215. this.status = "nomore"
  216. }
  217. },
  218. // 过滤已选择的
  219. fiterChecked (list){
  220. this.$store.state.vuex_shelfChoosePart.map(item => {
  221. let p = list.find(k => {
  222. return k.productSn == item.productSn
  223. })
  224. if(p){
  225. p.checked = true
  226. }
  227. })
  228. return list
  229. },
  230. // 对比已选择项目
  231. hasChecked (row){
  232. let b = this.$store.state.vuex_shelfChoosePart
  233. let has = b.findIndex(item => {
  234. return item.productSn && item.productSn == row.productSn
  235. })
  236. return has
  237. },
  238. // 选择配件
  239. choosePart(item,type){
  240. const hs = this.hasChecked(item)
  241. const b = this.$store.state.vuex_shelfChoosePart
  242. // 取消选择
  243. if(hs>=0){
  244. item.checked = false
  245. b.splice(hs,1)
  246. }else{
  247. item.checked = true
  248. item.qty = 1
  249. b.push(item)
  250. }
  251. if(type==0){
  252. this.vinPartList.splice()
  253. }else{
  254. this.partList.splice()
  255. }
  256. }
  257. }
  258. }
  259. </script>
  260. <style lang="less">
  261. .moreShelfPart{
  262. height: 100vh;
  263. .moreShelfPart-search{
  264. padding: 20rpx;
  265. }
  266. .moreShelfPart-body{
  267. flex-grow: 1;
  268. background-color: #fff;
  269. }
  270. .moreShelfPart-footer{
  271. padding: 20rpx;
  272. color: #191919;
  273. font-size: 26rpx;
  274. text-align: center;
  275. }
  276. .nav-right{
  277. padding: 0 30upx;
  278. height: calc(100vh - 180rpx);
  279. box-sizing: border-box;
  280. .nav-right-title{
  281. font-weight: bold;
  282. font-size: 32upx;
  283. padding: 10rpx 0;
  284. }
  285. .nav-right-item{
  286. padding: 10upx;
  287. border-bottom: 2rpx solid #f5f5f5;
  288. display: flex;
  289. .item-info{
  290. padding-left: 20rpx;
  291. .item-name{
  292. font-size: 32upx;
  293. display: flex;
  294. align-items: center;
  295. >image{
  296. width: 38rpx;
  297. height: 38rpx;
  298. margin-right: 10rpx;
  299. }
  300. >text{
  301. flex: 1;
  302. word-break: break-all;
  303. }
  304. }
  305. .item-detail{
  306. .item-detail-info{
  307. padding: 10upx 0 4upx;
  308. }
  309. .item-detail-text{
  310. font-size: 24upx;
  311. color: #999;
  312. margin-right: 20upx;
  313. word-break: break-all;
  314. }
  315. .item-price{
  316. margin-top: 10upx;
  317. .item-detail-text{
  318. color: #333;
  319. }
  320. }
  321. .nav-right-item-btns{
  322. text-align: right;
  323. margin-top: 10rpx;
  324. > view{
  325. &:first-child{
  326. .item-btn {
  327. margin-right: 10upx;
  328. width: auto;
  329. }
  330. }
  331. &:last-child{
  332. .item-btn {
  333. margin-left: 10upx;
  334. }
  335. }
  336. }
  337. .item-btn-icon{
  338. margin-left: 30upx;
  339. vertical-align: middle;
  340. }
  341. .item-btn {
  342. width: 112upx;
  343. &:after{
  344. border-color: #aaa;
  345. }
  346. }
  347. .item-btn.btn-unselected{
  348. background-color: #2db7f5!important;;
  349. border-color: #2db7f5!important;;
  350. }
  351. .item-btn.btn-selected{
  352. background-color: #19be6b!important;;
  353. border-color: #19be6b!important;
  354. }
  355. }
  356. }
  357. }
  358. .item-btn{
  359. margin: 0;
  360. width: 112upx;
  361. color: #fff;
  362. }
  363. .item-btn.btn-unselected{
  364. background-color: #2db7f5!important;;
  365. border-color: #2db7f5!important;;
  366. }
  367. .item-btn.btn-selected{
  368. background-color: #19be6b!important;;
  369. border-color: #19be6b!important;
  370. }
  371. }
  372. }
  373. }
  374. </style>