<template>
  <div>
    <el-alert
      title="提示：以下为历史数据，不生效，需要在上架规则中配置完成才能生效"
      type="info"
      :closable="false"
      show-icon
    />
    <el-form
      ref="form"
      :model="giftForm"
      label-position="right"
      style="margin-top: 20px"
      label-width="80px"
    >
      <el-form-item
        label="展现门店"
        style="position:relative"
      >
        <el-tooltip
          class="tips-content"
          effect="dark"
          popper-class="store-tips"
          placement="top-start"
        >
          <div slot="content" style="line-height:18px">
            会员的门店(常规设置)满足展示门店设置，则在礼品/优惠券列表可见
          </div>
          <i class="iconfont icon-QuestionCircleOutlined" />
        </el-tooltip>
        <vue-gic-store-linkage
          v-if="giftForm.useNewStoreWidget === 0 &&giftForm.creatorId "
          style="margin-left:10px"
          :creatorId="giftForm.creatorId"
          :disabled="true"
          :openFlag="giftForm.openFlag"
          @getDisGroupList="getDisGroupList"
          :msg="giftForm.sendChildData"
          ref="selectTree"
        />
        <span v-if="giftForm.useNewStoreWidget === 0&&giftForm.sendChildData.storeType === 1" class="store-tip" style="display: contents;">若选中的父分组下有新增的门店分组，系统不会默认选中此新增门店分组，请重新确认选择并保存礼品</span>
        <vue-gic-store-card
          v-show="giftForm.useNewStoreWidget === 1"
          style="margin-left:10px"
          class="pt10"
          ref="storeCard"
          :readonly="true"
          :uuid.sync="giftForm.uuid"
          scenes
        />
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  props: {
    form: Object,
  },
  data () {
    return {
      giftForm: {
        useNewStoreWidget: 1,
        openFlag: false,
        creatorId: '',
        sendChildData: { // 公共组件的值
          storeType: 1,
          storeGroupIds: '',
          storeIds: [],
        },
        uuid: '',
      }, // 表单的值
    };
  },
  watch: {
    form: {
      handler (val) {
        this.giftForm = JSON.parse(JSON.stringify(val));
        if (this.giftForm.useNewStoreWidget == 1) {
          this.$nextTick(_ => {
            this.$refs.storeCard && this.$refs.storeCard.init();
          });
        }
      },
      immediate: true,
    },
  },
};
</script>
