全栈小学生 0e47055ccb v1.0.0-beta.1
2023-04-15 17:12:49 +08:00

127 lines
3.8 KiB
Plaintext

<template>
<div class="main-container">
<el-card class="box-card !border-none" shadow="never">
<div class="flex">
<el-button type="primary" @click="addEvent">
{{ t('add{UCASE_CLASS_NAME}') }}
</el-button>
</div>
<el-card class="box-card !border-none my-[16px] table-search-wrap" shadow="never">
<el-form :inline="true" :model="{LCASE_CLASS_NAME}Table.searchParam" ref="searchFormRef">
{SEARCH_VIEW}
<el-form-item>
<el-button type="primary" @click="load{UCASE_NAME}List()">{{ t('search') }}</el-button>
<el-button @click="searchFormRef?.resetFields()">{{ t('reset') }}</el-button>
</el-form-item>
</el-form>
</el-card>
<div class="mt-[16px]">
<el-table :data="{LCASE_CLASS_NAME}Table.data" size="large" v-loading="{LCASE_CLASS_NAME}Table.loading">
<template #empty>
<span>{{ !{LCASE_CLASS_NAME}Table.loading ? t('emptyData') : '' }}</span>
</template>
{LISTS_VIEW}
<el-table-column :label="t('operation')" fixed="right" min-width="120">
<template #default="{ row }">
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button>
<el-button type="danger" link @click="deleteEvent(row.{PK})">{{ t('delete') }}</el-button>
</template>
</el-table-column>
</el-table>
<div class="mt-[16px] flex justify-end">
<el-pagination v-model:current-page="{LCASE_CLASS_NAME}Table.page" v-model:page-size="{LCASE_CLASS_NAME}Table.limit"
layout="total, sizes, prev, pager, next, jumper" :total="{LCASE_CLASS_NAME}Table.total"
@size-change="load{UCASE_NAME}List()" @current-change="load{UCASE_NAME}List" />
</div>
</div>
{EDIT_VIEW}
</el-card>
</div>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue'
import { t } from '@/lang'
import { get{UCASE_NAME}List, delete{UCASE_NAME} } from '@/api/{MODULE_NAME}'
import { img } from '@/utils/common'
import { ElMessageBox } from 'element-plus'
{EDIT_PATH}
let {LCASE_CLASS_NAME}Table = reactive({
page: 1,
limit: 10,
total: 0,
loading: true,
data: [],
searchParam:{
{SEARCH_PARAM}
}
})
const searchFormRef = ref<FormInstance>()
/**
* 获取{NOTES}列表
*/
const load{UCASE_NAME}List = (page: number = 1) => {
{LCASE_CLASS_NAME}Table.loading = true
{LCASE_CLASS_NAME}Table.page = page
get{UCASE_NAME}List({
page: {LCASE_CLASS_NAME}Table.page,
limit: {LCASE_CLASS_NAME}Table.limit,
...{LCASE_CLASS_NAME}Table.searchParam
}).then(res => {
{LCASE_CLASS_NAME}Table.loading = false
{LCASE_CLASS_NAME}Table.data = res.data.data
{LCASE_CLASS_NAME}Table.total = res.data.total
}).catch(() => {
{LCASE_CLASS_NAME}Table.loading = false
})
}
load{UCASE_NAME}List()
{EDIT_DIALOG}
/**
* 添加{NOTES}
*/
const addEvent = () => {
{ADD_EVENT}
}
/**
* 编辑{NOTES}
* @param data
*/
const editEvent = (data: any) => {
{EDIT_EVENT}
}
/**
* 删除{NOTES}
*/
const deleteEvent = (id: number) => {
ElMessageBox.confirm(t('{LCASE_CLASS_NAME}DeleteTips'), t('warning'),
{
confirmButtonText: t('confirm'),
cancelButtonText: t('cancel'),
type: 'warning',
}
).then(() => {
delete{UCASE_NAME}(id).then(() => {
load{UCASE_NAME}List()
}).catch(() => {
})
})
}
</script>
<style lang="scss" scoped></style>