<template>
  <div>
    <el-card class="!border-none mb-4" shadow="never">
      <el-form class="mb-[-16px]" :model="queryParams" inline>
        <el-form-item label="条码名称" prop="name">
          <el-input
            class="w-[280px]"
            v-model="queryParams.name"
            clearable
            placeholder="请输入条码名称"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="resetPage">查询</el-button>
          <el-button @click="resetParams">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card class="!border-none" v-loading="pager.loading" shadow="never">
      <div class="mt-4">
        <el-table :data="pager.lists">
          <el-table-column label="ID" prop="id" width="55" />
          <el-table-column label="名称" prop="name" show-overflow-tooltip />
          <el-table-column label="商品款数" prop="nums" show-overflow-tooltip />
          <el-table-column label="状态" prop="status" show-overflow-tooltip>
            <template #default="{ row }">
              <span v-if="row.status == 1">已报价</span>
              <span v-if="row.status == 0" style="color: #f56c6c">待报价</span>
            </template>
          </el-table-column>
          <el-table-column label="操作" width="170" fixed="right">
            <template #default="{ row }">
              <el-button link @click="handleDetail(row.id)" type="primary">
                <router-link
                  :to="{
                    path: 'quoteOffer',
                    query: {
                      id: row.id,
                      date: row.name.substring(0, 10)
                    },
                  }"
                >
                  立即报价
                </router-link>
              </el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>
      <div class="flex mt-4 justify-end">
        <pagination v-model="pager" @change="getLists" />
      </div>
    </el-card>
  </div>
</template>

<script lang="ts" setup name="codeLists">
import { usePaging } from "@/hooks/usePaging";
import { useDictData } from "@/hooks/useDictOptions";
import { opurchaseGoodsOfferDateListsApi } from "@/api/quote";
import feedback from "@/utils/feedback";

// 查询条件
const queryParams = reactive({});

// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
  fetchFun: opurchaseGoodsOfferDateListsApi,
  params: queryParams,
});

getLists();

const handleDetail = (e) => {};
</script>
