chooseProduct.vue 16 KB

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