report.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617
  1. <template>
  2. <view class="mainBox">
  3. <uni-nav-bar
  4. fixed="true"
  5. statusBar="true"
  6. left-icon="back"
  7. title="自然干燥-报工"
  8. @clickLeft="back"
  9. >
  10. </uni-nav-bar>
  11. <uni-section :title="`${workReportArea.name}(${workReportArea.code})`">
  12. <uni-table border stripe class="time-wrapper">
  13. <uni-tr>
  14. <uni-td>自然干燥开始时间</uni-td>
  15. <uni-td>
  16. <uni-datetime-picker
  17. type="datetimesingle"
  18. :clear-icon="true"
  19. v-model="workReport.productInfo.heatDryStartTime"
  20. />
  21. </uni-td>
  22. </uni-tr>
  23. <uni-tr>
  24. <uni-td>自然干燥计划完成时间</uni-td>
  25. <uni-td>
  26. <uni-datetime-picker
  27. type="datetimesingle"
  28. :clear-icon="true"
  29. v-model="workReport.productInfo.heatDryCompleteTime"
  30. />
  31. </uni-td>
  32. </uni-tr>
  33. </uni-table>
  34. </uni-section>
  35. <uni-section title="周转车信息">
  36. <view class="device">
  37. <template class="device" v-for="(item, index) in carList">
  38. <view class="divice-top">
  39. <view class="top-name">周转车编码</view>
  40. <view class="content">{{ item.code }}</view>
  41. <view class="del" @click="handleDelete(index)">删除</view>
  42. </view>
  43. <view class="order-wrapper">
  44. <view v-for="itm in item.orderList" class="order-row">
  45. <view class="order-col"> 工单编号:{{ itm.code }} </view>
  46. <view class="order-col"> 产品编码:{{ itm.produceCode }} </view>
  47. <view class="order-col full">
  48. <text>合格数量(PCS)</text>
  49. <uni-easyinput
  50. placeholder="请输入"
  51. v-model="itm.standardNum"
  52. ></uni-easyinput>
  53. </view>
  54. <view class="order-col full">
  55. <text>合格重量(KG)</text>
  56. <uni-easyinput
  57. trim="all"
  58. type="number"
  59. :disabled="true"
  60. :value="
  61. (itm.standardWeight =
  62. itm.standardNum === ''
  63. ? ''
  64. : multiply(itm.standardNum, itm.productUnitWeight || 1))
  65. "
  66. ></uni-easyinput>
  67. </view>
  68. <view class="order-col full">
  69. <text>不合格数量(PCS)</text
  70. ><uni-easyinput
  71. placeholder="请输入"
  72. v-model="itm.noStandardNum"
  73. ></uni-easyinput>
  74. <view class="handle" @click="handle(1, itm)">处置</view>
  75. </view>
  76. <view class="order-col full">
  77. <text>不合格品重量(KG)</text
  78. ><uni-easyinput
  79. trim="all"
  80. type="number"
  81. :disabled="true"
  82. :value="
  83. (itm.noStandardWeight =
  84. itm.noStandardNum === ''
  85. ? ''
  86. : multiply(
  87. itm.noStandardNum,
  88. itm.productUnitWeight || 1
  89. ))
  90. "
  91. ></uni-easyinput>
  92. </view>
  93. <!-- <view class="order-col full">
  94. <text>副产品(KG):</text
  95. ><uni-easyinput
  96. placeholder="请输入"
  97. v-model="itm.byProductWeight"
  98. ></uni-easyinput>
  99. <view class="handle" @click="handle(2, itm)">处置</view>
  100. </view> -->
  101. </view>
  102. </view>
  103. <!-- <uni-table border stripe>
  104. <uni-tr>
  105. <uni-th align="center">工单编号</uni-th>
  106. <uni-th align="center">产品编码</uni-th>
  107. <uni-th align="center">合格品</uni-th>
  108. <uni-th align="center"></uni-th>
  109. <uni-th align="center"></uni-th>
  110. </uni-tr>
  111. <uni-tr v-for="itm in item.orderList">
  112. <uni-td>{{ itm.code }}</uni-td>
  113. <uni-td> {{ itm.produceCode }} </uni-td>
  114. <uni-td>
  115. <uni-easyinput v-model="itm.standardNum"></uni-easyinput>
  116. </uni-td>
  117. <uni-td>
  118. <uni-easyinput v-model="itm.noStandardNum"></uni-easyinput>
  119. </uni-td>
  120. <uni-td>
  121. <uni-easyinput v-model="itm.byProductWeight"></uni-easyinput>
  122. </uni-td>
  123. </uni-tr>
  124. </uni-table> -->
  125. </template>
  126. <view class="addcar" @click="chooseCar">+</view>
  127. </view>
  128. </uni-section>
  129. <!-- <uni-section title="处置信息">
  130. <view class="device handlebox">
  131. <view class="device-line">
  132. <view class="line-title">不合格总数量</view>
  133. <view class="line-content">
  134. <uni-easyinput
  135. trim="all"
  136. disabled
  137. disableColor="#ffffff"
  138. :value="sumOpt.noStandardNum"
  139. ></uni-easyinput>
  140. <view class="handle" @click="handle(1)">处置</view>
  141. </view>
  142. </view>
  143. <view class="device-line">
  144. <view class="line-title">副产品</view>
  145. <view class="line-content">
  146. <uni-easyinput
  147. trim="all"
  148. disabled
  149. disableColor="#ffffff"
  150. :value="sumOpt.byProductWeight"
  151. ></uni-easyinput>
  152. <view class="handle" @click="handle(2)">处置</view>
  153. </view>
  154. </view>
  155. <view class="device-line">
  156. <view class="line-title">备注</view>
  157. <view class="line-content">
  158. <uni-easyinput trim="all" v-model="diviceName"></uni-easyinput>
  159. </view>
  160. </view>
  161. </view>
  162. </uni-section> -->
  163. <view class="bottom" @click="handleReport">完成报工</view>
  164. <!-- <locationPopu ref="locationRef"></locationPopu>
  165. <assetPopu ref="assetRef"></assetPopu>
  166. <moldPopu ref="moldRef"></moldPopu>
  167. <materialPopu ref="materialRef"></materialPopu> -->
  168. <carPopu ref="carRef" @confirm="carConfirm"></carPopu>
  169. <HandlePop ref="handlePopRef" />
  170. </view>
  171. </template>
  172. <script>
  173. import carPopu from "../components/carPopu.vue";
  174. import {
  175. pdaReport,
  176. getWorkerOrderInfo,
  177. getTaskListById,
  178. } from "@/api/production/execute";
  179. import HandlePop from "../components/HandlePop.vue";
  180. import dayjs from "dayjs";
  181. import { multiply } from "@/utils/math";
  182. // import locationPopu from "./components/locationPopu.vue";
  183. // import assetPopu from "./components/assetPopu.vue";
  184. // import moldPopu from "./components/moldPopu.vue";
  185. // import materialPopu from "./components/materialPopu.vue";
  186. export default {
  187. components: {
  188. HandlePop,
  189. // locationPopu,
  190. // assetPopu,
  191. // moldPopu,
  192. // materialPopu,
  193. carPopu,
  194. },
  195. data() {
  196. return {
  197. diviceName: "",
  198. carList: [],
  199. workReportArea: {
  200. associationType: "1",
  201. code: "",
  202. name: "",
  203. heatUpDuration: "",
  204. },
  205. lastTaskCode: "",
  206. workReport: {
  207. qualityItem: "",
  208. workOrderId: "",
  209. qualityStandard: "",
  210. executorId: "",
  211. taskSort: "",
  212. taskCode: "",
  213. taskName: "",
  214. executorJobNum: "",
  215. executeTime: dayjs(new Date()).format("YYYY-MM-DD HH:mm:ss"),
  216. remark: "",
  217. productInfo: {
  218. heatDryCompleteTime: "",
  219. heatDryStartTime: "",
  220. standardNum: "",
  221. byProductWeight: "",
  222. standardWeight: "",
  223. noStandardNum: "",
  224. noStandardWeight: "",
  225. },
  226. },
  227. sumOpt: {},
  228. };
  229. },
  230. onLoad({ name, code, path, id }) {
  231. this.workReportArea.code = code;
  232. this.workReportArea.name = name;
  233. this.workReportArea.path = path;
  234. this.workReportArea.sourceAreaId = id;
  235. const userInfo = uni.getStorageSync("userInfo");
  236. this.workReport.executorId = userInfo?.userId;
  237. this.workReport.executorJobNum = userInfo?.jobNumber;
  238. },
  239. watch: {
  240. // carList: {
  241. // deep: true,
  242. // handler() {
  243. // this.sumOpt = this.carList.reduce(
  244. // (next, pre) => {
  245. // let obj = pre.orderList.reduce(
  246. // (next, pre) => {
  247. // return {
  248. // noStandardNum:
  249. // Number(next.noStandardNum) + Number(pre.noStandardNum || 0),
  250. // byProductWeight:
  251. // Number(next.byProductWeight) +
  252. // Number(pre.byProductWeight || 0),
  253. // };
  254. // },
  255. // {
  256. // noStandardNum: 0,
  257. // byProductWeight: 0,
  258. // }
  259. // );
  260. // return {
  261. // noStandardNum:
  262. // Number(next.noStandardNum) + Number(obj.noStandardNum || 0),
  263. // byProductWeight:
  264. // Number(next.byProductWeight) + Number(obj.byProductWeight || 0),
  265. // };
  266. // },
  267. // {
  268. // noStandardNum: 0,
  269. // byProductWeight: 0,
  270. // }
  271. // );
  272. // },
  273. // },
  274. },
  275. methods: {
  276. multiply,
  277. chooseCar() {
  278. this.$refs.carRef.open();
  279. },
  280. handleDelete(index) {
  281. const _this = this;
  282. uni.showModal({
  283. title: `确定删除当前周转车`,
  284. content: "",
  285. confirmText: "确认",
  286. success: function (res) {
  287. if (res.confirm) {
  288. _this.carList.splice(index, 1);
  289. }
  290. },
  291. });
  292. },
  293. async carConfirm(list) {
  294. const obj = this.carList.map((i) => i.id);
  295. uni.showLoading();
  296. try {
  297. for (const p of list) {
  298. if (!obj.includes(p.id)) {
  299. obj.push(p.id);
  300. p.sourceInstanceId = p.id;
  301. p.extraField = {};
  302. const data = await getWorkerOrderInfo(p.code);
  303. this.$set(
  304. p,
  305. "orderList",
  306. data.map((item) => ({
  307. ...item,
  308. standardNum: "",
  309. noStandardNum: "",
  310. byProductWeight: "",
  311. }))
  312. );
  313. data.length && this._getTaskListById(data[0].produceVersionId);
  314. this.$set(this.carList, this.carList.length, p);
  315. }
  316. }
  317. } catch (error) {}
  318. uni.hideLoading();
  319. },
  320. chooseMaterial() {
  321. this.$refs.materialRef.open();
  322. },
  323. chooseAsset() {
  324. this.$refs.assetRef.open();
  325. },
  326. chooseMold() {
  327. this.$refs.moldRef.open();
  328. },
  329. chooseLocation() {
  330. this.$refs.locationRef.open();
  331. },
  332. handle(disposeType, item) {
  333. this.$refs.handlePopRef.open(disposeType, (data) => {
  334. data.workOrderCode = item.code;
  335. data.workOrderId = item.id;
  336. item.disposeOrderList = [data];
  337. });
  338. },
  339. async _getTaskListById(produceVersionId) {
  340. if (this.workReport.taskCode) {
  341. return;
  342. }
  343. // 获取工序
  344. let list = await getTaskListById(produceVersionId);
  345. list = list.filter((i) => !i.name.includes("工具棒"));
  346. const index = list.findIndex((i) => i.name.includes("挤压干燥"));
  347. if (index > -1) {
  348. this.workReport.taskSort = 88;
  349. this.workReport.taskCode = list[index].code + "-01";
  350. this.workReport.taskName = "自然干燥";
  351. this.lastTaskCode = list[index - 1]?.code;
  352. }
  353. },
  354. async handleReport() {
  355. if (!this.carList.length) {
  356. return uni.showToast({
  357. title: "请选择周转车",
  358. icon: "none",
  359. });
  360. }
  361. const params = [];
  362. this.carList.forEach((item) => {
  363. item.orderList.forEach((ele) => {
  364. this.workReport.workOrderId = ele.id;
  365. this.workReport.productInfo.standardNum = ele.standardNum;
  366. this.workReport.productInfo.standardWeight = ele.standardWeight;
  367. this.workReport.productInfo.noStandardNum = ele.noStandardNum;
  368. this.workReport.productInfo.noStandardWeight = ele.noStandardWeight;
  369. params.push({
  370. checkState: 1,
  371. isSapReportState: 0, //sap报工状态(0:不调用SAP接口报工;1:投料;2:报工;3:入库)
  372. lastTaskCode: this.lastTaskCode,
  373. disposeOrderList: ele.disposeOrderList,
  374. workReport: this.workReport,
  375. workReportArea: this.workReportArea,
  376. workReportDeviceList: [item],
  377. // workReportCategoryList: [
  378. // {
  379. // // batchNo: "",
  380. // // number: "",
  381. // // totalWeight: "",
  382. // rootCategoryLevelId: "9",
  383. // brandNum: ele.brandNo,
  384. // sourceCategoryId: ele.categoryId,
  385. // name: ele.productName,
  386. // code: ele.productCode,
  387. // },
  388. // ],
  389. ...ele,
  390. });
  391. });
  392. });
  393. const _this = this;
  394. uni.showModal({
  395. title: `是否提交报工?`,
  396. content: "",
  397. confirmText: "确认",
  398. success: async function (res) {
  399. if (res.confirm) {
  400. try {
  401. await pdaReport(params);
  402. uni.showToast({
  403. title: "报工成功!",
  404. });
  405. uni.navigateBack({
  406. delta: 1,
  407. });
  408. } catch (error) {
  409. uni.showToast({
  410. title: error,
  411. icon: "none",
  412. });
  413. }
  414. }
  415. },
  416. });
  417. },
  418. },
  419. };
  420. </script>
  421. <style lang="scss" scoped>
  422. .time-wrapper .uni-table-td {
  423. font-size: 28rpx;
  424. }
  425. .order-wrapper {
  426. padding: 0 20rpx;
  427. .order-row {
  428. border-bottom: 1rpx solid #ccc;
  429. padding-bottom: 20rpx;
  430. margin-bottom: 20rpx;
  431. }
  432. .order-col {
  433. display: flex;
  434. align-items: center;
  435. margin-bottom: 10rpx;
  436. text {
  437. margin-right: 20rpx;
  438. display: inline-block;
  439. width: 230rpx;
  440. }
  441. .uni-easyinput {
  442. width: 30%;
  443. }
  444. }
  445. }
  446. .device {
  447. width: 100%;
  448. .divice-top {
  449. width: 96%;
  450. height: 60rpx;
  451. margin: 10rpx auto;
  452. display: flex;
  453. align-items: center;
  454. justify-content: flex-start;
  455. }
  456. .divice-number {
  457. display: flex;
  458. align-items: center;
  459. justify-content: space-around;
  460. margin: 20rpx 0;
  461. span {
  462. margin-left: 10rpx;
  463. }
  464. view:last-child span {
  465. color: rgba(112, 182, 3, 1);
  466. }
  467. }
  468. .divice-btm {
  469. display: flex;
  470. align-items: center;
  471. justify-content: flex-start;
  472. width: 96%;
  473. margin: 0 auto;
  474. .btm-mold {
  475. display: flex;
  476. align-items: center;
  477. justify-content: flex-start;
  478. width: 60%;
  479. .content {
  480. width: 35%;
  481. }
  482. }
  483. .btm-mold.btm-last {
  484. width: 40%;
  485. .modle-input {
  486. margin: 0 10rpx;
  487. }
  488. }
  489. }
  490. .device-line {
  491. display: flex;
  492. align-items: center;
  493. width: 100%;
  494. border-bottom: 1rpx solid #ccc;
  495. // margin-bottom: 20rpx;
  496. height: 80rpx;
  497. .line-title {
  498. width: 30%;
  499. text-indent: 30rpx;
  500. }
  501. .line-content {
  502. display: flex;
  503. align-items: center;
  504. justify-content: space-between;
  505. width: 70%;
  506. margin-right: 20rpx;
  507. .content {
  508. width: 70%;
  509. margin: 0 20rpx 0 0;
  510. }
  511. .content-input {
  512. display: flex;
  513. align-items: center;
  514. justify-content: flex-start;
  515. width: 40%;
  516. view {
  517. margin-left: 10rpx;
  518. }
  519. }
  520. .line-right {
  521. display: flex;
  522. align-items: center;
  523. justify-content: flex-end;
  524. .right-minus {
  525. width: 80rpx;
  526. height: 51rpx;
  527. text-align: center;
  528. line-height: 51rpx;
  529. color: #fff;
  530. background: #f59a23;
  531. }
  532. .right-add {
  533. width: 80rpx;
  534. height: 51rpx;
  535. text-align: center;
  536. line-height: 51rpx;
  537. color: #fff;
  538. background: #70b603;
  539. margin-left: 10rpx;
  540. }
  541. .right-choose.u-button--info {
  542. border-color: #70b603;
  543. color: #70b603;
  544. }
  545. }
  546. }
  547. }
  548. .addcar {
  549. width: 100%;
  550. display: flex;
  551. align-items: center;
  552. justify-content: center;
  553. font-size: 120rpx;
  554. color: #ccc;
  555. font-weight: bold;
  556. line-height: 80rpx;
  557. }
  558. .content {
  559. width: 40%;
  560. border: 1rpx solid #ccc;
  561. border-radius: 8rpx;
  562. line-height: 60rpx;
  563. height: 60rpx;
  564. margin: 0 20rpx;
  565. }
  566. .choose {
  567. background: rgba(112, 182, 3, 1);
  568. color: #fff;
  569. padding: 10rpx 20rpx;
  570. border-radius: 8rpx;
  571. }
  572. .del {
  573. background: rgba(236, 128, 141, 1);
  574. color: #fff;
  575. padding: 10rpx 20rpx;
  576. border-radius: 8rpx;
  577. }
  578. .handle {
  579. background: rgba(112, 182, 3, 1);
  580. color: #fff;
  581. padding: 10rpx 20rpx;
  582. border-radius: 8rpx;
  583. margin-left: 60rpx;
  584. }
  585. }
  586. .handlebox {
  587. padding-bottom: 130rpx;
  588. }
  589. .bottom {
  590. width: 100%;
  591. height: 90rpx;
  592. display: flex;
  593. align-items: center;
  594. justify-content: center;
  595. position: fixed;
  596. bottom: 0;
  597. left: 0;
  598. font-size: 36rpx;
  599. color: #fff;
  600. background: #4b7902;
  601. }
  602. </style>