chooseProduct.vue 16 KB

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