packingBom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name">内包装</view>
  5. </view>
  6. <view class="material ">
  7. <view class="content_table">
  8. <view class="item">
  9. <view class="lable rx-cc">包装总数 </view>
  10. <view class="content content_num">
  11. <input class="uni-input" v-model="formedNumLast" type='digit'></input>
  12. <view class="unit">{{objData.unit}}</view>
  13. </view>
  14. </view>
  15. <view class="item rx-sc">
  16. <view class="rx ww55 ">
  17. <view class="lable lable150 rx-cc ">内包装单元</view>
  18. <view class="content content_num">
  19. <input class="uni-input" v-model="quantity"></input>
  20. </view>
  21. </view>
  22. <view class="rx ww45">
  23. <view class="rx-cc ww80">
  24. <view style="max-width: 100rpx; font-size: 24rpx;">{{objData.unit}}</view>/
  25. </view>
  26. <view class="content rx-sc">
  27. <zxz-uni-data-select :localdata="unitList" v-model="unit" dataValue='Key' format='{Value}'
  28. dataKey="Key" filterable :clear='false'></zxz-uni-data-select>
  29. <view class="penalize" @click="handleSplit">确认</view>
  30. </view>
  31. </view>
  32. </view>
  33. </view>
  34. <view class="content_table2" v-if='splitList.length'>
  35. <view class="head row rx-sc">
  36. <view class="item ww10">序号</view>
  37. <view class="item ww30">数量</view>
  38. <view class="item ww50">条码</view>
  39. <view class="item ww10 jsColor" @click="calculation()" v-if="clientEnvironmentId != 3">计算</view>
  40. <view class="item ww10" v-if="clientEnvironmentId == 3"></view>
  41. </view>
  42. <view class="table">
  43. <u-list @scrolltolower="scrolltolower" class="z_list" style="height: 100% !important;">
  44. <view class="tr row rx-sc" v-for="(it, idx) in splitList" :key='idx'>
  45. <view class="item ww10 rx-cc ">{{ it.computeSize }}</view>
  46. <view class="item ww30 content_num rx-sc">
  47. <input class="uni-input" v-model="it.quantity" type="digit"></input>
  48. <view style="width: 260rpx; font-size: 22rpx;"> {{objData.unit}}/ {{it.unit}}</view>
  49. </view>
  50. <view class="item ww50">
  51. {{ it.code }}
  52. </view>
  53. <view class="item ww10 rx-cc" v-if="!it.parentId" @click="handleCheck( idx, it)">
  54. <image class="check" v-if='it.check == 1' src='@/static/check.png'>
  55. </image>
  56. <image class="check" v-if='it.check == 0 || it.check == null '
  57. src='@/static/check_no.png'>
  58. </image>
  59. </view>
  60. </view>
  61. </u-list>
  62. </view>
  63. </view>
  64. </view>
  65. <view class="material ">
  66. <view class="title_box rx-bc">
  67. <view class="name">外包装</view>
  68. </view>
  69. <view class="content_table2" v-if='temporaryList.length'>
  70. <view class="head row rx-sc">
  71. <view class="item ww10">序号</view>
  72. <view class="item ww30">数量</view>
  73. <view class="item ww50">条码</view>
  74. <view class="item ww10"></view>
  75. </view>
  76. <view class="table">
  77. <view class="tr row rx-sc" v-for="(it, idx) in temporaryList" :key='idx'>
  78. <view class="item ww10 rx-cc ">{{ idx + 1 }}</view>
  79. <view class="item ww30 content_num rx-sc">
  80. <input class="uni-input" v-model="it.quantity" disabled type="digit"></input>
  81. <view style="width: 260rpx; font-size: 22rpx;"> {{objData.unit}}/ {{it.unit}}</view>
  82. </view>
  83. <view class="item ww50">
  84. {{ it.code }}
  85. </view>
  86. <view class="item ww10 rx-cc">
  87. <uni-icons custom-prefix="iconfont" type="icon-shanchu" size="20" color="#fa3534"
  88. @click="handclose(it)"></uni-icons>
  89. </view>
  90. </view>
  91. <view class="tr row rx-sc">
  92. <view class="item ww10 rx-cc ">合并</view>
  93. <view class="item ww90 rx-sc">
  94. 总共{{temporaryCount}} {{objData.unit}} / {{this.temporaryNum}} {{unit}}
  95. --打包成 1
  96. <zxz-uni-data-select :localdata="unitList" v-model="packUnit" dataValue='Key'
  97. format='{Value}' dataKey="Key" filterable :clear='false'></zxz-uni-data-select>
  98. <view class="penalize" @click="handlePack">打包</view>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <!-- 外包装 列表-->
  104. <view class="content_table2" v-if='packTwoList.length > 0'>
  105. <view class="head row rx-sc">
  106. <view class="item ww10">序号</view>
  107. <view class="item ww30">数量</view>
  108. <view class="item ww50">条码</view>
  109. <view class="item ww10"></view>
  110. </view>
  111. <view class="table">
  112. <view class="tr row rx-sc " v-for="(it, idx) in packTwoList" :key='idx'>
  113. <view class="item ww10 rx-cc ">{{ idx + 1 }}</view>
  114. <view class="item ww30 content_num rx-sc">
  115. {{ it.quantity}} {{ objData.unit }} / {{it.unit}}
  116. </view>
  117. <view class="item ww50">
  118. {{ it.code }}
  119. </view>
  120. <view class="item ww10 rx-cc">
  121. </view>
  122. </view>
  123. </view>
  124. </view>
  125. </view>
  126. <SearchPopup mode="center" v-if='show'>
  127. <template v-slot:list>
  128. <view class="search_list">
  129. <u-form labelPosition="left" :model="formData" labelWidth="180" labelAlign="left" class="baseForm">
  130. <u-form-item label="外包装数:" class="required-form" borderBottom prop="assetType">
  131. <input class="uni-input" v-model="formData.wPackNum" style="width: 280rpx;"
  132. placeholder="外包装数"></input> / {{splitList[0].unit}}
  133. </u-form-item>
  134. </u-form>
  135. </view>
  136. </template>
  137. <template v-slot:operate>
  138. <view class="operate_box rx-bc">
  139. <u-button size="small" class="u-reset-button" @click="calculationClose()">
  140. 取消
  141. </u-button>
  142. <u-button type="success" size="small" class="u-reset-button" @click="calculationReset()">
  143. 重置
  144. </u-button>
  145. <u-button type="success" size="small" class="u-reset-button" @click="calculationSave()">
  146. 确定
  147. </u-button>
  148. </view>
  149. </template>
  150. </SearchPopup>
  151. </view>
  152. </template>
  153. <script>
  154. import {
  155. getByCode
  156. } from '@/api/pda/common.js'
  157. import {
  158. packingReport,
  159. getPackingReport,
  160. packingReportRepeat,
  161. getPackingReportRepeat
  162. } from '@/api/pda/workOrder.js'
  163. import SearchPopup from '../../components/searchPopup.vue'
  164. export default {
  165. components: {
  166. SearchPopup
  167. },
  168. props: {
  169. objData: {
  170. type: Object,
  171. default: () => {}
  172. },
  173. taskId: {
  174. type: String,
  175. default: ''
  176. },
  177. workOrderId: {
  178. type: String,
  179. default: ''
  180. }
  181. },
  182. data() {
  183. return {
  184. formedNumLast: 0,
  185. quantity: '',
  186. unit: '',
  187. unitList: [],
  188. splitList: [],
  189. packUnit: null,
  190. temporaryNum: 0,
  191. temporaryCount: 0,
  192. temporaryList: [],
  193. packTwoList: [],
  194. show: false,
  195. formData: {
  196. wPackNum: null,
  197. },
  198. clientEnvironmentId: uni.getStorageSync("userInfo") && uni.getStorageSync("userInfo").clientEnvironmentId,
  199. }
  200. },
  201. created() {
  202. this.formedNumLast = this.objData.formedNumLast
  203. this.byCode(),
  204. this.getPackingDetails()
  205. this.getPackingDetailsTwo()
  206. },
  207. methods: {
  208. byCode() {
  209. getByCode('packing_unit').then(res => {
  210. this.unitList = []
  211. res.forEach((obj, index) => {
  212. for (let key in obj) {
  213. if (obj.hasOwnProperty(key)) { // 确保key是对象自身的属性
  214. this.unitList.push({
  215. Key: `${key}`,
  216. Value: ` ${obj[key]}`
  217. })
  218. }
  219. }
  220. });
  221. })
  222. },
  223. getPackingDetails() {
  224. let param = {
  225. workOrderId: this.workOrderId,
  226. taskId: this.taskId,
  227. tier: 1
  228. }
  229. getPackingReport(param).then(res => {
  230. this.splitList = res.detailList
  231. this.formedNumLast = res.totalQuantity
  232. this.quantity = res.quantity
  233. this.unit = res.unit
  234. })
  235. },
  236. handleSplit() {
  237. if (this.splitList.length) {
  238. uni.showToast({
  239. title: '产品已分包',
  240. icon: 'none'
  241. })
  242. return false
  243. }
  244. if (!this.formedNumLast) {
  245. uni.showToast({
  246. title: '包装总数数量不能为空',
  247. icon: 'none'
  248. })
  249. return false
  250. }
  251. if (!this.quantity) {
  252. uni.showToast({
  253. title: '内包装单元数量不能为空',
  254. icon: 'none'
  255. })
  256. return false
  257. }
  258. if (!this.unit) {
  259. uni.showToast({
  260. title: '请选择包装单位',
  261. icon: 'none'
  262. })
  263. return false
  264. }
  265. let param = {
  266. totalQuantity: this.formedNumLast,
  267. quantity: this.quantity,
  268. unit: this.unit,
  269. workOrderId: this.workOrderId,
  270. taskId: this.taskId,
  271. tier: 1
  272. }
  273. packingReport(param).then(res => {
  274. this.splitList = res.map(m => {
  275. return {
  276. check: false,
  277. ...m
  278. }
  279. })
  280. this.getPackingDetails()
  281. })
  282. },
  283. handleCheck(idx, it) {
  284. if (it.quantity <= 0) {
  285. uni.showToast({
  286. icon: 'none',
  287. title: '数量为空不能勾选'
  288. })
  289. return false
  290. }
  291. this.$set(this.splitList[idx], 'check', it.check ? 0 : 1)
  292. this.temporaryList = []
  293. this.temporaryList = this.splitList.filter(e => {
  294. return e.check == 1
  295. })
  296. this.temporaryNum = 0
  297. this.temporaryCount = 0
  298. if (this.temporaryList.length > 0) {
  299. this.temporaryList.forEach(e => {
  300. this.temporaryNum = this.temporaryNum + 1
  301. this.temporaryCount = this.temporaryCount + Number(e.quantity)
  302. })
  303. }
  304. },
  305. handclose(it) {
  306. this.splitList.forEach(f => {
  307. if (f.computeSize == it.computeSize) {
  308. f.check = 0
  309. }
  310. })
  311. this.temporaryList = []
  312. this.temporaryList = this.splitList.filter(e => {
  313. return e.check == 1
  314. })
  315. },
  316. getPackingDetailsTwo() {
  317. let param = {
  318. totalQuantity: this.formedNumLast,
  319. quantity: this.quantity,
  320. unit: this.unit,
  321. workOrderId: this.workOrderId,
  322. taskId: this.taskId,
  323. tier: 2,
  324. }
  325. getPackingReportRepeat(param).then(res => {
  326. this.packTwoList = res.detailList
  327. })
  328. },
  329. handlePack() {
  330. let _arr = []
  331. _arr = this.temporaryList.map(m => {
  332. return {
  333. ...m,
  334. isChecked: 1
  335. }
  336. })
  337. let param = {
  338. detailList: _arr,
  339. quantity: this.temporaryCount,
  340. totalQuantity: this.formedNumLast,
  341. unit: this.packUnit,
  342. taskId: this.taskId,
  343. workOrderId: this.workOrderId,
  344. tier: 2
  345. }
  346. packingReportRepeat(param).then(res => {
  347. this.temporaryList = []
  348. this.getPackingDetails()
  349. this.getPackingDetailsTwo()
  350. })
  351. },
  352. scrolltolower() {
  353. },
  354. getData() {
  355. let _packingReportMarginList = []
  356. _packingReportMarginList = this.splitList.filter(e => {
  357. return !e.parentId
  358. })
  359. let packInfo = {
  360. packingReportList: this.packTwoList,
  361. packingReportMarginList: _packingReportMarginList,
  362. formedNumLast: this.formedNumLast
  363. }
  364. return packInfo
  365. },
  366. calculation() {
  367. this.show = true
  368. },
  369. calculationSave() {
  370. let count = this.splitList.filter(item => item.isChecked != 1).length;
  371. if (this.formData.wPackNum <= count) {
  372. for (let i = 0; i < this.formData.wPackNum; i++) {
  373. this.splitList[i].check = 1
  374. }
  375. this.handleCheck(0, 0)
  376. this.calculationClose()
  377. } else {
  378. uni.showToast({
  379. icon: 'none',
  380. title: '外包装数超出内包装条数'
  381. })
  382. }
  383. },
  384. calculationClose() {
  385. this.show = false
  386. },
  387. calculationReset() {
  388. this.formData.wPackNum = null
  389. this.splitList.forEach(f => {
  390. f.check = null
  391. })
  392. this.temporaryList = []
  393. this.show = false
  394. }
  395. },
  396. }
  397. </script>
  398. <style lang="scss" scoped>
  399. .title_box {
  400. margin-top: 20rpx;
  401. .name {
  402. font-size: 28rpx;
  403. font-style: normal;
  404. font-weight: 400;
  405. color: $theme-color;
  406. padding-left: 20rpx;
  407. position: relative;
  408. &:before {
  409. position: absolute;
  410. content: '';
  411. left: 0rpx;
  412. top: 0rpx;
  413. bottom: 0rpx;
  414. width: 4rpx;
  415. height: 28rpx;
  416. background: $theme-color;
  417. margin: auto;
  418. }
  419. }
  420. }
  421. .material {
  422. margin-top: 10rpx;
  423. .content_table {
  424. width: 100%;
  425. border: 2rpx solid $border-color;
  426. .item {
  427. display: flex;
  428. border-bottom: 2rpx solid $border-color;
  429. .lable {
  430. width: 132rpx;
  431. text-align: center;
  432. background-color: #F7F9FA;
  433. font-size: 26rpx;
  434. border-right: 2rpx solid $border-color;
  435. flex-shrink: 0;
  436. }
  437. .lable220 {
  438. width: 220rpx !important;
  439. font-size: 24rpx;
  440. }
  441. .lable150 {
  442. width: 156rpx !important;
  443. font-size: 24rpx;
  444. }
  445. .ww80 {
  446. width: 80rpx;
  447. }
  448. .content {
  449. width: 518rpx;
  450. min-height: 64rpx;
  451. font-size: 28rpx;
  452. line-height: 28rpx;
  453. font-style: normal;
  454. font-weight: 400;
  455. // padding: 18rpx 8rpx;
  456. box-sizing: border-box;
  457. word-wrap: break-word;
  458. flex-grow: 1 !important;
  459. .unit {
  460. padding: 0 4rpx;
  461. font-size: 24rpx;
  462. color: #404446;
  463. }
  464. }
  465. &:last-child {
  466. border-bottom: none;
  467. }
  468. }
  469. .ww55 {
  470. width: 55%;
  471. }
  472. .ww45 {
  473. width: 45%;
  474. }
  475. }
  476. }
  477. .content_table2 {
  478. width: 100%;
  479. margin-top: 16rpx;
  480. .row {
  481. width: 100%;
  482. .item {
  483. color: #404446;
  484. font-size: 28rpx;
  485. padding-left: 12rpx;
  486. }
  487. .color157 {
  488. color: $theme-color;
  489. }
  490. .ww30 {
  491. width: 30%;
  492. }
  493. .ww50 {
  494. width: 50%;
  495. }
  496. .ww90 {
  497. width: 90%;
  498. }
  499. .ww15 {
  500. width: 15%;
  501. }
  502. .ww10 {
  503. width: 10%;
  504. }
  505. .ww30 {
  506. width: 30%;
  507. }
  508. .jsColor {
  509. color: $theme-color;
  510. font-size: 20rpx;
  511. }
  512. }
  513. .head {
  514. height: 64rpx;
  515. background: #F7F9FA;
  516. border-top: 2rpx solid #E3E5E5;
  517. border-left: 2rpx solid #E3E5E5;
  518. .item {
  519. height: 64rpx;
  520. line-height: 64rpx;
  521. border-right: 2rpx solid #E3E5E5;
  522. box-sizing: border-box;
  523. }
  524. }
  525. .tr {
  526. border-top: 2rpx solid #E3E5E5;
  527. border-left: 2rpx solid #E3E5E5;
  528. .item {
  529. font-size: 24rpx;
  530. min-height: 64rpx;
  531. display: flex;
  532. align-items: center;
  533. border-right: 2rpx solid #E3E5E5;
  534. box-sizing: border-box;
  535. white-space: normal;
  536. word-break: break-all;
  537. }
  538. &:last-child {
  539. border-bottom: 2rpx solid #E3E5E5;
  540. }
  541. }
  542. }
  543. .content_num {
  544. display: flex;
  545. align-items: center;
  546. padding: 0 4rpx;
  547. /deep/ .uni-input-input {
  548. border: 2rpx solid #F0F8F2;
  549. background: #F0F8F2;
  550. color: $theme-color;
  551. }
  552. }
  553. .penalize {
  554. width: 86rpx;
  555. line-height: 60rpx;
  556. background: $theme-color;
  557. font-size: 24rpx;
  558. text-align: center;
  559. color: #fff;
  560. }
  561. .check {
  562. width: 30rpx;
  563. height: 30rpx;
  564. }
  565. .z_list {
  566. max-height: 500rpx;
  567. }
  568. .search_list {
  569. min-height: 100rpx;
  570. width: 80vw;
  571. /deep/ .baseForm {
  572. padding: 0 20rpx;
  573. }
  574. }
  575. .operate_box {
  576. padding: 10rpx 32rpx;
  577. /deep/ .u-button {
  578. width: 30%;
  579. }
  580. }
  581. </style>