<script setup lang="ts">
import { ref } from "vue";
import SingleMode from "./single-mode.vue";
import BatchMode from "./batch-mode.vue";

defineProps<{
  supplierNo?: string;
  companyNo?: string;
  isComon?: string;
}>();

const emit = defineEmits(["pushOrder"]);

const visible = ref(false);
const isBatch = ref("1");

//派发保存x
function handlePushOrder(orders) {
  visible.value = false;
  emit("pushOrder", orders);
}

defineExpose({
  onDisplay: () => (visible.value = true)
});
</script>

<template>
  <ElDialog
    :close-on-click-modal="false"
    top="5vh"
    v-model="visible"
    title="选择采购单"
    center
    destroy-on-close
    width="1040px"
  >
    <el-radio-group v-model="isBatch">
      <el-radio label="1">勾选查找</el-radio>
      <el-radio label="2">批量查找(采购单号)</el-radio>
      <el-radio label="3">批量查找(销售单号)</el-radio>
    </el-radio-group>

    <template v-if="isBatch === '1'">
      <single-mode
        :company-no="companyNo"
        :supplier-no="supplierNo"
        :isComon="isComon"
        @selection="handlePushOrder"
      />
    </template>

    <template v-else>
      <batch-mode
        :company-no="companyNo"
        :supplier-no="supplierNo"
        :type="isBatch"
        :isComon="isComon"
        @selection="handlePushOrder"
      />
    </template>
  </ElDialog>
</template>

<style lang="scss" scoped>
::v-deep(.el-input__wrapper) {
  // box-shadow: none !important;
  box-shadow: 0 0 0 1px var(--el-input-border-color, var(--el-border-color))
    inset !important;
}
</style>
