<template>
  <div class="new-app-container layout-vertical">
    <YMTableSearch :loading="loading" :search-form="searchForm" @onValueChange="onValueChange" @submit="onSubmit" />
    <YMTable
      ref="table"
      :table-key="1"
      :index="true"
      :selection="false"
      :table-options="tableOptions"
      :edit-form="editForm"
      :edit-config="editConfig"
      :columns="columns"
      :rows-actions="rowsActions"
      :show-summary="false"
      :apis="apis"
      :custom-style="{ height: 'calc(100vh - 170px)' }"
    />
    <!-- 自定义弹窗 -->
    <Dialog ref="dialog">
      <template slot="content" />
    </Dialog>
  </div>
</template>
<script>
import Dialog from '@/components/Dialog/index.vue'

export default {
  components: {
    Dialog
  },
  data() {
    return {
      loading: false,
      visibleBasicDrawer: false,
      renderContent: '',
      searchForm: [
        {
          label: '模板模板',
          type: 'input',
          prop: 'xxxx',
          clearable: false
        },
        {
          label: '模板模板',
          type: 'input',
          prop: 'xxxx',
          clearable: false
        },
        {
          label: '勿删',
          type: 'select',
          prop: 'xxxx',
          clearable: false,
          options: [
            {
              value: 0,
              label: '否'
            },
            {
              value: 1,
              label: '是'
            }
          ]
        }
      ],
      columns: [
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: 'xxxx',
          prop: 'xxxx'
        },
        {
          label: '更新时间',
          prop: 'updated_at'
        },
        {
          label: '创建时间',
          prop: 'created_at'
        }
      ],
      rowsActions: [
        {
          key: 'edit',
          label: '编辑'
        },
        {
          key: 'delete',
          label: '删除'
        }
      ],
      apis: {
        list: {
          url: 'user/user',
          dataParam: 'data.data',
          resultParam: 'data',
          init: false
        },
        add: {
          url: '',
          cover: true,
          coverMethod: (row, node) => {
            return row.year + '、' + node[0].label
          }
        },
        edit: {
          url: '',
          cover: true,
          coverMethod: (row, node) => {
            return row.year + '、' + node[0].label
          }
        }
      },
      tableOptions: {},
      editForm: [],
      editConfig: {
        addTip: '注：备注',
        editTip: '注：备注'
      }
    }
  },
  created() {
  },
  mounted() {
    this.onSubmit()
  },
  methods: {
    handleSubmit(formData) {
      console.log('提交数据:', formData)
      // 调用API提交数据
    },
    handleClickDrawer(row) {

    },
    onValueChange(val) {

    },
    onSubmit(params) {
      this.$refs.table.getList(params)
    }
  }
}
</script>
