index.vue 6 KB
<template>
  <div class="marketing">
    <div class="flex head">
      <el-button type="primary" size="small" icon="el-icon-plus" @click="handleAdd">新增营销</el-button>
      <div class="head-info flex">
        <p>结合门店营销活动,指定客户创建智能营销,提高活动转化率</p>
        <el-popover placement="top" width="560" trigger="hover" content="通过导入的客户,门店可通过智能外呼及智能短信,结合营销活动的需要向离店用户进行智能营销,可实现标准、高效的营销同时实现用户线上化。">
          <img src="@/images/question.png" slot="reference" class="count-item-question" />
        </el-popover>
      </div>
    </div>
    <div class="container">
      <GLCombiForm :rowNumber="1" ref="formSearch" :formObj="tableSearchForm" :formData="searchFormData" @handleOk="handleSearch" @handleRest="handleReset"></GLCombiForm>
      <!-- 表格区域 开始 -->
      <GLTable ref="marketingRef" :getListApi="getListApi" :noDataImg="url" :searchForm="searchForm" :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn" @setTableFinishFun="setTableFinishFun">
        <template slot="imStatus" slot-scope="scope">
          <div :class="['task_icon', scope.scope.imStatus == 1 ? 'task_icon1' : 'task_icon2']">{{ scope.scope.imStatus == 1 ? '待处理' : scope.scope.imStatus == 2 ? '已完成' : '删除' }}</div>
        </template>
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <el-button type="text" @click="handleDetails(scope.scope)">详情</el-button>
          <el-button type="text" @click="handleDelete(scope.scope)">删除</el-button>
        </div>
      </GLTable>
    </div>
  </div>
</template>
<script>
import url from '@/assets/empty.png'
export default {
  data() {
    return {
      url: url,
      tableSearchForm: {
        imName: '',
        imStatus: '',
        createDate: []
      },
      searchForm: {},
      // 搜索
      searchFormData: [
        {
          label: '创建时间',
          name: 'createDate',
          type: 'datePicker',
          isClear: true
        },
        {
          label: '状态',
          name: 'imStatus',
          type: 'select',
          optionList: [
            { text: '全部', id: '' },
            { text: '待处理', id: 1 },
            { text: '已完成', id: 2 }
          ],
          optionId: 'id',
          optionLabel: 'text'
        },

        {
          label: '营销名称',
          name: 'imName',
          type: 'input'
        }
      ],
      getListApi: this.$apis.marketing.getMessageList,
      tableParams: {
        listName: 'data',
        tableOption: true,
        tableColumns: [
          {
            label: '营销名称',
            prop: 'imName',
            line: 1,
            width: 350
          },
          {
            label: '营销客户数',
            prop: 'customerCount'
          },
          {
            label: '状态',
            prop: 'imStatus',
            addHtml: 'imStatus'
          },
          {
            label: '创建时间',
            prop: 'sendTime'
          },
          {
            label: '创建人',
            prop: 'createdName'
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'count' }
    }
  },
  methods: {
    handleAdd() {
      this.$router.push({
        path: '/marketing/add'
      })
    },
    handleDetails(data) {
      this.$router.push({
        path: '/marketing/details',
        query: {
          id: data.id
        }
      })
    },
    handleDelete(data) {
      this.$confirm('删除后数据将无法恢复,是否确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$apis.marketing.updateMessageInfoStatus({ id: data.id, imStatus: 3 }).then(res => {
            if (res) {
              this.$message({
                type: 'success',
                message: '删除成功!'
              })
            }
            this.handleSearch()
          })
        })
        .catch(() => {})
    },
    getParams() {
      var params = JSON.parse(JSON.stringify(this.tableSearchForm))
      if (this.tableSearchForm.createDate.length) {
        params.startTime = new Date(this.tableSearchForm.createDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
        params.endTime = new Date(this.tableSearchForm.createDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
      }
      params.taskStatus = this.currentIndex

      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.searchForm = this.getParams()
        delete this.searchForm.createDate
        resolve()
      })
    },
    setTableFinishFun() {
      //接收到的数据为空
      this.$refs.marketingRef.data.length ? (this.$refs.marketingRef.tableHeightValues = '') : this.$refs.marketingRef.setTableHeightFun()
    },
    handleSearch() {
      this.$refs.marketingRef.refreshTable()
    },
    handleReset() {
      this.tableSearchForm = {
        imName: '',
        imStatus: '',
        createDate: []
      }
      this.searchForm = {
        imName: '',
        imStatus: '',
        startTime: '',
        endTime: ''
      }
      this.handleSearch()
    }
  }
}
</script>
<style lang="scss" scoped>
.marketing {
  .head {
    margin-bottom: 16px;
  }
  .head-info {
    font-weight: 400;
    font-size: 14px;
    color: #666666;

    p {
      margin: 0 4px 0 12px;
      line-height: 16px;
    }
    .count-item-question {
      width: 14px;
      height: 14px;
      display: inline-block;
    }
  }
  .task_icon {
    position: relative;
    &::after {
      content: '';
      position: absolute;
      top: 4px;
      left: -10px;
      width: 6px;
      height: 6px;
      border-radius: 4px;
    }

    &.task_icon1 {
      &::after {
        background: #fdb757;
      }
    }

    &.task_icon2 {
      &::after {
        background: #2cca74;
      }
    }
  }
}
</style>