初始代码

This commit is contained in:
wangmingwei
2026-04-21 17:19:25 +08:00
parent ac9bea0b65
commit fb2bc3165b
1320 changed files with 17009 additions and 0 deletions

View File

@@ -0,0 +1,361 @@
#parse("PublicMacro/DetailMarco.vm")
#parse("PublicMacro/ConstantMarco.vm")
##参数
#ConstantParams()
<template>
## 全屏弹窗
#if(${context.popupType}=="fullScreen")
<BasicPopup v-bind="$attrs" @register="registerPopup" :title="title" destroyOnClose>
<template #insertToolbar>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '${context.fullScreenWidth}' }">
<!-- 表单 -->
<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" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicPopup>
#end
## 普通弹窗
#if(${context.popupType}=="general")
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="${context.generalWidth}"
:minHeight="100" :showOkBtn="false">
<template #insertFooter>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<!-- 表单 -->
<a-row class="dynamic-form ${context.formStyle}">
<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" ref="formRef">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
#end
## 右侧弹窗
#if(${context.popupType}=="drawer")
<BasicDrawer v-bind="$attrs" @register="registerDrawer" :title="title" width="${context.drawerWidth}" showFooter
:showOkBtn="false">
<template #insertFooter>
#if(${context.HasPrintBtn})
<a-button type="primary" @click="handlePrint">#if(${context.printButtonTextI18nCode}){{t('${context.printButtonTextI18nCode}','${context.printButtonText}')}}#else${context.printButtonText}#end</a-button>
#end
</template>
<a-row class="p-10px dynamic-form ${context.formStyle}">
<!-- 表单 -->
<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" ref="formRef" >
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#DetailFormRendering()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicDrawer>
#end
<!-- 有关联表单详情:开始 -->
<RelationDetail ref="relationDetailRef" />
<!-- 有关联表单详情:结束 -->
#if(${context.HasPrintBtn})
<PrintSelect @register="registerPrintSelect" @change="handleShowBrowse" />
<PrintBrowse @register="registerPrintBrowse" />
#end
</template>
<script lang="ts" setup>
import { getDetailInfo } from './helper/api';
import { getConfigData } from '@/api/onlineDev/visualDev';
import { reactive, toRefs, nextTick, ref, computed, unref ,toRaw} from 'vue';
#if(${context.popupType}=="fullScreen")
import { BasicPopup, usePopup } from '@/components/Popup';
#end
import { BasicModal, useModal } from '@/components/Modal';
#if(${context.popupType}=="drawer")
import { BasicDrawer, useDrawer } from '@/components/Drawer';
#end
#if($childSummary == true)
import { thousandsFormat } from '@/utils/yunzhupaas';
#end
// 有关联表单详情
import RelationDetail from '@/views/common/dynamicModel/list/detail/index.vue';
// 表单权限
import { usePermission } from '@/hooks/web/usePermission';
#if(${context.HasPrintBtn})
// 打印模板多条生成PrintSelect
import PrintSelect from '@/components/PrintDesign/printSelect/index.vue';
import PrintBrowse from '@/components/PrintDesign/printBrowse/index.vue';
#end
import { useMessage } from '@/hooks/web/useMessage';
import { CaretRightOutlined } from '@ant-design/icons-vue';
import { buildUUID } from '@/utils/uuid';
import { useI18n } from '@/hooks/web/useI18n';
import { getDataChange } from '@/api/onlineDev/visualDev';
import { getDataInterfaceDataInfoByIds } from '@/api/systemData/dataInterface';
import ExtraRelationInfo from '@/components/yunzhupaas/RelationForm/src/ExtraRelationInfo.vue';
interface State {
dataForm: any;
title: string;
maskConfig: any;
interfaceRes: any;
locationScope: any;
extraOptions: any;
extraData: any;
## 活动面板参数
#foreach($fieLdsModel in ${context.form})
#set($yunzhupaasKey = "${fieLdsModel.yunzhupaasKey}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#set($isEnd = "${fieLdsModel.isEnd}")
#if(${isEnd}=='0')
#if($yunzhupaasKey=='collapse')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#if($yunzhupaasKey=='tab')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#if($yunzhupaasKey=='steps')
#if(${outermost}=='0')
${formModel.model}:any;
#end
#end
#end
#end
## 子表平铺活动面板变量
#foreach($children in ${context.children})
#set($aliasname = "${children.aliasLowName}")
#if($!{children.layoutType} == 'list')
${aliasname}outerActiveKey: any;
${aliasname}innerActiveKey: any;
#end
#end
}
defineOptions({ name: 'Detail' });
const { createMessage, createConfirm } = useMessage();
#if(${context.popupType}=="fullScreen")
const [registerPopup, { openPopup, setPopupProps, closePopup }] = usePopup();
#end
#if(${context.popupType}=="general")
const [registerModal, { openModal, setModalProps, closeModal }] = useModal();
#end
#if(${context.popupType}=="drawer")
const [registerDrawer, { openDrawer, setDrawerProps, closeDrawer }] = useDrawer();
#end
#if(${context.HasPrintBtn})
const [registerPrintSelect, { openModal: openPrintSelect }] = useModal();
const [registerPrintBrowse, { openModal: openPrintBrowse }] = useModal();
#end
##子表列表字段-及合计方法
#DetailChildTableColumns()
const { t } = useI18n();
const relationDetailRef = ref<any>(null);
const state = reactive<State>({
dataForm:{},
title: t('common.detailText','详情'),
maskConfig:#CreateMaskConfig(),
interfaceRes: ${context.templateJsonAll},
locationScope:#CreateLocationScope(),
extraOptions: #CreateExtraOptions(),
extraData: #CreateExtraData(),
## 活动面板参数
#foreach($fieLdsModel in ${context.form})
#set($yunzhupaasKey = "${fieLdsModel.yunzhupaasKey}")
#set($formModel = ${fieLdsModel.formModel})
#set($outermost = ${formModel.outermost})
#set($isEnd = "${fieLdsModel.isEnd}")
#if(${isEnd}=='0')
#if($yunzhupaasKey=='collapse')
#if(${outermost}=='0')
${formModel.model}:${formModel.active},
#end
#end
#if($yunzhupaasKey=='tab')
#if(${outermost}=='0')
${formModel.model}:'${formModel.active}',
#end
#end
#if($yunzhupaasKey=='steps')
#if(${outermost}=='0')
${formModel.model}:${formModel.active},
#end
#end
#end
#end
## 子表平铺活动面板变量
#foreach($children in ${context.children})
#set($aliasname = "${children.aliasLowName}")
#if($!{children.layoutType} == 'list')
${aliasname}outerActiveKey: [0],
${aliasname}innerActiveKey: [],
#end
#end
});
const { title, dataForm, maskConfig } = toRefs(state);
// 表单权限
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.dataForm.id = data.id;
#if(${context.popupType}=="fullScreen")
openPopup();
#end
#if(${context.popupType}=="general")
openModal();
#end
#if(${context.popupType}=="drawer")
openDrawer();
#end
nextTick(() => {
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
#InitActiveValue()
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
#if(${context.popupType}=="fullScreen")
closePopup();
#end
#if(${context.popupType}=="general")
closeModal();
#end
#if(${context.popupType}=="drawer")
closeDrawer();
#end
}
}
function getData(id) {
getDetailInfo(id).then((res) => {
state.dataForm = res.data || {};
nextTick(() => {
## 子表平铺,默认展开
#foreach($itemModel in ${context.children})
#set($aliasname =$itemModel.aliasLowName)
#if($!{itemModel.layoutType} == 'list')
if (state.dataForm.${aliasname}List) {
for (let i = 0; i < state.dataForm.${aliasname}List.length; i++) {
state.dataForm.${aliasname}List[i].yunzhupaasId = buildUUID();
}
}
set${aliasname}ActiveKey();
#end
#end
#runAllExtraFun()
changeLoading(false);
});
});
}
## 平铺布局时设置默认展开
#foreach($itemModel in ${context.children})
#if(${itemModel.layoutType} == 'list')
#set($aliasname =$itemModel.aliasLowName)
// 平铺布局时设置默认展开
function set${aliasname}ActiveKey() {
state.${aliasname}outerActiveKey = [0];
state.${aliasname}innerActiveKey = [];
#if(${itemModel.defaultExpandAll})
state.${aliasname}innerActiveKey = ['summary'];
if (!state.dataForm.${aliasname}List.length) return;
for (let i = 0; i < state.dataForm.${aliasname}List.length; i++) {
state.${aliasname}innerActiveKey.push(state.dataForm.${aliasname}List[i].yunzhupaasId);
}
#end
}
#end
#end
function toDetail(modelId, id, propsValue) {
if (!id) return;
getConfigData(modelId).then((res) => {
if (!res.data || !res.data.formData) return;
const formConf = JSON.parse(res.data.formData);
formConf.popupType = 'general';
formConf.hasPrintBtn = false;
formConf.customBtns = [];
const data = { id, formConf, modelId, propsValue};
relationDetailRef.value?.init(data);
});
}
#if($context.HasPrintBtn)
function handlePrint() {
let printId=#if(${context.PrintId})${context.PrintId}#else [] #end
if (!printId?.length) return createMessage.error('未配置打印模板');
if (printId?.length === 1) return handleShowBrowse(printId[0]);
openPrintSelect(true, printId);
}
function handleShowBrowse(id) {
openPrintBrowse(true, { id, formInfo: [{ formId: state.dataForm.id }] });
}
#end
function setFormProps(data) {
#if(${context.popupType}=="fullScreen")
setPopupProps(data);
#end
#if(${context.popupType}=="general")
setModalProps(data);
#end
#if(${context.popupType}=="drawer")
setDrawerProps(data);
#end
}
function changeLoading(loading) {
setFormProps({ loading });
}
##合计方法
#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
function getParamList(key) {
let templateJson: any[] = state.interfaceRes[key];
if (!templateJson || !templateJson.length || !state.dataForm) return templateJson;
for (let i = 0; i < templateJson.length; i++) {
if (templateJson[i].relationField && templateJson[i].sourceType == 1) {
templateJson[i].defaultValue = state.dataForm[templateJson[i].relationField + '_id'] || '';
}
}
return templateJson;
}
## 生成关联表单弹窗初始化数据方法
#ExtraInfoFun()
</script>

