view_form.hbs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <script lang="ts">
  2. export default { name: '{{pascalCase name}}Form' };
  3. </script>
  4. <script setup lang="ts">
  5. import { ref, PropType } from 'vue';
  6. import { query{{pascalCase name}}, create{{pascalCase name}}, update{{pascalCase name}}, delete{{pascalCase name}} } from '@/api/{{kebabCase path}}';
  7. import DialogForm from '@/components/DialogForm.vue';
  8. import LabelTip from '@/components/LabelTip.vue';
  9. defineProps({ modelValue: { type: Boolean, required: true }, beanId: { type: Number, default: null }, beanIds: { type: Array as PropType<number[]>, required: true } });
  10. defineEmits({ 'update:modelValue': null, finished: null });
  11. const focus = ref();
  12. const values = ref<Record<string, any>>({});
  13. </script>
  14. <template>
  15. <dialog-form
  16. v-model:values="values"
  17. :name="$t('menu.{{camelCase path}}.{{camelCase name}}')"
  18. :query-bean="query{{pascalCase name}}"
  19. :create-bean="create{{pascalCase name}}"
  20. :update-bean="update{{pascalCase name}}"
  21. :delete-bean="delete{{pascalCase name}}"
  22. :bean-id="beanId"
  23. :bean-ids="beanIds"
  24. :focus="focus"
  25. :init-values="(): any => ({})"
  26. :to-values="(bean) => ({ ...bean })"
  27. :model-value="modelValue"
  28. perms="{{camelCase name}}"
  29. @update:model-value="(event) => $emit('update:modelValue', event)"
  30. @finished="() => $emit('finished')"
  31. >
  32. <template #default="{ bean }">
  33. <el-form-item prop="name" :rules="{ required: true, message: () => $t('v.required') }">
  34. <template #label><label-tip message="{{camelCase name}}.name" /></template>
  35. <el-input ref="focus" v-model="values.name" maxlength="50"></el-input>
  36. </el-form-item>
  37. </template>
  38. </dialog-form>
  39. </template>