addBackOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655
  1. <template>
  2. <view class="modal-box">
  3. <view class="header_box">
  4. <view class="headerName u-flex">
  5. <text class="barBox"></text>
  6. <view class="shelfName u-line-1">{{ shelfName }}</view>
  7. <view class="screeningBox" @click="chooseShow = true">
  8. <text>滞销天数</text>
  9. <u-icon color="#666666" size="36" name="shaixuan" custom-prefix="iscm-icon"></u-icon>
  10. </view>
  11. </view>
  12. <view class="searchBox">
  13. <view class="searchBox_l">
  14. <u-search
  15. placeholder="请输入产品编码或产品名称搜索"
  16. @change="getSearchCon"
  17. @search="getSearchCon"
  18. @custom="getSearchCon"
  19. @clear="clearSearch"
  20. v-model="keyword"
  21. bg-color="#FFF"
  22. shape="round"
  23. :show-action="false"
  24. ></u-search>
  25. </view>
  26. <view class="searchBox_r" @click="handleScanCode"><u-icon name="scan"></u-icon></view>
  27. </view>
  28. </view>
  29. <view class="backOrderCon">
  30. <scroll-view scroll-y class="scroll-view" v-if="recallBillList && recallBillList.length>0" >
  31. <u-checkbox-group :wrap="true" @change="checkGroupChange">
  32. <view class="partList-list-box" v-for="(item,index) in recallBillList" :key="item.id">
  33. <view class="product flex align_center">
  34. <u-checkbox class="checkbox" v-model="item.isChecked" :name="item.id" size="40" shape="circle">
  35. <view class="flex align_center flex_1">
  36. <view class="pimgs">
  37. <u-image :src="item.productImageUrl?item.productImageUrl:`../../static/${$config('themePath')}/def_img@2x.png`" width="128" height="128" border-radius="10"></u-image>
  38. </view>
  39. <view class="pinfo">
  40. <view class="pname item-name">
  41. <text>{{item.shelfPlaceCode}}</text>
  42. {{item.productCode}}
  43. </view>
  44. <view class="productName u-line-2">
  45. {{item.productName}}
  46. </view>
  47. <view class="ptxt flex align_center">
  48. <view>
  49. 最大库容
  50. <text class="pnums">{{item.maxQty}}</text>
  51. </view>
  52. <view>
  53. /货架库存
  54. <text class="pnums">{{item.qty}}</text>
  55. </view>
  56. <view>
  57. /滞销
  58. <text class="pnums">{{item.unsalableDays}}</text>
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </u-checkbox>
  64. </view>
  65. <view class="ptools flex align_center justify_between">
  66. <view class="ptools_l u-flex">
  67. <view v-if="item.replenishBillQty && item.replenishBillQty!=0">
  68. 补货在途
  69. <text class="pnums">{{item.replenishBillQty}}</text>
  70. </view>
  71. <view v-if="item.recallBillQty && item.recallBillQty!=0">
  72. 调回在途
  73. <text class="pnums">{{item.recallBillQty}}</text>
  74. </view>
  75. </view>
  76. <view class="pcurnums flex align_center">
  77. <text>调回数量</text>
  78. <view class="u-ninput"><u-number-box color="#000" :input-height="60" bg-color="#fff" v-model="item.confirmQty" :min="0" :max="item.qty" @minus="minus" @plus="plus" @change="numberBoxChange"></u-number-box></view>
  79. </view>
  80. </view>
  81. </view>
  82. </u-checkbox-group>
  83. </scroll-view>
  84. <u-empty :src="`/static/${$config('themePath')}/def_no_data@3x.png`" icon-size="200" :text="noDataText" img-width="120" v-else></u-empty>
  85. </view>
  86. <view class="backOrderFooter u-flex" :style="{zIndex:(detailFlag? 99999:11)}">
  87. <view class="checkBox">
  88. <u-checkbox-group><u-checkbox v-model="allChecked" shape="circle" @change="allCheckedChange">全选</u-checkbox></u-checkbox-group>
  89. </view>
  90. <view class="footerBox u-flex u-row-between">
  91. <view class="footerBox_m u-flex">
  92. <view class="middle_l">
  93. 已选
  94. <text>{{chooseArr.length}}</text>
  95. 款/
  96. <text>{{totalNum}}</text>
  97. </view>
  98. <view class="middle_r" @click="seeDetail">
  99. <text>查看明细</text>
  100. <u-icon name="arrow-up" color="#999" size="28"></u-icon>
  101. </view>
  102. </view>
  103. <view class="footerBox_r"><u-button type="primary" shape="circle" @click="addBackOrder">新增调回单</u-button></view>
  104. </view>
  105. </view>
  106. <!-- 弹窗 -->
  107. <u-popup v-model="chooseShow" mode="right" width="60%">
  108. <view class="choosePopup">
  109. <view class="chooseTit">滞销天数</view>
  110. <view class="chooseDay u-flex">
  111. <u-input v-model="queryParam.unsalableDaysBegin" input-align="center" placeholder="起始天数" type="number" />
  112. <text>至</text>
  113. <u-input v-model="queryParam.unsalableDaysEnd" input-align="center" placeholder="截止天数" type="number" />
  114. </view>
  115. <view class="butBox u-flex">
  116. <u-button hover-class="none" shape="circle" size="medium" @click="reset">重置</u-button>
  117. <u-button hover-class="none" :custom-style="customBtnStyle" size="medium" shape="circle" @click="handelFilter">查询</u-button>
  118. </view>
  119. </view>
  120. </u-popup>
  121. <!-- 查看明细弹窗 -->
  122. <detailModal ref="detailPopup" @clearList='clearOneList' @clearAllList="clearAll" @changeNumRecount="recount" :detailShow="detailFlag" :chooseData="chooseArr" @close="detailFlag=false"></detailModal>
  123. </view>
  124. </template>
  125. <script>
  126. import { reportPage } from '@/api/vinLog';
  127. import { controlQueryList,insert } from '@/api/shelf';
  128. import detailModal from './detailModal'
  129. export default {
  130. components: {
  131. detailModal
  132. },
  133. data() {
  134. return {
  135. shelfSn: '',
  136. shelfName: '',
  137. recallBillList:[],//回调单列表
  138. chooseArr:[],
  139. noDataText: '暂无调回单',
  140. totalNum: 0,
  141. detailFlag:false,//查看详情
  142. chooseShow: false,//滞销天数弹窗
  143. theme: '',
  144. customBtnStyle: {
  145. // 自定义按钮样式
  146. borderColor: this.$config('primaryColor'),
  147. backgroundColor: this.$config('primaryColor'),
  148. color: '#fff'
  149. },
  150. allChecked: false,
  151. keyword: '',//搜索
  152. queryParam: { // 查询条件
  153. shelfSn:this.shelfSn,
  154. productCode: undefined,
  155. productName: undefined,
  156. unsalableDaysBegin: undefined,
  157. unsalableDaysEnd: undefined,
  158. queryWord:undefined
  159. },
  160. };
  161. },
  162. onLoad(options) {
  163. this.theme = getApp().globalData.theme;
  164. this.shelfSn = options.shelfSn;
  165. this.shelfName = options.shelfName;
  166. let ajaxData = {
  167. shelfSn: options.shelfSn
  168. };
  169. this.loadData(ajaxData);
  170. },
  171. onBackPress(e) {
  172. if (this.sortShow) {
  173. this.sortShow = false;
  174. this.isSortFlag = 0;
  175. return true;
  176. }
  177. },
  178. methods: {
  179. // 获取列表
  180. loadData(params) {
  181. const _this = this;
  182. uni.showLoading({
  183. title: '加载中...'
  184. });
  185. controlQueryList(params).then(res => {
  186. if (res.status == 200) {
  187. res.data.forEach(item=>{
  188. item.isChecked= false
  189. item.confirmQty = item.qty
  190. })
  191. this.recallBillList=res.data;
  192. }
  193. uni.hideLoading()
  194. });
  195. },
  196. checkGroupChange(e){
  197. let newArr=[];
  198. e.forEach(item=>{
  199. this.recallBillList.map(info =>{
  200. if(item == info.id) {
  201. newArr.push(info);
  202. }
  203. })
  204. })
  205. this.chooseArr = newArr;
  206. let flag = this.recallBillList.every(con => con.isChecked )
  207. if(flag){
  208. this.allChecked = true
  209. }else{
  210. this.allChecked = false
  211. }
  212. this.calculateTotal()
  213. },
  214. // 全选
  215. allCheckedChange(e){
  216. if(e.value){
  217. this.recallBillList.map(item=>{
  218. item.isChecked = true;
  219. })
  220. this.chooseArr = this.chooseArr.concat(this.recallBillList);
  221. }else{
  222. this.recallBillList.map(item=>{
  223. item.isChecked = false;
  224. })
  225. this.chooseArr = []
  226. this.$refs.detailPopup.clearAllList();
  227. }
  228. this.calculateTotal()
  229. },
  230. // 计算选中总件数
  231. calculateTotal(){
  232. this.totalNum = this.recallBillList.filter(item=>{
  233. return item.isChecked
  234. }).reduce((pre,cur)=>{
  235. return pre + cur.confirmQty
  236. },0)
  237. },
  238. //查看选中详情
  239. seeDetail(){
  240. if(this.chooseArr.length == 0){
  241. uni.showToast({
  242. title:'请先选择调回单',
  243. icon:'none'
  244. })
  245. }else{
  246. this.detailFlag = true;
  247. }
  248. },
  249. // 详情删除其中一条选中数据
  250. clearOneList(id){
  251. let i = this.recallBillList.findIndex(val =>{
  252. return val.id == id;
  253. })
  254. this.recallBillList[i].isChecked = false
  255. this.calculateTotal();
  256. },
  257. clearAll(){
  258. this.recallBillList.map(item=>{
  259. item.isChecked = false;
  260. })
  261. this.allChecked =false;
  262. this.chooseArr = []
  263. this.calculateTotal();
  264. },
  265. //进步器change事件
  266. numberBoxChange(){
  267. this.calculateTotal();
  268. },
  269. minus(){
  270. this.calculateTotal();
  271. },
  272. plus(){
  273. this.calculateTotal();
  274. },
  275. // 详情改变重新计算总件数
  276. recount(){
  277. this.calculateTotal();
  278. },
  279. // 重置
  280. reset() {
  281. let ajaxData = {
  282. shelfSn:this.shelfSn,
  283. productCode: undefined,
  284. productName: undefined,
  285. unsalableDaysBegin: undefined,
  286. unsalableDaysEnd: undefined,
  287. queryWord:undefined
  288. };
  289. this.queryParam = ajaxData;
  290. this.loadData(this.queryParam);
  291. },
  292. handelFilter(){
  293. if(this.checkValueRange()){
  294. this.queryParam.shelfSn = this.shelfSn;
  295. this.loadData(this.queryParam);
  296. }
  297. },
  298. // 搜索
  299. getSearchCon() {
  300. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  301. if (reg.test(this.keyword)) {
  302. //包含汉字
  303. this.queryParam.productName = this.keyword.trim()
  304. } else {
  305. this.queryParam.productCode=this.keyword.trim()
  306. }
  307. this.queryParam.shelfSn = this.shelfSn
  308. this.loadData(this.queryParam);
  309. },
  310. // 清空搜索内容
  311. clearSearch() {
  312. this.keyword = '';
  313. this.reset();
  314. },
  315. // 扫描
  316. handleScanCode(){
  317. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  318. this.mpaasScanModule.scan(
  319. {
  320. "scanMode":"Customized",
  321. "scanStyle":{
  322. "scanFrameSizePlus":{"width":250,"height":250},
  323. "scanFrameSize":200,
  324. "scanLight":"visible",
  325. "scanText":"对准条形码/二维码进行识别",
  326. "scanTitle":"扫码搜索货位产品",
  327. }
  328. },
  329. (result) => {
  330. if(result.scanStatus == 1){
  331. this.scanResult(result)
  332. }
  333. })
  334. },
  335. // 扫描结果
  336. scanResult(data){
  337. // 二维码
  338. console.log('111111',data)
  339. if(data.scanType == 'QRCODE'){
  340. const ret = data.scanValue.split("&")
  341. this.queryParam.queryWord = ret[1] // 产品编码
  342. }else{
  343. this.queryParam.queryWord = data.scanValue;
  344. }
  345. this.loadData(this.queryParam);
  346. },
  347. addBackOrder(){
  348. const arr = []
  349. const arrInd = []
  350. if(this.chooseArr.length == 0){
  351. uni.showToast({
  352. title:'请先选择调回单',
  353. icon:'none'
  354. })
  355. return;
  356. }
  357. this.chooseArr.forEach((item, index) => {
  358. if (item.confirmQty) {
  359. arr.push({
  360. shelfSn: item.shelfSn,
  361. shelfPlaceSn: item.shelfPlaceSn,
  362. shelfPlaceCode: item.shelfPlaceCode,
  363. productSn: item.productSn,
  364. productCode: item.productCode,
  365. productName: item.productName,
  366. qty: item.confirmQty
  367. })
  368. } else {
  369. arrInd.push(index + 1)
  370. }
  371. })
  372. if (arrInd.length > 0) {
  373. uni.showToast({
  374. title:'调回数量不能为空或0,请移除后提交',
  375. icon:'none'
  376. })
  377. return
  378. }
  379. uni.showLoading({
  380. title: '保存中...'
  381. });
  382. const params = {
  383. shelfSn: this.shelfSn,
  384. detailList: arr
  385. }
  386. insert(params).then(res => {
  387. uni.hideLoading()
  388. if (res.status == 200) {
  389. uni.showToast({
  390. title:res.message
  391. })
  392. setTimeout(()=>{
  393. uni.navigateTo({
  394. url:'/pages/shuntBackManage/cancellingStocks?sn='+res.data.sn
  395. })
  396. },800)
  397. }
  398. });
  399. },
  400. // 校验滞销天数数值范围
  401. checkValueRange () {
  402. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  403. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  404. const isOZero = this.queryParam.unsalableDaysBegin === 0
  405. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  406. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  407. const isTZero = this.queryParam.unsalableDaysEnd === 0
  408. // 第一个为空(可为null可为空字符)第二个不为空
  409. // 第一个不为空第二个为空(可为null可为空字符)
  410. // 第一个大于第二个
  411. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  412. uni.showToast({
  413. title:'请输入正确的滞销天数查询范围!',
  414. icon:'none'
  415. })
  416. return false
  417. }
  418. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  419. uni.showToast({
  420. title:'请输入正确的滞销天数查询范围!',
  421. icon:'none'
  422. })
  423. return false
  424. }
  425. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  426. uni.showToast({
  427. title:'请输入正确的滞销天数查询范围!',
  428. icon:'none'
  429. })
  430. return false
  431. }
  432. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  433. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  434. return true
  435. }
  436. }
  437. };
  438. </script>
  439. <style lang="less" scoped>
  440. .modal-box {
  441. background: #ffffff;
  442. padding: 20rpx;
  443. width: 100%;
  444. height: 100vh;
  445. box-sizing: border-box;
  446. .header_box {
  447. width: 100%;
  448. height: 142rpx;
  449. padding: 0 20rpx 20rpx;
  450. .headerName {
  451. padding-bottom: 15rpx;
  452. color: #222;
  453. font-size: 30rpx;
  454. .barBox {
  455. display: block;
  456. height: 30rpx;
  457. width: 6rpx;
  458. background: #0485f6;
  459. margin-right: 10rpx;
  460. border-radius: 10rpx;
  461. }
  462. .shelfName {
  463. font-weight: bold;
  464. width: calc(100% - 166rpx);
  465. }
  466. .screeningBox {
  467. font-size: 26rpx;
  468. width: 150rpx;
  469. text-align: right;
  470. text {
  471. vertical-align: top;
  472. }
  473. }
  474. }
  475. .searchBox {
  476. width: 100%;
  477. display: flex;
  478. align-items: center;
  479. padding: 0 20rpx;
  480. border: 1rpx solid #e0e0e0;
  481. border-radius: 50rpx;
  482. box-sizing: border-box;
  483. .searchBox_l {
  484. width: 87%;
  485. }
  486. .searchBox_r {
  487. width: 13%;
  488. text-align: right;
  489. font-size: 46rpx;
  490. color: #999;
  491. }
  492. }
  493. }
  494. .backOrderCon {
  495. width: 100%;
  496. height: calc(100vh - 280rpx);
  497. .scroll-view{
  498. height: 100%;
  499. .partList-list-box {
  500. width: 700rpx;
  501. padding: 10px 0;
  502. border-bottom: 2rpx solid #f5f5f5;
  503. &:last-child {
  504. border: 0;
  505. }
  506. .product {
  507. flex-grow: 1;
  508. .checkbox {
  509. width: 60rpx;
  510. }
  511. .pinfo {
  512. flex-grow: 1;
  513. padding-left: 20rpx;
  514. .pname {
  515. font-size: 26rpx;
  516. color:#222;
  517. text {
  518. font-weight: normal;
  519. margin-right: 10rpx;
  520. padding: 0 10rpx;
  521. background: rgba(3, 54, 146, 0.15);
  522. border-radius: 30rpx;
  523. color: #033692;
  524. font-size: 24rpx;
  525. }
  526. }
  527. .productName{
  528. width: 100%;
  529. font-size: 26rpx;
  530. margin:6rpx 0;
  531. }
  532. .pno {
  533. background-color: rgba(3, 54, 146, 0.15);
  534. border-radius: 50rpx;
  535. padding: 0 20rpx;
  536. color: #033692;
  537. font-size: 24rpx;
  538. margin-right: 10rpx;
  539. }
  540. .ptxt {
  541. font-size: 24rpx;
  542. color: #999;
  543. .pnums {
  544. color: #222;
  545. padding: 0 4upx;
  546. }
  547. }
  548. }
  549. }
  550. .ptools {
  551. margin-top: 30rpx;
  552. margin-left: 60rpx;
  553. .ptools_l{
  554. font-size: 24rpx;
  555. color: #999;
  556. view{
  557. :nth-child(2)::before{
  558. content: '/';
  559. }
  560. }
  561. .pnums {
  562. color: #ff5500;
  563. padding: 0 4rpx;
  564. }
  565. }
  566. .pcurnums {
  567. > text {
  568. font-size: 24rpx;
  569. color: #999;
  570. margin-right: 20rpx;
  571. }
  572. }
  573. .u-ninput {
  574. border: 2rpx solid #eee;
  575. border-radius: 50rpx;
  576. padding: 0 6rpx;
  577. }
  578. /deep/ .u-icon-disabled {
  579. background: #fff !important;
  580. }
  581. /deep/ .u-number-input {
  582. margin: 0 0;
  583. border: 2rpx solid #eee;
  584. border-top: 0;
  585. border-bottom: 0;
  586. }
  587. /deep/ .u-icon-plus,
  588. /deep/ .u-icon-minus {
  589. border-radius: 50rpx;
  590. }
  591. }
  592. }
  593. }
  594. }
  595. .backOrderFooter {
  596. height: 98rpx;
  597. box-sizing: border-box;
  598. padding: 10rpx 0;
  599. vertical-align: top;
  600. position: relative;
  601. background-color: #fff;
  602. .checkBox {
  603. width: 20%;
  604. }
  605. .footerBox {
  606. width: 80%;
  607. .footerBox_m {
  608. .middle_l {
  609. text {
  610. color: #ff5500;
  611. margin: 0 6rpx;
  612. }
  613. }
  614. .middle_r {
  615. font-size: 24rpx;
  616. color: #999;
  617. margin-left: 10rpx;
  618. }
  619. }
  620. .footerBox_r {
  621. width: 200rpx;
  622. button {
  623. width: 100%;
  624. font-size: 26rpx;
  625. }
  626. }
  627. }
  628. }
  629. // 弹窗样式
  630. .choosePopup {
  631. padding: 30rpx 20rpx;
  632. box-sizing: border-box;
  633. .chooseTit {
  634. text-align: center;
  635. }
  636. .chooseDay {
  637. margin: 60rpx 0;
  638. .u-input {
  639. border-bottom: 1rpx solid #e0e0e0;
  640. }
  641. }
  642. .butBox {
  643. margin-top: 100rpx;
  644. .u-size-medium {
  645. padding: 0 60rpx !important;
  646. }
  647. }
  648. }
  649. }
  650. </style>