creatTask.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303
  1. <template>
  2. <div>
  3. <el-row :gutter="20">
  4. <el-col :span="16">
  5. <div class="type-title">当前料箱</div>
  6. <div style="display: flex; margin-bottom: 15px">
  7. <ScanCodeInput
  8. v-model="currentBox"
  9. :clearable="true"
  10. placeholder="请扫描或输入料箱编号"
  11. style="width: 50%"
  12. @keyup.enter="enterBox"
  13. />
  14. <div class="current-box">
  15. <span class="left">{{ boxDetail?.name || "未绑定料箱" }}</span>
  16. <span class="right">{{ boxDetail?.code || "未绑定料箱" }}</span>
  17. </div>
  18. </div>
  19. <div class="type-title">请扫码物料</div>
  20. <ScanCodeInput
  21. v-model="scanCodeInput"
  22. placeholder="请扫描或输入物料编码"
  23. @keyup.enter="handleScanCodeInput"
  24. />
  25. <div style="height: calc(100vh - 450px); margin-top: 15px">
  26. <el-scrollbar>
  27. <div class="list-container">
  28. <div
  29. v-for="(item, index) in materialList"
  30. :key="index"
  31. class="list-box"
  32. >
  33. <div>
  34. <div class="name">{{ item.materialName }}</div>
  35. <div class="spec">{{ item.spec }}</div>
  36. </div>
  37. <div class="bottom">
  38. <NumberInput v-model="item.num" />
  39. <span class="unit">{{ item.unitDictLabel }}</span>
  40. </div>
  41. </div>
  42. </div>
  43. </el-scrollbar>
  44. </div>
  45. </el-col>
  46. <el-col :span="8">
  47. <div class="type-title">流转终点</div>
  48. <div class="destination">
  49. <div
  50. v-for="(item, index) in destinationList"
  51. :key="index"
  52. :class="{ selected: index === currentDestinationIndex }"
  53. class="end-box"
  54. @click="onEndBoxClick(index, item)"
  55. >
  56. <div class="name">{{ item.name }}</div>
  57. <div
  58. v-if="
  59. item.targetType === 'stock' && index === currentDestinationIndex
  60. "
  61. >
  62. <el-select
  63. v-model="selectStore"
  64. filterable
  65. placeholder="请选择"
  66. size="large"
  67. style="width: 200px"
  68. value-key="id"
  69. >
  70. <el-option
  71. v-for="store in storeMap.get(item.houseNo)"
  72. :key="store.id"
  73. :label="store.name"
  74. :value="store"
  75. />
  76. </el-select>
  77. </div>
  78. </div>
  79. </div>
  80. <el-button class="sureBtn" type="primary" @click="createTask"
  81. >创建任务
  82. </el-button>
  83. </el-col>
  84. </el-row>
  85. </div>
  86. </template>
  87. <script lang="ts" setup>
  88. //料箱
  89. import {
  90. addMaterialFlow,
  91. getBoxDetailByLabel,
  92. getDestinationList,
  93. getMaterialInfoByLabel,
  94. getStoreListByNo,
  95. } from "@/api/process/materialFlow";
  96. const currentBox = ref("ZJ000011");
  97. const boxDetail = ref<any>({});
  98. const enterBox = () => {
  99. getBoxDetailByLabel(currentBox.value).then((res) => {
  100. boxDetail.value = res.data;
  101. // materialList.value = res.data.materialList;
  102. });
  103. };
  104. // 物料
  105. const scanCodeInput = ref("2010100002301#gys022#sc022#100#20220929#31");
  106. const materialList = ref<any>([]);
  107. const handleScanCodeInput = () => {
  108. getMaterialInfoByLabel(scanCodeInput.value).then((res) => {
  109. res.data.batchCode = scanCodeInput.value;
  110. materialList.value.push(res.data);
  111. scanCodeInput.value = "";
  112. });
  113. };
  114. // 流转终点
  115. const destinationList = ref<any>();
  116. const currentDestination = ref<any>({});
  117. const currentDestinationIndex = ref(-1);
  118. const storeMap = new Map<string, Array<any>>();
  119. const selectStore = ref<any>({});
  120. const onEndBoxClick = (index: number, item: any) => {
  121. currentDestination.value = item;
  122. currentDestinationIndex.value = index;
  123. // 如果是仓库,会根据仓库的no获取仓储的列表,存入map, 如果已经有数据了则不需要再次请求接口
  124. if (item.targetType === "stock") {
  125. if (!storeMap.has(item.houseNo)) {
  126. getStoreListByNo(item.houseNo).then((res) => {
  127. storeMap.set(item.houseNo, res.data || []);
  128. });
  129. }
  130. }
  131. };
  132. onMounted(() => {
  133. let wm = new WeakMap();
  134. getDestinationList().then((res) => {
  135. console.log("destinationList", res);
  136. destinationList.value = res.data;
  137. });
  138. });
  139. const createTask = () => {
  140. const params = {
  141. circulationDetail: [...materialList.value],
  142. coordinate: "",
  143. houseNo: "",
  144. locationNo: "",
  145. stationId: 0,
  146. targetType: "",
  147. vehicleCode: "",
  148. vehicleId: 0,
  149. vehicleName: "",
  150. };
  151. params.targetType = currentDestination.value.targetType;
  152. if (currentDestination.value.targetType === "stock") {
  153. params.houseNo = currentDestination.value.houseNo;
  154. params.locationNo = selectStore.value.locationNo;
  155. params.coordinate = selectStore.value.coordinate;
  156. } else {
  157. params.stationId = currentDestination.value.id;
  158. }
  159. params.vehicleId = boxDetail.value.id;
  160. params.vehicleCode = boxDetail.value.code;
  161. params.vehicleName = boxDetail.value.name;
  162. addMaterialFlow(params).then((res) => {
  163. ElMessage.success("创建成功");
  164. console.log("res", res);
  165. });
  166. };
  167. </script>
  168. <style lang="scss" scoped>
  169. .type-title {
  170. font-weight: 500;
  171. font-size: 30px;
  172. color: rgba(0, 0, 0, 0.9);
  173. text-align: left;
  174. margin-bottom: 15px;
  175. }
  176. .current-box {
  177. background: rgba(0, 0, 0, 0.06);
  178. border-radius: 16px 16px 16px 16px;
  179. font-size: 20px;
  180. display: flex;
  181. justify-content: space-between;
  182. align-items: center;
  183. width: 50%;
  184. height: 49px;
  185. padding: 0 20px;
  186. .left {
  187. font-weight: 400;
  188. color: rgba(0, 0, 0, 0.6);
  189. text-align: left;
  190. }
  191. .right {
  192. font-weight: 500;
  193. color: rgba(0, 0, 0, 0.9);
  194. text-align: right;
  195. }
  196. }
  197. .list-container {
  198. width: 100%;
  199. display: grid;
  200. /*行间距*/
  201. grid-row-gap: 24px;
  202. /*列间距*/
  203. grid-column-gap: 24px;
  204. grid-template-columns: 1fr 1fr;
  205. .list-box {
  206. height: 210px;
  207. background: #fff;
  208. border-radius: 16px 16px 16px 16px;
  209. display: flex;
  210. flex-direction: column;
  211. justify-content: space-between;
  212. align-items: start;
  213. padding: 30px 30px;
  214. .name {
  215. font-weight: 500;
  216. font-size: 24px;
  217. color: rgba(0, 0, 0, 0.9);
  218. text-align: left;
  219. }
  220. .spec {
  221. font-size: 20px;
  222. color: rgba(0, 0, 0, 0.6);
  223. text-align: left;
  224. }
  225. .bottom {
  226. display: flex;
  227. justify-content: start;
  228. align-items: end;
  229. }
  230. .unit {
  231. font-weight: 500;
  232. font-size: 24px;
  233. color: rgba(0, 0, 0, 0.6);
  234. text-align: left;
  235. margin-left: 5px;
  236. }
  237. }
  238. }
  239. .destination {
  240. height: calc(100vh - 350px);
  241. margin-top: 15px;
  242. .end-box {
  243. height: 80px;
  244. background: #ffffff;
  245. border-radius: 40px;
  246. display: flex;
  247. justify-content: center;
  248. align-items: center;
  249. font-weight: 500;
  250. font-size: 24px;
  251. color: rgba(0, 0, 0, 0.9);
  252. display: flex;
  253. justify-content: space-evenly;
  254. align-items: center;
  255. }
  256. .end-box:not(:last-child) {
  257. margin-bottom: 15px;
  258. }
  259. .selected {
  260. border-radius: 40px;
  261. border: 2px solid rgba(10, 89, 247, 1);
  262. }
  263. .name {
  264. font-weight: 500;
  265. font-size: 24px;
  266. color: rgba(0, 0, 0, 0.9);
  267. }
  268. }
  269. .sureBtn {
  270. height: 80px;
  271. background: #0a59f7;
  272. border-radius: 76px 76px 76px 76px;
  273. width: 100%;
  274. margin-top: 10px;
  275. }
  276. </style>