config.js 6.53 KB
export default {
  data() {
    return {
      journeyStatus: 0,
      statusList: [],
      noConfig: false,
      activityType: {
        1: [
          {
            describe: '步骤一:关联营销活动',
            icon: 'el-icon-warning',
            isDisabled: false,
            status: [1],
            with: 165,
            btnName: '去关联',
            clickFun: () => {
              this.handleConcat()
            }
          },
          {
            describe: '步骤二:启用客户旅程',
            icon: 'el-icon-warning',
            isDisabled: true,
            with: 165,
            status: [1],
            btnName: '去开启',
            clickFun: () => {
              this.haneldOpen()
            }
          },
          {
            describe: '步骤一:已关联营销活动',
            icon: 'el-icon-success',
            isDisabled: false,
            status: [2],
            with: 165,
            btnName: '去查看',
            clickFun: () => {
              this.concatActivity()
            }
          },
          {
            describe: '步骤二:启用客户旅程',
            icon: 'el-icon-warning',
            isDisabled: false,
            with: 165,
            status: [2],
            btnName: '去开启',
            clickFun: () => {
              this.haneldOpen()
            }
          },
          {
            describe: '步骤一:已关联营销活动',
            icon: 'el-icon-success',
            isDisabled: false,
            with: 165,
            status: [3],
            btnName: '去查看',
            clickFun: () => {
              this.concatActivity()
            }
          },
          {
            describe: '步骤二:已启用客户旅程',
            icon: 'el-icon-success',
            with: 165,
            isDisabled: false,
            status: [3],
            btnName: '去停用',
            clickFun: () => {
              this.handleClose(-1)
            }
          },
          {
            describe: '步骤一:已关联营销活动',
            icon: 'el-icon-success',
            isDisabled: false,
            with: 165,
            status: [4],
            btnName: '去查看',
            clickFun: () => {
              this.concatActivity()
            }
          },
          {
            describe: '步骤二:已停用客户旅程',
            icon: 'el-icon-success',
            with: 165,
            isDisabled: true,
            status: [4],
            btnName: '已停用'
          }
        ],
        2: [
          {
            describe: '客户旅程 未开启',
            icon: 'el-icon-warning',
            isDisabled: false,
            with: 115,
            status: [1, 2],
            btnName: '去启用',
            clickFun: () => {
              this.haneldOpenQY()
            }
          },
          {
            describe: '客户旅程 已开启',
            icon: 'el-icon-success',
            isDisabled: false,
            status: [3],
            with: 115,
            btnName: '去停用',
            clickFun: () => {
              this.handleClose(-1)
            }
          },
          {
            describe: '客户旅程 已停用',
            icon: 'el-icon-warning',
            isDisabled: true,
            with: 115,
            status: [4],
            btnName: '已停用'
          }
        ]
      }
    }
  },
  mounted() {
    this.statusList = this.activityType[2]
    const query = this.$route.query
    this.query = query
    this.getDetail()
  },
  methods: {
    getDetail(order) {
      this.$apis.journeyConfig.getInstIdDetail({ instId: this.query.instId }).then(res => {
        console.log(res,'res')
        const instParam = JSON.parse(res.instParam)
        this.dataTypeCode = instParam.dataTypeCode
        this.noConfig = false
        //xbpzj 关联续保膨胀金
        if (this.dataTypeCode == 'xbpzj') {
          this.statusList = this.activityType[1]
        } else {
          this.statusList = this.activityType[2]
        }
        const stages = instParam.stages
        const instStatus = res.instStatus
        this.activityInfo = instParam.customData
        const activityId = this.activityInfo.activityId
        if (instStatus == 0 && !activityId) {
          this.journeyStatus = 1
        }
        if (instStatus == 0 && activityId) {
          this.journeyStatus = 2
        }
        if (instStatus == 1) {
          this.journeyStatus = 3
        }
        if (instStatus == -1) {
          this.journeyStatus = 4
        }
        const nodes = res.nodes.filter(item=>item.nodeSkip!=1)
        const configList = []
        for (let k in stages) {
          let list = []
          for (let v of nodes) {
            if (v.nodeParam && JSON.parse(v.nodeParam).stage == stages[k].value) {
              list.push({ ...JSON.parse(v.nodeParam), nodeId: v.instNodeId, nodeProtoId: v.nodeProtoId })
            }
          }
          list = list.filter(item => item.day)
          list.sort((a, b) => {
            return a.day - b.day
          })
          list.forEach(i => {
            if ([5, 7, 8, 9, 10].includes(i.taskType) && !i.taskParam) {
              this.noConfig = true
            }
          })
          if (stages[k].conditions && this.dataTypeCode == 'xbpzj') {
            stages[k].conditions.forEach(con => {
              const condition = con.conditions.filter(i => i.isHide)
              if (condition.length && condition.length == 1) {
                if (!condition[0].operators[0].value) {
                  this.noConfig = true
                }
              }
            })
          }

          const sopList = this.groupBy(list, 'day')
          configList.push({
            order: k,
            label: stages[k].value,
            isExpaned: order == k ? true : false,
            editable: stages[k].editable,
            conditionsList: stages[k].conditions || [],
            sopList,
            instStatus
          })
        }
        this.configList = configList
      })
    },
    async openAllConfig() {
      const supMerchantNo = await this.$apis.journeyConfig.authorizeMerchant({ merchantId: this.$globalState.session.merchantId })
      await this.$apis.journeyConfig.concatActivity({ instId: this.query.instId, data: { supMerchantNo } })
      this.setSopInsts(1)
    },
    async haneldOpenQY() {
      if (this.noConfig) {
        this.handleConfirm('开启提示', '确定', '请完善进入条件及SOP任务后,再启动客户旅程。', '', () => {
          // this.openAllConfig()
        })
      } else {
        this.openAllConfig()
      }
    }
  }
}