location-edit.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. <template>
  2. <view class="location-edit">
  3. <ul>
  4. <li v-for="(i,index) in listData" :key="i.id">
  5. <view class="label">
  6. 物料编码:{{i.materialCode}}
  7. <view class="" @click="deteleFn(i,index)">
  8. <image style="width:36rpx;height:36rpx" src="@/static/images/delete.png" mode=""></image>
  9. </view>
  10. </view>
  11. <view class="label">
  12. 物料名:{{i.materialName}}
  13. </view>
  14. <view class="label">
  15. <view class="">
  16. 数量:{{i.quantity}}
  17. </view>
  18. <view class="">
  19. 所在仓库:{{i.houseName}}
  20. </view>
  21. </view>
  22. <view class="label" @click="open(i,index)">
  23. 货架:{{ i.PlaceAreaName || '点击选择货架'}} >
  24. </view>
  25. </li>
  26. </ul>
  27. <view class="footer-btn">
  28. <view class="shaomiao" @click="scan()">
  29. <image style="width:36rpx;height:36rpx" src="@/static/images/shaomiao.png" mode=""></image>
  30. 扫描
  31. </view>
  32. <view class="set" @click="open()">
  33. 批量设置库存
  34. </view>
  35. </view>
  36. <view class="fixed-btn">
  37. <button style="background-color: #1A3AF0;color:#fff" @click="submitFn">提交</button>
  38. <button @click="backFn">取消</button>
  39. </view>
  40. <uni-popup ref="popup" type="top">
  41. <view class="search-box">
  42. <view class="">
  43. <input v-model="searchText" @input="search" class="uni-input" @ placeholder="输入货架名称进行搜索如A5" />
  44. </view>
  45. <ul>
  46. <li @click="selectMaterialList(i)" v-for="(i,index) in range" :key="i.id">
  47. {{i.name}}
  48. </li>
  49. </ul>
  50. </view>
  51. </uni-popup>
  52. </view>
  53. </template>
  54. <script>
  55. const pda = uni.requireNativePlugin('js-pda');
  56. export default {
  57. data(){
  58. return {
  59. timer: null,
  60. data: {},
  61. isReading: true,
  62. rfidCode: '',
  63. scanCode: '',
  64. listData:[],
  65. range:[],
  66. rangeCopy:[],
  67. searchText:'',
  68. setIndex:0,
  69. }
  70. },
  71. created(){
  72. this.getStockArea()
  73. },
  74. methods:{
  75. deteleFn(item,index){
  76. this.listData.splice(index,1)
  77. },
  78. backFn(){
  79. uni.navigateBack()
  80. },
  81. submitFn(){
  82. const req = [];
  83. if(this.listData.length == 0){
  84. uni.showToast({
  85. icon:"none",
  86. title: '请扫描物料',
  87. duration: 1000
  88. })
  89. return
  90. }
  91. for (var i = 0; i < this.listData.length; i++) {
  92. if(this.listData[i].PlaceAreaName == null){
  93. uni.showToast({
  94. icon:"none",
  95. title: '请选择货架',
  96. duration: 1000
  97. })
  98. return
  99. }
  100. req.push({
  101. placeareaid:this.listData[i].PlaceAreaId,
  102. id:this.listData[i].id
  103. })
  104. }
  105. uni.request({
  106. url: 'http://120.79.80.64:8050' + '/cloudApi/stockDetail/setAreaId',
  107. data: req,
  108. method: 'POST',
  109. success: (res) => {
  110. console.log(res)
  111. if(res.data.code == 200){
  112. uni.showToast({
  113. title: '设置成功',
  114. duration: 1000
  115. })
  116. setTimeout(()=>{
  117. uni.navigateBack()
  118. },1000)
  119. }
  120. },
  121. fail: (err) => {
  122. console.log(err)
  123. }
  124. });
  125. },
  126. search(){
  127. const v = this
  128. v.range = []
  129. const range = JSON.parse(JSON.stringify(v.rangeCopy))
  130. for (var i = 0; i < range.length; i++) {
  131. if(range[i].name.indexOf(v.searchText) != -1){
  132. v.range.push(range[i])
  133. }
  134. }
  135. },
  136. open(item,index){
  137. console.log(index)
  138. if(index != undefined){
  139. this.$refs.popup.open('top')
  140. this.setIndex = index
  141. }else{
  142. this.$refs.popup.open('top')
  143. this.setIndex = 'all'
  144. }
  145. },
  146. selectMaterialList(i){
  147. const v = this
  148. console.log(i)
  149. if(this.setIndex == 'all'){
  150. for (var j = 0; j < v.listData.length; j++) {
  151. v.listData[j].PlaceAreaId = i.id
  152. v.listData[j].PlaceAreaName = i.name
  153. }
  154. }else{
  155. v.listData[v.setIndex].PlaceAreaId = i.id
  156. v.listData[v.setIndex].PlaceAreaName = i.name
  157. }
  158. console.log(v.listData)
  159. this.$refs.popup.close()
  160. },
  161. getStockArea(){
  162. const v = this
  163. uni.request({
  164. url: 'http://120.79.80.64:8050' + '/cloudApi/stockArea/list',
  165. data: {},
  166. method: 'POST',
  167. success: (res) => {
  168. console.log(res)
  169. if(res.data.code == 200){
  170. this.range = res.data.data
  171. this.rangeCopy = res.data.data
  172. }
  173. },
  174. fail: (err) => {
  175. console.log(err)
  176. }
  177. });
  178. },
  179. scan() {
  180. const v = this
  181. uni.scanCode({
  182. success(res) {
  183. uni.request({
  184. url: 'http://120.79.80.64:8050' + '/cloudApi/stockDetail/getMaterialInfoByQrCode',
  185. data: {
  186. qrCode:res.result
  187. },
  188. method: 'POST',
  189. success: (res) => {
  190. console.log(res.data)
  191. if(res.data.code == 200){
  192. for (var i = 0; i < v.listData.length; i++) {
  193. if(v.listData[i].materialCode == res.data.data.materialCode){
  194. uni.showToast({
  195. icon:"none",
  196. title: '此物料已扫描',
  197. duration: 1000
  198. })
  199. return
  200. }
  201. }
  202. v.listData.push({...res.data.data,PlaceAreaName:null})
  203. }
  204. },
  205. fail: (err) => {
  206. }
  207. });
  208. }
  209. })
  210. },
  211. },
  212. }
  213. </script>
  214. <style scoped lang="less">
  215. .fixed-btn{
  216. display: flex;
  217. position: fixed;
  218. bottom: 10rpx;
  219. left: 0;
  220. right: 0;
  221. button{
  222. width: 40%;
  223. margin: 0 5%;
  224. }
  225. }
  226. .search-box{
  227. height: 80vh;
  228. overflow-y: scroll;
  229. background-color: #fff;
  230. ul{
  231. height: 70vh;
  232. overflow-y: scroll;
  233. }
  234. input{
  235. height: 70rpx;
  236. padding: 10rpx;
  237. border:1rpx solid #dcdcdc;
  238. margin: 10rpx;
  239. }
  240. ul{
  241. }
  242. }
  243. .location-edit{
  244. .footer-btn{
  245. .set{
  246. height: 70rpx;
  247. line-height: 70rpx;
  248. background: #EF0000;
  249. text-align: center;
  250. margin: 20rpx 20rpx;
  251. border-radius: 10rpx;
  252. color: #fff;
  253. }
  254. .shaomiao{
  255. height: 70rpx;
  256. line-height: 70rpx;
  257. background: #fff;
  258. text-align: center;
  259. margin: 0 20rpx;
  260. border:2rpx solid #979797;
  261. border-radius: 10rpx;
  262. image{
  263. margin-right: 20rpx;
  264. position: relative;
  265. top: 10rpx;
  266. }
  267. }
  268. }
  269. ul{
  270. padding: 0;
  271. margin: 30rpx 18rpx 20rpx;
  272. li{
  273. padding: 5rpx 40rpx;
  274. list-style: none;
  275. background-color: #fff;
  276. margin-top: 20rpx;
  277. .label{
  278. height: 66rpx;
  279. line-height: 66rpx;
  280. display: flex;
  281. justify-content: space-between;
  282. }
  283. .fl{
  284. float: left;
  285. }
  286. .fr{
  287. float: right;
  288. }
  289. }
  290. }
  291. }
  292. </style>