Merge branch 'develop' of https://gitee.com/likeshop_gitee/likeadmin-java into develop
This commit is contained in:
commit
769f5f2f43
|
|
@ -1,5 +1,6 @@
|
||||||
package com.hxkj.generator.util;
|
package com.hxkj.generator.util;
|
||||||
|
|
||||||
|
import com.hxkj.common.utils.ArrayUtil;
|
||||||
import com.hxkj.common.utils.StringUtil;
|
import com.hxkj.common.utils.StringUtil;
|
||||||
import com.hxkj.generator.config.GenConfig;
|
import com.hxkj.generator.config.GenConfig;
|
||||||
import com.hxkj.generator.constant.GenConstants;
|
import com.hxkj.generator.constant.GenConstants;
|
||||||
|
|
@ -41,9 +42,11 @@ public class VelocityUtil {
|
||||||
*/
|
*/
|
||||||
public static VelocityContext prepareContext(GenTable table, List<GenTableColumn> columns) {
|
public static VelocityContext prepareContext(GenTable table, List<GenTableColumn> columns) {
|
||||||
boolean isSearch = false; // 是否需要搜索
|
boolean isSearch = false; // 是否需要搜索
|
||||||
List<String> allFields = new LinkedList<>(); // 所有字段
|
String primaryKey = "id"; // 主键字段名称
|
||||||
List<String> listFields = new LinkedList<>(); // 列表字段
|
List<String> allFields = new LinkedList<>(); // 所有字段
|
||||||
|
List<String> listFields = new LinkedList<>(); // 列表字段
|
||||||
List<String> detailFields = new LinkedList<>(); // 详情字段
|
List<String> detailFields = new LinkedList<>(); // 详情字段
|
||||||
|
List<String> dictFields = new LinkedList<>(); // 字段字段
|
||||||
for (GenTableColumn column : columns) {
|
for (GenTableColumn column : columns) {
|
||||||
allFields.add(column.getColumnName());
|
allFields.add(column.getColumnName());
|
||||||
if (column.getIsList() == 1) {
|
if (column.getIsList() == 1) {
|
||||||
|
|
@ -55,6 +58,12 @@ public class VelocityUtil {
|
||||||
if (column.getIsQuery() == 1) {
|
if (column.getIsQuery() == 1) {
|
||||||
isSearch = true;
|
isSearch = true;
|
||||||
}
|
}
|
||||||
|
if (column.getIsPk() == 1) {
|
||||||
|
primaryKey = column.getJavaField();
|
||||||
|
}
|
||||||
|
if (StringUtil.isNotEmpty(column.getDictType())) {
|
||||||
|
dictFields.add(column.getDictType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置模板变量
|
// 设置模板变量
|
||||||
|
|
@ -70,9 +79,11 @@ public class VelocityUtil {
|
||||||
velocityContext.put("table", table);
|
velocityContext.put("table", table);
|
||||||
velocityContext.put("columns", columns);
|
velocityContext.put("columns", columns);
|
||||||
velocityContext.put("dateFields", SqlConstants.COLUMN_TIME_NAME);
|
velocityContext.put("dateFields", SqlConstants.COLUMN_TIME_NAME);
|
||||||
|
velocityContext.put("primaryKey", primaryKey);
|
||||||
velocityContext.put("allFields", allFields);
|
velocityContext.put("allFields", allFields);
|
||||||
velocityContext.put("listFields", listFields);
|
velocityContext.put("listFields", listFields);
|
||||||
velocityContext.put("detailFields", detailFields);
|
velocityContext.put("detailFields", detailFields);
|
||||||
|
velocityContext.put("dictFields", ArrayUtil.listToStringByStr(dictFields,","));
|
||||||
velocityContext.put("isSearch", isSearch);
|
velocityContext.put("isSearch", isSearch);
|
||||||
return velocityContext;
|
return velocityContext;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,41 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="index-lists">
|
||||||
<el-card class="!border-none mb-4" shadow="never">
|
<el-card class="!border-none" shadow="never">
|
||||||
<el-form
|
<el-form ref="formRef" class="mb-[-16px]" :model="queryParams" :inline="true">
|
||||||
class="mb-[-16px]"
|
|
||||||
:model="queryParams"
|
|
||||||
inline
|
|
||||||
>
|
|
||||||
#foreach ($column in $columns)
|
#foreach ($column in $columns)
|
||||||
#if($column.isQuery==1)
|
#if($column.isQuery==1)
|
||||||
<el-form-item label="${column.columnComment}" prop="type">
|
#if($column.htmlType=="datetime")
|
||||||
<el-input class="w-56" v-model="queryParams.${column.javaField}" clearable placeholder="请输入${column.columnComment}" />
|
<el-form-item label="${column.columnComment}" prop="${column.javaField}">
|
||||||
|
<data-picker
|
||||||
|
v-model:startTime="queryParams.startTime"
|
||||||
|
v-model:endTime="queryParams.endTime"
|
||||||
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType=="select")
|
||||||
|
<el-form-item label="${column.columnComment}" prop="${column.javaField}">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.${column.javaField}"
|
||||||
|
class="w-56"
|
||||||
|
clearable
|
||||||
|
>
|
||||||
|
#if($column.dictType=="")
|
||||||
|
<el-option label="请选择字典生成" value="" />
|
||||||
|
#else
|
||||||
|
<el-option label="全部" value="" />
|
||||||
|
<el-option
|
||||||
|
v-for="(item, index) in dictData.${column.dictType}"
|
||||||
|
:key="index"
|
||||||
|
:label="item.name"
|
||||||
|
:value="item.value"
|
||||||
|
/>
|
||||||
|
#end
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
#elseif($column.htmlType=="input")
|
||||||
|
<el-form-item label="${column.columnComment}" prop="${column.javaField}">
|
||||||
|
<el-input class="w-56" v-model="queryParams.${column.javaField}" />
|
||||||
|
</el-form-item>
|
||||||
|
#end
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
|
|
@ -19,112 +44,102 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<el-card class="!border-none mt-4" shadow="never">
|
||||||
<el-card class="!border-none" v-loading="pager.loading" shadow="never">
|
<div>
|
||||||
<el-button v-perms="['config/add']" type="primary" @click="handleAdd">
|
<el-button v-perms="['dept.jobs/add']" type="primary" @click="handleAdd()">
|
||||||
<template #icon>
|
<template #icon>
|
||||||
<icon name="el-icon-Plus" />
|
<icon name="el-icon-Plus" />
|
||||||
</template>
|
</template>
|
||||||
新增
|
新增
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-button
|
|
||||||
v-perms="['config/delete']"
|
|
||||||
:disabled="!selectData.length"
|
|
||||||
@click="handleDelete(selectData)"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
<div class="mt-4">
|
|
||||||
<el-table :data="pager.lists" @selection-change="handleSelectionChange">
|
|
||||||
<el-table-column type="selection" width="55" />
|
|
||||||
#foreach ($column in $columns)
|
|
||||||
#if($column.isList==1)
|
|
||||||
<el-table-column label="${column.columnComment}" prop="${column.javaField}" />
|
|
||||||
#end
|
|
||||||
#end
|
|
||||||
<el-table-column label="操作" width="120" fixed="right">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button
|
|
||||||
v-perms="['config/edit']"
|
|
||||||
type="primary"
|
|
||||||
link
|
|
||||||
@click="handleEdit(row)"
|
|
||||||
>
|
|
||||||
编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
v-perms="['config/delete']"
|
|
||||||
type="danger"
|
|
||||||
link
|
|
||||||
@click="handleDelete(row.id)"
|
|
||||||
>
|
|
||||||
删除
|
|
||||||
</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="flex mt-4 justify-end">
|
<el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists">
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.isList)
|
||||||
|
#if($column.htmlType=="select")
|
||||||
|
<el-table-column label="${column.columnComment}" prop="isStop" min-width="100">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<dict-value :options="dictData.${column.dictType}" :value="row.${column.javaField}" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
#elseif ($column.htmlType=="datetime")
|
||||||
|
<el-table-column label="${column.columnComment}" prop="${column.javaField}" min-width="180" />
|
||||||
|
#else
|
||||||
|
<el-table-column label="${column.columnComment}" prop="${column.javaField}" min-width="100" />
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
<el-table-column label="操作" width="120" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button
|
||||||
|
v-perms="['${moduleName}:edit']"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
@click="handleEdit(row)"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-perms="['${moduleName}:del']"
|
||||||
|
type="danger"
|
||||||
|
link
|
||||||
|
@click="handleDelete(row.id)"
|
||||||
|
>
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="flex justify-end mt-4">
|
||||||
<pagination v-model="pager" @change="getLists" />
|
<pagination v-model="pager" @change="getLists" />
|
||||||
</div>
|
</div>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
<edit-popup
|
||||||
<edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
|
v-if="showEdit"
|
||||||
|
ref="editRef"
|
||||||
|
:dict-data="dictData"
|
||||||
|
@success="getLists"
|
||||||
|
@close="showEdit = false"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
|
import { ${moduleName}Delete, ${moduleName}Lists } from '@/api/${moduleName}'
|
||||||
|
import { useDictData } from '@/hooks/useDictOptions'
|
||||||
import { usePaging } from '@/hooks/usePaging'
|
import { usePaging } from '@/hooks/usePaging'
|
||||||
import { dictDataLists } from '@/api/setting/dict'
|
|
||||||
import { apiConfigLists, apiConfigDelete } from '@/api/config'
|
|
||||||
import { timeFormat } from '@/utils/util'
|
|
||||||
import feedback from '@/utils/feedback'
|
import feedback from '@/utils/feedback'
|
||||||
import EditPopup from './edit.vue'
|
import EditPopup from './edit.vue'
|
||||||
|
|
||||||
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
|
||||||
// 是否显示编辑框
|
|
||||||
const showEdit = ref(false)
|
const showEdit = ref(false)
|
||||||
|
|
||||||
|
|
||||||
// 查询条件
|
|
||||||
const queryParams = reactive({
|
const queryParams = reactive({
|
||||||
type: '',
|
#foreach ($column in $columns)
|
||||||
name: '',
|
#if($column.isQuery)
|
||||||
value: ''
|
${column.javaField}: '',
|
||||||
|
#end
|
||||||
|
#end
|
||||||
})
|
})
|
||||||
|
|
||||||
// 选中数据
|
const { pager, getLists, resetPage, resetParams } = usePaging({
|
||||||
const selectData = ref<any[]>([])
|
fetchFun: ${moduleName}Lists,
|
||||||
|
|
||||||
// 表格选择后回调事件
|
|
||||||
const handleSelectionChange = (val: any[]) => {
|
|
||||||
selectData.value = val.map(({ id }) => id)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 字典数据
|
|
||||||
const dictData = reactive<Record<string, any[]>>({
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
// 获取字典数据
|
|
||||||
const getDictData = () => {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 分页相关
|
|
||||||
const { pager, getLists, resetParams, resetPage } = usePaging({
|
|
||||||
fetchFun: apiConfigLists,
|
|
||||||
params: queryParams
|
params: queryParams
|
||||||
})
|
})
|
||||||
|
#if($dictFields!="")
|
||||||
|
|
||||||
|
const { dictData } = useDictData<{
|
||||||
|
#foreach ($column in $columns)
|
||||||
|
#if($column.dictType!="")
|
||||||
|
${column.dictType}: any[]
|
||||||
|
#end
|
||||||
|
#end
|
||||||
|
}>([${dictFields}])
|
||||||
|
#end
|
||||||
|
|
||||||
// 添加
|
|
||||||
const handleAdd = async () => {
|
const handleAdd = async () => {
|
||||||
showEdit.value = true
|
showEdit.value = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
editRef.value?.open('add')
|
editRef.value?.open('add')
|
||||||
}
|
}
|
||||||
|
|
||||||
// 编辑
|
|
||||||
const handleEdit = async (data: any) => {
|
const handleEdit = async (data: any) => {
|
||||||
showEdit.value = true
|
showEdit.value = true
|
||||||
await nextTick()
|
await nextTick()
|
||||||
|
|
@ -132,14 +147,11 @@
|
||||||
editRef.value?.setFormData(data)
|
editRef.value?.setFormData(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 删除
|
const handleDelete = async (${primaryKey}: number) => {
|
||||||
const handleDelete = async (id: number | any[]) => {
|
await ${moduleName}Delete({ ${primaryKey} })
|
||||||
await feedback.confirm('确定要删除?')
|
feedback.msgSuccess('删除成功')
|
||||||
await apiConfigDelete({ id })
|
|
||||||
getLists()
|
getLists()
|
||||||
}
|
}
|
||||||
|
|
||||||
getLists()
|
getLists()
|
||||||
getDictData()
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue