store-out.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. <!-- 手动出库 -->
  2. <template>
  3. <view class="container-wrap">
  4. <uni-nav-bar title="手动出库" :status-bar="true" background-color="#3F92F9" color="#FFF">
  5. <view slot="left">
  6. <u-icon name="account-fill" color="#FFF" size="35"></u-icon>
  7. <span style="padding: 0 5rpx;color: #FFFFFF;">{{ userInfo.name }}</span>
  8. </view>
  9. <view slot="right" @tap="$utils.back()">
  10. <span style="color: #FFFFFF;">返回</span>
  11. </view>
  12. </uni-nav-bar>
  13. <view class="container">
  14. <view class="title">
  15. <span>
  16. <span style="color: red;">*</span>
  17. 出库信息
  18. </span>
  19. </view>
  20. <view class="text">
  21. <view class="label">领料人:</view>
  22. <select-lay :value="operateUser" placeholder="默认当前用户" :options="userList" @selectitem="selectitem" :zindex="2000"></select-lay>
  23. </view>
  24. <view class="text">
  25. <view class="label">仓库:</view>
  26. <select-lay :zindex="1000" :value="plcStationCode" :options="selectList" @selectitem="storeSelectitem"></select-lay>
  27. </view>
  28. <view class="text">
  29. <view class="label">出库类型:</view>
  30. <select-lay :value="stockChangeType" :options="typeList" @selectitem="typeSelectitem"></select-lay>
  31. </view>
  32. <view class="text" style="align-items: flex-start;">
  33. <view class="label">备注:</view>
  34. <u-input v-model="remark" type="textarea" :border="true" />
  35. </view>
  36. <view class="text" style="margin: 20rpx 0 30rpx 0;">
  37. <view class="label">领料时间:</view>
  38. <view style="line-height: 1;">{{ time }}</view>
  39. </view>
  40. <view class="title flex-between">
  41. <span>
  42. <span style="color: red;">*</span>
  43. 出库列表
  44. </span>
  45. <a href="#" @click="scan">+扫描添加</a>
  46. </view>
  47. <view class="list">
  48. <view class="item" v-for="(item, index) in scanList" :key="index">
  49. <view class="row">
  50. <view class="col">
  51. <view class="value">{{ item.materialCode }}</view>
  52. </view>
  53. <view class="col">
  54. <view class="value">{{ item.materialName }}</view>
  55. </view>
  56. </view>
  57. <view class="row sub-row">
  58. <view class="col">
  59. <view class="label">规格:</view>
  60. <view class="value">{{ item.spec }}</view>
  61. </view>
  62. <view class="col">
  63. <view class="label">数量:</view>
  64. <view class="value">{{ item.quantity }}米</view>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <my-fixed-button :customClick="true" @click="cfm" text="提交"></my-fixed-button>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import DateFormat from '../../../js_sdk/xfl-DateFormat/DateFormat.js';
  75. export default {
  76. data() {
  77. return {
  78. timer: null,
  79. time: new DateFormat(new Date()).toString(),
  80. show: false,
  81. operateUser: this.$storage.getStorageSync('userInfo').id,
  82. userInfo: this.$storage.getStorageSync('userInfo'),
  83. plcStationCode: '1',
  84. stockChangeType: '20',
  85. remark: '',
  86. isReading: false,
  87. scanList: [],
  88. userList: [],
  89. selectList: [],
  90. typeList: [
  91. { label: '出库', value: 20 },
  92. { label: '盘点删除', value: 21 },
  93. { label: '补出库', value: 23 },
  94. ],
  95. roleKey:null,
  96. accountNo:null,
  97. token:this.$storage.getStorageSync('token'),
  98. };
  99. },
  100. methods: {
  101. /* 选择类型 */
  102. typeSelectitem(index, item) {
  103. this.stockChangeType = item.value;
  104. },
  105. /* 选择领料人 */
  106. selectitem(index, item) {
  107. this.operateUser = item.value;
  108. this.roleKey = item.roleKey
  109. this.accountNo = item.accountNo
  110. console.log(this.accountNo)
  111. },
  112. /* 选择仓库 */
  113. storeSelectitem(index, item) {
  114. this.plcStationCode = item.value;
  115. uni.setStorage({
  116. key: 'plcStationCode',
  117. data: item.value
  118. })
  119. },
  120. cfm(){
  121. let obj = {
  122. userId: this.operateUser,
  123. plcCode: this.plcStationCode * 1,
  124. //rfidItems:['B00000000000000000030854'],
  125. rfidItems: this.scanList.map(item => item.rfidCode),
  126. stockChangeType: this.stockChangeType,
  127. remark: this.remark,
  128. device:1,
  129. }
  130. console.log(obj)
  131. if((this.roleKey == 'sewing' || this.roleKey == 'crop' || this.roleKey == '001')){
  132. if(this.stockChangeType == 20){
  133. this.materialReceiveSubmit(obj)
  134. return
  135. }
  136. }
  137. if(this.stockChangeType == 23){
  138. this.materialReceiveSubmit(obj)
  139. return
  140. }
  141. uni.request({
  142. url: 'http://120.79.80.64:8050' + '/cloudApi/stock/out',
  143. method: 'POST',
  144. header:{
  145. 'Content-Type' : 'application/json',
  146. },
  147. data: obj,
  148. success: res => {
  149. console.log(res)
  150. if(res.data.code == 200){
  151. this.$msg.showToast(res.msg || '操作成功!')
  152. this.timer = setTimeout(() => {
  153. this.$utils.back()
  154. }, 2000)
  155. }
  156. },fail(err) {
  157. console.log(err);
  158. }
  159. });
  160. // this.$http.HandleMacStockInOut(obj).then(res => {
  161. // console.log(res)
  162. // if(res.code === 0) {
  163. // this.$msg.showToast(res.msg || '操作成功!')
  164. // this.timer = setTimeout(() => {
  165. // this.$utils.back()
  166. // }, 2000)
  167. // }
  168. // })
  169. },
  170. materialReceiveSubmit(obj){
  171. console.log({
  172. rfidItems: this.scanList.map(item => item.rfidCode),
  173. submitUserId:this.userInfo.id,
  174. submitUserAccount:this.userInfo.account,
  175. receiveUserAccount: this.accountNo,
  176. type:(this.stockChangeType == 20) ? 1 : 2,
  177. userId: this.operateUser,
  178. plcCode: this.plcStationCode,
  179. rfidItems: this.scanList.map(item => item.rfidCode),
  180. stockChangeType: this.stockChangeType,
  181. remark: this.remark,
  182. token:this.token
  183. })
  184. uni.request({
  185. url: 'http://120.79.80.64:8050' + '/cloudApi/materialReceiving/submit',
  186. method: 'POST',
  187. header:{
  188. 'Content-Type' : 'application/json',
  189. },
  190. data: {
  191. rfidItems: this.scanList.map(item => item.rfidCode),
  192. submitUserId:this.userInfo.id,
  193. submitUserAccount:this.userInfo.account,
  194. receiveUserAccount: this.accountNo,
  195. type:(this.stockChangeType == 20) ? 1 : 2,
  196. userId: this.operateUser,
  197. plcCode: this.plcStationCode,
  198. rfidItems: this.scanList.map(item => item.rfidCode),
  199. stockChangeType: this.stockChangeType,
  200. remark: this.remark,
  201. token:this.token
  202. },
  203. success: res => {
  204. console.log(res)
  205. if(res.data.code == 200){
  206. this.$msg.showToast(res.msg || '操作成功!')
  207. this.timer = setTimeout(() => {
  208. this.$utils.back()
  209. }, 2000)
  210. }
  211. },fail(err) {
  212. console.log(err);
  213. }
  214. });
  215. },
  216. /* 扫描添加 */
  217. scan() {
  218. this.$utils.open('/pages/store-out-manage/store-out/store-out-scan')
  219. },
  220. getList () {
  221. this.$http.GetApplyStockOutTemp().then(res => {
  222. console.log(res)
  223. if(res.code === 0) {
  224. this.scanList = res.result
  225. }
  226. })
  227. },
  228. /* 添加扫描到的退货数据 */
  229. pushData(data) {
  230. console.log(this.scanList)
  231. let flag = true
  232. this.scanList.forEach(item => {
  233. if(item.rfidCode === data.rfidCode) {
  234. flag = false
  235. }
  236. })
  237. if(flag) {
  238. this.scanList.push(data)
  239. } else {
  240. setTimeout(() => {
  241. this.$msg.showToast('标签已存在!')
  242. }, 100)
  243. }
  244. },
  245. /* 获取用户列表 */
  246. getUserPageList() {
  247. uni.request({
  248. url: 'http://120.79.80.64:8050' + '/cloudApi/uUser/list',
  249. method: 'POST',
  250. header: {
  251. 'Content-Type': 'application/json',
  252. },
  253. data: {
  254. deptIdList: ['A012', 'A008', 'A007', 'A017', 'A005'],
  255. },
  256. success: res => {
  257. console.log(res)
  258. let list = res.data.data.map((item) => {
  259. return {
  260. label: item.realname,
  261. value: item.id,
  262. name: item.realname,
  263. }
  264. })
  265. this.userList = list
  266. },
  267. });
  268. },
  269. /* 手持机获取仓库 */
  270. getStockHouse() {
  271. this.$http.GetStockHouse().then(res => {
  272. if(res.code === 0) {
  273. this.selectList = res.result.map(item => {
  274. return {
  275. label: item.name,
  276. value: item.plcCode
  277. }
  278. })
  279. }
  280. })
  281. }
  282. },
  283. onLoad(option) {
  284. this.getUserPageList()
  285. this.getStockHouse()
  286. console.log(this.$storage.getStorageSync('token'),'token')
  287. uni.$on('scan-list', res => {
  288. console.log('?????????????')
  289. console.log(res)
  290. this.pushData(res)
  291. })
  292. uni.getStorage({
  293. key: 'plcStationCode',
  294. success: (res) => {
  295. this.plcStationCode = res.data
  296. }
  297. });
  298. },
  299. onUnload() {
  300. clearTimeout(this.timer)
  301. uni.$off('scan-list')
  302. }
  303. }
  304. </script>
  305. <style lang="scss" scoped>
  306. .container-wrap {
  307. overflow: hidden;
  308. .container {
  309. padding: 20rpx;
  310. height: calc(100vh - var(--status-bar-height) - 44px);
  311. overflow: auto;
  312. padding-bottom: 100rpx;
  313. .text {
  314. padding: 10rpx 0;
  315. display: flex;
  316. align-items: center;
  317. font-size: 24rpx;
  318. .label {
  319. width: 150rpx;
  320. text-align: right;
  321. }
  322. }
  323. .list {
  324. margin: 10rpx 0;
  325. .item {
  326. padding: 20rpx;
  327. margin-bottom: 10rpx;
  328. background-color: #FFFFFF;
  329. border: 1rpx solid rgba(215, 215, 215, 1);
  330. border-radius: 10rpx;
  331. .row {
  332. &.border {
  333. border-bottom: 1px solid rgba(215, 215, 215, 1);
  334. }
  335. .label {
  336. width: 80rpx;
  337. }
  338. .col {
  339. &:last-child {
  340. justify-content: flex-end;
  341. }
  342. }
  343. }
  344. .sub-row {
  345. align-items: flex-start;
  346. .label, .value {
  347. font-size: 24rpx;
  348. color: #7F7F7F;
  349. }
  350. }
  351. }
  352. }
  353. }
  354. }
  355. </style>