packingBom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816
  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" :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 && count != 0) {
  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. if (count != 0) {
  379. for (let i = 0; i < count; i++) {
  380. this.splitList[i].check = 1
  381. }
  382. this.handleCheck(0, 0)
  383. this.calculationClose()
  384. }
  385. uni.showToast({
  386. icon: 'none',
  387. title: '外包装数超出内包装条数'
  388. })
  389. }
  390. },
  391. calculationClose() {
  392. this.show = false
  393. },
  394. calculationReset() {
  395. this.formData.wPackNum = null
  396. this.splitList.forEach(f => {
  397. f.check = null
  398. })
  399. this.temporaryList = []
  400. this.show = false
  401. }
  402. },
  403. }
  404. </script>
  405. <style lang="scss" scoped>
  406. .title_box {
  407. margin-top: 20rpx;
  408. .name {
  409. font-size: 28rpx;
  410. font-style: normal;
  411. font-weight: 400;
  412. color: $theme-color;
  413. padding-left: 20rpx;
  414. position: relative;
  415. &:before {
  416. position: absolute;
  417. content: '';
  418. left: 0rpx;
  419. top: 0rpx;
  420. bottom: 0rpx;
  421. width: 4rpx;
  422. height: 28rpx;
  423. background: $theme-color;
  424. margin: auto;
  425. }
  426. }
  427. }
  428. .material {
  429. margin-top: 10rpx;
  430. .content_table {
  431. width: 100%;
  432. border: 2rpx solid $border-color;
  433. .item {
  434. display: flex;
  435. border-bottom: 2rpx solid $border-color;
  436. .lable {
  437. width: 132rpx;
  438. text-align: center;
  439. background-color: #F7F9FA;
  440. font-size: 26rpx;
  441. border-right: 2rpx solid $border-color;
  442. flex-shrink: 0;
  443. }
  444. .lable220 {
  445. width: 220rpx !important;
  446. font-size: 24rpx;
  447. }
  448. .lable150 {
  449. width: 156rpx !important;
  450. font-size: 24rpx;
  451. }
  452. .ww80 {
  453. width: 80rpx;
  454. }
  455. .content {
  456. width: 518rpx;
  457. min-height: 64rpx;
  458. font-size: 28rpx;
  459. line-height: 28rpx;
  460. font-style: normal;
  461. font-weight: 400;
  462. // padding: 18rpx 8rpx;
  463. box-sizing: border-box;
  464. word-wrap: break-word;
  465. flex-grow: 1 !important;
  466. .unit {
  467. padding: 0 4rpx;
  468. font-size: 24rpx;
  469. color: #404446;
  470. }
  471. }
  472. &:last-child {
  473. border-bottom: none;
  474. }
  475. }
  476. .ww55 {
  477. width: 55%;
  478. }
  479. .ww45 {
  480. width: 45%;
  481. }
  482. }
  483. }
  484. .content_table2 {
  485. width: 100%;
  486. margin-top: 16rpx;
  487. .row {
  488. width: 100%;
  489. .item {
  490. color: #404446;
  491. font-size: 28rpx;
  492. padding-left: 12rpx;
  493. }
  494. .color157 {
  495. color: $theme-color;
  496. }
  497. .ww30 {
  498. width: 30%;
  499. }
  500. .ww50 {
  501. width: 50%;
  502. }
  503. .ww90 {
  504. width: 90%;
  505. }
  506. .ww15 {
  507. width: 15%;
  508. }
  509. .ww10 {
  510. width: 10%;
  511. }
  512. .ww30 {
  513. width: 30%;
  514. }
  515. .jsColor {
  516. color: $theme-color;
  517. font-size: 20rpx;
  518. }
  519. }
  520. .head {
  521. height: 64rpx;
  522. background: #F7F9FA;
  523. border-top: 2rpx solid #E3E5E5;
  524. border-left: 2rpx solid #E3E5E5;
  525. .item {
  526. height: 64rpx;
  527. line-height: 64rpx;
  528. border-right: 2rpx solid #E3E5E5;
  529. box-sizing: border-box;
  530. }
  531. }
  532. .tr {
  533. border-top: 2rpx solid #E3E5E5;
  534. border-left: 2rpx solid #E3E5E5;
  535. .item {
  536. font-size: 24rpx;
  537. min-height: 64rpx;
  538. display: flex;
  539. align-items: center;
  540. border-right: 2rpx solid #E3E5E5;
  541. box-sizing: border-box;
  542. white-space: normal;
  543. word-break: break-all;
  544. }
  545. &:last-child {
  546. border-bottom: 2rpx solid #E3E5E5;
  547. }
  548. }
  549. }
  550. .content_num {
  551. display: flex;
  552. align-items: center;
  553. padding: 0 4rpx;
  554. /deep/ .uni-input-input {
  555. border: 2rpx solid #F0F8F2;
  556. background: #F0F8F2;
  557. color: $theme-color;
  558. }
  559. }
  560. .penalize {
  561. width: 86rpx;
  562. line-height: 60rpx;
  563. background: $theme-color;
  564. font-size: 24rpx;
  565. text-align: center;
  566. color: #fff;
  567. }
  568. .check {
  569. width: 30rpx;
  570. height: 30rpx;
  571. }
  572. .z_list {
  573. max-height: 500rpx;
  574. }
  575. .search_list {
  576. min-height: 100rpx;
  577. width: 80vw;
  578. /deep/ .baseForm {
  579. padding: 0 20rpx;
  580. }
  581. }
  582. .operate_box {
  583. padding: 10rpx 32rpx;
  584. /deep/ .u-button {
  585. width: 30%;
  586. }
  587. }
  588. </style>