chooseProduct.vue 16 KB

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