selectCrowd.vue 5.63 KB
<!--
 * @Description: 
 * @Author: huyue
 * @Date: 2022-05-24 18:18:53
 * @LastEditors: huyue
 * @LastEditTime: 2022-05-30 14:57:17
-->
<template>
	<div>
		<glsx-dialog :title="'人群筛选'" :isVisible="crowdVisible" :width="'1080px'" @confirmDialog="handleConfirm" @closeDialog="crowdVisible = !crowdVisible">
			<div class="member-wrapper">
    <div class="member-left">
      <div class="member-title">
				人群列表
      </div>
      <div class="member-content">
        <el-form :inline="true" class="member-form" :model="searchForm" @submit.native.prevent>
          <el-form-item label="人群名称" style="margin-bottom: 0">
            <el-input :size="size" v-model.trim="searchForm.keyword" @keyup.enter.native="search" clearable placeholder="请输入关键字搜索"></el-input>
          </el-form-item>
          <el-form-item label style="margin-bottom: 0;">
            <el-button type="primary" :size="size" @click="search">搜索</el-button>
          </el-form-item>
        </el-form>
        <div class="table-content" style="max-height: 456px">
          <GLTable v-loading="loading" ref="crowdTable" :getListApi="getCrowdList" :tableParams="crowdTableParams" :searchForm="searchForm" :hasPage="false" :noDataImg="url" :beforeSearchFn="beforeSearchFn" @selectionTable="selectionTable" @row-click="rowClick">
            <!-- <div slot="staffName" slot-scope="scope">
              <span>{{ scope.scope.staffName }}</span>
              <span class="staff-title" v-show="scope.scope.staffTitle">{{ scope.scope.staffTitle }}</span>
            </div> -->
          </GLTable>
        </div>
      </div>
    </div>
    <div class="member-right">
      <div class="member-title">已选</div>
      <div class="member-name">人群({{ innerTags.length }}项)</div>
      <div class="input-tag-wrapper">
        <div class="tag-box">
          <el-tag v-for="(tag, idx) in innerTags" :key="idx" type="info" closable :disable-transitions="false" @close="remove(tag)">
            <i class="el-icon-user-solid"></i>
            {{ tag.crowdName }}
          </el-tag>
        </div>
      </div>
    </div>
  </div>
		</glsx-dialog>
	</div>
</template>

<script>
import url from '@/assets/empty.png'
export default {
	name: 'SelectCrowd',
	data() {
		return {
      url,
			crowdVisible: false,
			searchForm: {req:{}},
			innerTags: [],
      tableCrowdData: [
        {
          name: 'asda'
        }
      ],
      getCrowdList: this.$apis.customerTransform.queryCrowdtree,
      pageConf: { pageSize: 'req.pageSize', pageNum: 'req.pageNum', totalCount: 'total' },
      crowdTableParams: {
        checkSelectKey: 'id',
        checkSelectVal: [],
        listName: 'crowdUnitList',
        // 行数据的key
        mutiSelectUniqueKey: 'id',
        // 多选ref的名称
        mutiSelectName: 'crowdlist',
        tableColumns: [
          {
            label: '人群名称',
            prop: 'crowdName'
          },
          {
            label: '人群描述',
            prop: 'crowdDesc'
          },
          {
            label: '人数',
            prop: 'total'
          }
        ]
      }
		}
	},
  methods: {
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm.req.merchantId = this.$globalState.session.merchantId
        this.searchForm.req.crowdType = 3
        this.searchForm.req.filterType = 2
        resolve()
      })
    },
    selectionTable(val) {
      this.innerTags = val
    },
    remove(item) {
      this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(item)
    },
    rowClick(row) {
      console.log(this.$refs.crowdTable)
      this.$refs.crowdTable.$refs.crowdlistMutiTable.toggleRowSelection(row)
    },
    search() {
      this.$refs.crowdTable.refreshTable()
    },
    handleConfirm() {
      this.$emit('crowdData', this.innerTags)
      this.crowdVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
.member-wrapper {
  display: flex;
  .member-title {
    font-size: 16px;
		color: #333;
    font-weight: 600;
    line-height: 22px;
    margin-bottom: 6px;
    span {
      display: inline-block;
      padding-left: 5px;
      font-size: 12px;
      color: #999;
      font-weight: 500;
    }
  }
  .member-left {
    width: 800px;

    .member-content {
      border: 1px solid #eee;
      border-bottom: none;
      .member-form {
        padding: 10px 20px;
      }
      .table-content {
        max-height: 456px;
        overflow: auto;
        border-top: 1px solid #eee;
      }
    }
    .member-checked {
      text-align: right;
      margin-top: 10px;
    }
  }
  .member-right {
    width: 286px;
    margin-left: 14px;
    .member-name {
      font-size: 14px;
      color: #333;
      line-height: 20px;
      padding: 18px;
      border: 1px solid #eee;
    }
  }
}
.tag-box {
  height: 100%;
}
.input-tag-wrapper {
  position: relative;
  font-size: 14px;
  border: 1px solid #eee;
  border-top: none;
  box-sizing: border-box;
  color: #606266;
  display: inline-block;
  padding: 8px 10px;
  line-height: 32px;
  transition: border-color 0.2s cubic-bezier(0.645, 0.045, 0.355, 1);
  width: 100%;
  height: calc(100% - 86px);
  display: flex;
  align-items: center;
  max-height: 500px;
  overflow: auto;
  // margin-bottom: 10px;
  i {
    color: #75acff;
    margin-right: 3px;
    font-size: 14px;
  }
  /deep/ input {
    /* input { */
    /* background-color: red!important;  调试用的样式 */
    outline: none !important;
    border: none !important;
  }
  /deep/ .el-input {
    min-width: 150px;
    width: auto;
    flex: 1;
  }
}
.el-tag {
  margin-right: 10px;
  line-height: 22px;
  margin-bottom: 5px;
  height: 24px;
}
/deep/.el-dialog__title {
	font-weight: 600;
}
</style>