Form.vue.vm 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. #parse("PublicMacro/FormMarco.vm")
  2. <template>
  3. <div class="flow-form ${context.formStyle}">
  4. <a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
  5. labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
  6. #if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
  7. :model="dataForm" :rules="dataRule" ref="formRef" :disabled="config.disabled">
  8. <a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
  9. <!-- 具体表单 -->
  10. #FormRendering()
  11. <!-- 表单结束 -->
  12. </a-row>
  13. </a-form>
  14. #if($isSelectDialog == true)
  15. <SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
  16. #end
  17. </div>
  18. </template>
  19. <script lang="ts" setup>
  20. import { reactive, toRefs, onMounted, ref , unref , computed, nextTick, toRaw, inject} from 'vue';
  21. import { useFlowForm } from '@/views/workFlow/workFlowForm/hooks/useFlowForm';
  22. import type { FormInstance } from 'ant-design-vue';
  23. import { JnpfRelationForm } from '@/components/Jnpf';
  24. import { useMessage } from '@/hooks/web/useMessage';
  25. import { useUserStore } from '@/store/modules/user';
  26. #if($isSelectDialog == true)
  27. import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
  28. #end
  29. import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/jnpf';
  30. import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
  31. import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
  32. import dayjs from 'dayjs';
  33. import { cloneDeep } from 'lodash-es';
  34. import { buildUUID } from '@/utils/uuid';
  35. import { CaretRightOutlined } from '@ant-design/icons-vue';
  36. import { useI18n } from '@/hooks/web/useI18n';
  37. interface State {
  38. #createStateParam("any")
  39. }
  40. const userStore = useUserStore();
  41. const userInfo = userStore.getUserInfo;
  42. const { t } = useI18n();
  43. const props = defineProps(['config']);
  44. const emit = defineEmits(['setPageLoad', 'eventReceiver']);
  45. const getLeftTreeActiveInfo: (() => any) | null = inject('getLeftTreeActiveInfo', null);
  46. const formRef = ref<FormInstance>();
  47. const state = reactive<State>({
  48. #createStateParam()
  49. });
  50. const { createMessage, createConfirm } = useMessage();
  51. const { dataForm, dataRule, optionsObj, ableAll, maskConfig } = toRefs(state);
  52. const { init, judgeShow, judgeWrite,judgeRequired, dataFormSubmit } = useFlowForm({
  53. config: props.config,
  54. selfState: state,
  55. emit,
  56. formRef,
  57. selfInit,
  58. selfGetInfo,
  59. });
  60. defineExpose({ dataFormSubmit });
  61. ##新增初始化数据
  62. function selfInit() {
  63. #EditGetOption(false)
  64. #InitActiveValue()
  65. state.childIndex = -1;
  66. if (getLeftTreeActiveInfo) state.dataForm = {...state.dataForm, ...(getLeftTreeActiveInfo() || {}) };
  67. }
  68. ##编辑和详情初始化数据
  69. function selfGetInfo(dataForm) {
  70. #EditGetOption(true)
  71. #InitActiveValue()
  72. }
  73. onMounted(() => {
  74. init();
  75. });
  76. #if($isSelectDialog == true)
  77. // 子表弹窗数据
  78. const selectModal = ref(null);
  79. #end
  80. #GetChildTableColumns()
  81. ##数据联动changeData方法
  82. #ChangeData()
  83. ##子表其他方法
  84. #CreateChildTableMethod()
  85. ##子表弹窗数据方法
  86. #if($isSelectDialog == true)
  87. #ChildDialogMethod()
  88. #end
  89. ##合计方法
  90. #if($childSummary==true)
  91. //子表合计方法
  92. function getCmpValOfRow(row, key, summaryField) {
  93. if (!summaryField.length) return '';
  94. const isSummary = key => summaryField.includes(key);
  95. const target = row[key];
  96. if (!target) return '';
  97. let data = isNaN(target) ? 0 : Number(target);
  98. if (isSummary(key)) return data || 0;
  99. return '';
  100. }
  101. #end
  102. ##数据选项--数据字典和远端数据初始化方法
  103. #GetDataOptionsMethod()
  104. ##动态时间处理
  105. #GetRelationDate()
  106. </script>