crowdDetail.vue 9.95 KB
<template>
  <div class="scrm-sub-client-container">
    <div class="container">
      <div>
        <div class="title">人群详情</div>
        <div class="info-box gl-form-page">
          <el-form class="create-form" :model="crowdForm" :rules="crowdRules">
            <div class="el-form-line">
              <el-form-item label="人群名称:" prop="crowdName" class="label-word">
                <div class="color-3">{{ crowdForm.crowdName }}</div>
              </el-form-item>
            </div>
            <div class="el-form-line">
              <el-form-item label="人群描述:" prop="groupNameRule" class="label-word">
                <div class="color-3">{{ crowdForm.crowdDesc }}</div>
              </el-form-item>
            </div>
            <div class="el-form-line">
              <el-form-item label="标签筛选:" prop="groupNameRule" class="label-word">
                <div class="flex">
                  <div class="font-14 color-58 mr2 hand" @click="open('dialogRuleVisible')">人群规则说明</div>
                  <div class="font-14 color-58 hand" @click="open('dialogLogicVisible')">人群规则逻辑</div>
                </div>
              </el-form-item>
            </div>
            <div class="el-form-line">
              <el-form-item label="已选标签:" prop="groupNameRule" class="label-word">
                <div class="pageContent" style="display: flex;">
                  <GLTable :tableData="selectedArray" :hasNum="hasNum" :hasPage="hasPage" :tableParams="tableParams" :headerStyle="{ height: '54px', background: '#F4F6FC', color: '#333333', fontSize: '14px' }">
                    <span slot="labelUnitList" slot-scope="scope">
                      <div class="allTagsWrap flex">
                        <template v-for="(item, index) in scope.scope.labelUnitList">
                          <span :class="['label', 'color-6', 'white-hide', 'mt10']" :key="index">
                            {{ item.labelName }}
                          </span>
                        </template>
                      </div>
                    </span>
                  </GLTable>
                </div>
              </el-form-item>
            </div>
          </el-form>
        </div>
      </div>
    </div>
    <GLDialog title="人群规则说明" :visible.sync="dialogRuleVisible" :hasFooter="false">
      <div class="crowd-dialog-wrap color-3">
        <div class="condition font-14">
          <b>说明:</b>
          <br />
          <span>
            标签组内已选标签取
            <b>并集(或)</b>
            ,即满足一个条件即可、标签组之间取
            <b>交集(且)</b>
            ,即同时满足标签组条件。
          </span>
        </div>
        <div class="flex-between">
          <div class="static-image">
            <img src="@/assets/crowdManage/sum.png" alt="" />
          </div>
          <div class="static-image">
            <img src="@/assets/crowdManage/intersection.png" alt="" />
          </div>
        </div>
      </div>
    </GLDialog>
    <GLDialog title="人群规则逻辑" class="crowd-logic-dialog" :visible.sync="dialogLogicVisible" :hasFooter="false">
      <div class="crowd-logic-dialog-wrap">
        <div :class="{ 'crowd-flex': true }" v-if="this.selectedArray.length > 1">
          <div class="crowd-line" id="lineHeight"></div>
          <div class="moreover">且</div>
          <div class="crowd-line" id="lineHeight2"></div>
        </div>
        <div class="crowd-logic-wrap" id="crowd-logic-wrap" :style="{ 'margin-left': this.selectedArray.length > 1 ? '20px' : '55px' }">
          <div class="crowd-logic-labels" v-for="(logicTag, index) in this.selectedArray" :key="index">
            <div class="crowd-logic-label-group-name font-14 color-3">{{ logicTag.groupName }}:</div>
            <div class="flex">
              <template v-for="(tag, id) in logicTag.labelUnitList">
                <div class="crowd-logic-tag color-6 font-14" :key="id">{{ tag.labelName }}</div>
                <template v-if="id < logicTag.labelUnitList.length - 1">
                  <div class="color-3 perhaps" :key="id">或</div>
                </template>
              </template>
            </div>
          </div>
        </div>
      </div>
    </GLDialog>
  </div>
</template>

