packingBom.vue 14 KB

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