messageModel.vue 5.07 KB
<template>
  <div class="square-main">
    <el-dialog
      title="选择模板"
      :visible.sync="dialogVisible"
      width="70%"
      :before-close="handleClose"
    >
      <div class="model-panel">
        <div class="model-panel-tab">
          <label>模板类型:</label>
          <el-tabs v-model="activeName" @tab-click="handleClick" type="card">
            <el-tab-pane label="售前" name="1"></el-tab-pane>
            <el-tab-pane label="售中" name="2"></el-tab-pane>
            <el-tab-pane label="售后" name="3"></el-tab-pane>
          </el-tabs>
        </div>
        <div class="model-item-panel" v-if="modelList.length>0" v-loading="loading">
          <div class="model-item" v-for="(item, index) in modelList" :key="index">
            <div class="model-item-radio">
              <el-radio v-model="messageRadio" :label="item"></el-radio>
            </div>
            <div class="model-item-title">
              <div class="model-title-h1">{{ item.title }}</div>
              <div class="model-title-h2">{{ item.content }}</div>
            </div>
            <div class="model-item-content">
              <div class="model-content">创建人:巴拉巴拉</div>
              <div class="model-content">创建日期:{{ item.createdTime }}</div>
            </div>
          </div>
        </div>
        <div class="model-item-panel"  v-else v-loading="loading">
          <img src="@/assets/img/empty.png" />
          <div class="empty-item">暂无数据</div>
        </div>
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="pageNum"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="pageSize"
          :total="tableTotal"
          layout="total, sizes, prev, pager, next, jumper"
        ></el-pagination>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button size="small" @click="dialogVisible = false">取 消</el-button>
        <el-button size="small" type="primary" @click="selectModelItem">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "activityModel",
  data() {
    return {
      dialogVisible: false,
      loading: false,
      activeName: "1",
      messageRadio: {},
      modelList: [],
      pageNum: 1,
      pageSize: 10,
      tableTotal: 0,
    };
  },
  methods: {
    init() {
      this.messageRadio = {};
      this.dialogVisible = true;
      this.dracImMessage();
    },
    selectModelItem() {
      this.dialogVisible = false;
      this.$emit("selectItem", this.messageRadio);
    },
    handleClick() {
      this.dracImMessage();
    },
    dracImMessage() {
      this.loading = true;
      let params = {
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        type: this.activeName,
      };
      this.$apis.marketing.dracImMessage(params).then((res) => {
        console.log(res);
        this.modelList = res.data;
        this.tableTotal = res.count;
        this.loading = false;
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
  },
};
</script> 

<style lang="scss" scoped>
.model-panel {
  .model-panel-tab {
    display: flex;
    align-items: center;
    margin-bottom: 18px;
    label {
      font-size: 16px;
      font-weight: 400;
      color: #000000;
      line-height: 24px;
    }
    /deep/ {
      .el-checkbox:last-of-type {
        margin-right: 8px;
      }
      .el-tabs__nav {
        border: 0;
      }
      .el-tabs__header {
        border: 0;
        background-color: #f4f6fc;
        margin: 0px;
      }
      .el-tabs__item {
        border: none;
        width: 180px;
        height: 32px;
        line-height: 32px;
        margin: 2px;
        text-align: center;
      }
      .el-tabs__item.is-active {
        background-color: #fff;
        border-radius: 4px;
      }
    }
  }
  .model-item-panel {
    > img {
      display: block;
      margin: 50px auto 0px;
      width: 60px;
      height: auto;
    }
    .empty-item {
      text-align: center;
      font-size: 14px;
      font-weight: 400;
      color: #000000;
      line-height: 22px;
      margin-bottom: 30px;
    }
    .model-item {
      display: flex;
      padding: 20px;
      border-bottom: 1px solid #e9e9e9;
      &-radio {
        width: 80px;
        /deep/ {
          .el-radio__input {
            margin-top: 10px;
          }
          .el-radio__label {
            display: none;
          }
        }
      }
      &-content {
        width: 210px;
        .model-content {
          font-size: 14px;
          font-weight: 400;
          color: #999999;
          line-height: 20px;
        }
      }
      &-title {
        flex: 1;
        .model-title-h1 {
          font-size: 14px;
          font-weight: 400;
          color: #333333;
          line-height: 20px;
        }
        .model-title-h2 {
          font-size: 14px;
          font-weight: 400;
          color: #999999;
          line-height: 20px;
        }
      }
    }
  }
}
</style>