微调
This commit is contained in:
23
frontend/src/api/system/dictionary/dictTree/index.ts
Normal file
23
frontend/src/api/system/dictionary/dictTree/index.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import http from '@/api'
|
||||||
|
import { type Dict } from '@/api/system/dictionary/interface'
|
||||||
|
|
||||||
|
//获取字典类型
|
||||||
|
export const getDictTreeList = (params: Dict.ReqDictTreeParams) => {
|
||||||
|
return http.get(`/dictTree/queryTree`, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加字典类型
|
||||||
|
export const addDictTree = (params: Dict.ResDictTree) => {
|
||||||
|
return http.post(`/dictTree/add`, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
//编辑字典类型
|
||||||
|
export const updateDictTree = (params: Dict.ResDictTree) => {
|
||||||
|
return http.post(`/dictTree/update`, params)
|
||||||
|
}
|
||||||
|
|
||||||
|
//删除字典类型
|
||||||
|
export const deleteDictTree = (params: string[]) => {
|
||||||
|
return http.post(`/dictTree/delete`, params)
|
||||||
|
}
|
||||||
|
|
||||||
@@ -139,4 +139,48 @@ export namespace Dict {
|
|||||||
export interface ResDictPqPage extends ResPage<ResDictPq> {
|
export interface ResDictPqPage extends ResPage<ResDictPq> {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 树形字典数据表格分页查询参数
|
||||||
|
*/
|
||||||
|
export interface ReqDictTreeParams extends ReqPage{
|
||||||
|
id: string;//指标字典表Id
|
||||||
|
pid: string;//
|
||||||
|
pids: string;//
|
||||||
|
name:string;//
|
||||||
|
code:string;//
|
||||||
|
sort:number;//
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 树形字典数据新增、修改、根据id查询返回的对象
|
||||||
|
*/
|
||||||
|
export interface ResDictTree {
|
||||||
|
id: string;//指标字典表Id
|
||||||
|
pid: string;//
|
||||||
|
pids: string;//
|
||||||
|
name:string;//
|
||||||
|
code:string;//
|
||||||
|
sort:number;//
|
||||||
|
remark?:string;//
|
||||||
|
status?:number;//'状态(字典 0正常 1停用 2删除)
|
||||||
|
createBy?:string | null;//
|
||||||
|
createTime?:string | null;//
|
||||||
|
updateBy?:string | null;//
|
||||||
|
updateTime?:string | null;//
|
||||||
|
level?:number | null;//
|
||||||
|
extend?:string | null;//对应type,不同类型可自定义配置
|
||||||
|
type?:number | null;//用于区分多种类型的字典树 0.台账对象类型 1.自定义报表指标类型
|
||||||
|
children?: ResDictTree[];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 电能质量指标字典数据表格查询分页返回的对象;
|
||||||
|
*/
|
||||||
|
export interface ResDictTreePage extends ResPage<ResDictTree> {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
margin-right: 10px; /* 日期选择器右侧间距 */
|
margin-right: 10px; /* 日期选择器右侧间距 */
|
||||||
width: 320px;
|
width: 250px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.date-picker {
|
.date-picker {
|
||||||
|
|||||||
@@ -24,28 +24,20 @@
|
|||||||
</template>
|
</template>
|
||||||
</ProTable>
|
</ProTable>
|
||||||
|
|
||||||
<!-- 新增/编辑资源对话框 -->
|
|
||||||
<ResourceDialog
|
|
||||||
:visible="dialogFormVisible"
|
|
||||||
:dialogTitle="dialogTitle"
|
|
||||||
:formData="dialogForm"
|
|
||||||
@update:visible="dialogFormVisible = $event"
|
|
||||||
@submit="submitForm"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
<script setup lang='tsx' name='useProTable'>
|
<script setup lang='tsx' name='useProTable'>
|
||||||
import { defineComponent,ref ,reactive} from 'vue'
|
import { defineComponent,ref ,reactive} from 'vue'
|
||||||
import { type Resource } from '@/api/resource/interface'
|
import { type Function } from '@/api/function/interface'
|
||||||
import ProTable from '@/components/ProTable/index.vue'
|
import ProTable from '@/components/ProTable/index.vue'
|
||||||
import ResourceDialog from "@/views/authority/resource/components/ResourceDialog.vue"; // 导入子组件
|
|
||||||
import {CirclePlus, Delete, EditPen,HomeFilled} from '@element-plus/icons-vue'
|
import {CirclePlus, Delete, EditPen,HomeFilled} from '@element-plus/icons-vue'
|
||||||
import resourceDataList from '@/api/resource/resourceData'
|
import resourceDataList from '@/api/function/functionExample'
|
||||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||||
import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||||
import { useDictStore } from '@/stores/modules/dict'
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
import { el } from 'element-plus/es/locale';
|
|
||||||
|
|
||||||
const dictStore = useDictStore()
|
const dictStore = useDictStore()
|
||||||
let multipleSelection = ref<string[]>([]);
|
let multipleSelection = ref<string[]>([]);
|
||||||
@@ -54,7 +46,7 @@ import { el } from 'element-plus/es/locale';
|
|||||||
const isEditMode = ref(false);
|
const isEditMode = ref(false);
|
||||||
const dialogTitle = ref('新增菜单')
|
const dialogTitle = ref('新增菜单')
|
||||||
|
|
||||||
const dialogForm = ref<Resource.ResResourceList>({
|
const dialogForm = ref<Function.ResFunction>({
|
||||||
id: '',
|
id: '',
|
||||||
pid:'',
|
pid:'',
|
||||||
pids:'',
|
pids:'',
|
||||||
@@ -72,7 +64,7 @@ import { el } from 'element-plus/es/locale';
|
|||||||
const proTable = ref<ProTableInstance>()
|
const proTable = ref<ProTableInstance>()
|
||||||
|
|
||||||
// 表格配置项
|
// 表格配置项
|
||||||
const columns = reactive<ColumnProps<Resource.ResResourceList>[]>([
|
const columns = reactive<ColumnProps<Function.ResFunction>[]>([
|
||||||
{ type: 'selection', fixed: 'left', width: 70 },
|
{ type: 'selection', fixed: 'left', width: 70 },
|
||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
@@ -162,40 +154,40 @@ const openEditDialog = (resource: Resource.ResResourceList) => {
|
|||||||
};
|
};
|
||||||
//批量删除
|
//批量删除
|
||||||
const handleDelList =()=>{
|
const handleDelList =()=>{
|
||||||
ElMessageBox.confirm(
|
// ElMessageBox.confirm(
|
||||||
`是否删除所选菜单信息?`, // 使用模板字符串来插值
|
// `是否删除所选菜单信息?`, // 使用模板字符串来插值
|
||||||
'温馨提示',
|
// '温馨提示',
|
||||||
{
|
// {
|
||||||
confirmButtonText: '确定',
|
// confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
// cancelButtonText: '取消',
|
||||||
type: 'warning',
|
// type: 'warning',
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
.then(() => {
|
// .then(() => {
|
||||||
resourceData.value = resourceData.value.filter(item => !multipleSelection.value.includes(item.id));
|
// resourceData.value = resourceData.value.filter(item => !multipleSelection.value.includes(item.id));
|
||||||
multipleSelection.value = []; // Clear selected rows
|
// multipleSelection.value = []; // Clear selected rows
|
||||||
ElMessage.success("批量删除成功");
|
// ElMessage.success("批量删除成功");
|
||||||
})
|
// })
|
||||||
|
|
||||||
}
|
}
|
||||||
// 删除资源
|
// 删除资源
|
||||||
const deleteResource = (params: Resource.ResResourceList) => {
|
const deleteResource = (params: Resource.ResResourceList) => {
|
||||||
ElMessageBox.confirm(
|
// ElMessageBox.confirm(
|
||||||
`是否删除【${params.name}】菜单?`, // 使用模板字符串来插值
|
// `是否删除【${params.name}】菜单?`, // 使用模板字符串来插值
|
||||||
'温馨提示',
|
// '温馨提示',
|
||||||
{
|
// {
|
||||||
confirmButtonText: '确定',
|
// confirmButtonText: '确定',
|
||||||
cancelButtonText: '取消',
|
// cancelButtonText: '取消',
|
||||||
type: 'warning',
|
// type: 'warning',
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
.then(() => {
|
// .then(() => {
|
||||||
resourceData.value = resourceData.value.filter(item => item.id !== params.id); // 过滤掉被删除的资源
|
// resourceData.value = resourceData.value.filter(item => item.id !== params.id); // 过滤掉被删除的资源
|
||||||
ElMessage({
|
// ElMessage({
|
||||||
type: 'success',
|
// type: 'success',
|
||||||
message: `删除${params.name}成功!`
|
// message: `删除${params.name}成功!`
|
||||||
})
|
// })
|
||||||
})
|
// })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
const {dialogVisible,data} = defineProps<{
|
const {dialogVisible,data} = defineProps<{
|
||||||
dialogVisible: boolean;
|
dialogVisible: boolean;
|
||||||
title: string;
|
title: string;
|
||||||
data: Role.ResRoleList;
|
data: Role.Permission;
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
// const leftvalue = ref<Role.Permission[]>([])
|
// const leftvalue = ref<Role.Permission[]>([])
|
||||||
|
|||||||
@@ -9,8 +9,8 @@
|
|||||||
<!-- 表格 header 按钮 -->
|
<!-- 表格 header 按钮 -->
|
||||||
<template #tableHeader='scope'>
|
<template #tableHeader='scope'>
|
||||||
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||||
<el-button type='primary' :icon='Upload' plain @click='downloadFile()'>批量导出</el-button>
|
<el-button type='primary' :icon='Upload' plain @click='downloadFile()'>导出</el-button>
|
||||||
<el-button type='primary' :icon='Download' plain @click='importFile()'>批量导入</el-button>
|
<el-button type='primary' :icon='Download' plain @click='importFile()'>导入</el-button>
|
||||||
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'
|
||||||
@click='batchDelete(scope.selectedListIds)'>
|
@click='batchDelete(scope.selectedListIds)'>
|
||||||
批量删除
|
批量删除
|
||||||
@@ -63,7 +63,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
{
|
{
|
||||||
prop: 'name',
|
prop: 'name',
|
||||||
label: '名称',
|
label: '名称',
|
||||||
search: { el: 'input' },
|
search: { el: 'input',order:2,offset:0.1},
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -90,7 +90,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prop: 'manufacturer',
|
prop: 'manufacturer',
|
||||||
label: '制作厂商',
|
label: '生产厂商',
|
||||||
enum: dictStore.getDictData('High_Cate'),
|
enum: dictStore.getDictData('High_Cate'),
|
||||||
search: { el: 'select', props: { filterable: true }},
|
search: { el: 'select', props: { filterable: true }},
|
||||||
fieldNames: { label: 'name', value: 'code' },
|
fieldNames: { label: 'name', value: 'code' },
|
||||||
@@ -101,7 +101,7 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
|
|||||||
label: '生产日期',
|
label: '生产日期',
|
||||||
minWidth: 200,
|
minWidth: 200,
|
||||||
search: {
|
search: {
|
||||||
span: 2,
|
order:1,
|
||||||
render: () => {
|
render: () => {
|
||||||
return (
|
return (
|
||||||
<div class='flx-flex-start'>
|
<div class='flx-flex-start'>
|
||||||
|
|||||||
@@ -88,8 +88,8 @@ const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{
|
{
|
||||||
(<el-tag type={scope.row.level === 1 ? 'info' : scope.row.level === 2 ? 'warning' : 'danger'}>
|
(<el-tag type={scope.row.level === 0 ? 'info' : scope.row.level === 1 ? 'warning' : 'danger'}>
|
||||||
{scope.row.level === 1 ? '普通' : scope.row.level === 2 ? '中等' : '严重'}
|
{scope.row.level === 0 ? '普通' : scope.row.level === 1 ? '中等' : '严重'}
|
||||||
</el-tag>)
|
</el-tag>)
|
||||||
}
|
}
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
<el-form-item label='数据模型' :label-width='140' prop='dataType'>
|
<el-form-item label='数据模型' :label-width='140' prop='dataType'>
|
||||||
<el-select v-model="formContent.dataType" clearable placeholder="请选择数据模型">
|
<el-select v-model="formContent.dataType" clearable placeholder="请选择数据模型">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('High_Cate')"
|
v-for="item in dictStore.getDictData('Cs_Data_Type')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.code"
|
:value="item.code"
|
||||||
@@ -25,7 +25,7 @@
|
|||||||
<el-form-item label='相别' :label-width='140' prop='phase'>
|
<el-form-item label='相别' :label-width='140' prop='phase'>
|
||||||
<el-select v-model="formContent.phase" clearable placeholder="请选择相别">
|
<el-select v-model="formContent.phase" clearable placeholder="请选择相别">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('High_Cate')"
|
v-for="item in dictStore.getDictData('phase')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.code"
|
:value="item.code"
|
||||||
@@ -65,7 +65,7 @@
|
|||||||
<el-form-item label='报表数据来源' :label-width='140' prop='resourcesId'>
|
<el-form-item label='报表数据来源' :label-width='140' prop='resourcesId'>
|
||||||
<el-select v-model="formContent.resourcesId" clearable placeholder="请选择报表数据来源">
|
<el-select v-model="formContent.resourcesId" clearable placeholder="请选择报表数据来源">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('Dev_Series')"
|
v-for="item in dictStore.getDictData('Data_Day')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.code"
|
:value="item.code"
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
<el-form-item label='数据表表名' :label-width='140' prop='classId'>
|
<el-form-item label='数据表表名' :label-width='140' prop='classId'>
|
||||||
<el-select v-model="formContent.classId" clearable placeholder="请选择数据表表名">
|
<el-select v-model="formContent.classId" clearable placeholder="请选择数据表表名">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('High_Cate')"
|
v-for="item in dictStore.getDictData('Data')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.code"
|
:value="item.code"
|
||||||
@@ -91,7 +91,7 @@
|
|||||||
<el-form-item label='超标判断方式' :label-width='140' prop='formula'>
|
<el-form-item label='超标判断方式' :label-width='140' prop='formula'>
|
||||||
<el-select v-model="formContent.formula" clearable placeholder="请选择超标判断方式">
|
<el-select v-model="formContent.formula" clearable placeholder="请选择超标判断方式">
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in dictStore.getDictData('formula')"
|
v-for="item in dictStore.getDictData('Limit_Value_Judgment')"
|
||||||
:key="item.id"
|
:key="item.id"
|
||||||
:label="item.name"
|
:label="item.name"
|
||||||
:value="item.code"
|
:value="item.code"
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
prop: 'dataType',
|
prop: 'dataType',
|
||||||
label: '数据模型',
|
label: '数据模型',
|
||||||
width: 180,
|
width: 180,
|
||||||
enum: dictStore.getDictData('High_Cate'),
|
enum: dictStore.getDictData('Cs_Data_Type'),
|
||||||
search: { el: 'select', props: { filterable: true } },
|
search: { el: 'select', props: { filterable: true } },
|
||||||
fieldNames: { label: 'name', value: 'code' },
|
fieldNames: { label: 'name', value: 'code' },
|
||||||
},
|
},
|
||||||
@@ -90,7 +90,7 @@
|
|||||||
prop: 'phase',
|
prop: 'phase',
|
||||||
label: '相别',
|
label: '相别',
|
||||||
width: 180,
|
width: 180,
|
||||||
enum: dictStore.getDictData('High_Cate'),
|
enum: dictStore.getDictData('phase'),
|
||||||
fieldNames: { label: 'name', value: 'code' },
|
fieldNames: { label: 'name', value: 'code' },
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -156,7 +156,7 @@
|
|||||||
prop: 'classId',
|
prop: 'classId',
|
||||||
label: '数据表表名',
|
label: '数据表表名',
|
||||||
width: 180,
|
width: 180,
|
||||||
enum: dictStore.getDictData('High_Cate'),
|
enum: dictStore.getDictData('Data'),
|
||||||
fieldNames: { label: 'name', value: 'code' },
|
fieldNames: { label: 'name', value: 'code' },
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -164,7 +164,7 @@
|
|||||||
prop: 'resourcesId',
|
prop: 'resourcesId',
|
||||||
label: '报表数据来源',
|
label: '报表数据来源',
|
||||||
width: 180,
|
width: 180,
|
||||||
enum: dictStore.getDictData('Dev_Series'),
|
enum: dictStore.getDictData('Data_Day'),
|
||||||
fieldNames: { label: 'name', value: 'code' },
|
fieldNames: { label: 'name', value: 'code' },
|
||||||
render: (scope) => {
|
render: (scope) => {
|
||||||
const codes = scope.row.resourcesId;
|
const codes = scope.row.resourcesId;
|
||||||
@@ -175,7 +175,7 @@
|
|||||||
prop: 'operation',
|
prop: 'operation',
|
||||||
label: '操作',
|
label: '操作',
|
||||||
fixed: 'right',
|
fixed: 'right',
|
||||||
width: 330,
|
minWidth: 200,
|
||||||
},
|
},
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,143 @@
|
|||||||
|
<template>
|
||||||
|
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogSmall' @close="close">
|
||||||
|
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' >
|
||||||
|
<el-form-item label='字典名称' :label-width='100' prop='name'>
|
||||||
|
<el-input v-model='formContent.name' placeholder='请输入字典名称' autocomplete='off' />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label='序号' :label-width='100'>
|
||||||
|
<el-input-number v-model='formContent.sort' :min="0" controls-position="right" style="width: 300px;"/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label='编码' :label-width='100' prop='code'>
|
||||||
|
<el-input v-model='formContent.code' placeholder='请输入字典编码' autocomplete='off' />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label='描述' :label-width='100' prop='remark'>
|
||||||
|
<el-input v-model='formContent.remark' placeholder='请输入字典描述' autocomplete='off' :rows="2"
|
||||||
|
type="textarea"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<div class='dialog-footer'>
|
||||||
|
<el-button @click='close()'>取消</el-button>
|
||||||
|
<el-button type='primary' @click='save()'>
|
||||||
|
保存
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
</template>
|
||||||
|
<script setup lang='ts'>
|
||||||
|
import { dialogSmall } from '@/utils/elementBind'
|
||||||
|
import { type Dict } from '@/api/system/dictionary/interface'
|
||||||
|
import { ElMessage, type FormItemRule } from 'element-plus'
|
||||||
|
import { addDictTree, updateDictTree } from '@/api/system/dictionary/dictTree'
|
||||||
|
import { computed, type Ref, ref } from 'vue';
|
||||||
|
import { useDictStore } from '@/stores/modules/dict'
|
||||||
|
const dictStore = useDictStore()
|
||||||
|
const selectedStatMethods = ref<string[]>([])
|
||||||
|
// 定义弹出组件元信息
|
||||||
|
const dialogFormRef = ref()
|
||||||
|
function useMetaInfo() {
|
||||||
|
const dialogVisible = ref(false)
|
||||||
|
const titleType = ref('add')
|
||||||
|
const formContent = ref<Dict.ResDictTree>({
|
||||||
|
id: '',
|
||||||
|
pid: '',
|
||||||
|
pids: '',
|
||||||
|
name: '',
|
||||||
|
code: ' ',
|
||||||
|
sort: 100,
|
||||||
|
remark: '',
|
||||||
|
status: 1,
|
||||||
|
children: [],
|
||||||
|
})
|
||||||
|
return { dialogVisible, titleType, formContent }
|
||||||
|
}
|
||||||
|
|
||||||
|
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||||
|
// 清空formContent
|
||||||
|
const resetFormContent = () => {
|
||||||
|
formContent.value = {
|
||||||
|
id: '',
|
||||||
|
pid: '',
|
||||||
|
pids: '',
|
||||||
|
name: '',
|
||||||
|
code: ' ',
|
||||||
|
sort: 100,
|
||||||
|
remark: '',
|
||||||
|
status: 1,
|
||||||
|
children: [],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let dialogTitle = computed(() => {
|
||||||
|
return titleType.value === 'add' ? '新增字典类型' : '编辑字典类型'
|
||||||
|
})
|
||||||
|
|
||||||
|
// 定义表单校验规则
|
||||||
|
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||||
|
dataType: [{ required: true, message: '数据模型必选!', trigger: 'change' }],
|
||||||
|
name: [{ required: true, message: '指标名称必填!', trigger: 'blur' }],
|
||||||
|
})
|
||||||
|
|
||||||
|
// 关闭弹窗
|
||||||
|
const close = () => {
|
||||||
|
dialogVisible.value = false
|
||||||
|
// 清空dialogForm中的值
|
||||||
|
resetFormContent()
|
||||||
|
// 重置表单
|
||||||
|
dialogFormRef.value?.resetFields()
|
||||||
|
selectedStatMethods.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存数据
|
||||||
|
const save = () => {
|
||||||
|
try {
|
||||||
|
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||||
|
if (valid) {
|
||||||
|
if (formContent.value.id) {
|
||||||
|
const result = await updateDictTree(formContent.value);
|
||||||
|
if(result.code != 'A0000'){
|
||||||
|
ElMessage.error({ message: result.message})
|
||||||
|
}else{
|
||||||
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
const result = await addDictTree(formContent.value);
|
||||||
|
if(result.code != 'A0000'){
|
||||||
|
ElMessage.error({ message: result.message})
|
||||||
|
}else{
|
||||||
|
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
close()
|
||||||
|
// 刷新表格
|
||||||
|
await props.refreshTable!()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error('验证过程中出现错误', err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开弹窗,可能是新增,也可能是编辑
|
||||||
|
const open = (sign: string, data: Dict.ResDictTree) => {
|
||||||
|
titleType.value = sign
|
||||||
|
dialogVisible.value = true
|
||||||
|
if (data.id) {
|
||||||
|
formContent.value = { ...data }
|
||||||
|
} else {
|
||||||
|
resetFormContent()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对外映射
|
||||||
|
defineExpose({ open })
|
||||||
|
const props = defineProps<{
|
||||||
|
refreshTable: (() => Promise<void>) | undefined;
|
||||||
|
}>()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
85
frontend/src/views/system/dictionary/dictTree/index.vue
Normal file
85
frontend/src/views/system/dictionary/dictTree/index.vue
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
<template>
|
||||||
|
<div class='table-box' ref='popupBaseView'>
|
||||||
|
<ProTable
|
||||||
|
ref='proTable'
|
||||||
|
:columns='columns'
|
||||||
|
:request-api='getDictTreeList'
|
||||||
|
>
|
||||||
|
<template #tableHeader>
|
||||||
|
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<template #operation='scope'>
|
||||||
|
<el-button type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||||
|
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||||
|
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||||
|
</template>
|
||||||
|
</ProTable>
|
||||||
|
</div>
|
||||||
|
<TreePopup :refresh-table='proTable?.getTableList' ref='treePopup'/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang='tsx' name='dict'>
|
||||||
|
import {CirclePlus, Delete, EditPen, Download, View} from '@element-plus/icons-vue'
|
||||||
|
import {type Dict} from '@/api/system/dictionary/interface'
|
||||||
|
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||||
|
import TreePopup from '@/views/system/dictionary/dictTree/components/treePopup.vue'
|
||||||
|
import {useDictStore} from '@/stores/modules/dict'
|
||||||
|
import {useHandleData} from '@/hooks/useHandleData'
|
||||||
|
import {
|
||||||
|
getDictTreeList,
|
||||||
|
deleteDictTree,
|
||||||
|
} from '@/api/system/dictionary/dictTree'
|
||||||
|
import { reactive, ref } from 'vue'
|
||||||
|
|
||||||
|
const dictStore = useDictStore()
|
||||||
|
|
||||||
|
const proTable = ref<ProTableInstance>()
|
||||||
|
const treePopup = ref()
|
||||||
|
|
||||||
|
const columns = reactive<ColumnProps<Dict.ResDictTree>[]>([
|
||||||
|
{
|
||||||
|
prop: 'name',
|
||||||
|
label: '字典名称',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'code',
|
||||||
|
label: '编码',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'remark',
|
||||||
|
label: '描述',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'status',
|
||||||
|
label: '状态',
|
||||||
|
width: 180,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prop: 'operation',
|
||||||
|
label: '操作',
|
||||||
|
fixed: 'right',
|
||||||
|
minWidth: 200,
|
||||||
|
},
|
||||||
|
])
|
||||||
|
|
||||||
|
|
||||||
|
// 打开 drawer(新增、编辑)
|
||||||
|
const openDialog = (titleType: string, row: Partial<Dict.ResDictTree> = {}) => {
|
||||||
|
treePopup.value?.open(titleType, row)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 删除字典类型
|
||||||
|
const handleDelete = async (params: Dict.ResDictTree) => {
|
||||||
|
await useHandleData(deleteDictTree, [params.id], `删除【${params.name}】树形字典类型`)
|
||||||
|
proTable.value?.getTableList()
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
Reference in New Issue
Block a user