workInProgressList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <view>
  3. <view class="title_box rx-bc">
  4. <view class="name"> 在制品: ({{ listArr.length || 0 }})个</view>
  5. </view>
  6. <view
  7. :class="[
  8. 'material',
  9. it.extInfo.reportWeight && it.extInfo.reportWeight && 'materialBor',
  10. ]"
  11. v-for="(it, idx) in listArr"
  12. :key="idx"
  13. >
  14. <view class="content_table">
  15. <view class="item rx-sc">
  16. <view class="rx">
  17. <view class="lable lable150 rx-cc">名称</view>
  18. <view class="content rx-bc">
  19. <view>{{ it.name }}</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="item rx-sc">
  24. <view class="rx ww50">
  25. <view class="lable lable150 rx-cc">批次号</view>
  26. <view class="content content_num">
  27. <input
  28. class="uni-input"
  29. v-model="it.batchNo"
  30. :disabled="isDetails"
  31. />
  32. </view>
  33. </view>
  34. <view class="rx ww50">
  35. <view class="lable lable150 rx-cc">牌号</view>
  36. <view class="content content_num">
  37. <view :disabled="isDetails">{{ it.brandNu }}</view>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="item rx-sc">
  42. <view class="rx">
  43. <view class="lable lable150 rx-cc">型号</view>
  44. <view class="content rx-sc">
  45. <view>{{ it.modelType }}</view>
  46. </view>
  47. </view>
  48. </view>
  49. <view class="item rx-sc">
  50. <view class="rx ww50">
  51. <view class="lable lable150 rx-cc">设备</view>
  52. <view class="content content_num">
  53. <zxz-uni-data-select
  54. :localdata="deviceList"
  55. v-model="it.deviceId"
  56. dataValue="instanceId"
  57. format="{name}"
  58. dataKey="instanceId"
  59. filterable
  60. :disabled="isDetails"
  61. :clear="false"
  62. ></zxz-uni-data-select>
  63. </view>
  64. <!-- <view class="content ">
  65. <view>{{ it.deviceName || it.extInfo.deviceName }}</view>
  66. </view> -->
  67. </view>
  68. <view class="rx ww50">
  69. <view class="lable lable150 rx-cc">炉次号</view>
  70. <view class="content content_num">
  71. <view v-if="isDetails">{{ it.extInfo.heatNumber }}</view>
  72. <input class="uni-input" v-else v-model="it.extInfo.heatNumber" />
  73. </view>
  74. </view>
  75. </view>
  76. <view class="item rx-sc">
  77. <view class="rx ww50">
  78. <view class="lable lable150 rx-cc">数量</view>
  79. <view class="content content_num">
  80. {{ it.feedQuantity || 0 }}{{ it.unit }}
  81. </view>
  82. </view>
  83. <view class="rx ww50">
  84. <view class="lable lable150 rx-cc">重量</view>
  85. <view class="content content_num">
  86. <view
  87. >{{ it.extInfo.newWeight || 0
  88. }}{{ it.extInfo.weightUnit }}</view
  89. >
  90. </view>
  91. </view>
  92. </view>
  93. <view class="item rx-sc">
  94. <view class="rx">
  95. <view class="lable lable150 rx-cc">操作</view>
  96. <view class="content rx-bc">
  97. <view style="display: flex">
  98. <u-button
  99. size="small"
  100. class="u-reset-button"
  101. type="primary"
  102. @click="batchClick(it, idx)"
  103. v-if="it.feedQuantity > 1 && it.isAllPackageData != 1"
  104. >拆批</u-button
  105. >
  106. <u-button
  107. size="small"
  108. class="u-reset-button"
  109. type="error"
  110. @click="deleteBatch(idx)"
  111. style="margin-left: 20px"
  112. >删除</u-button
  113. >
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <uni-popup ref="inputDialog" type="dialog">
  121. <uni-popup-dialog
  122. ref="inputClose"
  123. mode="input"
  124. title="拆批数"
  125. placeholder="请输入拆批数"
  126. :before-close="true"
  127. @close="handleClose"
  128. @confirm="timeoutCauseConfirm"
  129. ></uni-popup-dialog>
  130. </uni-popup>
  131. </view>
  132. </template>
  133. <script>
  134. import { splitBatch } from "@/api/pda/feeding";
  135. export default {
  136. props: {
  137. tableData: {
  138. type: Array,
  139. default: () => [],
  140. },
  141. itemData: {
  142. type: Object,
  143. default: () => {},
  144. },
  145. isDetails: {
  146. type: Boolean,
  147. default: false,
  148. },
  149. equipmentList: {
  150. type: Array,
  151. default: () => [],
  152. },
  153. },
  154. data() {
  155. return {
  156. pickerIndex: 0,
  157. isAllChecked: true,
  158. listArr: [],
  159. selectedIndexs: [],
  160. bacthData: {},
  161. bacthIndex: "",
  162. deviceList: [],
  163. };
  164. },
  165. watch: {
  166. tableData: {
  167. handler(v) {
  168. this.listArr = v;
  169. },
  170. immediate: true,
  171. deep: true,
  172. },
  173. equipmentList: {
  174. handler(v) {
  175. this.deviceList = v;
  176. this.changeHeatNumber();
  177. },
  178. immediate: true,
  179. deep: true,
  180. },
  181. },
  182. mounted() {
  183. // this.listArr.push(...this.itemData.product)
  184. if (this.itemData.product) {
  185. this.listArr.push(...this.itemData.product);
  186. this.listArr.forEach((item) => {
  187. if (!item.batchNo) {
  188. item.batchNo = this.itemData.batchNo;
  189. }
  190. item.childBatch = 0;
  191. });
  192. } else {
  193. this.list.push(...this.itemData.inProductList);
  194. }
  195. },
  196. methods: {
  197. handlerCheckedTow(e, index, item) {
  198. console.log(item);
  199. if (e.detail.value.length) {
  200. // this.$set(this.tableData[index], 'selected', true);
  201. item.selected = true;
  202. } else {
  203. // this.$set(this.tableData[index], 'selected', false);
  204. item.selected = false;
  205. }
  206. this.listArr[index] = item;
  207. // this.$emit('tableDataFn', this.tableData);
  208. console.log(this.tableData);
  209. this.$nextTick(() => {
  210. let a = this.listArr.filter((v) => v.selected);
  211. if (a.length && a.length == this.listArr.length) {
  212. this.isAllChecked = true;
  213. } else {
  214. this.isAllChecked = false;
  215. }
  216. });
  217. },
  218. //全选
  219. handlerChecked(e) {
  220. console.log(this.listArr);
  221. if (e.detail.value.length) {
  222. // 全选
  223. this.listArr.map((item) => {
  224. item.selected = true;
  225. });
  226. } else {
  227. // 未选中
  228. this.listArr.map((item) => {
  229. item.selected = false;
  230. });
  231. }
  232. this.listArr = [];
  233. this.$set(this, "listArr", this.listArr);
  234. this.listArr = this.tableData;
  235. this.$emit("tableDataFn", this.tableData);
  236. },
  237. blurNum(workReportInfo) {
  238. this.$emit("tableDataFn", this.tableData);
  239. },
  240. handlerChange(item, index) {
  241. // this.$emit('tableDataFn', this.tableData);
  242. console.log(item, index);
  243. },
  244. selectionChange(e) {
  245. this.selectedIndexs = e.detail.index;
  246. },
  247. batchClick(item, index) {
  248. console.log("拆批", item, index);
  249. this.bacthData = item;
  250. this.bacthIndex = index;
  251. this.$refs.inputDialog.open();
  252. },
  253. handleClose() {
  254. this.$refs.inputDialog.close();
  255. },
  256. async timeoutCauseConfirm(value) {
  257. if (!value) {
  258. uni.showToast({
  259. title: "请输入拆批的数量",
  260. icon: "none",
  261. });
  262. return;
  263. }
  264. if (value == 0) {
  265. uni.showToast({
  266. title: "拆批数不能等于0",
  267. icon: "none",
  268. });
  269. return;
  270. }
  271. if (!value) {
  272. uni.showToast({
  273. title: "拆批数不能为空",
  274. icon: "none",
  275. });
  276. return;
  277. }
  278. if (this.bacthData.extInfo.sourceQuantity < value) {
  279. uni.showToast({
  280. title: "拆批数不能大于数量",
  281. icon: "none",
  282. });
  283. return;
  284. }
  285. let dataList = [];
  286. await splitBatch({
  287. product: this.bacthData,
  288. splitQt: Number(value),
  289. }).then((res) => {
  290. res.forEach((item) => {
  291. dataList.push(this.deepCopy(item));
  292. });
  293. this.refreshData(dataList, value);
  294. });
  295. // this.$refs.inputDialog.close()
  296. },
  297. refreshData(list, value) {
  298. const number =
  299. Number(this.listArr[this.bacthIndex].extInfo.sourceQuantity) -
  300. Number(value);
  301. this.listArr[this.bacthIndex].extInfo.sourceQuantity = number;
  302. this.listArr[this.bacthIndex].feedQuantity = number;
  303. list.forEach((item) => {
  304. item.childBatch = 1;
  305. });
  306. let _arr = [...this.listArr, ...list];
  307. this.$set(this.listArr, this.listArr.length, ...list);
  308. this.$set(this.itemData, "product", _arr);
  309. this.$forceUpdate();
  310. this.$refs.inputDialog.close();
  311. },
  312. deleteBatch(index) {
  313. uni.showModal({
  314. title: "删除",
  315. content: "是否确实删除此物料!",
  316. confirmText: "确认", //这块是确定按钮的文字
  317. success: (rr) => {
  318. this.listArr.splice(index, 1);
  319. this.$set(this.itemData, "product", this.listArr);
  320. if (this.listArr.length == 0) {
  321. this.$set(this.itemData.workReportInfo, "formedNum", 0);
  322. this.$set(this.itemData.workReportInfo, "notFormedNum", 0);
  323. }
  324. this.$forceUpdate();
  325. },
  326. });
  327. },
  328. deepCopy(obj, hash = new WeakMap()) {
  329. if (obj === null) return null;
  330. if (obj instanceof Date) return new Date(obj);
  331. if (obj instanceof RegExp) return new RegExp(obj);
  332. if (typeof obj !== "object" && typeof obj !== "function") return obj;
  333. if (hash.has(obj)) return hash.get(obj);
  334. const result = Array.isArray(obj) ? [] : {};
  335. hash.set(obj, result);
  336. return Object.keys(obj).reduce((acc, key) => {
  337. acc[key] = this.deepCopy(obj[key], hash);
  338. return acc;
  339. }, result);
  340. },
  341. changeHeatNumber() {
  342. console.log(this.deviceList);
  343. this.deviceList.forEach((f) => {
  344. this.listArr.forEach((o) => {
  345. if (
  346. o.deviceId &&
  347. f.instanceId == o.deviceId &&
  348. this.deviceList.length > 1
  349. ) {
  350. console.log(444);
  351. o.extInfo.heatNumber = f.extInfo.heatNumber;
  352. this.$forceUpdate();
  353. } else if (this.deviceList.length == 1) {
  354. console.log(1323);
  355. o.extInfo.heatNumber = this.deviceList[0].extInfo.heatNumber;
  356. o.deviceId = f.instanceId;
  357. this.$forceUpdate();
  358. } else if (this.deviceList.length > 1) {
  359. }
  360. });
  361. });
  362. },
  363. },
  364. };
  365. </script>
  366. <style lang="scss" scoped>
  367. ::v-deep .uni-select--mask {
  368. position: relative !important;
  369. }
  370. .container {
  371. padding: 10rpx;
  372. overflow: auto;
  373. checkbox {
  374. transform: scale(0.8);
  375. }
  376. }
  377. .uni-input {
  378. width: 150rpx;
  379. border: 1px solid #f0f8f2;
  380. background: #f0f8f2;
  381. color: #157a2c;
  382. }
  383. /deep/.uni-table {
  384. min-width: 100vw !important;
  385. .uni-table-td,
  386. .uni-table-th {
  387. padding: 20rpx 10rpx !important;
  388. text-align: center !important;
  389. font-weight: normal !important;
  390. font-size: 26rpx !important;
  391. }
  392. .uni-table-text {
  393. font-size: 26rpx !important;
  394. }
  395. }
  396. .title_box {
  397. margin-top: 20rpx;
  398. .name {
  399. font-size: 28rpx;
  400. font-style: normal;
  401. font-weight: 400;
  402. color: $theme-color;
  403. padding-left: 20rpx;
  404. position: relative;
  405. &:before {
  406. position: absolute;
  407. content: "";
  408. left: 0rpx;
  409. top: 0rpx;
  410. bottom: 0rpx;
  411. width: 4rpx;
  412. height: 28rpx;
  413. background: $theme-color;
  414. margin: auto;
  415. }
  416. }
  417. .btn_box {
  418. .btn {
  419. padding: 0 18rpx;
  420. height: 50rpx;
  421. line-height: 50rpx;
  422. background: $theme-color;
  423. font-size: 26rpx;
  424. font-style: normal;
  425. font-weight: 400;
  426. font-size: 24rpx;
  427. color: #fff;
  428. border-radius: 4rpx;
  429. margin-left: 24rpx;
  430. }
  431. }
  432. }
  433. .material {
  434. margin-top: 16rpx;
  435. border: 1rpx solid transparent;
  436. .content_table {
  437. width: 100%;
  438. border: 2rpx solid $border-color;
  439. box-sizing: border-box;
  440. .item {
  441. display: flex;
  442. border-bottom: 2rpx solid $border-color;
  443. .lable {
  444. width: 132rpx;
  445. text-align: center;
  446. background-color: #f7f9fa;
  447. font-size: 26rpx;
  448. border-right: 2rpx solid $border-color;
  449. flex-shrink: 0;
  450. }
  451. .lable150 {
  452. width: 156rpx !important;
  453. font-size: 24rpx;
  454. }
  455. .lable190 {
  456. width: 200rpx !important;
  457. font-size: 24rpx;
  458. }
  459. .ww80 {
  460. width: 80rpx;
  461. }
  462. .content {
  463. width: 518rpx;
  464. min-height: 64rpx;
  465. font-size: 28rpx;
  466. line-height: 28rpx;
  467. font-style: normal;
  468. font-weight: 400;
  469. padding: 18rpx 8rpx;
  470. box-sizing: border-box;
  471. word-wrap: break-word;
  472. flex-grow: 1 !important;
  473. .unit {
  474. padding: 0 4rpx;
  475. font-size: 24rpx;
  476. color: #404446;
  477. }
  478. .penalize {
  479. width: 160rpx;
  480. line-height: 60rpx;
  481. background: $theme-color;
  482. font-size: 24rpx;
  483. text-align: center;
  484. color: #fff;
  485. }
  486. }
  487. .content_H {
  488. min-height: 92rpx;
  489. }
  490. .pd4 {
  491. padding: 4rpx 8rpx;
  492. }
  493. &:last-child {
  494. border-bottom: none;
  495. }
  496. }
  497. .ww55 {
  498. width: 55%;
  499. }
  500. .ww50 {
  501. width: 50%;
  502. }
  503. .ww45 {
  504. width: 45%;
  505. }
  506. .tag_box {
  507. padding: 2rpx 10rpx;
  508. margin-right: 12rpx;
  509. background: #e6a23c;
  510. font-size: 22rpx;
  511. color: #fff;
  512. border-radius: 4rpx;
  513. }
  514. }
  515. }
  516. .materialBor {
  517. border: 1rpx solid #157a2c;
  518. }
  519. .content_table2 {
  520. width: 100%;
  521. .row {
  522. width: 100%;
  523. .item {
  524. color: #404446;
  525. font-size: 28rpx;
  526. padding-left: 12rpx;
  527. }
  528. .color157 {
  529. color: $theme-color;
  530. }
  531. .ww30 {
  532. width: 30%;
  533. }
  534. .ww20 {
  535. width: 20%;
  536. }
  537. .ww15 {
  538. width: 15%;
  539. }
  540. .ww25 {
  541. width: 25%;
  542. }
  543. .ww50 {
  544. width: 50%;
  545. }
  546. .ww10 {
  547. width: 10%;
  548. }
  549. }
  550. .head {
  551. height: 64rpx;
  552. background: #f7f9fa;
  553. // border-top: 2rpx solid #E3E5E5;
  554. border-left: 2rpx solid #e3e5e5;
  555. box-sizing: border-box;
  556. .item {
  557. height: 64rpx;
  558. line-height: 64rpx;
  559. border-right: 2rpx solid #e3e5e5;
  560. box-sizing: border-box;
  561. font-size: 22rpx;
  562. }
  563. }
  564. .tr {
  565. border-top: 2rpx solid #e3e5e5;
  566. border-left: 2rpx solid #e3e5e5;
  567. .item {
  568. font-size: 24rpx;
  569. min-height: 74rpx;
  570. display: flex;
  571. align-items: center;
  572. border-right: 2rpx solid #e3e5e5;
  573. box-sizing: border-box;
  574. white-space: normal;
  575. word-break: break-all;
  576. }
  577. &:last-child {
  578. border-bottom: 2rpx solid #e3e5e5;
  579. }
  580. .numerate {
  581. font-size: 22rpx;
  582. color: $theme-color;
  583. }
  584. }
  585. }
  586. .content_num {
  587. display: flex;
  588. align-items: center;
  589. padding: 0 4rpx;
  590. /deep/ .uni-input-input {
  591. border: 2rpx solid #f0f8f2;
  592. background: #f0f8f2;
  593. color: $theme-color;
  594. }
  595. }
  596. .round {
  597. width: 32rpx;
  598. height: 32rpx;
  599. line-height: 30rpx;
  600. text-align: center;
  601. border-radius: 50%;
  602. background: $theme-color;
  603. font-size: 24rpx;
  604. font-style: normal;
  605. font-weight: 400;
  606. color: #fff;
  607. margin-right: 10rpx;
  608. }
  609. .popup_box {
  610. width: 94vw;
  611. padding: 16rpx 12rpx;
  612. box-sizing: border-box;
  613. }
  614. .operate_box {
  615. margin-top: 32rpx;
  616. padding: 10rpx 100rpx;
  617. /deep/ .u-button {
  618. width: 160rpx;
  619. }
  620. }
  621. .formula_box {
  622. font-size: 24rpx;
  623. font-style: normal;
  624. font-weight: 400;
  625. margin-top: 12rpx;
  626. }
  627. .reportWeight {
  628. font-size: 24rpx;
  629. font-style: normal;
  630. font-weight: 400;
  631. margin-top: 30rpx;
  632. text {
  633. color: $theme-color;
  634. }
  635. }
  636. </style>