Form.vue.vm 4.4 KB

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