materialTransfer.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  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.selectMaterialDtl.stockTransferDetailsList || this.selectMaterialDtl.stockTransferDetailsList.length == 0){
  227. uni.showToast({
  228. title: '请添加物料',
  229. icon: "none"
  230. })
  231. return
  232. }
  233. if (this.updateIndex === null) {
  234. this.form.backDetailList.push(this.selectMaterialDtl)
  235. } else {
  236. this.form.backDetailList[this.updateIndex] = this.selectMaterialDtl
  237. }
  238. this.selectMaterialDtl = {}
  239. this.$refs.addModal.close()
  240. },
  241. inputChange(e, index) {
  242. this.selectMaterialDtl.stockTransferDetailsList[index].quantity = e.detail.value
  243. console.log(this.selectMaterialDtl)
  244. },
  245. tabsChange(index) {
  246. this.swiperCurrent = index;
  247. this.current = index;
  248. },
  249. addList() {
  250. if (!this.selectMaterialDtl.name) {
  251. uni.showToast({
  252. title: '请选择物料',
  253. icon: "none"
  254. })
  255. return
  256. }
  257. this.selectMaterialDtl.stockTransferDetailsList.push({
  258. quantity: 0,
  259. })
  260. },
  261. selectMaterialList(i) {
  262. const v = this
  263. v.selectMaterialDtl = {
  264. materialId: i.id,
  265. stockTransferDetailsList: [],
  266. name: i.name,
  267. isEdit: false,
  268. userName: null,
  269. receiveUser: null,
  270. submitUser: v.form.submitUser
  271. }
  272. this.$refs.popup2.close()
  273. },
  274. openSelectModal() {
  275. this.selectMaterialDtl = {}
  276. this.updateIndex = null
  277. this.$refs.popup2.open()
  278. },
  279. getSelectMaterialList() {
  280. const v = this
  281. v.$post('/material/selectList', v.req).then(res => {
  282. console.log(res, 1231231231)
  283. this.materialData = res.data
  284. })
  285. },
  286. selectList() {
  287. const v = this
  288. v.$post('/stockBack/getPickingToday', v.req).then(res => {
  289. for (var i = 0; i < res.data.length; i++) {
  290. res.data[i].id = res.data[i].materialId
  291. res.data[i].name = res.data[i].materialName
  292. }
  293. this.pickingToday = res.data
  294. })
  295. },
  296. openModal() {
  297. this.$refs.addModal.open('bottom')
  298. },
  299. },
  300. }
  301. </script>
  302. <style scoped lang="less">
  303. .materialTransfer {
  304. background-color: #f2f2f2;
  305. min-height: 100vh;
  306. .user-select {
  307. display: flex;
  308. justify-content: space-between;
  309. height: 80rpx;
  310. line-height: 80rpx;
  311. padding: 0 20rpx;
  312. }
  313. }
  314. .tabs {
  315. background-color: #fff;
  316. display: flex;
  317. justify-content: space-between;
  318. .tab-box {
  319. width: 49%;
  320. text-align: center;
  321. height: 80rpx;
  322. line-height: 80rpx;
  323. position: relative;
  324. color: #000;
  325. .blue-line {
  326. position: absolute;
  327. bottom: 0;
  328. left: 50%;
  329. height: 4rpx;
  330. width: 100rpx;
  331. margin-left: -50rpx;
  332. background-color: blue;
  333. }
  334. .op0{
  335. opacity: 0;
  336. }
  337. }
  338. .active {
  339. color: #000 !important;
  340. }
  341. .active::before {
  342. position: absolute;
  343. bottom: 0;
  344. left: 50%;
  345. content: " ";
  346. height: 4rpx;
  347. width: 100rpx;
  348. margin-left: -50rpx;
  349. background-color: blue;
  350. }
  351. }
  352. .footer-btn-warp {
  353. display: flex;
  354. padding: 20rpx;
  355. button {
  356. width: 48%;
  357. color: #fff;
  358. }
  359. }
  360. .search-box {
  361. .input-warp {
  362. padding: 40rpx;
  363. }
  364. .search-input {
  365. border: 1rpx solid #dcdcdc;
  366. padding: 20rpx;
  367. }
  368. background-color: #fff;
  369. text-align: center;
  370. ul {
  371. li {
  372. padding: 25rpx 30rpx;
  373. border-bottom: 1rpx solid #dcdcdc;
  374. list-style: none;
  375. }
  376. }
  377. .no-data {
  378. padding: 100rpx;
  379. }
  380. }
  381. .addModal-content {
  382. background-color: #fff;
  383. border-top-left-radius: 20rpx;
  384. border-top-right-radius: 20rpx;
  385. padding-top: 40rpx;
  386. .footer-btn-warp {
  387. display: flex;
  388. padding: 20rpx;
  389. button {
  390. width: 48%;
  391. color: #fff;
  392. }
  393. }
  394. .ul {
  395. .li {
  396. display: flex;
  397. justify-content: space-between;
  398. height: 80rpx;
  399. line-height: 80rpx;
  400. margin-top: 20rpx;
  401. .input {
  402. width: 70%;
  403. input {
  404. border: 1rpx solid #dcdcdc;
  405. height: 78rpx;
  406. line-height: 78rpx;
  407. padding: 0 20rpx;
  408. }
  409. }
  410. }
  411. .delete-icon {
  412. height: 80rpx;
  413. width: 80rpx;
  414. text-align: center;
  415. line-height: 80rpx;
  416. font-size: 40rpx;
  417. color: #fff;
  418. background-color: #ccc;
  419. }
  420. }
  421. .select-warp {
  422. height: 80rpx;
  423. line-height: 80rpx;
  424. padding: 0 20rpx;
  425. box-sizing: border-box;
  426. display: flex;
  427. justify-content: space-between;
  428. .show-text {
  429. width: 60%;
  430. border: 1rpx solid #dcdcdc;
  431. padding: 0 20rpx;
  432. overflow: hidden;
  433. height: 80rpx;
  434. }
  435. .add-icon {
  436. height: 80rpx;
  437. width: 80rpx;
  438. text-align: center;
  439. line-height: 80rpx;
  440. font-size: 40rpx;
  441. color: #fff;
  442. background-color: #ccc;
  443. }
  444. }
  445. }
  446. .ul {
  447. .li {
  448. background-color: #fff;
  449. border-radius: 5rpx;
  450. margin: 20rpx 20rpx 0;
  451. .label {
  452. height: 100rpx;
  453. line-height: 100rpx;
  454. font-weight: 30rpx;
  455. border-bottom: 1rpx solid #ccc;
  456. padding: 0 20rpx;
  457. overflow: hidden;
  458. }
  459. .lists {
  460. border-bottom: 1rpx solid #ccc;
  461. .list-box {
  462. height: 100rpx;
  463. line-height: 100rpx;
  464. display: flex;
  465. justify-content: space-between;
  466. padding: 0 20rpx;
  467. }
  468. }
  469. .list-btn-warp {
  470. display: flex;
  471. padding: 20rpx;
  472. button {
  473. width: 48%;
  474. }
  475. }
  476. }
  477. }
  478. .add-header {
  479. height: 100rpx;
  480. line-height: 100rpx;
  481. font-size: 30rpx;
  482. font-weight: bold;
  483. overflow: hidden;
  484. padding: 20rpx;
  485. button {
  486. width: 200rpx;
  487. color: #fff;
  488. background-color: red;
  489. float: right;
  490. margin: 14rpx 0;
  491. }
  492. }
  493. </style>