report.vue 15 KB

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