wuliaocaiji.vue 6.6 KB

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