<%_
const oneToOneNotOwnerSide =[];
let hasUseJPADerivedIdentifier = false;
const { formFieldLines, showInOneRelationships, showInOneImportComponents } = (bcEntityData || { formFieldLines: [], showInOneRelationships: [], showInOneImportComponents: {}});
const showInOneEditByTable = showInOneRelationships.filter(rel => {
  if (rel.source && rel.source.annotationOnSource && rel.source.annotationOnSource.includes('editByList')) {
    return false;
  }
  if (rel.source && rel.source.annotationOnSource && rel.source.annotationOnSource.includes('editByFormList')) {
    return false;
  }
  return !(rel.source && rel.source.annotationOnSource && rel.source.annotationOnSource.includes('editByDescList'));
});
let importStatements = [];
if (showInOneEditByTable && showInOneEditByTable.length) {
  showInOneEditByTable.forEach(rel => {
    const sortFields = rel.otherEntity.fields.filter(field => field.options && field.options.sortField);
    if (sortFields && sortFields.length) {
      importStatements.push(`import Sortable from 'sortablejs';`);
      importStatements.push(`import { VxeTableInstance } from 'vxe-table';`);
    }
  });
}
_%>
<script lang="tsx">
  import { getCurrentInstance, reactive, computed, defineComponent, h, ref, resolveComponent, Component, nextTick, onUnmounted } from 'vue';
  import { useRoute, useRouter } from 'vue-router';
  import { message, Space, Tabs, TabPane, CollapsePanel, Collapse, Card } from 'ant-design-vue';
  import { isBoolean, isFunction } from 'lodash-es';

<%_ if (!useCommonTable) { _%>
  import config from './config/edit-config';
<%_ } _%>
  import { <%= entityAngularName %>, I<%= entityAngularName %> } from '@/models/<%= entityModelFileName %>.model';

<%_ if (useCommonTable) { _%>
  import { generateDataForDesigner } from '@/utils/jhipster/entity-form-utils';
<%_ } _%>
  import ServerProvider from '@/api-service/index';
  import { BasicForm, Button, Icon, PageWrapper } from '@begcode/components';
<%_ if (showInOneRelationships && showInOneRelationships.length) { _%>
  import { getButtonConfig } from '@begcode/components';
<%_ } _%>
<%_ if (showInOneRelationships && showInOneRelationships.length && useCommonTable) { _%>
  import { xGenerateTableColumns } from '@/utils/jhipster/entity-list-utils';
<%_ } _%>
  import { useGo } from '@/hooks/web/usePage';
  import { useMultipleTabStore } from '@/store/modules/multipleTab';
