form.stub 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <!-- 对话框表单 -->
  3. <el-dialog
  4. class="ba-operate-dialog"
  5. :close-on-click-modal="false"
  6. :model-value="baTable.form.operate ? true : false"
  7. @close="baTable.toggleForm"{%formDialogBig%}
  8. >
  9. <template #header>
  10. <div class="title" v-drag="['.ba-operate-dialog', '.el-dialog__header']" v-zoom="'.ba-operate-dialog'">
  11. {{ baTable.form.operate ? t(baTable.form.operate) : '' }}
  12. </div>
  13. </template>
  14. <el-scrollbar v-loading="baTable.form.loading" class="ba-table-form-scrollbar">
  15. <div
  16. class="ba-operate-form"
  17. :class="'ba-' + baTable.form.operate + '-form'"
  18. :style="'width: calc(100% - ' + baTable.form.labelWidth! / 2 + 'px)'"
  19. >
  20. <el-form
  21. v-if="!baTable.form.loading"
  22. ref="formRef"
  23. @keyup.enter="baTable.onSubmit(formRef)"
  24. :model="baTable.form.items"
  25. label-position="right"
  26. :label-width="baTable.form.labelWidth + 'px'"
  27. :rules="rules"
  28. >{%formItem%}
  29. </el-form>
  30. </div>
  31. </el-scrollbar>
  32. <template #footer>
  33. <div :style="'width: calc(100% - ' + baTable.form.labelWidth! / 1.8 + 'px)'">
  34. <el-button @click="baTable.toggleForm('')">{{ t('Cancel') }}</el-button>
  35. <el-button v-blur :loading="baTable.form.submitLoading" @click="baTable.onSubmit(formRef)" type="primary">
  36. {{ baTable.form.operateIds && baTable.form.operateIds.length > 1 ? t('Save and edit next item') : t('Save') }}
  37. </el-button>
  38. </div>
  39. </template>
  40. </el-dialog>
  41. </template>
  42. <script setup lang="ts">
  43. import { reactive, ref, inject } from 'vue'
  44. import { useI18n } from 'vue-i18n'
  45. import type baTableClass from '/@/utils/baTable'
  46. import FormItem from '/@/components/formItem/index.vue'
  47. import type { ElForm, FormItemRule } from 'element-plus'
  48. import { buildValidatorData } from '/@/utils/validate'
  49. {%importPackages%}
  50. const formRef = ref<InstanceType<typeof ElForm>>()
  51. const baTable = inject('baTable') as baTableClass
  52. const { t } = useI18n()
  53. const rules: Partial<Record<string, FormItemRule[]>> = reactive({{%formItemRules%}})
  54. </script>
  55. <style scoped lang="scss"></style>