index.vue 5.64 KB
<template>
  <div class="app-container">
    <el-row>
      <el-input v-model="keyword"
                placeholder="输入关键词搜索(名称/描述/受众组ID)"
                clearable
                size="small"
                prefix-icon="el-icon-search"
                style="margin-bottom: 20px;width: 300px;" />
      <el-button type="primary"
                 size="small"
                 @click="search"
                 v-hasPermi="['system:user:add']">
        查询
      </el-button>
    </el-row>
    <el-table v-loading="loading"
              :data="userList"
              border>
      <el-table-column label="受众组ID"
                       align="center"
                       prop="dmpId" />
      <el-table-column label="更新日期"
                       align="center"
                       prop="updateTime" />
      <el-table-column label="活跃用户数"
                       align="center"
                       prop="audienceNum" />
      <el-table-column label="状态"
                       align="center">
        <template slot-scope="scope">
          {{ scope.row.status && scope.row.status.value }}
        </template>
      </el-table-column>
      <el-table-column label="提交时间"
                       align="center"
                       prop="submitTime"
                       width="120">
      </el-table-column>
      <el-table-column label="客户名称"
                       align="center"
                       prop="customerName"
                       width="120" />
      <el-table-column label="人群包名称"
                       align="center"
                       prop="audienceName"
                       width="120" />
      <!-- <el-table-column label="人群包描述"
                       align="center"
                       prop="remark"
                       width="120" /> -->
      <el-table-column label="系统类型"
                       align="center"
                       prop="platform"
                       width="120">
        <template slot-scope="scope">
          {{ scope.row.platform && scope.row.platform.value }}
        </template>
      </el-table-column>
      <el-table-column label="人群包类型"
                       align="center"
                       prop="type"
                       width="120">
        <template slot-scope="scope">
          {{ scope.row.type && scope.row.type.value }}
        </template>
      </el-table-column>
      <el-table-column label="操作"
                       align="center"
                       width="180"
                       class-name="small-padding fixed-width opt-wrap">
        <template slot-scope="scope">
                     <!-- v-hasPermi="['system:user:remove']" -->
          <el-button size="mini"
                     type="text"
                     @click="clickDetail(scope.row)">查看详情</el-button>
          <el-button size="mini"
                     type="text"
                     :disabled="scope.row.status && (scope.row.status.code === 'IN_FORCE' || scope.row.status.code === 'CUSTOMIZE_ERROR')"
                     @click="clickDefine(scope.row)">确认人群</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total>0"
                :total="total"
                :page.sync="current"
                :limit.sync="size"
                @pagination="search" />
    <define :show.sync="showDefine"
            :item="item"
            :aid="aid"
            @success="search"></define>
    <detail :show.sync="showDetail"
            :item="item"></detail>
  </div>
</template>

<script>
import { queryCustomApi, queryDetailApi } from "@/api/audience/featured";
import Define from "./define";
import Detail from "./detail";
export default {
  components: { Define, Detail },
  data() {
    return {
      current: 1,
      size: 10,
      activeName: "featured",
      // 遮罩层
      loading: false,
      userList: [],
      keyword: "",
      total: 0,
      showDel: false,
      selectedItem: {},
      showDefine: false,
      showDetail: false,
      item: undefined,
      aid: undefined
    };
  },
  methods: {
    handleDelete(item) {
      this.showDel = true;
      this.selectedItem = item;
    },
    search() {
      let params = {
        current: this.current,
        size: this.size,
        param: this.keyword
      };
      queryCustomApi(params).then(
        res => {
          let { code, message, data } = res;
          if (code === 200) {
            this.userList = data.records;
            this.total = data.total;
          } else {
            this.$message({
              type: "error",
              message
            });
          }
        },
        error => {
          this.$message({
            type: "error",
            message: error.message
          });
        }
      );
    },
    clickDetail(item) {
      this.showDetail = true;
      this.queryDetail(item.audienceId);
    },
    clickDefine(item) {
      this.showDefine = true;
      this.aid = item.audienceId;
      this.queryDetail(item.audienceId);
    },
    queryDetail(aid) {
      if (!aid) {
        this.$message({
          type: "warning",
          message: "ID为空"
        });
        return;
      }
      queryDetailApi({ audienceId: aid }).then(res => {
        let { code, message, data } = res;
        if (code === 200) {
          this.item = data;
        } else {
          this.$message({
            type: "error",
            message
          });
        }
      });
    }
  },
  watch: {},
  created() {
    this.search();
  }
};
</script>

<style lang="scss">
.opt-wrap {
  .el-button--mini {
    &.is-disabled {
      color: #C0C4CC
    }
  }
}
</style>