<template>
  <s-code-editor v-model="textJSON" lang="json"></s-code-editor>
  <s-group-table
    :select="false"
    index="序号"
    v-model:data="tableData"
    :columns="columns"
  >
    <template #jd>111</template>
    <template #wd>2222</template>
  </s-group-table>
</template>
<script lang="ts" setup>
import { computed, ref } from 'vue'

const textJSON = computed({
  get () {
    return JSON.stringify(tableData.value, null, '\t')
  },
  set (value) {
    tableData.value = JSON.parse(value)
  }
})

const tableData = ref([
  { zoom: 1, pitch: 2, jd: 1, wd: 2 },
  { zoom: 1, pitch: 2, jd: 1, wd: 2 }
])

const columns = ref([
  {
    label: 'zoom',
    key: 'zoom',
    props: {
      formatter (row, col, val) {
        return val + 1
      }
    }
  },
  {
    label: '倾斜度',
    key: 'pitch'
  },
  {
    label: '中心',
    key: 'center',
    type: 'group',
    props: {
      mode: 'array',
      size: 'small',
      grid: {
        span: 4
      }
    },
    children: [
      {
        label: '经度',
        type: 'slot',
        key: 'jd'
      },
      {
        label: '纬度',
        type: 'slot',
        key: 'wd'
      }
    ]
  }
])

function changeValue (key: string, value: any) {
  console.log(key, value)
}
</script>
