179 lines
4.8 KiB
Plaintext
179 lines
4.8 KiB
Plaintext
<template>
|
|
<div class="app-container">
|
|
<div class="search-container">
|
|
<el-form ref="queryFormRef" :model="queryParams" :inline="true">
|
|
<el-form-item prop="keywords" label="关键字">
|
|
<el-input
|
|
v-model="queryParams.keywords"
|
|
placeholder="${className}名称"
|
|
clearable
|
|
@keyup.enter="handleQuery"
|
|
/>
|
|
</el-form-item>
|
|
|
|
<el-form-item>
|
|
<el-button type="primary" @click="handleQuery">
|
|
<i-ep-search />
|
|
搜索
|
|
</el-button>
|
|
<el-button @click="handleResetQuery">
|
|
<i-ep-refresh />
|
|
重置
|
|
</el-button>
|
|
</el-form-item>
|
|
</el-form>
|
|
</div>
|
|
|
|
<el-card shadow="never" class="table-container">
|
|
<template #header>
|
|
<el-button type="success" @click="handleOpenDialog()">
|
|
<i-ep-plus />
|
|
新增
|
|
</el-button>
|
|
<el-button
|
|
type="danger"
|
|
:disabled="ids.length === 0"
|
|
@click="handleDelete()"
|
|
>
|
|
<i-ep-delete />
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
|
|
<el-table
|
|
ref="dataTableRef"
|
|
v-loading="loading"
|
|
:data="${className.toLowerCase()}List"
|
|
highlight-current-row
|
|
border
|
|
@selection-change="handleSelectionChange"
|
|
>
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
#foreach($field in $fields)
|
|
<el-table-column label="${field.comment}" prop="${field.name}" min-width="100" />
|
|
#end
|
|
|
|
<el-table-column fixed="right" label="操作" width="220">
|
|
<template #default="scope">
|
|
<el-button
|
|
type="primary"
|
|
size="small"
|
|
link
|
|
@click="handleOpenDialog(scope.row.id)"
|
|
>
|
|
<i-ep-edit />
|
|
编辑
|
|
</el-button>
|
|
<el-button
|
|
type="danger"
|
|
size="small"
|
|
link
|
|
@click="handleDelete(scope.row.id)"
|
|
>
|
|
<i-ep-delete />
|
|
删除
|
|
</el-button>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table>
|
|
|
|
<pagination
|
|
v-if="total > 0"
|
|
v-model:total="total"
|
|
v-model:page="queryParams.pageNum"
|
|
v-model:limit="queryParams.pageSize"
|
|
@pagination="handleQuery"
|
|
/>
|
|
</el-card>
|
|
|
|
<!-- ${className}表单弹窗 -->
|
|
<el-dialog
|
|
v-model="dialog.visible"
|
|
:title="dialog.title"
|
|
width="500px"
|
|
@close="handleCloseDialog"
|
|
>
|
|
<el-form
|
|
ref="${className.toLowerCase()}FormRef"
|
|
:model="formData"
|
|
:rules="rules"
|
|
label-width="100px"
|
|
>
|
|
#foreach($field in $fields)
|
|
<el-form-item label="${field.comment}" prop="${field.name}">
|
|
<el-input v-model="formData.${field.name}" placeholder="请输入${field.comment}" />
|
|
</el-form-item>
|
|
#end
|
|
</el-form>
|
|
|
|
<template #footer>
|
|
<div class="dialog-footer">
|
|
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
|
<el-button @click="handleCloseDialog">取 消</el-button>
|
|
</div>
|
|
</template>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
|
defineOptions({
|
|
name: "${className}",
|
|
inheritAttrs: false,
|
|
});
|
|
|
|
import ${className}API, { ${className}PageVO, ${className}Form, ${className}PageQuery } from "@/api/${className.toLowerCase()}";
|
|
|
|
const queryFormRef = ref(ElForm);
|
|
const ${className.toLowerCase()}FormRef = ref(ElForm);
|
|
|
|
const loading = ref(false);
|
|
const ids = ref<number[]>([]);
|
|
const total = ref(0);
|
|
|
|
const queryParams = reactive<${className}PageQuery>({
|
|
pageNum: 1,
|
|
pageSize: 10,
|
|
});
|
|
|
|
// ${className}表格数据
|
|
const ${className.toLowerCase()}List = ref<${className}PageVO[]>();
|
|
|
|
// 弹窗
|
|
const dialog = reactive({
|
|
title: "",
|
|
visible: false,
|
|
});
|
|
// ${className}表单
|
|
const formData = reactive<${className}Form>({});
|
|
|
|
const rules = reactive({
|
|
#foreach($field in $fields)
|
|
${field.name}: [{ required: true, message: "请输入${field.comment}", trigger: "blur" }],
|
|
#end
|
|
});
|
|
|
|
/** 查询 */
|
|
function handleQuery() {
|
|
loading.value = true;
|
|
${className}API.getPage(queryParams)
|
|
.then((data) => {
|
|
${className.toLowerCase()}List.value = data.list;
|
|
total.value = data.total;
|
|
})
|
|
.finally(() => {
|
|
loading.value = false;
|
|
});
|
|
}
|
|
|
|
/** 重置查询 */
|
|
function handleResetQuery() {
|
|
queryFormRef.value.resetFields();
|
|
queryParams.pageNum = 1;
|
|
handleQuery();
|
|
}
|
|
|
|
/** 行复选框选中记录选中ID集合 */
|
|
function handleSelectionChange(selection: any) {
|
|
ids.value = selection.map((item: any
|