admin-vue3/src/views/system/codingrules/index.vue

130 lines
3.4 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<!-- 搜索工作栏 -->
<ContentWrap>
<Search :schema="allSchemas.searchSchema" @search="setSearchParams" @reset="setSearchParams">
<!-- -->
<template #actionMore>
<el-button
type="primary"
plain
@click="openForm('create')"
v-hasPermi="['system:coding-rules:create']"
>
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</template>
</Search>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<Table
:columns="allSchemas.tableColumns"
:data="tableObject.tableList"
:loading="tableObject.loading"
:pagination="{
total: tableObject.total
}"
v-model:pageSize="tableObject.pageSize"
v-model:currentPage="tableObject.currentPage"
>
<template #action="{ row }">
<el-button
link
type="primary"
@click="handlePreview(row.code)"
v-hasPermi="['system:coding-rules:update']"
>
预览
</el-button>
<el-button
link
type="primary"
@click="handleSetting(row.id, row.code)"
v-hasPermi="['system:coding-rules:update']"
>
规则设置
</el-button>
<el-button
link
type="primary"
@click="openForm('update', row.id)"
v-hasPermi="['system:coding-rules:update']"
>
编辑
</el-button>
<el-button
link
type="danger"
v-hasPermi="['system:coding-rules:delete']"
@click="handleDelete(row.id)"
>
删除
</el-button>
</template>
</Table>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<CodingRulesForm ref="formRef" @success="getList" />
</template>
<script setup lang="ts" name="CodingRules">
import { allSchemas } from './codingRules.data'
import * as CodingRulesApi from '@/api/system/codingrules'
import CodingRulesForm from './CodingRulesForm.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { Action } from 'element-plus'
const router = useRouter()
// tableObject
// tableMethods
// https://doc.iocoder.cn/vue3/crud-schema/
const { tableObject, tableMethods } = useTable({
getListApi: CodingRulesApi.getCodingRulesPage, //
delListApi: CodingRulesApi.deleteCodingRules //
})
//
const { getList, setSearchParams } = tableMethods
/** / */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = (id: number) => {
tableMethods.delList(id, false)
}
// 预览编码规则
const handlePreview = async (code: string) => {
const params = {
code,
preview: true
}
const previewData = await CodingRulesApi.previewCodingRulesApi(params)
ElMessageBox.alert(
`<strong>${previewData}</strong>`,
'编码规则预览',
{
dangerouslyUseHTMLString: true,
}
)
}
// 设置编码规则
const handleSetting = (id?: number, code?: string) => {
router.push({
name: 'CodingRulesDetails',
query: { id, code }
})
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>