transferComposite.vue 11 KB

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