crowdAdd.vue 31 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024
<template>
  <div class="scrm-sub-client-container">
    <div class="container" id="container">
      <div>
        <div class="title">创建人群</div>
        <div class="info-box">
          <el-form class="create-form" :model="crowdForm" :rules="crowdRules" ref="crowdForm" label-width="118px">
            <div class="el-form-line">
              <el-form-item label="人群名称:" prop="crowdName">
                <el-input v-model.trim="crowdForm.crowdName" size="small" placeholder="请输入人群名称" maxlength="60"></el-input>
              </el-form-item>
              <span class="limited">最多30个字符</span>
            </div>
            <div class="el-form-line">
              <el-form-item label="人群描述:">
                <el-input v-model.trim="crowdForm.crowdDesc" size="small" placeholder="请输入人群描述" maxlength="200"></el-input>
              </el-form-item>
              <span class="limited">最多100个字符</span>
            </div>
            <div class="el-form-line">
              <el-form-item label="标签筛选:" 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>
          </el-form>
          <div class="label-wrap">
            <div :class="{ 'fixed-box': true, is_fixed: isFixed, is_pb: isDom }" id="boxFixed">
              <template v-if="this.selectedArray.length > 0">
                <div :class="['select-label-wrap', 'font-14', 'flex-start', !isFixed ? 'is_auto' : '']" id="tagBox">
                  <div class="select-label color-3">已选标签:</div>
                  <div class="flex" id="selectTagBox">
                    <div class="selects" v-for="(selectTag, index) in selectedArray" :key="index" @click="labelFilter(selectTag)">
                      <template v-if="selectTag.groupName.length + selectTag.combination.length <= 20">
                        <div class="label-group-name color-3 hand">
                          <span class="color-9">{{ selectTag.groupName }}:</span>
                          {{ selectTag.combinationtext }}
                          <i class="el-icon-close" @click.stop="closeTag(selectTag, index)"></i>
                        </div>
                      </template>
                      <template v-else>
                        <el-tooltip placement="top">
                          <div slot="content" class="tooltip-text">{{ selectTag.groupName }}:{{ selectTag.combination }}</div>
                          <div class="label-group-name color-3 hand" style="padding-right: 60px">
                            <span class="color-9">{{ selectTag.groupName }}:</span>
                            {{ selectTag.combinationtext }}
                            <div class="select-num">+{{ selectTag.labelUnitList.length }}</div>
                            <i class="el-icon-close" @click.stop="closeTag(selectTag, index)"></i>
                          </div>
                        </el-tooltip>
                      </template>
                    </div>
                  </div>
                </div>
              </template>
              <el-form class="search-tag-form" :model="searchForm" size="small" filterable :inline="true" @submit.native.prevent label-position="right" label-width="auto">
                <el-form-item label="标签组名称">
                  <el-select v-model="searchForm.groupName" clearable filterable placeholder="请选择" @change="getLabelList" @clear="getLabelList">
                    <el-option v-for="item in groupArray" :key="item" :label="item" :value="item"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="标签名称">
                  <el-select v-model="searchForm.labelName" clearable filterable placeholder="请选择">
                    <el-option v-for="item in labelArray" :key="item" :label="item" :value="item"></el-option>
                  </el-select>
                </el-form-item>
                <el-form-item>
                  <el-button @click="resetTable" plain>重置</el-button>
                  <el-button type="primary" @click="searchTable">查询</el-button>
                </el-form-item>
                <div class="color-3 font-14 forecast">
                  查看预估人数
                  <template v-if="crowdCount === ''">
                    <span class="color-58" @click="getCrowdCount">查看</span>
                  </template>
                  <template v-else>
                    <span class="color-58">{{ crowdCount }}</span>
                  </template>
                </div>
              </el-form>
              <div class="expande-button-wrap" v-if="isFixed">
                <div class="expande-button" @click="expandeClick" v-if="!expande && isDom">
                  <i class="el-icon-arrow-down"></i>
                  <span>展开</span>
                </div>
                <div class="expande-button" @click="expandeClick" v-if="expande && isDom">
                  <i class="el-icon-arrow-up"></i>
                  <span>收起</span>
                </div>
              </div>
            </div>
            <div v-show="isFixed" style="width: 100%" id="placeholder"></div>
            <div class="pageContent">
              <GLTable ref="crowdManage" :hasNum="false" :tableTotal="tableTotal" :tableData="tableData" :searchForm="searchForm" :pageConf="pageConf" :noDataImg="url" @refreshTable="refreshTable" :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-3', 'white-hide', 'mt10', item.checked ? 'isChecked' : '']" :key="index" @click="selectTag(item, index)">
                        {{ item.labelName }}
                        <template v-if="item.checked">
                          <img src="@/assets/clientDetail/select-icon.png" class="select-icon" alt />
                        </template>
                      </span>
                    </template>
                  </div>
                </span>
              </GLTable>
            </div>
          </div>
        </div>
      </div>
    </div>
    <GLFooter>
      <el-button class="cancel-button" @click="handleCancel">取消</el-button>
      <el-button type="primary" @click="handleSubmit">保存</el-button>
    </GLFooter>
    <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="人群规则逻辑" :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: 'crowdAdd',
  data() {
    return {
      isFixed: false,
      offsetTop: 0,
      expande: false,
      isClick: false,
      addClick: false,
      isDom: false,
      isShowCloseBtn: true,
      tableData: [],
      isReload: true,
      dialogRuleVisible: false,
      dialogLogicVisible: false,
      crowdForm: {
        crowdName: '',
        crowdDesc: ''
      },
      crowdRules: {
        crowdName: [
          { required: true, message: '请输入人群名称', trigger: 'blur' },
          { max: 60, message: '最多支持60个汉字', trigger: 'blur' }
        ]
      },
      searchForm: {
        groupName: '',
        labelName: ''
      },
      groupArray: [], //标签组列表
      labelArray: [], //标签列表
      crowdCount: '', //预估人数
      page: {
        'req.pageSize': 10,
        'req.pageNum': 1
      },
      tableTotal: '',
      pageConf: { pageSize: 'req.pageSize', pageNum: 'req.pageNum' },
      tableParams: {
        tableColumns: [
          {
            label: '标签组',
            prop: 'groupName',
            width: 230,
            align: 'left'
          },
          {
            label: '标签组类型',
            prop: 'groupType',
            width: 180,
            align: 'left',
            formatter: cellValue => {
              return cellValue.groupType == '企业标签' && this.$globalState.session.merchantModel == 1 ? '集团标签' : cellValue.groupType
            }
          },
          {
            label: '标签',
            prop: 'labelUnitList',
            addHtml: 'labelUnitList',
            align: 'left'
          }
        ]
      },
      selectedArray: []
    }
  },
  created() {
    if (window.__POWERED_BY_QIANKUN__) {
      //运行在qiankun容器中
      this.merchantId = this.$globalState.session.merchantId
    }
    //获取标签组列表
    this.getGroupList()
    //获取标签列表
    this.getLabelList()
    //获取标签数据
    this.getLabelData()
  },
  watch: {
    selectedArray: function() {
      this.crowdCount = '' //初始化查看预估人数
      if (this.selectedArray.length > 0) {
        this.$nextTick(() => {
          //条件重置
          document.getElementById('placeholder').style.height = document.getElementById('boxFixed').offsetHeight + 'px'
          document.getElementById('tagBox').style.height = 'auto'
          let height = document.getElementById('selectTagBox').offsetHeight

          if (!this.isFixed || this.addClick) {
            //判断是否可以触发
            this.isClick = false
            this.expande = false
          }

          if (!this.isClick || this.addClick || !this.isFixed) {
            //获取当前元素的高

            if (height > 96) {
              document.getElementById('tagBox').style.height = 96 + 'px'
              this.isDom = true
            } else {
              document.getElementById('tagBox').style.height = 'auto'
              this.isDom = false
            }
          }
        })
      }
    }
  },
  mounted() {
    window.addEventListener('scroll', this.initHeight, true)
    this.$nextTick(() => {
      this.offsetTop = document.querySelector('#boxFixed').offsetTop
    })
  },
  methods: {
    getGroupList() {
      let params = {
        'req.merchantId': this.merchantId,
        'req.searchBoxType': 1 //搜索框类型 1-标签组搜索框 2-标签搜索框
      }
      this.$apis.crowdManage.getSearchBox(params).then(res => {
        if (res.code == 0) {
          this.groupArray = res.data.resultList
        }
      })
    },
    getLabelList() {
      let params = {
        'req.merchantId': this.merchantId,
        'req.searchBoxType': 2, //搜索框类型 1-标签组搜索框 2-标签搜索框
        'req.groupName': this.searchForm.groupName
      }
      this.$apis.crowdManage.getSearchBox(params).then(res => {
        if (res.code == 0) {
          this.labelArray = res.data.resultList
          this.searchForm.labelName = ''
        }
      })
    },
    handleParameters() {
      let tagCombine = []
      this.selectedArray.forEach(label => {
        tagCombine.push({
          groupId: label.groupId,
          labelIdList: label.labelIdList
        })
      })

      return tagCombine
    },
    //创建人群
    handleSubmit() {
      this.$refs.crowdForm.validate(valid => {
        if (valid) {
          let tagCombine = this.handleParameters()
          if (tagCombine.length == 0) {
            this.$message.error('必须选择一个标签')
            return
          }
          const params = {
            'req.merchantId': this.merchantId,
            'req.crowdType': 2, //类型 1-推荐 2-自定义
            'req.crowdName': this.crowdForm.crowdName,
            'req.crowdDesc': this.crowdForm.crowdDesc,
            'req.tagCombine': JSON.stringify(tagCombine)
          }
          this.$apis.crowdManage
            .addCrowd(params)
            .then(res => {
              if (res.data.code == 0) {
                this.$message({
                  type: 'success',
                  message: '操作成功!'
                })
                this.$router.push({
                  path: '/crowdManage/index',
                  query: {
                    selectTab: 2
                  }
                })
              } else {
                this.$message({
                  type: 'error',
                  message: res.data.message
                })
              }
            })
            .catch(err => {
              this.$message({
                type: 'error',
                message: err.message
              })
            })
        }
      })
    },
    //根据标签组合查询人群客户数
    getCrowdCount() {
      if (this.selectedArray.length > 0) {
        let params = {
          'req.merchantId': this.merchantId,
          'req.tagCombine': JSON.stringify(this.handleParameters())
        }
        this.$apis.crowdManage.getCrowdCount(params).then(res => {
          if (res.code == 0) {
            this.crowdCount = res.data.total
          }
        })
      }
    },
    delayScrollFunc(fn, delay) {
      const now = new Date().getTime()
      if (now - this.lastScrollCall < delay) return
      this.lastScrollCall = now

      setTimeout(() => {
        fn()
      }, 60) // 在实际项目中,我发现这里再延迟一点时间执行效果更好(针对监听scroll)
    },
    open(value) {
      if (value == 'dialogLogicVisible' && this.selectedArray.length == 0) {
        this.$confirm('暂未选中标签,无法生成人群规则逻辑,快去选标签吧?', '提示', {
          confirmButtonText: '我知道了',
          cancelButtonText: '取消',
          customClass: 'gl-message-box',
          showCancelButton: false,
          type: 'warning'
        })
          .then(() => {
            this[value] = false
          })
          .catch(() => {})

        return
      }
      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'
          }
        })
      }
    },
    handleClose() {
      this.dialogRuleVisible = false
      this.dialogLogicVisible = false
    },
    refreshTable(page) {
      this.page = page
      this.getLabelData()
    },
    expandeClick() {
      this.expande = !this.expande
      this.isClick = this.expande
      this.addClick = false
      if (this.expande) {
        document.getElementById('tagBox').style.height = 'auto'
      } else {
        document.getElementById('tagBox').style.height = 96 + 'px'
      }
      document.getElementById('placeholder').style.height = document.getElementById('boxFixed').offsetHeight + 'px'
    },
    initHeight() {
      var timeOut = null
      if (timeOut) {
        clearTimeout(timeOut)
      }
      timeOut = setTimeout(() => {
        var scrollTop = document.querySelector('.el-main-scroll>.el-scrollbar__wrap').scrollTop
        this.isFixed = scrollTop > this.offsetTop ? true : false
        if (!this.isFixed) {
          document.getElementById('placeholder').style.height = document.getElementById('boxFixed').offsetHeight + 'px'
        }
      }, 200)
    },
    //获取标签数据
    getLabelData() {
      let params = {
        'req.merchantId': this.merchantId,
        'req.groupName': this.searchForm.groupName,
        'req.labelName': this.searchForm.labelName,
        ...this.page
      }
      this.$apis.crowdManage.getLabelTreeList(params).then(res => {
        if (res.code == 0) {
          res.data.groupUnitList.forEach(item => {
            item.labelUnitList.forEach(label => {
              label.checked = false
            })
          })
          this.tableData = res.data.groupUnitList
          this.tableTotal = res.data.total
          this.getHistoryLabel()
        }
      })
    },
    //已选择标签状态保存
    getHistoryLabel() {
      let selectId = []
      if (this.selectedArray.length > 0) {
        for (let i = 0; i < this.selectedArray.length; i++) {
          for (let k = 0; k < this.selectedArray[i].labelUnitList.length; k++) {
            selectId.push(this.selectedArray[i].labelUnitList[k].labelId)
          }
        }
        for (let m = 0; m < this.tableData.length; m++) {
          for (let n = 0; n < this.tableData[m].labelUnitList.length; n++) {
            if (selectId.indexOf(this.tableData[m].labelUnitList[n].labelId) != -1) {
              this.tableData[m].labelUnitList[n].checked = true
            }
          }
        }
      }
    },

 
    //选择标签
    selectTag(data) {
      this.tableData.forEach(item => {
        item.labelUnitList.forEach(label => {
          if (label.labelId == data.labelId) {
            label.checked = !label.checked
            this.selectedLabelFn(item, data)
          }
        })
      })
    },

 
    // 添加已选标签
    selectedLabelFn(groupData, data) {
      this.addClick = true
      if (this.selectedArray.length > 0) {
        for (let i = 0; i < this.selectedArray.length; i++) {
          if (this.selectedArray[i].groupId == groupData.groupId) {
            if (data.checked) {
              this.selectedArray[i].labelUnitList.push(data)
            } else {
              for (let k = 0; k < this.selectedArray[i].labelUnitList.length; k++) {
                if (this.selectedArray[i].labelUnitList[k].labelId == data.labelId) {
                  this.selectedArray[i].labelUnitList.splice(k--, 1)
                }
              }
            }
          }
        }
        if (!this.selectedArray.some(tag => tag.groupId == groupData.groupId)) {
          this.selectedArray.push({
            groupId: groupData.groupId,
            groupName: groupData.groupName,
            labelUnitList: [data]
          })
        }
      } else {
        this.selectedArray.push({
          groupId: groupData.groupId,
          groupName: groupData.groupName,
          labelUnitList: [data]
        })
      }

      this.handleLabel()
    },
    //处理已选标签
    handleLabel() {
      for (let i = 0; i < this.selectedArray.length; i++) {
        let array = []
        let idArray = []
        if (this.selectedArray[i].labelUnitList.length == 0) {
          this.selectedArray.splice(i--, 1)
          return
        }
        for (let j = 0; j < this.selectedArray[i].labelUnitList.length; j++) {
          array.push(this.selectedArray[i].labelUnitList[j].labelName)
          idArray.push(this.selectedArray[i].labelUnitList[j].labelId)
        }
        this.selectedArray[i].labelIdList = idArray
        this.selectedArray[i].combination = array.join('、')
        let length = 40 - this.checkName(this.selectedArray[i].groupName)
        this.selectedArray[i].combinationtext = this.cutMaxCharStr(this.selectedArray[i].combination, length)
        this.$set(this.selectedArray, i, this.selectedArray[i])
      }
    },
    //删除选中标签
    closeTag(data, index) {
      this.addClick = true
      this.selectedArray.splice(index, 1)
      this.tableData.forEach(t => {
        if (t.groupId == data.groupId) {
          t.labelUnitList.forEach(m => {
            m.checked = false
          })
        }
      })
      //条件重置
      this.$nextTick(() => {
        document.getElementById('tagBox').style.height = 'auto'
        let height = document.getElementById('selectTagBox').offsetHeight

        if (height > 96) {
          document.getElementById('tagBox').style.height = 96 + 'px'
          this.isDom = true
        } else {
          document.getElementById('tagBox').style.height = 'auto'
          this.isDom = false
        }
      })
    },
    //点击标签组搜索
    labelFilter(data) {
      this.searchForm.groupName = data.groupName
      this.searchForm.labelName = ''
      //获取标签列表
      this.getLabelList()
      this.getLabelData()
    },
    //标签查询
    searchTable() {
      this.getLabelData()
    },
    //重置表格
    resetTable() {
      this.searchForm = {
        groupName: '',
        labelName: ''
      }
      this.page = {
        'req.pageSize': 10,
        'req.pageNum': 1
      }
      this.$refs.crowdManage.page[this.pageConf.pageSize] = 10
      this.$refs.crowdManage.page[this.pageConf.pageNum] = 1
      this.getLabelData()
    },
    handleCancel() {
      this.$router.push(`/crowdManage/index?selectTab=2`)
    },
    checkName(value) {
      // 一个汉字2个字符,字母数字1个字符
      var len = 0
      for (var i = 0; i < value.length; i++) {
        var c = value.charCodeAt(i)
        //单字节加1
        if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
          len++
        } else {
          len += 2
        }
      }
      return len
    },
    cutMaxCharStr: function(e, unit) {
      //e为传入字符串
      let str = e
      var len = 0
      var singleNum = 0
      var doubleNum = 0

      for (var i = 0; i < e.length; i++) {
        var c = e.charCodeAt(i)
        //单字节加1
        if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
          len++
        } else {
          len += 2
        }
      }
      if (len > unit) {
        var subLen = 0
        var subLen1 = 0
        var subLen2 = 0
        for (var v = 0; v < e.length; v++) {
          var ch = e.charCodeAt(v)
          //单字节
          if ((ch >= 0x0001 && ch <= 0x007e) || (0xff60 <= ch && ch <= 0xff9f)) {
            singleNum += 1
            subLen1++
          } else {
            doubleNum += 2
            subLen2++
          }
          if (singleNum + doubleNum >= unit) {
            subLen = subLen1 + subLen2
            break
          }
        }
        return str.substr(0, subLen)
      }
      return str
    }
  },
  destroyed() {
    window.removeEventListener('scroll', this.initHeight, true)
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/variables.scss';
.container {
  background: #ffffff;

  margin-bottom: 16px;
  // 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%;
      height: 246px;
      box-sizing: border-box;
      border-bottom: 1px solid #d8d8d8;
      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;
        }
      }

      .el-input {
        width: 415px;
      }
      /deep/ .el-form-item {
        margin-bottom: 6px !important;
      }
      /deep/ .el-form-item__error {
        color: #f56c6c;
        font-size: 12px;
        line-height: 1;
        padding-top: 30px;
        position: absolute;
        top: 100%;
        left: 0;
      }
    }

    .limited {
      font-size: 12px;
      font-weight: 400;
      color: #999999;
      line-height: 17px;
      margin-left: 118px;
      margin-bottom: 20px;
      margin-top: -20px;
    }
    .mr2 {
      margin-right: 20px;
    }
    .label-wrap {
      margin-top: 32px;
      width: 100%;
      .fixed-box {
        background: #ffffff;
        box-sizing: border-box;
        padding: 0 30px;
      }
      .is_fixed {
        width: calc(100vw - 250px);
        position: fixed;
        top: 60px;
        z-index: 999;
        padding: 20px 30px 20px 30px;
        box-shadow: 0px 10px 20px 0px rgba(88, 80, 255, 0.1);
      }
      .is_pb {
        padding: 20px 30px 52px 30px !important;
      }
      .is_auto {
        height: auto !important;
      }
      .search-tag-form {
        position: relative;
        display: flex;
        /deep/ .el-form-item {
          display: flex;
        }
      }
      .select-label-wrap {
        margin-bottom: 20px;
        overflow: hidden;
        .select-label {
          line-height: 26px;
          height: 26px;
          white-space: nowrap;
        }
        .selects {
          height: 26px;
          background: #ffffff;
          border: 1px solid rgba(232, 232, 234, 1);
          border-radius: 4px;
          margin-right: 4px;
          margin-bottom: 4px;
          position: relative;
          display: flex;
          align-items: center;
          flex-wrap: nowrap;

          .label-group-name {
            max-width: 533px;
            padding-top: 3px;
            padding-bottom: 3px;
            padding-left: 8px;
            padding-right: 30px;
            color: #666666;
            box-sizing: border-box;
            .select-num {
              line-height: 18px;
              height: 18px;
              background: #ffffff;
              border-radius: 2px;
              border: 1px solid #e7e7e9;
              padding: 0 4px;
              position: absolute;
              right: 27px;
              margin-left: 20px;
              top: 2px;
            }
          }

          //   .label {
          //     padding: 3px 8px;
          //     background: #fafbfe;
          //     border: 1px solid rgba(232, 232, 234, 1);
          //     border-radius: 4px;
          //     margin-right: 4px;
          //   }
          .el-icon-close {
            position: absolute;
            right: 8px;
            margin-left: 10px;
            top: 6px;
          }
        }
      }
      /deep/ .search-form {
        padding: 0 0 2px 0;
      }
      .pageContent {
        padding: 0 30px;
      }
      .forecast {
        position: absolute;
        right: 40px;
        top: 0;
        line-height: 36px;
        span {
          margin-left: 4px;
          cursor: pointer;
        }
      }
      .expande-button-wrap {
        position: absolute;
        bottom: 16px;
        left: 50%;
        transform: translateX(-50%);
        z-index: 99;
        .expande-button {
          color: $btnBlue;
          cursor: pointer;
          i {
            height: 8px;
          }
          span {
            height: 20px;
            font-size: 16px;
            font-weight: 400;
            color: $btnBlue;
            line-height: 20px;
          }
        }
      }
    }
    .allTagsWrap {
      .label {
        background: #fafbfe;
        border-radius: 4px;
        border: 1px solid #e8e8ea;
        text-align: center;
        margin-right: 4px;
        margin-top: 4px;
        position: relative;
        padding: 3px 8px;
        box-sizing: border-box;
        display: inline-block;
        cursor: pointer;
      }
      .isChecked {
        border: 1px solid #5850ff !important;
        color: #5850ff;
        .select-icon {
          width: 16px;
          height: 16px;
          position: absolute;
          top: 0;
          right: 0;
        }
      }
    }
  }
}

.footer-panel {
  // display: flex;
  // align-items: center;
  // justify-content: center;
  position: fixed;
  bottom: 0px;
  height: 78px;
  left: 220px;
  width: 100%;
  background: #ffffff;
  box-shadow: 0px -1px 1px 0px rgba(88, 80, 255, 0.1);
  z-index: 999;
  .el-button:nth-child(2) {
    margin-left: 20px;
  }
  div {
    display: inline-block;
    position: relative;
    transform: translate(-50%, -50%);
    left: 50%;
    top: 50%;
    margin-left: -110px;
  }
}
.label-text {
  margin-left: 10px;
  font-size: 14px;
  span {
    color: $btnBlue;
  }
}
.form-error {
  color: #f56c6c;
  font-size: 12px;
  margin-left: 186px;
  margin-top: 10px;
}
.sale-select {
  display: flex;
  align-items: center;
}
.tooltip-text {
  line-height: 18px;
}

.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;
  }
}
/deep/ .el-tooltip__popper.is-dark {
  background: #666666;
  box-shadow: 0px 2px 12px 0px rgba(0, 0, 0, 0.06);
}
</style>