<%_ if (showInOneImportComponents && Object.keys(showInOneImportComponents).length) { _%>
  <%_ Object.values(showInOneImportComponents).forEach(importLine => { _%>
<%- importLine %>
  <%_ });_%>
<%_  } _%>
<%_ if (importStatements && importStatements.length) { _%>
  <%_ importStatements.forEach(importLine => { _%>
<%- importLine %>
<%_ });} _%>
<%_ if (addCustomMethod.indexOf('updateTemplate') !== -1) { _%>
  <%- include(`../common/entity-custom/${entityClass}.updateTemplate.ejs`, {position: 'import'}); -%>
<%_ } _%>
<%_ let apiModuleName = this._.camelCase(clientRootFolder || microserviceName); _%>

  export default defineComponent({
    // begcode-please-regenerate-this-file 如果您不希望重新生成代码时被覆盖，将please修改为don't ！！！
    name: '<%= this._.upperFirst((moduleName || clientRootFolder) ? (moduleName || clientRootFolder) + entityAngularName : entityAngularName) %>Edit',
    props: {
      entityId: {
        type: [String, Number] as PropType<string | number>,
        default: '',
      },
      containerType: {
        type: String,
        default: 'router',
      },
      baseData: {
        type: Object,
        default: () => ({}),
      },
      savedOpen: {
        type: Boolean,
        default: false,
      },
    },
    components: {
      BasicForm,
      <%_ showInOneImportComponents && Object.keys(showInOneImportComponents).forEach(componentName => { _%>
      <%= componentName %>,
      <%_ }); _%>
    },
    async setup(props) {
      const ctx = getCurrentInstance()?.proxy;
      const apiService = ctx?.$apiService as typeof ServerProvider;
      const relationshipApis: any = {
        <%_ for (relationship of relationships) {
        const relationApiModuleName = this._.camelCase(relationship.otherEntity.clientRootFolder || relationship.otherEntity.microserviceName);
        _%>
        <%= relationship.relationshipName %>: apiService<%= relationApiModuleName ?  '.' + relationApiModuleName : ''%>.<%= relationship.otherEntity.entityInstance%>Service.<%= relationship.otherEntity.fieldsContainParentAndChildren ? 'tree' : 'retrieve'%>,
        <%_ } _%>
      };
      const route = useRoute();
      const router = useRouter();
      const go = useGo();
      const tabStore = useMultipleTabStore();
      const activeNames = ref<any[]>([]);
      const handleChange = (val: any[]) => {
        activeNames.value = val;
        ctx?.$emit('change', activeNames.value);
      };
      let <%= entityInstance %>Id = ref('');
      if (props.containerType === 'router') {
        <%= entityInstance %>Id.value = route.params?.entityId as string;
      } else {
        <%= entityInstance %>Id.value = props.entityId as string;
      }
      const <%= entityInstance %> = ref<I<%= entityAngularName %>>(new <%= entityAngularName %>());
      <%= entityInstance %>.value = Object.assign(<%= entityInstance %>.value, props.baseData);
      if (<%= entityInstance %>Id.value) {
        const data = await apiService.<%= apiModuleName ? apiModuleName + '.' : '' %><%= entityInstance %>Service.find(<% if (tsKeyType === 'number') { %>Number(<%= entityInstance %>Id.value) <% } else { %><%= entityInstance %>Id.value<% } %>);
        if (data) {
          <%= entityInstance %>.value = Object.assign(<%= entityInstance %>.value, data);
        }
      }
    <%_ if (useCommonTable) { _%>
      const commonTableData = await apiService.modelConfig.commonTableService.findByEntityName('<%= entityNameCapitalized %>');
      const formItemsConfig = generateDataForDesigner(commonTableData!);
    <%_ } else { _%>
      const formItemsConfig = config.fields();
    <%_ } _%>
<%_ if (addCustomMethod.indexOf('editComponent') !== -1) { _%>
<%- include(`../common/entity-custom/${entityClass}.editComponent.ejs`, {position: 'fieldsConfig'}); -%>
<%_ } _%>
      const submitButtonTitlePrefix = <%= entityInstance %>Id.value ? '更新' : '保存';
      const saveOrUpdateApi = <%= entityInstance %>Id.value
        ? apiService.<%= apiModuleName ? apiModuleName + '.' : '' %><%= entityInstance %>Service.update
        : apiService.<%= apiModuleName ? apiModuleName + '.' : '' %><%= entityInstance %>Service.create;
      const saveOrUpdate = () => {
        validate()
          .then(result => {
            if (result) {
              <%= entityInstance %>.value = Object.assign(<%= entityInstance %>.value, result);
              <%_ if (addCustomMethod.indexOf('updateTemplate') !== -1) { _%>
              <%- include(`../common/entity-custom/${entityClass}.updateTemplate.ejs`, {position: 'before-save'}); -%>
              <%_ } _%>
              saveOrUpdateApi(<%= entityInstance %>.value)
                .then(res => {
                  <%= entityInstance %>.value = Object.assign(<%= entityInstance %>.value, res);
                  <%= entityInstance %>Id.value = <%= entityInstance %>.value.id + '';
                  message.success(submitButtonTitlePrefix + '成功！');
                  if (props.containerType === 'router') {
                    const { fullPath } = route; //获取当前路径
                    tabStore.closeTabByKey(fullPath, router).then(() => {
                    <%_ const moduleNameOrClientRootFolder = clientRootFolder; _%>
                      go('/<%= moduleNameOrClientRootFolder ? (moduleNameOrClientRootFolder + '/') : '' %><%= entityUrl %>/' + <%= entityInstance %>Id.value + '/edit', true);
                    });
                  } else {
                    if (!props.savedOpen) {
                      ctx?.$emit('refresh', { update: true, containerType: props.containerType });
                    }
                    (ctx?.$refs['BASE_ENTITY'] as any).setFieldsValue(<%= entityInstance %>.value);
                  }
                })
                .catch(error => {
                  console.log('error', error);
                  message.error(submitButtonTitlePrefix + '失败！');
                });
            } else {
              message.error('数据验证失败！');
            }
          })
          .catch(error => {
            console.log('error', error);
            message.error('数据验证失败！');
          });
      };
      //获得关联表属性。
    <%_ if (useCommonTable) { _%>
    <%_
    showInOneRelationships.forEach(relationship => { _%>
      const <%= relationship.relationshipName %>Data = await apiService.modelConfig.commonTableService.findByEntityName('<%= relationship.otherEntityNameCapitalized %>');
      const <%= relationship.relationshipName %>Columns = xGenerateTableColumns(<%= relationship.relationshipName %>Data);
      // const <%= relationship.relationshipName %>ColumnsRender = pageControl.<%= relationship.relationshipName %>ColumnsRender();
    <%_
    })
    _%>
    <%_ } _%>
      const pageConfig = reactive<any>({
        active: '0',
        operations: [
          {
            title: '关闭',
            type: 'default',
            theme: 'close',
            skipValidate: true,
            click: async () => {
              if (props.containerType === 'router') {
                  const { fullPath } = route; //获取当前路径
                  await tabStore.closeTabByKey(fullPath, router)
              } else {
                ctx?.$emit('cancel', { containerType: props.containerType, update: false });
              }
            },
          },
          {
            hide: () => {
              return !!<%= entityInstance %>.value.id;
            },
            type: 'primary',
            theme: 'save',
            click: saveOrUpdate,
          },
          {
            hide: () => {
              return !<%= entityInstance %>.value.id;
            },
            theme: 'update',
            type: 'primary',
            click: saveOrUpdate,
          },
        ],
      });
      const isEdit = computed(() => {
        return true;
      });
      const validate = async () => {
        let isValid = true;
        let result = {};
        var refKeys = Object.keys(ctx?.$refs as object);
        for (const refKey of refKeys) {
          const component: any = ctx?.$refs[refKey];
          if (['BASE_ENTITY', 'FormList'].includes(refKey)) {
            if (component && component.validate) {
              const validateResult = await component.validate();
              if (!validateResult) {
                isValid = false;
                break;
              } else {
                result = { ...result, ...validateResult };
              }
            }
          } else {
            if (component && component.validate) {
              const validateResult = await component.validate(true);
              if (!validateResult) {
                const { fullData } = component.getTableData();
                fullData.forEach(row => {
                  if (typeof row.id === 'string' && row.id.startsWith('row_')) {
                    row.id = null;
                  }
                });
                result[refKey] = fullData;
              } else {
                isValid = false;
              }
            }
          }
        }
        if (!isValid) {
          return false;
        } else {
          return result;
        }
      };
      const formGroup = computed(() => [
        {
          title: props.containerType === 'router' ? '<%= bcTitle %>' : null,
          operation: [],
          component: {
            name: 'a-form',
            props: {
              modelName: 'BASE_ENTITY',
              model: <%= entityInstance %>.value,
              labelWidth: '120px',
              fieldMapToTime: [],
              compact: true,
              alwaysShowLines: 1,
              schemas: formItemsConfig,
              // formItemsRender,
              size: 'default',
              disabled: false,
              showAdvancedButton: false,
              showResetButton: false,
              showSubmitButton: false,
              showActionButtonGroup: false,
              resetButtonOptions: {
                type: 'default',
                size: 'default',
                text: '关闭',
                preIcon: null,
              },
              actionColOptions: {
                span: 18,
              },
              submitButtonOptions: {
                type: 'primary',
                size: 'default',
                text: submitButtonTitlePrefix,
                preIcon: null,
              },
              resetFunc: () => {
                ctx?.$emit('cancel', { update: false, containerType: props.containerType });
              },
              submitFunc: saveOrUpdate,
            },
            on: {},
          },
        },
      <%_
        let useDrop = false;
        let sortModelName = '';
      _%>
      <%_ if (showInOneRelationships && showInOneRelationships.length) { _%>
        {
          title: '关联表',
          operation: [],
          component: [
            <%_
            showInOneRelationships.forEach(relationship => { _%>
              <%_ if (relationship.source?.annotationOnSource?.includes('editByList')) { _%>
            {
              name: '<%= relationship.otherEntity.entityNameCapitalized %>List',
              title: '<%= relationship.bcTitle%>列表',
              props: {
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                query: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                query: {<%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value},
                <%_ } _%>
                editIn: 'modal',
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                baseData: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                baseData: { <%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value },
                <%_ } _%>
                gridOptions: {
                  toolbarConfig: {
                    import: true,
                    print: true,
                    export: true,
                  },
                },
                searchFormOptions: {
                  disabled: false,
                  allowSwitch: false,
                },
                gridCustomConfig: {
                  tools: [''],
                  hideOperations: false,
                  hideSlots: [],
                  columnsName: '',
                },
                modelName: '<%= relationship.otherEntity.entityNameCapitalized %>List',
              },
              disabled: () => {
                return !<%= entityInstance %>.value.id;
              },
            },
              <%_ } else　if (relationship.source?.annotationOnSource?.includes('editByFormList')) { _%>
            {
              name: 'FormList',
              title: '<%= relationship.bcTitle%>列表',
              props: {
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                query: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                query: {<%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value},
                <%_ } _%>
                editIn: 'modal',
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                baseData: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                baseData: { <%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value },
                <%_ } _%>
                formConfig: { schemas: config.<%= relationship.relationshipName %>Columns },
                fieldName: '<%= relationship.relationshipName %>',
                fieldData: <%= entityInstance %>.value.<%= relationship.relationshipName %>,
                modelName: 'FormList',
              },
              disabled: () => {
                return !<%= entityInstance %>.value.id;
              },
            },
              <%_ } else　if (relationship.source?.annotationOnSource?.includes('editByDescList')) { _%>
            {
              name: 'DescList',
              title: '<%= relationship.bcTitle%>列表',
              props: {
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                query: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                query: {<%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value},
                <%_ } _%>
                editIn: 'modal',
                <%_ if (relationship.source && relationship.source.annotationOnSource && relationship.source.annotationOnSource.toString().includes('relateByIdEntity')) { _%>
                baseData: { ownerEntityName: '<%= entityClass %>', ownerEntityId: <%= entityInstance %>Id.value },
                <%_ } else { _%>
                baseData: { <%= relationship.otherRelationship.relationshipName%>Id: <%= entityInstance %>Id.value },
                <%_ } _%>
                configData: [
                  {
                    formConfig: config.<%= relationship.relationshipName %>Columns,
                    data: {},
                  }
                ],
                data: <%= entityInstance %>.value.<%= relationship.relationshipName %>,
                savedOpen: true,
                toolButtons: [],
                editComponentPath: '@/views/<%= relationship.otherEntity.entityFolderName%>/<%= relationship.otherEntity.entityFileName%>-edit.vue',
                modelName: 'DescList',
              },
              slots: {
                default: (item) => {
                  return h(<%= relationship.otherEntity.entityNameCapitalized %>Desc, {entityId: item.id}, () => []);
                }
              },
              disabled: () => {
                return !<%= entityInstance %>.value.id;
              },
            },
              <%_ } else { _%>
              <%_
                const sortFields = relationship.otherEntity.fields.filter(field => field.options && field.options.sortField);
                sortModelName = relationship.relationshipName;
              _%>
            {
              name: 'vxe-grid',
              title: '<%= relationship.bcTitle%>列表',
              props: {
                modelName: '<%= relationship.relationshipName%>',
                data: <%= entityInstance %>.value.<%= relationship.relationshipName%>,
                columns: <%= useCommonTable ? '' : 'config.'%><%= relationship.relationshipName%>Columns(),
                border: true,
                showOverflow: true,
                editConfig: {
                  trigger: 'click',
                  mode: 'row',
                  beforeEditMethod({ row, rowIndex, column, columnIndex }) {
                    console.log('beforeEditMethod', row, rowIndex, column, columnIndex);
                    return true;
                  },
                },
                <%_
                  if (sortFields && sortFields.length > 0) {
                  useDrop = true;
                _%>
                rowConfig: {
                  useKey: true
                },
                <%_ } _%>
                onEditClosed: ({ $table, row, column }) => {
                  console.log('$table', $table);
                  if ($table.isUpdateByRow(row)) {
                    row.loading = true;
                    apiService.<%= apiModuleName ? apiModuleName + '.' : '' %><%= entityInstance %>Service
                      .update({ id: row.id, [column.field]: row[column.field] }, [row.id], [column.field])
                      .then(data => {
                        $table.reloadRow(row, data, column.field);
                        message.success('保存成功！');
                      })
                      .finally(() => {
                        row.loading = false;
                      });
                  }
                },
                fieldMapToTime: [],
                compact: true,
                size: 'default',
                disabled: !isEdit.value,
                toolbarConfig: {
                  buttons: [
                    { code: 'insert_actived', name: '新增', icon: 'fa fa-plus' },
                    { code: 'remove', name: '删除', icon: 'fa fa-trash-o' },
                  ],
                  // 表格右上角自定义按钮
                  tools: [
                    // { code: 'myPrint', name: '自定义打印' }
                  ],
                  import: false,
                  export: false,
                  print: false,
                  custom: false,
                },
              },
              slots: {
                <%_ if (sortFields && sortFields.length > 0) { _%>
                dragBtn: () => {return h('span', { class: 'drag-btn' }, h('i', { class: 'vxe-icon-sort' }, []))},
                dragTip: () => {return h('span', {}, ['拖动'])},
                <%_ } _%>
              },
            },
              <%_ } _%>
            <%_
            });
            _%>
          ],
        },
      <%_ } _%>
      ]);
    <%_ if (useDrop) { _%>
      let sortable1: any;

      const rowDrop = () => {
        const $table = ctx?.$refs['<%= sortModelName %>'] as VxeTableInstance;
        sortable1 = Sortable.create($table.$el.querySelector('.body--wrapper>.vxe-table--body tbody'), {
          handle: '.drag-btn',
          onEnd: (sortableEvent) => {
            const newIndex = sortableEvent.newIndex as number
            const oldIndex = sortableEvent.oldIndex as number
            // const currRow = demo1.tableData.splice(oldIndex, 1)[0]
            // demo1.tableData.splice(newIndex, 0, currRow)
          }
        })
      }
      let initTime: any
      onUnmounted(() => {
        clearTimeout(initTime)
        if (sortable1) {
          sortable1.destroy()
        }
      });
      await nextTick(() => {
        // 加载完成之后在绑定拖动事件
        initTime = setTimeout(() => {
          rowDrop()
        }, 500)
      });
    <%_ } _%>
    <%_ if (showInOneRelationships && showInOneRelationships.length) { _%>
      const getXGridSlots = component => {
      const slots: any = {};
      if (component.recordActions) {
        const buttons = reactive(component.recordActions.map(action => getButtonConfig(action)));
        buttons.filter(button => button.icon).forEach(button => (button.slots = { default: () => <Icon icon={button.icon} /> }));
        buttons.filter(button => !button.icon).forEach(button => (button.slots = { default: () => button.text }));
        slots.recordAction = row => (
          <div>
            <Space>
              {buttons.map(button => {
                return (
                  <Button
                    {...{
                      type: button.type || 'primary',
                      shape: button.shape || 'circle',
                      title: button.text || button.name,
                      onClick: () => {
                        if (button.onClick) {
                          button.onClick(row.row, button.name);
                        } else {
                          console.log(button.name, 'onClick事件未定义！');
                        }
                      },
                    }}
                    v-slots={button.slots}
                  ></Button>
                );
              })}
            </Space>
          </div>
        );
      } else {
        slots.recordAction = () => <div />;
      }
      if (component.slots) {
        Object.assign(slots, component.slots)
      }
      return slots;
    };
    <%_ } _%>
      const formSlots = () => [];
      const renderChild = () => {
        const wrapperPros: any = {};
        if (!pageConfig?.canExpand) {
          wrapperPros.bordered = false;
          wrapperPros.size = 'small';
        }
        return formGroup.value.map(item => {
          var componentRef = item.component;
          if (componentRef && !(componentRef instanceof Array)) {
            if (componentRef.name === 'a-form') {
              if (pageConfig?.canExpand) {
                // @ts-ignore
                return h(CollapsePanel, {}, h(BasicForm, { ...componentRef.props, ref: componentRef.props.modelName }, formSlots));
              } else {
                // @ts-ignore
                return h(BasicForm, { ...componentRef.props, ref: componentRef.props.modelName }, formSlots);
              }
            } else {
              const component = resolveComponent(componentRef.name);
              return h(
                pageConfig?.canExpand ? CollapsePanel : Card,
                { ...wrapperPros },
                () => h(component, { ...componentRef.props, ref: componentRef.props.modelName }, () => []),
              );
            }
          } else if (componentRef && componentRef instanceof Array) {
            return h(
              pageConfig?.canExpand ? CollapsePanel : Card,
              { ...wrapperPros },
              () => h(
                Tabs,
                {},
                () => componentRef.map((child, index) => {
                  const childComponent: Component = resolveComponent(child.name) as Component;
                  return h(
                    TabPane,
                    { tab: child.title || index, key: index, disabled: child.disabled && child.disabled() },
                    () => child.disabled && child.disabled()? [] : [h(
                      childComponent,
                      { ...child.props, ref: child.props.modelName },
                      <% if (showInOneRelationships && showInOneRelationships.length) { %>child?.name === 'vxe-grid' ? getXGridSlots(child) : (child.slots || {})<% } else { %>() => (child.slots || {})<% } %>)])
                }),
              ),
            );
          } else {
            return <div>无内容</div>;
          }
        });
      };
      const slots: any = {
        rightFooter: () => (
          <div>
            <Space>
              {pageConfig.operations.map((operation: any) => {
                const buttonSlots: any = {};
                if (operation.icon) {
                  buttonSlots.icon = () => <Icon icon={operation.icon} />;
                }
                if (operation.text) {
                  buttonSlots.default = () => operation.text;
                }
                const hideButton = isBoolean(operation.hide) ? operation.hide : isFunction(operation.hide) ? operation.hide() : false;
                switch (operation.theme) {
                  case 'save':
                    if (!buttonSlots.icon) {
                      buttonSlots.icon = () => <Icon icon={'ant-design:save-outlined'} />;
                    }
                    if (!buttonSlots.default) {
                      buttonSlots.default = () => '保存';
                    }
                    return hideButton ? (
                      <span />
                    ) : (
                      <Button
                        {...{
                          type: operation.type || 'default',
                          onClick: () => {
                            validate().then(result => {
                              operation.click(result);
                            });
                          },
                        }}
                        v-slots={buttonSlots}
                      ></Button>
                    );
                  case 'update':
                    if (!buttonSlots.icon) {
                      buttonSlots.icon = () => <Icon icon={'ant-design:check-outlined'} />;
                    }
                    if (!buttonSlots.default) {
                      buttonSlots.default = () => '更新';
                    }
                    return hideButton ? (
                      <span />
                    ) : (
                      <Button
                        {...{
                          type: operation.type || 'default',
                          onClick: () => {
                            validate().then(result => {
                              operation.click(result);
                            });
                          },
                        }}
                        v-slots={buttonSlots}
                      ></Button>
                    );
                  default:
                    return hideButton ? (
                      <span />
                    ) : (
                      <Button
                        {...{
                          type: operation.type || 'default',
                          onClick: () => {
                            if (operation.skipValidate) {
                            operation.click();
                          } else {
                            validate().then(result => {
                              operation.click(result);
                            });
                          }
                          },
                        }}
                      >
                        {operation.title}
                      </Button>
                    );
                }
              })}
            </Space>
          </div>
        ),
        default: () => {
          if (pageConfig?.canExpand) {
            return (
              <div>
                <Collapse value={activeNames} onchange={handleChange} v-slots={{ default: () => renderChild() }} />
              </div>
            );
          } else {
            if (props.containerType === 'router') {
              return (
                <div>
                  <Card
                          {...{
                            props: {
                              shadow: 'never',
                            },
                            bordered: false,
                            size: 'small',
                          }}
                          v-slots={{
                            title: () => h(Button, { preIcon: 'ant-design:form-outlined', type: 'link'}, () => [<%= entityInstance %>Id.value ? '编辑<%= bcTitle %>' : '新增<%= bcTitle %>']),
                            default: () => renderChild(),
                          }}
                  ></Card>
                </div>
              );
            } else {
              return renderChild();
            }
          }
        },
      };
