<!--
 * @Description: 
 * @Author: Format-qi 283810417@qq.com
 * @Date: 2022-06-30 10:28:40
 * @LastEditors: Format-qi 283810417@qq.com
 * @LastEditTime: 2022-06-30 10:31:20
-->
<template>
  <BzPageWrapper title="富文本嵌入表单示例">
    <BzCollapseContainer title="富文本表单">
      <BzForm
        :labelWidth="100"
        :schemas="schemas"
        :actionColOptions="{ span: 24 }"
        :baseColProps="{ span: 24 }"
        @submit="handleSubmit"
      />
    </BzCollapseContainer>
  </BzPageWrapper>
</template>
<script lang="ts">
  import { defineComponent, h } from 'vue';
  import { BzForm, FormSchema } from '/@/index';
  import { BzCollapseContainer } from '/@/index';
  import { useMessage } from '/@/index';
  import { BzTinymce } from '/@/index';
  import { BzPageWrapper } from '/@/index';

  const schemas: FormSchema[] = [
    {
      field: 'title',
      component: 'Input',
      label: 'title',
      defaultValue: 'defaultValue',
      rules: [{ required: true }],
    },
    {
      field: 'tinymce',
      component: 'Input',
      label: 'tinymce',
      defaultValue: 'defaultValue111',
      rules: [{ required: true }],
      render: ({ model, field }) => {
        return h(BzTinymce, {
          value: model[field],
          onChange: (value: string) => {
            model[field] = value;
          },
        });
      },
    },
  ];
  export default defineComponent({
    components: { BzForm, BzCollapseContainer, BzPageWrapper },
    setup() {
      const { createMessage } = useMessage();

      return {
        schemas,
        handleSubmit: (values: any) => {
          createMessage.success('click search,values:' + JSON.stringify(values));
        },
      };
    },
  });
</script>
