wuliaocaiji.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. <template>
  2. <div class="scanCode">
  3. <ScanCodeInput v-model="scanCode" @enterfnc="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. const { code, data } = await searchMaterial({
  73. operationId: store.odersData.operationId,
  74. processId: store.scanInfo.id,
  75. seqNo: scanCode.value,
  76. workOrderCode: store.odersData.workOrderCode,
  77. });
  78. if (code == "200") {
  79. scanData.value = data;
  80. showCJ.value = true;
  81. }
  82. };
  83. const opCompentDataList = ref([]);
  84. //通过id获取详情
  85. const getInfoById = async (item: any) => {
  86. const { data } = await getInfo({
  87. itemCode: item.itemCode,
  88. opId: store.odersData.operationId,
  89. processId: store.scanInfo.id,
  90. });
  91. showInfoData.value = data;
  92. showInfo.value = item;
  93. };
  94. const toXQPop = async (item: any) => {
  95. await getInfoById(item);
  96. showXQ.value = true;
  97. };
  98. //提交录入信息
  99. const submitRecordAdd = async (index) => {
  100. const chooseData = scanData.value[index];
  101. if (!chooseData) {
  102. ElMessage.error("请先选择物料,并确定数量在提交录入信息");
  103. return;
  104. }
  105. if (!chooseData.num || chooseData.num < 1) {
  106. ElMessage.error("请输入数量!");
  107. return;
  108. }
  109. const { code, data } = await itemRecordAdd({
  110. itemCode: chooseData.materialCode,
  111. itemModel: chooseData.spec,
  112. itemName: chooseData.materialName,
  113. itemSeq: scanCode.value,
  114. operationId: store.odersData.operationId,
  115. processId: store.scanInfo.id,
  116. num: chooseData.num,
  117. trackBy: "S",
  118. workOrderCode: store.odersData.workOrderCode,
  119. });
  120. if (code == "200") {
  121. showCJ.value = false;
  122. ElMessage.success("录入成功");
  123. getOpCompentData();
  124. }
  125. };
  126. const submit = () => {
  127. let selectIndex = caijiRef.value.selectIndex;
  128. submitRecordAdd(selectIndex);
  129. };
  130. //获取tag列表数据
  131. const getOpCompentData = async () => {
  132. const { data } = await recordList({
  133. operationId: store.odersData.operationId,
  134. workOrderCode: store.odersData.workOrderCode,
  135. pageNo: 1,
  136. pageSize: 9999,
  137. });
  138. opCompentDataList.value = data;
  139. };
  140. const input = ref("");
  141. onMounted(() => {
  142. getOpCompentData();
  143. });
  144. </script>
  145. <style lang="scss" scoped>
  146. .scanCode {
  147. width: 40%;
  148. margin-top: $p5;
  149. }
  150. .materialInfoBody {
  151. width: calc((100vw / 6 * 5) - 50px);
  152. margin-top: $p10;
  153. display: grid;
  154. gap: 20px;
  155. grid-template-columns: 1fr 1fr;
  156. .infoMsgImg {
  157. background-image: url("@/assets/images/caijiwancheng.png");
  158. background-position: right top;
  159. background-repeat: no-repeat;
  160. }
  161. .infoMsg {
  162. min-width: 600px;
  163. height: 190px;
  164. background-color: white;
  165. border-radius: 16px;
  166. display: flex;
  167. padding: $p20;
  168. justify-content: space-between;
  169. align-items: center;
  170. position: relative;
  171. .svgStyle {
  172. position: absolute;
  173. bottom: 0;
  174. right: 0;
  175. }
  176. .describe {
  177. font-size: $f20;
  178. color: $font-default-60;
  179. line-height: 30px;
  180. }
  181. .leftMsg {
  182. .nameMsg {
  183. font-size: $f24;
  184. font-weight: $Medium;
  185. }
  186. }
  187. .rightMsg {
  188. .sum {
  189. font-size: $f38;
  190. font-weight: bold;
  191. line-height: 38px;
  192. text-align: right;
  193. }
  194. }
  195. }
  196. }
  197. .showCodeBody {
  198. width: calc((100vw / 6 * 5) - 50px);
  199. height: calc((100vh - 240px));
  200. @include flex;
  201. .codeBox {
  202. width: 180px;
  203. display: flex;
  204. flex-direction: column;
  205. img {
  206. margin: 0 auto;
  207. }
  208. .codeText {
  209. text-align: center;
  210. font-size: $f20;
  211. color: #00000030;
  212. }
  213. }
  214. }
  215. </style>