materialTransfer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <div class="materialTransfer">
  3. <view class="add-header">
  4. 转仓面料: <button @click="openModal">添加物料</button>
  5. </view>
  6. <view class="ul">
  7. <view class="li" v-for="(i,index) in form.backDetailList" :key="i.materialId">
  8. <view class="label">
  9. 物料名称:{{i.name}}
  10. </view>
  11. <view class="lists">
  12. <view class="list-box" v-for="(j,jindex) in i.stockTransferDetailsList" :key="jindex">
  13. <view>卷{{jindex + 1}}</view>
  14. <view>
  15. <span>{{j.quantity}}</span>
  16. </view>
  17. </view>
  18. <view class="user-select">
  19. <view style="width:30%">
  20. 接收人:
  21. </view>
  22. <view class="" style="width:70%;border: 1rpx solid #dcdcdc;padding:0 20rpx">
  23. <picker :value="i.receiveUser" :range="selectOneList"
  24. @change="(e)=>printingWorkersSelect(e,index)" range-key="realName" style="width:100%">
  25. <view class="uni-input">{{i.userName || '请选择人员'}}</view>
  26. </picker>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="list-btn-warp">
  31. <button @click="listDelete(index)">删除</button>
  32. <button @click="listUpdate(i,index)">{{i.isEdit ? '确认' : '修改'}}</button>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="footer-btn-warp" style="margin-top: 20rpx;" v-if="form.backDetailList.length != 0">
  37. <button class="cancel" style="background-color:red" @click="backFn">取消</button>
  38. <button class="upload" style="background-color:blue" @click="submitBack()">确定</button>
  39. </view>
  40. <uni-popup ref="addModal" type="bottom">
  41. <view class="addModal-content">
  42. <view class="select-warp">
  43. <view class="label">
  44. 选择面料
  45. </view>
  46. <view class="show-text" @click="openSelectModal">
  47. {{!selectMaterialDtl.name ? '请选择物料' : selectMaterialDtl.name }}
  48. </view>
  49. <view class="add-icon">
  50. +
  51. </view>
  52. </view>
  53. <view style="height:40rpx;border-bottom: 1px solid #ccc;">
  54. </view>
  55. <view class="ul">
  56. <view class="li" v-for="(i,index) in selectMaterialDtl.stockTransferDetailsList" :key="index">
  57. <view class="delete-icon" @click="stockTransferDetailsListDelete(index)">
  58. -
  59. </view>
  60. <view class="li-label">
  61. 卷{{index + 1}}
  62. </view>
  63. <view class="input">
  64. <input type="number" :value="i.quantity" @input="((e)=>inputChange(e,index))">
  65. </view>
  66. </view>
  67. </view>
  68. <button class="add-btn" @click="addList">再添加一卷</button>
  69. <view class="footer-btn-warp" style="margin-top: 20rpx;">
  70. <button class="cancel" style="background-color:red" @click="cancelFn">取消</button>
  71. <button class="upload" style="background-color:blue" @click="pushList">确定</button>
  72. </view>
  73. </view>
  74. </uni-popup>
  75. <uni-popup ref="popup2" type="bottom">
  76. <view class="tabs">
  77. <view class="tab-box" @click="tabChange(0)">
  78. 今日领取的面料
  79. <view class="blue-line" :class="current === 1 ? 'op0':''">
  80. </view>
  81. </view>
  82. <view class="tab-box" @click="tabChange(1)">
  83. 选择其他
  84. <view class="blue-line" :class="current === 0 ? 'op0':''">
  85. </view>
  86. </view>
  87. </view>
  88. <view class="search-box" v-if="current == 0">
  89. <ul style="height: 60vh;overflow-y: scroll;">
  90. <li @click="selectMaterialList(i)" v-for="i in pickingToday" :key="i.id">
  91. {{i.name}}
  92. </li>
  93. <view class="no-data" v-if="pickingToday.length == 0">
  94. 暂无今日领取面料数据
  95. </view>
  96. </ul>
  97. </view>
  98. <view class="search-box" v-if="current == 1">
  99. <view class="input-warp">
  100. <input v-model="req.search" confirm-type="search" placeholder="请输入物料名称或编码"
  101. @input="getSelectMaterialList" class="search-input" />
  102. </view>
  103. <ul style="height: 60vh;overflow-y: scroll;">
  104. <li @click="selectMaterialList(i)" v-for="i in materialData" :key="i.id">
  105. {{i.name}}
  106. </li>
  107. <view class="no-data" v-if="materialData.length == 0">
  108. 暂无数据
  109. </view>
  110. </ul>
  111. </view>
  112. </uni-popup>
  113. </div>
  114. </template>
  115. <script>
  116. export default {
  117. name: "xx",
  118. data() {
  119. return {
  120. isEdit: false,
  121. swiperCurrent: 0,
  122. current: 0,
  123. list: [{
  124. name: '今日领取的面料'
  125. }, {
  126. name: '选择其他'
  127. }],
  128. userInfo: {},
  129. form: {
  130. submitUser: null,
  131. backDetailList: [],
  132. },
  133. req: {
  134. userId: null,
  135. pageNum: 1,
  136. pageSize: 30,
  137. search: null,
  138. materialCode: null,
  139. },
  140. pickingToday: [],
  141. materialData: [],
  142. selectMaterialDtl: {},
  143. updateIndex: null,
  144. selectOneList: [],
  145. }
  146. },
  147. created() {
  148. const v = this
  149. uni.getStorage({
  150. key: 'Authorization',
  151. success: (res => {
  152. console.log(res)
  153. v.form.submitUser = res.data.account
  154. v.req.userId = res.data.account
  155. v.userInfo = res.data
  156. console.log(v.req, 'req')
  157. v.selectList()
  158. v.getSelectMaterialList()
  159. v.getBackUser()
  160. })
  161. })
  162. },
  163. methods: {
  164. printingWorkersSelect(e, index) {
  165. console.log(e, index)
  166. this.form.backDetailList[index].receiveUser = this.selectOneList[e.detail.value].userId
  167. this.form.backDetailList[index].userName = this.selectOneList[e.detail.value].realName
  168. },
  169. getBackUser() {
  170. this.$post('/stockBack/getBackUser', {}).then(res => {
  171. this.selectOneList = res.data.A007.concat(res.data.A008, res.data.A012)
  172. })
  173. },
  174. tabChange(_type) {
  175. this.current = _type
  176. },
  177. submitBack() {
  178. const v = this
  179. console.log(v.form)
  180. for (var i = 0; i < this.form.backDetailList.length; i++) {
  181. this.form.backDetailList[i]
  182. for (var j = 0; j < this.form.backDetailList[i].stockTransferDetailsList.length; j++) {
  183. if(this.form.backDetailList[i].stockTransferDetailsList[j].quantity === 0){
  184. uni.showToast({
  185. title: '请输入数量!',
  186. icon:"none"
  187. })
  188. return
  189. }
  190. }
  191. }
  192. uni.showLoading({title: '加载中',mask:true});
  193. v.$post('/stockTransfer/add', this.form.backDetailList).then(res => {
  194. console.log(res)
  195. uni.hideLoading()
  196. if (res.code == 200) {
  197. uni.showToast({
  198. title: '提交成功,跳转中!'
  199. })
  200. setTimeout(() => {
  201. wx.reLaunch({
  202. url: '/pages/home'
  203. })
  204. }, 2000)
  205. }
  206. })
  207. },
  208. stockTransferDetailsListDelete(index) {
  209. this.selectMaterialDtl.stockTransferDetailsList.splice(index, 1)
  210. },
  211. listUpdate(i, index) {
  212. this.selectMaterialDtl = i
  213. this.updateIndex = index
  214. this.$refs.addModal.open()
  215. },
  216. listDelete(index) {
  217. this.form.backDetailList.splice(index, 1)
  218. },
  219. backFn() {
  220. uni.navigateBack()
  221. },
  222. cancelFn() {
  223. this.$refs.addModal.close()
  224. },
  225. pushList() {
  226. if (this.updateIndex === null) {
  227. this.form.backDetailList.push(this.selectMaterialDtl)
  228. } else {
  229. this.form.backDetailList[this.updateIndex] = this.selectMaterialDtl
  230. }
  231. this.selectMaterialDtl = {}
  232. this.$refs.addModal.close()
  233. },
  234. inputChange(e, index) {
  235. this.selectMaterialDtl.stockTransferDetailsList[index].quantity = e.detail.value
  236. console.log(this.selectMaterialDtl)
  237. },
  238. tabsChange(index) {
  239. this.swiperCurrent = index;
  240. this.current = index;
  241. },
  242. addList() {
  243. if (!this.selectMaterialDtl.name) {
  244. uni.showToast({
  245. title: '请选择物料',
  246. icon: "none"
  247. })
  248. return
  249. }
  250. this.selectMaterialDtl.stockTransferDetailsList.push({
  251. quantity: 0,
  252. })
  253. },
  254. selectMaterialList(i) {
  255. const v = this
  256. v.selectMaterialDtl = {
  257. materialId: i.id,
  258. stockTransferDetailsList: [],
  259. name: i.name,
  260. isEdit: false,
  261. userName: null,
  262. receiveUser: null,
  263. submitUser: v.form.submitUser
  264. }
  265. this.$refs.popup2.close()
  266. },
  267. openSelectModal() {
  268. this.selectMaterialDtl = {}
  269. this.updateIndex = null
  270. this.$refs.popup2.open()
  271. },
  272. getSelectMaterialList() {
  273. const v = this
  274. v.$post('/material/selectList', v.req).then(res => {
  275. console.log(res, 1231231231)
  276. this.materialData = res.data
  277. })
  278. },
  279. selectList() {
  280. const v = this
  281. v.$post('/stockBack/getPickingToday', v.req).then(res => {
  282. for (var i = 0; i < res.data.length; i++) {
  283. res.data[i].id = res.data[i].materialId
  284. res.data[i].name = res.data[i].materialName
  285. }
  286. this.pickingToday = res.data
  287. })
  288. },
  289. openModal() {
  290. this.$refs.addModal.open('bottom')
  291. },
  292. },
  293. }
  294. </script>
  295. <style scoped lang="less">
  296. .materialTransfer {
  297. background-color: #f2f2f2;
  298. min-height: 100vh;
  299. .user-select {
  300. display: flex;
  301. justify-content: space-between;
  302. height: 80rpx;
  303. line-height: 80rpx;
  304. padding: 0 20rpx;
  305. }
  306. }
  307. .tabs {
  308. background-color: #fff;
  309. display: flex;
  310. justify-content: space-between;
  311. .tab-box {
  312. width: 49%;
  313. text-align: center;
  314. height: 80rpx;
  315. line-height: 80rpx;
  316. position: relative;
  317. color: #000;
  318. .blue-line {
  319. position: absolute;
  320. bottom: 0;
  321. left: 50%;
  322. height: 4rpx;
  323. width: 100rpx;
  324. margin-left: -50rpx;
  325. background-color: blue;
  326. }
  327. .op0{
  328. opacity: 0;
  329. }
  330. }
  331. .active {
  332. color: #000 !important;
  333. }
  334. .active::before {
  335. position: absolute;
  336. bottom: 0;
  337. left: 50%;
  338. content: " ";
  339. height: 4rpx;
  340. width: 100rpx;
  341. margin-left: -50rpx;
  342. background-color: blue;
  343. }
  344. }
  345. .footer-btn-warp {
  346. display: flex;
  347. padding: 20rpx;
  348. button {
  349. width: 48%;
  350. color: #fff;
  351. }
  352. }
  353. .search-box {
  354. .input-warp {
  355. padding: 40rpx;
  356. }
  357. .search-input {
  358. border: 1rpx solid #dcdcdc;
  359. padding: 20rpx;
  360. }
  361. background-color: #fff;
  362. text-align: center;
  363. ul {
  364. li {
  365. padding: 25rpx 30rpx;
  366. border-bottom: 1rpx solid #dcdcdc;
  367. list-style: none;
  368. }
  369. }
  370. .no-data {
  371. padding: 100rpx;
  372. }
  373. }
  374. .addModal-content {
  375. background-color: #fff;
  376. border-top-left-radius: 20rpx;
  377. border-top-right-radius: 20rpx;
  378. padding-top: 40rpx;
  379. .footer-btn-warp {
  380. display: flex;
  381. padding: 20rpx;
  382. button {
  383. width: 48%;
  384. color: #fff;
  385. }
  386. }
  387. .ul {
  388. .li {
  389. display: flex;
  390. justify-content: space-between;
  391. height: 80rpx;
  392. line-height: 80rpx;
  393. margin-top: 20rpx;
  394. .input {
  395. width: 70%;
  396. input {
  397. border: 1rpx solid #dcdcdc;
  398. height: 78rpx;
  399. line-height: 78rpx;
  400. padding: 0 20rpx;
  401. }
  402. }
  403. }
  404. .delete-icon {
  405. height: 80rpx;
  406. width: 80rpx;
  407. text-align: center;
  408. line-height: 80rpx;
  409. font-size: 40rpx;
  410. color: #fff;
  411. background-color: #ccc;
  412. }
  413. }
  414. .select-warp {
  415. height: 80rpx;
  416. line-height: 80rpx;
  417. padding: 0 20rpx;
  418. box-sizing: border-box;
  419. display: flex;
  420. justify-content: space-between;
  421. .show-text {
  422. width: 60%;
  423. border: 1rpx solid #dcdcdc;
  424. padding: 0 20rpx;
  425. overflow: hidden;
  426. height: 80rpx;
  427. }
  428. .add-icon {
  429. height: 80rpx;
  430. width: 80rpx;
  431. text-align: center;
  432. line-height: 80rpx;
  433. font-size: 40rpx;
  434. color: #fff;
  435. background-color: #ccc;
  436. }
  437. }
  438. }
  439. .ul {
  440. .li {
  441. background-color: #fff;
  442. border-radius: 5rpx;
  443. margin: 20rpx 20rpx 0;
  444. .label {
  445. height: 100rpx;
  446. line-height: 100rpx;
  447. font-weight: 30rpx;
  448. border-bottom: 1rpx solid #ccc;
  449. padding: 0 20rpx;
  450. overflow: hidden;
  451. }
  452. .lists {
  453. border-bottom: 1rpx solid #ccc;
  454. .list-box {
  455. height: 100rpx;
  456. line-height: 100rpx;
  457. display: flex;
  458. justify-content: space-between;
  459. padding: 0 20rpx;
  460. }
  461. }
  462. .list-btn-warp {
  463. display: flex;
  464. padding: 20rpx;
  465. button {
  466. width: 48%;
  467. }
  468. }
  469. }
  470. }
  471. .add-header {
  472. height: 100rpx;
  473. line-height: 100rpx;
  474. font-size: 30rpx;
  475. font-weight: bold;
  476. overflow: hidden;
  477. padding: 20rpx;
  478. button {
  479. width: 200rpx;
  480. color: #fff;
  481. background-color: red;
  482. float: right;
  483. margin: 14rpx 0;
  484. }
  485. }
  486. </style>