<template>
  <div>
    <el-button type="primary" @click="rePush" style="margin-bottom: 16px">
      重新推送
    </el-button>
    <el-table :data="pager.lists">
      <el-table-column
        label="商品名称"
        prop="goods_name"
        show-overflow-tooltip
      />
      <!-- <el-table-column
        label="商品标签"
        prop="sys_labels_arr"
        show-overflow-tooltip
      >
        <template #default="{ row }">
          <span>{{
            row.sys_labels_arr.map((t: any) => t.name).join(",")
          }}</span>
        </template>
      </el-table-column> -->
      <el-table-column label="单位" prop="unit_name" show-overflow-tooltip />
      <el-table-column label="单价(元)" prop="price" show-overflow-tooltip />
      <el-table-column prop="nums" label="数量" />
      <el-table-column prop="total" label="合计(元)" />
      <el-table-column label="备注" prop="data" show-overflow-tooltip />
    </el-table>
    <div class="flex mt-4 justify-end">
      <pagination v-if="pager.lists" v-model="pager" @change="getLists" />
    </div>
  </div>
</template>

<script lang="ts" setup name="subOrder">
import { usePaging } from "@/hooks/usePaging";
import { useDictData } from "@/hooks/useDictOptions";
import {
  apiOpurchaseinfoListList,
  apicreateSupplierGoods,
} from "@/api/opurchaseclass";
import { useRoute } from "vue-router";

const route = useRoute();

const queryParams = reactive({
  is_push: 0,
  id: route.query.id,
  is_mer: 2,
  sys_labels_arr: "",
});
// 分页相关
const { pager, getLists, resetParams, resetPage } = usePaging({
  fetchFun: apiOpurchaseinfoListList,
  params: queryParams,
});

defineExpose({
  getLists,
});

// 获取字典数据
const { dictData } = useDictData("pay_type,auditing_type");

const rePush = async () => {
  await apicreateSupplierGoods({ id: route.query.id });
};
</script>
