chooseProduct.vue 15 KB

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