materialTransfer.vue 11 KB

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