store-out.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  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,
  124. rfidItems: this.scanList.map(item => item.rfidCode),
  125. stockChangeType: this.stockChangeType,
  126. remark: this.remark
  127. }
  128. console.log(obj)
  129. if((this.roleKey == 'sewing' || this.roleKey == 'crop' || this.roleKey == '001')){
  130. if(this.stockChangeType == 20){
  131. this.materialReceiveSubmit(obj)
  132. return
  133. }
  134. }
  135. if(this.stockChangeType == 23){
  136. this.materialReceiveSubmit(obj)
  137. return
  138. }
  139. this.$http.HandleMacStockInOut(obj).then(res => {
  140. console.log(res)
  141. if(res.code === 0) {
  142. this.$msg.showToast(res.msg || '操作成功!')
  143. this.timer = setTimeout(() => {
  144. this.$utils.back()
  145. }, 2000)
  146. }
  147. })
  148. },
  149. materialReceiveSubmit(obj){
  150. console.log({
  151. rfidItems: this.scanList.map(item => item.rfidCode),
  152. submitUserId:this.userInfo.id,
  153. submitUserAccount:this.userInfo.account,
  154. receiveUserAccount: this.accountNo,
  155. type:(this.stockChangeType == 20) ? 1 : 2,
  156. userId: this.operateUser,
  157. plcCode: this.plcStationCode,
  158. rfidItems: this.scanList.map(item => item.rfidCode),
  159. stockChangeType: this.stockChangeType,
  160. remark: this.remark,
  161. token:this.token
  162. })
  163. uni.request({
  164. url: 'http://120.79.80.64:8050' + '/cloudApi/materialReceiving/submit',
  165. method: 'POST',
  166. header:{
  167. 'Content-Type' : 'application/json',
  168. },
  169. data: {
  170. rfidItems: this.scanList.map(item => item.rfidCode),
  171. submitUserId:this.userInfo.id,
  172. submitUserAccount:this.userInfo.account,
  173. receiveUserAccount: this.accountNo,
  174. type:(this.stockChangeType == 20) ? 1 : 2,
  175. userId: this.operateUser,
  176. plcCode: this.plcStationCode,
  177. rfidItems: this.scanList.map(item => item.rfidCode),
  178. stockChangeType: this.stockChangeType,
  179. remark: this.remark,
  180. token:this.token
  181. },
  182. success: res => {
  183. console.log(res)
  184. if(res.data.code == 200){
  185. this.$msg.showToast(res.msg || '操作成功!')
  186. this.timer = setTimeout(() => {
  187. this.$utils.back()
  188. }, 2000)
  189. }
  190. },fail(err) {
  191. console.log(err);
  192. }
  193. });
  194. },
  195. /* 扫描添加 */
  196. scan() {
  197. this.$utils.open('/pages/store-out-manage/store-out/store-out-scan')
  198. },
  199. getList () {
  200. this.$http.GetApplyStockOutTemp().then(res => {
  201. console.log(res)
  202. if(res.code === 0) {
  203. this.scanList = res.result
  204. }
  205. })
  206. },
  207. /* 添加扫描到的退货数据 */
  208. pushData(data) {
  209. console.log(this.scanList)
  210. let flag = true
  211. this.scanList.forEach(item => {
  212. if(item.rfidCode === data.rfidCode) {
  213. flag = false
  214. }
  215. })
  216. if(flag) {
  217. this.scanList.push(data)
  218. } else {
  219. setTimeout(() => {
  220. this.$msg.showToast('标签已存在!')
  221. }, 100)
  222. }
  223. },
  224. /* 获取用户列表 */
  225. getUserPageList() {
  226. this.$http.GetUserPageList({
  227. pageIndex: 1,
  228. pageSize: 999,
  229. takeUser: true
  230. }).then(res => {
  231. console.log(res)
  232. if(res.code == 0) {
  233. let list = res.result.list.map(item => {
  234. return {
  235. label: item.realName,
  236. value: item.id,
  237. roleKey: item.roleKey,
  238. accountNo:item.accountNo
  239. }
  240. })
  241. this.userList = list
  242. }
  243. })
  244. },
  245. /* 手持机获取仓库 */
  246. getStockHouse() {
  247. this.$http.GetStockHouse().then(res => {
  248. if(res.code === 0) {
  249. this.selectList = res.result.map(item => {
  250. return {
  251. label: item.name,
  252. value: item.plcCode
  253. }
  254. })
  255. }
  256. })
  257. }
  258. },
  259. onLoad(option) {
  260. this.getUserPageList()
  261. this.getStockHouse()
  262. console.log(this.$storage.getStorageSync('token'),'token')
  263. uni.$on('scan-list', res => {
  264. console.log('?????????????')
  265. console.log(res)
  266. this.pushData(res)
  267. })
  268. uni.getStorage({
  269. key: 'plcStationCode',
  270. success: (res) => {
  271. this.plcStationCode = res.data
  272. }
  273. });
  274. },
  275. onUnload() {
  276. clearTimeout(this.timer)
  277. uni.$off('scan-list')
  278. }
  279. }
  280. </script>
  281. <style lang="scss" scoped>
  282. .container-wrap {
  283. overflow: hidden;
  284. .container {
  285. padding: 20rpx;
  286. height: calc(100vh - var(--status-bar-height) - 44px);
  287. overflow: auto;
  288. padding-bottom: 100rpx;
  289. .text {
  290. padding: 10rpx 0;
  291. display: flex;
  292. align-items: center;
  293. font-size: 24rpx;
  294. .label {
  295. width: 150rpx;
  296. text-align: right;
  297. }
  298. }
  299. .list {
  300. margin: 10rpx 0;
  301. .item {
  302. padding: 20rpx;
  303. margin-bottom: 10rpx;
  304. background-color: #FFFFFF;
  305. border: 1rpx solid rgba(215, 215, 215, 1);
  306. border-radius: 10rpx;
  307. .row {
  308. &.border {
  309. border-bottom: 1px solid rgba(215, 215, 215, 1);
  310. }
  311. .label {
  312. width: 80rpx;
  313. }
  314. .col {
  315. &:last-child {
  316. justify-content: flex-end;
  317. }
  318. }
  319. }
  320. .sub-row {
  321. align-items: flex-start;
  322. .label, .value {
  323. font-size: 24rpx;
  324. color: #7F7F7F;
  325. }
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>