电能质量字典界面

This commit is contained in:
sjl
2024-11-06 08:45:51 +08:00
parent 29bc14d3e1
commit 51f408ce7a
4 changed files with 92 additions and 46 deletions

View File

@@ -3,19 +3,6 @@ import type { ReqPage } from '@/api/interface'
// 被检设备模块 // 被检设备模块
export namespace Device { export namespace Device {
// 被检设备列表
export interface ResDeviceList {
id: string; //被检设备ID
deviceName: string; //检测设备名称
deviceType: string; //检测设备类型
deviceChannels: string;//设备通道数
PlanName: string; //所属计划名称
deviceUn: string; //设备额定电压
deviceIn: string; //设备额定电流
deviceCompany: string;//设备厂家
deviceModel: string; //设备模式 模拟 数字 比对
}
// 被检设备参数 // 被检设备参数
export interface ReqDeviceParams extends ReqPage { export interface ReqDeviceParams extends ReqPage {
id: string; //被检设备ID id: string; //被检设备ID
@@ -30,7 +17,7 @@ export namespace Device {
} }
// 被检设备列表 // 被检设备列表
export interface DeviceList { export interface ResDeviceList {
id: string; //装置序号ID id: string; //装置序号ID
name: string; //设备名称 name: string; //设备名称
pattern?: string; //设备模式 模拟 数字 比对 pattern?: string; //设备模式 模拟 数字 比对

View File

@@ -100,7 +100,7 @@ export namespace Dict {
name: string;//指标名称 name: string;//指标名称
phase: string;//相别 phase: string;//相别
dataType: string;//数据模型(epd、pqd...) dataType: string;//数据模型(epd、pqd...)
otherName?: string | null;//别名默认与Name相同主要是为了适配不同数据库里面字段 otherName?: string ;//别名默认与Name相同主要是为了适配不同数据库里面字段
showName?:string | null;//显示名称 showName?:string | null;//显示名称
sort:number;//排序 sort:number;//排序
type?: string | null;//指标数据类型(整型、浮点型、枚举型这些的) type?: string | null;//指标数据类型(整型、浮点型、枚举型这些的)

View File

@@ -25,9 +25,9 @@
<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('phase')" v-for="item in dictStore.getDictData('High_Cate')"
:key="item.id" :key="item.id"
:name="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
@@ -50,12 +50,11 @@
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item label='数据统计类型' :label-width='140' prop='statMethod'> <el-form-item label='数据统计类型' :label-width='140' prop='statMethod'>
<el-select v-model="selectedStatMethods" multiple placeholder="请选择数据统计类型">
<el-select v-model="formContent.statMethod" multiple placeholder="请选择数据统计类型">
<el-option <el-option
v-for="item in dictStore.getDictData('statMethod')" v-for="item in dictStore.getDictData('Event_Type')"
:key="item.value" :key="item.value"
:name="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
@@ -66,9 +65,9 @@
<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('resourcesId')" v-for="item in dictStore.getDictData('Dev_Series')"
:key="item.id" :key="item.id"
:name="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
@@ -76,9 +75,9 @@
<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('classId')" v-for="item in dictStore.getDictData('High_Cate')"
:key="item.id" :key="item.id"
:name="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
@@ -94,7 +93,7 @@
<el-option <el-option
v-for="item in dictStore.getDictData('formula')" v-for="item in dictStore.getDictData('formula')"
:key="item.id" :key="item.id"
:name="item.name" :label="item.name"
:value="item.code" :value="item.code"
/> />
</el-select> </el-select>
@@ -168,8 +167,9 @@
import { addDictPq, updateDictPq } from '@/api/system/dictionary/dictPq' import { addDictPq, updateDictPq } from '@/api/system/dictionary/dictPq'
import { computed, type Ref, ref } from 'vue'; import { computed, type Ref, ref } from 'vue';
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()
const selectedStatMethods = ref<string[]>([])
// 定义弹出组件元信息 // 定义弹出组件元信息
const dialogFormRef = ref() const dialogFormRef = ref()
function useMetaInfo() { function useMetaInfo() {
@@ -213,7 +213,6 @@
classId: [{ required: true, message: '数据库表名必选!', trigger: 'change' }], classId: [{ required: true, message: '数据库表名必选!', trigger: 'change' }],
}) })
// 关闭弹窗 // 关闭弹窗
const close = () => { const close = () => {
dialogVisible.value = false dialogVisible.value = false
@@ -221,6 +220,7 @@
resetFormContent() resetFormContent()
// 重置表单 // 重置表单
dialogFormRef.value?.resetFields() dialogFormRef.value?.resetFields()
selectedStatMethods.value = []
} }
// 保存数据 // 保存数据
@@ -228,13 +228,26 @@
try { try {
dialogFormRef.value?.validate(async (valid: boolean) => { dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
formContent.value.statMethod = selectedStatMethods.value.join(',')
if (formContent.value.id) { if (formContent.value.id) {
await updateDictPq(formContent.value) updateDictPq(formContent.value).then(result => {
} else { if(result.code != 'A0000'){
await addDictPq(formContent.value) ElMessage.error({ message: result.message})
} }else{
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })
}
})
} else {
addDictPq(formContent.value).then(result => {
if(result.code != 'A0000'){
ElMessage.error({ message: result.message})
}else{
ElMessage.success({ message: `${dialogTitle.value}成功!` })
}
})
}
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
close() close()
// 刷新表格 // 刷新表格
await props.refreshTable!() await props.refreshTable!()
@@ -249,7 +262,8 @@
const open = (sign: string, data: Dict.ResDictPq) => { const open = (sign: string, data: Dict.ResDictPq) => {
titleType.value = sign titleType.value = sign
dialogVisible.value = true dialogVisible.value = true
console.log('123456',dictStore) console.log(dictStore)
selectedStatMethods.value = data.statMethod ? data.statMethod.split(',') : []
if (data.id) { if (data.id) {
formContent.value = { ...data } formContent.value = { ...data }
} else { } else {
@@ -263,4 +277,6 @@
refreshTable: (() => Promise<void>) | undefined; refreshTable: (() => Promise<void>) | undefined;
}>() }>()
</script> </script>

View File

@@ -69,6 +69,10 @@
search: { search: {
el: 'input', el: 'input',
}, },
render: (scope) => {
const codes = scope.row.otherName;
return codes || '/';
}
}, },
{ {
prop: 'showName', prop: 'showName',
@@ -77,56 +81,95 @@
search: { search: {
el: 'input', el: 'input',
}, },
render: (scope) => {
const codes = scope.row.showName;
return codes || '/';
}
}, },
{ {
prop: 'phase', prop: 'phase',
label: '相别', label: '相别',
width: 180, width: 180,
enum: dictStore.getDictData('High_Cate'),
fieldNames: { label: 'name', value: 'code' },
}, },
{ {
prop: 'phase', prop: 'unit',
label: '单位', label: '单位',
width: 180, width: 180,
render: (scope) => {
const codes = scope.row.unit;
return codes || '/';
}
}, },
{ {
prop: 'type', prop: 'type',
label: '指标数据类型', label: '指标数据类型',
width: 180, width: 180,
render: (scope) => {
const codes = scope.row.type;
return codes || '/';
}
}, },
{ {
prop: 'harmStart', prop: 'harmStart',
label: '数据谐波次数', label: '数据谐波次数',
width: 180, width: 180,
render: (scope) => { render: (scope) => {
return scope.row.harmStart return (scope.row.harmStart && scope.row.harmEnd)
? `${scope.row.harmStart}-${scope.row.harmEnd}` ? `${scope.row.harmStart}-${scope.row.harmEnd}`
: '/'; // 如果 harmStart 为空,返回 \ : '/'; // 如果 harmStart 或 harmEnd 为空,返回 '/'
}, },
}, },
{ {
prop: 'statMethod', prop: 'statMethod',
label: '数据统计类型', label: '数据统计类型',
width: 180, width: 250,
render: (row) => { enum: dictStore.getDictData('Event_Type'),
const methods = row.statMethod || []; // 确保statMethod存在 fieldNames: { label: 'name', value: 'code' },
if (methods.length === 0) { render: (scope) => {
return '/'; // 空值时显示/ // 假设 statMethod 是一个数组,包含多个 'code' 值
} else if (methods.length > 2) { const codes = scope.row.statMethod; // 获取当前行的 statMethod 字段
return methods.join(', '); // 超过两个用逗号分隔 //console.log('codes',codes)
} else { if (!codes) {
return methods.join(' '); // 少于等于两个时用空格分隔 return '/'; // 如果 statMethod 为 undefined 或 null返回 '/'
} }
// 确保 codes 是一个字符串
const codeString = Array.isArray(codes) ? codes.join(',') : codes;
const codeArray = codeString.split(',');
if (codeArray.length > 1) {
// 查找与每个 code 值匹配的 name然后拼接成逗号分割的字符串
//console.log('codeArray',codeArray)
const names = codeArray.map(code => {
const dictItem = dictStore.getDictData('Event_Type').find(item => item.code === code);
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
});
//console.log('names',names)
return names.join(', '); // 用逗号连接所有的 name
}
// 查找单个 code 对应的 name
const dictItem = dictStore.getDictData('Event_Type').find(item => item.code === codeArray[0]);
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
}, },
}, },
{ {
prop: 'classId', prop: 'classId',
label: '数据表表名', label: '数据表表名',
width: 180, width: 180,
enum: dictStore.getDictData('High_Cate'),
fieldNames: { label: 'name', value: 'code' },
}, },
{ {
prop: 'resourcesId', prop: 'resourcesId',
label: '报表数据来源', label: '报表数据来源',
width: 180, width: 180,
enum: dictStore.getDictData('Dev_Series'),
fieldNames: { label: 'name', value: 'code' },
render: (scope) => {
const codes = scope.row.resourcesId;
return codes || '/';
}
}, },
{ {
prop: 'operation', prop: 'operation',