<template>
  <div>
    <div style="margin:40px;">
      <vue-gic-store-new class="inline-block" ref="storeNew" :options="options" :uuid.sync="uuid" :isAdd="isAdd"></vue-gic-store-new>
      <el-button @click="isSaveFun" type="primary">检查是否保存</el-button> {{isSave}}
      <el-button @click="getStoreConfig" type="primary">获取保存的数据</el-button> {{storeConfig}}
    </div>
    <el-switch v-model="editFlag"></el-switch>新增的
     <!--
    <div style="margin:40px;" v-if="editFlag">
      <vue-gic-store-new class="inline-block" ref="storeNew" :options="options"></vue-gic-store-new>
      <el-button @click="isSaveFun" type="primary">检查是否保存</el-button> {{isSave}}
      <el-button @click="getStoreConfig" type="primary">获取保存的数据</el-button> {{storeConfig}}
    </div> -->
    <!-- <div style="margin:40px;">
      <vue-gic-store-card ref="storeCard" :uuid.sync="uuid"></vue-gic-store-card>
      <el-button style="margin:10px;" @click="isStoreEmpty" type="primary">检查是否为空</el-button> {{isEmpty}}
    </div> -->
  </div>
</template>
<script>
import gicStoreNew from '../component/dmStore/index.vue'
import gicStoreCard from '../component/dmStore/store-card.vue'
  export default {
    components:{
      'vue-gic-store-new':gicStoreNew,
      'vue-gic-store-card':gicStoreCard

    },
    data() {
      return {
        // 参数
        // uuid:'1112ccc0e35911e8aaf8672621cbd111',  // 新增传空，编辑必传,
        uuid:'d7cf5ec1f49b11e8afb72f9b46e04729',  // 新增传空，编辑必传,
        // 需要的下拉 默认为全部[0,1,2,3,4,5]
        // 0 全部 1 门店类型 2门店标签 3 门店区域 4 门店分组 5 部分门店
        options:[0,1,2,3,4,5],
        isAdd:false,
        isSave:false,
        isEmpty:0,
        storeConfig:{},
        editFlag:false
      }
    },
    watch:{
      uuid(val) {
        console.log('uuidchange=>'+val)
      }
    },
    mounted() {
      // setTimeout(_ => {
        // this.uuid = '171b3f01f38d11e89acab39639a83083';
        // this.$refs.storeCard.init();
      // },1000)
    },
    methods:{
      isSaveFun() {
        this.$refs.storeNew.isStoreSave().then(res => {
          this.$tips({type:'warning',message:res?'已保存':'未保存'});
          this.isSave = res;
        })
      },
      getStoreConfig() {
        this.$refs.storeNew.getStoreConfig().then(data => {
          this.storeConfig = data;
        })
      },
      isStoreEmpty() {
          console.log(this.uuid)
          this.$refs.storeCard.getRightList().then(res => {
          this.$tips({type:'warning',message:res.length?'有数据':'没有数据'});
          console.log(res)
          this.isEmpty = res.length;
        })
      }
    }
  };
</script>



