// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import * as echarts from 'echarts'
import dataV from '@jiaminghi/data-view'
import request, { instance2 as request2 } from '@/utils/request.js'
// 语音提醒
// 百度语音播报
import scroll from 'vue-seamless-scroll'

Vue.use(scroll)
Vue.use(dataV)
Vue.prototype.CreateData1 = function (type, name, data, pageSize, pageList) {
  var paramStr = ''
  var paramarray = []
  if (type === '7') {
    data.map(v => {
      pageSize.map(h => {
        const val = h.toString()
        if (!v[val]) {
          this.$set(v, val, '')
        }
      })
    })
    paramStr = data
  } else {
    if (data !== undefined) {
      for (let i = 0; i < data.length; i++) {
        paramarray.push({
          name: data[i][0],
          value: data[i][1],
          type: data[i][2],
          output: data[i][3]
        })
      }
      paramStr = JSON.stringify(paramarray)
    }
  }
  var obj = []
  obj[0] = {}
  obj[0].type = type
  obj[0].name = name
  obj[0].param = paramStr
  obj[0].pageSize = pageSize
  obj[0].pageList = pageList
  var numn = JSON.stringify(obj[0])
  return numn
}
// 新通讯格式
Vue.prototype.CreateData = (cmd, tbname, fieldshow, other) => {
  const Param = JSON.stringify({
    cmd,
    tbname,
    fieldshow,
    ...other
  })
  const data = {
    type: 3001,
    Param,
    Name: '',
    Pagination: '',
    UserID: '',
    HasReturn: false

  }
  return JSON.stringify(data)
}
// 新通讯11/12---<
Vue.prototype.ExecDatabase = function (num) {
  return request({
    url: '',
    method: 'post',
    data: num
  })
}
// 使用 url2 的请求方法
Vue.prototype.ExecDatabase2 = function (num) {
  return request2({
    url: '',
    method: 'post',
    data: num
  })
}

Vue.use(dataV)
Vue.prototype.$echarts = echarts
Vue.prototype.$request = request
Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
