// import axios from 'axios'
import API from '@/utils/sha256/myHttpClient'
// import config from 'list.js'
const baseComponents = {
  data() {
    return {
      isTableDemo1: false,
      tableData1: {
        config: {},
        sourceData: []
      },
      tableData2: {
        config: {},
        sourceData: []
      },
      tableData3: {
        config: {},
        sourceData: []
      },
      tableData4: {
        config: {},
        sourceData: []
      },
      tableData5: {
        config: {},
        sourceData: []
      },
      tableData6: {
        config: {},
        sourceData: []
      },
      tableData7: {
        config: {},
        sourceData: []
      },
      tableData8: {
        config: {},
        sourceData: []
      },
      tableData9: {
        config: {},
        sourceData: []
      }
    }
  },
  mounted() {
    this.setData()
  },
  methods: {
    getAllData(routerParms = {}) {
    },
    getAllConfigAndData() {
    },
    setData() {
      // var this_list = []
      if (!this.searchParams.style_code) {
        this.searchParams.style_code = ''
      }
      const url = `TOOLAPI/web_query/query/`
      // EXEC dbo.spimOrderGoodsInquiry_V @sStyleCode='307926'，@bMock=1
      const postData = {
        exec_sql: `EXEC dbo.spimOrderGoodsInquiry_V @sStyleCode='${this.searchParams.style_code}', @bMock=0`,
        'db_name': 'HsGmtMES'
      }
      //   'db_name': 'hsMEP',
      //   `EXEC dbo.spimOrderGoodsInquiry_V @sStyleCode='307926'`
      API.post(url, {}, {}, postData).then(res => {
        // this_list = res.data
        this.tableData1.sourceData = res.data
        // this.tableData1.config = JSON.parse(this.tableData1.config)
        console.log(res.data)
        var indexArr = []
        var styleArr = []
        for (const i in res.data) {
          if (res.data[i].是否锁定 === '是') {
            console.log(i)
            indexArr.push(Number(i))
            styleArr[i] = { 'background': 'green' }
          }
        }
        console.log(indexArr, styleArr)
        this.tableData1.config = {
          'tableStyle': {
            'color': '#000',
            'font-size': '.14rem',
            'background': '#fff',
            'width': '100%'
          },
          'row': {
            'allStyle': {},
            'indexArr': indexArr,
            'styleArr': styleArr
          },
          'setWidth': {
            'styleArr': ['100px', '100px', '100px', '100px', '100px']
          },
          // 'hover': {
          //   'hoverBackground': '#ccc',
          //   'leaveBackground': '#fff'
          // },
          'showTooltip': true
        }
      })
      console.log(this.tableData1)
    },
    saveConfigData(routerParms, config, data, sql, is_mock) {
      // this.$API.runSave(routerParms, config, data, sql, is_mock)
    }
  }
}
export default baseComponents
