<template>
  <div class="list_container">
    <el-breadcrumb separator="/" class="bread_crumb">
      <el-breadcrumb-item>我的服务</el-breadcrumb-item>
      <el-breadcrumb-item>{{ $route.params.name }}</el-breadcrumb-item>
    </el-breadcrumb>
    <div class="table_container">
      <ces-table
        class="r_yhgl_table"
        size="mini"
        :border="false"
        :headers="headers"
        url="tableData"
        :searchShow="true"
        :autoAdd="false"
        :isDialog="true"
        :confirmOptions="confirmOptions"
        detailsUrl="/fwgl/servicedetail/"
        @primary-edit="editItem"
        @sold-out="soldOutItem"
        :emptyText="emptyText"
        :stripe="true"
        :pageSizeShow="true"
        :filterList="filterList"
      ></ces-table>
    </div>
  </div>
</template>

<script>
import cesTable from "@/components/table-um";
export default {
  data: () => ({
    headers: [],
    url: "",
    detailsUrl: "ss/",
    confirmOptions: {
      title: "提示", //提示
      message: "确认删除该条数据？", //""
      btnCancelText: "取消", //取消
      btnSubmitText: "确定", //确定
    },
    emptyText: "暂时没数据",
    filterList: [
      {
        name: "服务类型",
        prop: "fwlx",
        data: ["数据服务", "时空服务", "视频服务", "感知服务", "综合服务"],
      },
      {
        name: "服务领域",
        prop: "fwly",
        data: [
          "数据服务",
          "时空服务",
          "视频服务",
          "感知服务",
          "综合服务",
          "数据服务2",
          "时空服务2",
          "视频服务2",
          "感知服务2",
          "综合服务2",
          "感知服务3",
          "综合服务3",
        ],
      },
      {
        name: "开放程度",
        prop: "kfcd",
        data: ["数据服务", "时空服务", "视频服务", "感知服务", "综合服务"],
      },
      {
        name: "服务状态",
        prop: "fwzt",
        data: ["数据服务", "时空服务", "视频服务", "感知服务", "综合服务"],
      },
    ],
  }),
  components: {
    cesTable,
  },
  methods: {
    editItem(item) {
      this.$router.push("/fwgl/serviceedit/" + item.id);
    },
    soldOutItem(item) {
      console.log(item);
    },
  },
  mounted() {
    this.headers = [];

    this.headers.push(
      { label: "服务名称", prop: "name", type: "href", align: "left" },
      { label: "服务url", prop: "date", type: "href", align: "center" },
      { label: "开放程度", prop: "address", type: "href", align: "center" },
      { label: "服务描述", prop: "address", type: "href", align: "left" },
      { label: "注册发布时间", prop: "address", type: "href", align: "center" },
      { label: "服务类型", prop: "address", type: "href", align: "center" }
    );

    switch (parseInt(this.$route.params.type)) {
      case 0:
        this.headers.push({
          label: "操作",
          type: "Button",
          align: "center",
          width: 240,
          btnList: [
            {
              type: "primary-edit",
              label: "编辑",
              line: "|",
            },
            {
              type: "sold-out",
              label: "申请下架",
              line: "|",
            },
            {
              type: "primary-del",
              label: "删除",
            },
          ],
        });
        break;
      case 1:
        this.headers.push(
          { label: "申请状态", prop: "address", type: "href", align: "center" },
          {
            label: "操作",
            type: "Button",
            align: "center",
            width: 160,
            btnList: [
              {
                type: "sold-out",
                label: "取消",
                line: "|",
              },
              {
                type: "primary-del",
                label: "删除",
              },
            ],
          }
        );
        break;
      case 2:
        this.headers.push(
          { label: "审批时间", prop: "address", type: "href", align: "center" },
          { label: "审批状态", prop: "address", type: "href", align: "center" },
          {
            label: "操作",
            type: "Button",
            align: "center",
            width: 160,
            btnList: [
              {
                type: "sold-out",
                label: "审批",
                line: "|",
              },
              {
                type: "primary-del",
                label: "删除",
              },
            ],
          }
        );
        break;
    }
  },
};
</script>

<style scoped>
.bread_crumb {
  margin: 20px;
  font-size: 14px;
}
.table_container {
  height: calc(100% - 75px);
  padding: 15px 20px;
  margin: 0 20px;
  border-radius: 10px;
  overflow: hidden;
  background-color: #fff;
}
.table_container .ces-table-page {
  margin-top: 42px;
}
</style>
