<template>
  <div v-loading="loading">
    <el-form class="search" label-width="90px" inline>
      <el-row>
        <el-col :span="24">
          <el-form-item>
            <el-button size="small" @click="show_child_page('admin_category_add',{})" type="primary">添加标签</el-button>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <el-table
      :data="list"
      style="width: 100%">
      <el-table-column prop="name" label="标签名称"></el-table-column>
      <el-table-column prop="sub_title" label="副标题"></el-table-column>
      <el-table-column prop="order" label="排序"></el-table-column>
      <el-table-column fixed="right" width="100px" prop="act" label="操作">
        <template  slot-scope="scope">
          <el-button type="primary"  size="mini" @click="show_child_page('admin_category_add',{id:scope.row.id})">编辑标签</el-button>
        </template>
      </el-table-column>
    </el-table>

    <el-pagination
      background
      style="margin-top: 10px"
      layout="total,prev, pager, next"
      :current-page="search.page"
      @current-change="page_event"
      :page-size="search.pagesize"
      :total="search.total">
    </el-pagination>

    <admin_category_add v-if="child_page.type=='admin_category_add'" :point="value" v-model="child_page.obj.id" :back="this"></admin_category_add>
  </div>
</template>

<script>
  import admin_category_add from '@/components/child_page/admin_category_add';
  export default {
    props: {
      value: {},
    },
    components: {admin_category_add},
    data() {
      return {
        loading:true,
        list: [],
        child_page:{
          type:"",
          obj:{}
        },
        search:{
          pagesize: 20,
        },
      }
    },
    mounted() {
      this.getList();
    },
    methods: {
      show_child_page(type,obj)
      {
        this.child_page.type=type;
        this.child_page.obj=obj;
      },
      page_event(page) {
        this.search.page = page;
        this.getList();
      },
      async getList() {
        this.loading = true;
        let data=this.search;
        data.point=this.value-20;
        let res = await this.$post("/uapi/admin/pub/admin_category/list",data);
        if (res.status == 1) {
          this.list = res.data.list;
          this.search.total=res.data.total;
        }
        this.loading = false;
      },
    }
  }
</script>
