// components/filter/filter.ts
import { parseTime, optionsFilter, splitDates, hideInformation } from '../../utils/index'
Component({
  options: {
    styleIsolation: "shared"
  },
  /**
   * 组件的属性列表
   */
  properties: {
    type: {
      type: String,
      observer() {
        this.initData()
      }
    },
    value: {
      type: String,
      observer() {
        this.initData()
      }
    },
    params: {
      type: Array,
      value: [],
      observer() {
        this.initData()
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    funs: { parseTime, optionsFilter, splitDates, hideInformation },
    _value: ''
  },

  lifetimes: {
    ready() {
      this.initData()
    }
  },

  /**
   * 组件的方法列表
   */
  methods: {
    initData() {
      const { type, value, params, funs } = this.data
      this.setData({
        // @ts-ignore
        _value: funs[type](value, ...params)
      })
    }
  }
})
