chooseProduct.vue 17 KB

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