chooseProduct.vue 16 KB

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