<%_ if (addCustomMethod.indexOf('updateTemplate') !== -1) { _%>
  <%- include(`../common/entity-custom/${entityClass}.updateTemplate.ejs`, {position: 'field'}); -%>
<%_ } _%>
      return {
        // pageControl,
        <%= entityInstance %>Id,
        saveOrUpdate,
        formGroup,
        pageConfig,
        slots,
        <%_ if (useDrop) { _%>
        rowDrop,
        <%_ } _%>
        <%= entityInstance %>,
<%_ if (addCustomMethod.indexOf('updateTemplate') !== -1) { _%>
  <%- include(`../common/entity-custom/${entityClass}.updateTemplate.ejs`, {position: 'return'}); -%>
<%_ } _%>
      };
    },
    methods: {
<%_ if (addCustomMethod.indexOf('updateTemplate') !== -1) { _%>
<%- include(`../common/entity-custom/${entityClass}.updateTemplate.ejs`, {position: 'method'}); -%>
<%_ } _%>
    },
    render() {
      if (this.containerType === 'modal' || this.containerType === 'drawer') {
        // this.slots.actions = this.slots.rightFooter;
        delete this.slots.rightFooter;
        return <Card {...this.pageConfig} v-slots={this.slots} />;
      } else {
        return (
          <PageWrapper
            {...{
              props: {
                title: this.pageConfig?.title || '编辑',
              },
            }}
            v-slots={this.slots}
          />
        );
      }
    },
  });
</script>
