picking.vue 8.2 KB

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