quickReplenish.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. <template>
  2. <view class="content flex flex_column">
  3. <view class="head-info">
  4. <view class="p-title flex align_center">
  5. <text></text>
  6. <view class="shelfName flex align_center">
  7. <view>
  8. {{basicInfoData.shelfName}}
  9. </view>
  10. </view>
  11. </view>
  12. <view>系统检测到以下产品缺货,请选择需要补货的产品</view>
  13. </view>
  14. <view class="partlist">
  15. <quickProductList :list="partList" ref="productList" noDataText="暂无产品" @allChecked="allCheckedCallback"></quickProductList>
  16. </view>
  17. <view class="part-footer flex align_item justify_between">
  18. <view>
  19. <u-checkbox size="40" @change="allCheckeChange" v-model="allChecked" shape="circle">{{allChecked?'取消全选':'全选'}}</u-checkbox>
  20. </view>
  21. <view class="btns flex align_item justify_end">
  22. <view>
  23. <kk-printer ref="kkprinter" printBtnStyle="default-mid" defaultText="打印贴签" @startPrint="startPrint"></kk-printer>
  24. </view>
  25. <view style="padding: 0 10rpx;"></view>
  26. <view>
  27. <u-button class="handle-btn" :loading="loading" shape="circle" size="medium" hover-class="none" :custom-style="customBtnStyle" @click="replenish">快速补货</u-button>
  28. </view>
  29. </view>
  30. </view>
  31. <!-- 选择配送方式弹框 -->
  32. <choose-type-modal v-if="chooseModal" :openModal="chooseModal" @confirm="modalChooseType" @close="chooseModal = false" />
  33. <!-- 库存不足 弹框 -->
  34. <stock-modal v-if="stockModal" :openModal="stockModal" :list="stockList" :params="temParams" @confirm="modalStock" @close="stockModal=false" />
  35. </view>
  36. </template>
  37. <script>
  38. import quickProductList from './quickProductList.vue'
  39. import kkPrinter from '@/components/kk-printer/index.vue';
  40. import chooseTypeModal from './chooseTypeModal.vue'
  41. import stockModal from '@/pages/replenishmentManage/stockModal.vue'
  42. import {printTempl} from '@/libs/printTools.js'
  43. import {saveReplenishBill} from '@/api/shelfReplenish.js'
  44. export default {
  45. components: { quickProductList, kkPrinter, chooseTypeModal, stockModal },
  46. data() {
  47. return {
  48. loading: false,
  49. chooseModal: false,
  50. basicInfoData:null,
  51. partList: [],
  52. allChecked: false,
  53. printIndex: 0,
  54. isParinting: false,
  55. stockModal: false,
  56. stockList: [],
  57. temParams:null,
  58. customBtnStyle: { // 自定义按钮样式
  59. borderColor: this.$config('primaryColor'),
  60. backgroundColor: this.$config('primaryColor'),
  61. color: '#fff'
  62. },
  63. }
  64. },
  65. onReady() {
  66. uni.setNavigationBarColor({
  67. frontColor: '#ffffff',
  68. backgroundColor: this.$config('primaryColor')
  69. })
  70. this.$refs.productList.setData(this.partList)
  71. this.allCheckeChange({value:true})
  72. this.allChecked = true
  73. },
  74. onLoad(option) {
  75. this.basicInfoData = this.$store.state.vuex_tempData;
  76. this.partList = this.basicInfoData.list
  77. // 保持屏幕常亮
  78. uni.setKeepScreenOn({
  79. keepScreenOn: true
  80. });
  81. },
  82. onUnload() {
  83. this.partList = []
  84. this.$store.state.vuex_tempData = null
  85. // 保持屏幕常亮
  86. uni.setKeepScreenOn({
  87. keepScreenOn: false
  88. });
  89. },
  90. onBackPress(event){
  91. if(event.from == 'backbutton'){
  92. if(this.isParinting){
  93. uni.showToast({
  94. icon:'none',
  95. title: '正在打印中...'
  96. })
  97. }else{
  98. uni.navigateBack({delta: 1})
  99. }
  100. return true // 阻止默认返回行为(会导致无限循环)
  101. }
  102. },
  103. methods: {
  104. // 全选
  105. allCheckeChange(e){
  106. this.$refs.productList.allSelect(e.value)
  107. },
  108. allCheckedCallback(val){
  109. this.allChecked = val
  110. },
  111. // 补货
  112. replenish(){
  113. const result =this.$refs.productList.getAllChecked()
  114. console.log(result,result.length)
  115. if(result.length){
  116. this.chooseModal = true
  117. }else{
  118. this.toashMsg("请选择产品!")
  119. }
  120. },
  121. modalChooseType(data,confirm){
  122. const result =this.$refs.productList.getAllChecked()
  123. const arr = []
  124. result.map((item, index) => {
  125. arr.push({
  126. productSn: item.productSn,
  127. productCode: item.productCode,
  128. qty: item.printQty,
  129. shelfSn: this.basicInfoData.shelfSn,
  130. shelfPlaceCode: item.shelfPlaceCode,
  131. shelfPlaceSn: item.shelfPlaceSn
  132. })
  133. })
  134. const params = {
  135. detailList: arr,
  136. dispatchType: data.dispatchType,
  137. remarks: data.remarks,
  138. shelfSn:this.basicInfoData.shelfSn,
  139. confirm: confirm
  140. }
  141. console.log(params)
  142. uni.showLoading({
  143. title: "正在提交..."
  144. })
  145. this.loading = true
  146. saveReplenishBill(params).then(res => {
  147. console.log(res)
  148. if(res.status == 200){
  149. // 库存不足
  150. if(res.data&&res.data.length){
  151. this.temParams = params
  152. this.stockList = res.data
  153. this.stockModal = true
  154. }else{
  155. uni.navigateBack()
  156. this.toashMsg(res.message)
  157. }
  158. }
  159. this.loading = false
  160. this.chooseModal = false
  161. uni.hideLoading()
  162. })
  163. },
  164. // 继续补货
  165. modalStock(params){
  166. this.modalChooseType(params,1)
  167. this.stockModal = false
  168. },
  169. printOnce(opt,tsc,blesdk,data){
  170. const _this = this
  171. const dealer = this.$store.state.vuex_userData
  172. // 60*40 打印模板
  173. const command = printTempl(tsc,{
  174. dealerName: dealer.orgName,
  175. shelfName: data.shelfName || '',
  176. productCode: data.productCode || '',
  177. productName: data.productName || '',
  178. shelfPlaceCode: data.shelfPlaceCode || '',
  179. currentInven: data.printQty,
  180. printDate: this.$u.timeFormat(this.timestamp, 'yyyy-mm-dd hh:MM'),
  181. printUser: dealer.userNameCN,
  182. barCode: `${data.shelfSn}&${data.productCode}&${data.productSn}&${data.shelfPlaceSn}`
  183. })
  184. // 开始批量打印
  185. blesdk.senBlData(
  186. opt.deviceId,
  187. opt.serviceId,
  188. opt.writeId,
  189. command.getData(),
  190. function(){
  191. const result =_this.$refs.productList.getAllChecked()
  192. _this.printIndex = _this.printIndex + 1
  193. if(_this.printIndex < result.length){
  194. _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
  195. }else{
  196. _this.printIndex = 0
  197. _this.$refs.kkprinter.onPrintSuccess()
  198. _this.isParinting = false
  199. }
  200. });
  201. },
  202. // 批量打印
  203. startPrint(opt,tsc,blesdk){
  204. const _this = this
  205. const result =_this.$refs.productList.getAllChecked()
  206. console.log(result,result.length)
  207. if(result.length){
  208. if(_this.isParinting){
  209. return
  210. }
  211. clzConfirm({
  212. title: '提示',
  213. content: '开始打印后,无法撤回,系统将默认按照每个产品的补货数量批量打印',
  214. success (ret) {
  215. if (ret.confirm || ret.index == 0) {
  216. _this.isParinting = true
  217. _this.printOnce(opt,tsc,blesdk,result[_this.printIndex])
  218. }
  219. }
  220. })
  221. }else{
  222. _this.toashMsg("请选择产品!")
  223. _this.$refs.kkprinter.onPrintFail()
  224. }
  225. },
  226. }
  227. }
  228. </script>
  229. <style lang="less">
  230. .content{
  231. width: 100%;
  232. height: 100vh;
  233. background: #fff;
  234. .head-info{
  235. padding: 20rpx 20rpx 0;
  236. border-bottom: 2rpx solid #eee;
  237. > view{
  238. padding: 10rpx;
  239. color: darkorange;
  240. }
  241. .p-title{
  242. padding: 0 10rpx;
  243. display: flex;
  244. align-items: center;
  245. color: #222;
  246. font-size: 30rpx;
  247. > text{
  248. display: block;
  249. height: 30rpx;
  250. width: 6rpx;
  251. background: #0485F6;
  252. margin-right: 10rpx;
  253. border-radius: 10rpx;
  254. }
  255. .shelfName{
  256. flex-grow: 1;
  257. font-weight: bold;
  258. width: 80%;
  259. > view{
  260. overflow: hidden;
  261. white-space: nowrap;
  262. text-overflow: ellipsis;
  263. }
  264. }
  265. }
  266. }
  267. .partlist{
  268. flex-grow: 1;
  269. padding: 0 30rpx;
  270. overflow: auto;
  271. }
  272. .part-footer{
  273. padding: 20rpx 30rpx;
  274. border-top: 2rpx solid #eee;
  275. > view{
  276. &:first-child{
  277. width: 30%;
  278. text-align: left;
  279. padding-top: 10rpx;
  280. }
  281. text-align: right;
  282. }
  283. .btns{
  284. flex-grow: 1;
  285. button{
  286. width: 200rpx;
  287. }
  288. }
  289. }
  290. }
  291. </style>