marketingPlan.vue 6.7 KB
<template>
  <div class="scrm-sub-client-container">
    <div class="pageContent">
      <GLCombiForm :rowNumber="1" :formObj="searchForm" :formData="searchFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
      <GLTable :hasNum="true" @setTableFinishFun="setTableFinishFun" :beforeSearchFn="beforeSearchFn" ref="marketingPlan" :getListApi="getListApi" :searchForm="searchForm" :pageConf="pageConf" :tableParams="tableParams">
        <template slot="options" slot-scope="scope">
          <el-button v-if="scope.scope.sopStatus != 1" type="text" @click="handleJump(scope.scope.id)">SOP分析</el-button>
          <el-button v-if="scope.scope.sopStatus == 2" type="text" @click="handleEnd(scope.scope)">结束</el-button>
          <el-button v-if="scope.scope.sopStatus != 3" type="text" @click="handleEdit(scope.scope)">编辑</el-button>
          <el-button v-if="scope.scope.sopStatus == 1" type="text" @click="handleDelete(scope.scope)">删除</el-button>
        </template>
      </GLTable>
    </div>
  </div>
</template>

<script>
import { getSopInfoListApi } from '@/api/modules/clientDataOverview'
export default {
  props: ['crowdGroupId'],

  data() {
    return {
      searchForm: {
        crowdGroupId: this.crowdGroupId
      },
      searchFormList: [
        {
          type: 'input',
          inputType: 'text',
          name: 'crowdName',
          label: '人群名称'
        },
        {
          type: 'select',
          name: 'sopStatus',
          label: '营销状态',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: ''
            },
            {
              label: '未开始',
              value: '1'
            },
            {
              label: '进行中',
              value: '2'
            },
            {
              label: '已结束',
              value: '3'
            }
          ],
          placeholder: '请选择'
        }
      ],
      baseData: {
        sopStatusList: [
          {
            confId: 1,
            confName: '未开始'
          },
          {
            confId: 2,
            confName: '进行中'
          },
          {
            confId: 3,
            confName: '已结束'
          }
        ]
      },
      getListApi: getSopInfoListApi,
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      tableParams: {
        listName: 'list',
        tableColumns: [
          {
            label: '人群名称',
            prop: 'crowdName'
            // line: 1,
            // width: 220
          },
          {
            label: 'SOP名称',
            prop: 'sopName'
            // width: 240,
            // line: 1
          },
          {
            label: '营销时间',
            prop: 'startDate',
            width: 220,
            line: 1
          },
          {
            label: '营销状态',
            prop: 'sopStatus',
            formatter: cellValue => {
              return this.baseData.sopStatusList.map(item => item.confId).includes(cellValue.sopStatus) ? this.baseData.sopStatusList.find(item => item.confId == cellValue.sopStatus).confName : '-'
            }
          },
          {
            label: '完成度',
            prop: 'sopStatistics',
            formatter: cellValue => {
              return cellValue.sopStatistics ? Math.round((cellValue.sopStatistics.finishEventCount / cellValue.sopStatistics.eventCount) * 100).toFixed(0) + '%' : '-'
            }
          },
          {
            label: '操作',
            prop: 'options',
            addHtml: 'options',
            width: 180
          }
        ]
      }
    }
  },
  mounted() {
    //没数据的时候要算高度
  },
  methods: {
    // 结束
    handleEnd(row) {
      this.secondConfirm('结束', '结束SOP后,将不再进行营销任务自动推送,且不可恢复。是否确定结束?', 'clientDataOverview', 'endSopEventApi', { sopId: row.id })
    },

    handleDelete(row) {
      this.secondConfirm('删除', 'SOP删除后,不可恢复。是否确定删除?', 'clientDataOverview', 'deleteSopEventApi', { sopId: row.id })
    },
    secondConfirm(title, txt, apiModule, apiName, apiParams, fn) {
      this.$confirm(txt, title, {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        customClass: 'gl-message-box',
        type: 'warning',
        callback: action => {
          if (action == 'confirm') {
            this.$apis[apiModule][apiName](apiParams).then(res => {
              this.$message({
                message: res.code == '0' ? '操作成功' : res.message,
                type: res.code == '0' ? 'success' : 'error'
              })
              if (res.code == '0') {
                fn && fn()
                this.searchTable()
              }
            })
          }
        }
      })
    },
    // 跳转SOP分析
    handleJump(id) {
      const { crowdGroupName, crowdGroupDesc } = this.$route.query
      
      let query = JSON.stringify({
        crowdId: this.crowdGroupId,
        crowdGroupDesc,
        selectTab: 'second',
        crowdGroupName
      })
      if (this.$route.query && this.$route.query.flag == 1) {
        query = JSON.stringify({
          crowdId: this.crowdGroupId,
          crowdGroupDesc,
          crowdGroupName,
          selectTab: 'second',
          flag: 1
        })
      }
      this.$history.push(`/marketing/sop/sopAnalysisList?fromPage=${encodeURI(`/custom/clientDataOverview/marketingPeople?crowQuery=${query}`)}&id=${id}`)
    },
    // 跳转到编辑营销SOP
    handleEdit(row) {
      const { crowdGroupName, crowdGroupDesc } = this.$route.query
      let query = JSON.stringify({
        crowdId: this.crowdGroupId,
        selectTab: 'second',
        crowdGroupDesc,
        crowdGroupName
      })
      this.$history.push(`/marketing/sop/editSop?fromPage=${encodeURI(`/custom/clientDataOverview/marketingPeople?crowQuery=${query}`)}&addOrEdit=edit&id=${row.id}&$title=编辑SOP`)
    },
    setTableFinishFun() {
      this.$refs.marketingPlan.data.length ? (this.$refs.marketingPlan.tableHeightValues = '') : this.$refs.marketingPlan.setTableHeightFun()
    },
    setTableHeightEvent() {
      this.$refs.marketingPlan.setTableHeightFun()
    },
    // 搜索表格
    searchTable() {
      
      this.$refs.marketingPlan.refreshTable()
    },
    //重置表格
    resetTable() {
      this.searchForm = {
        crowdGroupId: this.crowdGroupId
      }
      this.$refs.marketingPlan.refreshTable()
    }
  }
}
</script>

<style lang="scss" scoped>
.gl-footer {
  z-index: 100;
}
/deep/ .el-tabs__content {
  margin-bottom: 64px;
}
.pageContent {
  padding: 20px 20px 30px;
  
  background-color: #fff;
}
</style>