export default {
  install(Vue) {
    Vue.prototype.CreateData = function(type, name, data, pageSize, pageList) {
      var param_Str = ''
      var param_array = []
      if (type === '7') {
        data.map(v => {
          pageSize.map(h => {
            const val = h.toString()
            if (!v[val]) {
              this.$set(v, val, '')
            }
          })
        })
        param_Str = data
      } else if (data !== undefined) {
        for (let i = 0; i < data.length; i++) {
          param_array.push({
            name: data[i][0],
            value: data[i][1],
            type: data[i][2],
            output: data[i][3]
          })
        }
        param_Str = JSON.stringify(param_array)
      }

      var obj = []
      obj[0] = {}
      obj[0].type = type
      obj[0].name = name
      obj[0].param = param_Str
      obj[0].pageSize = pageSize
      obj[0].pageList = pageList
      obj[0].UserID = this.id
      return JSON.stringify(obj[0])
    }
  }
}
