Commit ccac1c85311e3b9ab0befc9aef419f80c12a6eeb
1 parent
78451b6e
暂时删除vue3模板,因为vue3前端项目未正式发布,减少大家的误解
Showing
13 changed files
with
0 additions
and
2788 deletions
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei deleted
1 | -<template> | |
2 | - <div> | |
3 | -<#assign list_need_category=false> | |
4 | -<#assign list_need_pca=false> | |
5 | -<#assign bpm_flag=false> | |
6 | - | |
7 | -<#-- 开始循环 --> | |
8 | -<#list columns as po> | |
9 | -<#if po.fieldDbName=='bpm_status'> | |
10 | - <#assign bpm_flag=true> | |
11 | -</#if> | |
12 | -<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0> | |
13 | -<#assign list_need_category=true> | |
14 | -</#if> | |
15 | -<#if po.classType=='pca'> | |
16 | -<#assign list_need_pca=true> | |
17 | -</#if> | |
18 | -</#list> | |
19 | -<#-- 结束循环 --> | |
20 | - <!--引用表格--> | |
21 | - <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |
22 | - <!--插槽:table标题--> | |
23 | - <template #tableTitle> | |
24 | - <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |
25 | - <ExcelButton :config="excelConfig"></ExcelButton> | |
26 | - <a-dropdown v-if="checkedKeys.length > 0"> | |
27 | - <template #overlay> | |
28 | - <a-menu> | |
29 | - <a-menu-item key="1" @click="batchHandleDelete"> | |
30 | - <Icon icon="ant-design:delete-outlined"></Icon> | |
31 | - 删除 | |
32 | - </a-menu-item> | |
33 | - </a-menu> | |
34 | - </template> | |
35 | - <a-button>批量操作 | |
36 | - <Icon icon="mdi:chevron-down"></Icon> | |
37 | - </a-button> | |
38 | - </a-dropdown> | |
39 | - </template> | |
40 | - <!--操作栏--> | |
41 | - <template #action="{ record }"> | |
42 | - <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> | |
43 | - </template> | |
44 | - <!--字段回显插槽--> | |
45 | - <template #htmlSlot="{text}"> | |
46 | - <div v-html="text"></div> | |
47 | - </template> | |
48 | - <template #fileSlot="{text}"> | |
49 | - <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span> | |
50 | - <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button> | |
51 | - </template> | |
52 | - </BasicTable> | |
53 | - <!-- 表单区域 --> | |
54 | - <${entityName}Modal @register="registerModal" @success="handleSuccess"></${entityName}Modal> | |
55 | - </div> | |
56 | -</template> | |
57 | - | |
58 | -<script lang="ts" setup> | |
59 | - import {ref, computed, unref} from 'vue'; | |
60 | - import {BasicTable, useTable, TableAction} from '/@/components/Table'; | |
61 | - import ExcelButton from '/@/components/jeecg/ExcelButton.vue' | |
62 | - import {useModal} from '/@/components/Modal'; | |
63 | - import ${entityName}Modal from './components/${entityName}Modal.vue' | |
64 | - import {columns, searchFormSchema} from './${entityName?uncap_first}.data'; | |
65 | - import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './${entityName?uncap_first}.api'; | |
66 | - <#if list_need_category> | |
67 | - import { loadCategoryData } from '/@/api/common/api' | |
68 | - import { getAuthCache, setAuthCache } from '/@/utils/auth'; | |
69 | - import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum'; | |
70 | - </#if> | |
71 | - const checkedKeys = ref<Array<string | number>>([]); | |
72 | - //注册model | |
73 | - const [registerModal, {openModal}] = useModal(); | |
74 | - //注册table数据 | |
75 | - const [registerTable, {reload}] = useTable({ | |
76 | - title: '${tableVo.ftlDescription}', | |
77 | - api: list, | |
78 | - rowKey: 'id', | |
79 | - columns, | |
80 | - formConfig: { | |
81 | - labelWidth: 120, | |
82 | - schemas: searchFormSchema, | |
83 | - autoSubmitOnEnter:true, | |
84 | - showAdvancedButton:true, | |
85 | - fieldMapToTime: [ | |
86 | - <#list columns as po> | |
87 | - <#if po.isQuery=='Y'> | |
88 | - <#if po.queryMode!='single'> | |
89 | - <#if po.classType=='date'> | |
90 | - ['${po.fieldName}', ['${po.fieldName}_begin', '${po.fieldName}_end'], 'YYYY-MM-DD'], | |
91 | - <#elseif po.classType=='datetime'> | |
92 | - ['${po.fieldName}', ['${po.fieldName}_begin', '${po.fieldName}_end'], 'YYYY-MM-DD HH:mm:ss'], | |
93 | - </#if> | |
94 | - </#if> | |
95 | - </#if> | |
96 | - </#list> | |
97 | - ], | |
98 | - }, | |
99 | - striped: true, | |
100 | - useSearchForm: true, | |
101 | - showTableSetting: true, | |
102 | - clickToRowSelect: false, | |
103 | - bordered: true, | |
104 | - showIndexColumn: false, | |
105 | - tableSetting: {fullScreen: true}, | |
106 | - actionColumn: { | |
107 | - width: 120, | |
108 | - title: '操作', | |
109 | - dataIndex: 'action', | |
110 | - slots: {customRender: 'action'}, | |
111 | - fixed: 'right', | |
112 | - }, | |
113 | - }) | |
114 | - /** | |
115 | - * excel导入导出配置 | |
116 | - */ | |
117 | - const excelConfig = { | |
118 | - export: { | |
119 | - name:'${tableVo.ftlDescription}', | |
120 | - url: getExportUrl, | |
121 | - }, | |
122 | - import: { | |
123 | - url: getImportUrl, | |
124 | - success: reload, | |
125 | - } | |
126 | - } | |
127 | - /** | |
128 | - * 选择列配置 | |
129 | - */ | |
130 | - const rowSelection = { | |
131 | - type: 'checkbox', | |
132 | - columnWidth: 30, | |
133 | - selectedRowKeys: checkedKeys, | |
134 | - onChange: onSelectChange | |
135 | - } | |
136 | - /** | |
137 | - * 选择事件 | |
138 | - */ | |
139 | - function onSelectChange(selectedRowKeys: (string | number)[]) { | |
140 | - checkedKeys.value = selectedRowKeys; | |
141 | - } | |
142 | - /** | |
143 | - * 新增事件 | |
144 | - */ | |
145 | - function handleAdd() { | |
146 | - openModal(true, { | |
147 | - isUpdate: false, | |
148 | - showFooter: true, | |
149 | - }); | |
150 | - } | |
151 | - /** | |
152 | - * 编辑事件 | |
153 | - */ | |
154 | - function handleEdit(record: Recordable) { | |
155 | - openModal(true, { | |
156 | - record, | |
157 | - isUpdate: true, | |
158 | - showFooter: true, | |
159 | - }); | |
160 | - } | |
161 | - /** | |
162 | - * 详情 | |
163 | - */ | |
164 | - function handleDetail(record: Recordable) { | |
165 | - openModal(true, { | |
166 | - record, | |
167 | - isUpdate: true, | |
168 | - showFooter: false, | |
169 | - }); | |
170 | - } | |
171 | - /** | |
172 | - * 删除事件 | |
173 | - */ | |
174 | - async function handleDelete(record) { | |
175 | - await deleteOne({id: record.id}, reload); | |
176 | - } | |
177 | - /** | |
178 | - * 批量删除事件 | |
179 | - */ | |
180 | - async function batchHandleDelete() { | |
181 | - await batchDelete({ids: checkedKeys.value}, reload); | |
182 | - } | |
183 | - /** | |
184 | - * 成功回调 | |
185 | - */ | |
186 | - function handleSuccess() { | |
187 | - reload(); | |
188 | - } | |
189 | - /** | |
190 | - * 操作栏 | |
191 | - */ | |
192 | - function getTableAction(record){ | |
193 | - return [ | |
194 | - { | |
195 | - label: '编辑', | |
196 | - onClick: handleEdit.bind(null, record), | |
197 | - } | |
198 | - ] | |
199 | - } | |
200 | - /** | |
201 | - * 下拉操作栏 | |
202 | - */ | |
203 | - function getDropDownAction(record){ | |
204 | - return [ | |
205 | - { | |
206 | - label: '详情', | |
207 | - onClick: handleDetail.bind(null, record), | |
208 | - }, { | |
209 | - label: '删除', | |
210 | - popConfirm: { | |
211 | - title: '是否确认删除', | |
212 | - confirm: handleDelete.bind(null, record), | |
213 | - } | |
214 | - } | |
215 | - ] | |
216 | - } | |
217 | - <#if list_need_category> | |
218 | - /** | |
219 | - * 初始化字典配置 | |
220 | - */ | |
221 | - function initDictConfig(){ | |
222 | - <#list columns as po> | |
223 | - <#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'> | |
224 | - <#if po.classType=='cat_tree' && list_need_category==true> | |
225 | - loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => { | |
226 | - if (res) { | |
227 | - let allDictDate = getAuthCache(DB_DICT_DATA_KEY); | |
228 | - if(!allDictDate['${po.dictField?default("")}']){ | |
229 | - Object.assign(allDictDate,{'${po.dictField?default("")}':res}) | |
230 | - } | |
231 | - setAuthCache(DB_DICT_DATA_KEY,allDictDate) | |
232 | - } | |
233 | - }) | |
234 | - </#if> | |
235 | - </#if> | |
236 | - </#list> | |
237 | - } | |
238 | - initDictConfig(); | |
239 | - </#if> | |
240 | -</script> | |
241 | - | |
242 | -<style scoped> | |
243 | - | |
244 | -</style> | |
245 | 0 | \ No newline at end of file |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi deleted
1 | -import {defHttp} from '/@/utils/http/axios'; | |
2 | -import {Modal} from 'ant-design-vue'; | |
3 | - | |
4 | -enum Api { | |
5 | - list = '/${entityPackage}/${entityName?uncap_first}/list', | |
6 | - save='/${entityPackage}/${entityName?uncap_first}/add', | |
7 | - edit='/${entityPackage}/${entityName?uncap_first}/edit', | |
8 | - deleteOne = '/${entityPackage}/${entityName?uncap_first}/delete', | |
9 | - deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch', | |
10 | - importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel', | |
11 | - exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls', | |
12 | -} | |
13 | -/** | |
14 | - * 导出api | |
15 | - * @param params | |
16 | - */ | |
17 | -export const getExportUrl = Api.exportXls; | |
18 | -/** | |
19 | - * 导入api | |
20 | - */ | |
21 | -export const getImportUrl = Api.importExcel; | |
22 | -/** | |
23 | - * 列表接口 | |
24 | - * @param params | |
25 | - */ | |
26 | -export const list = (params) => | |
27 | - defHttp.get({url: Api.list, params}); | |
28 | - | |
29 | -/** | |
30 | - * 删除单个 | |
31 | - */ | |
32 | -export const deleteOne = (params,handleSuccess) => { | |
33 | - return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { | |
34 | - handleSuccess(); | |
35 | - }); | |
36 | -} | |
37 | -/** | |
38 | - * 批量删除 | |
39 | - * @param params | |
40 | - */ | |
41 | -export const batchDelete = (params, handleSuccess) => { | |
42 | - Modal.confirm({ | |
43 | - title: '确认删除', | |
44 | - content: '是否删除选中数据', | |
45 | - okText: '确认', | |
46 | - cancelText: '取消', | |
47 | - onOk: () => { | |
48 | - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { | |
49 | - handleSuccess(); | |
50 | - }); | |
51 | - } | |
52 | - }); | |
53 | -} | |
54 | -/** | |
55 | - * 保存或者更新 | |
56 | - * @param params | |
57 | - */ | |
58 | -export const saveOrUpdate = (params, isUpdate) => { | |
59 | - let url = isUpdate ? Api.edit : Api.save; | |
60 | - return defHttp.post({url: url, params}); | |
61 | -} |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi deleted
1 | -import {BasicColumn} from '/@/components/Table'; | |
2 | -import {FormSchema} from '/@/components/Table'; | |
3 | -import { rules} from '/@/utils/helper/validator'; | |
4 | -import { render } from '/@/utils/common/renderUtils'; | |
5 | -//列表数据 | |
6 | -export const columns: BasicColumn[] = [ | |
7 | - <#list columns as po> | |
8 | - <#if po.isShowList =='Y' && po.fieldName !='id'> | |
9 | - { | |
10 | - title: '${po.filedComment}', | |
11 | - align:"center", | |
12 | - <#if po.sort=='Y'> | |
13 | - sorter: true, | |
14 | - </#if> | |
15 | - <#if po.classType=='date'> | |
16 | - dataIndex: '${po.fieldName}', | |
17 | - customRender:({text}) =>{ | |
18 | - return !text?"":(text.length>10?text.substr(0,10):text) | |
19 | - }, | |
20 | - <#elseif po.fieldDbType=='Blob'> | |
21 | - dataIndex: '${po.fieldName}String' | |
22 | - <#elseif po.classType=='umeditor'> | |
23 | - dataIndex: '${po.fieldName}', | |
24 | - slots: { customRender: 'htmlSlot' }, | |
25 | - <#elseif po.classType=='pca'> | |
26 | - dataIndex: '${po.fieldName}', | |
27 | - slots: { customRender: 'pcaSlot' },//TODO 未翻译 | |
28 | - <#elseif po.classType=='file'> | |
29 | - dataIndex: '${po.fieldName}', | |
30 | - slots: { customRender: 'fileSlot' }, | |
31 | - <#elseif po.classType=='image'> | |
32 | - dataIndex: '${po.fieldName}', | |
33 | - customRender:render.renderAvatar, | |
34 | - <#elseif po.classType=='switch'> | |
35 | - dataIndex: '${po.fieldName}', | |
36 | -<#assign switch_extend_arr=['Y','N']> | |
37 | -<#if po.dictField?default("")?contains("[")> | |
38 | -<#assign switch_extend_arr=po.dictField?eval> | |
39 | -</#if> | |
40 | -<#list switch_extend_arr as a> | |
41 | -<#if a_index == 0> | |
42 | -<#assign switch_extend_arr1=a> | |
43 | -<#else> | |
44 | -<#assign switch_extend_arr2=a> | |
45 | -</#if> | |
46 | -</#list> | |
47 | - customRender:({text}) => { | |
48 | - return render.renderSwitch(text, [{text:'是',value:'${switch_extend_arr1}'},{text:'否',value:'${switch_extend_arr2}'}]) | |
49 | - }, | |
50 | - <#elseif po.classType == 'sel_tree' || po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'> | |
51 | - dataIndex: '${po.fieldName}_dictText' | |
52 | - <#elseif po.classType=='cat_tree'> | |
53 | - dataIndex: '${po.fieldName}', | |
54 | - <#if po.dictText?default("")?trim?length == 0> | |
55 | - customRender:({text}) => { | |
56 | - return render.renderCategoryTree(text,'${po.dictField?default("")}') | |
57 | - }, | |
58 | - <#else> | |
59 | - customRender: (text, record) => (text ? record['${po.dictText}'] : '') | |
60 | - </#if> | |
61 | - <#else> | |
62 | - dataIndex: '${po.fieldName}' | |
63 | - </#if> | |
64 | - }, | |
65 | - </#if> | |
66 | - </#list> | |
67 | -]; | |
68 | -//查询数据 | |
69 | -export const searchFormSchema: FormSchema[] = [ | |
70 | -<#-- 开始循环 --> | |
71 | -<#list columns as po> | |
72 | -<#if po.fieldDbName=='bpm_status'> | |
73 | - <#assign bpm_flag=true> | |
74 | -</#if> | |
75 | -<#if po.isQuery=='Y'> | |
76 | -<#assign query_flag=true> | |
77 | - <#assign query_field_dictCode=""> | |
78 | - <#if po.dictTable?default("")?trim?length gt 1> | |
79 | - <#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
80 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
81 | - <#assign query_field_dictCode="${po.dictField}"> | |
82 | - </#if> | |
83 | -<#if po.queryMode=='single'> | |
84 | - { | |
85 | - label: "${po.filedComment}", | |
86 | - field: "${po.fieldName}", | |
87 | -<#if po.classType=='sel_search'> | |
88 | - component: 'JSearchSelect', | |
89 | - componentProps:{ | |
90 | - dict:"${po.dictTable},${po.dictText},${po.dictField}" | |
91 | - }, | |
92 | -<#elseif po.classType=='sel_user'> | |
93 | - component: 'JSelectUserByDept', | |
94 | -<#elseif po.classType=='switch'> | |
95 | - component: 'JSwitch', | |
96 | - componentProps:{ | |
97 | - <#if po.dictField != 'is_open'> | |
98 | - options:"${po.dictField}" | |
99 | - </#if> | |
100 | - }, | |
101 | - <#elseif po.classType=='sel_depart'> | |
102 | - component: 'JSelectDept', | |
103 | - <#elseif po.classType=='list_multi'> | |
104 | - component: 'JMultiSelectTag',//暂无该组件 | |
105 | - componentProps:{ | |
106 | - dictCode:"query_field_dictCode?default("")" | |
107 | - }, | |
108 | - <#elseif po.classType=='cat_tree'> | |
109 | - component: 'JCategorySelect', | |
110 | - componentProps:{ | |
111 | - pcode:"${po.dictField?default("")}",//back和事件未添加,暂时有问题 | |
112 | - }, | |
113 | -<#elseif po.classType=='date'> | |
114 | - component: 'DatePicker', | |
115 | -<#elseif po.classType=='datetime'> | |
116 | - component: 'DatePicker', | |
117 | - componentProps: { | |
118 | - showTime:true | |
119 | - }, | |
120 | -<#elseif po.classType=='pca'> | |
121 | - component: 'JAreaLinkage', | |
122 | -<#elseif po.classType=='popup'> | |
123 | - component: 'JPopup', | |
124 | - componentProps: ({ formActionType }) => { | |
125 | - const {setFieldsValue} = formActionType; | |
126 | - return{ | |
127 | - setFieldsValue:setFieldsValue, | |
128 | - code:"${po.dictTable}", | |
129 | - fieldConfig:"${po.dictField}", | |
130 | - multi:${po.extendParams.popupMulti?c}, | |
131 | - } | |
132 | - }, | |
133 | -<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'> | |
134 | -<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- --> | |
135 | - component: 'JDictSelectTag', | |
136 | - componentProps:{ | |
137 | - <#if po.dictTable?default("")?trim?length gt 1> | |
138 | - dictCode:"${po.dictTable},${po.dictText},${po.dictField}" | |
139 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
140 | - dictCode:"${po.dictField}" | |
141 | - </#if> | |
142 | - }, | |
143 | -<#else> | |
144 | - component: 'Input', | |
145 | -</#if> | |
146 | -<#else> | |
147 | - { | |
148 | - label: "${po.filedComment}", | |
149 | - field: "${po.fieldName}", | |
150 | -<#if po.classType=='date'> | |
151 | - component: 'RangePicker', | |
152 | -<#elseif po.classType=='datetime'> | |
153 | - component: 'RangePicker', | |
154 | - componentProps: { | |
155 | - showTime:true | |
156 | - }, | |
157 | -<#else> | |
158 | - component: 'Input', //TODO 范围查询 | |
159 | -</#if> | |
160 | - colProps: {span: 6}, | |
161 | - }, | |
162 | -</#if> | |
163 | -</#if> | |
164 | -</#list> | |
165 | -<#-- 结束循环 --> | |
166 | -]; | |
167 | -//表单数据 | |
168 | -export const formSchema: FormSchema[] = [ | |
169 | -<#assign form_cat_tree = false> | |
170 | -<#assign form_cat_back = ""> | |
171 | -<#assign bpm_flag=false> | |
172 | -<#list columns as po><#rt/> | |
173 | -<#if po.fieldDbName=='bpm_status'> | |
174 | - <#assign bpm_flag=true> | |
175 | -</#if> | |
176 | -<#if po.isShow =='Y'> | |
177 | -<#assign form_field_dictCode=""> | |
178 | - <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1> | |
179 | - <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
180 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
181 | - <#assign form_field_dictCode="${po.dictField}"> | |
182 | - </#if> | |
183 | - { | |
184 | - label: '${po.filedComment}', | |
185 | - field: '${po.fieldName}', | |
186 | - <#if po.classType =='date'> | |
187 | - component: 'DatePicker', | |
188 | - <#elseif po.fieldType =='datetime'> | |
189 | - component: 'DatePicker', | |
190 | - componentProps: { | |
191 | - showTime:true | |
192 | - }, | |
193 | - <#elseif po.fieldType =='time'> | |
194 | - component: 'TimePicker', | |
195 | - <#elseif po.classType =='popup'> | |
196 | - component: 'JPopup', | |
197 | - componentProps: ({ formActionType }) => { | |
198 | - const {setFieldsValue} = formActionType; | |
199 | - return{ | |
200 | - setFieldsValue:setFieldsValue, | |
201 | - code:"${po.dictTable}", | |
202 | - fieldConfig:${po.dictField}, | |
203 | - multi:${po.extendParams.popupMulti?c}, | |
204 | - } | |
205 | - } | |
206 | - <#elseif po.classType =='sel_depart'> | |
207 | - component: 'JSelectDept', | |
208 | - <#elseif po.classType =='switch'> | |
209 | - component: 'JSwitch', | |
210 | - componentProps:{ | |
211 | - <#if po.dictField != 'is_open'> | |
212 | - options:${po.dictField} | |
213 | - </#if> | |
214 | - } | |
215 | - <#elseif po.classType =='pca'> | |
216 | - component: 'JAreaLinkage', | |
217 | - <#elseif po.classType =='markdown'> | |
218 | - component: 'JMarkdownEditor',//注意string转换问题 | |
219 | - <#elseif po.classType =='password'> | |
220 | - component: 'InputPassword', | |
221 | - <#elseif po.classType =='sel_user'> | |
222 | - component: 'JSelectUserByDept', | |
223 | - componentProps:{ | |
224 | - labelKey:'realname', | |
225 | - } | |
226 | - <#elseif po.classType =='textarea'> | |
227 | - component: 'InputTextArea',//TODO 注意string转换问题 | |
228 | - <#elseif po.classType=='list' || po.classType=='radio'> | |
229 | - component: 'JDictSelectTag', | |
230 | - componentProps:{ | |
231 | - dictCode:"${form_field_dictCode}" | |
232 | - } | |
233 | - <#elseif po.classType=='list_multi' || po.classType=='checkbox'> | |
234 | - component: 'JMultiSelectTag',//TODO 暂无该组件 | |
235 | - componentProps:{ | |
236 | - dictCode:"${form_field_dictCode}" | |
237 | - } | |
238 | - <#elseif po.classType=='sel_search'> | |
239 | - component: 'JSearchSelect', | |
240 | - componentProps:{ | |
241 | - dict:"${form_field_dictCode}" | |
242 | - } | |
243 | -<#elseif po.classType=='cat_tree'> | |
244 | - <#assign form_cat_tree = true> | |
245 | - component: 'JCategorySelect', | |
246 | - componentProps:{ | |
247 | - pcode:"${po.dictField?default("")}", //TODO back和事件未添加,暂时有问题 | |
248 | - } | |
249 | - <#if po.dictText?default("")?trim?length gt 1> | |
250 | - <#assign form_cat_back = "${po.dictText}"> | |
251 | - </#if> | |
252 | - <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'> | |
253 | - component: 'InputNumber', | |
254 | - <#elseif po.classType=='file'> | |
255 | - component: 'JUpload', | |
256 | - componentProps:{ | |
257 | - <#if po.uploadnum??> | |
258 | - maxCount:${po.uploadnum} | |
259 | - </#if> | |
260 | - } | |
261 | - <#elseif po.classType=='image'> | |
262 | - component: 'JImageUpload', | |
263 | - componentProps:{ | |
264 | - <#if po.uploadnum??> | |
265 | - fileMax:${po.uploadnum} | |
266 | - </#if> | |
267 | - } | |
268 | - <#elseif po.classType=='umeditor'> | |
269 | - component: 'JCodeEditor', //TODO String后缀暂未添加 | |
270 | - <#elseif po.classType == 'sel_tree'> | |
271 | - component: 'JTreeSelect', | |
272 | - componentProps:{ | |
273 | - <#if po.dictText??> | |
274 | - <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> | |
275 | - dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}", | |
276 | - <#elseif po.dictText?split(',')[1]??> | |
277 | - pidField:"${po.dictText?split(',')[1]}", | |
278 | - <#elseif po.dictText?split(',')[3]??> | |
279 | - hasChildField:"${po.dictText?split(',')[3]}", | |
280 | - </#if> | |
281 | - </#if> | |
282 | - pidValue:"${po.dictField}", | |
283 | - } | |
284 | - <#else> | |
285 | - component: 'Input', | |
286 | - </#if> | |
287 | - <#include "/common/utils.ftl"> | |
288 | - <#if po.isShow == 'Y' && poHasCheck(po)> | |
289 | - dynamicRules: ({model,schema}) => { | |
290 | - <#if po.fieldName != 'id'> | |
291 | - <#assign fieldValidType = po.fieldValidType!''> | |
292 | - return [ | |
293 | - <#-- 非空校验 --> | |
294 | - <#if po.nullable == 'N' || fieldValidType == '*'> | |
295 | - { required: true, message: '请输入${po.filedComment}!'}, | |
296 | - <#elseif fieldValidType!=''> | |
297 | - { required: false}, | |
298 | - </#if> | |
299 | - <#-- 唯一校验 --> | |
300 | - <#if fieldValidType == 'only'> | |
301 | - {...rules.duplicateCheckRule(<#if sub?default("")?trim?length gt 1>'${sub.tableName}'<#else>'${tableName}'</#if>, '${po.fieldDbName}',model,schema,true)[0]}, | |
302 | - <#-- 6到16位数字 --> | |
303 | - <#elseif fieldValidType == 'n6-16'> | |
304 | - { pattern: /^\d{6,16}$/, message: '请输入6到16位数字!'}, | |
305 | - <#-- 6到16位任意字符 --> | |
306 | - <#elseif fieldValidType == '*6-16'> | |
307 | - { pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'}, | |
308 | - <#-- 6到18位字符串 --> | |
309 | - <#elseif fieldValidType == 's6-18'> | |
310 | - { pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'}, | |
311 | - <#-- 网址 --> | |
312 | - <#elseif fieldValidType == 'url'> | |
313 | - { pattern: /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/, message: '请输入正确的网址!'}, | |
314 | - <#-- 电子邮件 --> | |
315 | - <#elseif fieldValidType == 'e'> | |
316 | - { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'}, | |
317 | - <#-- 手机号码 --> | |
318 | - <#elseif fieldValidType == 'm'> | |
319 | - { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'}, | |
320 | - <#-- 邮政编码 --> | |
321 | - <#elseif fieldValidType == 'p'> | |
322 | - { pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'}, | |
323 | - <#-- 字母 --> | |
324 | - <#elseif fieldValidType == 's'> | |
325 | - { pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'}, | |
326 | - <#-- 数字 --> | |
327 | - <#elseif fieldValidType == 'n'> | |
328 | - { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}, | |
329 | - <#-- 整数 --> | |
330 | - <#elseif fieldValidType == 'z'> | |
331 | - { pattern: /^-?\d+$/, message: '请输入整数!'}, | |
332 | - <#-- 金额 --> | |
333 | - <#elseif fieldValidType == 'money'> | |
334 | - { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}, | |
335 | - <#-- 正则校验 --> | |
336 | - <#elseif fieldValidType != '' && fieldValidType != '*'> | |
337 | - { pattern: '${fieldValidType}', message: '不符合校验规则!'}, | |
338 | - <#-- 无校验 --> | |
339 | - <#else> | |
340 | - <#t> | |
341 | - </#if> | |
342 | - ]; | |
343 | - </#if> | |
344 | - }, | |
345 | - </#if> | |
346 | - <#if po.readonly=='Y'> | |
347 | - dynamicDisabled:true | |
348 | - </#if> | |
349 | - }, | |
350 | -</#if> | |
351 | -</#list> | |
352 | -]; |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/one/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei deleted
1 | -<template> | |
2 | - <BasicModal v-bind="$attrs" @register="registerModal" :title="title" @ok="handleSubmit"> | |
3 | - <BasicForm @register="registerForm"/> | |
4 | - </BasicModal> | |
5 | -</template> | |
6 | - | |
7 | -<script lang="ts" setup> | |
8 | - import {ref, computed, unref} from 'vue'; | |
9 | - import {BasicModal, useModalInner} from '/@/components/Modal'; | |
10 | - import {BasicForm, useForm} from '/@/components/Form/index'; | |
11 | - import {formSchema} from '../${entityName?uncap_first}.data'; | |
12 | - import {saveOrUpdate} from '../${entityName?uncap_first}.api'; | |
13 | - // Emits声明 | |
14 | - const emit = defineEmits(['register','success']); | |
15 | - const isUpdate = ref(true); | |
16 | - //表单配置 | |
17 | - const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({ | |
18 | - labelWidth: 150, | |
19 | - schemas: formSchema, | |
20 | - showActionButtonGroup: false, | |
21 | - }); | |
22 | - //表单赋值 | |
23 | - const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |
24 | - //重置表单 | |
25 | - await resetFields(); | |
26 | - setModalProps({confirmLoading: false,showFooter:!!data?.showFooter}); | |
27 | - isUpdate.value = !!data?.isUpdate; | |
28 | - if (unref(isUpdate)) { | |
29 | - //表单赋值 | |
30 | - await setFieldsValue({ | |
31 | - ...data.record, | |
32 | - }); | |
33 | - } | |
34 | - // 隐藏底部时禁用整个表单 | |
35 | - setProps({ disabled: !data?.showFooter }) | |
36 | - }); | |
37 | - //设置标题 | |
38 | - const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑')); | |
39 | - //表单提交事件 | |
40 | - async function handleSubmit(v) { | |
41 | - try { | |
42 | - let values = await validate(); | |
43 | - setModalProps({confirmLoading: true}); | |
44 | - //提交表单 | |
45 | - await saveOrUpdate(values, isUpdate.value); | |
46 | - //关闭弹窗 | |
47 | - closeModal(); | |
48 | - //刷新列表 | |
49 | - emit('success'); | |
50 | - } finally { | |
51 | - setModalProps({confirmLoading: false}); | |
52 | - } | |
53 | - } | |
54 | -</script> | |
55 | - | |
56 | -<style lang="less" scoped> | |
57 | - | |
58 | -</style> | |
59 | 0 | \ No newline at end of file |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi deleted
1 | -import {defHttp} from "/@/utils/http/axios"; | |
2 | -import {Modal} from 'ant-design-vue'; | |
3 | - | |
4 | -enum Api { | |
5 | - list = '/${entityPackage}/${entityName?uncap_first}/rootList', | |
6 | - save='/${entityPackage}/${entityName?uncap_first}/add', | |
7 | - edit='/${entityPackage}/${entityName?uncap_first}/edit', | |
8 | - delete${entityName} = '/sys/${entityName?uncap_first}/delete', | |
9 | - deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch', | |
10 | - importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel', | |
11 | - exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls', | |
12 | - loadTreeData = '/${entityPackage}/${entityName?uncap_first}/loadTreeRoot', | |
13 | - getChildList = '/${entityPackage}/${entityName?uncap_first}/childList', | |
14 | - getChildListBatch = '/${entityPackage}/${entityName?uncap_first}/getChildListBatch', | |
15 | -} | |
16 | -/** | |
17 | - * 导出api | |
18 | - * @param params | |
19 | - */ | |
20 | -export const getExportUrl = Api.exportXls; | |
21 | -/** | |
22 | - * 导入api | |
23 | - * @param params | |
24 | - */ | |
25 | -export const getImportUrl = Api.importExcel; | |
26 | -/** | |
27 | - * 列表接口 | |
28 | - * @param params | |
29 | - */ | |
30 | -export const list = (params) => | |
31 | - defHttp.get({url: Api.list, params}); | |
32 | -/** | |
33 | - * 删除 | |
34 | - */ | |
35 | -export const delete${entityName} = (params,handleSuccess) => { | |
36 | - return defHttp.delete({url: Api.delete${entityName}, params}, {joinParamsToUrl: true}).then(() => { | |
37 | - handleSuccess(); | |
38 | - }); | |
39 | -} | |
40 | -/** | |
41 | - * 批量删除 | |
42 | - * @param params | |
43 | - */ | |
44 | -export const batchDelete${entityName} = (params, handleSuccess) => { | |
45 | - Modal.confirm({ | |
46 | - title: '确认删除', | |
47 | - content: '是否删除选中数据', | |
48 | - okText: '确认', | |
49 | - cancelText: '取消', | |
50 | - onOk: () => { | |
51 | - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { | |
52 | - handleSuccess(); | |
53 | - }); | |
54 | - } | |
55 | - }); | |
56 | -} | |
57 | -/** | |
58 | - * 保存或者更新 | |
59 | - * @param params | |
60 | - */ | |
61 | -export const saveOrUpdateDict = (params, isUpdate) => { | |
62 | - let url = isUpdate ? Api.edit : Api.save; | |
63 | - return defHttp.post({url: url, params}); | |
64 | -} | |
65 | -/** | |
66 | - * 查询全部树形节点数据 | |
67 | - * @param params | |
68 | - */ | |
69 | -export const loadTreeData = (params) => | |
70 | - defHttp.get({url: Api.loadTreeData,params}); | |
71 | -/** | |
72 | - * 查询子节点数据 | |
73 | - * @param params | |
74 | - */ | |
75 | -export const getChildList = (params) => | |
76 | - defHttp.get({url: Api.getChildList, params}); | |
77 | -/** | |
78 | - * 批量查询子节点数据 | |
79 | - * @param params | |
80 | - */ | |
81 | -export const getChildListBatch = (params) => | |
82 | - defHttp.get({url: Api.getChildListBatch, params},{isTransformResponse:false}); |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi deleted
1 | -import {BasicColumn} from '/@/components/Table'; | |
2 | -import {FormSchema} from '/@/components/Table'; | |
3 | -import { rules} from '/@/utils/helper/validator'; | |
4 | -import { render } from '/@/utils/common/renderUtils'; | |
5 | -//列表数据 | |
6 | -export const columns: BasicColumn[] = [ | |
7 | - <#list columns as po> | |
8 | - <#if po.isShowList =='Y' && po.fieldName !='id'> | |
9 | - { | |
10 | - title: '${po.filedComment}', | |
11 | - align:"center", | |
12 | - <#if po.sort=='Y'> | |
13 | - sorter: true, | |
14 | - </#if> | |
15 | - <#if po.classType=='date'> | |
16 | - dataIndex: '${po.fieldName}', | |
17 | - customRender:({text}) =>{ | |
18 | - return !text?"":(text.length>10?text.substr(0,10):text) | |
19 | - }, | |
20 | - <#elseif po.fieldDbType=='Blob'> | |
21 | - dataIndex: '${po.fieldName}String' | |
22 | - <#elseif po.classType=='umeditor'> | |
23 | - dataIndex: '${po.fieldName}', | |
24 | - slots: { customRender: 'htmlSlot' }, | |
25 | - <#elseif po.classType=='pca'> | |
26 | - dataIndex: '${po.fieldName}', | |
27 | - slots: { customRender: 'pcaSlot' },//TODO 未翻译 | |
28 | - <#elseif po.classType=='file'> | |
29 | - dataIndex: '${po.fieldName}', | |
30 | - slots: { customRender: 'fileSlot' }, | |
31 | - <#elseif po.classType=='image'> | |
32 | - dataIndex: '${po.fieldName}', | |
33 | - customRender:render.renderAvatar, | |
34 | - <#elseif po.classType=='switch'> | |
35 | - dataIndex: '${po.fieldName}', | |
36 | -<#assign switch_extend_arr=['Y','N']> | |
37 | -<#if po.dictField?default("")?contains("[")> | |
38 | -<#assign switch_extend_arr=po.dictField?eval> | |
39 | -</#if> | |
40 | -<#list switch_extend_arr as a> | |
41 | -<#if a_index == 0> | |
42 | -<#assign switch_extend_arr1=a> | |
43 | -<#else> | |
44 | -<#assign switch_extend_arr2=a> | |
45 | -</#if> | |
46 | -</#list> | |
47 | - customRender:({text}) => { | |
48 | - return render.renderSwitch(text, [{text:'是',value:'${switch_extend_arr1}'},{text:'否',value:'${switch_extend_arr2}'}]) | |
49 | - }, | |
50 | - <#elseif po.classType == 'sel_tree' || po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'> | |
51 | - dataIndex: '${po.fieldName}_dictText' | |
52 | - <#elseif po.classType=='cat_tree'> | |
53 | - dataIndex: '${po.fieldName}', | |
54 | - <#if po.dictText?default("")?trim?length == 0> | |
55 | - customRender:({text}) => { | |
56 | - return render.renderCategoryTree(text,'${po.dictField?default("")}') | |
57 | - }, | |
58 | - <#else> | |
59 | - customRender: (text, record) => (text ? record['${po.dictText}'] : '') | |
60 | - </#if> | |
61 | - <#else> | |
62 | - dataIndex: '${po.fieldName}' | |
63 | - </#if> | |
64 | - }, | |
65 | - </#if> | |
66 | - </#list> | |
67 | -]; | |
68 | -//查询数据 | |
69 | -export const searchFormSchema: FormSchema[] = [ | |
70 | -<#-- 开始循环 --> | |
71 | -<#list columns as po> | |
72 | -<#if po.fieldDbName=='bpm_status'> | |
73 | - <#assign bpm_flag=true> | |
74 | -</#if> | |
75 | -<#if po.isQuery=='Y'> | |
76 | -<#assign query_flag=true> | |
77 | - <#assign query_field_dictCode=""> | |
78 | - <#if po.dictTable?default("")?trim?length gt 1> | |
79 | - <#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
80 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
81 | - <#assign query_field_dictCode="${po.dictField}"> | |
82 | - </#if> | |
83 | -<#if po.queryMode=='single'> | |
84 | - { | |
85 | - label: "${po.filedComment}", | |
86 | - field: "${po.fieldName}", | |
87 | -<#if po.classType=='sel_search'> | |
88 | - component: 'JSearchSelect', | |
89 | - componentProps:{ | |
90 | - dict:"${po.dictTable},${po.dictText},${po.dictField}" | |
91 | - }, | |
92 | -<#elseif po.classType=='sel_user'> | |
93 | - component: 'JSelectUserByDept', | |
94 | -<#elseif po.classType=='switch'> | |
95 | - component: 'JSwitch', | |
96 | - componentProps:{ | |
97 | - <#if po.dictField != 'is_open'> | |
98 | - options:"${po.dictField}" | |
99 | - </#if> | |
100 | - }, | |
101 | - <#elseif po.classType=='sel_depart'> | |
102 | - component: 'JSelectDept', | |
103 | - <#elseif po.classType=='list_multi'> | |
104 | - component: 'JMultiSelectTag',//暂无该组件 | |
105 | - componentProps:{ | |
106 | - dictCode:"query_field_dictCode?default("")" | |
107 | - }, | |
108 | - <#elseif po.classType=='cat_tree'> | |
109 | - component: 'JCategorySelect', | |
110 | - componentProps:{ | |
111 | - pcode:"${po.dictField?default("")}",//back和事件未添加,暂时有问题 | |
112 | - }, | |
113 | -<#elseif po.classType=='date'> | |
114 | - component: 'DatePicker', | |
115 | -<#elseif po.classType=='datetime'> | |
116 | - component: 'DatePicker', | |
117 | - componentProps: { | |
118 | - showTime:true | |
119 | - }, | |
120 | -<#elseif po.classType=='pca'> | |
121 | - component: 'JAreaLinkage', | |
122 | -<#elseif po.classType=='popup'> | |
123 | - component: 'JPopup', | |
124 | - componentProps: ({ formActionType }) => { | |
125 | - const {setFieldsValue} = formActionType; | |
126 | - return{ | |
127 | - setFieldsValue:setFieldsValue, | |
128 | - code:"${po.dictTable}", | |
129 | - fieldConfig:"${po.dictField}", | |
130 | - multi:${po.extendParams.popupMulti?c}, | |
131 | - } | |
132 | - }, | |
133 | -<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'> | |
134 | -<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- --> | |
135 | - component: 'JDictSelectTag', | |
136 | - componentProps:{ | |
137 | - <#if po.dictTable?default("")?trim?length gt 1> | |
138 | - dictCode:"${po.dictTable},${po.dictText},${po.dictField}" | |
139 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
140 | - dictCode:"${po.dictField}" | |
141 | - </#if> | |
142 | - }, | |
143 | -<#else> | |
144 | - component: 'Input', | |
145 | -</#if> | |
146 | -<#else> | |
147 | - { | |
148 | - label: "${po.filedComment}", | |
149 | - field: "${po.fieldName}", | |
150 | -<#if po.classType=='date'> | |
151 | - component: 'RangePicker', | |
152 | -<#elseif po.classType=='datetime'> | |
153 | - component: 'RangePicker', | |
154 | - componentProps: { | |
155 | - showTime:true | |
156 | - }, | |
157 | -<#else> | |
158 | - component: 'Input', //TODO 范围查询 | |
159 | -</#if> | |
160 | - colProps: {span: 6}, | |
161 | - }, | |
162 | -</#if> | |
163 | -</#if> | |
164 | -</#list> | |
165 | -<#-- 结束循环 --> | |
166 | -]; | |
167 | -//表单数据 | |
168 | -export const formSchema: FormSchema[] = [ | |
169 | -<#assign form_cat_tree = false> | |
170 | -<#assign form_cat_back = ""> | |
171 | -<#assign bpm_flag=false> | |
172 | -<#list columns as po><#rt/> | |
173 | -<#if po.fieldDbName=='bpm_status'> | |
174 | - <#assign bpm_flag=true> | |
175 | -</#if> | |
176 | -<#if po.isShow =='Y'> | |
177 | -<#assign form_field_dictCode=""> | |
178 | - <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1> | |
179 | - <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
180 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
181 | - <#assign form_field_dictCode="${po.dictField}"> | |
182 | - </#if> | |
183 | - { | |
184 | - label: '${po.filedComment}', | |
185 | - field: '${po.fieldName}', | |
186 | - <#if po.classType =='date'> | |
187 | - component: 'DatePicker', | |
188 | - <#elseif po.fieldType =='datetime'> | |
189 | - component: 'DatePicker', | |
190 | - componentProps: { | |
191 | - showTime:true | |
192 | - }, | |
193 | - <#elseif po.fieldType =='time'> | |
194 | - component: 'TimePicker', | |
195 | - <#elseif po.classType =='popup'> | |
196 | - component: 'JPopup', | |
197 | - componentProps: ({ formActionType }) => { | |
198 | - const {setFieldsValue} = formActionType; | |
199 | - return{ | |
200 | - setFieldsValue:setFieldsValue, | |
201 | - code:"${po.dictTable}", | |
202 | - fieldConfig:${po.dictField}, | |
203 | - multi:${po.extendParams.popupMulti?c}, | |
204 | - } | |
205 | - } | |
206 | - <#elseif po.classType =='sel_depart'> | |
207 | - component: 'JSelectDept', | |
208 | - <#elseif po.classType =='switch'> | |
209 | - component: 'JSwitch', | |
210 | - componentProps:{ | |
211 | - <#if po.dictField != 'is_open'> | |
212 | - options:${po.dictField} | |
213 | - </#if> | |
214 | - } | |
215 | - <#elseif po.classType =='pca'> | |
216 | - component: 'JAreaLinkage', | |
217 | - <#elseif po.classType =='markdown'> | |
218 | - component: 'JMarkdownEditor',//注意string转换问题 | |
219 | - <#elseif po.classType =='password'> | |
220 | - component: 'InputPassword', | |
221 | - <#elseif po.classType =='sel_user'> | |
222 | - component: 'JSelectUserByDept', | |
223 | - componentProps:{ | |
224 | - labelKey:'realname', | |
225 | - } | |
226 | - <#elseif po.classType =='textarea'> | |
227 | - component: 'InputTextArea',//TODO 注意string转换问题 | |
228 | - <#elseif po.classType=='list' || po.classType=='radio'> | |
229 | - component: 'JDictSelectTag', | |
230 | - componentProps:{ | |
231 | - dictCode:"${form_field_dictCode}" | |
232 | - } | |
233 | - <#elseif po.classType=='list_multi' || po.classType=='checkbox'> | |
234 | - component: 'JMultiSelectTag',//TODO 暂无该组件 | |
235 | - componentProps:{ | |
236 | - dictCode:"${form_field_dictCode}" | |
237 | - } | |
238 | - <#elseif po.classType=='sel_search'> | |
239 | - component: 'JSearchSelect', | |
240 | - componentProps:{ | |
241 | - dict:"${form_field_dictCode}" | |
242 | - } | |
243 | -<#elseif po.classType=='cat_tree'> | |
244 | - <#assign form_cat_tree = true> | |
245 | - component: 'JCategorySelect', | |
246 | - componentProps:{ | |
247 | - pcode:"${po.dictField?default("")}", //TODO back和事件未添加,暂时有问题 | |
248 | - } | |
249 | - <#if po.dictText?default("")?trim?length gt 1> | |
250 | - <#assign form_cat_back = "${po.dictText}"> | |
251 | - </#if> | |
252 | - <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'> | |
253 | - component: 'InputNumber', | |
254 | - <#elseif po.classType=='file'> | |
255 | - component: 'JUpload', | |
256 | - componentProps:{ | |
257 | - <#if po.uploadnum??> | |
258 | - maxCount:${po.uploadnum} | |
259 | - </#if> | |
260 | - } | |
261 | - <#elseif po.classType=='image'> | |
262 | - component: 'JImageUpload', | |
263 | - componentProps:{ | |
264 | - <#if po.uploadnum??> | |
265 | - fileMax:${po.uploadnum} | |
266 | - </#if> | |
267 | - } | |
268 | - <#elseif po.classType=='umeditor'> | |
269 | - component: 'JCodeEditor', //TODO String后缀暂未添加 | |
270 | - <#elseif po.classType == 'sel_tree'> | |
271 | - component: 'JTreeSelect', | |
272 | - componentProps:{ | |
273 | - <#if po.dictText??> | |
274 | - <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> | |
275 | - dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}", | |
276 | - <#elseif po.dictText?split(',')[1]??> | |
277 | - pidField:"${po.dictText?split(',')[1]}", | |
278 | - <#elseif po.dictText?split(',')[3]??> | |
279 | - hasChildField:"${po.dictText?split(',')[3]}", | |
280 | - </#if> | |
281 | - </#if> | |
282 | - pidValue:"${po.dictField}", | |
283 | - } | |
284 | - <#else> | |
285 | - component: 'Input', | |
286 | - </#if> | |
287 | - <#include "/common/utils.ftl"> | |
288 | - <#if po.isShow == 'Y' && poHasCheck(po)> | |
289 | - dynamicRules: ({model,schema}) => { | |
290 | - <#if po.fieldName != 'id'> | |
291 | - <#assign fieldValidType = po.fieldValidType!''> | |
292 | - return [ | |
293 | - <#-- 非空校验 --> | |
294 | - <#if po.nullable == 'N' || fieldValidType == '*'> | |
295 | - { required: true, message: '请输入${po.filedComment}!'}, | |
296 | - <#elseif fieldValidType!=''> | |
297 | - { required: false}, | |
298 | - </#if> | |
299 | - <#-- 唯一校验 --> | |
300 | - <#if fieldValidType == 'only'> | |
301 | - {...rules.duplicateCheckRule(<#if sub?default("")?trim?length gt 1>'${sub.tableName}'<#else>'${tableName}'</#if>, '${po.fieldDbName}',model,schema,true)[0]}, | |
302 | - <#-- 6到16位数字 --> | |
303 | - <#elseif fieldValidType == 'n6-16'> | |
304 | - { pattern: /^\d{6,16}$/, message: '请输入6到16位数字!'}, | |
305 | - <#-- 6到16位任意字符 --> | |
306 | - <#elseif fieldValidType == '*6-16'> | |
307 | - { pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'}, | |
308 | - <#-- 6到18位字符串 --> | |
309 | - <#elseif fieldValidType == 's6-18'> | |
310 | - { pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'}, | |
311 | - <#-- 网址 --> | |
312 | - <#elseif fieldValidType == 'url'> | |
313 | - { pattern: /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/, message: '请输入正确的网址!'}, | |
314 | - <#-- 电子邮件 --> | |
315 | - <#elseif fieldValidType == 'e'> | |
316 | - { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'}, | |
317 | - <#-- 手机号码 --> | |
318 | - <#elseif fieldValidType == 'm'> | |
319 | - { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'}, | |
320 | - <#-- 邮政编码 --> | |
321 | - <#elseif fieldValidType == 'p'> | |
322 | - { pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'}, | |
323 | - <#-- 字母 --> | |
324 | - <#elseif fieldValidType == 's'> | |
325 | - { pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'}, | |
326 | - <#-- 数字 --> | |
327 | - <#elseif fieldValidType == 'n'> | |
328 | - { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}, | |
329 | - <#-- 整数 --> | |
330 | - <#elseif fieldValidType == 'z'> | |
331 | - { pattern: /^-?\d+$/, message: '请输入整数!'}, | |
332 | - <#-- 金额 --> | |
333 | - <#elseif fieldValidType == 'money'> | |
334 | - { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}, | |
335 | - <#-- 正则校验 --> | |
336 | - <#elseif fieldValidType != '' && fieldValidType != '*'> | |
337 | - { pattern: '${fieldValidType}', message: '不符合校验规则!'}, | |
338 | - <#-- 无校验 --> | |
339 | - <#else> | |
340 | - <#t> | |
341 | - </#if> | |
342 | - ]; | |
343 | - </#if> | |
344 | - }, | |
345 | - </#if> | |
346 | - <#if po.readonly=='Y'> | |
347 | - dynamicDisabled:true | |
348 | - </#if> | |
349 | - }, | |
350 | -</#if> | |
351 | -</#list> | |
352 | -]; |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei deleted
1 | -<template> | |
2 | - <BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit"> | |
3 | - <BasicForm @register="registerForm"/> | |
4 | - </BasicModal> | |
5 | -</template> | |
6 | -<script lang="ts" setup> | |
7 | - import {ref, computed, unref} from 'vue'; | |
8 | - import {BasicModal, useModalInner} from '/src/components/Modal'; | |
9 | - import {BasicForm, useForm} from '/src/components/Form'; | |
10 | - import {formSchema} from '../${entityName?uncap_first}.data'; | |
11 | - import {loadTreeData, saveOrUpdateDict} from '../${entityName?uncap_first}.api'; | |
12 | - // 获取emit | |
13 | - const emit = defineEmits(['register', 'success']); | |
14 | - const isUpdate = ref(true); | |
15 | - const expandedRowKeys = ref([]); | |
16 | - const treeData = ref([]); | |
17 | - //表单配置 | |
18 | - const [registerForm, {resetFields, setFieldsValue, validate, updateSchema}] = useForm({ | |
19 | - schemas: formSchema, | |
20 | - showActionButtonGroup: false, | |
21 | - labelCol: { | |
22 | - xs: { span: 24 }, | |
23 | - sm: { span: 4 }, | |
24 | - }, | |
25 | - wrapperCol: { | |
26 | - xs: { span: 24 }, | |
27 | - sm: { span: 18 }, | |
28 | - }, | |
29 | - }); | |
30 | - //表单赋值 | |
31 | - const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |
32 | - //重置表单 | |
33 | - await resetFields(); | |
34 | - expandedRowKeys.value = []; | |
35 | - setModalProps({confirmLoading: false, minHeight: 80}); | |
36 | - isUpdate.value = !!data?.isUpdate; | |
37 | - if (data?.record) { | |
38 | - //表单赋值 | |
39 | - await setFieldsValue({ | |
40 | - ...data.record, | |
41 | - }); | |
42 | - } | |
43 | - //父级节点树信息 | |
44 | - treeData.value = await loadTreeData({'async': false,'pcode':''}); | |
45 | - updateSchema({ | |
46 | - field: 'pid', | |
47 | - componentProps: {treeData}, | |
48 | - }); | |
49 | - }); | |
50 | - //设置标题 | |
51 | - const getTitle = computed(() => (!unref(isUpdate) ? '新增字典' : '编辑字典')); | |
52 | - | |
53 | - /** | |
54 | - * 根据pid获取展开的节点 | |
55 | - * @param pid | |
56 | - * @param arr | |
57 | - */ | |
58 | - function getExpandKeysByPid(pid,arr){ | |
59 | - if(pid && arr && arr.length>0){ | |
60 | - for(let i=0;i<arr.length;i++){ | |
61 | - if(arr[i].key==pid && unref(expandedRowKeys).indexOf(pid)<0){ | |
62 | - expandedRowKeys.value.push(arr[i].key); | |
63 | - getExpandKeysByPid(arr[i]['parentId'],unref(treeData)) | |
64 | - }else{ | |
65 | - getExpandKeysByPid(pid,arr[i].children) | |
66 | - } | |
67 | - } | |
68 | - } | |
69 | - } | |
70 | - //表单提交事件 | |
71 | - async function handleSubmit() { | |
72 | - try { | |
73 | - let values = await validate(); | |
74 | - setModalProps({confirmLoading: true}); | |
75 | - //提交表单 | |
76 | - await saveOrUpdateDict(values, isUpdate.value); | |
77 | - //关闭弹窗 | |
78 | - closeModal(); | |
79 | - //展开的节点信息 | |
80 | - await getExpandKeysByPid(values['pid'],unref(treeData)) | |
81 | - //刷新列表(isUpdate:是否编辑;values:表单信息;expandedArr:展开的节点信息) | |
82 | - emit('success', {isUpdate: unref(isUpdate), values:{...values},expandedArr: unref(expandedRowKeys).reverse()}); | |
83 | - } finally { | |
84 | - setModalProps({confirmLoading: false}); | |
85 | - } | |
86 | - } | |
87 | -</script> |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/default/tree/java/${bussiPackage}/${entityPackage}/vue3/index.vuei deleted
1 | -<template> | |
2 | - <div class="p-4"> | |
3 | - <!--引用表格--> | |
4 | - <BasicTable @register="registerTable" :rowSelection="rowSelection" :expandedRowKeys="expandedRowKeys" @expand="handleExpand" @fetch-success="onFetchSuccess"> | |
5 | - <!--插槽:table标题--> | |
6 | - <template #tableTitle> | |
7 | - <a-button type="primary" preIcon="ant-design:plus-outlined" @click="handleCreate"> 新增</a-button> | |
8 | - <a-upload name="file" :showUploadList="false" :customRequest="(file)=>handleImportXls(file,getImportUrl,importSuccess)"> | |
9 | - <a-button type="primary" preIcon="ant-design:import-outlined">导入</a-button> | |
10 | - </a-upload> | |
11 | - <a-button type="primary" preIcon="ant-design:export-outlined" @click="handleExportXls('${tableVo.ftlDescription}管理',getExportUrl)"> 导出</a-button> | |
12 | - | |
13 | - <a-dropdown v-if="checkedKeys.length > 0"> | |
14 | - <template #overlay> | |
15 | - <a-menu> | |
16 | - <a-menu-item key="1" @click="batchHandleDelete"> | |
17 | - <Icon icon="ant-design:delete-outlined"></Icon> | |
18 | - 删除 | |
19 | - </a-menu-item> | |
20 | - </a-menu> | |
21 | - </template> | |
22 | - <a-button>批量操作 | |
23 | - <Icon icon="ant-design:down-outlined"></Icon> | |
24 | - </a-button> | |
25 | - </a-dropdown> | |
26 | - </template> | |
27 | - <!--操作栏--> | |
28 | - <template #action="{ record }"> | |
29 | - <TableAction :actions="getTableAction(record)"/> | |
30 | - </template> | |
31 | - </BasicTable> | |
32 | - <!--字典弹窗--> | |
33 | - <${entityName}Modal @register="registerModal" @success="handleSuccess"/> | |
34 | - </div> | |
35 | -</template> | |
36 | - | |
37 | -<script lang="ts" setup> | |
38 | - //ts语法 | |
39 | - import {ref, computed, unref, toRaw, nextTick} from 'vue'; | |
40 | - import {BasicTable, useTable, TableAction} from '/src/components/Table'; | |
41 | - import {useDrawer} from '/src/components/Drawer'; | |
42 | - import ${entityName}Modal from './components/${entityName}Modal.vue'; | |
43 | - import {useModal} from '/src/components/Modal'; | |
44 | - import {useMethods} from '/src/hooks/system/useMethods'; | |
45 | - import {columns} from './${entityName}.data'; | |
46 | - import {list, delete${entityName}, batchDelete${entityName}, getExportUrl,getImportUrl, getChildList,getChildListBatch} from './${entityName}.api'; | |
47 | - | |
48 | - const checkedKeys = ref<Array<string | number>>([]); | |
49 | - const expandedRowKeys = ref([]); | |
50 | - const {handleExportXls,handleImportXls} = useMethods(); | |
51 | - //字典model | |
52 | - const [registerModal, {openModal}] = useModal(); | |
53 | - //注册table数据 | |
54 | - const [registerTable, {reload, collapseAll, updateTableDataRecord, findTableDataRecord,getDataSource}] = useTable({ | |
55 | - api: list, | |
56 | - rowKey: 'id', | |
57 | - columns, | |
58 | - striped: true, | |
59 | - useSearchForm: false, | |
60 | - showTableSetting: true, | |
61 | - clickToRowSelect: false, | |
62 | - bordered: true, | |
63 | - showIndexColumn: false, | |
64 | - tableSetting: {fullScreen: true}, | |
65 | - canResize: false, | |
66 | - actionColumn: { | |
67 | - width: 80, | |
68 | - title: '操作', | |
69 | - dataIndex: 'action', | |
70 | - slots: {customRender: 'action'}, | |
71 | - fixed: undefined, | |
72 | - }, | |
73 | - }) | |
74 | - | |
75 | - /** | |
76 | - * 选择列配置 | |
77 | - */ | |
78 | - const rowSelection = { | |
79 | - type: 'checkbox', | |
80 | - columnWidth: 10, | |
81 | - selectedRowKeys: checkedKeys, | |
82 | - onChange: onSelectChange | |
83 | - } | |
84 | - | |
85 | - /** | |
86 | - * 选择事件 | |
87 | - */ | |
88 | - function onSelectChange(selectedRowKeys: (string | number)[]) { | |
89 | - checkedKeys.value = selectedRowKeys; | |
90 | - } | |
91 | - | |
92 | - /** | |
93 | - * 新增事件 | |
94 | - */ | |
95 | - function handleCreate() { | |
96 | - openModal(true, { | |
97 | - isUpdate: false, | |
98 | - }); | |
99 | - } | |
100 | - | |
101 | - /** | |
102 | - * 编辑事件 | |
103 | - */ | |
104 | - async function handleEdit(record) { | |
105 | - openModal(true, { | |
106 | - record, | |
107 | - isUpdate: true, | |
108 | - }); | |
109 | - } | |
110 | - | |
111 | - /** | |
112 | - * 详情 | |
113 | - */ | |
114 | - async function handleDetail(record) { | |
115 | - openModal(true, { | |
116 | - record, | |
117 | - isUpdate: true, | |
118 | - hideFooter: true, | |
119 | - }); | |
120 | - } | |
121 | - | |
122 | - /** | |
123 | - * 删除事件 | |
124 | - */ | |
125 | - async function handleDelete(record) { | |
126 | - await delete${entityName}({id: record.id}, importSuccess); | |
127 | - | |
128 | - } | |
129 | - | |
130 | - /** | |
131 | - * 批量删除事件 | |
132 | - */ | |
133 | - async function batchHandleDelete() { | |
134 | - const ids = checkedKeys.value.filter(item => !item.includes('loading')) | |
135 | - await batchDelete${entityName}({ids: ids}, importSuccess); | |
136 | - } | |
137 | - /** | |
138 | - * 导入 | |
139 | - */ | |
140 | - function importSuccess() { | |
141 | - reload() && (expandedRowKeys.value = []); | |
142 | - } | |
143 | - /** | |
144 | - * 添加下级 | |
145 | - */ | |
146 | - function handleAddSub(record) { | |
147 | - openModal(true, { | |
148 | - record, | |
149 | - isUpdate: false, | |
150 | - }); | |
151 | - } | |
152 | - /** | |
153 | - * 成功回调 | |
154 | - */ | |
155 | - async function handleSuccess({isUpdate, values, expandedArr}) { | |
156 | - if (isUpdate) { | |
157 | - //编辑回调 | |
158 | - updateTableDataRecord(values.id, values); | |
159 | - } else { | |
160 | - if(!values['pid']){ | |
161 | - //新增根节点 | |
162 | - reload(); | |
163 | - }else{ | |
164 | - //新增子集 | |
165 | - expandedRowKeys.value = []; | |
166 | - for (let key of unref(expandedArr)) { | |
167 | - await expandTreeNode(key) | |
168 | - } | |
169 | - } | |
170 | - } | |
171 | - } | |
172 | - | |
173 | - /** | |
174 | - * 接口请求成功后回调 | |
175 | - */ | |
176 | - function onFetchSuccess(result) { | |
177 | - getDataByResult(result.items)&&loadDataByExpandedRows(); | |
178 | - } | |
179 | - /** | |
180 | - * 根据已展开的行查询数据(用于保存后刷新时异步加载子级的数据) | |
181 | - */ | |
182 | - async function loadDataByExpandedRows() { | |
183 | - if (unref(expandedRowKeys).length > 0) { | |
184 | - const res = await getChildListBatch({ parentIds: unref(expandedRowKeys).join(',')}); | |
185 | - if (res.success && res.result.records.length>0) { | |
186 | - //已展开的数据批量子节点 | |
187 | - let records = res.result.records | |
188 | - const listMap = new Map(); | |
189 | - for (let item of records) { | |
190 | - let pid = item['pid']; | |
191 | - if (unref(expandedRowKeys).includes(pid)) { | |
192 | - let mapList = listMap.get(pid); | |
193 | - if (mapList == null) { | |
194 | - mapList = []; | |
195 | - } | |
196 | - mapList.push(item); | |
197 | - listMap.set(pid, mapList); | |
198 | - } | |
199 | - } | |
200 | - let childrenMap = listMap; | |
201 | - let fn = (list) => { | |
202 | - if(list) { | |
203 | - list.forEach(data => { | |
204 | - if (unref(expandedRowKeys).includes(data.id)) { | |
205 | - data.children = getDataByResult(childrenMap.get(data.id)) | |
206 | - fn(data.children) | |
207 | - } | |
208 | - }) | |
209 | - } | |
210 | - }; | |
211 | - fn(getDataSource()) | |
212 | - } | |
213 | - } | |
214 | - } | |
215 | - /** | |
216 | - * 处理数据集 | |
217 | - */ | |
218 | - function getDataByResult(result){ | |
219 | - if(result && result.length>0){ | |
220 | - return result.map(item=>{ | |
221 | - //判断是否标记了带有子节点 | |
222 | - if(item["hasChild"]=='1'){ | |
223 | - let loadChild = { id: item.id+'_loadChild', name: 'loading...', isLoading: true } | |
224 | - item.children = [loadChild] | |
225 | - } | |
226 | - return item | |
227 | - }) | |
228 | - } | |
229 | - } | |
230 | - /** | |
231 | - *树节点展开合并 | |
232 | - * */ | |
233 | - async function handleExpand(expanded, record) { | |
234 | - // 判断是否是展开状态,展开状态(expanded)并且存在子集(children)并且未加载过(isLoading)的就去查询子节点数据 | |
235 | - if (expanded) { | |
236 | - expandedRowKeys.value.push(record.id) | |
237 | - if (record.children.length > 0 && !!record.children[0].isLoading) { | |
238 | - let result = await getChildList({pid: record.id}); | |
239 | - result=result.records?result.records:result; | |
240 | - if (result && result.length > 0) { | |
241 | - record.children = getDataByResult(result); | |
242 | - } else { | |
243 | - record.children = null | |
244 | - record.hasChild = '0' | |
245 | - } | |
246 | - } | |
247 | - } else { | |
248 | - let keyIndex = expandedRowKeys.value.indexOf(record.id) | |
249 | - if (keyIndex >= 0) { | |
250 | - expandedRowKeys.value.splice(keyIndex, 1); | |
251 | - } | |
252 | - } | |
253 | - } | |
254 | - /** | |
255 | - *操作表格后处理树节点展开合并 | |
256 | - * */ | |
257 | - async function expandTreeNode(key) { | |
258 | - let record = findTableDataRecord(key) | |
259 | - expandedRowKeys.value.push(key); | |
260 | - let result = await getChildList({pid: key}); | |
261 | - if (result && result.length > 0) { | |
262 | - record.children = getDataByResult(result); | |
263 | - } else { | |
264 | - record.children = null | |
265 | - record.hasChild = '0' | |
266 | - } | |
267 | - updateTableDataRecord(key, record); | |
268 | - } | |
269 | - /** | |
270 | - * 操作栏 | |
271 | - */ | |
272 | - function getTableAction(record) { | |
273 | - return [ | |
274 | - { | |
275 | - label: '编辑', | |
276 | - onClick: handleEdit.bind(null, record), | |
277 | - }, | |
278 | - { | |
279 | - label: '删除', | |
280 | - popConfirm: { | |
281 | - title: '确定删除吗?', | |
282 | - confirm: handleDelete.bind(null, record), | |
283 | - }, | |
284 | - }, | |
285 | - { | |
286 | - label: '添加下级', | |
287 | - onClick: handleAddSub.bind(null, {pid: record.id}), | |
288 | - } | |
289 | - ] | |
290 | - } | |
291 | -</script> | |
292 | - | |
293 | -<style scoped> | |
294 | - | |
295 | -</style> |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/${entityName}List.vuei deleted
1 | -<template> | |
2 | - <div> | |
3 | -<#assign list_need_category=false> | |
4 | -<#assign list_need_pca=false> | |
5 | -<#assign bpm_flag=false> | |
6 | - | |
7 | -<#-- 开始循环 --> | |
8 | -<#list columns as po> | |
9 | -<#if po.fieldDbName=='bpm_status'> | |
10 | - <#assign bpm_flag=true> | |
11 | -</#if> | |
12 | -<#if po.classType=='cat_tree' && po.dictText?default("")?trim?length == 0> | |
13 | -<#assign list_need_category=true> | |
14 | -</#if> | |
15 | -<#if po.classType=='pca'> | |
16 | -<#assign list_need_pca=true> | |
17 | -</#if> | |
18 | -</#list> | |
19 | -<#-- 结束循环 --> | |
20 | - <!--引用表格--> | |
21 | - <BasicTable @register="registerTable" :rowSelection="rowSelection"> | |
22 | - <!--插槽:table标题--> | |
23 | - <template #tableTitle> | |
24 | - <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button> | |
25 | - <ExcelButton :config="excelConfig"></ExcelButton> | |
26 | - <a-dropdown v-if="checkedKeys.length > 0"> | |
27 | - <template #overlay> | |
28 | - <a-menu> | |
29 | - <a-menu-item key="1" @click="batchHandleDelete"> | |
30 | - <Icon icon="ant-design:delete-outlined"></Icon> | |
31 | - 删除 | |
32 | - </a-menu-item> | |
33 | - </a-menu> | |
34 | - </template> | |
35 | - <a-button>批量操作 | |
36 | - <Icon icon="mdi:chevron-down"></Icon> | |
37 | - </a-button> | |
38 | - </a-dropdown> | |
39 | - </template> | |
40 | - <!--操作栏--> | |
41 | - <template #action="{ record }"> | |
42 | - <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/> | |
43 | - </template> | |
44 | - <!--字段回显插槽--> | |
45 | - <template #htmlSlot="{text}"> | |
46 | - <div v-html="text"></div> | |
47 | - </template> | |
48 | - <template #fileSlot="{text}"> | |
49 | - <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span> | |
50 | - <a-button v-else :ghost="true" type="primary" preIcon="ant-design:download-outlined" size="small" @click="downloadFile(text)">下载</a-button> | |
51 | - </template> | |
52 | - </BasicTable> | |
53 | - <!-- 表单区域 --> | |
54 | - <${entityName}Modal @register="registerModal" @success="handleSuccess"></${entityName}Modal> | |
55 | - </div> | |
56 | -</template> | |
57 | - | |
58 | -<script lang="ts" setup> | |
59 | - import {ref, computed, unref} from 'vue'; | |
60 | - import {BasicTable, useTable, TableAction} from '/@/components/Table'; | |
61 | - import ExcelButton from '/@/components/jeecg/ExcelButton.vue' | |
62 | - import {useModal} from '/@/components/Modal'; | |
63 | - import ${entityName}Modal from './components/${entityName}Modal.vue' | |
64 | - import {columns, searchFormSchema} from './${entityName?uncap_first}.data'; | |
65 | - import {list, deleteOne, batchDelete, getImportUrl,getExportUrl} from './${entityName?uncap_first}.api'; | |
66 | - <#if list_need_category> | |
67 | - import { loadCategoryData } from '/@/api/common/api' | |
68 | - import { getAuthCache, setAuthCache } from '/@/utils/auth'; | |
69 | - import { DB_DICT_DATA_KEY } from '/@/enums/cacheEnum'; | |
70 | - </#if> | |
71 | - const checkedKeys = ref<Array<string | number>>([]); | |
72 | - //注册model | |
73 | - const [registerModal, {openModal}] = useModal(); | |
74 | - //注册table数据 | |
75 | - const [registerTable, {reload}] = useTable({ | |
76 | - title: '${tableVo.ftlDescription}', | |
77 | - api: list, | |
78 | - rowKey: 'id', | |
79 | - columns, | |
80 | - formConfig: { | |
81 | - labelWidth: 120, | |
82 | - schemas: searchFormSchema, | |
83 | - autoSubmitOnEnter:true, | |
84 | - showAdvancedButton:true, | |
85 | - fieldMapToTime: [ | |
86 | - <#list columns as po> | |
87 | - <#if po.isQuery=='Y'> | |
88 | - <#if po.queryMode!='single'> | |
89 | - <#if po.classType=='date'> | |
90 | - ['${po.fieldName}', ['${po.fieldName}_begin', '${po.fieldName}_end'], 'YYYY-MM-DD'], | |
91 | - <#elseif po.classType=='datetime'> | |
92 | - ['${po.fieldName}', ['${po.fieldName}_begin', '${po.fieldName}_end'], 'YYYY-MM-DD HH:mm:ss'], | |
93 | - </#if> | |
94 | - </#if> | |
95 | - </#if> | |
96 | - </#list> | |
97 | - ], | |
98 | - }, | |
99 | - striped: true, | |
100 | - useSearchForm: true, | |
101 | - showTableSetting: true, | |
102 | - clickToRowSelect: false, | |
103 | - bordered: true, | |
104 | - showIndexColumn: false, | |
105 | - tableSetting: {fullScreen: true}, | |
106 | - actionColumn: { | |
107 | - width: 120, | |
108 | - title: '操作', | |
109 | - dataIndex: 'action', | |
110 | - slots: {customRender: 'action'}, | |
111 | - fixed: 'right', | |
112 | - }, | |
113 | - }) | |
114 | - /** | |
115 | - * excel导入导出配置 | |
116 | - */ | |
117 | - const excelConfig = { | |
118 | - export: { | |
119 | - name:'${tableVo.ftlDescription}', | |
120 | - url: getExportUrl, | |
121 | - }, | |
122 | - import: { | |
123 | - url: getImportUrl, | |
124 | - success: reload, | |
125 | - } | |
126 | - } | |
127 | - /** | |
128 | - * 选择列配置 | |
129 | - */ | |
130 | - const rowSelection = { | |
131 | - type: 'checkbox', | |
132 | - columnWidth: 30, | |
133 | - selectedRowKeys: checkedKeys, | |
134 | - onChange: onSelectChange | |
135 | - } | |
136 | - /** | |
137 | - * 选择事件 | |
138 | - */ | |
139 | - function onSelectChange(selectedRowKeys: (string | number)[]) { | |
140 | - checkedKeys.value = selectedRowKeys; | |
141 | - } | |
142 | - /** | |
143 | - * 新增事件 | |
144 | - */ | |
145 | - function handleAdd() { | |
146 | - openModal(true, { | |
147 | - isUpdate: false, | |
148 | - showFooter: true, | |
149 | - }); | |
150 | - } | |
151 | - /** | |
152 | - * 编辑事件 | |
153 | - */ | |
154 | - function handleEdit(record: Recordable) { | |
155 | - openModal(true, { | |
156 | - record, | |
157 | - isUpdate: true, | |
158 | - showFooter: true, | |
159 | - }); | |
160 | - } | |
161 | - /** | |
162 | - * 详情 | |
163 | - */ | |
164 | - function handleDetail(record: Recordable) { | |
165 | - openModal(true, { | |
166 | - record, | |
167 | - isUpdate: true, | |
168 | - showFooter: false, | |
169 | - }); | |
170 | - } | |
171 | - /** | |
172 | - * 删除事件 | |
173 | - */ | |
174 | - async function handleDelete(record) { | |
175 | - await deleteOne({id: record.id}, reload); | |
176 | - } | |
177 | - /** | |
178 | - * 批量删除事件 | |
179 | - */ | |
180 | - async function batchHandleDelete() { | |
181 | - await batchDelete({ids: checkedKeys.value}, reload); | |
182 | - } | |
183 | - /** | |
184 | - * 成功回调 | |
185 | - */ | |
186 | - function handleSuccess() { | |
187 | - reload(); | |
188 | - } | |
189 | - /** | |
190 | - * 操作栏 | |
191 | - */ | |
192 | - function getTableAction(record){ | |
193 | - return [ | |
194 | - { | |
195 | - label: '编辑', | |
196 | - onClick: handleEdit.bind(null, record), | |
197 | - } | |
198 | - ] | |
199 | - } | |
200 | - /** | |
201 | - * 下拉操作栏 | |
202 | - */ | |
203 | - function getDropDownAction(record){ | |
204 | - return [ | |
205 | - { | |
206 | - label: '详情', | |
207 | - onClick: handleDetail.bind(null, record), | |
208 | - }, { | |
209 | - label: '删除', | |
210 | - popConfirm: { | |
211 | - title: '是否确认删除', | |
212 | - confirm: handleDelete.bind(null, record), | |
213 | - } | |
214 | - } | |
215 | - ] | |
216 | - } | |
217 | - <#if list_need_category> | |
218 | - /** | |
219 | - * 初始化字典配置 | |
220 | - */ | |
221 | - function initDictConfig(){ | |
222 | - <#list columns as po> | |
223 | - <#if (po.isQuery=='Y' || po.isShowList=='Y') && po.classType!='popup'> | |
224 | - <#if po.classType=='cat_tree' && list_need_category==true> | |
225 | - loadCategoryData({code:'${po.dictField?default("")}'}).then((res) => { | |
226 | - if (res) { | |
227 | - let allDictDate = getAuthCache(DB_DICT_DATA_KEY); | |
228 | - if(!allDictDate['${po.dictField?default("")}']){ | |
229 | - Object.assign(allDictDate,{'${po.dictField?default("")}':res}) | |
230 | - } | |
231 | - setAuthCache(DB_DICT_DATA_KEY,allDictDate) | |
232 | - } | |
233 | - }) | |
234 | - </#if> | |
235 | - </#if> | |
236 | - </#list> | |
237 | - } | |
238 | - initDictConfig(); | |
239 | - </#if> | |
240 | -</script> | |
241 | - | |
242 | -<style scoped> | |
243 | - | |
244 | -</style> | |
245 | 0 | \ No newline at end of file |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__api.tsi deleted
1 | -import {defHttp} from '/@/utils/http/axios'; | |
2 | -import {Modal} from 'ant-design-vue'; | |
3 | - | |
4 | -enum Api { | |
5 | - list = '/${entityPackage}/${entityName?uncap_first}/list', | |
6 | - save='/${entityPackage}/${entityName?uncap_first}/add', | |
7 | - edit='/${entityPackage}/${entityName?uncap_first}/edit', | |
8 | - deleteOne = '/${entityPackage}/${entityName?uncap_first}/delete', | |
9 | - deleteBatch = '/${entityPackage}/${entityName?uncap_first}/deleteBatch', | |
10 | - importExcel = '/${entityPackage}/${entityName?uncap_first}/importExcel', | |
11 | - exportXls = '/${entityPackage}/${entityName?uncap_first}/exportXls', | |
12 | -<#list subTables as sub><#rt/> | |
13 | - ${sub.entityName?uncap_first}List = '/${entityPackage}/${entityName?uncap_first}/query${sub.entityName}ByMainId', | |
14 | -</#list> | |
15 | -} | |
16 | -/** | |
17 | - * 导出api | |
18 | - * @param params | |
19 | - */ | |
20 | -export const getExportUrl = Api.exportXls; | |
21 | - | |
22 | -/** | |
23 | - * 导入api | |
24 | - */ | |
25 | -export const getImportUrl = Api.importExcel; | |
26 | -<#list subTables as sub><#rt/> | |
27 | -/** | |
28 | - * 查询子表数据 | |
29 | - * @param params | |
30 | - */ | |
31 | -export const ${sub.entityName?uncap_first}List = Api.${sub.entityName?uncap_first}List; | |
32 | -</#list> | |
33 | -/** | |
34 | - * 列表接口 | |
35 | - * @param params | |
36 | - */ | |
37 | -export const list = (params) => | |
38 | - defHttp.get({url: Api.list, params}); | |
39 | - | |
40 | -/** | |
41 | - * 删除单个 | |
42 | - */ | |
43 | -export const deleteOne = (params,handleSuccess) => { | |
44 | - return defHttp.delete({url: Api.deleteOne, params}, {joinParamsToUrl: true}).then(() => { | |
45 | - handleSuccess(); | |
46 | - }); | |
47 | -} | |
48 | -/** | |
49 | - * 批量删除 | |
50 | - * @param params | |
51 | - */ | |
52 | -export const batchDelete = (params, handleSuccess) => { | |
53 | - Modal.confirm({ | |
54 | - title: '确认删除', | |
55 | - content: '是否删除选中数据', | |
56 | - okText: '确认', | |
57 | - cancelText: '取消', | |
58 | - onOk: () => { | |
59 | - return defHttp.delete({url: Api.deleteBatch, data: params}, {joinParamsToUrl: true}).then(() => { | |
60 | - handleSuccess(); | |
61 | - }); | |
62 | - } | |
63 | - }); | |
64 | -} | |
65 | -/** | |
66 | - * 保存或者更新 | |
67 | - * @param params | |
68 | - */ | |
69 | -export const saveOrUpdate = (params, isUpdate) => { | |
70 | - let url = isUpdate ? Api.edit : Api.save; | |
71 | - return defHttp.post({url: url, params}); | |
72 | -} |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/${entityName}__data.tsi deleted
1 | -import {BasicColumn} from '/@/components/Table'; | |
2 | -import {FormSchema} from '/@/components/Table'; | |
3 | -import { rules} from '/@/utils/helper/validator'; | |
4 | -import { render } from '/@/utils/common/renderUtils'; | |
5 | -import {JVxeTypes,JVxeColumn} from '/@/components/jeecg/JVxeTable/types' | |
6 | -//列表数据 | |
7 | -export const columns: BasicColumn[] = [ | |
8 | - <#list columns as po> | |
9 | - <#if po.isShowList =='Y' && po.fieldName !='id'> | |
10 | - { | |
11 | - title: '${po.filedComment}', | |
12 | - align:"center", | |
13 | - <#if po.sort=='Y'> | |
14 | - sorter: true, | |
15 | - </#if> | |
16 | - <#if po.classType=='date'> | |
17 | - dataIndex: '${po.fieldName}', | |
18 | - customRender:({text}) =>{ | |
19 | - return !text?"":(text.length>10?text.substr(0,10):text) | |
20 | - }, | |
21 | - <#elseif po.fieldDbType=='Blob'> | |
22 | - dataIndex: '${po.fieldName}String' | |
23 | - <#elseif po.classType=='umeditor'> | |
24 | - dataIndex: '${po.fieldName}', | |
25 | - slots: { customRender: 'htmlSlot' }, | |
26 | - <#elseif po.classType=='pca'> | |
27 | - dataIndex: '${po.fieldName}', | |
28 | - slots: { customRender: 'pcaSlot' },//TODO 未翻译 | |
29 | - <#elseif po.classType=='file'> | |
30 | - dataIndex: '${po.fieldName}', | |
31 | - slots: { customRender: 'fileSlot' }, | |
32 | - <#elseif po.classType=='image'> | |
33 | - dataIndex: '${po.fieldName}', | |
34 | - customRender:render.renderAvatar, | |
35 | - <#elseif po.classType=='switch'> | |
36 | - dataIndex: '${po.fieldName}', | |
37 | -<#assign switch_extend_arr=['Y','N']> | |
38 | -<#if po.dictField?default("")?contains("[")> | |
39 | -<#assign switch_extend_arr=po.dictField?eval> | |
40 | -</#if> | |
41 | -<#list switch_extend_arr as a> | |
42 | -<#if a_index == 0> | |
43 | -<#assign switch_extend_arr1=a> | |
44 | -<#else> | |
45 | -<#assign switch_extend_arr2=a> | |
46 | -</#if> | |
47 | -</#list> | |
48 | - customRender:({text}) => { | |
49 | - return render.renderSwitch(text, [{text:'是',value:'${switch_extend_arr1}'},{text:'否',value:'${switch_extend_arr2}'}]) | |
50 | - }, | |
51 | - <#elseif po.classType == 'sel_tree' || po.classType=='list' || po.classType=='list_multi' || po.classType=='sel_search' || po.classType=='radio' || po.classType=='checkbox' || po.classType=='sel_depart' || po.classType=='sel_user'> | |
52 | - dataIndex: '${po.fieldName}_dictText' | |
53 | - <#elseif po.classType=='cat_tree'> | |
54 | - dataIndex: '${po.fieldName}', | |
55 | - <#if po.dictText?default("")?trim?length == 0> | |
56 | - customRender:({text}) => { | |
57 | - return render.renderCategoryTree(text,'${po.dictField?default("")}') | |
58 | - }, | |
59 | - <#else> | |
60 | - customRender: (text, record) => (text ? record['${po.dictText}'] : '') | |
61 | - </#if> | |
62 | - <#else> | |
63 | - dataIndex: '${po.fieldName}' | |
64 | - </#if> | |
65 | - }, | |
66 | - </#if> | |
67 | - </#list> | |
68 | -]; | |
69 | -//查询数据 | |
70 | -export const searchFormSchema: FormSchema[] = [ | |
71 | -<#-- 开始循环 --> | |
72 | -<#list columns as po> | |
73 | -<#if po.fieldDbName=='bpm_status'> | |
74 | - <#assign bpm_flag=true> | |
75 | -</#if> | |
76 | -<#if po.isQuery=='Y'> | |
77 | -<#assign query_flag=true> | |
78 | - <#assign query_field_dictCode=""> | |
79 | - <#if po.dictTable?default("")?trim?length gt 1> | |
80 | - <#assign query_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
81 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
82 | - <#assign query_field_dictCode="${po.dictField}"> | |
83 | - </#if> | |
84 | -<#if po.queryMode=='single'> | |
85 | - { | |
86 | - label: "${po.filedComment}", | |
87 | - field: "${po.fieldName}", | |
88 | -<#if po.classType=='sel_search'> | |
89 | - component: 'JSearchSelect', | |
90 | - componentProps:{ | |
91 | - dict:"${po.dictTable},${po.dictText},${po.dictField}" | |
92 | - }, | |
93 | -<#elseif po.classType=='sel_user'> | |
94 | - component: 'JSelectUserByDept', | |
95 | -<#elseif po.classType=='switch'> | |
96 | - component: 'JSwitch', | |
97 | - componentProps:{ | |
98 | - <#if po.dictField != 'is_open'> | |
99 | - options:"${po.dictField}" | |
100 | - </#if> | |
101 | - }, | |
102 | - <#elseif po.classType=='sel_depart'> | |
103 | - component: 'JSelectDept', | |
104 | - <#elseif po.classType=='list_multi'> | |
105 | - component: 'JMultiSelectTag',//暂无该组件 | |
106 | - componentProps:{ | |
107 | - dictCode:"query_field_dictCode?default("")" | |
108 | - }, | |
109 | - <#elseif po.classType=='cat_tree'> | |
110 | - component: 'JCategorySelect', | |
111 | - componentProps:{ | |
112 | - pcode:"${po.dictField?default("")}",//back和事件未添加,暂时有问题 | |
113 | - }, | |
114 | -<#elseif po.classType=='date'> | |
115 | - component: 'DatePicker', | |
116 | -<#elseif po.classType=='datetime'> | |
117 | - component: 'DatePicker', | |
118 | - componentProps: { | |
119 | - showTime:true | |
120 | - }, | |
121 | -<#elseif po.classType=='pca'> | |
122 | - component: 'JAreaLinkage', | |
123 | -<#elseif po.classType=='popup'> | |
124 | - component: 'JPopup', | |
125 | - componentProps: ({ formActionType }) => { | |
126 | - const {setFieldsValue} = formActionType; | |
127 | - return{ | |
128 | - setFieldsValue:setFieldsValue, | |
129 | - code:"${po.dictTable}", | |
130 | - fieldConfig:"${po.dictField}", | |
131 | - multi:${po.extendParams.popupMulti?c}, | |
132 | - } | |
133 | - }, | |
134 | -<#elseif po.classType=='list' || po.classType=='radio' || po.classType=='checkbox'> | |
135 | -<#-- ---------------------------下拉或是单选 判断数据字典是表字典还是普通字典------------------------------- --> | |
136 | - component: 'JDictSelectTag', | |
137 | - componentProps:{ | |
138 | - <#if po.dictTable?default("")?trim?length gt 1> | |
139 | - dictCode:"${po.dictTable},${po.dictText},${po.dictField}" | |
140 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
141 | - dictCode:"${po.dictField}" | |
142 | - </#if> | |
143 | - }, | |
144 | -<#else> | |
145 | - component: 'Input', | |
146 | -</#if> | |
147 | -<#else> | |
148 | - { | |
149 | - label: "${po.filedComment}", | |
150 | - field: "${po.fieldName}", | |
151 | -<#if po.classType=='date'> | |
152 | - component: 'RangePicker', | |
153 | -<#elseif po.classType=='datetime'> | |
154 | - component: 'RangePicker', | |
155 | - componentProps: { | |
156 | - showTime:true | |
157 | - }, | |
158 | -<#else> | |
159 | - component: 'Input', //TODO 范围查询 | |
160 | -</#if> | |
161 | - colProps: {span: 6}, | |
162 | - }, | |
163 | -</#if> | |
164 | -</#if> | |
165 | -</#list> | |
166 | -<#-- 结束循环 --> | |
167 | -]; | |
168 | -//表单数据 | |
169 | -export const formSchema: FormSchema[] = [ | |
170 | -<#assign form_cat_tree = false> | |
171 | -<#assign form_cat_back = ""> | |
172 | -<#assign bpm_flag=false> | |
173 | -<#list columns as po><#rt/> | |
174 | -<#if po.fieldDbName=='bpm_status'> | |
175 | - <#assign bpm_flag=true> | |
176 | -</#if> | |
177 | -<#if po.isShow =='Y'> | |
178 | -<#assign form_field_dictCode=""> | |
179 | - <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1> | |
180 | - <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
181 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
182 | - <#assign form_field_dictCode="${po.dictField}"> | |
183 | - </#if> | |
184 | - { | |
185 | - label: '${po.filedComment}', | |
186 | - field: '${po.fieldName}', | |
187 | - <#if po.classType =='date'> | |
188 | - component: 'DatePicker', | |
189 | - <#elseif po.fieldType =='datetime'> | |
190 | - component: 'DatePicker', | |
191 | - componentProps: { | |
192 | - showTime:true | |
193 | - }, | |
194 | - <#elseif po.fieldType =='time'> | |
195 | - component: 'TimePicker', | |
196 | - <#elseif po.classType =='popup'> | |
197 | - component: 'JPopup', | |
198 | - componentProps: ({ formActionType }) => { | |
199 | - const {setFieldsValue} = formActionType; | |
200 | - return{ | |
201 | - setFieldsValue:setFieldsValue, | |
202 | - code:"${po.dictTable}", | |
203 | - fieldConfig:${po.dictField}, | |
204 | - multi:${po.extendParams.popupMulti?c}, | |
205 | - } | |
206 | - } | |
207 | - <#elseif po.classType =='sel_depart'> | |
208 | - component: 'JSelectDept', | |
209 | - <#elseif po.classType =='switch'> | |
210 | - component: 'JSwitch', | |
211 | - componentProps:{ | |
212 | - <#if po.dictField != 'is_open'> | |
213 | - options:${po.dictField} | |
214 | - </#if> | |
215 | - } | |
216 | - <#elseif po.classType =='pca'> | |
217 | - component: 'JAreaLinkage', | |
218 | - <#elseif po.classType =='markdown'> | |
219 | - component: 'JMarkdownEditor',//注意string转换问题 | |
220 | - <#elseif po.classType =='password'> | |
221 | - component: 'InputPassword', | |
222 | - <#elseif po.classType =='sel_user'> | |
223 | - component: 'JSelectUserByDept', | |
224 | - componentProps:{ | |
225 | - labelKey:'realname', | |
226 | - } | |
227 | - <#elseif po.classType =='textarea'> | |
228 | - component: 'InputTextArea',//TODO 注意string转换问题 | |
229 | - <#elseif po.classType=='list' || po.classType=='radio'> | |
230 | - component: 'JDictSelectTag', | |
231 | - componentProps:{ | |
232 | - dictCode:"${form_field_dictCode}" | |
233 | - } | |
234 | - <#elseif po.classType=='list_multi' || po.classType=='checkbox'> | |
235 | - component: 'JMultiSelectTag',//TODO 暂无该组件 | |
236 | - componentProps:{ | |
237 | - dictCode:"${form_field_dictCode}" | |
238 | - } | |
239 | - <#elseif po.classType=='sel_search'> | |
240 | - component: 'JSearchSelect', | |
241 | - componentProps:{ | |
242 | - dict:"${form_field_dictCode}" | |
243 | - } | |
244 | -<#elseif po.classType=='cat_tree'> | |
245 | - <#assign form_cat_tree = true> | |
246 | - component: 'JCategorySelect', | |
247 | - componentProps:{ | |
248 | - pcode:"${po.dictField?default("")}", //TODO back和事件未添加,暂时有问题 | |
249 | - } | |
250 | - <#if po.dictText?default("")?trim?length gt 1> | |
251 | - <#assign form_cat_back = "${po.dictText}"> | |
252 | - </#if> | |
253 | - <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'> | |
254 | - component: 'InputNumber', | |
255 | - <#elseif po.classType=='file'> | |
256 | - component: 'JUpload', | |
257 | - componentProps:{ | |
258 | - <#if po.uploadnum??> | |
259 | - maxCount:${po.uploadnum} | |
260 | - </#if> | |
261 | - } | |
262 | - <#elseif po.classType=='image'> | |
263 | - component: 'JImageUpload', | |
264 | - componentProps:{ | |
265 | - <#if po.uploadnum??> | |
266 | - fileMax:${po.uploadnum} | |
267 | - </#if> | |
268 | - } | |
269 | - <#elseif po.classType=='umeditor'> | |
270 | - component: 'JCodeEditor', //TODO String后缀暂未添加 | |
271 | - <#elseif po.classType == 'sel_tree'> | |
272 | - component: 'JTreeSelect', | |
273 | - componentProps:{ | |
274 | - <#if po.dictText??> | |
275 | - <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> | |
276 | - dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}", | |
277 | - <#elseif po.dictText?split(',')[1]??> | |
278 | - pidField:"${po.dictText?split(',')[1]}", | |
279 | - <#elseif po.dictText?split(',')[3]??> | |
280 | - hasChildField:"${po.dictText?split(',')[3]}", | |
281 | - </#if> | |
282 | - </#if> | |
283 | - pidValue:"${po.dictField}", | |
284 | - } | |
285 | - <#else> | |
286 | - component: 'Input', | |
287 | - </#if> | |
288 | - <#include "/common/utils.ftl"> | |
289 | - <#if po.isShow == 'Y' && poHasCheck(po)> | |
290 | - dynamicRules: ({model,schema}) => { | |
291 | - <#if po.fieldName != 'id'> | |
292 | - <#assign fieldValidType = po.fieldValidType!''> | |
293 | - return [ | |
294 | - <#-- 非空校验 --> | |
295 | - <#if po.nullable == 'N' || fieldValidType == '*'> | |
296 | - { required: true, message: '请输入${po.filedComment}!'}, | |
297 | - <#elseif fieldValidType!=''> | |
298 | - { required: false}, | |
299 | - </#if> | |
300 | - <#-- 唯一校验 --> | |
301 | - <#if fieldValidType == 'only'> | |
302 | - {...rules.duplicateCheckRule(<#if sub?default("")?trim?length gt 1>'${sub.tableName}'<#else>'${tableName}'</#if>, '${po.fieldDbName}',model,schema,true)[0]}, | |
303 | - <#-- 6到16位数字 --> | |
304 | - <#elseif fieldValidType == 'n6-16'> | |
305 | - { pattern: /^\d{6,16}$/, message: '请输入6到16位数字!'}, | |
306 | - <#-- 6到16位任意字符 --> | |
307 | - <#elseif fieldValidType == '*6-16'> | |
308 | - { pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'}, | |
309 | - <#-- 6到18位字符串 --> | |
310 | - <#elseif fieldValidType == 's6-18'> | |
311 | - { pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'}, | |
312 | - <#-- 网址 --> | |
313 | - <#elseif fieldValidType == 'url'> | |
314 | - { pattern: /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/, message: '请输入正确的网址!'}, | |
315 | - <#-- 电子邮件 --> | |
316 | - <#elseif fieldValidType == 'e'> | |
317 | - { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'}, | |
318 | - <#-- 手机号码 --> | |
319 | - <#elseif fieldValidType == 'm'> | |
320 | - { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'}, | |
321 | - <#-- 邮政编码 --> | |
322 | - <#elseif fieldValidType == 'p'> | |
323 | - { pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'}, | |
324 | - <#-- 字母 --> | |
325 | - <#elseif fieldValidType == 's'> | |
326 | - { pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'}, | |
327 | - <#-- 数字 --> | |
328 | - <#elseif fieldValidType == 'n'> | |
329 | - { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}, | |
330 | - <#-- 整数 --> | |
331 | - <#elseif fieldValidType == 'z'> | |
332 | - { pattern: /^-?\d+$/, message: '请输入整数!'}, | |
333 | - <#-- 金额 --> | |
334 | - <#elseif fieldValidType == 'money'> | |
335 | - { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}, | |
336 | - <#-- 正则校验 --> | |
337 | - <#elseif fieldValidType != '' && fieldValidType != '*'> | |
338 | - { pattern: '${fieldValidType}', message: '不符合校验规则!'}, | |
339 | - <#-- 无校验 --> | |
340 | - <#else> | |
341 | - <#t> | |
342 | - </#if> | |
343 | - ]; | |
344 | - </#if> | |
345 | - }, | |
346 | - </#if> | |
347 | - <#if po.readonly=='Y'> | |
348 | - dynamicDisabled:true | |
349 | - </#if> | |
350 | - }, | |
351 | -</#if> | |
352 | -</#list> | |
353 | -]; | |
354 | -//子表单数据 | |
355 | -<#list subTables as sub> | |
356 | -<#if sub.foreignRelationType =='1'> | |
357 | -export const ${sub.entityName?uncap_first}FormSchema: FormSchema[] = [ | |
358 | -<#assign form_cat_tree = false> | |
359 | -<#assign form_cat_back = ""> | |
360 | -<#assign bpm_flag=false> | |
361 | -<#list sub.colums as po><#rt/> | |
362 | -<#if po.fieldDbName=='bpm_status'> | |
363 | - <#assign bpm_flag=true> | |
364 | -</#if> | |
365 | -<#if po.isShow =='Y'> | |
366 | -<#assign form_field_dictCode=""> | |
367 | - <#if po.dictTable?default("")?trim?length gt 1 && po.dictText?default("")?trim?length gt 1 && po.dictField?default("")?trim?length gt 1> | |
368 | - <#assign form_field_dictCode="${po.dictTable},${po.dictText},${po.dictField}"> | |
369 | - <#elseif po.dictField?default("")?trim?length gt 1> | |
370 | - <#assign form_field_dictCode="${po.dictField}"> | |
371 | - </#if> | |
372 | - { | |
373 | - label: '${po.filedComment}', | |
374 | - field: '${po.fieldName}', | |
375 | - <#if po.classType =='date'> | |
376 | - component: 'DatePicker', | |
377 | - <#elseif po.fieldType =='datetime'> | |
378 | - component: 'DatePicker', | |
379 | - componentProps: { | |
380 | - showTime:true | |
381 | - }, | |
382 | - <#elseif po.fieldType =='time'> | |
383 | - component: 'TimePicker', | |
384 | - <#elseif po.classType =='popup'> | |
385 | - component: 'JPopup', | |
386 | - componentProps: ({ formActionType }) => { | |
387 | - const {setFieldsValue} = formActionType; | |
388 | - return{ | |
389 | - setFieldsValue:setFieldsValue, | |
390 | - code:"${po.dictTable}", | |
391 | - fieldConfig:${po.dictField}, | |
392 | - multi:${po.extendParams.popupMulti?c}, | |
393 | - } | |
394 | - } | |
395 | - <#elseif po.classType =='sel_depart'> | |
396 | - component: 'JSelectDept', | |
397 | - <#elseif po.classType =='switch'> | |
398 | - component: 'JSwitch', | |
399 | - componentProps:{ | |
400 | - <#if po.dictField != 'is_open'> | |
401 | - options:${po.dictField} | |
402 | - </#if> | |
403 | - } | |
404 | - <#elseif po.classType =='pca'> | |
405 | - component: 'JAreaLinkage', | |
406 | - <#elseif po.classType =='markdown'> | |
407 | - component: 'JMarkdownEditor',//注意string转换问题 | |
408 | - <#elseif po.classType =='password'> | |
409 | - component: 'InputPassword', | |
410 | - <#elseif po.classType =='sel_user'> | |
411 | - component: 'JSelectUserByDept', | |
412 | - componentProps:{ | |
413 | - labelKey:'realname', | |
414 | - } | |
415 | - <#elseif po.classType =='textarea'> | |
416 | - component: 'InputTextArea',//TODO 注意string转换问题 | |
417 | - <#elseif po.classType=='list' || po.classType=='radio'> | |
418 | - component: 'JDictSelectTag', | |
419 | - componentProps:{ | |
420 | - dictCode:"${form_field_dictCode}" | |
421 | - } | |
422 | - <#elseif po.classType=='list_multi' || po.classType=='checkbox'> | |
423 | - component: 'JMultiSelectTag',//TODO 暂无该组件 | |
424 | - componentProps:{ | |
425 | - dictCode:"${form_field_dictCode}" | |
426 | - } | |
427 | - <#elseif po.classType=='sel_search'> | |
428 | - component: 'JSearchSelect', | |
429 | - componentProps:{ | |
430 | - dict:"${form_field_dictCode}" | |
431 | - } | |
432 | -<#elseif po.classType=='cat_tree'> | |
433 | - <#assign form_cat_tree = true> | |
434 | - component: 'JCategorySelect', | |
435 | - componentProps:{ | |
436 | - pcode:"${po.dictField?default("")}", //TODO back和事件未添加,暂时有问题 | |
437 | - } | |
438 | - <#if po.dictText?default("")?trim?length gt 1> | |
439 | - <#assign form_cat_back = "${po.dictText}"> | |
440 | - </#if> | |
441 | - <#elseif po.fieldDbType=='int' || po.fieldDbType=='double' || po.fieldDbType=='BigDecimal'> | |
442 | - component: 'InputNumber', | |
443 | - <#elseif po.classType=='file'> | |
444 | - component: 'JUpload', | |
445 | - componentProps:{ | |
446 | - <#if po.uploadnum??> | |
447 | - maxCount:${po.uploadnum} | |
448 | - </#if> | |
449 | - } | |
450 | - <#elseif po.classType=='image'> | |
451 | - component: 'JImageUpload', | |
452 | - componentProps:{ | |
453 | - <#if po.uploadnum??> | |
454 | - fileMax:${po.uploadnum} | |
455 | - </#if> | |
456 | - } | |
457 | - <#elseif po.classType=='umeditor'> | |
458 | - component: 'JCodeEditor', //TODO String后缀暂未添加 | |
459 | - <#elseif po.classType == 'sel_tree'> | |
460 | - component: 'JTreeSelect', | |
461 | - componentProps:{ | |
462 | - <#if po.dictText??> | |
463 | - <#if po.dictText?split(',')[2]?? && po.dictText?split(',')[0]??> | |
464 | - dict:"${po.dictTable},${po.dictText?split(',')[2]},${po.dictText?split(',')[0]}", | |
465 | - <#elseif po.dictText?split(',')[1]??> | |
466 | - pidField:"${po.dictText?split(',')[1]}", | |
467 | - <#elseif po.dictText?split(',')[3]??> | |
468 | - hasChildField:"${po.dictText?split(',')[3]}", | |
469 | - </#if> | |
470 | - </#if> | |
471 | - pidValue:"${po.dictField}", | |
472 | - } | |
473 | - <#else> | |
474 | - component: 'Input', | |
475 | - </#if> | |
476 | - <#include "/common/utils.ftl"> | |
477 | - <#if po.isShow == 'Y' && poHasCheck(po)> | |
478 | - dynamicRules: ({model,schema}) => { | |
479 | - <#if po.fieldName != 'id'> | |
480 | - <#assign fieldValidType = po.fieldValidType!''> | |
481 | - return [ | |
482 | - <#-- 非空校验 --> | |
483 | - <#if po.nullable == 'N' || fieldValidType == '*'> | |
484 | - { required: true, message: '请输入${po.filedComment}!'}, | |
485 | - <#elseif fieldValidType!=''> | |
486 | - { required: false}, | |
487 | - </#if> | |
488 | - <#-- 唯一校验 --> | |
489 | - <#if fieldValidType == 'only'> | |
490 | - {...rules.duplicateCheckRule(<#if sub?default("")?trim?length gt 1>'${sub.tableName}'<#else>'${tableName}'</#if>, '${po.fieldDbName}',model,schema,true)[0]}, | |
491 | - <#-- 6到16位数字 --> | |
492 | - <#elseif fieldValidType == 'n6-16'> | |
493 | - { pattern: /^\d{6,16}$/, message: '请输入6到16位数字!'}, | |
494 | - <#-- 6到16位任意字符 --> | |
495 | - <#elseif fieldValidType == '*6-16'> | |
496 | - { pattern: /^.{6,16}$/, message: '请输入6到16位任意字符!'}, | |
497 | - <#-- 6到18位字符串 --> | |
498 | - <#elseif fieldValidType == 's6-18'> | |
499 | - { pattern: /^.{6,18}$/, message: '请输入6到18位任意字符!'}, | |
500 | - <#-- 网址 --> | |
501 | - <#elseif fieldValidType == 'url'> | |
502 | - { pattern: /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-.,@?^=%&:\/~+#]*[\w\-@?^=%&\/~+#])?$/, message: '请输入正确的网址!'}, | |
503 | - <#-- 电子邮件 --> | |
504 | - <#elseif fieldValidType == 'e'> | |
505 | - { pattern: /^([\w]+\.*)([\w]+)@[\w]+\.\w{3}(\.\w{2}|)$/, message: '请输入正确的电子邮件!'}, | |
506 | - <#-- 手机号码 --> | |
507 | - <#elseif fieldValidType == 'm'> | |
508 | - { pattern: /^1[3456789]\d{9}$/, message: '请输入正确的手机号码!'}, | |
509 | - <#-- 邮政编码 --> | |
510 | - <#elseif fieldValidType == 'p'> | |
511 | - { pattern: /^[1-9]\d{5}$/, message: '请输入正确的邮政编码!'}, | |
512 | - <#-- 字母 --> | |
513 | - <#elseif fieldValidType == 's'> | |
514 | - { pattern: /^[A-Z|a-z]+$/, message: '请输入字母!'}, | |
515 | - <#-- 数字 --> | |
516 | - <#elseif fieldValidType == 'n'> | |
517 | - { pattern: /^-?\d+\.?\d*$/, message: '请输入数字!'}, | |
518 | - <#-- 整数 --> | |
519 | - <#elseif fieldValidType == 'z'> | |
520 | - { pattern: /^-?\d+$/, message: '请输入整数!'}, | |
521 | - <#-- 金额 --> | |
522 | - <#elseif fieldValidType == 'money'> | |
523 | - { pattern: /^(([1-9][0-9]*)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额!'}, | |
524 | - <#-- 正则校验 --> | |
525 | - <#elseif fieldValidType != '' && fieldValidType != '*'> | |
526 | - { pattern: '${fieldValidType}', message: '不符合校验规则!'}, | |
527 | - <#-- 无校验 --> | |
528 | - <#else> | |
529 | - <#t> | |
530 | - </#if> | |
531 | - ]; | |
532 | - </#if> | |
533 | - }, | |
534 | - </#if> | |
535 | - <#if po.readonly=='Y'> | |
536 | - dynamicDisabled:true | |
537 | - </#if> | |
538 | - }, | |
539 | -</#if> | |
540 | -</#list> | |
541 | -]; | |
542 | -</#if> | |
543 | -</#list> | |
544 | -//子表表格配置 | |
545 | -<#list subTables as sub> | |
546 | -<#if sub.foreignRelationType =='0'> | |
547 | -export const ${sub.entityName?uncap_first}Columns: JVxeColumn[] = [ | |
548 | -<#assign popupBackFields = ""> | |
549 | - | |
550 | -<#-- 循环子表的列 开始 --> | |
551 | -<#list sub.colums as col><#rt/> | |
552 | -<#if col.isShow =='Y'> | |
553 | -<#if col.filedComment !='外键' > | |
554 | - { | |
555 | - title: '${col.filedComment}', | |
556 | - key: '${autoStringSuffixForModel(col)}', | |
557 | -<#if col.classType =='date'> | |
558 | - type: JVxeTypes.date, | |
559 | - <#if col.readonly=='Y'> | |
560 | - disabled:true, | |
561 | - </#if> | |
562 | -<#elseif col.classType =='datetime'> | |
563 | - type: JVxeTypes.datetime, | |
564 | - <#if col.readonly=='Y'> | |
565 | - disabled:true, | |
566 | - </#if> | |
567 | -<#elseif col.classType =='textarea'> | |
568 | - type: JVxeTypes.textarea, | |
569 | - <#if col.readonly=='Y'> | |
570 | - disabled:true, | |
571 | - </#if> | |
572 | -<#elseif "int,decimal,double,"?contains(col.classType)> | |
573 | - type: JVxeTypes.inputNumber, | |
574 | - <#if col.readonly=='Y'> | |
575 | - disabled:true, | |
576 | - </#if> | |
577 | -<#elseif col.classType =='list' || col.classType =='radio'> | |
578 | - type: JVxeTypes.select, | |
579 | - options:[], | |
580 | - <#if col.dictTable?default("")?trim?length gt 1> | |
581 | - dictCode:"${col.dictTable},${col.dictText},${col.dictField}", | |
582 | - <#else> | |
583 | - dictCode:"${col.dictField}", | |
584 | - </#if> | |
585 | - <#if col.readonly=='Y'> | |
586 | - disabled:true, | |
587 | - </#if> | |
588 | -<#elseif col.classType =='list_multi' || col.classType =='checkbox'> | |
589 | - type: JVxeTypes.selectMultiple, | |
590 | - options:[], | |
591 | - <#if col.dictTable?default("")?trim?length gt 1> | |
592 | - dictCode:"${col.dictTable},${col.dictText},${col.dictField}", | |
593 | - <#else> | |
594 | - dictCode:"${col.dictField}", | |
595 | - </#if> | |
596 | - <#if col.readonly=='Y'> | |
597 | - disabled:true, | |
598 | - </#if> | |
599 | -<#elseif col.classType =='sel_search'> | |
600 | - type: JVxeTypes.selectSearch, | |
601 | - <#if col.dictTable?default("")?trim?length gt 1> | |
602 | - dictCode:"${col.dictTable},${col.dictText},${col.dictField}", | |
603 | - <#else> | |
604 | - dictCode:"${col.dictField}", | |
605 | - </#if> | |
606 | - <#if col.readonly=='Y'> | |
607 | - disabled:true, | |
608 | - </#if> | |
609 | -<#elseif col.classType =='image'> | |
610 | - type: JVxeTypes.image, | |
611 | - token:true, | |
612 | - responseName:"message", | |
613 | - <#if col.readonly=='Y'> | |
614 | - disabled:true, | |
615 | - </#if> | |
616 | - <#if col.uploadnum??> | |
617 | - number: ${col.uploadnum}, | |
618 | - </#if> | |
619 | -<#elseif col.classType =='file'> | |
620 | - type: JVxeTypes.file, | |
621 | - token:true, | |
622 | - responseName:"message", | |
623 | - <#if col.readonly=='Y'> | |
624 | - disabled:true, | |
625 | - </#if> | |
626 | - <#if col.uploadnum??> | |
627 | - number: ${col.uploadnum}, | |
628 | - </#if> | |
629 | -<#elseif col.classType =='switch'> | |
630 | - type: JVxeTypes.checkbox, | |
631 | - <#if col.dictField == 'is_open'> | |
632 | - customValue: ['Y', 'N'], | |
633 | - <#else> | |
634 | - customValue: ${col.dictField}, | |
635 | - </#if> | |
636 | - <#if col.readonly=='Y'> | |
637 | - disabled:true, | |
638 | - </#if> | |
639 | -<#elseif col.classType =='popup'> | |
640 | -<#if popupBackFields?length gt 0> | |
641 | - <#assign popupBackFields = "${popupBackFields}"+","+"${col.dictText}"> | |
642 | -<#else> | |
643 | - <#assign popupBackFields = "${col.dictText}"> | |
644 | -</#if> | |
645 | - type: JVxeTypes.popup, | |
646 | - popupCode:"${col.dictTable}", | |
647 | - field:"${col.dictField}", | |
648 | - orgFields:"${col.dictField}", | |
649 | - destFields:"${Format.underlineToHump(col.dictText)}", | |
650 | - <#if col.readonly=='Y'> | |
651 | - disabled:true, | |
652 | - </#if> | |
653 | -<#else> | |
654 | - type: JVxeTypes.input, | |
655 | - <#if col.readonly=='Y'> | |
656 | - disabled:true, | |
657 | - </#if> | |
658 | -</#if> | |
659 | -<#if col.classType =='list_multi' || col.classType =='checkbox'> | |
660 | - width:"250px", | |
661 | -<#else> | |
662 | - width:"200px", | |
663 | -</#if> | |
664 | -<#if col.classType =='file'> | |
665 | - placeholder: '请选择文件', | |
666 | -<#else> | |
667 | - placeholder: '请输入${'$'}{title}', | |
668 | -</#if> | |
669 | -<#if col.defaultVal??> | |
670 | -<#if col.fieldDbType=="BigDecimal" || col.fieldDbType=="double" || col.fieldDbType=="int"> | |
671 | - defaultValue:${col.defaultVal}, | |
672 | - <#else> | |
673 | - defaultValue:"${col.defaultVal}", | |
674 | -</#if> | |
675 | -<#else> | |
676 | - defaultValue:'', | |
677 | -</#if> | |
678 | -<#-- 子表的校验 --> | |
679 | -<#assign subFieldValidType = col.fieldValidType!''> | |
680 | -<#-- 非空校验 --> | |
681 | -<#if col.nullable == 'N' || subFieldValidType == '*'> | |
682 | - validateRules: [{ required: true, message: '${'$'}{title}不能为空' }], | |
683 | -<#-- 其他情况下,只要有值就被认为是正则校验 --> | |
684 | -<#elseif subFieldValidType?length gt 0> | |
685 | -<#assign subMessage = '格式不正确'> | |
686 | -<#if subFieldValidType == 'only' > | |
687 | - <#assign subMessage = '不能重复'> | |
688 | -</#if> | |
689 | - validateRules: [{ pattern: "${subFieldValidType}", message: "${'$'}{title}${subMessage}" }], | |
690 | -</#if> | |
691 | - }, | |
692 | -</#if> | |
693 | -</#if> | |
694 | -</#list> | |
695 | -<#-- 循环子表的列 结束 --> | |
696 | - ] | |
697 | -</#if> | |
698 | -</#list> | |
699 | 0 | \ No newline at end of file |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/${entityName}Modal.vuei deleted
1 | -<template> | |
2 | - <BasicModal v-bind="$attrs" @register="registerModal" :title="title" @ok="handleSubmit"> | |
3 | - <BasicForm @register="registerForm" ref="formRef"/> | |
4 | - <!-- 子表单区域 --> | |
5 | - <a-tabs v-model:activeKey="activeKey" @change="handleChangeTabs"> | |
6 | -<#list subTables as sub><#rt/> | |
7 | - <#if sub.foreignRelationType =='1'> | |
8 | - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> | |
9 | - <${sub.entityName}Form ref="${sub.entityName?uncap_first}Form"></${sub.entityName}Form> | |
10 | - </a-tab-pane> | |
11 | - | |
12 | - <#else> | |
13 | - <a-tab-pane tab="${sub.ftlDescription}" :key="refKeys[${sub_index}]" :forceRender="true"> | |
14 | - <JVxeTable | |
15 | - keep-source | |
16 | - resizable | |
17 | - :ref="refKeys[${sub_index}]" | |
18 | - :loading="${sub.entityName?uncap_first}Table.loading" | |
19 | - :columns="${sub.entityName?uncap_first}Table.columns" | |
20 | - :dataSource="${sub.entityName?uncap_first}Table.dataSource" | |
21 | - :maxHeight="300" | |
22 | - :rowNumber="true" | |
23 | - :rowSelection="true" | |
24 | - :toolbar="true" | |
25 | - /> | |
26 | - </a-tab-pane> | |
27 | - </#if> | |
28 | -</#list> | |
29 | - </a-tabs> | |
30 | - </BasicModal> | |
31 | -</template> | |
32 | - | |
33 | -<script lang="ts" setup> | |
34 | - import {ref, computed, unref,reactive} from 'vue'; | |
35 | - import {BasicModal, useModalInner} from '/@/components/Modal'; | |
36 | - import {BasicForm, useForm} from '/@/components/Form/index'; | |
37 | - import { JVxeTable } from '/@/components/jeecg/JVxeTable' | |
38 | - import { useJvxeMethod } from '/@/hooks/system/useJvxeMethods.ts' | |
39 | - <#list subTables as sub> | |
40 | - <#if sub.foreignRelationType =='1'> | |
41 | - import ${sub.entityName}Form from './${sub.entityName}Form.vue' | |
42 | - </#if> | |
43 | - </#list> | |
44 | - import {formSchema<#list subTables as sub><#if sub.foreignRelationType =='0'>,${sub.entityName?uncap_first}Columns</#if></#list>} from '../${entityName?uncap_first}.data'; | |
45 | - import {saveOrUpdate<#list subTables as sub>,${sub.entityName?uncap_first}List</#list>} from '../${entityName?uncap_first}.api'; | |
46 | - import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils' | |
47 | - // Emits声明 | |
48 | - const emit = defineEmits(['register','success']); | |
49 | - const isUpdate = ref(true); | |
50 | - const refKeys = ref([<#list subTables as sub>'${sub.entityName?uncap_first}', </#list>]); | |
51 | - <#assign hasOne2Many = false> | |
52 | - <#assign hasOne2One = false> | |
53 | - const activeKey = ref('${subTables[0].entityName?uncap_first}'); | |
54 | -<#list subTables as sub> | |
55 | -<#if sub.foreignRelationType =='0'> | |
56 | - <#assign hasOne2Many = true> | |
57 | - const ${sub.entityName?uncap_first} = ref(); | |
58 | -</#if> | |
59 | -<#if sub.foreignRelationType =='1'> | |
60 | - <#assign hasOne2One = true> | |
61 | - const ${sub.entityName?uncap_first}Form = ref(); | |
62 | -</#if> | |
63 | -</#list> | |
64 | - const tableRefs = {<#list subTables as sub><#if sub.foreignRelationType =='0'>${sub.entityName?uncap_first}, <#assign hasOne2Many = true></#if></#list>}; | |
65 | - <#list subTables as sub> | |
66 | - <#if sub.foreignRelationType =='0'> | |
67 | - const ${sub.entityName?uncap_first}Table = reactive({ | |
68 | - loading: false, | |
69 | - dataSource: [], | |
70 | - columns:${sub.entityName?uncap_first}Columns | |
71 | - }) | |
72 | - </#if> | |
73 | - </#list> | |
74 | - //表单配置 | |
75 | - const [registerForm, {setProps,resetFields, setFieldsValue, validate}] = useForm({ | |
76 | - labelWidth: 150, | |
77 | - schemas: formSchema, | |
78 | - showActionButtonGroup: false, | |
79 | - }); | |
80 | - //表单赋值 | |
81 | - const [registerModal, {setModalProps, closeModal}] = useModalInner(async (data) => { | |
82 | - //重置表单 | |
83 | - await reset(); | |
84 | - setModalProps({confirmLoading: false,showCancelBtn:data?.showFooter,showOkBtn:data?.showFooter}); | |
85 | - isUpdate.value = !!data?.isUpdate; | |
86 | - if (unref(isUpdate)) { | |
87 | - //表单赋值 | |
88 | - await setFieldsValue({ | |
89 | - ...data.record, | |
90 | - }); | |
91 | - <#list subTables as sub><#rt/> | |
92 | - <#if sub.foreignRelationType =='1'> | |
93 | - ${sub.entityName?uncap_first}Form.value.initFormData(${sub.entityName?uncap_first}List,data?.record?.id) | |
94 | - </#if> | |
95 | - </#list> | |
96 | - <#list subTables as sub><#rt/> | |
97 | - <#if sub.foreignRelationType =='0'> | |
98 | - requestSubTableData(${sub.entityName?uncap_first}List, {id:data?.record?.id}, ${sub.entityName?uncap_first}Table) | |
99 | - </#if> | |
100 | - </#list> | |
101 | - } | |
102 | - // 隐藏底部时禁用整个表单 | |
103 | - setProps({ disabled: !data?.showFooter }) | |
104 | - }); | |
105 | - //方法配置 | |
106 | - const [handleChangeTabs,handleSubmit,requestSubTableData,formRef] = useJvxeMethod(requestAddOrEdit,classifyIntoFormData,tableRefs,activeKey,refKeys<#if hasOne2One==true>,validateSubForm</#if>); | |
107 | - | |
108 | - //设置标题 | |
109 | - const title = computed(() => (!unref(isUpdate) ? '新增' : '编辑')); | |
110 | - | |
111 | - async function reset(){ | |
112 | - await resetFields(); | |
113 | - activeKey.value = ref('${subTables[0].entityName?uncap_first}'); | |
114 | - <#list subTables as sub> | |
115 | - <#if sub.foreignRelationType =='0'> | |
116 | - ${sub.entityName?uncap_first}Table.dataSource = []; | |
117 | - </#if> | |
118 | - <#if sub.foreignRelationType =='1'> | |
119 | - ${sub.entityName?uncap_first}Form.value.resetFields(); | |
120 | - </#if> | |
121 | - </#list> | |
122 | - } | |
123 | - function classifyIntoFormData(allValues) { | |
124 | - let main = Object.assign({}, allValues.formValue) | |
125 | - return { | |
126 | - ...main, // 展开 | |
127 | - <#assign subManyIndex = 0> | |
128 | - <#list subTables as sub><#rt/> | |
129 | - <#if sub.foreignRelationType =='0'> | |
130 | - ${sub.entityName?uncap_first}List: allValues.tablesValue[${subManyIndex}].tableData, | |
131 | - <#assign subManyIndex = subManyIndex+1> | |
132 | - <#else> | |
133 | - ${sub.entityName?uncap_first}List: ${sub.entityName?uncap_first}Form.value.getFormData(), | |
134 | - </#if> | |
135 | - </#list> | |
136 | - } | |
137 | - } | |
138 | - <#if hasOne2One==true> | |
139 | - //校验所有一对一子表表单 | |
140 | - function validateSubForm(allValues){ | |
141 | - return new Promise((resolve,reject)=>{ | |
142 | - Promise.all([ | |
143 | - <#list subTables as sub><#rt/> | |
144 | - <#if sub.foreignRelationType =='1'> | |
145 | - ${sub.entityName?uncap_first}Form.value.validateForm(${sub_index}), | |
146 | - </#if> | |
147 | - </#list> | |
148 | - ]).then(() => { | |
149 | - resolve(allValues) | |
150 | - }).catch(e => { | |
151 | - if (e.error === VALIDATE_FAILED) { | |
152 | - // 如果有未通过表单验证的子表,就自动跳转到它所在的tab | |
153 | - activeKey.value = e.index == null ? unref(activeKey) : refKeys.value[e.index] | |
154 | - } else { | |
155 | - console.error(e) | |
156 | - } | |
157 | - }) | |
158 | - }) | |
159 | - } | |
160 | - </#if> | |
161 | - //表单提交事件 | |
162 | - async function requestAddOrEdit(values) { | |
163 | - try { | |
164 | - setModalProps({confirmLoading: true}); | |
165 | - //提交表单 | |
166 | - await saveOrUpdate(values, isUpdate.value); | |
167 | - //关闭弹窗 | |
168 | - closeModal(); | |
169 | - //刷新列表 | |
170 | - emit('success'); | |
171 | - } finally { | |
172 | - setModalProps({confirmLoading: false}); | |
173 | - } | |
174 | - } | |
175 | -</script> | |
176 | - | |
177 | -<style lang="less" scoped> | |
178 | - | |
179 | -</style> | |
180 | 0 | \ No newline at end of file |
jeecg-boot/jeecg-boot-module-system/src/main/resources/jeecg/code-template-online/jvxe/onetomany/java/${bussiPackage}/${entityPackage}/vue3/components/[1-n]Form.vuei deleted
1 | -<#list subTables as sub> | |
2 | -<#if sub.foreignRelationType=='1'> | |
3 | -#segment#${sub.entityName}Form.vue | |
4 | -<template> | |
5 | - <BasicForm @register="registerForm"/> | |
6 | -</template> | |
7 | -<script lang="ts"> | |
8 | - import {defineComponent} from 'vue'; | |
9 | - import {BasicForm, useForm} from '/@/components/Form/index'; | |
10 | - import {${sub.entityName?uncap_first}FormSchema} from '../${entityName?uncap_first}.data'; | |
11 | - import {defHttp} from '/@/utils/http/axios'; | |
12 | - import { VALIDATE_FAILED } from '/@/utils/common/vxeUtils' | |
13 | - | |
14 | - export default defineComponent({ | |
15 | - name:"${sub.entityName}Form", | |
16 | - components: {BasicForm}, | |
17 | - emits:['register'], | |
18 | - setup(_,{emit}) { | |
19 | - const [registerForm, {resetFields, setFieldsValue,getFieldsValue,validate}] = useForm({ | |
20 | - labelWidth: 150, | |
21 | - schemas: ${sub.entityName?uncap_first}FormSchema, | |
22 | - showActionButtonGroup: false, | |
23 | - }); | |
24 | - /** | |
25 | - *初始化加载数据 | |
26 | - */ | |
27 | - function initFormData(url,id){ | |
28 | - if(id){ | |
29 | - defHttp.get({url,params:{id}},{isTransformResponse:false}).then(res=>{ | |
30 | - res.success && setFieldsValue({...res.result[0]}); | |
31 | - }) | |
32 | - } | |
33 | - } | |
34 | - /** | |
35 | - *获取表单数据 | |
36 | - */ | |
37 | - function getFormData(){ | |
38 | - return [getFieldsValue()]; | |
39 | - } | |
40 | - /** | |
41 | - *表单校验 | |
42 | - */ | |
43 | - function validateForm(index){ | |
44 | - return new Promise((resolve, reject) => { | |
45 | - // 验证子表表单 | |
46 | - validate().then(()=>{ | |
47 | - return resolve() | |
48 | - }).catch(()=> { | |
49 | - return reject({ error: VALIDATE_FAILED ,index}) | |
50 | - }) | |
51 | - }) | |
52 | - } | |
53 | - return { | |
54 | - registerForm, | |
55 | - resetFields, | |
56 | - initFormData, | |
57 | - getFormData, | |
58 | - validateForm | |
59 | - } | |
60 | - } | |
61 | - }) | |
62 | -</script> | |
63 | -</#if> | |
64 | -</#list> |