<template>
  <div class="content">
       <Tabs type="card">
        <TabPane label="放松"></TabPane>
        <TabPane label="常规"></TabPane>
    </Tabs>
    <div class="topSearch">
      <div class="left">
        <Input style="width:280px" search enter-button placeholder="" @on-search='search'/>
         <span class="lable">
              场景
            </span>
             <Select clearable  v-model="model1" style="width:90px" :filterable='true'>
              <Option
                v-for="item in $store.state.app.sceneObj.scenes"
                :value="item.id"
                :key="item.id"
                >{{ item.name }}</Option
              >
            </Select>
             <span class="lable">
              主题
            </span>
             <Select clearable  v-model="model1" style="width:90px" :filterable='true'>
              <Option
                v-for="item in $store.state.app.sceneObj.themes"
                :value="item.id"
                :key="item.id"
                >{{ item.name }}</Option
              >
            </Select>
             <span class="lable">
              栏目
            </span>
             <Select clearable  v-model="model1" style="width:90px" :filterable='true'>
              <Option
                v-for="item in $store.state.app.categoryObj.categories"
                :value="item.id"
                :key="item.id"
                >{{ item.name }}</Option
              >
            </Select>
             <span class="lable">
              条目
            </span>
             <Select clearable  v-model="model1" style="width:90px" :filterable='true' >
              <Option
                v-for="item in $store.state.app.categoryObj.courses"
                :value="item.id"
                :key="item.id"
                >{{ item.name }}</Option
              >
            </Select>
      </div>
      <div class="right">
        <Button @click="add" type="primary">新增</Button>
        <Button type="error" @click="del">删除</Button>
      </div>
    </div>
     <Stable :data='data' @edit='edit' @select='select'/>
     <Forms :visible.sync="visible" :search='search' :row='row'/>
  </div>
</template>

<script>
import Stable from './table.vue'
import Forms from './form.vue'
import {
  getShop,
  delShop
} from '@/api/shop'
export default {
  name: 'goods',
  components: {
    Stable,
    Forms
  },
  data () {
    return {
      model1: null,
      selectList: [],
      visible: false,
      draggableVisible: false,
      row: {},
      data: []
    }
  },
  methods: {
    edit (row) {
      this.visible = true
      this.row = row
    },
    add () {
      this.visible = true
      this.row = {
        id: 'add'
      }
    },
    select (val) {
      this.selectList = val
    },
    del () {
      delShop(this.selectList).then((res) => {
        if (res.code === 200) {
          this.$Message.success('删除成功')
          this.search()
        } else {
          this.$Message.error('删除失败')
        }
      })
    },
    search (p) {
      getShop(p).then((res) => {
        this.data = res.data
      })
    }
  },
  mounted () {
    this.search({})
  }
}
</script>

<style lang="less"></style>
