index.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view class="p-content">
  3. <view class="p-head" v-if="baseData">
  4. <view>
  5. <view>
  6. <text>采购单号:</text>
  7. <text style="color: crimson;">{{baseData[0].purchaseBillNo}}</text>
  8. </view>
  9. <view>
  10. <button :disabled="loading" size="mini" type="primary" @click="toOut"> 入库 <text class="iconfont icon-icon-test43"></text></button>
  11. </view>
  12. </view>
  13. <view>
  14. <view>
  15. <text>发货单号:</text>
  16. <text style="color: crimson;">{{baseData[0].sendBillNo}}</text>
  17. </view>
  18. </view>
  19. <view>
  20. <view>
  21. <text>条码:</text>
  22. <view>
  23. <input
  24. @blur="addQty(true)"
  25. style="width: 100%;text-align: left;"
  26. class="uni-input"
  27. placeholder="扫描或输入条码"
  28. border="surround"
  29. v-model="code">
  30. </view>
  31. </view>
  32. </view>
  33. <view style="justify-content: flex-start;flex-wrap: wrap;" v-for="(item,bindex) in baseData" :key="item.id">
  34. <view>总款数:{{ item.totalPutCategory }}</view>
  35. <view>发货数量: {{ item.totalPutQty }}</view>
  36. <view>发货金额: {{ item.totalPutAmount?toThousands(item.totalPutAmount,2):'0.00' }}</view>
  37. <view>入库数量: {{ item && (item.totalRealPutQty || item.totalRealPutQty==0) ? item.totalRealPutQty : '--' }}</view>
  38. <view>入库金额: {{ item && (item.totalRealPutAmount || item.totalRealPutAmount==0) ? toThousands(item.totalRealPutAmount, 2) : '--' }}</view>
  39. </view>
  40. </view>
  41. <view class="p-body">
  42. <uni-table style="width: 100%;" border emptyText="暂无数据" :loading="loading" >
  43. <!-- 表头行 -->
  44. <uni-tr>
  45. <uni-td align="center">产品编码</uni-td>
  46. <uni-td align="center">仓库仓位</uni-td>
  47. <uni-td align="center">入库/发货数量</uni-td>
  48. <uni-td align="center">入库金额</uni-td>
  49. </uni-tr>
  50. <!-- 表格数据行 -->
  51. <uni-tr
  52. v-for="item in detailList"
  53. :key="item.id"
  54. :checkedRow="curProduct&&curProduct.dealerProductEntity.qrCode == item.dealerProductEntity.qrCode"
  55. >
  56. <uni-td width="30%" align="center">
  57. <view @click="copyText(item.dealerProductEntity.code)">{{item.dealerProductEntity.code}}</view>
  58. </uni-td>
  59. <uni-td width="30%" align="center">
  60. <view @click="editRow(item)">
  61. <view>{{item.warehouseEntity&&item.warehouseEntity.name||defWarehouseName[0]}}/</view>
  62. <view>{{item.warehouseLocationEntity&&item.warehouseLocationEntity.name||defWarehouseName[1]}}</view>
  63. </view>
  64. </uni-td>
  65. <uni-td width="20%" align="center"><text style="color: red;">{{item.realPutQty}}</text>/{{item.putQty}}</uni-td>
  66. <uni-td width="20%" align="center">
  67. {{item.realPutAmount}}
  68. </uni-td>
  69. </uni-tr>
  70. </uni-table>
  71. </view>
  72. <view class="p-footer">
  73. <button size="mini" type="warn" @click="addQty(false)"> <text class="iconfont icon-reduce-btn"> 减 </text></button>
  74. <button size="mini" type="primary" @click="addQty(true)"> <text class="iconfont icon-add-btn"> 加 </text></button>
  75. </view>
  76. <scanCode @onKeyDown="keyDown"></scanCode>
  77. <!-- 选择仓库 -->
  78. <chooseWarehouse ref="chooseWarehouse" :openPick="showPick" :value="defWarehouse" @close="showPick=false" @change="confirmWarehouse"></chooseWarehouse>
  79. <!-- 左键扫描,修改包装数 -->
  80. <uni-popup ref="popup" :mask-click="false" type="dialog">
  81. <view style="background-color: #fff;padding: 30rpx 50rpx;border-radius: 30rpx;width: 75%;margin: 0 auto;">
  82. <view v-if="curProduct">
  83. <view style="padding: 30rpx 0;">
  84. 产品编码:{{curProduct.dealerProductEntity.code}}
  85. </view>
  86. <view style="display: flex;align-items: center;">
  87. 数量:
  88. <u--input
  89. placeholder="请输入数量"
  90. border="surround"
  91. v-model="curProduct.packQty"
  92. :min="0"
  93. type="digit"
  94. ></u--input>
  95. {{curProduct.dealerProductEntity.unit}}
  96. {{curProduct.dealerProductEntity.packQtyUnit?("/"+curProduct.dealerProductEntity.packQtyUnit):''}}
  97. </view>
  98. </view>
  99. <view style="display: flex;padding: 60rpx 15rpx 10rpx;justify-content: space-between;">
  100. <button size="mini" @click="closePop">取消</button>
  101. <button size="mini" type="primary" @click="okPop">确定</button>
  102. </view>
  103. </view>
  104. </uni-popup>
  105. <u-modal :show="showModal" :title="msg.title" :confirmText="msg.confirmText" showCancelButton :content='msg.content' @cancel="showModal=false" @confirm="confirmModal"></u-modal>
  106. </view>
  107. </template>
  108. <script>
  109. import scanCode from '@/libs/scan-code.vue';
  110. import { purchaseWriteStockIn, receivingQuery, receivingDetail, purchaseUpdateWarehouse, updateRealPutQty, receivingStockInVerify } from '@/config/api.js'
  111. import { playAudio, toThousands } from '@/libs/tools.js'
  112. import clipboard from "@/js_sdk/dc-clipboard/clipboard.js"
  113. import chooseWarehouse from './chooseWarehouse.vue'
  114. export default {
  115. components: { scanCode, chooseWarehouse },
  116. data() {
  117. return {
  118. loading: false,
  119. showModal: false,
  120. msg:{title:'提示',content:''},
  121. showPick: false,
  122. baseData: null,
  123. detailList:[],
  124. code:'',
  125. receivingBillSn: null,
  126. salesId: null,
  127. curProduct: null,
  128. toThousands,
  129. defWarehouse: [],
  130. defWarehouseName:[],
  131. keyName: ''
  132. };
  133. },
  134. onLoad(opts) {
  135. var _this = this
  136. this.receivingBillSn = opts.receivingBillSn
  137. this.salesId = opts.id
  138. // 默认仓库仓位
  139. this.defWarehouse = this.$store.state.vuex_tempData
  140. // 调用数据
  141. this.getDetail()
  142. this.getDetailList()
  143. uni.$on('scancodedate', function(content) {
  144. console.log("扫描到的内容为:", content, _this.keyName)
  145. _this.code = content||''
  146. if(_this.keyName == 'rightKey'){
  147. _this.addQty(true)
  148. }
  149. if(_this.keyName == 'leftKey'){
  150. _this.openPack()
  151. }
  152. })
  153. },
  154. onShow() {
  155. this.hideKeyborder()
  156. const list = this.$store.state.vuex_warehouseList
  157. const an =list.find(item => item.warehouseSn==this.defWarehouse[0])
  158. const cn = an&&an.warehouseLocationList&&an.warehouseLocationList.find(item => item.warehouseLocationSn == this.defWarehouse[1])
  159. this.defWarehouseName = [an&&an.name,cn&&cn.name]
  160. console.log(this.defWarehouseName)
  161. },
  162. onUnload() {
  163. uni.$off('scancodedate')
  164. },
  165. methods: {
  166. hideKeyborder(){
  167. uni.hideKeyboard()
  168. },
  169. // 复制
  170. copyText(text){
  171. clipboard.setText(text);
  172. uni.showToast({
  173. icon: 'none',
  174. title: '编码已复制成功'
  175. })
  176. },
  177. closePop(){
  178. this.$refs.popup.close()
  179. },
  180. okPop(){
  181. if(this.curProduct.packQty){
  182. this.changePutQty(this.curProduct,Number(this.curProduct.realPutQty) + Number(this.curProduct.packQty))
  183. this.closePop()
  184. }else{
  185. uni.$u.toast("请输入数量!")
  186. }
  187. },
  188. keyDown(e){
  189. this.keyName = e
  190. },
  191. // 确定选择仓库
  192. confirmWarehouse(data){
  193. console.log(data)
  194. this.updateWarehouse({id:this.curProduct.id,warehouseSn:data[0],warehouseLocationSn:data[1]})
  195. },
  196. // 修改仓库
  197. editRow(item){
  198. this.showPick = true
  199. this.curProduct = item
  200. },
  201. // 获取当前操作行
  202. getCurRow(){
  203. const curProduct = this.detailList.find(item => item.dealerProductEntity.qrCode == this.code)
  204. this.curProduct = curProduct || null
  205. this.curProduct.packQty = this.curProduct.dealerProductEntity.packQty || 0
  206. return curProduct
  207. },
  208. // 修改仓库
  209. updateWarehouse (row) {
  210. console.log(row)
  211. this.loading = true
  212. purchaseUpdateWarehouse({
  213. id: row.id,
  214. warehouseSn: row.warehouseSn,
  215. warehouseLocationSn: row.warehouseLocationSn
  216. }).then(res => {
  217. if (res.status == 200) {
  218. this.showPick = false
  219. this.getDetailList()
  220. }
  221. this.loading = false
  222. })
  223. },
  224. // 修改入库数量
  225. changePutQty(record, realPutQty){
  226. if(realPutQty){
  227. this.loading = true
  228. updateRealPutQty({id:record.id,realPutQty:realPutQty}).then(res => {
  229. if(res.status == 200){
  230. uni.$u.toast(res.message)
  231. this.getDetail()
  232. this.getDetailList()
  233. }
  234. this.loading = false
  235. })
  236. }else{
  237. uni.$u.toast("入库数量不能为0")
  238. }
  239. },
  240. //拣货
  241. addQty(flag){
  242. if(this.code==''){
  243. uni.$u.toast("请扫描或输入条形码")
  244. return
  245. }
  246. const row = this.getCurRow()
  247. if(row){
  248. if(row.warehouseLocationSn){
  249. this.changePutQty(row,row.realPutQty + (flag?1:-1))
  250. }else{
  251. uni.$u.toast("此商品没有仓库仓位")
  252. }
  253. }else{
  254. uni.$u.toast("此商品不存在")
  255. }
  256. },
  257. // 详情
  258. getDetail(){
  259. receivingQuery({receivingBillSn: this.receivingBillSn}).then(res => {
  260. console.log(res,'详情')
  261. if(res.status == 200){
  262. this.baseData = res.data
  263. }
  264. })
  265. },
  266. // 产品明细列表
  267. getDetailList(){
  268. receivingDetail({pageNo:1,pageSize:1000,receivingBillSn:this.receivingBillSn}).then(res => {
  269. console.log(res,'明细列表')
  270. if(res.status == 200){
  271. this.detailList = res.data.list
  272. this.getCurRow()
  273. }
  274. })
  275. },
  276. // 打开包装数弹框
  277. openPack(){
  278. const curProduct = this.getCurRow()
  279. if(curProduct){
  280. this.$refs.popup.open()
  281. }else{
  282. uni.$u.toast("此商品不存在")
  283. }
  284. },
  285. // 入库
  286. async toOut(){
  287. const isOk = await receivingStockInVerify({receivingBillSn:this.receivingBillSn})
  288. if(!isOk.data){
  289. this.submitForm()
  290. }else{
  291. this.showModal = true
  292. this.msg = {
  293. title: '提示',
  294. content: '有产品入库数量与发货数量不一致',
  295. confirmText: '确定入库'
  296. }
  297. }
  298. },
  299. confirmModal(e){
  300. this.submitForm()
  301. },
  302. async submitForm(){
  303. const a = this.defWarehouse
  304. const ret = await purchaseWriteStockIn({id: this.baseData[0].id,warehouseSn:a[0], warehouseLocationSn:a[1]})
  305. if(ret.status == 200){
  306. this.$store.state.vuex_isRefash = true
  307. uni.navigateBack()
  308. }
  309. this.showModal = false
  310. }
  311. },
  312. }
  313. </script>
  314. <style lang="scss">
  315. .p-content{
  316. .p-head{
  317. font-size: 32upx;
  318. color: $uni-text-color;
  319. >view{
  320. display: flex;
  321. align-items: center;
  322. padding: 10upx 20upx;
  323. border-bottom: 1px solid #eee;
  324. justify-content: space-between;
  325. > view{
  326. display: flex;
  327. padding: 0 10upx;
  328. align-items: center;
  329. }
  330. }
  331. .uni-input{
  332. border: 1px solid #eee;
  333. width: 150upx;
  334. text-align: center;
  335. padding: 8upx;
  336. }
  337. }
  338. .p-body{
  339. overflow: auto;
  340. flex-grow: 1;
  341. height: 50%;
  342. }
  343. .p-footer{
  344. padding:30upx;
  345. display: flex;
  346. > button{
  347. width: 40%;
  348. }
  349. }
  350. }
  351. </style>