<template>
  <div class="dm-qywx__item__wrap">
    <div class="fz16">
      {{ qfxx.qfxxEnterpriseName }}
      <span style="margin-left: 16px">{{ item.qfxx.consumerStoreType ? '按门店条件' : '固定门店' }}</span>
    </div>
    <div class="divider"></div>
    <div>{{ item.title }}</div>
    <div style="margin-top:12px;color:#606266;white-space:pre-wrap;word-break:break-word">{{ qfxx.remark }}</div>
    <p style="margin-top:12px;color:#606266">
      <span>群发内容：</span>
      <span v-for="(el, index) in materials" :key="el">
        <template v-if="index !== 0"> / </template>
        <span v-html="el"></span>
      </span>
    </p>
    <p v-if="item.qfxx.failSetting == 1" style="margin-top:12px;color:#606266">
      <span>群发失败设置：</span>
      <span v-if="item.qfxx.telFlag">话务</span><span v-if="item.qfxx.smsFlag && item.qfxx.telFlag"> / </span>
      <span v-if="item.qfxx.smsFlag">
        短信
        <template v-if="item.qfxx.gicSmsTemplateId == -1"> ( {{ item.qfxx.smsTitle }} - 短信模板已删除 ) </template>
      </span>
    </p>
  </div>
</template>

<script>
export default {
  name: 'item-qfxx',
  props: {
    item: {
      type: Object,
      default() {
        return {};
      }
    }
  },
  computed: {
    qfxx() {
      return this.item.qfxx || {};
    },
    materials() {
      let mapName = {
        1: '文本',
        2: '图片',
        3: '网页',
        4: '视频',
        5: '文件',
        6: '小程序'
      };
      let res = JSON.parse(this.item.qfxx.chatContent || '[]');
      const items = res.filter(el => el.statusFlag == 0);
      return [...new Set(res.map(el => el.type))].map(el => {
        if (items.length > 0 && items.some(item => item.type == el)) {
          return `${mapName[el]} (<span style="color:#F56C6C">已失效</span>)`;
        } else {
          return mapName[el];
        }
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.divider {
  margin-top: 12px;
  margin-bottom: 18px;
  height: 1px;
  background-color: #dcdfe6;
}
/deep/ .el-checkbox {
  margin: 0;
  margin-right: 20px;
}
</style>
