<template>
  <div class="app-container">
    <el-radio-group
      v-model="queryParams.type"
      size="mini"
      @change="handleQuery"
    >
      <el-radio-button label="1">成果</el-radio-button>
      <el-radio-button label="2">专利</el-radio-button>
      <el-radio-button label="3">专家</el-radio-button>
      <el-radio-button label="4">实验室</el-radio-button>
      <el-radio-button label="5">企业</el-radio-button>
    </el-radio-group>

    <!-- <el-row :gutter="20">
      <el-col
        :xs="12"
        :sm="6"
        :lg="4"
        style="margin-top: 20px"
        v-for="item in 10"
        :key="item"
      >
        <div style="border: 1px solid #787878">
          <div style="text-align: right">
            <el-tag type="warning" effect="dark" style="border-radius: 0">
              7.8万
            </el-tag>
          </div>
          <div style="padding: 10px">
            <div class="ellipsis">
              高碳当量高强度灰铁材质研发高碳当量高强度灰铁材质研发
            </div>
            <div
              style="
                margin: 10px 0;
                display: flex;
                justify-content: space-between;
              "
            >
              <el-tag type="info" effect="plain">所属领域</el-tag>
              <el-tag type="info" effect="plain">普通企业需求</el-tag>
            </div>
            <div style="margin-bottom: 10px">研发类型:</div>
            <div>截止时间:</div>
          </div>
          <div class="btn_info pointer">查看详情</div>
        </div>
      </el-col>
    </el-row> -->

    <div style="margin-top: 20px" v-loading="loading">
      <section v-for="item in postList" :key="item.id">
        <div style="border: 1px solid #dcdcdc; margin-bottom: 10px">
          <gainItem :data="item"></gainItem>
        </div>
      </section>
    </div>

    <!-- <pagination
      v-show="total > 0"
      :total="total"
      v-model:page="queryParams.pageNum"
      v-model:limit="queryParams.pageSize"
      @pagination="getList"
    /> -->
  </div>
</template>

<script setup name="Post">
import {
  listPost,
  addPost,
  delPost,
  getPost,
  updatePost,
} from "@/api/system/post";
import gainItem from "@/views/admin/components/gainItem.vue";

const { proxy } = getCurrentInstance();
const router = useRouter();

const postList = ref([]);
const loading = ref(true);
const total = ref(0);

const data = reactive({
  form: {},
  queryParams: {
    pageNum: 1,
    pageSize: 10,
    postCode: undefined,
    type: "1",
  },
  rules: {
    name: [{ required: true, message: "公司名称不能为空", trigger: "blur" }],
    dutyParagraph: [
      { required: true, message: "公司税号不能为空", trigger: "blur" },
    ],
    bank: [{ required: true, message: "开户行不能为空", trigger: "blur" }],
    bankAccount: [
      { required: true, message: "开户行账号不能为空", trigger: "blur" },
    ],
    bankPhone: [
      { required: true, message: "开户行电话不能为空", trigger: "blur" },
    ],
    email: [{ required: true, message: "电子邮箱不能为空", trigger: "blur" }],
    phone: [{ required: true, message: "联系电话不能为空", trigger: "blur" }],
    address: [{ required: true, message: "地址不能为空", trigger: "blur" }],
    username: [{ required: true, message: "联系人不能为空", trigger: "blur" }],
    userPhone: [
      { required: true, message: "联系人电话不能为空", trigger: "blur" },
    ],
    userAddress: [
      { required: true, message: "邮寄地址不能为空", trigger: "blur" },
    ],
  },
});

const { queryParams, form, rules } = toRefs(data);

/** 查询列表 */
function getList() {
  postList.value = [
    {
      is_collect: true,
      id: "Q7K1Jx6VYodq",
      mode: 1,
      title: "测试6",
      description: "",
      image: "",
      file: "",
      maturity: 1,
      lead_standard: 0,
      cooperation_mode: 101,
      config: "",
      introduce: "",
      shelf_status: 0,
      status: 0,
      created_at: "0001-01-01T00:00:00Z",
      updated_at: "0001-01-01T00:00:00Z",
      research_name: "",
      visit_count: 0,
      collect_count: 0,
      mode_title: "免费模式",
      maturity_title: "正在研发",
      cooperation_mode_title: "技术转让",
      customers: ["关键词1", "关键词2"],
      industrys: ["农、林、牧、渔业/农业", "采矿业/煤炭开采和洗选业", "制造业"],
      keywords: ["关键词1", "关键词2"],
    },
    {
      is_collect: false,
      id: "gympJE5JrLxe",
      mode: 1,
      title: "测试5",
      description: "",
      image: "",
      file: "",
      maturity: 1,
      lead_standard: 0,
      cooperation_mode: 101,
      config: "",
      introduce: "",
      shelf_status: 0,
      status: 0,
      created_at: "0001-01-01T00:00:00Z",
      updated_at: "0001-01-01T00:00:00Z",
      research_name: "",
      visit_count: 0,
      collect_count: 0,
      mode_title: "免费模式",
      maturity_title: "正在研发",
      cooperation_mode_title: "技术转让",
      customers: ["关键词1", "关键词2"],
      industrys: ["农、林、牧、渔业/农业", "采矿业/煤炭开采和洗选业", "制造业"],
      keywords: ["关键词1", "关键词2"],
    },
  ];
  total.value = 15;
  loading.value = false;
  // loading.value = true;
  // listPost(queryParams.value).then(
  //   (response) => {
  //     postList.value = response.rows;
  //     total.value = response.total;
  //     loading.value = false;
  //   }
  // );
}
/** 搜索按钮操作 */
function handleQuery() {
  queryParams.value.pageNum = 1;
  getList();
}
/** 删除按钮操作 */
function handleDelete(id) {
  proxy.$modal
    .confirm('是否确认删除订单号为"' + id + '"的数据项？')
    .then(function () {
      return delPost(postIds);
    })
    .then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    })
    .catch(() => {});
}
function handleResults(id) {
  router.push({ path: "./results" });
}
getList();
</script>
<style lang="scss" scoped>
.btn_info {
  height: 35px;
  line-height: 35px;
  text-align: center;
  color: #fff;
  background-color: #787878;
}
</style>
