marketingPlan.vue 6.62 KB
<template>
  <div class="scrm-sub-client-container">
    <div class="pageContent">
      <GLCombiForm :formObj="searchForm" :formData="searchFormList" @handleOk="searchTable" @handleRest="resetTable"></GLCombiForm>
      <GLTable v-loading="loading" :hasNum="true" @setTableHeightEvent="setTableHeightEvent" @setTableFinishFun="setTableFinishFun" ref="marketingPlan" :getListApi="getListApi" :searchForm="searchForm" :pageConf="pageConf" :noDataImg="url" :tableParams="tableParams">
        <template slot="options" slot-scope="scope">
          <el-button class="blue-text" type="text" @click="goSOPAnalysis(scope.scope.id)">SOP分析</el-button>
          <el-button class="blue-text" type="text" @click="goSOPEdit(scope.scope.id)">编辑</el-button>
          <el-button class="blue-text" type="text" @click="handleDelete(scope.scope)">删除</el-button>
          <el-button class="blue-text" type="text" @click="handleEnd(scope.scope)">结束</el-button>
          <!-- <el-button v-if="scope.scope.sopStatus != 1" type="text" @click="handleJump('sopAnalysisList', scope.scope)">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('edit', 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 { getTableList } from '@/api/modules/clientManage'
export default {
  data() {
    return {
      searchForm: {},
      searchFormList: [
        {
          type: 'input',
          inputType: 'text',
          // name: 'keyword',
          label: '人群名称'
        },
        {
          type: 'select',
          // name: 'type',
          label: '营销状态',
          optionLabel: 'label',
          optionId: 'value',
          optionList: [
            {
              label: '全部',
              value: ''
            }
          ],
          placeholder: '请选择'
        }
      ],
      getListApi: this.$apis.clientDataOverview.getSopInfoListApi,
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      tableParams: {
        listName: 'data',
        tableColumns: [
          {
            label: '人群名称',
            prop: 'orderNo'
          },
          {
            label: 'SOP名称',
            prop: 'name'
          },
          {
            label: '营销时间',
            prop: 'phone'
          },
          {
            label: '完成度',
            prop: 'dsdasd'
          },
          {
            label: '营销状态',
            prop: 'dsdasds'
          },
          {
            label: '操作',
            prop: 'options',
            addHtml: 'options'
          }
        ]
      }
    }
  },
  mounted() {
    //没数据的时候要算高度
    setTimeout(() => {
      if (!this.$refs.marketingPlan.data.length) {
        this.loading = true
        this.$refs.marketingPlan.setTableHeightFun()
        this.loading = false
      }
    }, 200)
  },
  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: '取消',
        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分析
    goSOPAnalysis(id) {
      this.$history.push(`/marketing/sop/sopAnalysisList?fromPage=${encodeURI('/custom/clientDataOverview/marketingPeople?selectTab=second')}&id=${id}`)
    },
    // 跳转SOP编辑页面
    // goSOPEdit(id) {
    //   var params = {
    //     addOrEdit: 'edit',
    //     fromPage: '/custom/clientDataOverview/marketingPeople?selectTab=second',
    //     $title: encodeURI('编辑SOP')
    //   }
    //   // addOrEdit != 'add' && (params.id = row.id)
    //   this.$router.push({
    //     path: '/sop/editSop',
    //     query: params
    //   })
    // },
    // 跳转到营销SOP
    goSOPEdit() {
      let marketQuery

      var params = {
        addOrEdit: 'edit',
        fromPage: `/custom/clientDataOverview/marketingPeople?crowdId=${this.crowdGroupId}&selectTab=2`,
        $title: encodeURI('编辑SOP'),
        info: {
          // 人群
          customerOptType: 2,
          crowdList: []
        }
      }
      params.info.crowdList.push(marketQuery)
      this.$common.utils.storage.set('sopInfo', params)
      console.log(params)
      this.$history.push({
        path: 'marketing/sop/editSop'
      })
    },
    // 确认删除或结束
    confirm(type) {
      this.$confirm(`是否确认${type == 'delete' ? '删除' : '结束'}?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          this.$message({
            type: 'success',
            message: '操作成功!'
          })
        })
        .catch(() => {
          this.$message({
            type: 'info',
            message: '已取消操作'
          })
        })
    },
    setTableFinishFun() {
      this.$refs.marketingPlan.data.length ? (this.$refs.marketingPlan.tableHeightValues = '') : this.$refs.marketingPlan.setTableHeightFun()
    },
    setTableHeightEvent() {
      this.$refs.marketingPlan.setTableHeightFun()
    },
    // 搜索表格
    searchTable() {
      console.log(this.searchForm)
      this.$refs.marketingPlan.refreshTable()
    },
    //重置表格
    resetTable() {
      this.searchForm = {
        status: '',
        type: ''
      }
      this.$refs.marketingPlan.refreshTable()
    }
  }
}
</script>

<style lang="scss" scoped>
.pageContent {
  padding: 20px 20px 30px;
  box-shadow: 0 10px 20px 0 rgba(88, 80, 255, 0.1);
  background-color: #fff;
}
</style>