workInProgressList.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721
  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.extInfo.sourceQuantity || 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.extInfo.sourceQuantity > 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. this.$message.warning("拆批数不能等于0");
  266. return;
  267. }
  268. if (!value) {
  269. this.$message.warning("拆批数不能为空");
  270. return;
  271. }
  272. if (this.bacthData.extInfo.sourceQuantity < value) {
  273. this.$message.warning("拆批数不能大于数量");
  274. return;
  275. }
  276. let dataList = [];
  277. await splitBatch({
  278. product: this.bacthData,
  279. splitQt: Number(value),
  280. }).then((res) => {
  281. res.forEach((item) => {
  282. dataList.push(this.deepCopy(item));
  283. });
  284. this.refreshData(dataList, value);
  285. });
  286. // this.$refs.inputDialog.close()
  287. },
  288. refreshData(list, value) {
  289. const number =
  290. Number(this.listArr[this.bacthIndex].extInfo.sourceQuantity) -
  291. Number(value);
  292. this.listArr[this.bacthIndex].extInfo.sourceQuantity = number;
  293. this.listArr[this.bacthIndex].feedQuantity = number;
  294. list.forEach((item) => {
  295. item.childBatch = 1;
  296. });
  297. let _arr = [...this.listArr, ...list];
  298. this.$set(this.listArr, this.listArr.length, ...list);
  299. this.$set(this.itemData, "product", _arr);
  300. this.$forceUpdate();
  301. this.$refs.inputDialog.close();
  302. },
  303. deleteBatch(index) {
  304. uni.showModal({
  305. title: "删除",
  306. content: "是否确实删除此物料!",
  307. confirmText: "确认", //这块是确定按钮的文字
  308. success: (rr) => {
  309. this.listArr.splice(index, 1);
  310. this.$set(this.itemData, "product", this.listArr);
  311. if (this.listArr.length == 0) {
  312. this.$set(this.itemData.workReportInfo, "formedNum", 0);
  313. this.$set(this.itemData.workReportInfo, "notFormedNum", 0);
  314. }
  315. this.$forceUpdate();
  316. },
  317. });
  318. },
  319. deepCopy(obj, hash = new WeakMap()) {
  320. if (obj === null) return null;
  321. if (obj instanceof Date) return new Date(obj);
  322. if (obj instanceof RegExp) return new RegExp(obj);
  323. if (typeof obj !== "object" && typeof obj !== "function") return obj;
  324. if (hash.has(obj)) return hash.get(obj);
  325. const result = Array.isArray(obj) ? [] : {};
  326. hash.set(obj, result);
  327. return Object.keys(obj).reduce((acc, key) => {
  328. acc[key] = this.deepCopy(obj[key], hash);
  329. return acc;
  330. }, result);
  331. },
  332. changeHeatNumber() {
  333. console.log(this.deviceList);
  334. this.deviceList.forEach((f) => {
  335. this.listArr.forEach((o) => {
  336. if (
  337. o.deviceId &&
  338. f.instanceId == o.deviceId &&
  339. this.deviceList.length > 1
  340. ) {
  341. console.log(444);
  342. o.extInfo.heatNumber = f.extInfo.heatNumber;
  343. this.$forceUpdate();
  344. } else if (this.deviceList.length == 1) {
  345. console.log(1323);
  346. o.extInfo.heatNumber = this.deviceList[0].extInfo.heatNumber;
  347. o.deviceId = f.instanceId;
  348. this.$forceUpdate();
  349. } else if (this.deviceList.length > 1) {
  350. }
  351. });
  352. });
  353. },
  354. },
  355. };
  356. </script>
  357. <style lang="scss" scoped>
  358. ::v-deep .uni-select--mask {
  359. position: relative !important;
  360. }
  361. .container {
  362. padding: 10rpx;
  363. overflow: auto;
  364. checkbox {
  365. transform: scale(0.8);
  366. }
  367. }
  368. .uni-input {
  369. width: 150rpx;
  370. border: 1px solid #f0f8f2;
  371. background: #f0f8f2;
  372. color: #157a2c;
  373. }
  374. /deep/.uni-table {
  375. min-width: 100vw !important;
  376. .uni-table-td,
  377. .uni-table-th {
  378. padding: 20rpx 10rpx !important;
  379. text-align: center !important;
  380. font-weight: normal !important;
  381. font-size: 26rpx !important;
  382. }
  383. .uni-table-text {
  384. font-size: 26rpx !important;
  385. }
  386. }
  387. .title_box {
  388. margin-top: 20rpx;
  389. .name {
  390. font-size: 28rpx;
  391. font-style: normal;
  392. font-weight: 400;
  393. color: $theme-color;
  394. padding-left: 20rpx;
  395. position: relative;
  396. &:before {
  397. position: absolute;
  398. content: "";
  399. left: 0rpx;
  400. top: 0rpx;
  401. bottom: 0rpx;
  402. width: 4rpx;
  403. height: 28rpx;
  404. background: $theme-color;
  405. margin: auto;
  406. }
  407. }
  408. .btn_box {
  409. .btn {
  410. padding: 0 18rpx;
  411. height: 50rpx;
  412. line-height: 50rpx;
  413. background: $theme-color;
  414. font-size: 26rpx;
  415. font-style: normal;
  416. font-weight: 400;
  417. font-size: 24rpx;
  418. color: #fff;
  419. border-radius: 4rpx;
  420. margin-left: 24rpx;
  421. }
  422. }
  423. }
  424. .material {
  425. margin-top: 16rpx;
  426. border: 1rpx solid transparent;
  427. .content_table {
  428. width: 100%;
  429. border: 2rpx solid $border-color;
  430. box-sizing: border-box;
  431. .item {
  432. display: flex;
  433. border-bottom: 2rpx solid $border-color;
  434. .lable {
  435. width: 132rpx;
  436. text-align: center;
  437. background-color: #f7f9fa;
  438. font-size: 26rpx;
  439. border-right: 2rpx solid $border-color;
  440. flex-shrink: 0;
  441. }
  442. .lable150 {
  443. width: 156rpx !important;
  444. font-size: 24rpx;
  445. }
  446. .lable190 {
  447. width: 200rpx !important;
  448. font-size: 24rpx;
  449. }
  450. .ww80 {
  451. width: 80rpx;
  452. }
  453. .content {
  454. width: 518rpx;
  455. min-height: 64rpx;
  456. font-size: 28rpx;
  457. line-height: 28rpx;
  458. font-style: normal;
  459. font-weight: 400;
  460. padding: 18rpx 8rpx;
  461. box-sizing: border-box;
  462. word-wrap: break-word;
  463. flex-grow: 1 !important;
  464. .unit {
  465. padding: 0 4rpx;
  466. font-size: 24rpx;
  467. color: #404446;
  468. }
  469. .penalize {
  470. width: 160rpx;
  471. line-height: 60rpx;
  472. background: $theme-color;
  473. font-size: 24rpx;
  474. text-align: center;
  475. color: #fff;
  476. }
  477. }
  478. .content_H {
  479. min-height: 92rpx;
  480. }
  481. .pd4 {
  482. padding: 4rpx 8rpx;
  483. }
  484. &:last-child {
  485. border-bottom: none;
  486. }
  487. }
  488. .ww55 {
  489. width: 55%;
  490. }
  491. .ww50 {
  492. width: 50%;
  493. }
  494. .ww45 {
  495. width: 45%;
  496. }
  497. .tag_box {
  498. padding: 2rpx 10rpx;
  499. margin-right: 12rpx;
  500. background: #e6a23c;
  501. font-size: 22rpx;
  502. color: #fff;
  503. border-radius: 4rpx;
  504. }
  505. }
  506. }
  507. .materialBor {
  508. border: 1rpx solid #157a2c;
  509. }
  510. .content_table2 {
  511. width: 100%;
  512. .row {
  513. width: 100%;
  514. .item {
  515. color: #404446;
  516. font-size: 28rpx;
  517. padding-left: 12rpx;
  518. }
  519. .color157 {
  520. color: $theme-color;
  521. }
  522. .ww30 {
  523. width: 30%;
  524. }
  525. .ww20 {
  526. width: 20%;
  527. }
  528. .ww15 {
  529. width: 15%;
  530. }
  531. .ww25 {
  532. width: 25%;
  533. }
  534. .ww50 {
  535. width: 50%;
  536. }
  537. .ww10 {
  538. width: 10%;
  539. }
  540. }
  541. .head {
  542. height: 64rpx;
  543. background: #f7f9fa;
  544. // border-top: 2rpx solid #E3E5E5;
  545. border-left: 2rpx solid #e3e5e5;
  546. box-sizing: border-box;
  547. .item {
  548. height: 64rpx;
  549. line-height: 64rpx;
  550. border-right: 2rpx solid #e3e5e5;
  551. box-sizing: border-box;
  552. font-size: 22rpx;
  553. }
  554. }
  555. .tr {
  556. border-top: 2rpx solid #e3e5e5;
  557. border-left: 2rpx solid #e3e5e5;
  558. .item {
  559. font-size: 24rpx;
  560. min-height: 74rpx;
  561. display: flex;
  562. align-items: center;
  563. border-right: 2rpx solid #e3e5e5;
  564. box-sizing: border-box;
  565. white-space: normal;
  566. word-break: break-all;
  567. }
  568. &:last-child {
  569. border-bottom: 2rpx solid #e3e5e5;
  570. }
  571. .numerate {
  572. font-size: 22rpx;
  573. color: $theme-color;
  574. }
  575. }
  576. }
  577. .content_num {
  578. display: flex;
  579. align-items: center;
  580. padding: 0 4rpx;
  581. /deep/ .uni-input-input {
  582. border: 2rpx solid #f0f8f2;
  583. background: #f0f8f2;
  584. color: $theme-color;
  585. }
  586. }
  587. .round {
  588. width: 32rpx;
  589. height: 32rpx;
  590. line-height: 30rpx;
  591. text-align: center;
  592. border-radius: 50%;
  593. background: $theme-color;
  594. font-size: 24rpx;
  595. font-style: normal;
  596. font-weight: 400;
  597. color: #fff;
  598. margin-right: 10rpx;
  599. }
  600. .popup_box {
  601. width: 94vw;
  602. padding: 16rpx 12rpx;
  603. box-sizing: border-box;
  604. }
  605. .operate_box {
  606. margin-top: 32rpx;
  607. padding: 10rpx 100rpx;
  608. /deep/ .u-button {
  609. width: 160rpx;
  610. }
  611. }
  612. .formula_box {
  613. font-size: 24rpx;
  614. font-style: normal;
  615. font-weight: 400;
  616. margin-top: 12rpx;
  617. }
  618. .reportWeight {
  619. font-size: 24rpx;
  620. font-style: normal;
  621. font-weight: 400;
  622. margin-top: 30rpx;
  623. text {
  624. color: $theme-color;
  625. }
  626. }
  627. </style>