chooseProduct.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642
  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. if(!this.keyword){
  268. params.queryWord = undefined
  269. }
  270. controlQueryList(params).then(res => {
  271. if (res.status == 200) {
  272. res.data.forEach(item=>{
  273. item.isChecked= false
  274. if(item.recallBillQty){
  275. item.confirmQty = item.qty - item.recallBillQty>0 ?item.qty - item.recallBillQty: 0;
  276. }else{
  277. item.confirmQty = item.qty
  278. }
  279. })
  280. _this.partList=res.data;
  281. }else{
  282. _this.partList =[]
  283. }
  284. //过滤之前选过的值
  285. if(_this.nowData.chooseKey && _this.nowData.chooseKey.length >0){
  286. _this.partList = _this.partList.filter(item => {
  287. const row = _this.nowData.chooseKey.findIndex(k => k == item.id)
  288. return !(row>=0)
  289. })
  290. }
  291. // 已选
  292. _this.partList.map(item => {
  293. const row = _this.chooseList.find(k => k.id == item.id)
  294. item.checked = !!row
  295. })
  296. this.$refs.productList.setData(_this.partList)
  297. setTimeout(()=>{
  298. uni.hideLoading()
  299. },_this.partList.length*30)
  300. });
  301. },
  302. // 提交
  303. submitOrder(){
  304. if(this.totalCategory){
  305. if(this.nowData.chooseKey && this.nowData.chooseKey.length>0){
  306. uni.$emit("chooseBackProduct",this.chooseList)
  307. uni.navigateBack()
  308. }else{
  309. this.$store.commit('setShuntBackList',this.chooseList);
  310. uni.redirectTo({
  311. url:'/pages/shuntBackManage/addBackOrder?shelfSn='+ this.nowData.shelfSn+'&shelfName='+this.nowData.shelfName
  312. })
  313. }
  314. }else{
  315. uni.showToast({
  316. icon: 'none',
  317. title: '请选择产品'
  318. })
  319. }
  320. },
  321. // 扫描
  322. handleScanCode(){
  323. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  324. this.mpaasScanModule.scan(
  325. {
  326. "scanMode":"Customized",
  327. "scanStyle":{
  328. "scanFrameSizePlus":{"width":250,"height":250},
  329. "scanFrameSize":200,
  330. "scanLight":"visible",
  331. "scanText":"对准条形码/二维码进行识别",
  332. "scanTitle":"扫码搜索货位产品",
  333. }
  334. },
  335. (result) => {
  336. if(result.scanStatus == 1){
  337. this.scanResult(result)
  338. }
  339. })
  340. },
  341. // 扫描结果
  342. scanResult(data){
  343. // 二维码
  344. if(data.scanType == 'QRCODE'){
  345. const ret = data.scanValue.split("&")
  346. this.queryParam.queryWord = ret[1] // 产品编码
  347. this.keyword= ret[1]
  348. }else{
  349. this.queryParam.queryWord = data.scanValue;
  350. this.keyword= data.scanValue
  351. }
  352. this.queryParam.shelfSn = this.nowData.shelfSn
  353. this.loadData(this.queryParam);
  354. },
  355. delDetail(con,pot){
  356. this.$refs.productList.setChecked(con.id,false)
  357. this.chooseList.splice(pot,1);
  358. this.allChecked = false
  359. // 全部清空
  360. if(this.chooseList.length==0){
  361. this.clearChoose()
  362. }
  363. },
  364. // 搜索
  365. getSearchCon() {
  366. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  367. if(!this.queryParam.queryWord){
  368. if (reg.test(this.keyword)) {
  369. //包含汉字
  370. this.queryParam.productName = this.keyword.trim()
  371. } else {
  372. this.queryParam.productCode=this.keyword.trim()
  373. }
  374. }
  375. this.queryParam.shelfSn = this.nowData.shelfSn
  376. this.loadData(this.queryParam);
  377. },
  378. // 校验滞销天数数值范围
  379. checkValueRange () {
  380. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  381. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  382. const isOZero = this.queryParam.unsalableDaysBegin === 0
  383. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  384. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  385. const isTZero = this.queryParam.unsalableDaysEnd === 0
  386. // 第一个为空(可为null可为空字符)第二个不为空
  387. // 第一个不为空第二个为空(可为null可为空字符)
  388. // 第一个大于第二个
  389. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  390. uni.showToast({
  391. title:'请输入正确的滞销天数查询范围!',
  392. icon:'none'
  393. })
  394. return false
  395. }
  396. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  397. uni.showToast({
  398. title:'请输入正确的滞销天数查询范围!',
  399. icon:'none'
  400. })
  401. return false
  402. }
  403. if (this.queryParam.unsalableDaysBegin*1 > this.queryParam.unsalableDaysEnd *1) {
  404. uni.showToast({
  405. title:'请输入正确的滞销天数查询范围!',
  406. icon:'none'
  407. })
  408. return false
  409. }
  410. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  411. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  412. return true
  413. }
  414. }
  415. }
  416. </script>
  417. <style lang="less">
  418. .content{
  419. height: 100vh;
  420. width: 100%;
  421. background: #fff;
  422. .searchBar{
  423. padding: 0 0.8rem 0.3rem;
  424. .p-title{
  425. padding: 0 15rpx;
  426. display: flex;
  427. align-items: center;
  428. color: #222;
  429. font-size: 30rpx;
  430. > text{
  431. display: block;
  432. height: 30rpx;
  433. width: 6rpx;
  434. background: #0485F6;
  435. margin-right: 10rpx;
  436. border-radius: 10rpx;
  437. }
  438. .shelfName{
  439. flex-grow: 1;
  440. font-weight: bold;
  441. width: 74%;
  442. > view{
  443. overflow: hidden;
  444. white-space: nowrap;
  445. text-overflow: ellipsis;
  446. }
  447. }
  448. .screeningBox {
  449. font-size: 26rpx;
  450. width: 150rpx;
  451. text-align: right;
  452. color: #0485F6;
  453. text {
  454. vertical-align: top;
  455. }
  456. }
  457. .btns{
  458. width:100rpx;
  459. text-align: right;
  460. font-size: 28rpx;
  461. color: #0485F6;
  462. }
  463. }
  464. .search{
  465. margin-top: 15upx;
  466. padding: 0.1rem;
  467. border-radius: 50rpx;
  468. border:1rpx solid #eee;
  469. .input{
  470. flex-grow: 1;
  471. padding: 4rpx;
  472. }
  473. .icon{
  474. width: 13%;
  475. text-align: center;
  476. font-size: 46rpx;
  477. color: #999;
  478. }
  479. }
  480. }
  481. .check-list{
  482. padding: 0 0.8rem;
  483. flex-grow: 1;
  484. overflow: auto;
  485. }
  486. .footer-bar{
  487. background-color: #f8f8f8;
  488. padding: 20upx;
  489. position: relative;
  490. z-index: 99999;
  491. .f-left{
  492. color: #fff;
  493. }
  494. .active{
  495. background-color: #0485F6;
  496. }
  497. .f-mid{
  498. flex-grow: 1;
  499. color: #666;
  500. font-size: 0.8rem;
  501. > view{
  502. padding: 0 5upx;
  503. &:first-child{
  504. text{
  505. color: red;
  506. }
  507. }
  508. &:last-child{
  509. font-size: 0.8rem;
  510. color: #0485F6;
  511. }
  512. }
  513. }
  514. .f-btns{
  515. button{
  516. width: 200upx;
  517. }
  518. }
  519. }
  520. //滞销天数弹窗样式
  521. .choosePopup {
  522. padding: 30rpx 20rpx;
  523. box-sizing: border-box;
  524. .chooseTit {
  525. text-align: center;
  526. }
  527. .chooseDay {
  528. margin: 60rpx 0;
  529. .u-input {
  530. border-bottom: 1rpx solid #e0e0e0;
  531. }
  532. }
  533. .butBox {
  534. margin-top: 100rpx;
  535. .u-size-medium {
  536. padding: 0 60rpx !important;
  537. }
  538. }
  539. }
  540. // 详情页弹窗样式
  541. .head{
  542. width: 100%;
  543. text-align: center;
  544. box-sizing: border-box;
  545. padding:30rpx 20rpx;
  546. background: #f8f8f8;
  547. position: relative;
  548. font-weight: bold;
  549. text{
  550. position: absolute;
  551. top:30rpx ;
  552. left:20rpx;
  553. color:red;
  554. font-weight: normal;
  555. }
  556. }
  557. .scroll-view{
  558. height: 584rpx;
  559. .partList-list-box {
  560. width: 700rpx;
  561. margin:0 auto;
  562. padding: 10px 0;
  563. border-bottom: 2rpx solid #f5f5f5;
  564. &:last-child {
  565. border: 0;
  566. }
  567. .product {
  568. flex-grow: 1;
  569. .checkbox {
  570. width: 60rpx;
  571. }
  572. .pinfo {
  573. flex-grow: 1;
  574. padding-left: 20rpx;
  575. .pname {
  576. font-size: 26rpx;
  577. color:#222;
  578. text {
  579. font-weight: normal;
  580. margin-right: 10rpx;
  581. padding: 0 10rpx;
  582. background: rgba(3, 54, 146, 0.15);
  583. border-radius: 30rpx;
  584. color: #033692;
  585. font-size: 24rpx;
  586. }
  587. }
  588. .productName{
  589. width: 100%;
  590. font-size: 26rpx;
  591. margin:6rpx 0;
  592. }
  593. .pno {
  594. background-color: rgba(3, 54, 146, 0.15);
  595. border-radius: 50rpx;
  596. padding: 0 20rpx;
  597. color: #033692;
  598. font-size: 24rpx;
  599. margin-right: 10rpx;
  600. }
  601. .ptxt {
  602. font-size: 24rpx;
  603. color: #999;
  604. .pnums {
  605. color: #222;
  606. padding: 0 4upx;
  607. }
  608. }
  609. }
  610. }
  611. .ptools {
  612. margin-top: 30rpx;
  613. margin-left: 60rpx;
  614. .ptools_l{
  615. font-size: 24rpx;
  616. color: #999;
  617. view{
  618. :nth-child(2)::before{
  619. content: '/';
  620. }
  621. }
  622. .pnums {
  623. color: #ff5500;
  624. padding: 0 4rpx;
  625. }
  626. }
  627. .pcurnums {
  628. > text {
  629. font-size: 24rpx;
  630. color: #999;
  631. margin-right: 20rpx;
  632. }
  633. }
  634. }
  635. }
  636. }
  637. }
  638. </style>