addBackOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629
  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. uni.scanCode({
  318. success: (res)=> {
  319. console.log('条码类型:' + res.scanType);
  320. console.log('条码内容:' + res.result);
  321. this.queryParam.queryWord = res.result;
  322. }
  323. });
  324. this.loadData(this.queryParam);
  325. },
  326. addBackOrder(){
  327. const arr = []
  328. const arrInd = []
  329. if(this.chooseArr.length == 0){
  330. uni.showToast({
  331. title:'请先选择调回单',
  332. icon:'none'
  333. })
  334. return;
  335. }
  336. this.chooseArr.forEach((item, index) => {
  337. if (item.confirmQty) {
  338. arr.push({
  339. shelfSn: item.shelfSn,
  340. shelfPlaceSn: item.shelfPlaceSn,
  341. shelfPlaceCode: item.shelfPlaceCode,
  342. productSn: item.productSn,
  343. productCode: item.productCode,
  344. productName: item.productName,
  345. qty: item.confirmQty
  346. })
  347. } else {
  348. arrInd.push(index + 1)
  349. }
  350. })
  351. if (arrInd.length > 0) {
  352. uni.showToast({
  353. title:'调回数量不能为空或0,请移除后提交',
  354. icon:'none'
  355. })
  356. return
  357. }
  358. uni.showLoading({
  359. title: '保存中...'
  360. });
  361. const params = {
  362. shelfSn: this.shelfSn,
  363. detailList: arr
  364. }
  365. insert(params).then(res => {
  366. uni.hideLoading()
  367. if (res.status == 200) {
  368. uni.showToast({
  369. title:res.message
  370. })
  371. }
  372. });
  373. },
  374. // 校验滞销天数数值范围
  375. checkValueRange () {
  376. const isONull = this.queryParam.unsalableDaysBegin === null || this.queryParam.unsalableDaysBegin === undefined
  377. const isOEmpty = this.queryParam.unsalableDaysBegin === ''
  378. const isOZero = this.queryParam.unsalableDaysBegin === 0
  379. const isTNull = this.queryParam.unsalableDaysEnd === null || this.queryParam.unsalableDaysEnd === undefined
  380. const isTEmpty = this.queryParam.unsalableDaysEnd === ''
  381. const isTZero = this.queryParam.unsalableDaysEnd === 0
  382. // 第一个为空(可为null可为空字符)第二个不为空
  383. // 第一个不为空第二个为空(可为null可为空字符)
  384. // 第一个大于第二个
  385. if ((isONull || isOEmpty) && (this.queryParam.unsalableDaysEnd || isTZero)) {
  386. uni.showToast({
  387. title:'请输入正确的滞销天数查询范围!',
  388. icon:'none'
  389. })
  390. return false
  391. }
  392. if ((this.queryParam.unsalableDaysBegin || isOZero) && (isTNull || isTEmpty)) {
  393. uni.showToast({
  394. title:'请输入正确的滞销天数查询范围!',
  395. icon:'none'
  396. })
  397. return false
  398. }
  399. if (this.queryParam.unsalableDaysBegin > this.queryParam.unsalableDaysEnd) {
  400. uni.showToast({
  401. title:'请输入正确的滞销天数查询范围!',
  402. icon:'none'
  403. })
  404. return false
  405. }
  406. this.queryParam.unsalableDaysBegin = this.queryParam.unsalableDaysBegin > 999999999 ? 999999999 : this.queryParam.unsalableDaysBegin
  407. this.queryParam.unsalableDaysEnd = this.queryParam.unsalableDaysEnd > 999999999 ? 999999999 : this.queryParam.unsalableDaysEnd
  408. return true
  409. }
  410. }
  411. };
  412. </script>
  413. <style lang="less" scoped>
  414. .modal-box {
  415. background: #ffffff;
  416. padding: 20rpx;
  417. width: 100%;
  418. height: 100vh;
  419. box-sizing: border-box;
  420. .header_box {
  421. width: 100%;
  422. height: 142rpx;
  423. padding: 0 20rpx 20rpx;
  424. .headerName {
  425. padding-bottom: 15rpx;
  426. color: #222;
  427. font-size: 30rpx;
  428. .barBox {
  429. display: block;
  430. height: 30rpx;
  431. width: 6rpx;
  432. background: #0485f6;
  433. margin-right: 10rpx;
  434. border-radius: 10rpx;
  435. }
  436. .shelfName {
  437. font-weight: bold;
  438. width: calc(100% - 166rpx);
  439. }
  440. .screeningBox {
  441. font-size: 26rpx;
  442. width: 150rpx;
  443. text-align: right;
  444. text {
  445. vertical-align: top;
  446. }
  447. }
  448. }
  449. .searchBox {
  450. width: 100%;
  451. display: flex;
  452. align-items: center;
  453. padding: 0 20rpx;
  454. border: 1rpx solid #e0e0e0;
  455. border-radius: 50rpx;
  456. box-sizing: border-box;
  457. .searchBox_l {
  458. width: 87%;
  459. }
  460. .searchBox_r {
  461. width: 13%;
  462. text-align: right;
  463. font-size: 46rpx;
  464. color: #999;
  465. }
  466. }
  467. }
  468. .backOrderCon {
  469. width: 100%;
  470. height: calc(100vh - 280rpx);
  471. .scroll-view{
  472. height: 100%;
  473. .partList-list-box {
  474. width: 700rpx;
  475. padding: 10px 0;
  476. border-bottom: 2rpx solid #f5f5f5;
  477. &:last-child {
  478. border: 0;
  479. }
  480. .product {
  481. flex-grow: 1;
  482. .checkbox {
  483. width: 60rpx;
  484. }
  485. .pinfo {
  486. flex-grow: 1;
  487. padding-left: 20rpx;
  488. .pname {
  489. font-size: 26rpx;
  490. color:#222;
  491. text {
  492. font-weight: normal;
  493. margin-right: 10rpx;
  494. padding: 0 10rpx;
  495. background: rgba(3, 54, 146, 0.15);
  496. border-radius: 30rpx;
  497. color: #033692;
  498. font-size: 24rpx;
  499. }
  500. }
  501. .productName{
  502. width: 100%;
  503. font-size: 26rpx;
  504. margin:6rpx 0;
  505. }
  506. .pno {
  507. background-color: rgba(3, 54, 146, 0.15);
  508. border-radius: 50rpx;
  509. padding: 0 20rpx;
  510. color: #033692;
  511. font-size: 24rpx;
  512. margin-right: 10rpx;
  513. }
  514. .ptxt {
  515. font-size: 24rpx;
  516. color: #999;
  517. .pnums {
  518. color: #222;
  519. padding: 0 4upx;
  520. }
  521. }
  522. }
  523. }
  524. .ptools {
  525. margin-top: 30rpx;
  526. margin-left: 60rpx;
  527. .ptools_l{
  528. font-size: 24rpx;
  529. color: #999;
  530. view{
  531. :nth-child(2)::before{
  532. content: '/';
  533. }
  534. }
  535. .pnums {
  536. color: #ff5500;
  537. padding: 0 4rpx;
  538. }
  539. }
  540. .pcurnums {
  541. > text {
  542. font-size: 24rpx;
  543. color: #999;
  544. margin-right: 20rpx;
  545. }
  546. }
  547. .u-ninput {
  548. border: 2rpx solid #eee;
  549. border-radius: 50rpx;
  550. padding: 0 6rpx;
  551. }
  552. /deep/ .u-icon-disabled {
  553. background: #fff !important;
  554. }
  555. /deep/ .u-number-input {
  556. margin: 0 0;
  557. border: 2rpx solid #eee;
  558. border-top: 0;
  559. border-bottom: 0;
  560. }
  561. /deep/ .u-icon-plus,
  562. /deep/ .u-icon-minus {
  563. border-radius: 50rpx;
  564. }
  565. }
  566. }
  567. }
  568. }
  569. .backOrderFooter {
  570. height: 98rpx;
  571. box-sizing: border-box;
  572. padding: 10rpx 0;
  573. vertical-align: top;
  574. position: relative;
  575. background-color: #fff;
  576. .checkBox {
  577. width: 20%;
  578. }
  579. .footerBox {
  580. width: 80%;
  581. .footerBox_m {
  582. .middle_l {
  583. text {
  584. color: #ff5500;
  585. margin: 0 6rpx;
  586. }
  587. }
  588. .middle_r {
  589. font-size: 24rpx;
  590. color: #999;
  591. margin-left: 10rpx;
  592. }
  593. }
  594. .footerBox_r {
  595. width: 200rpx;
  596. button {
  597. width: 100%;
  598. font-size: 26rpx;
  599. }
  600. }
  601. }
  602. }
  603. // 弹窗样式
  604. .choosePopup {
  605. padding: 30rpx 20rpx;
  606. box-sizing: border-box;
  607. .chooseTit {
  608. text-align: center;
  609. }
  610. .chooseDay {
  611. margin: 60rpx 0;
  612. .u-input {
  613. border-bottom: 1rpx solid #e0e0e0;
  614. }
  615. }
  616. .butBox {
  617. margin-top: 100rpx;
  618. .u-size-medium {
  619. padding: 0 60rpx !important;
  620. }
  621. }
  622. }
  623. }
  624. </style>