微调
This commit is contained in:
@@ -2,43 +2,44 @@ import type { ReqPage, ResPage } from '@/api/interface'
|
||||
|
||||
// 检测源模块
|
||||
export namespace TestSource {
|
||||
|
||||
/**
|
||||
* 检测脚本表格分页查询参数
|
||||
*/
|
||||
export interface ReqTestSourceParams extends ReqPage{
|
||||
id: string; // 装置序号id 必填
|
||||
name: string;
|
||||
pattern: string;
|
||||
}
|
||||
/**
|
||||
* 检测源表格分页查询参数
|
||||
*/
|
||||
export interface ReqTestSourceParams extends ReqPage {
|
||||
id: string
|
||||
name: string
|
||||
pattern: string
|
||||
}
|
||||
|
||||
// 检测源接口
|
||||
export interface ResTestSource {
|
||||
id: string; //检测源ID
|
||||
name?: string; //检测源名称(检测源类型 + 设备类型 + 数字自动生成)
|
||||
pattern: string;//检测源模式(字典表Code字段,数字、模拟、比对)
|
||||
type: string; //检测源类型(字典表Code字段,标准源、高精度设备)
|
||||
devType: string;//检测源设备类型(字典表Code字段)
|
||||
parameter?: string;//源参数(JSON字符串)
|
||||
state:number;//
|
||||
createBy?: string;
|
||||
createTime?: string;
|
||||
updateBy?: string;
|
||||
updateTime?: string;
|
||||
id: string
|
||||
name?: string
|
||||
pattern: string
|
||||
type: string
|
||||
devType: string
|
||||
maxVoltage?: number
|
||||
maxCurrent?: number
|
||||
parameter?: string
|
||||
state: number
|
||||
createBy?: string
|
||||
createTime?: string
|
||||
updateBy?: string
|
||||
updateTime?: string
|
||||
}
|
||||
|
||||
/* 检测脚本查询分页返回的对象;
|
||||
*/
|
||||
export interface ResTestSourcePage extends ResPage<ResTestSource> {
|
||||
|
||||
}
|
||||
export interface ParameterType{
|
||||
id:string;
|
||||
type:string;
|
||||
desc:string;
|
||||
value:string|null;
|
||||
sort:number;
|
||||
pId:string;
|
||||
children?:ParameterType[];
|
||||
|
||||
/*
|
||||
* 检测源查询分页返回的对象
|
||||
*/
|
||||
export interface ResTestSourcePage extends ResPage<ResTestSource> {}
|
||||
|
||||
export interface ParameterType {
|
||||
id: string
|
||||
type: string
|
||||
desc: string
|
||||
value: string | null
|
||||
sort: number
|
||||
pId: string
|
||||
children?: ParameterType[]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,6 +206,20 @@ function handleWarningError(stepRef: any, logRef: any, message: string) {
|
||||
watch(webMsgSend, function (newValue, oldValue) {
|
||||
if (testStatus.value !== 'waiting') {
|
||||
switch (newValue.requestId) {
|
||||
case 'overloadTest':
|
||||
if (newValue.code === 1) {
|
||||
handleFatalError(step1, step1InitLog, '电压过载!')
|
||||
}
|
||||
if (newValue.code === 2) {
|
||||
handleFatalError(step1, step1InitLog, '电流过载!')
|
||||
}
|
||||
if (newValue.code === 3) {
|
||||
handleFatalError(step1, step1InitLog, '电压和电流过载!')
|
||||
}
|
||||
if (newValue.code === 4) {
|
||||
handleFatalError(step1, step1InitLog, '过载检测成功!')
|
||||
}
|
||||
break;
|
||||
case 'yjc_ytxjy':
|
||||
switch (newValue.operateCode) {
|
||||
case 'INIT_GATHER':
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
class="form-three"
|
||||
>
|
||||
<el-form-item label="设备类型" prop="devType">
|
||||
<el-select v-model="formContent.devType" placeholder="请选择源型号">
|
||||
<el-select v-model="formContent.devType" placeholder="请选择源设备类型">
|
||||
<el-option
|
||||
v-for="item in dictStore.getDictData(dictTypeCode)"
|
||||
:key="item.id"
|
||||
@@ -29,6 +29,24 @@
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="最大电压" prop="maxVoltage">
|
||||
<el-input-number
|
||||
v-model="formContent.maxVoltage"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="最大电流" prop="maxCurrent">
|
||||
<el-input-number
|
||||
v-model="formContent.maxCurrent"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:step="0.1"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
@@ -40,7 +58,7 @@
|
||||
/>
|
||||
<template #footer>
|
||||
<div>
|
||||
<el-button :disabled="tableIsDisable" @click="close()">取 消</el-button>
|
||||
<el-button :disabled="tableIsDisable" @click="close()">取消</el-button>
|
||||
<el-button :disabled="tableIsDisable" type="primary" @click="save()">保存</el-button>
|
||||
</div>
|
||||
</template>
|
||||
@@ -49,12 +67,12 @@
|
||||
|
||||
<script lang="ts" setup name="ErrorSystemDialog">
|
||||
import { ElMessage, type FormItemRule } from 'element-plus'
|
||||
import { computed, Ref, ref } from 'vue'
|
||||
import { computed, ref, type Ref } from 'vue'
|
||||
import { dialogBig } from '@/utils/elementBind'
|
||||
import { addTestSource, getTestSourceById, updateTestSource } from '@/api/device/testSource/index'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import { type TestSource } from '@/api/device/interface/testSource'
|
||||
// 定义弹出组件元信息
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
|
||||
const dialogFormRef = ref()
|
||||
const dictStore = useDictStore()
|
||||
const mode = ref()
|
||||
@@ -71,13 +89,15 @@ function useMetaInfo() {
|
||||
parameter: '',
|
||||
type: '',
|
||||
devType: '',
|
||||
maxVoltage: undefined,
|
||||
maxCurrent: undefined,
|
||||
state: 1
|
||||
})
|
||||
return { dialogVisible, titleType, formContent }
|
||||
}
|
||||
|
||||
const { dialogVisible, titleType, formContent } = useMetaInfo()
|
||||
// 清空formContent
|
||||
|
||||
const resetFormContent = () => {
|
||||
formContent.value = {
|
||||
id: '',
|
||||
@@ -85,11 +105,13 @@ const resetFormContent = () => {
|
||||
parameter: '',
|
||||
type: '',
|
||||
devType: '',
|
||||
maxVoltage: undefined,
|
||||
maxCurrent: undefined,
|
||||
state: 1
|
||||
}
|
||||
}
|
||||
|
||||
let dialogTitle = computed(() => {
|
||||
const dialogTitle = computed(() => {
|
||||
switch (titleType.value) {
|
||||
case 'add':
|
||||
tableIsDisable.value = false
|
||||
@@ -101,45 +123,52 @@ let dialogTitle = computed(() => {
|
||||
tableIsDisable.value = true
|
||||
return '查看检测源'
|
||||
default:
|
||||
return '' // 默认情况,可选
|
||||
return ''
|
||||
}
|
||||
})
|
||||
|
||||
let dictTypeCode = computed(() => {
|
||||
const dictTypeCode = computed(() => {
|
||||
return 'S_Dev_Type_' + dictStore.getDictData('Pattern').find(item => item.id === modeId.value)?.code
|
||||
})
|
||||
// 定义规则
|
||||
|
||||
const validateNonNegative = (label: string) => {
|
||||
return (_rule: FormItemRule, value: number | undefined, callback: (error?: Error) => void) => {
|
||||
if (value != null && value < 0) {
|
||||
callback(new Error(`${label} cannot be negative`))
|
||||
return
|
||||
}
|
||||
callback()
|
||||
}
|
||||
}
|
||||
|
||||
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
|
||||
name: [{ required: true, message: '检测源名称必填!', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '检测源名称必填', trigger: 'blur' }],
|
||||
devType: [{ required: true, message: '请选择一项设备类型', trigger: 'change' }],
|
||||
type: [{ required: true, message: '请选择一项检测源类型', trigger: 'change ' }]
|
||||
type: [{ required: true, message: '请选择一项检测源类型', trigger: 'change' }],
|
||||
maxVoltage: [{ validator: validateNonNegative('最大电压'), trigger: 'change' }],
|
||||
maxCurrent: [{ validator: validateNonNegative('最大电流'), trigger: 'change' }]
|
||||
})
|
||||
|
||||
// 关闭弹窗
|
||||
const close = () => {
|
||||
dialogVisible.value = false
|
||||
// 清空dialogForm中的值
|
||||
resetFormContent()
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
parameterTable.value?.clearData()
|
||||
}
|
||||
|
||||
// 保存数据
|
||||
const save = () => {
|
||||
try {
|
||||
dialogFormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
if (formContent.value.id) {
|
||||
await updateTestSource(formContent.value)
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功` })
|
||||
} else {
|
||||
await addTestSource(formContent.value)
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功!` })
|
||||
ElMessage.success({ message: `${dialogTitle.value}成功` })
|
||||
}
|
||||
close()
|
||||
// 刷新表格
|
||||
await props.refreshTable!()
|
||||
await props.refreshTable?.()
|
||||
}
|
||||
})
|
||||
} catch (err) {
|
||||
@@ -147,7 +176,6 @@ const save = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 打开弹窗,可能是新增,也可能是编辑
|
||||
const open = async (sign: string, data: TestSource.ResTestSource, currentMode: string) => {
|
||||
titleType.value = sign
|
||||
dialogVisible.value = true
|
||||
@@ -155,13 +183,25 @@ const open = async (sign: string, data: TestSource.ResTestSource, currentMode: s
|
||||
modeId.value = dictStore.getDictData('Pattern').find(item => item.name === currentMode)?.id
|
||||
if (data.id) {
|
||||
const result = await getTestSourceById(data)
|
||||
if (result && result.data) {
|
||||
formContent.value = result.data as TestSource.ResTestSource
|
||||
const sourceData = (result?.data ?? {}) as Partial<TestSource.ResTestSource>
|
||||
formContent.value = {
|
||||
id: sourceData.id ?? data.id,
|
||||
pattern: sourceData.pattern ?? modeId.value,
|
||||
parameter: sourceData.parameter ?? '',
|
||||
type: sourceData.type ?? '',
|
||||
devType: sourceData.devType ?? '',
|
||||
maxVoltage: sourceData.maxVoltage ?? undefined,
|
||||
maxCurrent: sourceData.maxCurrent ?? undefined,
|
||||
state: sourceData.state ?? 1,
|
||||
name: sourceData.name,
|
||||
createBy: sourceData.createBy,
|
||||
createTime: sourceData.createTime,
|
||||
updateBy: sourceData.updateBy,
|
||||
updateTime: sourceData.updateTime
|
||||
}
|
||||
} else {
|
||||
resetFormContent()
|
||||
}
|
||||
// 重置表单
|
||||
dialogFormRef.value?.resetFields()
|
||||
}
|
||||
|
||||
@@ -169,7 +209,6 @@ const changeParameter = (parameterArr: any) => {
|
||||
formContent.value.parameter = JSON.stringify(parameterArr)
|
||||
}
|
||||
|
||||
// 对外映射
|
||||
defineExpose({ open })
|
||||
const props = defineProps<{
|
||||
refreshTable: (() => Promise<void>) | undefined
|
||||
|
||||
@@ -1,115 +1,123 @@
|
||||
<template>
|
||||
<div class='table-box'>
|
||||
<ProTable
|
||||
ref='proTable'
|
||||
:columns='columns'
|
||||
:request-api="getTableList"
|
||||
>
|
||||
<!-- :data='testSourceData' 如果要显示静态数据,就切换该配置-->
|
||||
<!-- 表格 header 按钮 -->
|
||||
<template #tableHeader='scope'>
|
||||
<el-button v-auth.testSource="'add'" type='primary' :icon='CirclePlus' @click="openDialog('add')">新增</el-button>
|
||||
<el-button v-auth.testSource="'delete'" type='danger' :icon='Delete'
|
||||
plain :disabled='!scope.isSelected' @click='batchDelete(scope.selectedListIds)'>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
<!-- 表格操作 -->
|
||||
<template #operation='scope'>
|
||||
<el-button v-auth.testSource="'view'" type='primary' link :icon='View' @click="openDialog('view', scope.row)">查看</el-button>
|
||||
<el-button v-auth.testSource="'edit'" type='primary' link :icon='EditPen' @click="openDialog('edit', scope.row)">编辑</el-button>
|
||||
<el-button v-auth.testSource="'delete'" type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
|
||||
</template>
|
||||
|
||||
</ProTable>
|
||||
<div class="table-box">
|
||||
<ProTable ref="proTable" :columns="columns" :request-api="getTableList">
|
||||
<template #tableHeader="scope">
|
||||
<el-button v-auth.testSource="'add'" type="primary" :icon="CirclePlus" @click="openDialog('add')">
|
||||
新增
|
||||
</el-button>
|
||||
<el-button
|
||||
v-auth.testSource="'delete'"
|
||||
type="danger"
|
||||
:icon="Delete"
|
||||
plain
|
||||
:disabled="!scope.isSelected"
|
||||
@click="batchDelete(scope.selectedListIds)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
<template #operation="scope">
|
||||
<el-button v-auth.testSource="'view'" type="primary" link :icon="View" @click="openDialog('view', scope.row)">
|
||||
查看
|
||||
</el-button>
|
||||
<el-button v-auth.testSource="'edit'" type="primary" link :icon="EditPen" @click="openDialog('edit', scope.row)">
|
||||
编辑
|
||||
</el-button>
|
||||
<el-button
|
||||
v-auth.testSource="'delete'"
|
||||
type="primary"
|
||||
link
|
||||
:icon="Delete"
|
||||
@click="handleDelete(scope.row)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</ProTable>
|
||||
</div>
|
||||
<TestSourcePopup :refresh-table='proTable?.getTableList' ref='testSourcePopup' />
|
||||
<TestSourcePopup :refresh-table="proTable?.getTableList" ref="testSourcePopup" />
|
||||
</template>
|
||||
|
||||
</template>
|
||||
|
||||
<script setup lang='tsx' name='useRole'>
|
||||
import { type TestSource } from '@/api/device/interface/testSource'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import { useDownload } from '@/hooks/useDownload'
|
||||
import { useAuthButtons } from '@/hooks/useAuthButtons'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import ImportExcel from '@/components/ImportExcel/index.vue'
|
||||
import type{ ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import TestSourcePopup from './components/testSourcePopup.vue'
|
||||
import {
|
||||
getTestSourceList,deleteTestSource,
|
||||
} from '@/api/device/testSource/index'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
|
||||
defineOptions({
|
||||
name: 'testSource'
|
||||
})
|
||||
const testSourcePopup = ref()
|
||||
const dictStore = useDictStore()
|
||||
const modeStore = useModeStore();
|
||||
// ProTable 实例
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const getTableList = (params: any) => {
|
||||
<script setup lang="tsx" name="useRole">
|
||||
import { type TestSource } from '@/api/device/interface/testSource'
|
||||
import { useHandleData } from '@/hooks/useHandleData'
|
||||
import ProTable from '@/components/ProTable/index.vue'
|
||||
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
|
||||
import { CirclePlus, Delete, EditPen, View } from '@element-plus/icons-vue'
|
||||
import { useDictStore } from '@/stores/modules/dict'
|
||||
import TestSourcePopup from './components/testSourcePopup.vue'
|
||||
import { getTestSourceList, deleteTestSource } from '@/api/device/testSource/index'
|
||||
import { reactive, ref } from 'vue'
|
||||
import { useModeStore } from '@/stores/modules/mode'
|
||||
|
||||
let newParams = JSON.parse(JSON.stringify(params))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id//获取数据字典中对应的id
|
||||
newParams.pattern = patternId
|
||||
return getTestSourceList(newParams)
|
||||
defineOptions({
|
||||
name: 'testSource'
|
||||
})
|
||||
|
||||
const testSourcePopup = ref()
|
||||
const dictStore = useDictStore()
|
||||
const modeStore = useModeStore()
|
||||
const proTable = ref<ProTableInstance>()
|
||||
|
||||
const getTableList = (params: any) => {
|
||||
const newParams = JSON.parse(JSON.stringify(params))
|
||||
const patternId = dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.id
|
||||
newParams.pattern = patternId
|
||||
return getTestSourceList(newParams)
|
||||
}
|
||||
|
||||
// 表格配置项
|
||||
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 ,
|
||||
},
|
||||
const columns = reactive<ColumnProps<TestSource.ResTestSource>[]>([
|
||||
{ type: 'selection', fixed: 'left', width: 70 },
|
||||
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
|
||||
{
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 300,
|
||||
prop: 'name',
|
||||
label: '名称',
|
||||
search: { el: 'input' },
|
||||
minWidth: 300
|
||||
},
|
||||
{
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
enum: dictStore.getDictData('S_Dev_Type_'+dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.code),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 250,
|
||||
prop: 'devType',
|
||||
label: '设备类型',
|
||||
enum: dictStore.getDictData(
|
||||
'S_Dev_Type_' + dictStore.getDictData('Pattern').find(item => item.name === modeStore.currentMode)?.code
|
||||
),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 250
|
||||
},
|
||||
{
|
||||
prop: 'type',
|
||||
label: '检测源类型',
|
||||
enum: dictStore.getDictData('Pq_Source_Type'),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 150,
|
||||
prop: 'type',
|
||||
label: '检测源类型',
|
||||
enum: dictStore.getDictData('Pq_Source_Type'),
|
||||
fieldNames: { label: 'name', value: 'id' },
|
||||
search: { el: 'select' },
|
||||
minWidth: 150
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
|
||||
])
|
||||
|
||||
{
|
||||
prop: 'maxVoltage',
|
||||
label: '最大电压(V)',
|
||||
minWidth: 140
|
||||
},
|
||||
{
|
||||
prop: 'maxCurrent',
|
||||
label: '最大电流(A)',
|
||||
minWidth: 140
|
||||
},
|
||||
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 }
|
||||
])
|
||||
|
||||
// 打开 drawer(新增、编辑)
|
||||
const openDialog = (titleType: string, row: Partial<TestSource.ResTestSource> = {}) => {
|
||||
|
||||
testSourcePopup.value?.open(titleType, row,modeStore.currentMode)
|
||||
testSourcePopup.value?.open(titleType, row, modeStore.currentMode)
|
||||
}
|
||||
|
||||
|
||||
// 批量删除设备
|
||||
const batchDelete = async (id: string[]) => {
|
||||
await useHandleData(deleteTestSource, id, '删除所选检测源')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
await useHandleData(deleteTestSource, id, '删除所选检测源')
|
||||
proTable.value?.clearSelection()
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
// 删除设备
|
||||
const handleDelete = async (params: TestSource.ResTestSource) => {
|
||||
await useHandleData(deleteTestSource, [params.id], `删除【${params.name}】检测源`)
|
||||
proTable.value?.getTableList()
|
||||
await useHandleData(deleteTestSource, [params.id], `删除【${params.name}】检测源`)
|
||||
proTable.value?.getTableList()
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user