picking.vue 8.7 KB

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