chooseProduct.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="searchBar">
  4. <view class="p-title flex align_center">
  5. <text></text>
  6. <view class="shelfName">
  7. <view>{{nowData.shelfName}}</view>
  8. </view>
  9. <view class="screeningBox" @click="chooseShow = true">
  10. <text>滞销天数</text>
  11. <u-icon color="#0485F6" size="30" name="shaixuan" custom-prefix="iscm-icon"></u-icon>
  12. </view>
  13. </view>
  14. <view class="search flex align_center">
  15. <view class="input">
  16. <u-search
  17. v-model="keyword"
  18. @input="$u.debounce(getSearchCon, 800)"
  19. @search="getSearchCon"
  20. @custom="getSearchCon"
  21. @clear="clearSearch"
  22. bg-color="#fff"
  23. :show-action="false"
  24. placeholder="请输入产品编码或名称搜索"></u-search>
  25. </view>
  26. <view class="icon" @click="handleScanCode">
  27. <u-icon name="scan"></u-icon>
  28. </view>
  29. </view>
  30. </view>
  31. <view class="check-list">
  32. <productList ref="productList" noDataText="暂无产品" @allChecked="allCheckedCallback"></productList>
  33. </view>
  34. <!-- 底部栏 -->
  35. <view class="footer-bar flex align_center" v-if="partList.length">
  36. <view class="f-left">
  37. <u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
  38. </view>
  39. <view class="f-mid" @click="isDetailShow=!isDetailShow">
  40. <view>
  41. 已选<text>{{totalCategory}}</text>款产品
  42. </view>
  43. <view v-if="!isDetailShow">
  44. 查看明细 <u-icon name="arrow-up"></u-icon>
  45. </view>
  46. <view v-else>
  47. 关闭明细 <u-icon name="arrow-down"></u-icon>
  48. </view>
  49. </view>
  50. <view class="f-btns">
  51. <u-button size="medium" @click="submitOrder" :custom-style="customBtnStyle" shape="circle" type="primary" hover-class="none" >确定选择</u-button>
  52. </view>
  53. </view>
  54. <!-- 滞销天数弹窗 -->
  55. <u-popup v-model="chooseShow" mode="right" width="60%">
  56. <view class="choosePopup">
  57. <view class="chooseTit">滞销天数</view>
  58. <view class="chooseDay u-flex">
  59. <u-input v-model="queryParam.unsalableDaysBegin" input-align="center" placeholder="起始天数" type="number" />
  60. <text>至</text>
  61. <u-input v-model="queryParam.unsalableDaysEnd" input-align="center" placeholder="截止天数" type="number" />
  62. </view>
  63. <view class="butBox u-flex">
  64. <u-button hover-class="none" shape="circle" size="medium" @click="reset">重置</u-button>
  65. <u-button hover-class="none" :custom-style="customBtnStyle" size="medium" shape="circle" @click="handelFilter">查询</u-button>
  66. </view>
  67. </view>
  68. </u-popup>
  69. <!-- 详情弹窗 -->
  70. <u-popup v-model="isDetailShow" mode="bottom" :duration="0" height="800" border-radius="25" :closeable="true">
  71. <view class="head">
  72. 已选产品
  73. <text @click="clearChoose">清空列表</text>
  74. </view>
  75. <scroll-view scroll-y class="scroll-view" v-if="chooseList.length>0">
  76. <view class="partList-list-box" v-for="(item,index) in chooseList" :key="item.id">
  77. <view class="product flex align_center">
  78. <view class="uni-col-1" @click="delDetail(item,index)">
  79. <u-icon name="close-circle" color="#ff5500" size="35"></u-icon>
  80. </view>
  81. <view class="flex flex_1">
  82. <view class="pimgs">
  83. <u-image :src="item.productImageUrl?item.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="120" height="120" border-radius="10"></u-image>
  84. </view>
  85. <view class="pinfo">
  86. <view class="pname item-name">
  87. <text>{{item.shelfPlaceCode}}</text>
  88. {{item.productCode}}
  89. </view>
  90. <view class="productName u-line-2">
  91. {{item.productName}}
  92. </view>
  93. <view class="ptxt flex align_center justify_end">
  94. <view>
  95. 最大库容
  96. <text class="pnums">{{item.maxQty}}</text>
  97. </view>
  98. <view>
  99. /货架库存
  100. <text class="pnums">{{item.qty}}</text>
  101. </view>
  102. <view>
  103. /滞销
  104. <text class="pnums">{{!item.unsalableDays || (item.unsalableDays&&item.unsalableDays) == 0 ?'--天':item.unsalableDays}}</text>
  105. </view>
  106. </view>
  107. </view>
  108. </view>
  109. </view>
  110. <view class="ptools flex align_center">
  111. <view class="ptools_l u-flex">
  112. <view v-if="item.replenishBillQty && item.replenishBillQty!=0">
  113. 补货在途
  114. <text class="pnums">{{item.replenishBillQty}}</text>
  115. </view>
  116. <view v-if="item.recallBillQty && item.recallBillQty!=0">
  117. {{item.replenishBillQty && item.replenishBillQty!=0 ? '/':''}}调回在途
  118. <text class="pnums">{{item.recallBillQty}}</text>
  119. </view>
  120. </view>
  121. </view>
  122. </view>
  123. </scroll-view>
  124. <view style="margin-top:100rpx;" v-else>
  125. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="180" text="暂无选中产品"></u-empty>
  126. </view>
  127. </u-popup>
  128. </view>
  129. </template>
  130. <script>
  131. import { reportPage } from '@/api/vinLog';
  132. import productList from './productList.vue'
  133. import { controlQueryList,insert } from '@/api/shelf';
  134. export default {
  135. components: {
  136. productList
  137. },
  138. data() {
  139. return {
  140. nowData:null,
  141. keyword:'',
  142. noDataText: '暂无产品',
  143. partList: [],
  144. allChecked: false,
  145. customBtnStyle: { // 自定义按钮样式
  146. borderColor: this.$config('primaryColor'),
  147. backgroundColor: this.$config('primaryColor'),
  148. color: '#fff'
  149. },
  150. isDetailShow:false,//详情弹窗显示
  151. chooseList: [],
  152. chooseShow:false,
  153. queryParam: { // 查询条件
  154. shelfSn:undefined,
  155. productCode: undefined,
  156. productName: undefined,
  157. unsalableDaysBegin: undefined,
  158. unsalableDaysEnd: undefined,
  159. queryWord:undefined
  160. }
  161. }
  162. },
  163. onBackPress(e) {
  164. if((this.chooseShow || this.isDetailShow) && e.from == "backbutton") {
  165. this.chooseShow = false;
  166. this.isDetailShow= false
  167. return true;
  168. }
  169. },
  170. onLoad(opts) {
  171. this.nowData = JSON.parse(decodeURIComponent(opts.data));
  172. let ajaxData = {
  173. shelfSn: this.nowData.shelfSn
  174. };
  175. this.loadData(ajaxData);
  176. },
  177. onReady() {
  178. uni.setNavigationBarColor({
  179. frontColor: '#ffffff',
  180. backgroundColor: this.$config('primaryColor')
  181. })
  182. },
  183. computed: {
  184. totalCategory () {
  185. return this.chooseList.length
  186. },
  187. },
  188. methods: {
  189. // 单击全选
  190. allCheckeChange(e){
  191. this.$refs.productList.allSelect(e.value)
  192. const list = this.$refs.productList.getAllData()
  193. list.map(item => {
  194. this.allCheckedCallback(true,item)
  195. })
  196. if(!e.value && this.showCart){
  197. this.showCart = false
  198. }
  199. },
  200. // 选中事件
  201. allCheckedCallback(isAllChecked,row){
  202. console.log(isAllChecked,row)
  203. const has = this.chooseList.findIndex(k => k.id == row.id)
  204. // 在已选列表中
  205. if(has>=0){
  206. // 取消选中
  207. if(!row.checked){
  208. this.chooseList.splice(has,1)
  209. }
  210. }else{
  211. // 不在已选列表中,添加
  212. if(row.checked){
  213. this.chooseList.push(row)
  214. }
  215. }
  216. // 是否全选
  217. this.allChecked = isAllChecked
  218. },
  219. // 清空已选数据
  220. clearChoose(){
  221. this.chooseList = []
  222. this.allChecked = false
  223. if(this.$refs.productList){
  224. this.$refs.productList.allSelect(false)
  225. }
  226. },
  227. clearSearch(){
  228. // 重置
  229. this.keyword = ''
  230. this.changeSearch()
  231. },
  232. changeSearch(){
  233. let ajaxData = {
  234. shelfSn:this.nowData.shelfSn,
  235. productCode: undefined,
  236. productName: undefined,
  237. unsalableDaysBegin: undefined,
  238. unsalableDaysEnd: undefined,
  239. queryWord:undefined
  240. };
  241. this.queryParam = ajaxData;
  242. this.partList = []
  243. this.loadData(ajaxData)
  244. },
  245. // 重置
  246. reset() {
  247. let ajaxData = {
  248. shelfSn:this.nowData.shelfSn,
  249. productCode: undefined,
  250. productName: undefined,
  251. unsalableDaysBegin: undefined,
  252. unsalableDaysEnd: undefined,
  253. queryWord:undefined
  254. };
  255. this.queryParam = ajaxData;
  256. this.loadData(ajaxData);
  257. },
  258. handelFilter(){
  259. if(this.checkValueRange()){
  260. this.queryParam.shelfSn = this.nowData.shelfSn;
  261. this.chooseShow =false;
  262. this.loadData(this.queryParam);
  263. }
  264. },
  265. // 获取数字货架列表
  266. loadData(params) {
  267. const _this = this;
  268. uni.showLoading({
  269. mask:true,
  270. title:"正在加载..."
  271. })
  272. if(!this.keyword){
  273. params.queryWord = undefined
  274. }
  275. controlQueryList(params).then(res => {
  276. if (res.status == 200) {
  277. res.data.forEach(item=>{
  278. item.isChecked= false
  279. if(item.recallBillQty){
  280. item.confirmQty = item.qty - item.recallBillQty>0 ?item.qty - item.recallBillQty: 0;
  281. }else{
  282. item.confirmQty = item.qty
  283. }
  284. })
  285. _this.partList=res.data;
  286. }else{
  287. _this.partList =[]
  288. }
  289. //过滤之前选过的值
  290. if(_this.nowData.chooseKey && _this.nowData.chooseKey.length >0){
  291. _this.partList = _this.partList.filter(item => {
  292. const row = _this.nowData.chooseKey.findIndex(k => k == item.id)
  293. return !(row>=0)
  294. })
  295. }
  296. // 已选
  297. _this.partList.map(item => {
  298. const row = _this.chooseList.find(k => k.id == item.id)
  299. item.checked = !!row
  300. })
  301. this.$refs.productList.setData(_this.partList)
  302. setTimeout(()=>{
  303. uni.hideLoading()
  304. },_this.partList.length*30)
  305. });
  306. },
  307. // 提交
  308. submitOrder(){
  309. if(this.totalCategory){
  310. if(this.nowData.chooseKey && this.nowData.chooseKey.length>0){
  311. uni.$emit("chooseBackProduct",this.chooseList)
  312. uni.navigateBack()
  313. }else{
  314. this.$store.commit('setShuntBackList',this.chooseList);
  315. uni.redirectTo({
  316. url:'/pages/shuntBackManage/addBackOrder?shelfSn='+ this.nowData.shelfSn+'&shelfName='+this.nowData.shelfName
  317. })
  318. }
  319. }else{
  320. uni.showToast({
  321. icon: 'none',
  322. title: '请选择产品'
  323. })
  324. }
  325. },
  326. // 扫描
  327. handleScanCode(){
  328. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  329. this.mpaasScanModule.scan(
  330. {
  331. "scanMode":"Customized",
  332. "scanStyle":{
  333. "scanFrameSizePlus":{"width":250,"height":250},
  334. "scanFrameSize":200,
  335. "scanLight":"visible",
  336. "scanText":"对准条形码/二维码进行识别",
  337. "scanTitle":"扫码搜索货位产品",
  338. }
  339. },
  340. (result) => {
  341. if(result.scanStatus == 1){
  342. this.scanResult(result)
  343. }
  344. })
  345. },
  346. // 扫描结果
  347. scanResult(data){
  348. // 二维码
  349. if(data.scanType == 'QRCODE'){
  350. const ret = data.scanValue.split("&")
  351. this.queryParam.queryWord = ret[1] // 产品编码
  352. this.keyword= ret[1]
  353. }else{
  354. this.queryParam.queryWord = data.scanValue;
  355. this.keyword= data.scanValue
  356. }
  357. this.queryParam.shelfSn = this.nowData.shelfSn
  358. this.loadData(this.queryParam);
  359. },
  360. delDetail(con,pot){
  361. this.$refs.productList.setChecked(con.id,false)
  362. this.chooseList.splice(pot,1);
  363. this.allChecked = false
  364. // 全部清空
  365. if(this.chooseList.length==0){
  366. this.clearChoose()
  367. }
  368. },
  369. // 搜索
  370. getSearchCon() {
  371. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  372. if(!this.queryParam.queryWord){
  373. if (reg.test(this.keyword)) {
  374. //包含汉字
  375. this.queryParam.productName = this.keyword.trim()
  376. } else {
  377. this.queryParam.productCode=this.keyword.trim()
  378. }
  379. }
  380. this.queryParam.shelfSn = this.nowData.shelfSn
  381. this.loadData(this.queryParam);
  382. },
  383. // 校验滞销天数数值范围
  384. checkValueRange () {
  385. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  386. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  387. const isOZero = this.queryParam.unsalableDaysBegin === 0
  388. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  389. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  390. const isTZero = this.queryParam.unsalableDaysEnd === 0
  391. // 第一个为空(可为null可为空字符)第二个不为空
  392. // 第一个不为空第二个为空(可为null可为空字符)
  393. // 第一个大于第二个
  394. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  395. uni.showToast({
  396. title:'请输入正确的滞销天数查询范围!',
  397. icon:'none'
  398. })
  399. return false
  400. }
  401. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  402. uni.showToast({
  403. title:'请输入正确的滞销天数查询范围!',
  404. icon:'none'
  405. })
  406. return false
  407. }
  408. if (this.queryParam.unsalableDaysBegin*1 > this.queryParam.unsalableDaysEnd *1) {
  409. uni.showToast({
  410. title:'请输入正确的滞销天数查询范围!',
  411. icon:'none'
  412. })
  413. return false
  414. }
  415. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  416. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  417. return true
  418. }
  419. }
  420. }
  421. </script>
  422. <style lang="less">
  423. .content{
  424. height: 100vh;
  425. width: 100%;
  426. background: #fff;
  427. .searchBar{
  428. padding: 0.5rem 0.3rem;
  429. .p-title{
  430. padding: 0 15rpx;
  431. display: flex;
  432. align-items: center;
  433. color: #222;
  434. font-size: 30rpx;
  435. > text{
  436. display: block;
  437. height: 30rpx;
  438. width: 6rpx;
  439. background: #0485F6;
  440. margin-right: 10rpx;
  441. border-radius: 10rpx;
  442. }
  443. .shelfName{
  444. flex-grow: 1;
  445. font-weight: bold;
  446. width: 74%;
  447. > view{
  448. overflow: hidden;
  449. white-space: nowrap;
  450. text-overflow: ellipsis;
  451. }
  452. }
  453. .screeningBox {
  454. font-size: 26rpx;
  455. width: 150rpx;
  456. text-align: right;
  457. color: #0485F6;
  458. text {
  459. vertical-align: top;
  460. }
  461. }
  462. .btns{
  463. width:100rpx;
  464. text-align: right;
  465. font-size: 28rpx;
  466. color: #0485F6;
  467. }
  468. }
  469. .search{
  470. margin-top: 15upx;
  471. padding: 0.1rem;
  472. border-radius: 50rpx;
  473. border:1rpx solid #eee;
  474. .input{
  475. flex-grow: 1;
  476. padding: 4rpx;
  477. }
  478. .icon{
  479. width: 13%;
  480. text-align: center;
  481. font-size: 46rpx;
  482. color: #999;
  483. }
  484. }
  485. }
  486. .check-list{
  487. padding: 0 0.8rem;
  488. flex-grow: 1;
  489. overflow: auto;
  490. flex-basis: 0;
  491. }
  492. .footer-bar{
  493. background-color: #f8f8f8;
  494. padding: 20upx;
  495. position: relative;
  496. z-index: 99999;
  497. .f-left{
  498. color: #fff;
  499. }
  500. .active{
  501. background-color: #0485F6;
  502. }
  503. .f-mid{
  504. flex-grow: 1;
  505. color: #666;
  506. font-size: 0.8rem;
  507. > view{
  508. padding: 0 5upx;
  509. &:first-child{
  510. text{
  511. color: red;
  512. }
  513. }
  514. &:last-child{
  515. font-size: 0.8rem;
  516. color: #0485F6;
  517. }
  518. }
  519. }
  520. .f-btns{
  521. button{
  522. width: 200upx;
  523. }
  524. }
  525. }
  526. //滞销天数弹窗样式
  527. .choosePopup {
  528. padding: 30rpx 20rpx;
  529. box-sizing: border-box;
  530. .chooseTit {
  531. text-align: center;
  532. }
  533. .chooseDay {
  534. margin: 60rpx 0;
  535. .u-input {
  536. border-bottom: 1rpx solid #e0e0e0;
  537. }
  538. }
  539. .butBox {
  540. margin-top: 100rpx;
  541. .u-size-medium {
  542. padding: 0 60rpx !important;
  543. }
  544. }
  545. }
  546. // 详情页弹窗样式
  547. .head{
  548. width: 100%;
  549. text-align: center;
  550. box-sizing: border-box;
  551. padding:30rpx 20rpx;
  552. background: #f8f8f8;
  553. position: relative;
  554. font-weight: bold;
  555. text{
  556. position: absolute;
  557. top:30rpx ;
  558. left:20rpx;
  559. color:red;
  560. font-weight: normal;
  561. }
  562. }
  563. .scroll-view{
  564. height: 584rpx;
  565. .partList-list-box {
  566. width: 700rpx;
  567. margin:0 auto;
  568. padding: 10px 0;
  569. border-bottom: 2rpx solid #f5f5f5;
  570. &:last-child {
  571. border: 0;
  572. }
  573. .product {
  574. flex-grow: 1;
  575. .checkbox {
  576. width: 60rpx;
  577. }
  578. .pinfo {
  579. flex-grow: 1;
  580. padding-left: 20rpx;
  581. .pname {
  582. font-size: 26rpx;
  583. color:#222;
  584. text {
  585. font-weight: normal;
  586. margin-right: 10rpx;
  587. padding: 0 10rpx;
  588. background: rgba(3, 54, 146, 0.15);
  589. border-radius: 30rpx;
  590. color: #033692;
  591. font-size: 24rpx;
  592. }
  593. }
  594. .productName{
  595. width: 100%;
  596. font-size: 30rpx;
  597. margin:6rpx 0;
  598. }
  599. .pno {
  600. background-color: rgba(3, 54, 146, 0.15);
  601. border-radius: 50rpx;
  602. padding: 0 20rpx;
  603. color: #033692;
  604. font-size: 24rpx;
  605. margin-right: 10rpx;
  606. }
  607. .ptxt {
  608. font-size: 28rpx;
  609. color: #999;
  610. .pnums {
  611. color: #222;
  612. padding: 0 4upx;
  613. }
  614. }
  615. }
  616. }
  617. .ptools {
  618. margin-top: 10rpx;
  619. margin-left: 60rpx;
  620. .ptools_l{
  621. font-size: 26rpx;
  622. color: #999;
  623. view{
  624. :nth-child(2)::before{
  625. content: '/';
  626. }
  627. }
  628. .pnums {
  629. color: #ff5500;
  630. padding: 0 4rpx;
  631. }
  632. }
  633. .pcurnums {
  634. > text {
  635. font-size: 24rpx;
  636. color: #999;
  637. margin-right: 20rpx;
  638. }
  639. }
  640. }
  641. }
  642. }
  643. }
  644. </style>