<template>
  <!-- 扫码板块 -->
  <div class="commonTitle">扫码</div>
  <div class="icon">
    <img class="imgIcon" src="@/assets/icons/shaoma.svg" @click="toProSteps" />
  </div>
  <div class="body">
    <ScanCodeInput :inputValue="inputValue" @setinputvalue="setInputValue" @enterfnc="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("12020100000052404100011");
const toProSteps = () => {
  store.odersData.qrCode = inputValue.value;
  getScanData();
};
const setInputValue = (value: any) => {
  inputValue.value = value;
};
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" });
  } else {
    ElMessage.warning(msg);
  }
};
</script>

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

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