picking.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  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">
  12. {{ workReportDeviceList.name }}({{ workReportDeviceList.code }})
  13. </view>
  14. <view class="form-box">
  15. <view class="form-col full"
  16. ><text>投料开始时间</text>
  17. <uni-easyinput
  18. placeholder="请输入"
  19. class="modle-input"
  20. trim="all"
  21. v-model="time"
  22. ></uni-easyinput>
  23. </view>
  24. <view class="form-col"
  25. ><text>升温曲线</text>
  26. <uni-easyinput
  27. placeholder="请输入"
  28. class="modle-input"
  29. trim="all"
  30. v-model="workReportDeviceList.heatUpLine"
  31. ></uni-easyinput>
  32. </view>
  33. <view class="form-col"
  34. ><text>升温时间</text>
  35. <uni-easyinput
  36. placeholder="请输入"
  37. class="modle-input"
  38. trim="all"
  39. v-model="workReportDeviceList.heatUpDuration"
  40. ></uni-easyinput>
  41. </view>
  42. </view>
  43. <uni-section title="周转车信息">
  44. <view class="device">
  45. <template class="device" v-for="(item, index) in carList">
  46. <view class="divice-top">
  47. <view class="top-name">周转车编码</view>
  48. <view class="content">{{ item.code }}</view>
  49. <view class="del" @click="handleDelete(index)">删除</view>
  50. </view>
  51. <uni-table border stripe>
  52. <uni-tr>
  53. <uni-th align="center">工单编号</uni-th>
  54. <uni-th align="center">产品编码</uni-th>
  55. <uni-th align="center">数量(PCS)</uni-th>
  56. </uni-tr>
  57. <uni-tr v-for="itm in item.orderList">
  58. <uni-td>{{ itm.code }}</uni-td>
  59. <uni-td> {{ itm.produceCode }} </uni-td>
  60. <uni-td>
  61. <uni-easyinput v-model="itm.reportNum"></uni-easyinput>
  62. </uni-td>
  63. </uni-tr>
  64. </uni-table>
  65. </template>
  66. <view class="addcar" @click="chooseCar">+</view>
  67. </view>
  68. </uni-section>
  69. <view class="bottom" @click="_feedBatchSave">完成投料</view>
  70. <carPopu ref="carRef" @confirm="carConfirm"></carPopu>
  71. </view>
  72. </template>
  73. <script>
  74. import carPopu from "../components/carPopu.vue";
  75. import {
  76. feedBatchSave,
  77. getWorkerOrderInfo,
  78. getTaskListById,
  79. } from "@/api/production/execute";
  80. export default {
  81. components: { carPopu },
  82. data() {
  83. return {
  84. time: "",
  85. carList: [],
  86. workReportDeviceList: {
  87. associationType: "2",
  88. heatUpDuration: "",
  89. heatUpLine: "",
  90. },
  91. params: {
  92. taskCode: "",
  93. upperTaskCode: "",
  94. },
  95. };
  96. },
  97. onLoad(options) {
  98. this.workReportDeviceList = Object.assign(
  99. this.workReportDeviceList,
  100. options
  101. );
  102. },
  103. methods: {
  104. chooseCar() {
  105. this.$refs.carRef.open();
  106. },
  107. handleDelete(index) {
  108. const _this = this;
  109. uni.showModal({
  110. title: `确定删除当前周转车`,
  111. content: "",
  112. confirmText: "确认",
  113. success: function (res) {
  114. if (res.confirm) {
  115. _this.carList.splice(index, 1);
  116. }
  117. },
  118. });
  119. },
  120. async carConfirm(list) {
  121. const obj = this.carList.map((i) => i.id);
  122. uni.showLoading();
  123. try {
  124. for (const p of list) {
  125. if (!obj.includes(p.id)) {
  126. obj.push(p.id);
  127. p.sourceInstanceId = p.id;
  128. const data = await getWorkerOrderInfo(p.code);
  129. p.orderList = data.map((item) => ({
  130. ...item,
  131. reportNum: "",
  132. workOrderId: item.id,
  133. workOrderCode: item.code,
  134. }));
  135. data.length && this._getTaskListById(data[0].produceVersionId);
  136. this.carList.push(p);
  137. }
  138. }
  139. } catch (error) {}
  140. uni.hideLoading();
  141. },
  142. async _getTaskListById(produceVersionId) {
  143. if (this.params.taskCode) {
  144. return;
  145. }
  146. // 获取工序
  147. let list = await getTaskListById(produceVersionId);
  148. list = list.filter((i) => !i.name.includes("工具棒"));
  149. const index = list.findIndex((i) => i.name.includes("挤压干燥"));
  150. if (index > -1) {
  151. this.params = {
  152. taskCode: list[index].code + "-01",
  153. upperTaskCode: list[index - 1]?.code,
  154. };
  155. }
  156. },
  157. async _feedBatchSave() {
  158. if (!this.workReportDeviceList.heatUpDuration) {
  159. return uni.showToast({
  160. title: "请输入升温时间",
  161. icon: "none",
  162. });
  163. }
  164. if (!this.workReportDeviceList.heatUpLine) {
  165. return uni.showToast({
  166. title: "请输入升温曲线",
  167. icon: "none",
  168. });
  169. }
  170. if (!this.carList.length) {
  171. return uni.showToast({
  172. title: "请选择周转车",
  173. icon: "none",
  174. });
  175. }
  176. const _this = this;
  177. uni.showModal({
  178. title: `是否投料?`,
  179. content: "",
  180. confirmText: "确认",
  181. success: async function (res) {
  182. if (res.confirm) {
  183. const feedAddList = [];
  184. _this.carList.forEach((ele) => {
  185. feedAddList.push(
  186. ...ele.orderList.map((i) => ({
  187. checkState: 1,
  188. status: 1,
  189. ..._this.workReportDeviceList,
  190. ...i,
  191. turnoverVehicleCode: ele.code,
  192. }))
  193. );
  194. });
  195. _this.params.feedAddList = feedAddList;
  196. await feedBatchSave(_this.params);
  197. uni.showToast({
  198. title: "投料成功!",
  199. });
  200. setTimeout(() => {
  201. uni.navigateBack({
  202. delta: 1,
  203. });
  204. }, 1500);
  205. }
  206. },
  207. });
  208. },
  209. },
  210. };
  211. </script>
  212. <style lang="scss" scoped>
  213. .bottom {
  214. width: 100%;
  215. height: 90rpx;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. position: fixed;
  220. bottom: 0;
  221. left: 0;
  222. font-size: 36rpx;
  223. color: #fff;
  224. background: #4b7902;
  225. }
  226. .mainBox {
  227. padding-bottom: 90rpx;
  228. box-sizing: border-box;
  229. .form-box {
  230. display: flex;
  231. justify-content: space-between;
  232. align-items: center;
  233. flex-wrap: wrap;
  234. padding: 0 10rpx;
  235. .form-col {
  236. width: 50%;
  237. display: flex;
  238. align-items: center;
  239. margin-bottom: 10rpx;
  240. text {
  241. margin-right: 15rpx;
  242. }
  243. &.full {
  244. width: 100%;
  245. }
  246. }
  247. }
  248. .title {
  249. font-weight: bold;
  250. padding: 10rpx;
  251. }
  252. .drying-time {
  253. padding: 10rpx;
  254. display: flex;
  255. align-items: center;
  256. .uni-easyinput {
  257. width: 30vw;
  258. }
  259. }
  260. }
  261. .device {
  262. width: 100%;
  263. .divice-top {
  264. width: 96%;
  265. height: 60rpx;
  266. margin: 10rpx auto;
  267. display: flex;
  268. align-items: center;
  269. justify-content: flex-start;
  270. }
  271. .divice-number {
  272. display: flex;
  273. align-items: center;
  274. justify-content: space-around;
  275. margin: 20rpx 0;
  276. span {
  277. margin-left: 10rpx;
  278. }
  279. view:last-child span {
  280. color: rgba(112, 182, 3, 1);
  281. }
  282. }
  283. .divice-btm {
  284. display: flex;
  285. align-items: center;
  286. justify-content: flex-start;
  287. width: 96%;
  288. margin: 0 auto;
  289. .btm-mold {
  290. display: flex;
  291. align-items: center;
  292. justify-content: flex-start;
  293. width: 60%;
  294. .content {
  295. width: 35%;
  296. }
  297. }
  298. .btm-mold.btm-last {
  299. width: 40%;
  300. .modle-input {
  301. margin: 0 10rpx;
  302. }
  303. }
  304. }
  305. .device-line {
  306. display: flex;
  307. align-items: center;
  308. width: 100%;
  309. border-bottom: 1rpx solid #ccc;
  310. // margin-bottom: 20rpx;
  311. height: 80rpx;
  312. .line-title {
  313. width: 30%;
  314. text-indent: 30rpx;
  315. }
  316. .line-content {
  317. display: flex;
  318. align-items: center;
  319. justify-content: space-between;
  320. width: 70%;
  321. margin-right: 20rpx;
  322. .content {
  323. width: 70%;
  324. margin: 0 20rpx 0 0;
  325. }
  326. .content-input {
  327. display: flex;
  328. align-items: center;
  329. justify-content: flex-start;
  330. width: 40%;
  331. view {
  332. margin-left: 10rpx;
  333. }
  334. }
  335. .line-right {
  336. display: flex;
  337. align-items: center;
  338. justify-content: flex-end;
  339. .right-minus {
  340. width: 80rpx;
  341. height: 51rpx;
  342. text-align: center;
  343. line-height: 51rpx;
  344. color: #fff;
  345. background: #f59a23;
  346. }
  347. .right-add {
  348. width: 80rpx;
  349. height: 51rpx;
  350. text-align: center;
  351. line-height: 51rpx;
  352. color: #fff;
  353. background: #70b603;
  354. margin-left: 10rpx;
  355. }
  356. .right-choose.u-button--info {
  357. border-color: #70b603;
  358. color: #70b603;
  359. }
  360. }
  361. }
  362. }
  363. .addcar {
  364. width: 100%;
  365. display: flex;
  366. align-items: center;
  367. justify-content: center;
  368. font-size: 120rpx;
  369. color: #ccc;
  370. font-weight: bold;
  371. line-height: 80rpx;
  372. }
  373. .content {
  374. width: 40%;
  375. border: 1rpx solid #ccc;
  376. border-radius: 8rpx;
  377. line-height: 60rpx;
  378. height: 60rpx;
  379. margin: 0 20rpx;
  380. }
  381. .choose {
  382. background: rgba(112, 182, 3, 1);
  383. color: #fff;
  384. padding: 10rpx 20rpx;
  385. border-radius: 8rpx;
  386. }
  387. .del {
  388. background: rgba(236, 128, 141, 1);
  389. color: #fff;
  390. padding: 10rpx 20rpx;
  391. border-radius: 8rpx;
  392. }
  393. .handle {
  394. background: rgba(112, 182, 3, 1);
  395. color: #fff;
  396. padding: 10rpx 20rpx;
  397. border-radius: 8rpx;
  398. margin-left: 60rpx;
  399. }
  400. }
  401. </style>