wangchen147 c0d930bae5 0.0.8
2023-12-09 11:11:53 +08:00

154 lines
4.4 KiB
Plaintext

<template>
<div class="main-container">
<el-card class="box-card !border-none" shadow="never">
<div class="flex justify-between items-center">
<span class="text-[20px]">{{pageName}}</span>
<el-button type="primary" @click="addEvent">
{{ t('add{UCASE_NAME}') }}
</el-button>
</div>
<el-card class="box-card !border-none my-[10px] 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="resetForm(searchFormRef)">{{ t('reset') }}</el-button>
</el-form-item>
</el-form>
</el-card>
<div class="mt-[10px]">
<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="primary" 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 { useDictionary } from '@/app/api/dict'
import { get{UCASE_NAME}List, delete{UCASE_NAME} } from '@{API_PATH}'
import { img } from '@/utils/common'
import { ElMessageBox } from 'element-plus'
{EDIT_PATH}
import { useRoute } from 'vue-router'
const route = useRoute()
const pageName = route.meta.title;
let {LCASE_CLASS_NAME}Table = reactive({
page: 1,
limit: 10,
total: 0,
loading: true,
data: [],
searchParam:{
{SEARCH_PARAM}
}
})
const searchFormRef = ref<FormInstance>()
// 选中数据
const selectData = ref<any[]>([])
// 字典数据
{DICT_LIST}
/**
* 获取{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(() => {
})
})
}
const resetForm = (formEl: FormInstance | undefined) => {
if (!formEl) return
formEl.resetFields()
load{UCASE_NAME}List()
}
</script>
<style lang="scss" scoped>
/* 多行超出隐藏 */
.multi-hidden {
word-break: break-all;
text-overflow: ellipsis;
overflow: hidden;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
}
</style>