packingBom.vue 15 KB

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