<template>
  <div>
    <GenericManager
      :uri="resource_uri"
      :visible_fields="['id', 'name', 'description', 'article__title', 'template_asset__filename']"
      :editable_fields="['name', 'description', 'article', 'template_asset']"
      no_details=1
      object_name="产品"
      :actions="actions"
      show_search=1
      ref="gm"
    />
  </div>
</template>

<script>
export default {
  name: 'Products',
  props: [],
  components: {
  },
  data: function () {
    return {
      products: [],
      resource_uri: "/api/v1/product/",
      actions: [
        {
          name: '',
          handler: this.handle_preview,
          icon: 'eye',
          title: '预览页面',
        },
        {
          name: '',
          icon: 'book',
          handler: this.handle_manage_properties,
        },
      ],
    };
  },
  computed: {
  },
  methods: {
    handle_preview: function(item) {
      window.open('/api/article/?id=' + item.article__id, '_blank');
    },
    handle_manage_properties(item) {
      console.log("handle manage properties", item);
      this.$router.push("/product-properties/" + item.id + "/");
    },
  },
  mounted() {
  },
}
</script>

<style scoped>
</style>

