123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- #parse("PublicMacro/FormMarco.vm")
- <template>
- <BasicPopup v-bind="$attrs" @register="registerPopup" :show-back-icon="false" :show-cancel-btn="false" title="${context.formModelName}">
- <template #insertToolbar>
- <a-button type="primary" @click="handleSubmit" :loading="btnLoading">{{t('common.saveText','保存')}}</a-button>
- <a-button type="warning" class="ml-10px" @click="handleReset">{{t('component.cropper.btn_reset','重置')}}</a-button>
- </template>
- <a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '100%' }">
- <!-- 表单 -->
- <a-form :colon="false" size="${context.size}" layout=#if(${context.labelPosition}=="top") "vertical" #else "horizontal" #end
- labelAlign=#if(${context.labelPosition}=="right") "right" #else "left" #end
- #if(${context.labelPosition}!="top") :labelCol="{ style: { width: '${context.labelWidth}px' } }" #end
- :model="dataForm" :rules="dataRule" ref="formRef" >
- <a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
- <!-- 具体表单 -->
- #FormRendering()
- <!-- 表单结束 -->
- </a-row>
- </a-form>
- </a-row>
- #if($isSelectDialog == true)
- <SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
- #end
- </BasicPopup>
- </template>
- <script lang="ts" setup>
- import { create } from './helper/api';
- import { reactive, toRefs, nextTick, ref, unref, computed, toRaw} from 'vue';
- import { BasicPopup, usePopupInner } from '@/components/Popup';
- import { useUserStore } from '@/store/modules/user';
- import type { FormInstance } from 'ant-design-vue';
- import { useMessage } from '@/hooks/web/useMessage';
- import { useI18n } from '@/hooks/web/useI18n';
- import { JnpfRelationForm } from '@/components/Jnpf';
- #if($isSelectDialog == true)
- import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
- #end
- import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/jnpf';
- import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
- import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
- // 表单权限
- import { usePermission } from '@/hooks/web/usePermission';
- import dayjs from 'dayjs';
- import { cloneDeep } from 'lodash-es';
- import { buildUUID } from '@/utils/uuid';
- import { CaretRightOutlined } from '@ant-design/icons-vue';
- interface State {
- btnLoading: boolean;
- #createStateParam("any")
- }
- defineEmits(['register']);
- const userStore = useUserStore();
- const userInfo = userStore.getUserInfo;
- const { createMessage, createConfirm } = useMessage();
- const { t } = useI18n();
- const [registerPopup, { changeLoading }] = usePopupInner(init);
- const formRef = ref<FormInstance>();
- #if($isSelectDialog == true)
- // 子表弹窗数据
- const selectModal = ref(null);
- #end
- const state = reactive<State>({
- btnLoading: false,
- #createStateParam()
- });
- const { dataForm, dataRule, btnLoading, optionsObj, ableAll, maskConfig } = toRefs(state);
- // 表单权限
- const { hasFormP } = usePermission();
- #GetChildTableColumns()
- function init() {
- changeLoading(true);
- #EditGetOption(false)
- #InitActiveValue()
- nextTick(() => {
- changeLoading(false);
- });
- }
- async function handleSubmit() {
- try {
- const values = await getForm()?.validate();
- if (!values) return;
- ### 非流程子表字段验证
- #if(!$context.isFlow)
- #foreach($itemModel in ${context.children})
- if(!$!{itemModel.aliasLowName}Exist()) return;
- #end
- #end
- state.btnLoading = true;
- create(state.dataForm)
- .then(res => {
- createMessage.success(res.msg);
- state.btnLoading = false;
- handleReset();
- })
- .catch(() => {
- state.btnLoading = false;
- });
- } catch (_) {}
- }
- function handleReset() {
- getForm().resetFields();
- #foreach($child in ${context.children})
- state.dataForm.${child.aliasLowName}List = [];
- #end
- init();
- }
- function getForm() {
- const form = unref(formRef);
- if (!form) {
- throw new Error('form is null!');
- }
- return form;
- }
- ##数据联动changeData方法
- #ChangeData()
- ##子表其他方法
- #CreateChildTableMethod()
- ##子表弹窗数据方法
- #if($isSelectDialog == true)
- #ChildDialogMethod()
- #end
- ##合计方法
- #if($childSummary==true)
- //子表合计方法
- function getCmpValOfRow(row, key, summaryField) {
- if (!summaryField.length) return '';
- const isSummary = key => summaryField.includes(key);
- const target = row[key];
- if (!target) return '';
- let data = isNaN(target) ? 0 : Number(target);
- if (isSummary(key)) return data || 0;
- return '';
- }
- #end
- ##数据选项--数据字典和远端数据初始化方法
- #GetDataOptionsMethod()
- ##动态时间处理
- #GetRelationDate()
- </script>
|