<template>
  <el-dialog title="提示" width="520px" top="30vh" custom-class="cre-dialog" :modal-append-to-body="false" :visible.sync="dialogVisible" :before-close="close">
    <div v-loading="loading" class="flex">
      <div class="el-message-box__status el-icon-warning position-ab"></div>
      <div class="batch-content">
        <p class="batch-txt">{{ tips }}</p>
        <ul class="batch-ul">
          <li v-for="item in list" :key="item.id" class="batch-li" @click="handleClickItem(item)">
            <span class="relationName"> {{ item.busiObjRelationType | activeType }}--{{ item.busiObjRelationName }}</span>
            <span class="relationCreater">{{ item.busiObjRelationCreater }}</span>
          </li>
        </ul>
      </div>
    </div>
    <!-- <span class="footer" slot="footer">
      <el-button type="primary" @click="close">关闭</el-button>
    </span> -->
  </el-dialog>
</template>

<script>
const routeMap = {
  //1, "短信群发"2, "智能营销"3, "ai营销"4, "导入群发"5, "扫码营销"
  1: '/message/record', //活动名maxlength10
  2: '/ecm/list', //活动名maxlength30
  3: '/ai/list', //活动名maxlength30
  4: '/message/import-send', //活动名maxlength10
  5: '/scan/list' //活动名maxlength9
};
export default {
  props: {
    dialogVisible: {
      type: Boolean,
      default: false
    },
    tips: {
      type: String,
      default: '当前短信模板已被以下活动引用，删除后引用该模板的活动短信将无法发送，慎重操作！如需删除模板，需要先暂停引用活动，才可删除'
    },
    list: {
      type: Array,
      default: () => []
    },
    loading: false
  },
  filters: {
    activeType(val) {
      const obj = {
        1: '短信群发',
        2: '智能营销',
        3: 'AI营销',
        4: '导入群发',
        5: '扫码营销'
      };
      return obj[val];
    }
  },
  methods: {
    close() {
      this.$emit('update:dialogVisible', false);
    },
    handleClickItem(item) {
      if (item.permissionFlag) {
        this.localtionChange(item);
      } else {
        this.$message.warning('当前活动无权限查看，请联系创建人修改活动状态');
      }
    },
    localtionChange(item) {
      const path = routeMap[item.busiObjRelationType];
      this.$router.push(`${path}`);
    }
  }
};
</script>

<style lang="scss" scoped>
.cre-dialog {
  .position-ab {
    top: 95px;
  }
  .batch-content {
    margin-left: 38px;
    .batch-txt {
      font-size: 14px;
      color: #303133;
      line-height: 20px;
    }
    .batch-ul {
      margin-top: 16px;
      li {
        display: flex;
        justify-content: flex-start;
        margin-bottom: 10px;
      }
      .relationName,
      .relationCreater {
        font-size: 14px;
        color: #303133;
        line-height: 20px;
        text-align: left;
      }
      .relationName {
        width: 288px;
        color: #2f54eb;
        cursor: pointer;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
      .relationCreater {
        margin-left: 10px;
        width: 145px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }
    }
  }
  .footer {
    display: flex;
    justify-content: center;
  }
}
</style>
