add.vue 7.22 KB
<template>
  <div class="live-room">
    <div class="m-b-20">
      <step-bar @changeStep="changeIndex">
        <template slot="center">
          <div class="journey-step bg-fff pb20">
            <div class="journey-step-title border-title">
              {{ titleConfig[currentIndex] }}
            </div>
            <div class="journey-step-body">
              <SelJourneyTemplate v-show="currentIndex == '0'" ref="journeyTemplat"></SelJourneyTemplate>
              <div v-if="currentIndex == '1'">
                <!--                <div class="journey-step-info" v-for="(val, k) in configList" :key="k">-->
                <!--                  configList-->
                <collapse-item-tpl ref="collapseRef" :configList="configList" :isDisabled="isDisabled"></collapse-item-tpl>
                <!--                </div>-->
              </div>
              <DistributionStore v-if="currentIndex == '2'"></DistributionStore>
            </div>
          </div>
        </template>
      </step-bar>
    </div>
  </div>
</template>

<script>
import StepBar from './components/StepBar.vue'
import CollapseItemTpl from './components/CollapseItemTpl'
import SelJourneyTemplate from './components/selJourneyTemplate'
import DistributionStore from './components/DistributionStore'

export default {
  components: {
    StepBar,
    SelJourneyTemplate,
    CollapseItemTpl,
    DistributionStore
  },
  name: 'add',
  data() {
    return {
      ruleForm: {
        name: '',
        region: ''
      },
      rules: {
        region: [{ required: true, message: '请选择活动区域', trigger: 'change' }]
      },
      titleConfig: {
        '0': '旅程模板',
        '1': '客户旅程阶段',
        '2': '分配门店'
      },
      isDisabled: false,
      currentIndex: 0,
      configList: [],
      configList2: [
        {
          label: '可报价',
          isExpaned: false,
          taskList: [
            {
              status: [1, 2],
              name: '进入条件',
              desc: '描述用户触发何种条件后,将自动变更为该旅程阶',
              progressList: [
                {
                  name: '33'
                },
                {
                  name: '33'
                },
                {
                  name: '33'
                }
              ]
            }
          ]
        },
        {
          label: '有意向',
          isExpaned: false,
          taskList: [
            {
              status: [1, 2],
              name: '进入条件',
              desc: '描述用户触发何种条件后,将自动变更为该旅程阶',
              progressList: [
                {
                  name: '33'
                }
              ],
              sopList: [
                {
                  day: '第一天',
                  times: [
                    {
                      time: '7:00',
                      process: 1
                    },
                    {
                      time: '8:00',
                      process: 2
                    },
                    {
                      time: '9:00',
                      process: 3
                    }
                  ]
                },
                {
                  day: '第二天',
                  times: [
                    {
                      time: '7:00',
                      process: 1
                    },
                    {
                      time: '8:00',
                      process: 2
                    }
                  ]
                },
                {
                  day: '第三天'
                },
                {
                  day: '第四天'
                },
                {
                  day: '第五天'
                }
              ]
            }
          ]
        }
      ]
    }
  },
  mounted() {
    // this.$bus.$off('whetherToProceedNext')
    this.$bus.$on('whetherToProceedNext', data => {
      const query = data.tplId
      this.getDetail(query)
    })
  },
  methods: {
    changeIndex(currentInex) {
      this.currentIndex = currentInex
    },
    getDetail(val) {
      this.$apis.journeyConfig.getSOPDetailsApi({ tplId: val }).then(res => {
        const tplParamDef = JSON.parse(res.tplParamDef)
        const stages = tplParamDef.stages.defaultValue
        const customData = tplParamDef.customData.defaultValue
        const nodes = res.nodes
        const configList = []
        for (let k in stages) {
          let list = []
          for (let v of nodes) {
            if (v.nodeParamDef && JSON.parse(v.nodeParamDef).stage.defaultValue == stages[k].value) {
              list.push({
                ...JSON.parse(v.nodeParamDef),
                nodeSkipable: v.nodeSkipable,
                nodeProtoId: v.nodeProtoId,
                nodeId: v.nodeId,
                nodeSkip: '0',
                nodeVisible: v.nodeVisible, // nodeVisible 0 节点不可见 1 可见
                customData
              })
            }
          }
          list = list.filter(item => item.day)
          list.sort((a, b) => {
            return a.day.defaultValue - b.day.defaultValue
          })
          let sopList = this.groupBy(list, 'day.defaultValue')
          sopList = sopList.map(function(arr) {
            return arr.filter(function(obj) {
              // nodeVisible 0 节点不可见 1 可见
              return obj.nodeVisible == 1
            })
          })
          configList.push({
            label: stages[k].value,
            isExpaned: true,
            editable: stages[k].editable,
            conditionsList: stages[k].conditions || [],
            sopList
          })
        }
        console.log(configList, 'configList')
        this.configList = configList
      })
    },
    groupBy(list, name) {
      const m = new Map()
      list.map(item => {
        m.set(item['day']['defaultValue'], [...(m.get(item['day']['defaultValue']) || ''), item])
      })
      return [...m.values()]
    },
    //关闭
    handleClose() {
      this.handleConfirm('关闭提示', '确定关闭', '旅程关闭后将禁用无法重新开启', '', () => {
        this.journeyStatus = 4
      })
    },
    //关联活动成功
    setProcess() {
      this.journeyStatus = 2
    },
    handleConfirm(title, btnName, content, customClass, callback) {
      this.$confirm(content, title, {
        confirmButtonText: btnName,
        cancelButtonText: '取消',
        customClass,
        type: 'warning'
      })
        .then(() => {
          callback()
        })
        .catch(() => {})
    },
    //开启
    haneldOpen() {
      this.handleConfirm('开启提示', '确定开启', '旅程开启后将无法修改关联的活动链接', '', () => {
        this.journeyStatus = 3
      })
    },
    //关联活动
    handleConcat() {
      this.handleConfirm('关联提示', '前往关联', '当前旅程尚未关联活动链接,请关联后再尝试开启', 'concat-color', this.concatActivity)
    },
    //打开活动
    concatActivity() {
      this.$refs.activityForm.init()
    },
    changeNode(val) {
      console.log(val)
    }
  }
}
</script>

<style lang="scss" scoped>
/deep/ .journey-step-body {
  min-height: calc(100vh - 350px);
}
</style>
<style lang="scss">
.concat-color {
  .el-icon-warning {
    color: #5850ff;
  }
}
</style>