chooseProduct.vue 16 KB

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