This commit is contained in:
仲么了
2024-02-19 13:44:32 +08:00
commit 361cbb713d
238 changed files with 202544 additions and 0 deletions

View File

@@ -0,0 +1,113 @@
<template>
<div class='default-main'>
<div class='custom-table-header'>
<div class="title">字典树列表</div>
<el-button :icon='Plus' type='primary' @click='addMenu'>新增字典类型</el-button>
</div>
<Table ref='tableRef' />
<PopupForm ref='popupFormRef'></PopupForm>
</div>
</template>
<script setup lang='ts'>
import { Plus } from '@element-plus/icons-vue'
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import { ElMessage } from 'element-plus'
import PopupForm from './popupForm.vue'
import { dicDelete } from '@/api/system-boot/dic'
defineOptions({
name: 'setting/dictionary/tree'
})
const popupFormRef = ref()
const tableStore = new TableStore({
showPage:false,
url: '/system-boot/dic/dicTree',
method: 'GET',
column: [
{ title: '字典名称', field: 'name', treeNode: true, align: 'left' },
// { title: '排序', field: 'sort',width:'80' },
{ title: '编码', field: 'code' },
{ title: '描述', field: 'remark' },
{
title: '状态',
field: 'status',
width: '80',
render: 'tag',
custom: {
0: 'success',
1: 'warning',
2: 'danger'
},
replaceValue: {
0: '正常',
1: '禁用',
2: '删除'
}
},
{
title: '操作',
width: '180',
render: 'buttons',
fixed: 'right',
buttons: [
{
title: '新增',
type: 'primary',
icon: 'el-icon-Plus',
render: 'basicButton',
click: row => {
popupFormRef.value.open('新增字典类型', {
name: '',
code: '',
remark: '',
sort: 100,
type: 0,
pid: row.id,
id: ''
})
}
},
{
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'basicButton',
click: row => {
popupFormRef.value.open('编辑字典类型', row)
}
},
{
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除该字典类型吗?'
},
click: row => {
dicDelete(row.id).then(() => {
ElMessage.success('删除成功')
tableStore.index()
})
}
}
]
}
]
})
provide('tableStore', tableStore)
tableStore.table.params.searchState = 0
onMounted(() => {
tableStore.index()
})
const addMenu = () => {
popupFormRef.value.open('新增字典类型')
}
</script>

View File

@@ -0,0 +1,83 @@
<template>
<el-dialog class="cn-operate-dialog" v-model="dialogVisible" :title="title">
<el-scrollbar>
<el-form :inline="false" :model="form" label-width="120px" :rules="rules">
<el-form-item label="字典名称:" prop="name">
<el-input v-model="form.name" placeholder="请输入字典名称"></el-input>
</el-form-item>
<el-form-item label="序号:" prop="sort" class="top">
<el-input v-model="form.sort" placeholder="请输入序号"></el-input>
</el-form-item>
<el-form-item label="编码:" prop="code" class="top">
<el-input v-model="form.code" placeholder="请输入字典编码"></el-input>
</el-form-item>
<el-form-item label="描述:" class="top">
<el-input v-model="form.remark" placeholder="请输入字典描述"></el-input>
</el-form-item>
</el-form>
</el-scrollbar>
<template #footer>
<span class="dialog-footer">
<el-button @click="dialogVisible = false">取消</el-button>
<el-button type="primary" @click="submit">确认</el-button>
</span>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { ref, inject } from 'vue'
import { reactive } from 'vue'
import TableStore from '@/utils/tableStore'
import { ElMessage } from 'element-plus'
import { useAdminInfo } from '@/stores/adminInfo'
import { dicAdd, dicUpdate } from '@/api/system-boot/dic'
const adminInfo = useAdminInfo()
const tableStore = inject('tableStore') as TableStore
// do not use same name with ref
const form = reactive({
name: '',
code: '',
remark: '',
sort: 100,
type: 0,
pid: 0,
id: ''
})
const rules = {
name: [{ required: true, message: '名称不能为空', trigger: 'blur' }],
sort: [{ required: true, message: '排序不能为空', trigger: 'blur' }],
code: [{ required: true, message: '编码不能为空', trigger: 'blur' }]
}
const dialogVisible = ref(false)
const title = ref('新增菜单')
const open = (text: string, data?: anyObj) => {
title.value = text
dialogVisible.value = true
if (data) {
for (let key in form) {
form[key] = data[key]
}
} else {
for (let key in form) {
form[key] = ''
}
form.sort = 100
form.pid = 0
form.type = 0
}
}
const submit = async () => {
if (form.id) {
await dicUpdate(form)
} else {
await dicAdd(form)
}
ElMessage.success('保存成功')
tableStore.index()
dialogVisible.value = false
}
defineExpose({ open })
</script>