addBackOrder.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  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 || (item.unsalableDays&&item.unsalableDays) == 0 ?'--天':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. {{item.replenishBillQty && item.replenishBillQty!=0 ? '/':''}}调回在途
  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="1" :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:undefined,
  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. this.queryParam.shelfSn = options.shelfSn
  167. let ajaxData = {
  168. shelfSn: options.shelfSn
  169. };
  170. this.loadData(ajaxData);
  171. },
  172. onBackPress(e) {
  173. if (this.sortShow) {
  174. this.chooseShow = false;
  175. this.detailPopup = false;
  176. return true;
  177. }
  178. },
  179. methods: {
  180. // 获取列表
  181. loadData(params) {
  182. const _this = this;
  183. uni.showLoading({
  184. mask:true,
  185. title:"正在加载..."
  186. })
  187. controlQueryList(params).then(res => {
  188. if (res.status == 200) {
  189. res.data.forEach(item=>{
  190. item.isChecked= false
  191. item.confirmQty = item.qty
  192. })
  193. this.recallBillList=res.data;
  194. }
  195. setTimeout(()=>{
  196. uni.hideLoading()
  197. },this.recallBillList.length*40)
  198. });
  199. },
  200. checkGroupChange(e){
  201. let flag = this.recallBillList.every(con => con.isChecked )
  202. if(flag){
  203. this.allChecked = true
  204. }else{
  205. this.allChecked = false
  206. }
  207. this.calculateTypeTotal()
  208. this.calculateTotal()
  209. },
  210. // 全选
  211. allCheckedChange(e){
  212. if(e.value){
  213. this.recallBillList.map(item=>{
  214. item.isChecked = true;
  215. })
  216. }else{
  217. this.recallBillList.map(item=>{
  218. item.isChecked = false;
  219. })
  220. }
  221. this.calculateTotal()
  222. this.calculateTypeTotal()
  223. },
  224. // 计算选中总款数
  225. calculateTypeTotal(){
  226. this.chooseArr = this.recallBillList.filter(item=>{
  227. return item.isChecked
  228. })
  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(ajaxData);
  291. },
  292. handelFilter(){
  293. if(this.checkValueRange()){
  294. this.queryParam.shelfSn = this.shelfSn;
  295. this.chooseShow =false;
  296. this.loadData(this.queryParam);
  297. }
  298. },
  299. // 搜索
  300. getSearchCon() {
  301. var reg = new RegExp('[\\u4E00-\\u9FFF]+', 'g');
  302. if(!this.queryParam.queryWord){
  303. if (reg.test(this.keyword)) {
  304. //包含汉字
  305. this.queryParam.productName = this.keyword.trim()
  306. } else {
  307. this.queryParam.productCode=this.keyword.trim()
  308. }
  309. }
  310. this.queryParam.shelfSn = this.shelfSn
  311. this.loadData(this.queryParam);
  312. },
  313. // 清空搜索内容
  314. clearSearch() {
  315. this.keyword = '';
  316. this.reset();
  317. },
  318. // 扫描
  319. handleScanCode(){
  320. this.mpaasScanModule = uni.requireNativePlugin("wss-scan")
  321. this.mpaasScanModule.scan(
  322. {
  323. "scanMode":"Customized",
  324. "scanStyle":{
  325. "scanFrameSizePlus":{"width":250,"height":250},
  326. "scanFrameSize":200,
  327. "scanLight":"visible",
  328. "scanText":"对准条形码/二维码进行识别",
  329. "scanTitle":"扫码搜索货位产品",
  330. }
  331. },
  332. (result) => {
  333. if(result.scanStatus == 1){
  334. this.scanResult(result)
  335. }
  336. })
  337. },
  338. // 扫描结果
  339. scanResult(data){
  340. // 二维码
  341. if(data.scanType == 'QRCODE'){
  342. const ret = data.scanValue.split("&")
  343. this.queryParam.queryWord = ret[1] // 产品编码
  344. this.keyword= ret[1]
  345. }else{
  346. this.queryParam.queryWord = data.scanValue;
  347. this.keyword= data.scanValue
  348. }
  349. this.queryParam.shelfSn = this.shelfSn
  350. this.loadData(this.queryParam);
  351. },
  352. addBackOrder(){
  353. const arr = []
  354. const arrInd = []
  355. if(this.chooseArr.length == 0){
  356. uni.showToast({
  357. title:'请先选择调回产品',
  358. icon:'none'
  359. })
  360. return;
  361. }
  362. this.chooseArr.forEach((item, index) => {
  363. if (item.confirmQty) {
  364. arr.push({
  365. shelfSn: item.shelfSn,
  366. shelfPlaceSn: item.shelfPlaceSn,
  367. shelfPlaceCode: item.shelfPlaceCode,
  368. productSn: item.productSn,
  369. productCode: item.productCode,
  370. productName: item.productName,
  371. qty: item.confirmQty
  372. })
  373. } else {
  374. arrInd.push(index + 1)
  375. }
  376. })
  377. if (arrInd.length > 0) {
  378. uni.showToast({
  379. title:'调回数量不能为空或0,请移除后提交',
  380. icon:'none'
  381. })
  382. return
  383. }
  384. uni.showLoading({
  385. title: '保存中...'
  386. });
  387. const params = {
  388. shelfSn: this.shelfSn,
  389. detailList: arr
  390. }
  391. insert(params).then(res => {
  392. if (res.status == 200) {
  393. uni.showToast({
  394. title:res.message
  395. })
  396. setTimeout(()=>{
  397. uni.navigateTo({
  398. url:'/pages/shuntBackManage/cancellingStocks?sn='+res.data
  399. })
  400. },800)
  401. }
  402. uni.hideLoading()
  403. });
  404. },
  405. // 校验滞销天数数值范围
  406. checkValueRange () {
  407. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  408. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  409. const isOZero = this.queryParam.unsalableDaysBegin === 0
  410. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  411. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  412. const isTZero = this.queryParam.unsalableDaysEnd === 0
  413. // 第一个为空(可为null可为空字符)第二个不为空
  414. // 第一个不为空第二个为空(可为null可为空字符)
  415. // 第一个大于第二个
  416. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  417. uni.showToast({
  418. title:'请输入正确的滞销天数查询范围!',
  419. icon:'none'
  420. })
  421. return false
  422. }
  423. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  424. uni.showToast({
  425. title:'请输入正确的滞销天数查询范围!',
  426. icon:'none'
  427. })
  428. return false
  429. }
  430. if (this.queryParam.unsalableDaysBegin*1 > this.queryParam.unsalableDaysEnd *1) {
  431. uni.showToast({
  432. title:'请输入正确的滞销天数查询范围!',
  433. icon:'none'
  434. })
  435. return false
  436. }
  437. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  438. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  439. return true
  440. }
  441. }
  442. };
  443. </script>
  444. <style lang="less" scoped>
  445. .modal-box {
  446. background: #ffffff;
  447. padding: 20rpx;
  448. width: 100%;
  449. height: 100vh;
  450. box-sizing: border-box;
  451. .header_box {
  452. width: 100%;
  453. height: 142rpx;
  454. padding: 0 20rpx 20rpx;
  455. .headerName {
  456. padding-bottom: 15rpx;
  457. color: #222;
  458. font-size: 30rpx;
  459. .barBox {
  460. display: block;
  461. height: 30rpx;
  462. width: 6rpx;
  463. background: #0485f6;
  464. margin-right: 10rpx;
  465. border-radius: 10rpx;
  466. }
  467. .shelfName {
  468. font-weight: bold;
  469. width: calc(100% - 166rpx);
  470. }
  471. .screeningBox {
  472. font-size: 26rpx;
  473. width: 150rpx;
  474. text-align: right;
  475. text {
  476. vertical-align: top;
  477. }
  478. }
  479. }
  480. .searchBox {
  481. width: 100%;
  482. display: flex;
  483. align-items: center;
  484. padding: 0 20rpx;
  485. border: 1rpx solid #e0e0e0;
  486. border-radius: 50rpx;
  487. box-sizing: border-box;
  488. .searchBox_l {
  489. width: 87%;
  490. }
  491. .searchBox_r {
  492. width: 13%;
  493. text-align: right;
  494. font-size: 46rpx;
  495. color: #999;
  496. }
  497. }
  498. }
  499. .backOrderCon {
  500. width: 100%;
  501. height: calc(100vh - 280rpx);
  502. .scroll-view{
  503. height: 100%;
  504. .partList-list-box {
  505. width: 700rpx;
  506. padding: 10px 0;
  507. border-bottom: 2rpx solid #f5f5f5;
  508. &:last-child {
  509. border: 0;
  510. }
  511. .product {
  512. flex-grow: 1;
  513. .checkbox {
  514. width: 60rpx;
  515. }
  516. .pinfo {
  517. flex-grow: 1;
  518. padding-left: 20rpx;
  519. .pname {
  520. font-size: 26rpx;
  521. color:#222;
  522. text {
  523. font-weight: normal;
  524. margin-right: 10rpx;
  525. padding: 0 10rpx;
  526. background: rgba(3, 54, 146, 0.15);
  527. border-radius: 30rpx;
  528. color: #033692;
  529. font-size: 24rpx;
  530. }
  531. }
  532. .productName{
  533. width: 100%;
  534. font-size: 26rpx;
  535. margin:6rpx 0;
  536. }
  537. .pno {
  538. background-color: rgba(3, 54, 146, 0.15);
  539. border-radius: 50rpx;
  540. padding: 0 20rpx;
  541. color: #033692;
  542. font-size: 24rpx;
  543. margin-right: 10rpx;
  544. }
  545. .ptxt {
  546. font-size: 24rpx;
  547. color: #999;
  548. .pnums {
  549. color: #222;
  550. padding: 0 4upx;
  551. }
  552. }
  553. }
  554. }
  555. .ptools {
  556. margin-top: 30rpx;
  557. margin-left: 60rpx;
  558. .ptools_l{
  559. font-size: 24rpx;
  560. color: #999;
  561. view{
  562. :nth-child(2)::before{
  563. content: '/';
  564. }
  565. }
  566. .pnums {
  567. color: #ff5500;
  568. padding: 0 4rpx;
  569. }
  570. }
  571. .pcurnums {
  572. > text {
  573. font-size: 24rpx;
  574. color: #999;
  575. margin-right: 20rpx;
  576. }
  577. }
  578. .u-ninput {
  579. border: 2rpx solid #eee;
  580. border-radius: 50rpx;
  581. padding: 0 6rpx;
  582. }
  583. /deep/ .u-icon-disabled {
  584. background: #fff !important;
  585. }
  586. /deep/ .u-number-input {
  587. margin: 0 0;
  588. border: 2rpx solid #eee;
  589. border-top: 0;
  590. border-bottom: 0;
  591. }
  592. /deep/ .u-icon-plus,
  593. /deep/ .u-icon-minus {
  594. border-radius: 50rpx;
  595. }
  596. }
  597. }
  598. }
  599. }
  600. .backOrderFooter {
  601. height: 98rpx;
  602. box-sizing: border-box;
  603. padding: 10rpx 0;
  604. vertical-align: top;
  605. position: relative;
  606. background-color: #fff;
  607. .checkBox {
  608. width: 20%;
  609. }
  610. .footerBox {
  611. width: 80%;
  612. .footerBox_m {
  613. .middle_l {
  614. text {
  615. color: #ff5500;
  616. margin: 0 6rpx;
  617. }
  618. }
  619. .middle_r {
  620. font-size: 24rpx;
  621. color: #999;
  622. margin-left: 10rpx;
  623. }
  624. }
  625. .footerBox_r {
  626. width: 200rpx;
  627. button {
  628. width: 100%;
  629. font-size: 26rpx;
  630. }
  631. }
  632. }
  633. }
  634. // 弹窗样式
  635. .choosePopup {
  636. padding: 30rpx 20rpx;
  637. box-sizing: border-box;
  638. .chooseTit {
  639. text-align: center;
  640. }
  641. .chooseDay {
  642. margin: 60rpx 0;
  643. .u-input {
  644. border-bottom: 1rpx solid #e0e0e0;
  645. }
  646. }
  647. .butBox {
  648. margin-top: 100rpx;
  649. .u-size-medium {
  650. padding: 0 60rpx !important;
  651. }
  652. }
  653. }
  654. }
  655. </style>