Merge branch 'master' of http://192.168.1.22:3000/frontend/pqs-9100_client
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" :model-value="visible" @close="handleCancel" v-bind="dialogSmall">
|
||||
<el-form :model="formData" :rules="rules">
|
||||
<el-form-item label="菜单名称" prop="name">
|
||||
<el-input v-model="formData.name" />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单路径" prop="path">
|
||||
<el-input v-model="formData.path" />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单排序" prop="sort">
|
||||
<el-input-number v-model="formData.sort" />
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择资源类型">
|
||||
<el-option label="菜单" value="菜单" />
|
||||
<el-option label="按钮" value="按钮" />
|
||||
<el-option label="公共资源" value="公共资源" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="菜单描述" prop="remark">
|
||||
<el-input v-model="formData.remark" :rows="2" type="textarea"/>
|
||||
</el-form-item>
|
||||
<el-form-item label="路由名称" prop="route_Name">
|
||||
<el-input v-model="formData.route_Name" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">确 定</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="ResourceDialog">
|
||||
import { defineProps, defineEmits, reactive,watch } from 'vue';
|
||||
import { dialogSmall } from '@/utils/elementBind'
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
dialogTitle: string;
|
||||
|
||||
formData: {
|
||||
|
||||
id:string;
|
||||
name: string;
|
||||
path: string;
|
||||
sort: number;
|
||||
type: string;
|
||||
remark: string;
|
||||
route_Name: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
const rules = {
|
||||
name :[
|
||||
{require:true,trigger:"blur",message:"请填写菜单名称"}
|
||||
]
|
||||
}
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'submit', data: any): void;
|
||||
}>();
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false); // 关闭对话框
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
emit('submit', props.formData); // 提交表单数据
|
||||
emit('update:visible', false); // 提交后关闭对话框
|
||||
};
|
||||
|
||||
// 当 props.visible 改变时,更新 formData
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (!newVal) {
|
||||
// 这里可以重置表单数据,如果需要的话
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -39,13 +39,12 @@
|
||||
import { defineComponent,ref ,reactive} from 'vue'
|
||||
import { type Resource } from '@/api/resource/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import ResourceDialog from '@/components/ResourceDialog/index.vue'; // 导入子组件
|
||||
import {Operation, CirclePlus, Delete, EditPen, Download, Upload, View, Refresh} from '@element-plus/icons-vue'
|
||||
import ResourceDialog from "@/views/authority/resource/components/ResourceDialog.vue"; // 导入子组件
|
||||
import {CirclePlus, Delete, EditPen} from '@element-plus/icons-vue'
|
||||
import resourceDataList from '@/api/resource/resourceData'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
let multipleSelection = ref<string[]>([]);
|
||||
import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
let multipleSelection = ref<string[]>([]);
|
||||
const resourceData = resourceDataList
|
||||
const dialogFormVisible = ref(false)
|
||||
const isEditMode = ref(false);
|
||||
@@ -70,17 +69,18 @@ import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
width: 120,
|
||||
width: 150,
|
||||
search: { el: 'input', tooltip: '我是搜索提示' },
|
||||
},
|
||||
{
|
||||
prop: 'path',
|
||||
label: '路径',
|
||||
width: 180,
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
prop: 'sort',
|
||||
label: '排序',
|
||||
width: 100,
|
||||
search: {
|
||||
// 自定义 search 显示内容
|
||||
render: ({ searchParam }) => {
|
||||
@@ -90,6 +90,7 @@ import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
<span class='mr10 ml10'>-</span>
|
||||
<el-input vModel_trim={searchParam.maxAge} placeholder='最大排序' />
|
||||
</div>
|
||||
|
||||
)
|
||||
},
|
||||
},
|
||||
@@ -97,13 +98,31 @@ import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
{
|
||||
prop: 'type',
|
||||
label: '资源类型',
|
||||
width: 150,
|
||||
// 字典数据(本地数据)
|
||||
//enum: dictStore.getDictData('type'),
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
//search: { el: 'select', props: { filterable: true } },
|
||||
//fieldNames: { label: 'label', value: 'resourceType' },
|
||||
search: {
|
||||
// 自定义 search 显示内容
|
||||
render: ({ searchParam }) => {
|
||||
return (
|
||||
<div class='flx-center'>
|
||||
<el-select >
|
||||
<el-option ></el-option>
|
||||
<el-option label="未检测"></el-option>
|
||||
<el-option label="检测中"></el-option>
|
||||
<el-option label="检测完成"></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'route_Name',
|
||||
width: 200,
|
||||
label: '路由名称',
|
||||
search: { el: 'input' },
|
||||
},
|
||||
@@ -121,11 +140,7 @@ import { ElMessage, ElMessageBox, inputEmits } from 'element-plus';
|
||||
prop: 'update_Time',
|
||||
label: '更新时间',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
span: 1,
|
||||
props: { type: 'daterange', valueFormat: 'YYYY-MM-DD'},
|
||||
defaultValue: ['2024-11-12', '2024-12-12'],}
|
||||
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 200 },
|
||||
])
|
||||
@@ -166,7 +181,7 @@ const submitForm = () => {
|
||||
const openEditDialog = (resource: Resource.ResResourceList) => {
|
||||
dialogForm.value = { ...resource }; // 复制资源数据以便编辑
|
||||
isEditMode.value = true; // 设置为编辑模式
|
||||
dialogTitle.value = '编辑资源';
|
||||
dialogTitle.value = '编辑菜单';
|
||||
dialogFormVisible.value = true; // 显示对话框
|
||||
};
|
||||
//选中
|
||||
@@ -177,9 +192,21 @@ const openEditDialog = (resource: Resource.ResResourceList) => {
|
||||
};
|
||||
//批量删除
|
||||
const handleDelList =()=>{
|
||||
ElMessageBox.confirm(
|
||||
`是否删除所选菜单信息?`, // 使用模板字符串来插值
|
||||
'温馨提示',
|
||||
{
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
resourceData.value = resourceData.value.filter(item => !multipleSelection.value.includes(item.id));
|
||||
multipleSelection.value = []; // Clear selected rows
|
||||
ElMessage.success("批量删除成功");
|
||||
})
|
||||
|
||||
}
|
||||
// 删除资源
|
||||
const deleteResource = (params: Resource.ResResourceList) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--双列-->
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='title' v-bind='dialogMiddle'>
|
||||
<el-dialog v-model='dialogVisible' :title='title' v-bind='dialogMiddle' >
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" label-width="auto" ref="formRef" class='form-two'>
|
||||
<el-form-item label="姓名" prop="username" >
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<template>
|
||||
<div class='table-box'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:data='userData'
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:data='userData'
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
@@ -26,11 +26,11 @@
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
<single-column ref='singleColumn' />
|
||||
<double-column ref='doubleColumn' />
|
||||
<single-column ref='singleColumn' />
|
||||
<double-column ref='doubleColumn' />
|
||||
</template>
|
||||
<script setup lang='tsx' name='useProTable'>
|
||||
import { ref ,reactive} from 'vue'
|
||||
import { ref, reactive } from 'vue'
|
||||
import { User } from '@/api/user/interface'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
@@ -43,6 +43,7 @@ import userDataList from '@/api/user/userData'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import SingleColumn from '@/views/demo/proTable/singleColumn.vue'
|
||||
import DoubleColumn from '@/views/demo/proTable/doubleColumn.vue'
|
||||
|
||||
const dictStore = useDictStore()
|
||||
import {
|
||||
getUserList,
|
||||
@@ -54,6 +55,8 @@ import {
|
||||
getUserStatus,
|
||||
} from '@/api/user/user'
|
||||
import { ElMessageBox } from 'element-plus'
|
||||
import router from '@/routers'
|
||||
|
||||
const userData = userDataList
|
||||
const singleColumn = ref()
|
||||
const doubleColumn = ref()
|
||||
@@ -88,7 +91,7 @@ const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
||||
prop: 'username',
|
||||
label: '姓名',
|
||||
width: 120,
|
||||
search: { el: 'input'},
|
||||
search: { el: 'input' },
|
||||
},
|
||||
{
|
||||
prop: 'gender',
|
||||
@@ -105,11 +108,11 @@ const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
||||
// 自定义 search 显示内容
|
||||
render: ({ searchParam }) => {
|
||||
return (
|
||||
<div class='flx-center'>
|
||||
<el-input vModel_trim={searchParam.minAge} placeholder='最小年龄' />
|
||||
<span class='mr10 ml10'>-</span>
|
||||
<el-input vModel_trim={searchParam.maxAge} placeholder='最大年龄' />
|
||||
</div>
|
||||
<div class='flx-center'>
|
||||
<el-input vModel_trim={searchParam.minAge} placeholder='最小年龄' />
|
||||
<span class='mr10 ml10'>-</span>
|
||||
<el-input vModel_trim={searchParam.maxAge} placeholder='最大年龄' />
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
@@ -125,19 +128,19 @@ const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
||||
fieldNames: { label: 'userLabel', value: 'userStatus' },
|
||||
render: scope => {
|
||||
return (
|
||||
<>
|
||||
{BUTTONS.value.status ? (
|
||||
<el-switch
|
||||
model-value={scope.row.status}
|
||||
active-text={scope.row.status ? '启用' : '禁用'}
|
||||
active-value={1}
|
||||
inactive-value={0}
|
||||
onClick={() => changeStatus(scope.row)}
|
||||
/>
|
||||
) : (
|
||||
<el-tag type={scope.row.status ? 'success' : 'danger'}>{scope.row.status ? '启用' : '禁用'}</el-tag>
|
||||
)}
|
||||
</>
|
||||
<>
|
||||
{BUTTONS.value.status ? (
|
||||
<el-switch
|
||||
model-value={scope.row.status}
|
||||
active-text={scope.row.status ? '启用' : '禁用'}
|
||||
active-value={1}
|
||||
inactive-value={0}
|
||||
onClick={() => changeStatus(scope.row)}
|
||||
/>
|
||||
) : (
|
||||
<el-tag type={scope.row.status ? 'success' : 'danger'}>{scope.row.status ? '启用' : '禁用'}</el-tag>
|
||||
)}
|
||||
</>
|
||||
)
|
||||
},
|
||||
},
|
||||
@@ -156,8 +159,9 @@ const columns = reactive<ColumnProps<User.ResUserList>[]>([
|
||||
])
|
||||
// 删除用户信息
|
||||
const deleteAccount = async (params: User.ResUserList) => {
|
||||
await useHandleData(deleteUser, { id: [params.id] }, `删除【${params.username}】用户`)
|
||||
proTable.value?.getTableList()
|
||||
// await useHandleData(deleteUser, { id: [params.id] }, `删除【${params.username}】用户`)
|
||||
// proTable.value?.getTableList()
|
||||
router.push('/plan/autoTest')
|
||||
}
|
||||
// 批量删除用户信息
|
||||
const batchDelete = async (id: string[]) => {
|
||||
@@ -169,7 +173,7 @@ const batchDelete = async (id: string[]) => {
|
||||
const resetPass = async (params: User.ResUserList) => {
|
||||
// await useHandleData(resetUserPassWord, { id: params.id }, `重置【${params.username}】用户密码`)
|
||||
// proTable.value?.getTableList()
|
||||
doubleColumn.value.open("双列弹出框")
|
||||
doubleColumn.value.open('双列弹出框')
|
||||
}
|
||||
// 切换用户状态
|
||||
const changeStatus = async (row: User.ResUserList) => {
|
||||
@@ -182,7 +186,7 @@ const changeStatus = async (row: User.ResUserList) => {
|
||||
// 导出用户列表
|
||||
const downloadFile = async () => {
|
||||
ElMessageBox.confirm('确认导出用户数据?', '温馨提示', { type: 'warning' }).then(() =>
|
||||
useDownload(exportUserInfo, '用户列表', proTable.value?.searchParam),
|
||||
useDownload(exportUserInfo, '用户列表', proTable.value?.searchParam),
|
||||
)
|
||||
}
|
||||
// 批量添加用户
|
||||
@@ -198,6 +202,6 @@ const batchAdd = () => {
|
||||
}
|
||||
// 打开 drawer(新增、查看、编辑)
|
||||
const openDrawer = (title: string, row: Partial<User.ResUserList> = {}) => {
|
||||
singleColumn.value.open("单列弹出框")
|
||||
singleColumn.value.open('单列弹出框')
|
||||
}
|
||||
</script>
|
||||
@@ -1,6 +1,6 @@
|
||||
<!--单列-->
|
||||
<template>
|
||||
<el-dialog v-model='dialogVisible' :title='title' v-bind='dialogSmall'>
|
||||
<el-dialog v-model='dialogVisible' :title='title' v-bind='dialogSmall' >
|
||||
<el-scrollbar>
|
||||
<el-form :inline="false" label-width="auto" ref="formRef">
|
||||
<el-form-item label="姓名" prop="username">
|
||||
|
||||
93
frontend/src/views/log/index.vue
Normal file
93
frontend/src/views/log/index.vue
Normal file
@@ -0,0 +1,93 @@
|
||||
<template>
|
||||
<div class='table-box'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:data='logData'
|
||||
@selection-change='handleSelectionChange'
|
||||
type='selection'
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader>
|
||||
<el-button type='primary' :icon='DataAnalysis'>分析</el-button>
|
||||
<el-button type='primary' :icon='Upload'>导出csv</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
</template>
|
||||
<script setup lang='tsx' name='useProTable'>
|
||||
// 根据实际路径调整
|
||||
import TimeControl from '@/components/TimeControl/index.vue'
|
||||
import { type Log } from '@/api/log/interface'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import { Upload ,DataAnalysis} from '@element-plus/icons-vue'
|
||||
import logDataList from '@/api/log/logData'
|
||||
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
|
||||
import { reactive,ref } from 'vue'
|
||||
let multipleSelection = ref<string[]>([])
|
||||
const logData = logDataList
|
||||
// 定义包含和排除的单位
|
||||
const includedUnits = ['日', '周', '月', '季度']; // 可以根据需要包含的单位
|
||||
const excludedUnits = ['年']; // 要排除的单位
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<Log.LogList>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 50 },
|
||||
{
|
||||
prop: 'content',
|
||||
label: '内容',
|
||||
width: 600,
|
||||
},
|
||||
{
|
||||
prop: 'record_Time',
|
||||
label: '记录时间',
|
||||
width: 180,
|
||||
},
|
||||
{
|
||||
prop: 'user',
|
||||
label: '操作用户',
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
},
|
||||
|
||||
{
|
||||
prop: 'type',
|
||||
label: '日志类型',
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
},
|
||||
{
|
||||
prop: 'level',
|
||||
label: '日志等级',
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
},
|
||||
{
|
||||
prop: 'record_Time',
|
||||
label: '记录时间',
|
||||
isShow: false,
|
||||
search: {
|
||||
span: 2,
|
||||
render: ({ searchParam }) => {
|
||||
return (
|
||||
<div class='flx-flex-start'>
|
||||
<TimeControl/>
|
||||
</div>
|
||||
)
|
||||
},
|
||||
},
|
||||
},
|
||||
])
|
||||
|
||||
//选中
|
||||
// 处理选择变化
|
||||
const handleSelectionChange = (selection: Log.LogList[]) => {
|
||||
multipleSelection.value = selection.map(row => row.id) // 更新选中的行
|
||||
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,91 @@
|
||||
<template >
|
||||
<el-dialog :title="dialogTitle" :model-value="visible" @close="handleCancel" v-bind="dialogSmall" >
|
||||
<el-form-item label="指标类型" prop="type">
|
||||
<el-select
|
||||
class='select'
|
||||
placeholder='选择时间单位'
|
||||
>
|
||||
<!-- 采用 v-for 动态渲染 -->
|
||||
<el-option
|
||||
v-for="unit in typeList"
|
||||
:key="unit.value"
|
||||
:label="unit.label"
|
||||
:value="unit.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">新增</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="IndicatorTypeDialog">
|
||||
import { defineProps, defineEmits, reactive,watch } from 'vue';
|
||||
import { dialogSmall} from '@/utils/elementBind'
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
dialogTitle: string;
|
||||
|
||||
formData: {
|
||||
|
||||
id:string;
|
||||
name: string;
|
||||
path: string;
|
||||
sort: number;
|
||||
type: string;
|
||||
remark: string;
|
||||
route_Name: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
const typeList = [
|
||||
{ label: '电压', value: '电压' },
|
||||
{ label: '频率', value: '频率' },
|
||||
{ label: '电压三相不平衡度', value: '电压三相不平衡度' },
|
||||
{ label: '电流三相不平衡度', value: '电流三相不平衡度' },
|
||||
{ label: '电压波动', value: '电压波动' },
|
||||
{ label: '短时闪变', value: '短时闪变' },
|
||||
{ label: '谐波电压', value: '谐波电压' },
|
||||
{ label: '谐波电流', value: '谐波电流' },
|
||||
{ label: '谐波相角', value: '谐波相角' },
|
||||
{ label: '谐波功率', value: '谐波功率' },
|
||||
{ label: '间谐波电压', value: '间谐波电压' },
|
||||
{ label: '间谐波电流', value: '间谐波电流' },
|
||||
{ label: '功率', value: '功率' },
|
||||
{ label: '电流', value: '电流' },
|
||||
{ label: '暂态电压幅值', value: '暂态电压幅值' },
|
||||
{ label: '暂态持续时间', value: '暂态持续时间' },
|
||||
];
|
||||
|
||||
const rules = {
|
||||
name :[
|
||||
{require:true,trigger:"blur",message:"请填写菜单名称"}
|
||||
]
|
||||
}
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'submit', data: any): void;
|
||||
}>();
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false); // 关闭对话框
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
emit('submit', props.formData); // 提交表单数据
|
||||
emit('update:visible', false); // 提交后关闭对话框
|
||||
};
|
||||
|
||||
// 当 props.visible 改变时,更新 formData
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (!newVal) {
|
||||
// 这里可以重置表单数据,如果需要的话
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,294 @@
|
||||
<template>
|
||||
<el-dialog :title="dialogTitle" :model-value="visible" @close="handleCancel" v-bind="dialogBig">
|
||||
<el-tabs type="border-card">
|
||||
<el-tab-pane label="基础信息">
|
||||
<div class="form-grid">
|
||||
<el-form :model="formData" >
|
||||
<el-row :gutter="20" >
|
||||
<el-col :span="10">
|
||||
<el-form-item label="误差体系名称" prop="name">
|
||||
<el-input placeholder="标准号+年份+设备等级"/>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="发布时间" prop="publishTime">
|
||||
<el-input />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="上传误差体系截图" prop="screenshot">
|
||||
<el-button :icon="FolderOpened" type="primary"></el-button>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<el-row :gutter="20" >
|
||||
<el-col :span="10">
|
||||
<el-form-item label="适用设备等级" prop="type">
|
||||
<el-select placeholder="请选择设备等级">
|
||||
<el-option label="A级" value="A级" />
|
||||
<el-option label="S级" value="S级" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<el-form-item label="实施时间" prop="publishTime">
|
||||
<el-input />
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
<el-col :span="6">
|
||||
<el-form-item label="状态" prop="type">
|
||||
<el-select placeholder="请选择状态">
|
||||
<el-option label="启用" value="启用" />
|
||||
<el-option label="停用" value="停用" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</el-form>
|
||||
</div>
|
||||
</el-tab-pane>
|
||||
</el-tabs>
|
||||
<div class="dialog-footer">
|
||||
<el-button :icon='CirclePlus' type="primary" @click="openAddDialog">新增</el-button>
|
||||
<el-button :icon='Delete' type="danger" >批量删除</el-button>
|
||||
</div>
|
||||
|
||||
<el-table :data="tableData" style="width: 100%;text-align: center" >
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="id" label="序号" width="60" />
|
||||
<el-table-column prop="type" label="电能质量检测指标类型" width="200"/>
|
||||
<el-table-column label="起止范围">
|
||||
<el-table-column label="起始">
|
||||
<template #default="{ row }">
|
||||
<el-row type="flex" align="middle">
|
||||
<el-col :span="16">
|
||||
<el-select v-model="row.startSelect" placeholder="选择起始值" style="width: 70px;">
|
||||
<el-option
|
||||
v-for="option in errorStartOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span>{{ row.startRange }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="结束">
|
||||
<template #default="{ row }">
|
||||
<el-row type="flex" align="middle">
|
||||
<el-col :span="16">
|
||||
<el-select v-model="row.endSelect" placeholder="选择结束值" style="width: 70px;">
|
||||
<el-option
|
||||
v-for="option in errorEndOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-col>
|
||||
<el-col :span="8">
|
||||
<span>{{ row.endRange }}</span>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="单位" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.unit" placeholder="选择单位">
|
||||
<el-option
|
||||
v-for="option in errorUnitOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="最大误差">
|
||||
<el-table-column prop="maxErrorValue" label="最大误差值" width="100"/>
|
||||
<el-table-column label="误差类型">
|
||||
<template #default="{ row }">
|
||||
<el-select v-model="row.errorType" placeholder="选择误差类型">
|
||||
<el-option
|
||||
v-for="option in errorTypeOptions"
|
||||
:key="option.value"
|
||||
:label="option.label"
|
||||
:value="option.value"
|
||||
/>
|
||||
</el-select>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="150">
|
||||
<template #default>
|
||||
<el-button type="primary" link :icon='CopyDocument'>复制</el-button>
|
||||
<el-button type='primary' link :icon='Delete' >删除</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 新增/编辑资源对话框 -->
|
||||
<IndicatorTypeDialog
|
||||
:visible="dialogFormVisible"
|
||||
:formData="dialogForm"
|
||||
:dialogTitle="dialogTitle"
|
||||
@update:visible="dialogFormVisible = $event"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="ErrorSystemDialog">
|
||||
import { defineProps, defineEmits, reactive,watch,ref } from 'vue';
|
||||
import { dialogBig,dialogMiddle} from '@/utils/elementBind'
|
||||
import IndicatorTypeDialog from "@/views/machine/errorSystem/components/IndicatorTypeDialog.vue"; // 导入子组件
|
||||
import {CirclePlus, Delete, EditPen,FolderOpened,CopyDocument} from '@element-plus/icons-vue'
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
dialogTitle: string;
|
||||
|
||||
formData: {
|
||||
|
||||
id:string;
|
||||
name: string;
|
||||
path: string;
|
||||
sort: number;
|
||||
type: string;
|
||||
remark: string;
|
||||
route_Name: string;
|
||||
};
|
||||
}>();
|
||||
const dialogFormVisible = ref(false)
|
||||
const dialogTitle = ref('新增检测指标误差项')
|
||||
const errorTypeOptions = [
|
||||
{ label: '绝对值-标称值', value: 'type1' },
|
||||
{ label: '相对值-I类', value: 'type2' },
|
||||
{ label: '相对值-II类', value: 'type3' },
|
||||
{ label: '绝对值-值类型', value: 'type4' },
|
||||
];
|
||||
|
||||
const errorUnitOptions = [
|
||||
{ label: '标称值', value: 'type1' },
|
||||
{ label: '值', value: 'type2' },
|
||||
{ label: '无', value: 'type3' },
|
||||
];
|
||||
|
||||
const errorStartOptions = [
|
||||
{ label: '>', value: 'type1' },
|
||||
{ label: '>=', value: 'type2' },
|
||||
{ label: '无', value: 'type3' },
|
||||
];
|
||||
|
||||
const errorEndOptions = [
|
||||
{ label: '<', value: 'type1' },
|
||||
{ label: '<=', value: 'type2' },
|
||||
{ label: '无', value: 'type3' },
|
||||
];
|
||||
|
||||
|
||||
const tableData = [
|
||||
{
|
||||
id: '1',
|
||||
type: '电压',
|
||||
startSelect: 'type1',
|
||||
startRange: '0.1',
|
||||
endSelect: 'type2',
|
||||
endRange: '1.5',
|
||||
unit:'type1',
|
||||
maxErrorValue:'0.001',
|
||||
errorType:'type1'
|
||||
},
|
||||
{
|
||||
id: '2',
|
||||
type: '电流',
|
||||
startSelect: 'type2',
|
||||
startRange: '0.01',
|
||||
endSelect: 'type1',
|
||||
endRange: '0.05',
|
||||
unit:'type1',
|
||||
maxErrorValue:'0.005',
|
||||
errorType:'type1'
|
||||
},
|
||||
{
|
||||
id: '3',
|
||||
type: '频率',
|
||||
startSelect: 'type2',
|
||||
startRange: '42.5',
|
||||
endSelect: 'type2',
|
||||
endRange: '57.5',
|
||||
unit:'type1',
|
||||
maxErrorValue:'0.01',
|
||||
errorType:'type4'
|
||||
},
|
||||
|
||||
|
||||
]
|
||||
|
||||
const rules = {
|
||||
name :[
|
||||
{require:true,trigger:"blur",message:"请填写菜单名称"}
|
||||
]
|
||||
}
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'submit', data: any): void;
|
||||
}>();
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false); // 关闭对话框
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
emit('submit', props.formData); // 提交表单数据
|
||||
emit('update:visible', false); // 提交后关闭对话框
|
||||
};
|
||||
|
||||
// 当 props.visible 改变时,更新 formData
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (!newVal) {
|
||||
// 这里可以重置表单数据,如果需要的话
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
const openAddDialog = () => {
|
||||
dialogFormVisible.value = true; // 打开对话框
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.form-grid {
|
||||
display: flex;
|
||||
flex-direction: row; /* 横向排列 */
|
||||
flex-wrap: wrap; /* 允许换行 */
|
||||
}
|
||||
.form-grid .el-form-item {
|
||||
flex: 1 1 30%; /* 控件宽度 */
|
||||
margin-right: 20px; /* 控件间距 */
|
||||
}
|
||||
.form-grid .el-form-item:last-child {
|
||||
margin-right: 0; /* 最后一个控件不需要右边距 */
|
||||
}
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
margin-bottom: 10px; /* 调整这里的值以增加或减少间距 */
|
||||
}
|
||||
.el-tabs {
|
||||
margin-bottom: 20px; /* 添加底部边距 */
|
||||
}
|
||||
|
||||
.el-table th, .el-table td {
|
||||
text-align: center; /* 所有单元格文字居中 */
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,91 @@
|
||||
<template >
|
||||
<el-dialog :title="dialogTitle" :model-value="visible" @close="handleCancel" v-bind="dialogSmall" >
|
||||
<el-form-item label="指标类型" prop="type">
|
||||
<el-select
|
||||
class='select'
|
||||
placeholder='选择时间单位'
|
||||
>
|
||||
<!-- 采用 v-for 动态渲染 -->
|
||||
<el-option
|
||||
v-for="unit in typeList"
|
||||
:key="unit.value"
|
||||
:label="unit.label"
|
||||
:value="unit.value"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">新增</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup name="IndicatorTypeDialog">
|
||||
import { defineProps, defineEmits, reactive,watch } from 'vue';
|
||||
import { dialogSmall} from '@/utils/elementBind'
|
||||
const props = defineProps<{
|
||||
visible: boolean;
|
||||
dialogTitle: string;
|
||||
|
||||
formData: {
|
||||
|
||||
id:string;
|
||||
name: string;
|
||||
path: string;
|
||||
sort: number;
|
||||
type: string;
|
||||
remark: string;
|
||||
route_Name: string;
|
||||
};
|
||||
}>();
|
||||
|
||||
const typeList = [
|
||||
{ label: '电压', value: '电压' },
|
||||
{ label: '频率', value: '频率' },
|
||||
{ label: '电压三相不平衡度', value: '电压三相不平衡度' },
|
||||
{ label: '电流三相不平衡度', value: '电流三相不平衡度' },
|
||||
{ label: '电压波动', value: '电压波动' },
|
||||
{ label: '短时闪变', value: '短时闪变' },
|
||||
{ label: '谐波电压', value: '谐波电压' },
|
||||
{ label: '谐波电流', value: '谐波电流' },
|
||||
{ label: '谐波相角', value: '谐波相角' },
|
||||
{ label: '谐波功率', value: '谐波功率' },
|
||||
{ label: '间谐波电压', value: '间谐波电压' },
|
||||
{ label: '间谐波电流', value: '间谐波电流' },
|
||||
{ label: '功率', value: '功率' },
|
||||
{ label: '电流', value: '电流' },
|
||||
{ label: '暂态电压幅值', value: '暂态电压幅值' },
|
||||
{ label: '暂态持续时间', value: '暂态持续时间' },
|
||||
];
|
||||
|
||||
const rules = {
|
||||
name :[
|
||||
{require:true,trigger:"blur",message:"请填写菜单名称"}
|
||||
]
|
||||
}
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:visible', value: boolean): void;
|
||||
(e: 'submit', data: any): void;
|
||||
}>();
|
||||
|
||||
const handleCancel = () => {
|
||||
emit('update:visible', false); // 关闭对话框
|
||||
};
|
||||
|
||||
const handleSubmit = () => {
|
||||
emit('submit', props.formData); // 提交表单数据
|
||||
emit('update:visible', false); // 提交后关闭对话框
|
||||
};
|
||||
|
||||
// 当 props.visible 改变时,更新 formData
|
||||
watch(() => props.visible, (newVal) => {
|
||||
if (!newVal) {
|
||||
// 这里可以重置表单数据,如果需要的话
|
||||
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
104
frontend/src/views/machine/errorSystem/index.vue
Normal file
104
frontend/src/views/machine/errorSystem/index.vue
Normal file
@@ -0,0 +1,104 @@
|
||||
<template>
|
||||
<div class='table-box'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:data='errorData'
|
||||
type='selection'
|
||||
>
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader>
|
||||
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增误差体系</el-button>
|
||||
<el-button type='danger' :icon='Delete' plain
|
||||
>
|
||||
批量删除误差体系
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button type='primary' link :icon='View' @row-click="handleRowClick">查看</el-button>
|
||||
<el-button type='primary' link :icon='EditPen' @click="openEditDialog(scope.row)">编辑</el-button>
|
||||
<el-button type='primary' link :icon='Delete' >删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
|
||||
<!-- 新增/编辑资源对话框 -->
|
||||
<ResourceDialog
|
||||
:visible="dialogFormVisible"
|
||||
:formData="dialogForm"
|
||||
:dialogTitle="dialogTitle"
|
||||
@update:visible="dialogFormVisible = $event"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts" name='useProTable'>
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ColumnProps } from '@/components/ProTable/interface'
|
||||
import { CirclePlus, Delete,EditPen,View} from '@element-plus/icons-vue'
|
||||
import errorDataList from '@/api/error/errorData'
|
||||
import { reactive,ref } from 'vue'
|
||||
import type { ErrorSystem } from '@/api/error/interface'
|
||||
import ResourceDialog from "@/views/machine/errorSystem/components/ErrorSystemDialog.vue"; // 导入子组件
|
||||
let multipleSelection = ref<string[]>([])
|
||||
const errorData = errorDataList
|
||||
const dialogFormVisible = ref(false)
|
||||
const dialogTitle = ref('新增误差体系')
|
||||
const dialogForm = ref<ErrorSystem.ErrorSystemList>({
|
||||
id: '',
|
||||
name: '',
|
||||
year:'',
|
||||
level:'',
|
||||
});
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<ErrorSystem.ErrorSystemList>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 50 },
|
||||
{
|
||||
prop: 'id',
|
||||
label: '序号',
|
||||
width: 100,
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: '误差体系名称',
|
||||
width: 300,
|
||||
},
|
||||
{
|
||||
prop: 'year',
|
||||
label: '标准实施年份',
|
||||
search: { el: 'input' },
|
||||
},
|
||||
|
||||
{
|
||||
prop: 'level',
|
||||
label: '适用设备等级',
|
||||
search: { el: 'select', props: { filterable: true } },
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right' },
|
||||
])
|
||||
|
||||
// 打开编辑对话框
|
||||
const openEditDialog = (resource: ErrorSystem.ErrorSystemList) => {
|
||||
|
||||
};
|
||||
|
||||
const openAddDialog = () => {
|
||||
dialogForm.value = {
|
||||
id: '',
|
||||
name: '',
|
||||
year: '',
|
||||
level: '',
|
||||
};
|
||||
dialogFormVisible.value = true; // 打开对话框
|
||||
};
|
||||
|
||||
|
||||
const handleRowClick = (row: ErrorSystem.ErrorSystemList) =>{
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
||||
@@ -51,8 +51,6 @@ const getTreeData = (val: any) => {
|
||||
defaultChecked.value = [];
|
||||
data.value = val;
|
||||
defaultChecked.value.push(data.value[0].children[0].children[0].id);
|
||||
console.log(defaultChecked.value, "+++++++++++++");
|
||||
console.log(treeList.value);
|
||||
treeRef.value.setCurrentKey(defaultChecked.value);
|
||||
};
|
||||
const filterText = ref("");
|
||||
|
||||
@@ -271,7 +271,6 @@ const dataCallback = (data: any) => {
|
||||
total: data.length || data.total, //total
|
||||
};
|
||||
};
|
||||
console.log(proTable.value, "proTable.value?proTable.value?proTable.value?");
|
||||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||||
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
|
||||
const getTableList = (params: any) => {
|
||||
|
||||
@@ -240,7 +240,6 @@ const dataCallback = (data: any) => {
|
||||
total: data.length || data.total,
|
||||
};
|
||||
};
|
||||
console.log(proTable.value, "proTable.value?proTable.value?proTable.value?");
|
||||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||||
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
|
||||
const getTableList = (params: any) => {
|
||||
|
||||
@@ -240,7 +240,6 @@ const dataCallback = (data: any) => {
|
||||
total: data.length || data.total,
|
||||
};
|
||||
};
|
||||
console.log(proTable.value, "proTable.value?proTable.value?proTable.value?");
|
||||
// 如果你想在请求之前对当前请求参数做一些操作,可以自定义如下函数:params 为当前所有的请求参数(包括分页),最后返回请求列表接口
|
||||
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
|
||||
const getTableList = (params: any) => {
|
||||
|
||||
250
frontend/src/views/system/dict/data.vue
Normal file
250
frontend/src/views/system/dict/data.vue
Normal file
@@ -0,0 +1,250 @@
|
||||
<template>
|
||||
<div class="table-box">
|
||||
<ProTable :columns="columns" :data="data">
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="openDrawer('新增')">新增</el-button>
|
||||
<el-button type="primary" :icon="Upload" plain @click="batchAdd">批量添加</el-button>
|
||||
<el-button type="primary" :icon="Download" plain @click="downloadFile">导出</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected"
|
||||
@click="batchDelete(scope.selectedListIds)">
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="EditPen" @click="openDrawer('编辑', scope.row)">编辑</el-button>
|
||||
<el-button type="primary" link :icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogType === '新增' ? '新增字典数据' : '编辑字典数据'" v-bind="dialogSmall">
|
||||
<div>
|
||||
<el-form :model="dialogForm">
|
||||
<el-form-item label="字典类型编码" :label-width="100">
|
||||
<el-input :value="route.params.code" disabled />
|
||||
</el-form-item>
|
||||
<el-form-item label="编码" :label-width="100">
|
||||
<el-input v-model="dialogForm.code" placeholder="请输入" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="名称" :label-width="100">
|
||||
<el-input v-model="dialogForm.name" placeholder="请输入" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="值" :label-width="100">
|
||||
<el-input v-model="dialogForm.value" placeholder="请输入" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示排序" :label-width="100">
|
||||
<el-input-number v-model="dialogForm.sort" :min="1" :max="100" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" :label-width="100">
|
||||
<el-radio-group v-model.number="dialogForm.state">
|
||||
<el-radio v-for="item in dictStore.getDictData('status')" :key="item.id" :value="item.code">{{
|
||||
item.label
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<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="tsx" name="dictData">
|
||||
import { useRoute } from 'vue-router'
|
||||
import { CirclePlus, Delete, EditPen, Download, Upload } from '@element-plus/icons-vue'
|
||||
import { Dict } from '@/api/system/dict/interface'
|
||||
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||
import { dialogSmall } from '@/utils/elementBind'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { dictDataList } from '@/api/system/dict/dictExample'
|
||||
import {
|
||||
updateDictData,
|
||||
addDictData,
|
||||
batchAddDictData,
|
||||
exportDictData,
|
||||
deleteDictData
|
||||
} from '@/api/system/dict'
|
||||
|
||||
const route = useRoute()
|
||||
|
||||
const dictStore = useDictStore()
|
||||
const data = dictDataList
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const columns = reactive<ColumnProps<Dict.ResDictData>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
width: 160,
|
||||
search: {
|
||||
el: 'input',
|
||||
props: {
|
||||
placeholder: '请输入名称'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: '编码',
|
||||
width: 160,
|
||||
search: {
|
||||
el: 'input',
|
||||
props: {
|
||||
placeholder: '请输入编码'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'value',
|
||||
label: '值',
|
||||
width: 160
|
||||
},
|
||||
{
|
||||
prop: 'level',
|
||||
label: '事件等级',
|
||||
width: 100,
|
||||
render: scope => {
|
||||
return (
|
||||
<>
|
||||
{scope.row.level === 0 || scope.row.level === null || scope.row.level === undefined ?
|
||||
(<span>—</span>) :
|
||||
(<el-tag type={scope.row.level === 1 ? 'info' : scope.row.level === 2 ? 'warning' : 'danger'}>
|
||||
{scope.row.level === 1 ? '普通' : scope.row.level === 2 ? '警告' : '危险'}
|
||||
</el-tag>)
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '状态',
|
||||
enum: dictStore.getDictData('status'),
|
||||
search: {
|
||||
el: 'tree-select',
|
||||
props: { filterable: true }
|
||||
},
|
||||
fieldNames: { label: 'label', value: 'code' },
|
||||
render: scope => {
|
||||
return (
|
||||
<>
|
||||
{
|
||||
<el-tag type={scope.row.state ? 'success' : 'danger'} > {scope.row.state ? '正常' : '禁用'} </el-tag>
|
||||
}
|
||||
</>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
props: { type: 'daterange', valueFormat: 'YYYY-MM-DD' }
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
width: 330
|
||||
},
|
||||
])
|
||||
|
||||
const { dialogVisible, dialogType, dialogForm } = useCount();
|
||||
function useCount() {
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('新增')
|
||||
|
||||
const dialogForm = ref({
|
||||
id: "",
|
||||
name: "",
|
||||
code: "",
|
||||
value: "",
|
||||
sort: 1,
|
||||
state: 1, // 状态:0-删除 1-正常
|
||||
})
|
||||
|
||||
return { dialogVisible, dialogType, dialogForm };
|
||||
}
|
||||
|
||||
// 打开 drawer(新增、查看、编辑)
|
||||
const openDrawer = (title: string, row: Partial<Dict.ResDictType> = {}) => {
|
||||
dialogVisible.value = true
|
||||
dialogType.value = title
|
||||
if (title === '编辑') {
|
||||
row && (dialogForm.value = row as { id: string; name: string; code: string; value: string; sort: number; state: number; });
|
||||
}
|
||||
}
|
||||
|
||||
// 批量添加字典数据
|
||||
const dialogRef = ref<InstanceType<typeof ImportExcel> | null>(null)
|
||||
const batchAdd = () => {
|
||||
const params = {
|
||||
title: '字典数据',
|
||||
tempApi: exportDictData,
|
||||
importApi: batchAddDictData,
|
||||
getTableList: proTable.value?.getTableList,
|
||||
}
|
||||
dialogRef.value?.acceptParams(params)
|
||||
}
|
||||
|
||||
// 导出字典数据
|
||||
const downloadFile = async () => {
|
||||
ElMessageBox.confirm('确认导出字典数据?', '温馨提示', { type: 'warning' }).then(() =>
|
||||
useDownload(exportDictData, '字典数据列表', proTable.value?.searchParam),
|
||||
)
|
||||
}
|
||||
|
||||
// 批量删除字典数据
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deleteDictData, { id }, '删除所选字典数据')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除字典数据
|
||||
const handleDelete = async (params: Dict.ResDictType) => {
|
||||
await useHandleData(deleteDictData, { id: [params.id] }, `删除【${params.name}】字典数据`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
//清空dialogForm中的值
|
||||
dialogForm.value = {
|
||||
id: "",
|
||||
name: "",
|
||||
code: "",
|
||||
value: "",
|
||||
sort: 1,
|
||||
state: 1,
|
||||
}
|
||||
}
|
||||
|
||||
const save = async () => {
|
||||
if (dialogType.value === '新增') {
|
||||
await useHandleData(addDictData, dialogForm.value, '新增字典数据')
|
||||
} else {
|
||||
await useHandleData(updateDictData, dialogForm.value, '编辑字典数据')
|
||||
}
|
||||
close()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
224
frontend/src/views/system/dict/index.vue
Normal file
224
frontend/src/views/system/dict/index.vue
Normal file
@@ -0,0 +1,224 @@
|
||||
<template>
|
||||
<div class="table-box">
|
||||
<ProTable :columns="columns" :data="data" :request-api="getDictTypeList">
|
||||
<template #tableHeader="scope">
|
||||
<el-button type="primary" :icon="CirclePlus" @click="openDrawer('新增')">新增</el-button>
|
||||
<el-button type="primary" :icon="Download" plain @click="downloadFile">导出</el-button>
|
||||
<el-button type="danger" :icon="Delete" plain :disabled="!scope.isSelected"
|
||||
@click="batchDelete(scope.selectedListIds)">
|
||||
批量删除
|
||||
</el-button>
|
||||
</template>
|
||||
|
||||
<template #operation="scope">
|
||||
<el-button type="primary" link :icon="View" @click="toDictData(scope.row)">查看</el-button>
|
||||
<el-button type="primary" link :icon="EditPen" @click="openDrawer('编辑', scope.row)">编辑</el-button>
|
||||
<el-button type="primary" link :icon="Delete" @click="handleDelete(scope.row)">删除</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
|
||||
<el-dialog v-model="dialogVisible" :title="dialogType === '新增' ? '新增字典类型' : '编辑字典类型'" v-bind="dialogSmall">
|
||||
<div>
|
||||
<el-form :model="dialogForm">
|
||||
<el-form-item label="类型名称" :label-width="100">
|
||||
<el-input v-model="dialogForm.name" placeholder="请输入" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型编码" :label-width="100">
|
||||
<el-input v-model="dialogForm.code" placeholder="请输入" autocomplete="off" />
|
||||
</el-form-item>
|
||||
<el-form-item label="显示排序" :label-width="100">
|
||||
<el-input-number v-model="dialogForm.sort" :min="1" :max="100" />
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" :label-width="100">
|
||||
<el-radio-group v-model.number="dialogForm.state">
|
||||
<el-radio v-for="item in dictStore.getDictData('status')" :key="item.id" :value="item.code">{{ item.label
|
||||
}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" :label-width="100">
|
||||
<el-input v-model="dialogForm.remark" placeholder="请输入备注" autocomplete="off" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<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="tsx" name="dict">
|
||||
import { CirclePlus, Delete, EditPen, Download, View } from '@element-plus/icons-vue'
|
||||
import { Dict } from '@/api/system/dict/interface'
|
||||
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
// import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||
import { dialogSmall } from '@/utils/elementBind'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
// import { useAuthButtons } from '@/hooks/useAuthButtons'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { dictTypeList } from '@/api/system/dict/dictExample'
|
||||
import {
|
||||
getDictTypeList,
|
||||
addDictType,
|
||||
updateDictType,
|
||||
exportDictType,
|
||||
deleteDictType
|
||||
} from '@/api/system/dict'
|
||||
|
||||
|
||||
const dictStore = useDictStore()
|
||||
// const BUTTONS = useAuthButtons()
|
||||
const router = useRouter()
|
||||
const data = dictTypeList
|
||||
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '类型名称',
|
||||
width: 160,
|
||||
search: {
|
||||
el: 'input',
|
||||
props: {
|
||||
placeholder: '请输入字典名称'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'code',
|
||||
label: '类型编码',
|
||||
width: 160,
|
||||
search: {
|
||||
el: 'input',
|
||||
props: {
|
||||
placeholder: '请输入字典编码'
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'state',
|
||||
label: '状态',
|
||||
enum: dictStore.getDictData('status'),
|
||||
search: {
|
||||
el: 'tree-select',
|
||||
props: { filterable: true }
|
||||
},
|
||||
fieldNames: { label: 'label', value: 'code' },
|
||||
render: scope => {
|
||||
return (
|
||||
<>
|
||||
{
|
||||
<el-tag type={scope.row.state ? 'success' : 'danger'} > {scope.row.state ? '正常' : '禁用'} </el-tag>
|
||||
}
|
||||
</>
|
||||
)
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '描述',
|
||||
width: 200,
|
||||
},
|
||||
{
|
||||
prop: 'createTime',
|
||||
label: '创建时间',
|
||||
width: 180,
|
||||
search: {
|
||||
el: 'date-picker',
|
||||
props: { type: 'daterange', valueFormat: 'YYYY-MM-DD' }
|
||||
}
|
||||
},
|
||||
{
|
||||
prop: 'operation',
|
||||
label: '操作',
|
||||
fixed: 'right',
|
||||
width: 330
|
||||
},
|
||||
])
|
||||
|
||||
const { dialogVisible, dialogType, dialogForm } = useCount();
|
||||
function useCount() {
|
||||
const dialogVisible = ref(false)
|
||||
const dialogType = ref('新增')
|
||||
|
||||
const dialogForm = ref({
|
||||
id: "",
|
||||
name: "",
|
||||
code: "",
|
||||
sort: 1,
|
||||
state: 1, // 状态:0-删除 1-正常
|
||||
remark: ""
|
||||
})
|
||||
|
||||
return { dialogVisible, dialogType, dialogForm };
|
||||
}
|
||||
|
||||
// 打开 drawer(新增、查看、编辑)
|
||||
const openDrawer = (title: string, row: Partial<Dict.ResDictType> = {}) => {
|
||||
dialogVisible.value = true
|
||||
dialogType.value = title
|
||||
if (title === '编辑') {
|
||||
row && (dialogForm.value = row as { id: string; name: string; code: string; sort: number; state: number; remark: string; });
|
||||
}
|
||||
}
|
||||
|
||||
// 导出字典类型
|
||||
const downloadFile = async () => {
|
||||
ElMessageBox.confirm('确认导出字典类型数据?', '温馨提示', { type: 'warning' }).then(() =>
|
||||
useDownload(exportDictType, '字典类型列表', proTable.value?.searchParam),
|
||||
)
|
||||
}
|
||||
|
||||
// 批量删除字典类型
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deleteDictType, { id }, '删除所选字典类型')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除字典类型
|
||||
const handleDelete = async (params: Dict.ResDictType) => {
|
||||
await useHandleData(deleteDictType, { id: [params.id] }, `删除【${params.name}】字典类型`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
//查看字典类型包含的字典数据
|
||||
const toDictData = (row: Dict.ResDictType) => {
|
||||
router.push({ name: 'dictData', params: { id: row.id, code: row.code } })
|
||||
}
|
||||
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
//清空dialogForm中的值
|
||||
dialogForm.value = {
|
||||
id: "",
|
||||
name: "",
|
||||
code: "",
|
||||
state: 1,
|
||||
sort: 1,
|
||||
remark: ""
|
||||
}
|
||||
}
|
||||
|
||||
const save =async () => {
|
||||
if (dialogType.value === '新增') {
|
||||
await useHandleData(addDictType, dialogForm.value, '新增字典类型')
|
||||
} else {
|
||||
await useHandleData(updateDictType, dialogForm.value, '编辑字典类型')
|
||||
}
|
||||
close()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped></style>
|
||||
Reference in New Issue
Block a user