<script setup lang="ts">
import { shallowRef, shallowReactive } from "vue";
import SearchBatch from "./search-batch.vue";
import SearchBatchMain from "./search-batch-main.vue";

import { useCompany } from "/@/hooks/core/useCompany";


enum SearchMode {
  check,
  batch
}

const { currentCompany } = useCompany()
const showModel = shallowRef(false);
const currentSearchMode = shallowRef(3);
const emit = defineEmits(["reload", "save-btn-click"]);

const payload = shallowReactive({
  companyNo: "",
  platform_type: ""
});

async function show(_companyNo, _platform_type) {
  showModel.value = true;
  payload.companyNo = currentCompany.value.companyNo;
  payload.platform_type = "";
}

function handleConfirm(selected) {
  emit("save-btn-click", selected);
  showModel.value = false;
}

defineExpose({
  show
});
</script>

<template>
  <el-dialog
    top="5vh"
    center
    v-model="showModel"
    :close-on-click-modal="false"
    :close-on-press-escape="false"
    append-to-body
    destroy-on-close
    title="批量查找订单"
    :width="'1040px'"
  >
    <ElRadioGroup v-model="currentSearchMode">
      <ElRadio :label="3">批量查找(销售订单主编号)</ElRadio>
      <ElRadio :label="2">批量查找(销售订单编号)</ElRadio>
    </ElRadioGroup>

    <template v-if="currentSearchMode === 2">
      <SearchBatch :payload="payload" @confirm="handleConfirm" />
    </template>

    <template v-if="currentSearchMode === 3">
      <SearchBatchMain :payload="payload" @confirm="handleConfirm" />
    </template>
  </el-dialog>
</template>

<style lang="scss" scoped>
:deep(.el-pagination) {
  justify-content: flex-start !important;
}

.search {
  padding: 0px !important;
}
</style>
