materialTransfer.vue 12 KB

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