<script>
export default {
  name: 'crowdDetail',
  data() {
    return {
      crowdForm: {
        crowdName: '',
        crowdDesc: ''
      },
      crowdId: this.$route.params.id ? this.$route.params.id : '',
      crowdPage: this.$route.query.crowdType ? this.$route.query.crowdType : '',
      tableTotal: '',
      isShowCloseBtn: true,
      dialogRuleVisible: false,
      dialogLogicVisible: false,
      tableData: [],
      hasPage: false,
      hasNum: true,
      page: {},
      tableParams: {
        tableColumns: [
          {
            label: '标签组',
            prop: 'groupName',
            width: 230,
            align: 'left'
          },
          {
            label: '标签组类型',
            prop: 'groupType',
            width: 220,
            formatter: cellValue => {
              return cellValue.groupType == '企业标签' && this.$globalState.session.merchantModel == 1 ? '集团标签' : cellValue.groupType
            },
            align: 'left'
          },
          {
            label: '标签',
            prop: 'labelUnitList',
            addHtml: 'labelUnitList',
            align: 'left'
          }
        ]
      },
      crowdRules: {
        crowdName: [{ required: true }]
      },
      selectedArray: []
    }
  },
  created() {
    // 通过人群Id查询人群详情
    this.getCrowdDetails()
  },
  mounted() {

  },
  methods: {
    goBack() {
      this.$router.push({
        path: '/crowdManage/index',
        query: {
          selectTab: this.crowdPage
        }
      })
    },
    //获取标签数据
    getCrowdDetails() {
      let params = {
        'req.crowdId': this.crowdId
      }
      this.$apis.crowdManage.getCrowdDetails(params).then(res => {

        if (res.code == 0) {
          this.crowdForm.crowdName = res.data.crowdName
          this.crowdForm.crowdDesc = res.data.crowdDesc

          this.selectedArray = res.data.tagCombine ? JSON.parse(res.data.tagCombine) : []
        }
      })
    },
    handleClose() {
      this.dialogRuleVisible = false
      this.dialogLogicVisible = false
    },
    open(value) {
      this[value] = true
      if (this.dialogLogicVisible == true && this.selectedArray.length > 1) {
        this.$nextTick(() => {
          let height = document.getElementById('crowd-logic-wrap').offsetHeight
          if (height >= 650) {
            document.getElementById('lineHeight').style.height = 308 + 'px'
            document.getElementById('lineHeight2').style.height = 308 + 'px'
            this.logicFix = true
          } else {
            let lineHeight = (height - 35) / 2
            document.getElementById('lineHeight').style.height = lineHeight + 'px'
            document.getElementById('lineHeight2').style.height = lineHeight + 'px'
          }
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
/deep/.glsx-table{
  width: 100%;
}
.container {
  background: #ffffff;

  height: calc(100vh - 164px);
  overflow-y: auto;
  // padding: 20px;

  .title {
    padding: 20px 0 17px 20px;
    font-size: 16px;
    color: #333;
    font-weight: 600;
    border-bottom: 1px solid #d8d8d8;
    &::after {
      content: '';
    }
  }
  .info-box {
    width: 100%;
    padding: 30px 0;
    box-sizing: border-box;
    .create-form {
      width: 100%;
      box-sizing: border-box;
      padding: 0 30px;
    }
    .el-form-line {
      margin-bottom: 20px;
      .label-word {
        /deep/ .el-form-item__content {
          line-height: 20px;
        }
        /deep/ .el-form-item__label {
          line-height: 20px;
          margin-right: 0;
        }
      }
    }
    .mr2 {
      margin-right: 20px;
    }
    .allTagsWrap {
      .label {
        background: #f4f6fc;
        border-radius: 4px;
        border: 1px solid #e8e8ea;
        text-align: center;
        margin-right: 4px;
        margin-top: 4px;
        position: relative;
        padding: 0 8px;
        height: 26px;
        line-height: 26px;
        box-sizing: border-box;
        display: inline-block;
      }
      .isChecked {
        border: 1px solid #5850ff !important;
        color: #5850ff;
        .select-icon {
          width: 16px;
          height: 16px;
          position: absolute;
          top: 0;
          right: 0;
        }
      }
    }
  }
}
.crowd-dialog-wrap {
  .condition {
    margin-bottom: 16px;
    line-height: 21px;
    b {
      color: #666666;
    }
    span {
      white-space: nowrap;
    }
  }
  .static-image {
    width: 335px;
    height: 325px;
    img {
      width: 100%;
    }
  }
}
.crowd-logic-dialog-wrap {
  display: flex;
  .crowd-flex {
    display: flex;
    flex-direction: column;
    align-items: center;
  }
  .crowd-line {
    width: 1px;
    background: #5850ff;
  }
  .moreover {
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #5850ff;
    line-height: 35px;
    width: 35px;
    height: 35px;
    background: #efeeff;
    border-radius: 4px;
    border: 1px solid #5850ff;
  }
  .crowd-logic-wrap {
    width: 100%;
    height: auto;

    .crowd-logic-labels {
      width: 625px;
      background: #ffffff;
      border-radius: 4px;
      border: 1px solid #e5e5e5;
      padding: 10px;
      box-sizing: border-box;
      margin-top: 10px;
      .crowd-logic-label-group-name {
        line-height: 21px;
      }
      .crowd-logic-tag {
        padding: 1px 8px;
        line-height: 24px;
        height: 26px;
        background: #f4f6fc;
        border-radius: 4px;
        border: 1px solid #e8e8ea;
        margin-top: 8px;
        margin-right: 8px;
      }
      .perhaps {
        margin-top: 8px;
        margin-right: 8px;
        font-weight: 400;
      }
    }
  }
  .crowd-logic-wrap :nth-child(1) {
    margin-top: 0;
  }
}
</style>