<template>
  <!-- 扫码板块 -->
  <div class="icon">
    <img class="imgIcon" src="@/assets/icons/shaoma.svg" />
  </div>
  <div class="body">
    <ScanCodeInput v-model="inputValue" @keyup.enter="toProSteps" />
  </div>
</template>

<script lang="ts" setup>
import ScanCodeInput from "@/components/ScanCodeInput/index.vue";
import { useProcessStore } from "@/store";
import { getScan } from "@/api/process";
const store = useProcessStore();
const router = useRouter();
const inputValue = ref("");
const toProSteps = () => {
  if (inputValue.value == "") return ElMessage.error("二维码不能为空！");
  store.odersData.qrCode = inputValue.value;
  getScanData();
};
const getScanData = async () => {
  const { code, data, msg } = await getScan({
    operationId: Number(store.odersData.operationId),
    qrCode: store.odersData.qrCode,
    workOrderCode: store.odersData.workOrderCode,
    //stationId暂时随便传一个
    stationId: 1,
  });
  if (code == "200") {
    store.scanInfo = data;
    router.push({ path: "/pro-steps" });
  }
};
</script>

<style lang="scss" scoped>
.icon {
  @include flex;
  height: 120px;

  .imgIcon {
    width: 100px;
    height: 100px;
  }
}
</style>
