<script setup lang="ts">
import type { BasicForm, ICRUD } from '@/types/form'
import { getVersionList, saveVersion, deleteVersion } from '@/api/miniprogram'

const CRUD: ICRUD = {
  create(data) {
    return saveVersion(data)
  },
  update(data) {
    return saveVersion(data)
  },
  getList(data) {
    return getVersionList(data).then((res: any) => {
      return {
        list: res
      }
    })
  },
  delete(data) {
    return deleteVersion({
      ids: data.id
    })
  }
}

const formConfig = reactive<BasicForm>({
  span: 24,
  formItems: [
    {
      label: '版本号',
      value: '',
      name: 'number',
      type: 'input',
      rules: [{ required: true, message: '请输入版本号', trigger: 'blur' }]
    },
    {
      label: '标题',
      value: '',
      name: 'title',
      type: 'input'
    },
    {
      label: '内容',
      value: '',
      name: 'content',
      type: 'editor',
      rules: [{ required: true, message: '请输入内容', trigger: 'blur' }]
    },
    {
      label: '发布日期',
      value: '',
      name: 'publishDate',
      type: 'date-picker',
      props: {
        type: 'date'
      }
    }
  ]
})
</script>

<template>
  <pro-table :crud="CRUD" :formConfig="formConfig">
    <vxe-column field="number" title="版本号"></vxe-column>
    <vxe-column field="title" title="标题"></vxe-column>
    <vxe-column field="publishDate" title="发布日期"></vxe-column>
  </pro-table>
</template>

<style lang="scss" scoped></style>