View File

@@ -0,0 +1,169 @@
#parse("PublicMacro/FormMarco.vm")
## 行内-弹窗编辑生成表单字段
#macro(FormRenderingExtra)
#foreach($html in ${context.columnList})
#set($vModel = "${html.vModel}")
#set($beforeVmodel = "${html.vModel}")
#set($mastModel="${context.formModel}.${beforeVmodel}")
#set($config = $html.config)
#set($mastKey = "${config.yunzhupaasKey}")
#set($show = $config.noShow)
#set($pcshow = $config.pc)
#set($startTime=${html.startTime})
#set($endTime=${html.endTime})
#if(${mastKey}=='datePicker'||${mastKey}=='timePicker')
#GetStartAndEndTime($mastKey,$config,$html,$startTime,$endTime)
#end
#if($show == false && $pcshow == true && !$html.prop.toLowerCase().startsWith("tablefield"))
<a-col :span="24" class="ant-col-item" #if($context.isFlow) v-if="judgeShow('${beforeVmodel}')"
#elseif(${context.columnData.useFormPermission}) #if(${vModel}) v-if="com.yunzhupaas.hasFormP('${beforeVmodel}')"
#elseif($mastKey == 'relationFormAttr' || $mastKey == 'popupAttr') v-if="com.yunzhupaas.hasFormP('${html.relationField}')" #end #end >
<a-form-item #if($config.showLabel == true) #if($config.labelWidth && ${context.labelPosition}!="top") :labelCol="{ style: { width: '${config.labelWidth}px' } }"#end
#else :labelCol="{ style: { width: '0px' } }"#end #if($vModel) name="${beforeVmodel}" #end>
<template #label>#if(${config.labelI18nCode}) {{t('${config.labelI18nCode}','${config.label}')}} #else${config.label} #end
#if((${config.label} || ${config.labelI18nCode}) && ${context.labelSuffix})${context.labelSuffix}#end
#if((${config.label} || ${config.labelI18nCode}) && (${config.tipLabel} || ${config.tipLabelI18nCode}))
<BasicHelp #if(${config.tipLabelI18nCode}) :text="t('${config.tipLabelI18nCode}','${config.tipLabel}')" #else text="${config.tipLabel}" #end />#end</template>
#CreateFieldTag($mastKey,$html,$config,$mastModel,$beforeVmodel,-1,false)
</a-form-item>
</a-col>
#end
#end
#end
<template>
##
##<!-- 普通弹窗 -->
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="${context.generalWidth}"
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
:minHeight="100" @ok="handleSubmit(0)" @continue="handleSubmit(1)" :closeFunc="onClose">
<a-row class="dynamic-form ${context.formStyle}">
<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" class="${context.formStyle}">
<a-row :gutter="#if(${context.formStyle}=='word-form')0#else${context.gutter}#end">
<!-- 具体表单 -->
#FormRenderingExtra()
<!-- 表单结束 -->
</a-row>
</a-form>
</a-row>
</BasicModal>
##<!-- 普通弹窗 -->
</template>
<script lang="ts" setup>
import { create, update, getInfo } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed } from 'vue';
import { BasicModal, useModal } from '@/components/Modal';
import { useMessage } from '@/hooks/web/useMessage';
import { useUserStore } from '@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
import { yunzhupaasRelationForm } from '@/components/yunzhupaas';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/yunzhupaas';
import dayjs from 'dayjs';
import { useI18n } from '@/hooks/web/useI18n';
interface State {
#createStateParam("any")
title: string;
}
const emit = defineEmits(['reload']);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage } = useMessage();
const { t } = useI18n();
const [registerModal, { openModal, setModalProps }] = useModal();
const formRef = ref<FormInstance>();
const state = reactive<State>({
#createStateParam()
title: '',
});
const { title, dataRule, dataForm, optionsObj, ableAll, maskConfig } = toRefs(state);
defineExpose({ init });
function init(data) {
state.title = !data.id || data.id === 'yunzhupaasAdd' ? t('common.add2Text','新增') : t('common.editText','编辑');
setFormProps({ continueLoading: false });
openModal();
##主表options
#foreach($fieLdsModel in ${context.fields})
#set($html = $fieLdsModel.formColumnModel.fieLdsModel)
#set($vModel = "${html.vModel}")
#set($config = $html.config)
#set($dataType = "$!{config.dataType}")
#if($!{config.dataType}=='dictionary'||$!{config.dataType}=='dynamic')
get${vModel}Options();
#end
#end
##副表options
#foreach($ColumnFieldModel in ${context.mastTable})
#set($html =${ColumnFieldModel.formMastTableModel})
#set($vModel = "${html.vModel}")
#set($config = $html.mastTable.fieLdsModel.config)
#if($!{config.dataType}=='dictionary'||$!{config.dataType}=='dynamic')
get${vModel}Options();
#end
#end
nextTick(() => {
getForm().resetFields();
state.dataForm = JSON.parse(JSON.stringify(data.formData));
state.dataForm.id = !data.id || data.id === 'yunzhupaasAdd' ? '' :data.id;
});
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
async function handleSubmit() {
try {
const values = await getForm()?.validate();
if (!values) return;
setFormProps({ continueLoading: true });
const formMethod = state.dataForm.id ? update : create;
formMethod(state.dataForm)
.then((res) => {
createMessage.success(res.msg);
setFormProps({ continueLoading: false });
setFormProps({ open: false });
emit('reload');
})
.catch(() => {
setFormProps({ continueLoading: false });
});
} catch (_) {}
}
function setFormProps(data) {
setModalProps(data);
}
function changeLoading(loading) {
setModalProps({ loading });
}
async function onClose() {
if (state.isContinue) emit('reload');
return true;
}
//option方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

View File

@@ -0,0 +1,416 @@
#parse("PublicMacro/FormMarco.vm")
<template>
## 全屏弹窗
#if(${context.popupType}=="fullScreen")
##<!-- 全屏弹窗 -->
<BasicPopup v-bind="$attrs" @register="registerPopup" showOkBtn destroyOnClose
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertToolbar>
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" v-if="showContinueBtn" />
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="p-10px dynamic-form ${context.formStyle}" :style="{ margin: '0 auto', width: '${context.fullScreenWidth}' }">
<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>
</BasicPopup>
##<!-- 全屏弹窗 -->
#end
## 普通弹窗
#if(${context.popupType}=="general")
##<!-- 普通弹窗 -->
<BasicModal v-bind="$attrs" @register="registerModal" width="${context.generalWidth}"
:minHeight="100"
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertFooter>
<div class="float-left mt-5px">
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" />
</div>
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="dynamic-form ${context.formStyle}">
<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>
</BasicModal>
##<!-- 普通弹窗 -->
#end
## 右侧弹窗
#if(${context.popupType}=="drawer")
##<!-- 右侧弹窗 -->
<BasicDrawer v-bind="$attrs" @register="registerDrawer" width="${context.drawerWidth}" showFooter
#if(${context.cancelButtonText} || ${context.cancelButtonTextI18nCode})
#if(${context.cancelButtonTextI18nCode}):cancelText="t('${context.cancelButtonTextI18nCode}','${context.cancelButtonText}')"
#else cancelText="${context.CancelButton}"#end
#end
#if(${context.confirmButtonText} || ${context.confirmButtonTextI18nCode})
#if(${context.confirmButtonTextI18nCode}):okText="t('${context.confirmButtonTextI18nCode}','${context.confirmButtonText}')"
#else okText="${context.confirmButtonText}"#end
#end
@ok="handleSubmit" :closeFunc="onClose">
<template #title>
<a-space :size="10">
<div class="text-16px font-medium">{{ title }}</div>
## <!-- 分组和树形不展示 -->
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
<a-space-compact size="small" block v-if="dataForm.id">
<a-tooltip :title="t('common.prevRecord')">
<a-button size="small" :disabled="getPrevDisabled" @click="handlePrev">
<i class="icon-ym icon-ym-caret-left text-10px"></i>
</a-button>
</a-tooltip>
<a-tooltip :title="t('common.nextRecord')">
<a-button size="small" :disabled="getNextDisabled" @click="handleNext">
<i class="icon-ym icon-ym-caret-right text-10px"></i>
</a-button>
</a-tooltip>
</a-space-compact>
#end
</a-space>
</template>
#if(${context.hasConfirmAndAddBtn} && (!${context.groupTable} && !${context.treeTable}))
## <!-- 分组和树形不展示 -->
<template #insertFooter>
<div class="float-left mt-5px">
<yunzhupaasCheckboxSingle v-model:value="submitType" :label="continueText" />
</div>
</template>
## <!-- 分组和树形不展示 -->
#end
<a-row class="p-10px dynamic-form ${context.formStyle}">
<!-- 表单 -->
<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>
</BasicDrawer>
##<!-- 右侧弹窗 -->
#end
#if($isSelectDialog == true)
<SelectModal :config="state.currTableConf" :formData="state.dataForm" ref="selectModal" @select="addForSelect"/>
#end
</template>
<script lang="ts" setup>
import { create, update, getInfo } from './helper/api';
import { reactive, toRefs, nextTick, ref, unref, computed,toRaw, inject } from 'vue';
#if(${context.popupType}=="fullScreen")
import { BasicPopup, usePopup } from '@/components/Popup';
#end
#if(${context.popupType}=="general")
import { BasicModal, useModal } from '@/components/Modal';
#end
#if(${context.popupType}=="drawer")
import { BasicDrawer, useDrawer } from '@/components/Drawer';
#end
import { yunzhupaasRelationForm } from '@/components/yunzhupaas';
import { useMessage } from '@/hooks/web/useMessage';
import { useI18n } from '@/hooks/web/useI18n';
import { useUserStore } from '@/store/modules/user';
import type { FormInstance } from 'ant-design-vue';
#if($isSelectDialog == true)
import SelectModal from '@/components/CommonModal/src/SelectModal.vue';
#end
import { thousandsFormat , getDateTimeUnit, getTimeUnit} from '@/utils/yunzhupaas';
import { getDictionaryDataSelector } from '@/api/systemData/dictionary';
import { getDataInterfaceRes } from '@/api/systemData/dataInterface';
import dayjs from 'dayjs';
// 表单权限
import { usePermission } from '@/hooks/web/usePermission';
import { cloneDeep } from 'lodash-es';
import { buildUUID } from '@/utils/uuid';
import { CaretRightOutlined } from '@ant-design/icons-vue';
interface State {
#createStateParam("any")
title: string;
#if(${context.hasConfirmAndAddBtn})continueText: string; #end
allList: any[];
currIndex: number;
isContinue: boolean;
submitType: number;
showContinueBtn: boolean;
}
const emit = defineEmits(['reload']);
const getLeftTreeActiveInfo: (() => any) | null = inject('getLeftTreeActiveInfo', null);
const userStore = useUserStore();
const userInfo = userStore.getUserInfo;
const { createMessage, createConfirm } = useMessage();
const { t } = useI18n();
#if(${context.popupType}=="fullScreen")
const [registerPopup, { openPopup, setPopupProps }] = usePopup();
#end
#if(${context.popupType}=="general")
const [registerModal, { openModal, setModalProps }] = useModal();
#end
#if(${context.popupType}=="drawer")
const [registerDrawer, { openDrawer, setDrawerProps }] = useDrawer();
#end
const formRef = ref<FormInstance>();
#if($isSelectDialog == true)
// 子表弹窗数据
const selectModal = ref(null);
#end
#GetChildTableColumns()
const state = reactive<State>({
#createStateParam()
title: "",
#if(${context.hasConfirmAndAddBtn}) continueText: "", #end
allList: [],
currIndex: 0,
isContinue: false,
submitType: 0,
showContinueBtn: #if(${context.hasConfirmAndAddBtn}) true #else false #end,
});
const { title, #if(${context.hasConfirmAndAddBtn}) continueText, #end showContinueBtn, dataRule, dataForm, optionsObj, ableAll, maskConfig,submitType } = toRefs(state);
const getPrevDisabled = computed(() => state.currIndex === 0);
const getNextDisabled = computed(() => state.currIndex === state.allList.length - 1);
// 表单权限
const { hasFormP } = usePermission();
defineExpose({ init });
function init(data) {
state.submitType = 0;
state.isContinue = false;
state.title = !data.id ? t('common.add2Text','新增') : t('common.editText','编辑');
#if(${context.hasConfirmAndAddBtn}) state.continueText = !data.id ? t('common.continueAndAddText','确定并新增') : t('common.continueText','确定并继续'); #end
setFormProps({ continueLoading: false });
state.dataForm.id = data.id;
#if(${context.popupType}=="fullScreen")
openPopup();
#end
#if(${context.popupType}=="general")
openModal();
#end
#if(${context.popupType}=="drawer")
openDrawer();
#end
state.allList = data.allList;
state.currIndex = state.allList.length && data.id ? state.allList.findIndex((item) => item.id === data.id) : 0;
nextTick(() => {
getForm().resetFields();
#foreach($child in ${context.children})
state.dataForm.${child.aliasLowName}List = [];
#end
setTimeout(initData, 0);
});
}
function initData() {
changeLoading(true);
#InitActiveValue()
if (state.dataForm.id) {
getData(state.dataForm.id);
} else {
//初始化options
#EditGetOption(false)
// 设置默认值
state.dataForm={
#CreateDataform()
};
if (getLeftTreeActiveInfo) state.dataForm = {...state.dataForm, ...(getLeftTreeActiveInfo() || {}) };
state.childIndex = -1;
changeLoading(false);
}
}
function getForm() {
const form = unref(formRef);
if (!form) {
throw new Error('form is null!');
}
return form;
}
function getData(id) {
getInfo(id).then((res) => {
state.dataForm = res.data || {};
## 初始化options
#EditGetOption(true)
state.childIndex = -1;
changeLoading(false);
});
}
async function handleSubmit(type) {
try {
const values = await getForm()?.validate();
if (!values) return;
### 非流程子表字段验证
#if(!$context.isFlow)
#foreach($itemModel in ${context.children})
if(!$!{itemModel.aliasLowName}Exist()) return;
#end
#end
setFormProps({ confirmLoading: true });
const formMethod = state.dataForm.id ? update : create;
formMethod(state.dataForm)
.then((res) => {
createMessage.success(res.msg);
setFormProps({ confirmLoading: false });
if (state.submitType == 1) {
initData();
state.isContinue = true;
} else {
setFormProps({ open: false });
emit('reload');
}
})
.catch(() => {
setFormProps({ confirmLoading: false });
});
} catch (_) {}
}
function handlePrev() {
state.currIndex--;
handleGetNewInfo();
}
function handleNext() {
state.currIndex++;
handleGetNewInfo();
}
function handleGetNewInfo() {
changeLoading(true);
getForm().resetFields();
const id = state.allList[state.currIndex].id;
getData(id);
}
function setFormProps(data) {
#if(${context.popupType}=="fullScreen")
setPopupProps(data);
#end
#if(${context.popupType}=="general")
setModalProps(data);
#end
#if(${context.popupType}=="drawer")
setDrawerProps(data);
#end
}
function changeLoading(loading) {
#if(${context.popupType}=="fullScreen")
setPopupProps({ loading });
#end
#if(${context.popupType}=="general")
setModalProps({ loading });
#end
#if(${context.popupType}=="drawer")
setDrawerProps({ loading });
#end
}
async function onClose() {
if (state.isContinue) emit('reload');
return true;
}
##合计方法
#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
##数据联动changeData方法
#ChangeData()
##子表其他方法
#CreateChildTableMethod()
##子表弹窗数据方法
#if($isSelectDialog == true)
#ChildDialogMethod()
#end
##数据选项--数据字典和远端数据初始化方法
#GetDataOptionsMethod()
##动态时间处理
#GetRelationDate()
</script>

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff