wuliaocaiji.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <template>
  2. <div class="scanCode">
  3. <ScanCodeInput v-model="scanCode" @keyup.enter="enterfnc" />
  4. </div>
  5. <div class="showCodeBody" v-if="opCompentDataList.length < 1">
  6. <div class="codeBox">
  7. <img
  8. src="@/assets/icons/shaoma.svg"
  9. style="width: 134px; height: 134px"
  10. />
  11. <div class="codeText">扫码物料码添加物料</div>
  12. </div>
  13. </div>
  14. <div class="materialInfoBody" v-else>
  15. <div
  16. :class="
  17. item.needNum - item.realNum == 0 ? 'infoMsg infoMsgImg' : 'infoMsg'
  18. "
  19. v-for="item in opCompentDataList"
  20. @click="toXQPop(item)"
  21. >
  22. <div class="leftMsg">
  23. <div class="nameMsg">{{ item.itemName }}</div>
  24. <div class="describe">{{ item.itemModel }}</div>
  25. <div class="describe">需求:{{ item.needNum }}</div>
  26. </div>
  27. <div class="rightMsg" v-if="item.needNum - item.realNum != 0">
  28. <div class="sum">{{ item.needNum - item.realNum }}</div>
  29. <div class="describe">还需采集</div>
  30. </div>
  31. <svg-icon icon-class="jiaobiao" size="25" class="svgStyle" />
  32. </div>
  33. </div>
  34. <xiangqingPopUp
  35. v-model="showXQ"
  36. :showInfoData="showInfoData"
  37. :showInfo="showInfo"
  38. />
  39. <caijiRightPopUp
  40. v-model="showCJ"
  41. @submit="submit"
  42. ref="caijiRef"
  43. :seqNo="scanCode"
  44. />
  45. </template>
  46. <script lang="ts" setup>
  47. import ScanCodeInput from "@/components/ScanCodeInput/index.vue";
  48. import caijiRightPopUp from "../popUpView/caijiRightPopUp.vue";
  49. import xiangqingPopUp from "../popUpView/xiangqingPopUp.vue";
  50. import {
  51. recordList,
  52. searchMaterial,
  53. itemRecordAdd,
  54. getInfo,
  55. } from "@/api/prosteps/wuliaocaiji";
  56. import { useProcessStore } from "@/store";
  57. defineOptions({
  58. name: "Wuliaocaiji",
  59. });
  60. const caijiRef = ref(null);
  61. const store = useProcessStore();
  62. const scanCode = ref("");
  63. const showXQ = ref(false);
  64. const showCJ = ref(false);
  65. //详情展示数据
  66. const showInfoData = ref([]);
  67. const showInfo = ref({});
  68. //详情展示数据 ↑
  69. const scanData = ref([]);
  70. provide("scanData", scanData);
  71. const enterfnc = async () => {
  72. let str = scanCode.value;
  73. scanCode.value = "";
  74. const { code, data } = await searchMaterial({
  75. operationId: store.odersData.operationId,
  76. processId: store.scanInfo.id,
  77. seqNo: store.scanInfo.seqNo,
  78. scanCode: str,
  79. workOrderCode: store.odersData.workOrderCode,
  80. });
  81. if (code == "200") {
  82. scanData.value = data;
  83. showCJ.value = true;
  84. }
  85. };
  86. const opCompentDataList = ref([]);
  87. //通过id获取详情
  88. const getInfoById = async (item: any) => {
  89. const { data } = await getInfo({
  90. itemCode: item.itemCode,
  91. opId: store.odersData.operationId,
  92. processId: store.scanInfo.id,
  93. });
  94. showInfoData.value = data;
  95. showInfo.value = item;
  96. };
  97. const toXQPop = async (item: any) => {
  98. await getInfoById(item);
  99. showXQ.value = true;
  100. };
  101. //提交录入信息
  102. const submitRecordAdd = async (index) => {
  103. const chooseData = scanData.value[index];
  104. if (!chooseData) {
  105. ElMessage.error("请先选择物料,并确定数量在提交录入信息");
  106. return;
  107. }
  108. if (!chooseData.num || chooseData.num < 1) {
  109. ElMessage.error("请输入数量!");
  110. return;
  111. }
  112. const { code, data } = await itemRecordAdd({
  113. itemCode: chooseData.materialCode,
  114. itemModel: chooseData.spec,
  115. itemName: chooseData.materialName,
  116. itemSeq: scanCode.value,
  117. operationId: store.odersData.operationId,
  118. processId: store.scanInfo.id,
  119. num: chooseData.num,
  120. seqNo: store.scanInfo.seqNo,
  121. trackBy: "S",
  122. workOrderCode: store.odersData.workOrderCode,
  123. });
  124. if (code == "200") {
  125. showCJ.value = false;
  126. ElMessage.success("录入成功");
  127. getOpCompentData();
  128. }
  129. };
  130. const submit = () => {
  131. let selectIndex = caijiRef.value.selectIndex;
  132. submitRecordAdd(selectIndex);
  133. };
  134. //获取tag列表数据
  135. const getOpCompentData = async () => {
  136. const { data } = await recordList({
  137. operationId: store.odersData.operationId,
  138. workOrderCode: store.odersData.workOrderCode,
  139. seqNo: store.scanInfo.seqNo,
  140. processId: store.scanInfo.id,
  141. pageNo: 1,
  142. pageSize: 9999,
  143. });
  144. opCompentDataList.value = data;
  145. };
  146. const input = ref("");
  147. onMounted(() => {
  148. getOpCompentData();
  149. });
  150. </script>
  151. <style lang="scss" scoped>
  152. .scanCode {
  153. width: 40%;
  154. margin-top: $p5;
  155. }
  156. .materialInfoBody {
  157. width: calc((100vw / 6 * 5) - 50px);
  158. margin-top: $p10;
  159. display: grid;
  160. gap: 20px;
  161. grid-template-columns: 1fr 1fr;
  162. .infoMsgImg {
  163. background-image: url("@/assets/images/caijiwancheng.png");
  164. background-position: right top;
  165. background-repeat: no-repeat;
  166. }
  167. .infoMsg {
  168. min-width: 600px;
  169. height: 190px;
  170. background-color: white;
  171. border-radius: 16px;
  172. display: flex;
  173. padding: $p20;
  174. justify-content: space-between;
  175. align-items: center;
  176. position: relative;
  177. .svgStyle {
  178. position: absolute;
  179. bottom: 0;
  180. right: 0;
  181. }
  182. .describe {
  183. font-size: $f20;
  184. color: $font-default-60;
  185. line-height: 30px;
  186. }
  187. .leftMsg {
  188. .nameMsg {
  189. font-size: $f24;
  190. font-weight: $Medium;
  191. }
  192. }
  193. .rightMsg {
  194. .sum {
  195. font-size: $f38;
  196. font-weight: bold;
  197. line-height: 38px;
  198. text-align: right;
  199. }
  200. }
  201. }
  202. }
  203. .showCodeBody {
  204. width: calc((100vw / 6 * 5) - 50px);
  205. height: calc((100vh - 240px));
  206. @include flex;
  207. .codeBox {
  208. width: 180px;
  209. display: flex;
  210. flex-direction: column;
  211. img {
  212. margin: 0 auto;
  213. }
  214. .codeText {
  215. text-align: center;
  216. font-size: $f20;
  217. color: #00000030;
  218. }
  219. }
  220. }
  221. </style>