shiftHandover.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  1. <template>
  2. <view class="checkSubmit">
  3. <view class="form-box" style="margin:0 30rpx">
  4. <uni-forms ref="baseForm" label-position="left">
  5. <view class="commons-title">
  6. 接班人员
  7. </view>
  8. <uni-forms-item label="接班人员" required>
  9. <picker @change="bindPickerChange2" :range="userList" range-key="nickName">
  10. <view class="" style="text-align: right;display: flex;justify-content: space-between;padding-top:20rpx">
  11. <view class="" style="color:#999">
  12. {{successorName || '请选择接班人员'}}
  13. </view>
  14. <uni-icons type="forward" size="20"></uni-icons>
  15. </view>
  16. </picker>
  17. </uni-forms-item>
  18. <view class="commons-title">
  19. 转班明细
  20. </view>
  21. <view style="border-bottom: 1rpx solid #000;" v-for="(i,index) in formData" :key="i.qrCode">
  22. <uni-forms-item label="物料名称" required>
  23. <view>
  24. <view class="" style="text-align: right;display: flex;justify-content: space-between;padding-top:20rpx">
  25. <view class="" style="color:#999" @click="openSelectQd(index)">
  26. {{i.qrCodeName || '请选择物料或者扫描二维码'}}
  27. </view>
  28. <uni-icons type="scan" @click="scanCode(index)" size="20"></uni-icons>
  29. <uni-icons @click="openSelectQd(index)" type="forward" size="20"></uni-icons>
  30. </view>
  31. </view>
  32. </uni-forms-item>
  33. <view style="width:90%">
  34. <uni-forms-item label="称重结果" required>
  35. <uni-easyinput v-model="i.weighingResults" />
  36. <span style="position: absolute;right:-80rpx;top:10px">kg</span>
  37. </uni-forms-item>
  38. </view>
  39. <uni-forms-item label="有无外包装" required>
  40. <switch style="transform:scale(0.8)" @change="(e)=>switchChange(e,index,'outerPackaging')" />
  41. </uni-forms-item>
  42. <uni-forms-item label="有无卷芯" required>
  43. <switch style="transform:scale(0.8)" @change="(e)=>switchChange(e,index,'convolution')" />
  44. </uni-forms-item>
  45. </view>
  46. </uni-forms>
  47. <button size="mini" type="default" style="width: 500rpx;margin: 20rpx auto;display: block;"
  48. @click="add()">
  49. 添加明细
  50. </button>
  51. </view>
  52. <view class="submit-box">
  53. <view class="" style="line-height: 80rpx;text-align: center;">
  54. 本次转班:{{formData.length}} 件
  55. </view>
  56. <button @click="addShift" style="background: #0066CC;color:#fff;margin-bottom: 30rpx;">提交</button>
  57. </view>
  58. <uni-popup ref="popup" type="top">
  59. <view class="search-box">
  60. <uni-search-bar @confirm="getMaterial" v-model="req.materialName" @cancel="reload">
  61. </uni-search-bar>
  62. <ul>
  63. <li @click="selectMaterialList(i)" v-for="i in materialList" :key="i.id">
  64. {{i.name}}
  65. </li>
  66. </ul>
  67. </view>
  68. </uni-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import {
  73. getInfo
  74. } from "@/util/api.js";
  75. import Vue from 'vue'
  76. import htzImageUpload from '@/components/htz-image-upload/htz-image-upload.vue'
  77. import {
  78. dateFormat,
  79. getTime
  80. } from '../../util/uitl.js'
  81. export default {
  82. components: {
  83. htzImageUpload,
  84. },
  85. data() {
  86. return {
  87. req:{
  88. materialName:null,
  89. },
  90. formData: [],
  91. userList:[],
  92. materialList:[],
  93. successorName:null,
  94. successorId:null,
  95. userData:null,
  96. materialIndex:null,
  97. }
  98. },
  99. onLoad(option) {
  100. const v = this
  101. v.getUser()
  102. uni.getStorage({
  103. key: "userInfo",
  104. success(_data) {
  105. v.userData = _data.data
  106. },
  107. fail() {
  108. }
  109. })
  110. //v.getMaterial()
  111. },
  112. methods: {
  113. selectMaterialList(i){
  114. const v = this
  115. console.log(i)
  116. v.formData[v.materialIndex].qrCode = null
  117. v.formData[v.materialIndex].qrCodeName = i.name
  118. v.formData[v.materialIndex].quantity = null
  119. v.formData[v.materialIndex].materialId = i.id
  120. console.log(v.formData)
  121. },
  122. addShift(){
  123. const v = this
  124. console.log(v.formData,123123123)
  125. if(!v.successorId){
  126. uni.showToast({
  127. icon:'none',
  128. title: '请选择交接人员',
  129. duration: 2000
  130. });
  131. return
  132. }
  133. if(v.formData.length == 0){
  134. uni.showToast({
  135. icon:'none',
  136. title: '请添加明细',
  137. duration: 2000
  138. });
  139. return
  140. }
  141. for (var i = 0; i < v.formData.length; i++) {
  142. const element = v.formData[i]
  143. element.shiftHandoverPersonneId = v.userData.id
  144. element.successorId = v.successorId
  145. element.count = v.formData.length
  146. console.log(element.weighingResults)
  147. if(element.weighingResults == 0 || !element.weighingResults){
  148. uni.showToast({
  149. icon:'none',
  150. title: '请填写物料剩余数量',
  151. duration: 2000
  152. });
  153. return
  154. }
  155. if(!element.materialId){
  156. uni.showToast({
  157. icon:'none',
  158. title: '请选择物料',
  159. duration: 2000
  160. });
  161. return
  162. }
  163. }
  164. v.$post('/mgr/shiftChange/addShift',v.formData).then(res=>{
  165. if(res.code == 200){
  166. uni.showToast({
  167. title: '提交成功,跳转中!'
  168. })
  169. setTimeout(()=>{
  170. wx.reLaunch({
  171. url: '/pages/home'
  172. })
  173. },500)
  174. }
  175. })
  176. },
  177. add(){
  178. const v = this
  179. v.formData.push({
  180. shiftHandoverPersonneId:null,
  181. successorId:null,
  182. qrCode:null,
  183. qrCodeName:null,
  184. materialId:null,
  185. quantity:null,
  186. convolution:0,
  187. outerPackaging:0,
  188. weighingResults:0,
  189. })
  190. },
  191. scanCode(index) {
  192. const v = this
  193. uni.scanCode({
  194. onlyFromCamera: true,
  195. success: function(res) {
  196. uni.showToast({
  197. icon: "loading",
  198. title: '加载中',
  199. duration: 1500
  200. });
  201. v.$post('/wx/common/gerMaterialInfoByQrcode', {
  202. qrCode: res.result
  203. }).then(res => {
  204. if(res.code == 200){
  205. v.formData[index].qrCode = res.data.qrCode
  206. v.formData[index].qrCodeName = res.data.materialName
  207. v.formData[index].quantity = res.data.quantity
  208. v.formData[index].materialId = res.data.materialId
  209. }
  210. })
  211. }
  212. });
  213. },
  214. //打开搜索
  215. openSelectQd(index){
  216. const v = this
  217. v.materialIndex = index
  218. this.$refs.popup.open('top')
  219. },
  220. reload(){
  221. this.req.keyword = null
  222. this.getMaterial()
  223. },
  224. //物料信息
  225. getMaterial(){
  226. const v = this
  227. v.$post('/wx/common/getMaterial',v.req).then(res=>{
  228. if(res.code == 200){
  229. v.materialList = res.data
  230. }
  231. })
  232. },
  233. //用户信息
  234. getUser(){
  235. const v = this
  236. v.$post('/wx/common/getUser',v.formData).then(res=>{
  237. if(res.code == 200){
  238. v.userList = res.data
  239. }
  240. })
  241. },
  242. switchChange(e,index,key){
  243. const v = this
  244. e.detail.value ? v.formData[index][key] = 1 : v.formData[index][key] = 0
  245. console.log(v.formData)
  246. },
  247. //选择人员
  248. bindPickerChange2(e){
  249. const v = this
  250. console.log(v.userList[e.detail.value])
  251. v.successorName = v.userList[e.detail.value].nickName
  252. v.successorId = v.userList[e.detail.value].userId
  253. },
  254. },
  255. }
  256. </script>
  257. <style lang="less">
  258. .checkSubmit {
  259. .search-box{
  260. background-color: #fff;
  261. ul{
  262. li{
  263. height: 80rpx;
  264. line-height: 80rpx;
  265. padding: 0 30rpx;
  266. border-bottom: 1rpx solid #dcdcdc;
  267. }
  268. }
  269. }
  270. .submit-box {
  271. padding: 0 30rpx;
  272. }
  273. .dtl {
  274. padding: 30rpx;
  275. border-bottom: 1rpx solid #dcdcdc;
  276. font-size: 26rpx;
  277. line-height: 40rpx;
  278. }
  279. .addQrcode-list {
  280. height: 80rpx;
  281. display: flex;
  282. justify-content: space-between;
  283. padding: 15rpx;
  284. border-bottom: 1rpx solid #dcdcdc;
  285. font-size: 24rpx;
  286. .fl {
  287. display: flex;
  288. .code {
  289. margin-right: 20rpx;
  290. }
  291. }
  292. .fr {
  293. line-height: 80rpx;
  294. }
  295. }
  296. }
  297. .popup-input-warp {
  298. padding: 30rpx 40rpx;
  299. }
  300. .txt {
  301. margin-bottom: 20rpx;
  302. }
  303. .imglist {
  304. display: flex;
  305. flex-wrap: wrap;
  306. }
  307. .imglist .item {
  308. width: 150rpx;
  309. height: 150rpx;
  310. margin-right: 22rpx;
  311. margin-bottom: 10rpx;
  312. position: relative;
  313. }
  314. .imglist .last-item {
  315. width: 150rpx;
  316. height: 150rpx;
  317. text-align: center;
  318. line-height: 146rpx;
  319. border: 2rpx dashed #8B97A9;
  320. box-sizing: border-box;
  321. }
  322. .imglist .item image {
  323. width: 100%;
  324. height: 100%;
  325. }
  326. .imglist .item .delete {
  327. width: 30rpx;
  328. height: 30rpx;
  329. position: absolute;
  330. top: -25rpx;
  331. right: -12rpx;
  332. font-size: 40rpx;
  333. font-weight: bold;
  334. }
  335. </style>