parent
71de6bec63
commit
e4673ecdaa
@ -0,0 +1,48 @@
|
||||
<#if need_select_tag>
|
||||
JDictSelectTag,
|
||||
</#if>
|
||||
<#if need_switch>
|
||||
JSwitch,
|
||||
</#if>
|
||||
<#if need_multi>
|
||||
JSelectMultiple,
|
||||
</#if>
|
||||
<#if need_search>
|
||||
JSearchSelect,
|
||||
</#if>
|
||||
<#if need_popup>
|
||||
JPopup,
|
||||
</#if>
|
||||
<#if need_category>
|
||||
JCategorySelect,
|
||||
</#if>
|
||||
<#if need_dept>
|
||||
JSelectDept,
|
||||
</#if>
|
||||
<#if need_dept_user>
|
||||
JSelectUserByDept,
|
||||
</#if>
|
||||
<#if need_select_tree>
|
||||
JTreeSelect,
|
||||
</#if>
|
||||
<#if need_time>
|
||||
TimePicker,
|
||||
</#if>
|
||||
<#if need_pca>
|
||||
JAreaLinkage,
|
||||
</#if>
|
||||
<#if need_upload>
|
||||
JUpload,
|
||||
</#if>
|
||||
<#if need_image_upload>
|
||||
JImageUpload,
|
||||
</#if>
|
||||
<#if need_markdown>
|
||||
JMarkdownEditor,
|
||||
</#if>
|
||||
<#if need_editor>
|
||||
JEditor,
|
||||
</#if>
|
||||
<#if need_checkbox>
|
||||
JCheckbox,
|
||||
</#if>
|
@ -0,0 +1,107 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<#if po.isShow =='Y' && po.fieldName != 'id' && isNotPidField(tableVo, po.fieldDbName)>
|
||||
<#assign form_field_dictCode="">
|
||||
<#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1>
|
||||
<#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign form_field_dictCode="${po.dictField}">
|
||||
</#if>
|
||||
<a-col :span="${form_span}">
|
||||
<a-form-item label="${po.filedComment}" v-bind="validateInfos.${autoStringSuffixForModel(po)}">
|
||||
<#if po.classType =='date'>
|
||||
<a-date-picker placeholder="请选择${po.filedComment}" v-model:value="formData.${po.fieldName}" value-format="YYYY-MM-DD" style="width: 100%" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType =='datetime'>
|
||||
<a-date-picker placeholder="请选择${po.filedComment}" v-model:value="formData.${po.fieldName}" showTime value-format="YYYY-MM-DD HH:mm:ss" style="width: 100%" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType =='time'>
|
||||
<#assign need_time = true>
|
||||
<time-picker placeholder="请选择${po.filedComment}" value-format="HH:mm:ss" v-model:value="formData.${po.fieldName}" style="width: 100%" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType =='popup'>
|
||||
<#assign need_popup = true>
|
||||
<#assign sourceFields = po.dictField?default("")?trim?split(",")/>
|
||||
<#assign targetFields = po.dictText?default("")?trim?split(",")/>
|
||||
<j-popup
|
||||
placeholder="请选择${po.filedComment}"
|
||||
v-model:value="formData.${po.fieldName}"
|
||||
code="${po.dictTable}"
|
||||
:fieldConfig="[
|
||||
<#list sourceFields as fieldName>
|
||||
{ source: '${fieldName}', target: '${targetFields[fieldName_index]}' },
|
||||
</#list>
|
||||
]"
|
||||
:multi="${po.extendParams.popupMulti?c}"
|
||||
:setFieldsValue="setFieldsValue"
|
||||
<#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if><#rt>
|
||||
/>
|
||||
<#elseif po.classType =='sel_depart'>
|
||||
<#assign need_dept = true>
|
||||
<j-select-dept v-model:value="formData.${po.fieldName}" :multiple="${po.extendParams.multi?default('true')}" checkStrictly <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> />
|
||||
<#elseif po.classType =='switch'>
|
||||
<#assign need_switch = true>
|
||||
<j-switch v-model:value="formData.${po.fieldName}" <#if po.dictField != 'is_open'>:options="${po.dictField}"</#if> <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>></j-switch>
|
||||
<#elseif po.classType =='pca'>
|
||||
<#assign need_pca = true>
|
||||
<j-area-linkage v-model:value="formData.${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> />
|
||||
<#elseif po.classType =='markdown'>
|
||||
<#assign need_markdown = true>
|
||||
<j-markdown-editor v-model:value="formData.${autoStringSuffixForModel(po)}" id="${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>></j-markdown-editor>
|
||||
<#elseif po.classType =='password'>
|
||||
<a-input-password v-model:value="formData.${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType =='sel_user'>
|
||||
<#assign need_dept_user = true>
|
||||
<j-select-user-by-dept v-model:value="formData.${po.fieldName}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType =='textarea'>
|
||||
<a-textarea v-model:value="formData.${autoStringSuffixForModel(po)}" rows="4" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType=='radio'>
|
||||
<#assign need_select_tag = true>
|
||||
<j-dict-select-tag type='radio' v-model:value="formData.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType=='list'>
|
||||
<#assign need_select_tag = true>
|
||||
<j-dict-select-tag v-model:value="formData.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType=='list_multi'>
|
||||
<#assign need_multi = true>
|
||||
<j-select-multiple type="${po.classType}" v-model:value="formData.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> :triggerChange="false"/>
|
||||
<#elseif po.classType=='checkbox'>
|
||||
<#assign need_checkbox = true>
|
||||
<j-checkbox type="${po.classType}" v-model:value="formData.${po.fieldName}" dictCode="${form_field_dictCode}" placeholder="请选择${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType=='sel_search'>
|
||||
<#assign need_search = true>
|
||||
<j-search-select v-model:value="formData.${po.fieldName}" dict="${form_field_dictCode}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> />
|
||||
<#elseif po.classType=='cat_tree'>
|
||||
<#assign need_category = true>
|
||||
<j-category-select v-model:value="formData.${po.fieldName}" pcode="${po.dictField?default("")}" placeholder="请选择${po.filedComment}" <#if po.dictText?default("")?trim?length gt 1>back="${dashedToCamel(po.dictText)}"</#if> <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> @change="(value) => handleFormChange('${po.fieldName}', value)" />
|
||||
<#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
|
||||
<a-input-number v-model:value="formData.${po.fieldName}" placeholder="请输入${po.filedComment}" style="width: 100%" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.classType=='file'>
|
||||
<#assign need_upload = true>
|
||||
<j-upload v-model:value="formData.${po.fieldName}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if> <#if po.uploadnum??>:maxCount=${po.uploadnum}</#if>></j-upload>
|
||||
<#elseif po.classType=='image'>
|
||||
<#assign need_image_upload = true>
|
||||
<j-image-upload <#if po.uploadnum??>:fileMax=${po.uploadnum}</#if> v-model:value="formData.${po.fieldName}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>></j-image-upload>
|
||||
<#elseif po.classType=='umeditor'>
|
||||
<#assign need_editor = true>
|
||||
<j-editor v-model:value="formData.${autoStringSuffixForModel(po)}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>/>
|
||||
<#elseif po.fieldDbType=='Blob'>
|
||||
<a-input v-model:value="formData.${autoStringSuffixForModel(po)}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>></a-input>
|
||||
<#elseif po.classType == 'sel_tree'>
|
||||
<#assign need_select_tree = true>
|
||||
<j-tree-select
|
||||
<#if po.dictText??>
|
||||
<#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??>
|
||||
dict="${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}"
|
||||
<#elseif po.dictText?split(',')[1]??>
|
||||
pidField="${po.dictText?split(',')[1]}"
|
||||
<#elseif po.dictText?split(',')[3]??>
|
||||
hasChildField="${po.dictText?split(',')[3]}"
|
||||
</#if>
|
||||
</#if>
|
||||
pidValue="${po.dictField}"
|
||||
<#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>
|
||||
v-model:value="formData.${po.fieldName}"
|
||||
@change="(value) => handleFormChange('${po.fieldName}', value)">
|
||||
</j-tree-select>
|
||||
<#else>
|
||||
<a-input v-model:value="formData.${po.fieldName}" placeholder="请输入${po.filedComment}" <#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>></a-input>
|
||||
</#if>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</#if>
|
@ -0,0 +1,48 @@
|
||||
<#if need_select_tag>
|
||||
import JDictSelectTag from '/@/components/Form/src/jeecg/components/JDictSelectTag.vue';
|
||||
</#if>
|
||||
<#if need_switch>
|
||||
import JSwitch from '/@/components/Form/src/jeecg/components/JSwitch.vue';
|
||||
</#if>
|
||||
<#if need_multi>
|
||||
import JSelectMultiple from '/@/components/Form/src/jeecg/components/JSelectMultiple.vue';
|
||||
</#if>
|
||||
<#if need_search>
|
||||
import JSearchSelect from '/@/components/Form/src/jeecg/components/JSearchSelect.vue';
|
||||
</#if>
|
||||
<#if need_popup>
|
||||
import JPopup from '/@/components/Form/src/jeecg/components/JPopup.vue';
|
||||
</#if>
|
||||
<#if need_category>
|
||||
import JCategorySelect from '/@/components/Form/src/jeecg/components/JCategorySelect.vue';
|
||||
</#if>
|
||||
<#if need_dept>
|
||||
import JSelectDept from '/@/components/Form/src/jeecg/components/JSelectDept.vue';
|
||||
</#if>
|
||||
<#if need_dept_user>
|
||||
import JSelectUserByDept from '/@/components/Form/src/jeecg/components/JSelectUserByDept.vue';
|
||||
</#if>
|
||||
<#if need_select_tree>
|
||||
import JTreeSelect from '/@/components/Form/src/jeecg/components/JTreeSelect.vue';
|
||||
</#if>
|
||||
<#if need_time>
|
||||
import { TimePicker } from 'ant-design-vue';
|
||||
</#if>
|
||||
<#if need_pca>
|
||||
import JAreaLinkage from '/@/components/Form/src/jeecg/components/JAreaLinkage.vue';
|
||||
</#if>
|
||||
<#if need_upload>
|
||||
import JUpload from '/@/components/Form/src/jeecg/components/JUpload/JUpload.vue';
|
||||
</#if>
|
||||
<#if need_image_upload>
|
||||
import JImageUpload from '/@/components/Form/src/jeecg/components/JImageUpload.vue';
|
||||
</#if>
|
||||
<#if need_markdown>
|
||||
import JMarkdownEditor from '/@/components/Form/src/jeecg/components/JMarkdownEditor.vue';
|
||||
</#if>
|
||||
<#if need_editor>
|
||||
import JEditor from '/@/components/Form/src/jeecg/components/JEditor.vue';
|
||||
</#if>
|
||||
<#if need_checkbox>
|
||||
import JCheckbox from "/@/components/Form/src/jeecg/components/JCheckbox.vue";
|
||||
</#if>
|
@ -0,0 +1,85 @@
|
||||
<#if po.isQuery=='Y'>
|
||||
<#assign query_flag=true>
|
||||
<#if query_field_no==2>
|
||||
<template v-if="toggleSearchStatus">
|
||||
</#if>
|
||||
<#assign query_field_dictCode="">
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#assign need_select_tag = true>
|
||||
<#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}">
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#assign need_select_tag = true>
|
||||
<#assign query_field_dictCode="${po.dictField}">
|
||||
</#if>
|
||||
<#if po.queryMode=='single'>
|
||||
<#if query_field_no gt 1> </#if><a-col :lg="8">
|
||||
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
|
||||
<#if po.classType=='sel_search'>
|
||||
<#if query_field_no gt 1> </#if><j-search-select placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" dict="${po.dictTable},${po.dictText},${po.dictField}" />
|
||||
<#elseif po.classType=='sel_user'>
|
||||
<#if query_field_no gt 1> </#if><j-select-user-by-dept placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" />
|
||||
<#elseif po.classType=='switch'>
|
||||
<#if query_field_no gt 1> </#if><j-switch placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" <#if po.dictField!= 'is_open'>:options="${po.dictField}"</#if> query />
|
||||
<#elseif po.classType=='sel_depart'>
|
||||
<#if query_field_no gt 1> </#if><j-select-dept placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" checkStrictly />
|
||||
<#elseif po.classType=='list_multi'>
|
||||
<#if query_field_no gt 1> </#if><j-select-multiple placeholder="请选择${po.filedComment}" dictCode="${query_field_dictCode?default("")}" v-model:value="queryParam.${po.fieldName}" />
|
||||
<#elseif po.classType=='cat_tree'>
|
||||
<#if query_field_no gt 1> </#if><j-category-select placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" pcode="${po.dictField?default("")}" @change="(value) => handleFormChange('${po.fieldName}', value)" />
|
||||
<#elseif po.classType=='date'>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker valueFormat="YYYY-MM-DD" placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" />
|
||||
<#elseif po.classType=='datetime'>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker showTime valueFormat="YYYY-MM-DD HH:mm:ss" placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" />
|
||||
<#elseif po.classType=='pca'>
|
||||
<#if query_field_no gt 1> </#if><j-area-linkage v-model:value="queryParam.${po.fieldName}" placeholder="请选择${po.filedComment}" @change="(value) => handleAreaChange('${po.fieldName}', value)" />
|
||||
<#elseif po.classType=='sel_tree'>
|
||||
<#if query_field_no gt 1> </#if><j-tree-select v-model:value="queryParam.${po.fieldName}" placeholder="请选择${po.filedComment}" <#if po.dictText??><#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??>dict="${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}" <#elseif po.dictText?split(',')[1]??>pidField:"${po.dictText?split(',')[1]}", <#elseif po.dictText?split(',')[3]??>hasChildField:"${po.dictText?split(',')[3]}"</#if> </#if>pidValue="${po.dictField}" />
|
||||
<#elseif po.classType=='popup'>
|
||||
<#assign sourceFields = po.dictField?default("")?trim?split(",")/>
|
||||
<#assign targetFields = po.dictText?default("")?trim?split(",")/>
|
||||
<#if query_field_no gt 1> </#if><j-popup
|
||||
<#if query_field_no gt 1> </#if>placeholder="请选择${po.filedComment}"
|
||||
<#if query_field_no gt 1> </#if>v-model:value="queryParam.${po.fieldName}"
|
||||
<#if query_field_no gt 1> </#if>code="${po.dictTable}"
|
||||
<#if query_field_no gt 1> </#if>:fieldConfig="[
|
||||
<#list sourceFields as fieldName>
|
||||
<#if query_field_no gt 1> </#if>{ source: '${fieldName}', target: '${targetFields[fieldName_index]}' },
|
||||
</#list>
|
||||
<#if query_field_no gt 1> </#if>]"
|
||||
<#if query_field_no gt 1> </#if>:multi="${po.extendParams.popupMulti?c}"
|
||||
<#if query_field_no gt 1> </#if>:setFieldsValue="setFieldsValue" />
|
||||
<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'>
|
||||
<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- -->
|
||||
<#if po.dictTable?default("")?trim?length gt 1>
|
||||
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" dictCode="${po.dictTable},${po.dictText},${po.dictField}"/>
|
||||
<#elseif po.dictField?default("")?trim?length gt 1>
|
||||
<#if query_field_no gt 1> </#if><j-dict-select-tag placeholder="请选择${po.filedComment}" v-model:value="queryParam.${po.fieldName}" dictCode="${po.dictField}"/>
|
||||
<#else>
|
||||
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model:value="queryParam.${po.fieldName}"></a-input>
|
||||
</#if>
|
||||
<#else>
|
||||
<#if query_field_no gt 1> </#if><a-input placeholder="请输入${po.filedComment}" v-model:value="queryParam.${po.fieldName}"></a-input>
|
||||
</#if>
|
||||
<#if query_field_no gt 1> </#if></a-form-item>
|
||||
<#if query_field_no gt 1> </#if></a-col>
|
||||
<#else>
|
||||
<#if query_field_no gt 1> </#if><a-col :lg="8">
|
||||
<#if query_field_no gt 1> </#if><a-form-item label="${po.filedComment}">
|
||||
<#if po.classType=='date'>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker value-format="YYYY-MM-DD" placeholder="请选择开始时间" v-model:value="queryParam.${po.fieldName}_begin" class="query-group-cust"/>
|
||||
<#if query_field_no gt 1> </#if><span class="query-group-split-cust">~</span>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker value-format="YYYY-MM-DD" placeholder="请选择结束日期" v-model:value="queryParam.${po.fieldName}_end" class="query-group-cust"/>
|
||||
<#elseif po.classType=='datetime'>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker showTime value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择开始时间" v-model:value="queryParam.${po.fieldName}_begin" class="query-group-cust" />
|
||||
<#if query_field_no gt 1> </#if><span class="query-group-split-cust">~</span>
|
||||
<#if query_field_no gt 1> </#if><a-date-picker showTime value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择结束时间" v-model:value="queryParam.${po.fieldName}_end" class="query-group-cust" />
|
||||
<#else>
|
||||
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最小值" v-model:value="queryParam.${po.fieldName}_begin" class="query-group-cust"></a-input>
|
||||
<#if query_field_no gt 1> </#if><span class="query-group-split-cust">~</span>
|
||||
<#if query_field_no gt 1> </#if><a-input placeholder="请输入最大值" v-model:value="queryParam.${po.fieldName}_end" class="query-group-cust"></a-input>
|
||||
</#if>
|
||||
<#if query_field_no gt 1> </#if></a-form-item>
|
||||
<#if query_field_no gt 1> </#if></a-col>
|
||||
</#if>
|
||||
<#assign query_field_no=query_field_no+1>
|
||||
</#if>
|
@ -0,0 +1,13 @@
|
||||
<#assign sourceFields = col.dictField?default("")?trim?split(",")/>
|
||||
<#assign targetFields = col.dictText?default("")?trim?split(",")/>
|
||||
type: JVxeTypes.popup,
|
||||
popupCode:"${col.dictTable}",
|
||||
fieldConfig: [
|
||||
<#list sourceFields as fieldName>
|
||||
{ source: '${fieldName}', target: '${targetFields[fieldName_index]}' },
|
||||
</#list>
|
||||
],
|
||||
<#if col.readonly=='Y'>
|
||||
disabled:true,
|
||||
</#if>
|
||||
|
@ -0,0 +1,17 @@
|
||||
<#assign sourceFields = po.dictField?default("")?trim?split(",")/>
|
||||
<#assign targetFields = po.dictText?default("")?trim?split(",")/>
|
||||
component: 'JPopup',
|
||||
componentProps: ({ formActionType }) => {
|
||||
const {setFieldsValue} = formActionType;
|
||||
return{
|
||||
setFieldsValue:setFieldsValue,
|
||||
code:"${po.dictTable}",
|
||||
fieldConfig: [
|
||||
<#list sourceFields as fieldName>
|
||||
{ source: '${fieldName}', target: '${targetFields[fieldName_index]}' },
|
||||
</#list>
|
||||
],
|
||||
multi:${po.extendParams.popupMulti?c}
|
||||
}
|
||||
},
|
||||
|
@ -0,0 +1,49 @@
|
||||
<#assign fieldValidType = po.fieldValidType!''>
|
||||
<#-- 非空校验 -->
|
||||
<#if po.nullable == 'N' || fieldValidType == '*'>
|
||||
{ required: true, message: '请输入${po.filedComment}!'}<#rt>,
|
||||
<#elseif fieldValidType!=''>
|
||||
{ required: false}<#rt>,
|
||||
</#if>
|
||||
<#-- 唯一校验 -->
|
||||
<#if fieldValidType == 'only'>
|
||||
{ validator: ${po.fieldName}Duplicatevalidate }<#rt>
|
||||
<#-- 6到16位数字 -->
|
||||
<#elseif fieldValidType == 'n6-16'>
|
||||
{ pattern: /^\d{6,16}$/, message: '请输入6到16位数字!'}<#rt>,
|
||||
<#-- 6到16位任意字符 -->
|
||||
<#elseif fieldValidType == '*6-16'>
|
||||
{ pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'}<#rt>,
|
||||
<#-- 6到18位字符串 -->
|
||||
<#elseif fieldValidType == 's6-18'>
|
||||
{ pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'}<#rt>,
|
||||
<#-- 网址 -->
|
||||
<#elseif fieldValidType == 'url'>
|
||||
{ pattern: /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/, message: '请输入正确的网址!'}<#rt>,
|
||||
<#-- 电子邮件 -->
|
||||
<#elseif fieldValidType == 'e'>
|
||||
{ pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'}<#rt>,
|
||||
<#-- 手机号码 -->
|
||||
<#elseif fieldValidType == 'm'>
|
||||
{ pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'}<#rt>,
|
||||
<#-- 邮政编码 -->
|
||||
<#elseif fieldValidType == 'p'>
|
||||
{ pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'}<#rt>,
|
||||
<#-- 字母 -->
|
||||
<#elseif fieldValidType == 's'>
|
||||
{ pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'}<#rt>,
|
||||
<#-- 数字 -->
|
||||
<#elseif fieldValidType == 'n'>
|
||||
{ pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}<#rt>,
|
||||
<#-- 整数 -->
|
||||
<#elseif fieldValidType == 'z'>
|
||||
{ pattern: /^-?\d+$/, message: '请输入整数!'}<#rt>,
|
||||
<#-- 金额 -->
|
||||
<#elseif fieldValidType == 'money'>
|
||||
{ pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}<#rt>,
|
||||
<#-- 正则校验 -->
|
||||
<#elseif fieldValidType != '' && fieldValidType != '*'>
|
||||
{ pattern: '${fieldValidType}', message: '不符合校验规则!'}<#rt>,
|
||||
<#else>
|
||||
<#t>
|
||||
</#if>
|
@ -0,0 +1,6 @@
|
||||
<#include "../../utils.ftl">
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && poHasCheck(po)>
|
||||
${po.fieldName}: [<#include "vue3CoreNative.ftl">],
|
||||
</#if>
|
||||
</#list>
|
@ -0,0 +1,23 @@
|
||||
<#include "../utils.ftl">
|
||||
<#if col.isShow == 'Y' && poHasCheck(col)>
|
||||
validateRules: [
|
||||
<#if col.fieldName != 'id'>
|
||||
<#assign subFieldValidType = col.fieldValidType!''>
|
||||
<#-- 非空校验 -->
|
||||
<#if col.nullable == 'N' || fieldValidType == '*'>
|
||||
{ required: true, message: '${'$'}{title}不能为空' },
|
||||
<#elseif fieldValidType!=''>
|
||||
{ required: false},
|
||||
</#if>
|
||||
<#-- 其他情况下,只要有值就被认为是正则校验 -->
|
||||
<#if subFieldValidType?length gt 0>
|
||||
<#assign subMessage = '格式不正确'>
|
||||
<#if subFieldValidType == 'only' >
|
||||
<#assign subMessage = '不能重复'>
|
||||
</#if>
|
||||
{ pattern: "${subFieldValidType}", message: "${'$'}{title}${subMessage}" }
|
||||
<#t>
|
||||
</#if>
|
||||
</#if>
|
||||
],
|
||||
</#if>
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,348 @@
|
||||
<template>
|
||||
<div>
|
||||
<#assign query_field_no=0>
|
||||
<#assign need_category = false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign query_flag = false>
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<#-- 开始循环 -->
|
||||
<#list columns as po>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
|
||||
<#assign need_category=true>
|
||||
</#if>
|
||||
<#if po.classType=='pca'>
|
||||
<#assign need_pca=true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_search'>
|
||||
<#assign need_search = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_user'>
|
||||
<#assign need_dept_user = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_depart'>
|
||||
<#assign need_dept = true>
|
||||
</#if>
|
||||
<#if po.classType=='switch'>
|
||||
<#assign need_switch = true>
|
||||
</#if>
|
||||
<#if po.classType=='list_multi'>
|
||||
<#assign need_multi = true>
|
||||
</#if>
|
||||
<#if po.classType=='popup'>
|
||||
<#assign need_popup = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_tree'>
|
||||
<#assign need_select_tree = true>
|
||||
</#if>
|
||||
<#if po.classType=='time'>
|
||||
<#assign need_time = true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeSearch.ftl">
|
||||
</#list>
|
||||
<#if query_field_no gt 2>
|
||||
</template>
|
||||
</#if>
|
||||
<#if query_flag>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
|
||||
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
|
||||
{{ toggleSearchStatus ? '收起' : '展开' }}
|
||||
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
|
||||
</a>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</#if>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<#-- 结束循环 -->
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined"></Icon>
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button>批量操作
|
||||
<Icon icon="mdi:chevron-down"></Icon>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
||||
</template>
|
||||
<!--字段回显插槽-->
|
||||
<template #htmlSlot="{text}">
|
||||
<div v-html="text"></div>
|
||||
</template>
|
||||
<!--省市区字段回显插槽-->
|
||||
<template #pcaSlot="{text}">
|
||||
{{ getAreaTextByCode(text) }}
|
||||
</template>
|
||||
<template #fileSlot="{text}">
|
||||
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
|
||||
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<${entityName}Modal ref="registerModal" @success="handleSuccess"></${entityName}Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="${entityPackage}-${entityName?uncap_first}" setup>
|
||||
import { ref, reactive } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns } from './${entityName}.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './${entityName}.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import ${entityName}Modal from './components/${entityName}Modal.vue'
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
<#if need_category>
|
||||
import { loadCategoryData } from '/@/api/common/api';
|
||||
import { getAuthCache, setAuthCache } from '/@/utils/auth';
|
||||
import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum';
|
||||
</#if>
|
||||
<#if need_pca>
|
||||
import { getAreaTextByCode } from '/@/components/Form/src/utils/Area';
|
||||
</#if>
|
||||
|
||||
const queryParam = ref<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '${tableVo.ftlDescription}',
|
||||
api: list,
|
||||
columns,
|
||||
canResize:false,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam.value);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: "${tableVo.ftlDescription}",
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const labelCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 7 },
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
});
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
function handleDetail(record: Recordable) {
|
||||
registerModal.value.disableSubmit = true;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({ id: record.id }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
queryParam.value = {};
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
<#if need_popup>
|
||||
/**
|
||||
* popup组件值改变事件
|
||||
*/
|
||||
function setFieldsValue(map) {
|
||||
Object.keys(map).map((key) => {
|
||||
queryParam.value[key] = map[key];
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_pca>
|
||||
/**
|
||||
* 省市区点击事件
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleAreaChange(key, value) {
|
||||
queryParam.value[key] = value.join(',');
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_category>
|
||||
/**
|
||||
* form点击事件
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
queryParam.value[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化字典配置
|
||||
*/
|
||||
function initDictConfig() {
|
||||
<#list columns as po>
|
||||
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
|
||||
<#if po.classType=='cat_tree' && need_category==true>
|
||||
loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => {
|
||||
if (res) {
|
||||
let allDictDate = getAuthCache(DB_DICT_DATA_KEY);
|
||||
if(!allDictDate['${po.dictField?default("")}']){
|
||||
Object.assign(allDictDate,{'${po.dictField?default("")}':res})
|
||||
}
|
||||
setAuthCache(DB_DICT_DATA_KEY,allDictDate)
|
||||
}
|
||||
});
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
initDictConfig();
|
||||
</#if>
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust{
|
||||
width: calc(50% - 15px);
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,69 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/${entityPackage}/${entityName?uncap_first}/list',
|
||||
save='/${entityPackage}/${entityName?uncap_first}/add',
|
||||
edit='/${entityPackage}/${entityName?uncap_first}/edit',
|
||||
deleteOne = '/${entityPackage}/${entityName?uncap_first}/delete',
|
||||
deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch',
|
||||
importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel',
|
||||
exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
* @param isUpdate
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params }, { isTransformResponse: false });
|
||||
}
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,185 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-row>
|
||||
<#assign need_category = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign hasOnlyValidate = false>
|
||||
<#assign form_span = 24>
|
||||
<#if tableVo.fieldRowNum==2>
|
||||
<#assign form_span = 12>
|
||||
<#elseif tableVo.fieldRowNum==3>
|
||||
<#assign form_span = 8>
|
||||
<#elseif tableVo.fieldRowNum==4>
|
||||
<#assign form_span = 6>
|
||||
</#if>
|
||||
<#list columns as po>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
<#assign hasOnlyValidate = true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeForm.ftl">
|
||||
</#list>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, defineProps, computed } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import moment from 'moment';
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
import { getValueType } from '/@/utils';
|
||||
import { saveOrUpdate } from '../${entityName}.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
<#if hasOnlyValidate == true>
|
||||
import { duplicateValidate } from '/@/utils/helper/validator'
|
||||
</#if>
|
||||
|
||||
const props = defineProps({
|
||||
disabled: { type: Boolean, default: false },
|
||||
});
|
||||
const formRef = ref();
|
||||
const useForm = Form.useForm;
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y'>
|
||||
<#if po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
|
||||
${po.fieldName}: undefined,
|
||||
<#elseif po.fieldDbType=='Blob'>
|
||||
${po.fieldName}String: '',
|
||||
<#else>
|
||||
${po.fieldName}: '',
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = {
|
||||
<#include "/common/validatorRulesTemplate/native/vue3MainNative.ftl">
|
||||
};
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
edit({});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function edit(record) {
|
||||
nextTick(() => {
|
||||
resetFields();
|
||||
//赋值
|
||||
Object.assign(formData, record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
confirmLoading.value = true;
|
||||
const isUpdate = ref<boolean>(false);
|
||||
//时间格式化
|
||||
let model = formData;
|
||||
if (model.id) {
|
||||
isUpdate.value = true;
|
||||
}
|
||||
//循环数据
|
||||
for (let data in model) {
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (model[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||
if (valueType === 'string') {
|
||||
model[data] = model[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
await saveOrUpdate(model, isUpdate.value)
|
||||
.then((res) => {
|
||||
if (res.success) {
|
||||
createMessage.success(res.message);
|
||||
emit('ok');
|
||||
} else {
|
||||
createMessage.warning(res.message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
<#if need_popup>
|
||||
/**
|
||||
* popup组件值改变事件
|
||||
*/
|
||||
function setFieldsValue(map) {
|
||||
Object.keys(map).map((key) => {
|
||||
formData[key] = map[key];
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_category || need_select_tree>
|
||||
/**
|
||||
* 值改变事件触发
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
formData[key] = value;
|
||||
}
|
||||
</#if>
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
async function ${po.fieldName}Duplicatevalidate(_r, value) {
|
||||
return duplicateValidate('${tableName}', '${po.fieldDbName}', value, formData.id || '')
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.antd-modal-form {
|
||||
height: 500px !important;
|
||||
overflow-y: auto;
|
||||
padding: 24px 24px 24px 24px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,75 @@
|
||||
<template>
|
||||
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<${entityName}Form ref="registerForm" @ok="submitCallback" :disabled="disableSubmit"></${entityName}Form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import ${entityName}Form from './${entityName}Form.vue'
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(800);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add() {
|
||||
title.value = '新增';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback() {
|
||||
handleCancel();
|
||||
emit('success');
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,497 @@
|
||||
<template>
|
||||
<div>
|
||||
<#assign pidFieldName = "">
|
||||
<#assign hasChildrenField = "">
|
||||
<#list originalColumns as po>
|
||||
<#if po.fieldDbName == tableVo.extendParams.pidField>
|
||||
<#assign pidFieldName = po.fieldName>
|
||||
</#if>
|
||||
<#if po.fieldDbName == tableVo.extendParams.hasChildren>
|
||||
<#assign hasChildrenField = po.fieldName>
|
||||
</#if>
|
||||
</#list>
|
||||
<#assign query_field_no=0>
|
||||
<#assign need_category = false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign query_flag = false>
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<#-- 开始循环 -->
|
||||
<#list columns as po>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
|
||||
<#assign need_category=true>
|
||||
</#if>
|
||||
<#if po.classType=='pca'>
|
||||
<#assign need_pca=true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_search'>
|
||||
<#assign need_search = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_user'>
|
||||
<#assign need_dept_user = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_depart'>
|
||||
<#assign need_dept = true>
|
||||
</#if>
|
||||
<#if po.classType=='switch'>
|
||||
<#assign need_switch = true>
|
||||
</#if>
|
||||
<#if po.classType=='list_multi'>
|
||||
<#assign need_multi = true>
|
||||
</#if>
|
||||
<#if po.classType=='popup'>
|
||||
<#assign need_popup = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_tree'>
|
||||
<#assign need_select_tree = true>
|
||||
</#if>
|
||||
<#if po.classType=='time'>
|
||||
<#assign need_time = true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeSearch.ftl">
|
||||
</#list>
|
||||
<#if query_field_no gt 2>
|
||||
</template>
|
||||
</#if>
|
||||
<#if query_flag>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
|
||||
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
|
||||
{{ toggleSearchStatus ? '收起' : '展开' }}
|
||||
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
|
||||
</a>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</#if>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<#-- 结束循环 -->
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection" :expandedRowKeys="expandedRowKeys" @expand="handleExpand" @fetch-success="onFetchSuccess">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined"></Icon>
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button
|
||||
>批量操作
|
||||
<Icon icon="ant-design:down-outlined"></Icon>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)" />
|
||||
</template>
|
||||
<!--字段回显插槽-->
|
||||
<template #htmlSlot="{ text }">
|
||||
<div v-html="text"></div>
|
||||
</template>
|
||||
<!--省市区字段回显插槽-->
|
||||
<template #pcaSlot="{ text }">
|
||||
{{ getAreaTextByCode(text) }}
|
||||
</template>
|
||||
<template #fileSlot="{ text }">
|
||||
<span v-if="!text" style="font-size: 12px; font-style: italic">无文件</span>
|
||||
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<${entityName}Modal ref="registerModal" @success="handleSuccess"></${entityName}Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="${entityPackage}-${entityName?uncap_first}" setup>
|
||||
import { ref, reactive, unref } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns } from './${entityName}.data';
|
||||
import {list, delete${entityName}, batchDelete${entityName}, getExportUrl,getImportUrl, getChildList,getChildListBatch} from './${entityName}.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import ${entityName}Modal from './components/${entityName}Modal.vue'
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
<#if need_category>
|
||||
import { loadCategoryData } from '/@/api/common/api';
|
||||
import { getAuthCache, setAuthCache } from '/@/utils/auth';
|
||||
import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum';
|
||||
</#if>
|
||||
<#if need_pca>
|
||||
import { getAreaTextByCode } from '/@/components/Form/src/utils/Area';
|
||||
</#if>
|
||||
|
||||
const expandedRowKeys = ref([]);
|
||||
const queryParam = ref<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '${tableVo.ftlDescription}',
|
||||
api: list,
|
||||
columns,
|
||||
canResize:false,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam.value);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: "${tableVo.ftlDescription}",
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: success
|
||||
},
|
||||
});
|
||||
const [registerTable, {reload, collapseAll, updateTableDataRecord, findTableDataRecord,getDataSource},{ rowSelection, selectedRowKeys }] = tableContext
|
||||
const labelCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 7 },
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
});
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add();
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
async function handleEdit(record) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
async function handleDetail(record) {
|
||||
registerModal.value.disableSubmit = true;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await delete${entityName}({ id: record.id }, success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
const ids = selectedRowKeys.value.filter((item) => !item.includes('loading'));
|
||||
await batchDelete${entityName}({ id: ids }, success);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调刷新页面
|
||||
*/
|
||||
function success() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加下级
|
||||
*/
|
||||
function handleAddSub(record) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.add(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
async function handleSuccess({ isUpdate, values, expandedArr, changeParent }) {
|
||||
if (isUpdate) {
|
||||
if (changeParent) {
|
||||
reload();
|
||||
} else {
|
||||
// 编辑回调
|
||||
updateTableDataRecord(values.id, values);
|
||||
}
|
||||
} else {
|
||||
if (!values['id'] || !values['pid']) {
|
||||
//新增根节点
|
||||
reload();
|
||||
} else {
|
||||
//新增子集
|
||||
expandedRowKeys.value = [];
|
||||
for (let key of unref(expandedArr)) {
|
||||
await expandTreeNode(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 接口请求成功后回调
|
||||
*/
|
||||
function onFetchSuccess(result) {
|
||||
getDataByResult(result.items) && loadDataByExpandedRows();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据已展开的行查询数据(用于保存后刷新时异步加载子级的数据)
|
||||
*/
|
||||
async function loadDataByExpandedRows() {
|
||||
if (unref(expandedRowKeys).length > 0) {
|
||||
const res = await getChildListBatch({ parentIds: unref(expandedRowKeys).join(',') });
|
||||
if (res.success && res.result.records.length > 0) {
|
||||
//已展开的数据批量子节点
|
||||
let records = res.result.records;
|
||||
const listMap = new Map();
|
||||
for (let item of records) {
|
||||
let pid = item['${pidFieldName}'];
|
||||
if (unref(expandedRowKeys).includes(pid)) {
|
||||
let mapList = listMap.get(pid);
|
||||
if (mapList == null) {
|
||||
mapList = [];
|
||||
}
|
||||
mapList.push(item);
|
||||
listMap.set(pid, mapList);
|
||||
}
|
||||
}
|
||||
let childrenMap = listMap;
|
||||
let fn = (list) => {
|
||||
if (list) {
|
||||
list.forEach((data) => {
|
||||
if (unref(expandedRowKeys).includes(data.id)) {
|
||||
data.children = getDataByResult(childrenMap.get(data.id));
|
||||
fn(data.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
fn(getDataSource());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理数据集
|
||||
*/
|
||||
function getDataByResult(result) {
|
||||
if (result && result.length > 0) {
|
||||
return result.map((item) => {
|
||||
//判断是否标记了带有子节点
|
||||
if (item['hasChild'] == '1') {
|
||||
let loadChild = { id: item.id + '_loadChild', name: 'loading...', isLoading: true };
|
||||
item.children = [loadChild];
|
||||
}
|
||||
return item;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*树节点展开合并
|
||||
*/
|
||||
async function handleExpand(expanded, record) {
|
||||
// 判断是否是展开状态,展开状态(expanded)并且存在子集(children)并且未加载过(isLoading)的就去查询子节点数据
|
||||
if (expanded) {
|
||||
expandedRowKeys.value.push(record.id);
|
||||
if (record.children.length > 0 && !!record.children[0].isLoading) {
|
||||
let result = await getChildList({ ${pidFieldName}: record.id});
|
||||
result = result.records ? result.records : result;
|
||||
if (result && result.length > 0) {
|
||||
record.children = getDataByResult(result);
|
||||
} else {
|
||||
record.children = null;
|
||||
record.hasChild = '0';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let keyIndex = expandedRowKeys.value.indexOf(record.id);
|
||||
if (keyIndex >= 0) {
|
||||
expandedRowKeys.value.splice(keyIndex, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作表格后处理树节点展开合并
|
||||
*/
|
||||
async function expandTreeNode(key) {
|
||||
let record = findTableDataRecord(key);
|
||||
expandedRowKeys.value.push(key);
|
||||
let result = await getChildList({ ${pidFieldName}: key });
|
||||
if (result && result.length > 0) {
|
||||
record.children = getDataByResult(result);
|
||||
} else {
|
||||
record.children = null;
|
||||
record.hasChild = '0';
|
||||
}
|
||||
updateTableDataRecord(key, record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record) {
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
},
|
||||
{
|
||||
label: '添加下级',
|
||||
onClick: handleAddSub.bind(null, { pid: record.id }),
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '确定删除吗?',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
},
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
queryParam.value = {};
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
<#if need_popup>
|
||||
/**
|
||||
* popup组件值改变事件
|
||||
*/
|
||||
function setFieldsValue(map) {
|
||||
Object.keys(map).map((key) => {
|
||||
queryParam.value[key] = map[key];
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_pca>
|
||||
/**
|
||||
* 省市区点击事件
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleAreaChange(key, value) {
|
||||
queryParam.value[key] = value.join(',');
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_category>
|
||||
/**
|
||||
* form点击事件
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
queryParam.value[key] = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化字典配置
|
||||
*/
|
||||
function initDictConfig() {
|
||||
<#list columns as po>
|
||||
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
|
||||
<#if po.classType=='cat_tree' && need_category==true>
|
||||
loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => {
|
||||
if (res) {
|
||||
let allDictDate = getAuthCache(DB_DICT_DATA_KEY);
|
||||
if(!allDictDate['${po.dictField?default("")}']){
|
||||
Object.assign(allDictDate,{'${po.dictField?default("")}':res})
|
||||
}
|
||||
setAuthCache(DB_DICT_DATA_KEY,allDictDate)
|
||||
}
|
||||
});
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
initDictConfig();
|
||||
</#if>
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust{
|
||||
width: calc(50% - 15px);
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,90 @@
|
||||
import { defHttp } from "/@/utils/http/axios";
|
||||
import { Modal } from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/${entityPackage}/${entityName?uncap_first}/rootList',
|
||||
save='/${entityPackage}/${entityName?uncap_first}/add',
|
||||
edit='/${entityPackage}/${entityName?uncap_first}/edit',
|
||||
delete${entityName} = '/${entityPackage}/${entityName?uncap_first}/delete',
|
||||
importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel',
|
||||
exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls',
|
||||
loadTreeData = '/${entityPackage}/${entityName?uncap_first}/loadTreeRoot',
|
||||
getChildList = '/${entityPackage}/${entityName?uncap_first}/childList',
|
||||
getChildListBatch = '/${entityPackage}/${entityName?uncap_first}/getChildListBatch',
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
* @param params
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const delete${entityName} = (params,handleSuccess) => {
|
||||
return defHttp.delete({ url: Api.delete${entityName}, params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
* @param handleSuccess
|
||||
*/
|
||||
export const batchDelete${entityName} = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({ url: Api.delete${entityName}, data: params }, { joinParamsToUrl: true }).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
* @param isUpdate
|
||||
*/
|
||||
export const saveOrUpdateDict = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({ url: url, params },{ isTransformResponse:false });
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询全部树形节点数据
|
||||
* @param params
|
||||
*/
|
||||
export const loadTreeData = (params) => defHttp.get({ url: Api.loadTreeData,params });
|
||||
|
||||
/**
|
||||
* 查询子节点数据
|
||||
* @param params
|
||||
*/
|
||||
export const getChildList = (params) => defHttp.get({ url: Api.getChildList, params });
|
||||
|
||||
/**
|
||||
* 批量查询子节点数据
|
||||
* @param params
|
||||
*/
|
||||
export const getChildListBatch = (params) => defHttp.get({ url: Api.getChildListBatch, params },{ isTransformResponse:false });
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,235 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<template>
|
||||
<a-spin :spinning="confirmLoading">
|
||||
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol">
|
||||
<a-row>
|
||||
<#assign need_category = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign pidFieldName = "">
|
||||
<#assign hasOnlyValidate = false>
|
||||
<#assign form_span = 24>
|
||||
<#if tableVo.fieldRowNum==2>
|
||||
<#assign form_span = 12>
|
||||
<#elseif tableVo.fieldRowNum==3>
|
||||
<#assign form_span = 8>
|
||||
<#elseif tableVo.fieldRowNum==4>
|
||||
<#assign form_span = 6>
|
||||
</#if>
|
||||
<#list columns as po>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
<#assign hasOnlyValidate = true>
|
||||
</#if>
|
||||
<#if po.fieldDbName == tableVo.extendParams.pidField>
|
||||
<#assign pidFieldName = po.fieldName>
|
||||
<a-col :span="${form_span}">
|
||||
<a-form-item label="父级节点" v-bind="validateInfos.${autoStringSuffixForModel(po)}">
|
||||
<j-tree-select
|
||||
placeholder="请选择${po.filedComment}"
|
||||
v-model:value="formData.${po.fieldName}"
|
||||
dict="${tableVo.tableName},${tableVo.extendParams.textField},id"
|
||||
pidField="${tableVo.extendParams.pidField}"
|
||||
pidValue="0"
|
||||
hasChildField="${tableVo.extendParams.hasChildren}"
|
||||
<#if po.readonly=='Y'>disabled<#else>:disabled="disabled"</#if>>
|
||||
</j-tree-select>
|
||||
</a-form-item>
|
||||
</a-col>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeForm.ftl">
|
||||
</#list>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, reactive, defineExpose, nextTick, unref, defineProps, computed } from 'vue';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import moment from 'moment';
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
import { getValueType } from '/@/utils';
|
||||
import { validateDuplicateValue } from '/@/utils/helper/validator';
|
||||
import {loadTreeData, saveOrUpdateDict} from '../${entityName}.api';
|
||||
import { Form } from 'ant-design-vue';
|
||||
<#if hasOnlyValidate == true>
|
||||
import { duplicateValidate } from '/@/utils/helper/validator'
|
||||
</#if>
|
||||
|
||||
const useForm = Form.useForm;
|
||||
const formRef = ref();
|
||||
const isUpdate = ref(true);
|
||||
const expandedRowKeys = ref([]);
|
||||
const treeData = ref([]);
|
||||
const pidField = ref<string>('pid');
|
||||
const emit = defineEmits(['register', 'ok']);
|
||||
let model: Nullable<Recordable> = null;
|
||||
const formData = reactive<Record<string, any>>({
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y'>
|
||||
<#if po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'>
|
||||
${po.fieldName}: undefined,
|
||||
<#elseif po.fieldDbType=='Blob'>
|
||||
${po.fieldName}String: '',
|
||||
<#else>
|
||||
${po.fieldName}: '',
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
const { createMessage } = useMessage();
|
||||
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } });
|
||||
const wrapperCol = ref<any>({ xs: { span: 24 }, sm: { span: 16 } });
|
||||
const confirmLoading = ref<boolean>(false);
|
||||
//表单验证
|
||||
const validatorRules = {
|
||||
<#include "/common/validatorRulesTemplate/native/vue3MainNative.ftl">
|
||||
};
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true });
|
||||
const props = defineProps({
|
||||
disabled: { type: Boolean, default: false },
|
||||
});
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add(obj = {}) {
|
||||
edit(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
function edit(record) {
|
||||
nextTick(async () => {
|
||||
resetFields();
|
||||
expandedRowKeys.value = [];
|
||||
treeData.value = await loadTreeData({ async: false, pcode: '' });
|
||||
//赋值
|
||||
Object.assign(formData, record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据pid获取展开的节点
|
||||
* @param pid
|
||||
* @param arr
|
||||
*/
|
||||
function getExpandKeysByPid(pid, arr) {
|
||||
if (pid && arr && arr.length > 0) {
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
if (arr[i].key == pid && unref(expandedRowKeys).indexOf(pid) < 0) {
|
||||
expandedRowKeys.value.push(arr[i].key);
|
||||
getExpandKeysByPid(arr[i]['parentId'], unref(treeData));
|
||||
} else {
|
||||
getExpandKeysByPid(pid, arr[i].children);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交数据
|
||||
*/
|
||||
async function submitForm() {
|
||||
// 触发表单验证
|
||||
await validate();
|
||||
confirmLoading.value = true;
|
||||
const isUpdate = ref<boolean>(false);
|
||||
//时间格式化
|
||||
if (formData.id) {
|
||||
isUpdate.value = true;
|
||||
}
|
||||
//循环数据
|
||||
for (let data in formData) {
|
||||
//如果该数据是数组并且是字符串类型
|
||||
if (formData[data] instanceof Array) {
|
||||
let valueType = getValueType(formRef.value.getProps, data);
|
||||
//如果是字符串类型的需要变成以逗号分割的字符串
|
||||
if (valueType === 'string') {
|
||||
formData[data] = formData[data].join(',');
|
||||
}
|
||||
}
|
||||
}
|
||||
await saveOrUpdateDict(formData, isUpdate.value)
|
||||
.then(async (res) => {
|
||||
if (res.success) {
|
||||
await getExpandKeysByPid(formData['${pidFieldName}'], unref(treeData));
|
||||
emit('ok', {
|
||||
isUpdate: unref(isUpdate),
|
||||
values: { ...formData },
|
||||
expandedArr: unref(expandedRowKeys).reverse(),
|
||||
// 是否更改了父级节点
|
||||
changeParent: model != null && model['${pidFieldName}'] != formData['${pidFieldName}'],
|
||||
});
|
||||
createMessage.success(res.message);
|
||||
} else {
|
||||
createMessage.warning(res.message);
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
confirmLoading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
<#if need_popup>
|
||||
/**
|
||||
* popup组件值改变事件
|
||||
*/
|
||||
function setFieldsValue(map) {
|
||||
Object.keys(map).map((key) => {
|
||||
formData[key] = map[key];
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_category || need_select_tree>
|
||||
/**
|
||||
* 值改变事件触发
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
formData[key] = value;
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
async function ${po.fieldName}Duplicatevalidate(_r, value) {
|
||||
return duplicateValidate('${tableName}', '${po.fieldDbName}', value, formData.id || '')
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
submitForm,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.antd-modal-form {
|
||||
height: 500px !important;
|
||||
overflow-y: auto;
|
||||
padding: 24px 24px 24px 24px;
|
||||
}
|
||||
</style>
|
@ -0,0 +1,81 @@
|
||||
<template>
|
||||
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭">
|
||||
<${entityName}Form ref="registerForm" @ok="submitCallback" :disabled="disableSubmit"></${entityName}Form>
|
||||
</a-modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { ref, nextTick, defineExpose } from 'vue';
|
||||
import ${entityName}Form from './${entityName}Form.vue'
|
||||
|
||||
const title = ref<string>('');
|
||||
const width = ref<number>(800);
|
||||
const visible = ref<boolean>(false);
|
||||
const disableSubmit = ref<boolean>(false);
|
||||
const registerForm = ref();
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
|
||||
/**
|
||||
* 新增
|
||||
*/
|
||||
function add(obj={}) {
|
||||
title.value = '新增';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.add(obj);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
* @param record
|
||||
*/
|
||||
function edit(record) {
|
||||
title.value = disableSubmit.value ? '详情' : '编辑';
|
||||
visible.value = true;
|
||||
nextTick(() => {
|
||||
registerForm.value.edit(record);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 确定按钮点击事件
|
||||
*/
|
||||
function handleOk() {
|
||||
registerForm.value.submitForm();
|
||||
}
|
||||
|
||||
/**
|
||||
* form保存回调事件
|
||||
*/
|
||||
function submitCallback({ isUpdate, values, expandedArr, changeParent }) {
|
||||
handleCancel();
|
||||
emit('success', {
|
||||
isUpdate: isUpdate,
|
||||
values: values,
|
||||
expandedArr: expandedArr,
|
||||
// 是否更改了父级节点
|
||||
changeParent: changeParent,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消按钮回调事件
|
||||
*/
|
||||
function handleCancel() {
|
||||
visible.value = false;
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
add,
|
||||
edit,
|
||||
disableSubmit,
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
/**隐藏样式-modal确定按钮 */
|
||||
.jee-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
</style>
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,340 @@
|
||||
<template>
|
||||
<div>
|
||||
<#assign query_field_no=0>
|
||||
<#assign need_category = false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form @keyup.enter.native="reload" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<#-- 开始循环 -->
|
||||
<#list columns as po>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0>
|
||||
<#assign need_category=true>
|
||||
</#if>
|
||||
<#if po.classType=='pca'>
|
||||
<#assign need_pca=true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_search'>
|
||||
<#assign need_search = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_user'>
|
||||
<#assign need_dept_user = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_depart'>
|
||||
<#assign need_dept = true>
|
||||
</#if>
|
||||
<#if po.classType=='switch'>
|
||||
<#assign need_switch = true>
|
||||
</#if>
|
||||
<#if po.classType=='list_multi'>
|
||||
<#assign need_multi = true>
|
||||
</#if>
|
||||
<#if po.classType=='popup'>
|
||||
<#assign need_popup = true>
|
||||
</#if>
|
||||
<#if po.classType=='sel_tree'>
|
||||
<#assign need_select_tree = true>
|
||||
</#if>
|
||||
<#if po.classType=='time'>
|
||||
<#assign need_time = true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeSearch.ftl">
|
||||
</#list>
|
||||
<#if query_field_no gt 2>
|
||||
</template>
|
||||
</#if>
|
||||
<#if query_flag>
|
||||
<a-col :xl="6" :lg="7" :md="8" :sm="24">
|
||||
<span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
|
||||
<a-col :lg="6">
|
||||
<a-button type="primary" preIcon="ant-design:search-outlined" @click="reload">查询</a-button>
|
||||
<a-button preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
|
||||
<a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
|
||||
{{ toggleSearchStatus ? '收起' : '展开' }}
|
||||
<Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
|
||||
</a>
|
||||
</a-col>
|
||||
</span>
|
||||
</a-col>
|
||||
</#if>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<#-- 结束循环 -->
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<!--插槽:table标题-->
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
|
||||
<j-upload-button type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
|
||||
<a-dropdown v-if="selectedRowKeys.length > 0">
|
||||
<template #overlay>
|
||||
<a-menu>
|
||||
<a-menu-item key="1" @click="batchHandleDelete">
|
||||
<Icon icon="ant-design:delete-outlined"></Icon>
|
||||
删除
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</template>
|
||||
<a-button>批量操作
|
||||
<Icon icon="mdi:chevron-down"></Icon>
|
||||
</a-button>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
|
||||
</template>
|
||||
<!--字段回显插槽-->
|
||||
<template #htmlSlot="{text}">
|
||||
<div v-html="text"></div>
|
||||
</template>
|
||||
<!--省市区字段回显插槽-->
|
||||
<template #pcaSlot="{text}">
|
||||
{{ getAreaTextByCode(text) }}
|
||||
</template>
|
||||
<template #fileSlot="{text}">
|
||||
<span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
|
||||
<a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button>
|
||||
</template>
|
||||
</BasicTable>
|
||||
<!-- 表单区域 -->
|
||||
<${entityName}Modal @register="registerModal" @success="handleSuccess"></${entityName}Modal>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="${entityPackage}-${entityName?uncap_first}" setup>
|
||||
import {ref, reactive, computed, unref} from 'vue';
|
||||
import {BasicTable, useTable, TableAction} from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage'
|
||||
import {useModal} from '/@/components/Modal';
|
||||
import ${entityName}Modal from './components/${entityName}Modal.vue'
|
||||
import {columns, searchFormSchema} from './${entityName}.data';
|
||||
import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './${entityName}.api';
|
||||
import {downloadFile} from '/@/utils/common/renderUtils';
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
<#if need_pca>
|
||||
import { getAreaTextByCode } from '/@/components/Form/src/utils/Area';
|
||||
</#if>
|
||||
<#if need_category>
|
||||
import { loadCategoryData } from '/@/api/common/api'
|
||||
import { getAuthCache, setAuthCache } from '/@/utils/auth';
|
||||
import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum';
|
||||
</#if>
|
||||
const checkedKeys = ref<Array<string | number>>([]);
|
||||
//注册model
|
||||
const [registerModal, {openModal}] = useModal();
|
||||
//注册table数据
|
||||
const { prefixCls,tableContext,onExportXls,onImportXls } = useListPage({
|
||||
tableProps:{
|
||||
title: '${tableVo.ftlDescription}',
|
||||
api: list,
|
||||
columns,
|
||||
canResize:false,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed:'right'
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam.value);
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name:"${tableVo.ftlDescription}",
|
||||
url: getExportUrl,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess
|
||||
},
|
||||
})
|
||||
|
||||
const [registerTable, {reload},{ rowSelection, selectedRowKeys }] = tableContext
|
||||
|
||||
/**
|
||||
* 新增事件
|
||||
*/
|
||||
function handleAdd() {
|
||||
openModal(true, {
|
||||
isUpdate: false,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: true,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
function handleDetail(record: Recordable) {
|
||||
openModal(true, {
|
||||
record,
|
||||
isUpdate: true,
|
||||
showFooter: false,
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 删除事件
|
||||
*/
|
||||
async function handleDelete(record) {
|
||||
await deleteOne({id: record.id}, handleSuccess);
|
||||
}
|
||||
/**
|
||||
* 批量删除事件
|
||||
*/
|
||||
async function batchHandleDelete() {
|
||||
await batchDelete({ids: selectedRowKeys.value},handleSuccess);
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record){
|
||||
return [
|
||||
{
|
||||
label: '编辑',
|
||||
onClick: handleEdit.bind(null, record),
|
||||
}
|
||||
]
|
||||
}
|
||||
/**
|
||||
* 下拉操作栏
|
||||
*/
|
||||
function getDropDownAction(record){
|
||||
return [
|
||||
{
|
||||
label: '详情',
|
||||
onClick: handleDetail.bind(null, record),
|
||||
}, {
|
||||
label: '删除',
|
||||
popConfirm: {
|
||||
title: '是否确认删除',
|
||||
confirm: handleDelete.bind(null, record),
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
<#if need_category>
|
||||
/**
|
||||
* form点击事件
|
||||
* @param value
|
||||
*/
|
||||
function handleFormChange(key, value) {
|
||||
queryParam.value[key] = value;
|
||||
}
|
||||
/**
|
||||
* 初始化字典配置
|
||||
*/
|
||||
function initDictConfig(){
|
||||
<#list columns as po>
|
||||
<#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'>
|
||||
<#if po.classType=='cat_tree' && need_category==true>
|
||||
loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => {
|
||||
if (res) {
|
||||
let allDictDate = getAuthCache(DB_DICT_DATA_KEY);
|
||||
if(!allDictDate['${po.dictField?default("")}']){
|
||||
Object.assign(allDictDate,{'${po.dictField?default("")}':res})
|
||||
}
|
||||
setAuthCache(DB_DICT_DATA_KEY,allDictDate)
|
||||
}
|
||||
})
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
initDictConfig();
|
||||
</#if>
|
||||
|
||||
/* ----------------------以下为原生查询需要添加的-------------------------- */
|
||||
const queryParam = ref<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const labelCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 7 },
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: { span: 24 },
|
||||
sm: { span: 16 },
|
||||
});
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
queryParam.value = {};
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
<#if need_popup>
|
||||
/**
|
||||
* popup组件值改变事件
|
||||
*/
|
||||
function setFieldsValue(map) {
|
||||
Object.keys(map).map((key) => {
|
||||
queryParam.value[key] = map[key];
|
||||
});
|
||||
}
|
||||
</#if>
|
||||
|
||||
<#if need_pca>
|
||||
/**
|
||||
* 省市区点击事件
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
function handleAreaChange(key, value) {
|
||||
queryParam.value[key] = value.join(',');
|
||||
}
|
||||
</#if>
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust{
|
||||
width: calc(50% - 15px);
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
}
|
||||
</style>
|
@ -0,0 +1,82 @@
|
||||
import {defHttp} from '/@/utils/http/axios';
|
||||
import {Modal} from 'ant-design-vue';
|
||||
|
||||
enum Api {
|
||||
list = '/${entityPackage}/${entityName?uncap_first}/list',
|
||||
save='/${entityPackage}/${entityName?uncap_first}/add',
|
||||
edit='/${entityPackage}/${entityName?uncap_first}/edit',
|
||||
deleteOne = '/${entityPackage}/${entityName?uncap_first}/delete',
|
||||
deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch',
|
||||
importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel',
|
||||
exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls',
|
||||
queryDataById = '/${entityPackage}/${entityName?uncap_first}/queryById',
|
||||
<#list subTables as sub><#rt/>
|
||||
${sub.entityName?uncap_first}List = '/${entityPackage}/${entityName?uncap_first}/query${sub.entityName}ByMainId',
|
||||
</#list>
|
||||
}
|
||||
/**
|
||||
* 导出api
|
||||
* @param params
|
||||
*/
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
/**
|
||||
* 导入api
|
||||
*/
|
||||
export const getImportUrl = Api.importExcel;
|
||||
|
||||
<#list subTables as sub><#rt/>
|
||||
/**
|
||||
* 查询子表数据
|
||||
* @param params
|
||||
*/
|
||||
export const query${sub.entityName}ListByMainId = (id) => defHttp.get({url: Api.${sub.entityName?uncap_first}List, params:{ id }});
|
||||
</#list>
|
||||
|
||||
/**
|
||||
* 列表接口
|
||||
* @param params
|
||||
*/
|
||||
export const list = (params) =>
|
||||
defHttp.get({url: Api.list, params});
|
||||
|
||||
/**
|
||||
* 删除单个
|
||||
*/
|
||||
export const deleteOne = (params,handleSuccess) => {
|
||||
return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 批量删除
|
||||
* @param params
|
||||
*/
|
||||
export const batchDelete = (params, handleSuccess) => {
|
||||
Modal.confirm({
|
||||
title: '确认删除',
|
||||
content: '是否删除选中数据',
|
||||
okText: '确认',
|
||||
cancelText: '取消',
|
||||
onOk: () => {
|
||||
return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => {
|
||||
handleSuccess();
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 保存或者更新
|
||||
* @param params
|
||||
*/
|
||||
export const saveOrUpdate = (params, isUpdate) => {
|
||||
let url = isUpdate ? Api.edit : Api.save;
|
||||
return defHttp.post({url: url, params});
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据id查询数据
|
||||
* @param params
|
||||
*/
|
||||
export const queryDataById = (id) => defHttp.get({url: Api.queryDataById, params:{ id }});
|
||||
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1,264 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<#assign need_category = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign form_span = 24>
|
||||
<#if tableVo.fieldRowNum==2>
|
||||
<#assign form_span = 12>
|
||||
<#elseif tableVo.fieldRowNum==3>
|
||||
<#assign form_span = 8>
|
||||
<#elseif tableVo.fieldRowNum==4>
|
||||
<#assign form_span = 6>
|
||||
</#if>
|
||||
<#assign hasOne2manyTable = false>
|
||||
<#assign subTabActiveKey = ''>
|
||||
<#assign subMainFieldMap={}>
|
||||
<#assign subTableColumnsKey=[]>
|
||||
<#assign hasOnlyValidate = false>
|
||||
<template>
|
||||
<a-spin :spinning="loading">
|
||||
<a-form v-bind="formItemLayout">
|
||||
<a-row>
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
<#assign hasOnlyValidate = true>
|
||||
</#if>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeForm.ftl">
|
||||
</#list>
|
||||
</a-row>
|
||||
</a-form>
|
||||
|
||||
<!-- 子表单区域 -->
|
||||
<a-tabs v-model:activeKey="activeKey">
|
||||
<#list subTables as sub><#rt/>
|
||||
<a-tab-pane tab="${sub.ftlDescription}" key="${sub.entityName?uncap_first}" :forceRender="true">
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
<${Format.humpToShortbar(sub.entityName)}-form ref="${sub.entityName?uncap_first}FormRef" :disabled="formDisabled"></${Format.humpToShortbar(sub.entityName)}-form>
|
||||
<#else>
|
||||
<j-vxe-table
|
||||
:keep-source="true"
|
||||
ref="${sub.entityName?uncap_first}TableRef"
|
||||
:loading="${sub.entityName?uncap_first}Table.loading"
|
||||
:columns="${sub.entityName?uncap_first}Table.columns"
|
||||
:dataSource="${sub.entityName?uncap_first}Table.dataSource"
|
||||
:maxHeight="300"
|
||||
:disabled="formDisabled"
|
||||
:rowNumber="true"
|
||||
:rowSelection="true"
|
||||
:toolbar="true"/>
|
||||
</#if>
|
||||
</a-tab-pane>
|
||||
</#list>
|
||||
</a-tabs>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, reactive, computed, toRaw } from 'vue';
|
||||
import { useValidateAntFormAndTable } from '/@/hooks/system/useJvxeMethods';
|
||||
import { <#list subTables as sub><#if sub.foreignRelationType =='0'>query${sub.entityName}ListByMainId, </#if></#list>queryDataById, saveOrUpdate } from '../${entityName}.api';
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
import ${sub.entityName}Form from './${sub.entityName}Form.vue'
|
||||
<#else>
|
||||
<#assign hasOne2manyTable = true>
|
||||
<#assign subTableColumnsKey += ['${sub.entityName?uncap_first}Columns']>
|
||||
</#if>
|
||||
<#if sub?? && (sub.foreignMainKeys)??>
|
||||
<#list sub.foreignMainKeys as key>
|
||||
<#assign subMainFieldMap += {"${sub.entityName}": "${dashedToCamel(key)}"}>
|
||||
</#list>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if hasOne2manyTable == true>
|
||||
import { JVxeTable } from '/@/components/jeecg/JVxeTable';
|
||||
import {<#list subTableColumnsKey as columnsKey><#if columnsKey_index gt 0>, </#if>${columnsKey}</#list>} from '../${entityName}.data';
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
<#if hasOnlyValidate == true>
|
||||
import { duplicateValidate } from '/@/utils/helper/validator'
|
||||
</#if>
|
||||
import { Form } from 'ant-design-vue';
|
||||
const useForm = Form.useForm;
|
||||
|
||||
export default defineComponent({
|
||||
name: "${entityName}Form",
|
||||
components:{
|
||||
<#include "/common/form/native/vue3NativeComponents.ftl">
|
||||
<#if hasOne2manyTable == true>
|
||||
JVxeTable,
|
||||
</#if>
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
${sub.entityName}Form,
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
props:{
|
||||
disabled:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
emits:['success'],
|
||||
setup(props, {emit}) {
|
||||
const loading = ref(false);
|
||||
<#list subTables as sub>
|
||||
<#if sub_index == 0>
|
||||
<#assign subTabActiveKey = '${sub.entityName?uncap_first}'>
|
||||
</#if>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
const ${sub.entityName?uncap_first}FormRef = ref();
|
||||
<#else>
|
||||
const ${sub.entityName?uncap_first}TableRef = ref();
|
||||
const ${sub.entityName?uncap_first}Table = reactive<Record<string, any>>({
|
||||
loading: false,
|
||||
columns: ${sub.entityName?uncap_first}Columns,
|
||||
dataSource: []
|
||||
});
|
||||
</#if>
|
||||
</#list>
|
||||
const activeKey = ref('${subTabActiveKey}');
|
||||
const formData = reactive<Record<string, any>>({
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y'>
|
||||
${po.fieldName}: '',
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
|
||||
//表单验证
|
||||
const validatorRules = reactive({
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && poHasCheck(po)>
|
||||
${po.fieldName}: [<#include "/common/validatorRulesTemplate/native/vue3CoreNative.ftl">],
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
const {resetFields, validate, validateInfos} = useForm(formData, validatorRules, {immediate: true});
|
||||
const dbData = {};
|
||||
const formItemLayout = {
|
||||
labelCol: {xs: {span: 24}, sm: {span: 5}},
|
||||
wrapperCol: {xs: {span: 24}, sm: {span: 16}},
|
||||
};
|
||||
|
||||
const formDisabled = computed(() => {
|
||||
return props.disabled;
|
||||
});
|
||||
|
||||
function add() {
|
||||
resetFields();
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
${sub.entityName?uncap_first}FormRef.value.initFormData();
|
||||
<#else>
|
||||
${sub.entityName?uncap_first}Table.dataSource = [];
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
|
||||
async function edit(row) {
|
||||
//主表数据
|
||||
await queryMainData(row.id);
|
||||
//子表数据
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
await ${sub.entityName?uncap_first}FormRef.value.initFormData(row['${subMainFieldMap[sub.entityName]}']);
|
||||
<#else>
|
||||
const ${sub.entityName?uncap_first}DataList = await query${sub.entityName}ListByMainId(row['${subMainFieldMap[sub.entityName]}']);
|
||||
${sub.entityName?uncap_first}Table.dataSource = [...${sub.entityName?uncap_first}DataList];
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
|
||||
async function queryMainData(id) {
|
||||
const row = await queryDataById(id);
|
||||
Object.keys(row).map(k => {
|
||||
formData[k] = row[k];
|
||||
});
|
||||
}
|
||||
|
||||
const {getSubFormAndTableData, transformData} = useValidateAntFormAndTable(activeKey, {
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
'${sub.entityName?uncap_first}': ${sub.entityName?uncap_first}FormRef,
|
||||
<#else>
|
||||
'${sub.entityName?uncap_first}': ${sub.entityName?uncap_first}TableRef,
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
|
||||
async function getFormData() {
|
||||
await validate();
|
||||
return transformData(toRaw(formData))
|
||||
}
|
||||
|
||||
async function submitForm() {
|
||||
const mainData = await getFormData();
|
||||
const subData = await getSubFormAndTableData();
|
||||
const values = Object.assign({}, dbData, mainData, subData);
|
||||
console.log('表单提交数据', values)
|
||||
const isUpdate = values.id ? true : false
|
||||
await saveOrUpdate(values, isUpdate);
|
||||
//关闭弹窗
|
||||
emit('success');
|
||||
}
|
||||
|
||||
function setFieldsValue(values) {
|
||||
if(values){
|
||||
Object.keys(values).map(k=>{
|
||||
formData[k] = values[k];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<#list columns as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
async function ${po.fieldName}Duplicatevalidate(_r, value) {
|
||||
return duplicateValidate('${tableName}', '${po.fieldDbName}', value, formData.id || '')
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
return {
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType =='1'>
|
||||
${sub.entityName?uncap_first}FormRef,
|
||||
<#else>
|
||||
${sub.entityName?uncap_first}TableRef,
|
||||
${sub.entityName?uncap_first}Table,
|
||||
</#if>
|
||||
</#list>
|
||||
validatorRules,
|
||||
validateInfos,
|
||||
activeKey,
|
||||
loading,
|
||||
formData,
|
||||
setFieldsValue,
|
||||
formItemLayout,
|
||||
formDisabled,
|
||||
getFormData,
|
||||
submitForm,
|
||||
add,
|
||||
edit
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
@ -0,0 +1,69 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" :width="${getModalWidth(tableVo.fieldRowNum?default(1))}" @ok="handleSubmit">
|
||||
<${Format.humpToShortbar(entityName)}-form ref="formComponent" :disabled="formDisabled" @success="submitSuccess"></${Format.humpToShortbar(entityName)}-form>
|
||||
</BasicModal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import ${entityName}Form from './${entityName}Form.vue';
|
||||
|
||||
export default {
|
||||
name: "TestCgMainVxeModal",
|
||||
components:{
|
||||
BasicModal,
|
||||
${entityName}Form
|
||||
},
|
||||
emits:['register','success'],
|
||||
setup(_p, {emit}){
|
||||
const formComponent = ref()
|
||||
const isUpdate = ref(true);
|
||||
const formDisabled = ref(false);
|
||||
const title = ref('')
|
||||
|
||||
//表单赋值
|
||||
const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => {
|
||||
setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter});
|
||||
isUpdate.value = !!data?.isUpdate;
|
||||
title.value = data?.isUpdate?'编辑':'新增'
|
||||
formDisabled.value = !data?.showFooter;
|
||||
if (unref(isUpdate)) {
|
||||
console.log('data', data)
|
||||
formComponent.value.edit(data.record)
|
||||
}else{
|
||||
formComponent.value.add()
|
||||
}
|
||||
});
|
||||
|
||||
function handleSubmit() {
|
||||
formComponent.value.submitForm();
|
||||
}
|
||||
|
||||
function submitSuccess(){
|
||||
emit('success');
|
||||
closeModal();
|
||||
}
|
||||
|
||||
return {
|
||||
registerModal,
|
||||
title,
|
||||
formComponent,
|
||||
formDisabled,
|
||||
handleSubmit,
|
||||
submitSuccess
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style lang="less" scoped>
|
||||
/** 时间和数字输入框样式 */
|
||||
:deep(.ant-input-number){
|
||||
width: 100%
|
||||
}
|
||||
|
||||
:deep(.ant-calendar-picker){
|
||||
width: 100%
|
||||
}
|
||||
</style>
|
@ -0,0 +1,149 @@
|
||||
<#include "/common/utils.ftl">
|
||||
<#list subTables as sub>
|
||||
<#if sub.foreignRelationType=='1'>
|
||||
#segment#${sub.entityName}Form.vue
|
||||
<#include "/common/utils.ftl">
|
||||
<#assign need_category = false>
|
||||
<#assign bpm_flag=false>
|
||||
<#assign need_pca = false>
|
||||
<#assign need_search = false>
|
||||
<#assign need_dept_user = false>
|
||||
<#assign need_switch = false>
|
||||
<#assign need_dept = false>
|
||||
<#assign need_multi = false>
|
||||
<#assign need_popup = false>
|
||||
<#assign need_select_tag = false>
|
||||
<#assign need_select_tree = false>
|
||||
<#assign need_time = false>
|
||||
<#assign need_markdown = false>
|
||||
<#assign need_upload = false>
|
||||
<#assign need_image_upload = false>
|
||||
<#assign need_editor = false>
|
||||
<#assign need_checkbox = false>
|
||||
<#assign form_span = 24>
|
||||
<#if tableVo.fieldRowNum==2>
|
||||
<#assign form_span = 12>
|
||||
<#elseif tableVo.fieldRowNum==3>
|
||||
<#assign form_span = 8>
|
||||
<#elseif tableVo.fieldRowNum==4>
|
||||
<#assign form_span = 6>
|
||||
</#if>
|
||||
<#assign hasOnlyValidate = false>
|
||||
<template>
|
||||
<a-spin :spinning="loading">
|
||||
<a-form v-bind="formItemLayout">
|
||||
<a-row>
|
||||
<#list sub.colums as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
<#assign hasOnlyValidate = true>
|
||||
</#if>
|
||||
<#if po.fieldDbName=='bpm_status'>
|
||||
<#assign bpm_flag=true>
|
||||
</#if>
|
||||
<#include "/common/form/native/vue3NativeForm.ftl">
|
||||
</#list>
|
||||
</a-row>
|
||||
</a-form>
|
||||
</a-spin>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, reactive, toRaw } from 'vue';
|
||||
import { query${sub.entityName}ListByMainId } from '../${entityName}.api';
|
||||
<#include "/common/form/native/vue3NativeImport.ftl">
|
||||
<#if hasOnlyValidate == true>
|
||||
import { duplicateValidate } from '/@/utils/helper/validator'
|
||||
</#if>
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { Form } from 'ant-design-vue';
|
||||
const useForm = Form.useForm;
|
||||
|
||||
export default defineComponent({
|
||||
name: '${sub.entityName}Form',
|
||||
components:{
|
||||
<#include "/common/form/native/vue3NativeComponents.ftl">
|
||||
},
|
||||
props:{
|
||||
disabled:{
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
setup(){
|
||||
const { createMessage } = useMessage();
|
||||
const isForm = true;
|
||||
const loading = ref(false);
|
||||
const formData = reactive<Record<string, any>>({
|
||||
<#list sub.colums as po>
|
||||
<#if po.isShow == 'Y'>
|
||||
${po.fieldName}: '',
|
||||
</#if>
|
||||
</#list>
|
||||
});
|
||||
//表单验证
|
||||
const validatorRules = reactive({
|
||||
<#list sub.colums as po>
|
||||
<#if po.isShow == 'Y' && poHasCheck(po)>
|
||||
${po.fieldName}: [<#include "/common/validatorRulesTemplate/native/vue3CoreNative.ftl">],
|
||||
</#if>
|
||||
</#list>
|
||||
})
|
||||
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, {immediate: true});
|
||||
const formItemLayout = {
|
||||
labelCol: { xs: { span: 24 }, sm: { span: 5 } },
|
||||
wrapperCol: { xs: { span: 24 }, sm: { span: 16 } },
|
||||
};
|
||||
|
||||
async function initFormData(mainId) {
|
||||
resetFields();
|
||||
if(mainId){
|
||||
let list = await query${sub.entityName}ListByMainId(mainId);
|
||||
if(list && list.length>0){
|
||||
let temp = list[0];
|
||||
Object.keys(temp).map(k=>{
|
||||
formData[k] = temp[k];
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function getFormData() {
|
||||
await validate();
|
||||
let subFormData = toRaw(formData);
|
||||
if(Object.keys(subFormData).length>0){
|
||||
return subFormData
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function setFieldsValue(values) {
|
||||
if(values){
|
||||
Object.keys(values).map(k=>{
|
||||
formData[k] = values[k];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
<#list sub.colums as po>
|
||||
<#if po.isShow == 'Y' && po.fieldValidType?default("") == 'only'>
|
||||
async function ${po.fieldName}Duplicatevalidate(_r, value) {
|
||||
return duplicateValidate('${sub.tableName}', '${po.fieldDbName}', value, formData.id || '')
|
||||
}
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
return {
|
||||
loading,
|
||||
formData,
|
||||
formItemLayout,
|
||||
initFormData,
|
||||
getFormData,
|
||||
setFieldsValue,
|
||||
isForm,
|
||||
validateInfos
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</#if>
|
||||
</#list>
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
@ -0,0 +1 @@
|
||||
<#include "/common/sql/menu_insert.ftl">
|
Loading…
Reference in new issue