Files
admin-govern/src/views/govern/manage/basic/dictionary.vue

152 lines
5.6 KiB
Vue
Raw Normal View History

2024-01-22 19:13:58 +08:00
<template>
2024-01-23 14:14:26 +08:00
<div class="default-main">
2024-01-22 19:13:58 +08:00
<TableHeader>
<template #select>
2024-01-23 14:14:26 +08:00
<el-form-item label="数据分类">
2024-01-22 19:13:58 +08:00
<el-select
2024-01-23 14:14:26 +08:00
v-model="tableStore.table.params.dataType"
2024-01-22 19:13:58 +08:00
multiple
filterable
collapse-tags
clearable
2024-01-23 14:14:26 +08:00
placeholder="请选择数据分类"
2024-01-22 19:13:58 +08:00
>
<el-option
2024-01-23 14:14:26 +08:00
v-for="item in DataTypeSelect"
:key="item.id"
:label="item.name"
:value="item.id"
2024-01-22 19:13:58 +08:00
></el-option>
</el-select>
</el-form-item>
2024-01-23 14:14:26 +08:00
<el-form-item label="数据存储">
2024-01-22 19:13:58 +08:00
<el-select
2024-01-23 14:14:26 +08:00
v-model="tableStore.table.params.classId"
2024-01-22 19:13:58 +08:00
multiple
filterable
collapse-tags
clearable
2024-01-23 14:14:26 +08:00
placeholder="请选择数据存储"
2024-01-22 19:13:58 +08:00
>
<el-option
2024-01-23 14:14:26 +08:00
v-for="item in DataSelect"
:key="item.id"
:label="item.name"
:value="item.id"
2024-01-22 19:13:58 +08:00
></el-option>
</el-select>
</el-form-item>
2024-01-23 14:14:26 +08:00
<el-form-item label="过滤筛选:">
<el-input
v-model="tableStore.table.params.searchValue"
placeholder="数据名称、别名、名称"
clearable
></el-input>
2024-01-22 19:13:58 +08:00
</el-form-item>
</template>
<template #operation>
2024-01-23 14:05:03 +08:00
<el-button :icon="Plus" type="primary" @click="addMenu" class="ml10">新增字典</el-button>
2024-01-22 19:13:58 +08:00
</template>
</TableHeader>
2024-01-23 14:14:26 +08:00
<Table ref="tableRef" />
<PopupDictionary ref="popupDictionary"></PopupDictionary>
2024-01-22 19:13:58 +08:00
</div>
</template>
2024-01-23 14:14:26 +08:00
<script setup lang="ts">
2024-01-22 19:13:58 +08:00
import { ref, onMounted, provide } from 'vue'
import TableStore from '@/utils/tableStore'
import Table from '@/components/table/index.vue'
import TableHeader from '@/components/table/header/index.vue'
import { useDictData } from '@/stores/dictData'
import PopupDictionary from './popupDictionary.vue'
2024-01-23 14:05:03 +08:00
import { ElMessage } from 'element-plus'
import { delCsDictData } from '@/api/system-boot/csDictData'
import { Plus } from '@element-plus/icons-vue'
2024-01-22 19:13:58 +08:00
defineOptions({
name: 'govern/manage/basic/dictionary'
})
const popupDictionary = ref()
const dictData = useDictData()
const DataSelect = dictData.getBasicData('Data')
const DataTypeSelect = dictData.getBasicData('Cs_Data_Type')
2024-01-22 19:56:30 +08:00
const ResourcesIdSelect = dictData.getBasicData('Data_Day')
2024-01-22 19:13:58 +08:00
const tableStore = new TableStore({
url: '/system-boot/csDictData/list',
method: 'POST',
column: [
{ title: '数据分类', field: 'dataTypeName' },
{ title: '数据名称', field: 'name' },
{ title: '别名', field: 'otherName' },
{ title: '展示名称', field: 'showName' },
{ title: '相别', field: 'phaseName' },
{ title: '单位', field: 'unit' },
{ title: '基础数据类型', field: 'type' },
{ title: '数据谐波次数', field: 'harmStart' },
{ title: '数据统计方法', field: 'statMethod' },
{ title: '数据存储', field: 'classIdName' },
2024-01-22 19:56:30 +08:00
{ title: '数据来源', field: 'resourcesIdName' },
2024-01-22 19:13:58 +08:00
{
title: '操作',
align: 'center',
width: '130',
render: 'buttons',
buttons: [
{
name: 'edit',
title: '编辑',
type: 'primary',
icon: 'el-icon-EditPen',
render: 'tipButton',
click: row => {
popupDictionary.value.open('编辑字典', row)
}
},
{
name: 'del',
title: '删除',
type: 'danger',
icon: 'el-icon-Delete',
render: 'confirmButton',
popconfirm: {
confirmButtonText: '确认',
cancelButtonText: '取消',
confirmButtonType: 'danger',
title: '确定删除吗?'
},
click: row => {
2024-01-23 14:14:26 +08:00
delCsDictData(row.id).then(res => {
ElMessage.success('删除成功')
2024-01-23 14:05:03 +08:00
tableStore.index()
})
2024-01-22 19:13:58 +08:00
}
}
]
}
],
loadCallback: () => {
tableStore.table.data.forEach((item: any) => {
item.classIdName = DataSelect.find((child: any) => child.id == item.classId)?.name || '/'
2024-01-22 19:56:30 +08:00
item.resourcesIdName = ResourcesIdSelect.find((child: any) => child.id == item.resourcesId)?.name || '/'
2024-01-22 19:13:58 +08:00
item.phaseName = item.phase === 'M' ? '/' : item.phase || '/'
for (let key in item) {
if (typeof item[key] !== 'number') {
item[key] = item[key] || '/'
}
}
})
}
})
2024-01-22 19:56:30 +08:00
tableStore.table.params.searchValue = ''
2024-01-22 19:13:58 +08:00
tableStore.table.params.dataType = ''
tableStore.table.params.classId = ''
provide('tableStore', tableStore)
onMounted(() => {
tableStore.index()
})
const addMenu = () => {
popupDictionary.value.open('新增字典')
}
</script>