creatTask.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418
  1. <template>
  2. <div>
  3. <el-row :gutter="20">
  4. <el-col :span="24">
  5. <div style="display: flex; margin-bottom: 15px">
  6. <div class="type-title">当前料箱</div>
  7. <div class="current-box" style="width: 25vw">
  8. <span class="left">料箱id: {{ boxDetail?.rfid ?? "" }}</span>
  9. <!-- <span class="right">{{ boxDetail?.code || "未绑定料箱" }}</span>-->
  10. </div>
  11. <ScanCodeInput
  12. v-model="currentBox"
  13. :clearable="true"
  14. placeholder="请扫描或输入料箱编号"
  15. style="width: 30vw"
  16. @keyup.enter="enterBox"
  17. />
  18. </div>
  19. <div style="display: flex; margin-bottom: 15px">
  20. <div class="type-title">请扫码物料</div>
  21. <ScanCodeInput
  22. v-model="scanCodeInput"
  23. style="width: 30vw"
  24. placeholder="请扫描或输入物料编码"
  25. @keyup.enter="handleScanCodeInput"
  26. />
  27. </div>
  28. <div
  29. v-loading="map.get('getMaterialInfoByLabel')"
  30. style="height: calc(100vh - 350px); margin-top: 15px"
  31. >
  32. <el-scrollbar>
  33. <div class="list-container">
  34. <div
  35. v-for="(item, index) in materialList"
  36. :key="item"
  37. class="list-box"
  38. >
  39. <div>
  40. <div class="name">{{ item.materialName }}</div>
  41. <div class="spec">{{ item.materialCode }}</div>
  42. <div class="spec">{{ item.batchNo }}</div>
  43. <div class="spec">
  44. {{ item.spec }}
  45. </div>
  46. </div>
  47. <div class="bottom">
  48. <NumberInput
  49. v-if="item.codeType === 'BATCH'"
  50. v-model="item.num"
  51. />
  52. <div v-else class="number" v-text="item.num"></div>
  53. <span class="unit">{{ item.unitDictLabel }}</span>
  54. </div>
  55. <i-ep-delete
  56. class="delete"
  57. color="#ff4d4f"
  58. size="20px"
  59. @click="deleteMaterial(index)"
  60. />
  61. </div>
  62. </div>
  63. </el-scrollbar>
  64. </div>
  65. </el-col>
  66. <!-- <el-col :span="8" style="position: relative">
  67. <div class="type-title">流转终点</div>
  68. <div class="destination">
  69. <el-scrollbar>
  70. <div
  71. v-for="(item, index) in destinationList"
  72. :key="index"
  73. :class="{ selected: index === currentDestinationIndex }"
  74. class="end-box"
  75. @click="onEndBoxClick(index, item)"
  76. >
  77. <div class="name">{{ item.name }}</div>
  78. </div>
  79. </el-scrollbar>
  80. </div>
  81. </el-col> -->
  82. <el-button
  83. class="sureBtn el-button-big"
  84. type="primary"
  85. @click="popStatus = true"
  86. >创建任务
  87. </el-button>
  88. </el-row>
  89. <!-- 弹窗 -->
  90. <div class="midPopUp" v-if="popStatus" @click="handleClose">
  91. <div class="container" @click.stop>
  92. <div class="body">
  93. <div class="destination">
  94. <el-scrollbar>
  95. <div
  96. v-for="(item, index) in destinationList"
  97. :key="index"
  98. :class="{ selected: index === currentDestinationIndex }"
  99. class="end-box"
  100. @click="onEndBoxClick(index, item)"
  101. >
  102. <div class="name">{{ item.name }}</div>
  103. </div>
  104. </el-scrollbar>
  105. </div>
  106. </div>
  107. <div class="bottomBtn">
  108. <el-button class="leftBtn" @click="handleClose">取消</el-button>
  109. <el-button class="rightBtn" @click="createTask" type="primary"
  110. >确认</el-button
  111. >
  112. </div>
  113. </div>
  114. </div>
  115. </div>
  116. </template>
  117. <script lang="ts" setup>
  118. //料箱
  119. import {
  120. addMaterialFlow,
  121. getDestinationList,
  122. getMaterialInfoByLabel,
  123. getStationInfo,
  124. } from "@/api/process/materialFlow";
  125. import { useCommonStoreHook, useUserStore } from "@/store";
  126. const popStatus = ref(false);
  127. const handleClose = () => {
  128. popStatus.value = false;
  129. };
  130. const submit = () => {};
  131. const commonS = useCommonStoreHook();
  132. const userStore = useUserStore();
  133. const map = commonS.loadingMap;
  134. const currentBox = ref("");
  135. const boxDetail = ref<any>({});
  136. let currentTimer = -1;
  137. const enterBox = () => {
  138. currentBox.value = currentBox.value.trim();
  139. boxDetail.value.rfid = currentBox.value;
  140. // getBoxDetailByLabel(currentBox.value).then((res: any) => {
  141. // boxDetail.value = res.data;
  142. // // materialList.value = res.data.materialList;
  143. // });
  144. };
  145. // 物料
  146. const scanCodeInput = ref("");
  147. const materialList = ref<any[]>([]);
  148. const handleScanCodeInput = () => {
  149. getMaterialInfoByLabel(scanCodeInput.value).then((res: any) => {
  150. // 扫描之后要先查看数组中是否有这个物料,有的话就数量相加,没有的话就添加到数组中
  151. let hasMaterial = false;
  152. for (let i = 0; i < materialList.value.length; i++) {
  153. let currentMaterial = materialList.value[i];
  154. if (
  155. currentMaterial.batchCode === res.data.batchCode &&
  156. currentMaterial.materialCode === res.data.materialCode
  157. ) {
  158. hasMaterial = true;
  159. // SEQ/BATCH 如果是流转卡号数量只能唯1,序列号相加
  160. if (currentMaterial.codeType === "BATCH") {
  161. materialList.value[i].num += res.data.num;
  162. break;
  163. }
  164. }
  165. }
  166. !hasMaterial && materialList.value.push(res.data);
  167. scanCodeInput.value = "";
  168. });
  169. };
  170. const deleteMaterial = (index: number) => {
  171. materialList.value.splice(index, 1);
  172. };
  173. // 流转终点
  174. const destinationList = ref<any>();
  175. const currentDestination = ref<any>({});
  176. const currentDestinationIndex = ref(-1);
  177. const storeMap = new Map<string, Array<any>>();
  178. const selectStore = ref<any>({});
  179. const onEndBoxClick = (index: number, item: any) => {
  180. currentDestination.value = item;
  181. currentDestinationIndex.value = index;
  182. // 如果是仓库,会根据仓库的no获取仓储的列表,存入map, 如果已经有数据了则不需要再次请求接口 =》 后来不需要展示了 就注释了
  183. // if (item.targetType === "stock") {
  184. // if (!storeMap.has(item.houseNo)) {
  185. // getStoreListByNo(item.houseNo).then((res) => {
  186. // storeMap.set(item.houseNo, res.data || []);
  187. // });
  188. // }
  189. // }
  190. };
  191. onMounted(() => {
  192. let wm = new WeakMap();
  193. getDestinationList(1).then((res: any) => {
  194. destinationList.value = res.data;
  195. });
  196. currentTimer = setInterval(() => {
  197. if (currentBox.value && currentBox.value.trim() !== "") {
  198. boxDetail.value.rfid = currentBox.value.trim();
  199. } else {
  200. getStationInfo({ stanCode: userStore.user.stationCode }).then(
  201. (res: any) => {
  202. boxDetail.value = res.data;
  203. // 如果右边的输入框有值,就以右边的为准
  204. }
  205. );
  206. }
  207. }, 1500);
  208. });
  209. onBeforeUnmount(() => {
  210. clearInterval(currentTimer);
  211. });
  212. const createTask = () => {
  213. const params = {
  214. circulationDetail: [...materialList.value],
  215. // coordinate: "",
  216. houseNo: "1",
  217. // locationNo: "",
  218. stationId: "",
  219. targetType: "",
  220. vehicleCode: boxDetail.value.rfid,
  221. // vehicleId: 0,
  222. vehicleName: "",
  223. };
  224. params.targetType = currentDestination.value.targetType;
  225. if (currentDestination.value.targetType === "stock") {
  226. params.houseNo = currentDestination.value.houseNo;
  227. // params.locationNo = selectStore.value.locationNo;
  228. // params.coordinate = selectStore.value.coordinate;
  229. } else {
  230. params.stationId = currentDestination.value.id;
  231. }
  232. addMaterialFlow(params).then((res) => {
  233. ElMessage.success("创建成功");
  234. //1366 一体机—物料流转任务创建成功后 清空页面数据
  235. scanCodeInput.value = "";
  236. materialList.value = [];
  237. handleClose();
  238. });
  239. };
  240. </script>
  241. <style lang="scss" scoped>
  242. .type-title {
  243. width: 190px;
  244. font-weight: 500;
  245. font-size: 30px;
  246. color: rgba(0, 0, 0, 0.9);
  247. text-align: left;
  248. margin-bottom: 15px;
  249. }
  250. .midPopUp {
  251. z-index: 999;
  252. .container {
  253. display: flex;
  254. .body {
  255. flex: 1;
  256. height: calc(100% - 40px);
  257. padding: 0 10%;
  258. }
  259. .bottomBtn {
  260. height: 40px;
  261. display: flex;
  262. justify-content: center;
  263. align-items: center;
  264. .el-button {
  265. width: 120px;
  266. height: 40px;
  267. font-size: 20px;
  268. }
  269. }
  270. }
  271. }
  272. .current-box {
  273. background: rgba(0, 0, 0, 0.06);
  274. border-radius: 16px 16px 16px 16px;
  275. font-size: 20px;
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. width: 50%;
  280. height: 49px;
  281. padding: 0 20px;
  282. .left {
  283. font-weight: 400;
  284. color: rgba(0, 0, 0, 0.6);
  285. text-align: left;
  286. }
  287. .right {
  288. font-weight: 500;
  289. color: rgba(0, 0, 0, 0.9);
  290. text-align: right;
  291. }
  292. }
  293. .list-container {
  294. width: 100%;
  295. display: grid;
  296. /*行间距*/
  297. grid-row-gap: 24px;
  298. /*列间距*/
  299. grid-column-gap: 24px;
  300. grid-template-columns: 1fr 1fr 1fr;
  301. .list-box {
  302. min-height: 240px;
  303. background: #fff;
  304. border-radius: 16px 16px 16px 16px;
  305. display: flex;
  306. flex-direction: column;
  307. justify-content: space-between;
  308. align-items: start;
  309. padding: 30px 30px;
  310. position: relative;
  311. .name {
  312. font-weight: 500;
  313. font-size: 24px;
  314. color: rgba(0, 0, 0, 0.9);
  315. text-align: left;
  316. }
  317. .spec {
  318. font-size: 20px;
  319. color: rgba(0, 0, 0, 0.6);
  320. text-align: left;
  321. }
  322. .bottom {
  323. display: flex;
  324. justify-content: start;
  325. align-items: end;
  326. }
  327. .unit {
  328. font-weight: 500;
  329. font-size: 24px;
  330. color: rgba(0, 0, 0, 0.6);
  331. text-align: left;
  332. margin-left: 5px;
  333. }
  334. .delete {
  335. position: absolute;
  336. top: 20px;
  337. right: 20px;
  338. }
  339. }
  340. }
  341. .destination {
  342. height: calc(100% - 40px);
  343. margin-top: 15px;
  344. .end-box {
  345. height: 80px;
  346. background: #ffffff;
  347. border-radius: 40px;
  348. display: flex;
  349. justify-content: center;
  350. align-items: center;
  351. font-weight: 500;
  352. font-size: 24px;
  353. color: rgba(0, 0, 0, 0.9);
  354. display: flex;
  355. justify-content: space-evenly;
  356. align-items: center;
  357. }
  358. .end-box:not(:last-child) {
  359. margin-bottom: 15px;
  360. }
  361. .selected {
  362. border-radius: 40px;
  363. border: 2px solid rgba(10, 89, 247, 1);
  364. }
  365. .name {
  366. font-weight: 500;
  367. font-size: 24px;
  368. color: rgba(0, 0, 0, 0.9);
  369. }
  370. }
  371. .sureBtn {
  372. height: 80px;
  373. background: #0a59f7;
  374. border-radius: 76px 76px 76px 76px;
  375. width: 32vw;
  376. margin-top: 10px;
  377. font-size: $f24;
  378. position: fixed;
  379. top: 70px;
  380. right: 24px;
  381. z-index: 9;
  382. }
  383. .number {
  384. font-size: $f38;
  385. font-weight: bolder;
  386. }
  387. </style>