caijiRightPopUp.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div class="rightFullPopUp" v-if="modelValue" @click="handleClose">
  3. <div class="container" @click.stop>
  4. <div class="headerTittle">物料采集</div>
  5. <div class="header">
  6. <div class="inputBox">
  7. <ScanCodeInput v-model="scanCode" @keyup.enter="enterfnc" />
  8. </div>
  9. </div>
  10. <el-scrollbar>
  11. <div class="body">
  12. <div
  13. :class="successStaus(item.materialCode) ? 'infoBox' : 'infoBox bg'"
  14. v-for="(item, index) in scanData"
  15. @click="setSelectIndex(index)"
  16. :key="index"
  17. >
  18. <div class="leftInfo">
  19. <div class="titleText">
  20. {{ item.materialName }}({{ item.spec }})
  21. </div>
  22. <div class="describeText">{{ item.materialCode }}</div>
  23. <div class="describeText">批次号:</div>
  24. <template v-if="selectIndex == index">
  25. <ScanCodeInput v-model="item.batchNo" />
  26. </template>
  27. <div v-else class="titleText">{{ item.batchNo }}</div>
  28. <!-- <div class="describeText">批次号:xxx</div>
  29. <div class="describeText">计划编号:xxx</div>
  30. <div class="describeText">订单编号:xxx</div>
  31. <div class="describeText">入库单号:xxx</div> -->
  32. </div>
  33. <div class="rightInput">
  34. <div></div>
  35. <div class="operate">
  36. <div class="describeText operateText">录入数量</div>
  37. <template v-if="selectIndex == index">
  38. <NumberInput v-model="item.num" :max="item.needNum" />
  39. </template>
  40. <div v-else class="titleText">{{ item.num }}</div>
  41. </div>
  42. </div>
  43. </div>
  44. <Empty v-if="scanData.length == 0" />
  45. </div>
  46. </el-scrollbar>
  47. <div class="bottomBtn">
  48. <el-button class="leftBtn" @click="handleClose">取消</el-button>
  49. <el-button class="rightBtn" @click="emits('submit')" type="primary"
  50. >确认</el-button
  51. >
  52. </div>
  53. </div>
  54. </div>
  55. </template>
  56. <script setup>
  57. import {
  58. getInfo,
  59. itemRecordAdd,
  60. recordList,
  61. searchMaterial,
  62. } from "@/api/prosteps/wuliaocaiji";
  63. import { useProcessStore } from "@/store";
  64. const scanCode = ref("");
  65. const store = useProcessStore();
  66. const scanCodeCopyValue = ref("");
  67. const opCompentDataList = inject("opCompentDataList");
  68. //获取当前扫码总物料code code 以及是否数量满足 status
  69. const resArray = ref([]);
  70. const successStaus = (code) => {
  71. let res = true;
  72. for (let i = 0; i < resArray.value.length; i++) {
  73. if (code == resArray.value[i].code) {
  74. res = resArray.value[i].status;
  75. }
  76. }
  77. return res;
  78. };
  79. const getRes = () => {
  80. console.log("111");
  81. resArray.value = [];
  82. opCompentDataList.value.forEach((item) => {
  83. resArray.value.push({
  84. code: item.itemCode,
  85. status: true,
  86. needNum: item.needNum,
  87. });
  88. });
  89. for (let i = 0; i < resArray.value.length; i++) {
  90. let num = 0;
  91. for (let j = 0; j < scanData.value.length; j++) {
  92. if (resArray.value[i].code == scanData.value[j].materialCode) {
  93. num += scanData.value[j].num;
  94. }
  95. }
  96. if (resArray.value[i].needNum <= num) {
  97. resArray.value[i].status = false;
  98. }
  99. }
  100. };
  101. const enterfnc = async () => {
  102. let str = scanCode.value;
  103. scanCodeCopyValue.value = scanCode.value;
  104. scanCode.value = "";
  105. const { code, data } = await searchMaterial({
  106. operationId: store.odersData.operationId,
  107. processId: store.scanInfo.id,
  108. seqNo: store.scanInfo.seqNo,
  109. scanCode: str,
  110. workOrderCode: store.odersData.workOrderCode,
  111. });
  112. if (code == "200") {
  113. let newData = data[0];
  114. for (let i = 0; i < resArray.value.length; i++) {
  115. if ((resArray.value[i].code = newData.materialCode)) {
  116. for (let i = 0; i < resArray.value.length; i++) {
  117. if (resArray.value[i].status == false) {
  118. ElMessage.error("该物料数量已经满足需求数量,请勿再次添加");
  119. return;
  120. }
  121. }
  122. }
  123. }
  124. newData.itemSeq = scanCodeCopyValue.value;
  125. scanData.value.push(newData);
  126. }
  127. };
  128. const emits = defineEmits(["update:modelValue", "submit"]);
  129. const props = defineProps({
  130. modelValue: {
  131. type: Boolean,
  132. default: false,
  133. },
  134. seqNo: {
  135. type: String,
  136. default: "",
  137. },
  138. });
  139. const selectIndex = ref();
  140. const setSelectIndex = (index) => {
  141. selectIndex.value = index;
  142. };
  143. const scanData = inject("scanData");
  144. const scanSum = ref(0);
  145. const handleClose = () => {
  146. emits("update:modelValue", false);
  147. };
  148. const showSeqNo = computed(() => {
  149. return props.seqNo;
  150. });
  151. watch(
  152. () => scanData.value,
  153. () => {
  154. getRes();
  155. },
  156. {
  157. deep: true,
  158. }
  159. );
  160. defineExpose({
  161. selectIndex,
  162. });
  163. </script>
  164. <style lang="scss" scoped>
  165. .header {
  166. @include flex;
  167. width: 100%;
  168. margin: $p10 0;
  169. .inputBox {
  170. width: 75%;
  171. }
  172. }
  173. .describeText {
  174. line-height: 25px !important;
  175. }
  176. .body {
  177. .bg {
  178. background-color: rgb(100, 187, 92) !important;
  179. div {
  180. color: white;
  181. }
  182. }
  183. .infoBox {
  184. width: 100%;
  185. height: 200px;
  186. background-color: white;
  187. border-radius: 16px;
  188. display: flex;
  189. justify-content: space-between;
  190. padding: $p20;
  191. background-color: white;
  192. border-radius: 16px;
  193. margin-bottom: $f10;
  194. .leftInfo {
  195. display: flex;
  196. flex-direction: column;
  197. justify-content: space-between;
  198. div {
  199. text-align: left;
  200. }
  201. }
  202. .rightInput {
  203. display: flex;
  204. flex-direction: column;
  205. justify-content: space-between;
  206. .operate {
  207. .operateText {
  208. text-align: left;
  209. }
  210. }
  211. }
  212. }
  213. }
  214. .bottomBtn {
  215. width: 100%;
  216. height: 70px;
  217. display: flex;
  218. align-items: center;
  219. justify-content: space-between;
  220. padding: $p10 10% 0 10%;
  221. .leftBtn {
  222. height: 55px;
  223. width: 45%;
  224. border-radius: 16px;
  225. font-size: $f20;
  226. color: #0a59f7;
  227. background-color: #00000015;
  228. border: 0px;
  229. }
  230. .rightBtn {
  231. height: 55px;
  232. width: 45%;
  233. border-radius: 16px;
  234. font-size: $f20;
  235. color: white;
  236. }
  237. }
  238. </style>