report.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  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="`${equipObj.name}(${equipObj.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 { multiply } from "@/utils/math";
  180. import HandlePop from "../components/HandlePop.vue";
  181. import dayjs from "dayjs";
  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. equipObj: {
  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({ data }) {
  231. this.equipObj = JSON.parse(data);
  232. const userInfo = uni.getStorageSync("userInfo");
  233. this.workReport.executorId = userInfo?.userId;
  234. this.workReport.executorJobNum = userInfo?.jobNumber;
  235. },
  236. methods: {
  237. multiply,
  238. chooseCar() {
  239. this.$refs.carRef.open();
  240. },
  241. handleDelete(index) {
  242. const _this = this;
  243. uni.showModal({
  244. title: `确定删除当前周转车`,
  245. content: "",
  246. confirmText: "确认",
  247. success: function (res) {
  248. if (res.confirm) {
  249. _this.carList.splice(index, 1);
  250. }
  251. },
  252. });
  253. },
  254. async carConfirm(list) {
  255. const obj = this.carList.map((i) => i.id);
  256. uni.showLoading();
  257. try {
  258. for (const p of list) {
  259. if (!obj.includes(p.id)) {
  260. obj.push(p.id);
  261. p.sourceInstanceId = p.id;
  262. const data = await getWorkerOrderInfo(p.code);
  263. this.$set(
  264. p,
  265. "orderList",
  266. data.map((item) => ({
  267. ...item,
  268. standardNum: "",
  269. noStandardNum: "",
  270. byProductWeight: "",
  271. }))
  272. );
  273. data.length && this._getTaskListById(data[0].produceVersionId);
  274. this.$set(this.carList, this.carList.length, p);
  275. }
  276. }
  277. } catch (error) {}
  278. uni.hideLoading();
  279. },
  280. chooseMaterial() {
  281. this.$refs.materialRef.open();
  282. },
  283. chooseAsset() {
  284. this.$refs.assetRef.open();
  285. },
  286. chooseMold() {
  287. this.$refs.moldRef.open();
  288. },
  289. chooseLocation() {
  290. this.$refs.locationRef.open();
  291. },
  292. handle(disposeType, item) {
  293. this.$refs.handlePopRef.open(disposeType, (data) => {
  294. data.workOrderCode = item.code;
  295. data.workOrderId = item.id;
  296. item.disposeOrderList = [data];
  297. });
  298. },
  299. async _getTaskListById(produceVersionId) {
  300. if (this.workReport.taskCode) {
  301. return;
  302. }
  303. // 获取工序
  304. const list = await getTaskListById(produceVersionId);
  305. list = list.filter((i) => !i.name.includes("工具棒"));
  306. const index = list.findIndex((i) => i.name.includes("挤压干燥"));
  307. if (index > -1) {
  308. this.workReport.taskSort = 88;
  309. this.workReport.taskCode = list[index].code + "-01";
  310. this.workReport.taskName = "自然干燥";
  311. this.lastTaskCode = list[index - 1]?.code;
  312. }
  313. },
  314. async handleReport() {
  315. if (!this.carList.length) {
  316. return uni.showToast({
  317. title: "请选择周转车",
  318. icon: "none",
  319. });
  320. }
  321. const params = [];
  322. this.carList.forEach((item) => {
  323. item.orderList.forEach((ele) => {
  324. this.workReport.workOrderId = ele.id;
  325. params.push({
  326. checkState: 1,
  327. isSapReportState: 2, //sap报工状态(0:不调用SAP接口报工;1:投料;2:报工;3:入库)
  328. lastTaskCode: this.lastTaskCode,
  329. disposeOrderList: ele.disposeOrderList,
  330. workReport: this.workReport,
  331. workReportDeviceList: [this.equipObj, item],
  332. // workReportCategoryList: [
  333. // {
  334. // // batchNo: "",
  335. // // number: "",
  336. // // totalWeight: "",
  337. // rootCategoryLevelId: "9",
  338. // brandNum: ele.brandNo,
  339. // sourceCategoryId: ele.categoryId,
  340. // name: ele.productName,
  341. // code: ele.productCode,
  342. // },
  343. // ],
  344. ...ele,
  345. });
  346. });
  347. });
  348. const _this = this;
  349. uni.showModal({
  350. title: `是否提交报工?`,
  351. content: "",
  352. confirmText: "确认",
  353. success: async function (res) {
  354. if (res.confirm) {
  355. try {
  356. await pdaReport(params);
  357. uni.showToast({
  358. title: "报工成功!",
  359. });
  360. uni.navigateBack({
  361. delta: 1,
  362. });
  363. } catch (error) {
  364. uni.showToast({
  365. title: error,
  366. icon: "none",
  367. });
  368. }
  369. }
  370. },
  371. });
  372. },
  373. },
  374. };
  375. </script>
  376. <style lang="scss" scoped>
  377. .time-wrapper .uni-table-td {
  378. font-size: 28rpx;
  379. }
  380. .order-wrapper {
  381. padding: 0 20rpx;
  382. .order-row {
  383. border-bottom: 1rpx solid #ccc;
  384. padding-bottom: 20rpx;
  385. margin-bottom: 20rpx;
  386. }
  387. .order-col {
  388. display: flex;
  389. align-items: center;
  390. margin-bottom: 10rpx;
  391. text {
  392. margin-right: 20rpx;
  393. display: inline-block;
  394. width: 230rpx;
  395. }
  396. .uni-easyinput {
  397. width: 30%;
  398. }
  399. }
  400. }
  401. .device {
  402. width: 100%;
  403. .divice-top {
  404. width: 96%;
  405. height: 60rpx;
  406. margin: 10rpx auto;
  407. display: flex;
  408. align-items: center;
  409. justify-content: flex-start;
  410. }
  411. .divice-number {
  412. display: flex;
  413. align-items: center;
  414. justify-content: space-around;
  415. margin: 20rpx 0;
  416. span {
  417. margin-left: 10rpx;
  418. }
  419. view:last-child span {
  420. color: rgba(112, 182, 3, 1);
  421. }
  422. }
  423. .divice-btm {
  424. display: flex;
  425. align-items: center;
  426. justify-content: flex-start;
  427. width: 96%;
  428. margin: 0 auto;
  429. .btm-mold {
  430. display: flex;
  431. align-items: center;
  432. justify-content: flex-start;
  433. width: 60%;
  434. .content {
  435. width: 35%;
  436. }
  437. }
  438. .btm-mold.btm-last {
  439. width: 40%;
  440. .modle-input {
  441. margin: 0 10rpx;
  442. }
  443. }
  444. }
  445. .device-line {
  446. display: flex;
  447. align-items: center;
  448. width: 100%;
  449. border-bottom: 1rpx solid #ccc;
  450. // margin-bottom: 20rpx;
  451. height: 80rpx;
  452. .line-title {
  453. width: 30%;
  454. text-indent: 30rpx;
  455. }
  456. .line-content {
  457. display: flex;
  458. align-items: center;
  459. justify-content: space-between;
  460. width: 70%;
  461. margin-right: 20rpx;
  462. .content {
  463. width: 70%;
  464. margin: 0 20rpx 0 0;
  465. }
  466. .content-input {
  467. display: flex;
  468. align-items: center;
  469. justify-content: flex-start;
  470. width: 40%;
  471. view {
  472. margin-left: 10rpx;
  473. }
  474. }
  475. .line-right {
  476. display: flex;
  477. align-items: center;
  478. justify-content: flex-end;
  479. .right-minus {
  480. width: 80rpx;
  481. height: 51rpx;
  482. text-align: center;
  483. line-height: 51rpx;
  484. color: #fff;
  485. background: #f59a23;
  486. }
  487. .right-add {
  488. width: 80rpx;
  489. height: 51rpx;
  490. text-align: center;
  491. line-height: 51rpx;
  492. color: #fff;
  493. background: #70b603;
  494. margin-left: 10rpx;
  495. }
  496. .right-choose.u-button--info {
  497. border-color: #70b603;
  498. color: #70b603;
  499. }
  500. }
  501. }
  502. }
  503. .addcar {
  504. width: 100%;
  505. display: flex;
  506. align-items: center;
  507. justify-content: center;
  508. font-size: 120rpx;
  509. color: #ccc;
  510. font-weight: bold;
  511. line-height: 80rpx;
  512. }
  513. .content {
  514. width: 40%;
  515. border: 1rpx solid #ccc;
  516. border-radius: 8rpx;
  517. line-height: 60rpx;
  518. height: 60rpx;
  519. margin: 0 20rpx;
  520. }
  521. .choose {
  522. background: rgba(112, 182, 3, 1);
  523. color: #fff;
  524. padding: 10rpx 20rpx;
  525. border-radius: 8rpx;
  526. }
  527. .del {
  528. background: rgba(236, 128, 141, 1);
  529. color: #fff;
  530. padding: 10rpx 20rpx;
  531. border-radius: 8rpx;
  532. }
  533. .handle {
  534. background: rgba(112, 182, 3, 1);
  535. color: #fff;
  536. padding: 10rpx 20rpx;
  537. border-radius: 8rpx;
  538. margin-left: 60rpx;
  539. }
  540. }
  541. .handlebox {
  542. padding-bottom: 130rpx;
  543. }
  544. .bottom {
  545. width: 100%;
  546. height: 90rpx;
  547. display: flex;
  548. align-items: center;
  549. justify-content: center;
  550. position: fixed;
  551. bottom: 0;
  552. left: 0;
  553. font-size: 36rpx;
  554. color: #fff;
  555. background: #4b7902;
  556. }
  557. </style>