<template>
  <div class="pageIndexClass">
    <byTable :source="sourceList.data" :pagination="sourceList.pagination" :config="config" :loading="loading" :selectConfig="selectConfig"
             highlight-current-row @get-list="getList">
      <template #code="{ item }">
        <div v-if="Number(item.sumPayMoney) > Number(item.amount)" style="cursor: pointer; color: #f54a45" @click="handleClickCode(item)">
          {{ item.code }}
        </div>
        <div v-else style="cursor: pointer; color: #409eff" @click="handleClickCode(item)">
          {{ item.code }}
        </div>
      </template>

    </byTable>

  </div>
</template>

<script setup>
import byTable from "@/components/byTable/index";
const { proxy } = getCurrentInstance();
const payStatus = ref([
  {
    label: "未付款",
    value: 0,
  },
  {
    label: "部分付款",
    value: 10,
  },
  {
    label: "已付款",
    value: 20,
  },
]);
const sourceList = ref({
  data: [],
  pagination: {
    total: 0,
    pageNum: 1,
    pageSize: 10,
    keyword: "",
    status: "",
    payStatus: "",
  },
});
const loading = ref(false);
const selectConfig = computed(() => {
  return [];
});
const config = computed(() => {
  return [
    {
      attrs: {
        label: "订单类型",
        prop: "a",
        width: 130,
      },
    },
    {
      attrs: {
        label: "订单号",
        prop: "code",
        width: 180,
      },
    },

    {
      attrs: {
        label: "业务公司",
        prop: "b",
        width: 140,
      },
    },
    {
      attrs: {
        label: "业务部门",
        prop: "c",
        width: 140,
      },
    },
    {
      attrs: {
        label: "工厂",
        prop: "userName",
        width: 140,
      },
    },
    {
      attrs: {
        label: "订单归属",
        prop: "d",
        width: 140,
      },
    },

    {
      attrs: {
        label: "订单金额",
        prop: "amount",
        width: 140,
      },
    },
    {
      attrs: {
        label: "下单时间",
        prop: "createTime",
        width: 160,
      },
    },
    {
      attrs: {
        label: "交期",
        prop: "e",
        width: 140,
      },
    },
    {
      attrs: {
        label: "完工入库时间",
        prop: "createTime",
        width: 160,
      },
    },

    {
      attrs: {
        label: "出货时间",
        prop: "f",

        width: 140,
      },
    },
    {
      attrs: {
        label: "出货间隔时间",
        prop: "g",

        width: 140,
      },
    },
    {
      attrs: {
        label: "出货不及时率",
        prop: "h",

        width: 140,
      },
    },
  ];
});

const getList = async (req) => {
  sourceList.value.pagination = { ...sourceList.value.pagination, ...req };
  loading.value = true;
  proxy.post("/ehsdPurchase/page", sourceList.value.pagination).then((res) => {
    console.log(res);
    sourceList.value.data = res.rows.map((x) => ({
      ...x,
      a: "常规订单",
      b: "三梵实业",
      c: "业务部",
      d: "三梵体育",
      e: "2024-02-15",
      f: "2024-02-14",
      g: "10",
      h: "10%",
    }));
    sourceList.value.pagination.total = res.total;
    setTimeout(() => {
      loading.value = false;
    }, 200);
  });
};

getList();
</script>

<style lang="scss" scoped>
</style>