packingBom.vue 14 KB

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