combiFormConfig.js 3.35 KB
let _this = null
const defaultFormData = {
  sopJourneyStage: ''
}
import * as dayjs from 'dayjs'

export default {
  created() {
    _this = this
  },
  data() {
    return {
      refreshTime: '',
      searchForm: {
        ...defaultFormData
      },
      searchSelectObj: {
        keyword: {
          attr: 'customerPhone',
          value: ''
        }
      },
      searchFormData: [
        {
          label: '旅程',
          name: 'sopJourneyId',
          type: 'select',
          labelWidth: 56,
          optionList: [],
          optionId: 'instId',
          optionLabel: 'instName',
          changeAttr: e => {
            this.getStage(e)
          }
        },
        {
          label: '旅程阶段',
          name: 'sopJourneyStage',
          type: 'select',
          labelWidth: 56,
          optionList: [],
          optionId: 'value',
          optionLabel: 'label'
        },
        {
          type: 'selectInput',
          selectName: 'keyword',
          isClear: true,
          inputWidth: '320px',
          selectWidth: '110px',
          selectOption: [
            {
              label: '客户电话',
              name: 'customerPhone'
            },
            {
              label: '客户姓名',
              name: 'customerName'
            },
            {
              label: '微信昵称',
              name: 'wechatNickname'
            }
          ],
          handleSelectChange(value) {
            _this.searchSelectObj.keyword.value = ''
          }
        },
        {
          label: '跟进人',
          name: 'sopFollowUpPersonPhone',
          type: 'select',
          labelWidth: 56,
          optionList: [],
          optionId: 'confId',
          optionLabel: 'confName'
        },
        {
          label: '进入旅程时间',
          name: 'time',
          type: 'datePicker',
          labelWidth: 72,
          isClear: true,
          customPickerOptions: {
            disabledDate(val) {
              let disabled = true,
                startTime = dayjs().subtract(1, 'year'),
                endTime = dayjs(),
                date = dayjs(val)
              if (startTime < date && dayjs(date) < endTime) disabled = false
              return disabled
            }
          }
        }
      ],
      stageList: [],
      tableSearchForm: {
        ...defaultFormData
      }
    }
  },
  watch: {
    // watchJourney: {
    //   immediate: true,
    //   handler (newval) {
    //     //清空旅程阶段并调用旅程阶段接口
    //     console.log(newval)
    //   }
    // },
    'searchForm.a'(newval) {
      //清空旅程阶段并调用旅程阶段接口
      console.log(newval, 'a')
    }
  },
  // computed: {
  //   watchJourney () {
  //     return this.searchForm.a
  //   }
  // },
  methods: {
    getStage(e) {
      console.log(_this.searchFormData)
      const step = _this.searchFormData.find(i => i.name === 'sopJourneyStage')
      let optionList = _this.journeyList.find(i => i.instId == e).journeyItem
      step.optionList = optionList
      this.stageList = step.optionList
      console.log(this.stageList)
    },
    getSelectInputParams() {
      const list = Object.keys(this.searchSelectObj)
      var params = {}
      list.forEach(i => {
        const item = this.searchSelectObj[i]
        item.value && (params[item.attr] = item.value)
      })
      return params
    }
  }
}