| | |
| | | <div class="p-2"> |
| | | <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave"> |
| | | <div class="search" v-show="showSearch"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px"> |
| | | <el-form :model="queryParams" ref="queryFormRef" :inline="true" label-width="68px" class="-mb-15px"> |
| | | #foreach($column in $columns) |
| | | #if($column.query) |
| | | #set($dictType=$column.dictType) |
| | |
| | | <template #header> |
| | | <el-row :gutter="10" class="mb8"> |
| | | <el-col :span="1.5"> |
| | | <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button> |
| | | <el-button type="primary" plain icon="Plus" @click="openForm('create')" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button> |
| | | </el-col> |
| | | <el-col :span="1.5"> |
| | | <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button> |
| | |
| | | </template> |
| | | |
| | | <script setup name="${BusinessName}" lang="ts"> |
| | | import { list${BusinessName}, get${BusinessName}, del${BusinessName}, add${BusinessName}, update${BusinessName} } from '@/api/${moduleName}/${businessName}'; |
| | | import { ${BusinessName}VO, ${BusinessName}Query, ${BusinessName}Form } from '@/api/${moduleName}/${businessName}/types'; |
| | | /** 模块导入 */ |
| | | import { list${BusinessName}, del${BusinessName}} from '@/api/${moduleName}/${businessName}'; |
| | | import { ${BusinessName}VO, ${BusinessName}Query} from '@/api/${moduleName}/${businessName}/types'; |
| | | |
| | | defineOptions({ name: '${BusinessName}' }) |
| | | |
| | | const { proxy } = getCurrentInstance() as ComponentInternalInstance; |
| | | #if(${dicts} != '') |
| | | /** 当前页面引用的数据字典 */ |
| | | #set($dictsNoSymbol=$dicts.replace("'", "")) |
| | | const { ${dictsNoSymbol} } = toRefs<any>(proxy?.useDict(${dicts})); |
| | | #end |
| | | |
| | | const ${businessName}List = ref<${BusinessName}VO[]>([]); |
| | | const buttonLoading = ref(false); |
| | | // 是否加载遮罩层 |
| | | const loading = ref(true); |
| | | // 是否显示查询项 |
| | | const showSearch = ref(true); |
| | | const ids = ref<Array<string | number>>([]); |
| | | const ${businessName}List = ref<${BusinessName}VO[]>([]); |
| | | // 列表选中的记录Id |
| | | const ids = ref<Array<number | string>>([]); |
| | | // 单选 |
| | | const single = ref(true); |
| | | // 多选 |
| | | const multiple = ref(true); |
| | | // 总记录数 |
| | | const total = ref(0); |
| | | |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | // 日期范围 |
| | | #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)}) |
| | | const dateRange${AttrName} = ref<[DateModelType, DateModelType]>(['', '']); |
| | | #end |
| | | #end |
| | | |
| | | const queryFormRef = ref<ElFormInstance>(); |
| | | const ${businessName}FormRef = ref<ElFormInstance>(); |
| | | |
| | | const dialog = reactive<DialogOption>({ |
| | | visible: false, |
| | | title: '' |
| | | }); |
| | | |
| | | const initFormData: ${BusinessName}Form = { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.htmlType == "checkbox") |
| | | $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | #else |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({ |
| | | form: {...initFormData}, |
| | | queryParams: { |
| | | // 查询参数 |
| | | const queryParams = reactive({ |
| | | pageNum: 1, |
| | | pageSize: 10, |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") |
| | | $column.javaField: undefined, |
| | | #end |
| | | #end |
| | | #end |
| | | params: { |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }, |
| | | rules: { |
| | | #foreach ($column in $columns) |
| | | #if($column.insert || $column.edit) |
| | | #if($column.required) |
| | | #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | #if($parentheseIndex != -1) |
| | | #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | #else |
| | | #set($comment=$column.columnComment) |
| | | #end |
| | | $column.javaField: [ |
| | | { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| | | ]#if($foreach.count != $columns.size()),#end |
| | | #end |
| | | #end |
| | | #end |
| | | } |
| | | }); |
| | | #foreach ($column in $columns) |
| | | #if($column.query) |
| | | #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") |
| | | $column.javaField: '', |
| | | #end |
| | | #end |
| | | #end |
| | | }) |
| | | ## const ${businessName}FormRef = ref<ElFormInstance>(); |
| | | ## |
| | | ## const dialog = reactive<DialogOption>({ |
| | | ## visible: false, |
| | | ## title: '' |
| | | ## }); |
| | | |
| | | const { queryParams, form, rules } = toRefs(data); |
| | | ## const initFormData: ${BusinessName}Form = { |
| | | ## #foreach ($column in $columns) |
| | | ## #if($column.insert || $column.edit) |
| | | ## #if($column.htmlType == "checkbox") |
| | | ## $column.javaField: []#if($foreach.count != $columns.size()),#end |
| | | ## #else |
| | | ## $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | ## #end |
| | | ## #end |
| | | ## #end |
| | | ## } |
| | | ## const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({ |
| | | ## form: {...initFormData}, |
| | | ## queryParams: { |
| | | ## pageNum: 1, |
| | | ## pageSize: 10, |
| | | ## #foreach ($column in $columns) |
| | | ## #if($column.query) |
| | | ## #if($column.htmlType != "datetime" || $column.queryType != "BETWEEN") |
| | | ## $column.javaField: undefined, |
| | | ## #end |
| | | ## #end |
| | | ## #end |
| | | ## params: { |
| | | ## #foreach ($column in $columns) |
| | | ## #if($column.query) |
| | | ## #if($column.htmlType == "datetime" && $column.queryType == "BETWEEN") |
| | | ## $column.javaField: undefined#if($foreach.count != $columns.size()),#end |
| | | ## #end |
| | | ## #end |
| | | ## #end |
| | | ## } |
| | | ## }, |
| | | ## rules: { |
| | | ## #foreach ($column in $columns) |
| | | ## #if($column.insert || $column.edit) |
| | | ## #if($column.required) |
| | | ## #set($parentheseIndex=$column.columnComment.indexOf("(")) |
| | | ## #if($parentheseIndex != -1) |
| | | ## #set($comment=$column.columnComment.substring(0, $parentheseIndex)) |
| | | ## #else |
| | | ## #set($comment=$column.columnComment) |
| | | ## #end |
| | | ## $column.javaField: [ |
| | | ## { required: true, message: "$comment不能为空", trigger: #if($column.htmlType == "select" || $column.htmlType == "radio")"change"#else"blur"#end } |
| | | ## ]#if($foreach.count != $columns.size()),#end |
| | | ## #end |
| | | ## #end |
| | | ## #end |
| | | ## } |
| | | ## }); |
| | | ## |
| | | ## const { queryParams, form, rules } = toRefs(data); |
| | | |
| | | /** 查询${functionName}列表 */ |
| | | const getList = async () => { |
| | |
| | | proxy?.addDateRange(queryParams.value, dateRange${AttrName}.value, '${AttrName}'); |
| | | #end |
| | | #end |
| | | const res = await list${BusinessName}(queryParams.value); |
| | | const res = await list${BusinessName}(queryParams); |
| | | ${businessName}List.value = res.rows; |
| | | total.value = res.total; |
| | | loading.value = false; |
| | | } |
| | | |
| | | /** 取消按钮 */ |
| | | const cancel = () => { |
| | | reset(); |
| | | dialog.visible = false; |
| | | } |
| | | |
| | | /** 表单重置 */ |
| | | const reset = () => { |
| | | form.value = {...initFormData}; |
| | | ${businessName}FormRef.value?.resetFields(); |
| | | } |
| | | |
| | | /** 搜索按钮操作 */ |
| | |
| | | multiple.value = !selection.length; |
| | | } |
| | | |
| | | /** 新增按钮操作 */ |
| | | const handleAdd = () => { |
| | | reset(); |
| | | dialog.visible = true; |
| | | dialog.title = "添加${functionName}"; |
| | | } |
| | | |
| | | /** 修改按钮操作 */ |
| | | const handleUpdate = async (row?: ${BusinessName}VO) => { |
| | | reset(); |
| | | const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0] |
| | | const res = await get${BusinessName}(_${pkColumn.javaField}); |
| | | Object.assign(form.value, res.data); |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.split(","); |
| | | #end |
| | | #end |
| | | dialog.visible = true; |
| | | dialog.title = "修改${functionName}"; |
| | | } |
| | | |
| | | /** 提交按钮 */ |
| | | const submitForm = () => { |
| | | ${businessName}FormRef.value?.validate(async (valid: boolean) => { |
| | | if (valid) { |
| | | buttonLoading.value = true; |
| | | #foreach ($column in $columns) |
| | | #if($column.htmlType == "checkbox") |
| | | form.value.$column.javaField = form.value.${column.javaField}.join(","); |
| | | #end |
| | | #end |
| | | if (form.value.${pkColumn.javaField}) { |
| | | await update${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } else { |
| | | await add${BusinessName}(form.value).finally(() => buttonLoading.value = false); |
| | | } |
| | | proxy?.#[[$modal]]#.msgSuccess("修改成功"); |
| | | dialog.visible = false; |
| | | await getList(); |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** 删除按钮操作 */ |
| | | const handleDelete = async (row?: ${BusinessName}VO) => { |
| | | const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value; |
| | |
| | | /** 导出按钮操作 */ |
| | | const handleExport = () => { |
| | | proxy?.download('${moduleName}/${businessName}/export', { |
| | | ...queryParams.value |
| | | ...queryParams |
| | | }, `${businessName}_#[[${new Date().getTime()}]]#.xlsx`) |
| | | } |
| | | |
| | | /** 弹出框(增加、修改) */ |
| | | const detailFormRef = ref(); |
| | | const openForm = (type: string, id?: number) => { |
| | | detailFormRef?.value.open(type, id) |
| | | } |
| | | onMounted(() => { |
| | | getList(); |
| | | }); |