检测脚本添加额定电压、额定电流 修改bug

This commit is contained in:
GGJ
2025-03-14 15:03:36 +08:00
parent 7caa4a5303
commit 410cfb0f7a
8 changed files with 171 additions and 108 deletions

View File

@@ -2,39 +2,37 @@ import type { ReqPage, ResPage } from '@/api/interface'
// 检测脚本模块
export namespace TestScript {
/**
* 检测脚本表格分页查询参数
*/
export interface ReqTestScriptParams extends ReqPage{
id: string; // 装置序号id 必填
name: string;
type: string;
pattern:string;
}
/**
* 检测脚本表格分页查询参数
*/
export interface ReqTestScriptParams extends ReqPage {
id: string // 装置序号id 必填
name: string
type: string
pattern: string
}
// 检测脚本接口
export interface ResTestScript {
id?: string; //检测脚本ID
name: string; //检测脚本名称
type: string; //设定0为脚本1为模板
pattern: string;//检测脚本模式(字典表Code字段数字、模拟、比对)
valueType?: string;//脚本值类型(字典表Code字段相对值脚本、绝对值脚本、无)
standardName: string;//参照标准名称
standardTime: string;//标准推行时间
state?:number;//
createBy?: string;
createTime?: string;
updateBy?: string;
updateTime?: string;
selectedValue?: string;
id?: string //检测脚本ID
name: string //检测脚本名称
type: string //设定0为脚本1为模板
pattern: string //检测脚本模式(字典表Code字段数字、模拟、比对)
valueType?: string //脚本值类型(字典表Code字段相对值脚本、绝对值脚本、无)
standardName: string //参照标准名称
standardTime: string //标准推行时间
state?: number //
createBy?: string
createTime?: string
updateBy?: string
updateTime?: string
selectedValue?: string
ratedCurr?: number
ratedVolt?: number
}
/**
* 检测脚本查询分页返回的对象;
*/
export interface ResTestScriptPage extends ResPage<ResTestScript> {
}
}
/**
* 检测脚本查询分页返回的对象;
*/
export interface ResTestScriptPage extends ResPage<ResTestScript> {}
}

View File

@@ -578,6 +578,26 @@
}
}
}
.form-four {
display: flex;
flex-wrap: wrap;
// justify-content: space-between;
.el-form-item {
display: flex;
width: 24%;
.el-form-item__content {
flex: 1;
.el-select,
.el-cascader,
.el-input__inner,
.el-date-editor {
width: 100%;
}
}
}
}
.el-table__cell {
border-right: 1px solid #ebeef5 !important;

View File

@@ -8,7 +8,7 @@
:header-cell-style="{ textAlign: 'center',backgroundColor: '#003078',color: '#fff' } "
:cell-style="{ textAlign: 'center' }"
style="width: 100%"
:style="{ height: '250px',maxHeight: '400px',overflow:'hidden'}"
:style="{ height: '400px',maxHeight: '400px',overflow:'hidden'}"
@selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="sort" label="序号" width="60" />

View File

@@ -3,7 +3,7 @@
<el-tabs type="border-card">
<el-tab-pane label="基础信息">
<div >
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' label-width="auto" class="form-three">
<el-form :model="formContent" ref='dialogFormRef' :rules='rules' label-width="auto" class="form-four">
<el-form-item label="标准号" prop="standardName" >
<el-input v-model='formContent.standardName' placeholder="请填写标准号"/>
</el-form-item>

View File

@@ -8,7 +8,7 @@
color: '#fff'
}"
stripe
height="calc(100vh - 480px)"
:height="`calc(100vh - ${props.shrink ? '535px' : '480px'})`"
:style="{ overflow: 'hidden' }"
row-key="id"
:expand-row-keys="[props.activeName]"
@@ -75,6 +75,9 @@ const props = defineProps({
options: {
type: Array,
required: true
},
shrink: {
type: Boolean
}
})
const tableData = ref<any[]>([])

View File

@@ -6,11 +6,15 @@
<el-divider style="flex: 1" content-position="left">检测项目概要信息</el-divider>
</div>
<div class="data-check-content">
<div class="content-tree">
<div class="content-tree" :style="{ height: `calc(100vh - ${props.shrink ? '370px' : '315px'})` }">
<Tree :treeData="treeData" @setTab="setTab" />
</div>
<div class="content-right-Tabs" style="height: calc(100vh - 315px); width: 100px">
<div
class="content-right-Tabs"
style="width: 100px"
:style="{ height: `calc(100vh - ${props.shrink ? '370px' : '315px'})` }"
>
<el-tabs type="border-card" style="height: 100%" v-model="activeName" @tab-change="tabChange">
<el-tab-pane v-for="tab in tabData" :key="tab.value" :label="tab.label" :name="tab.value">
<div v-if="activeName == tab.value">
@@ -26,6 +30,7 @@
:formContent="props.formContent"
:options="props.options"
style="width: 360px"
:shrink="props.shrink"
:disabled="tab.children.length == 0 ? false : true"
ref="communRef"
/>
@@ -55,7 +60,7 @@
stripe
:cell-style="{ textAlign: 'center' }"
highlight-current-row
height="calc(100vh - 480px)"
:height="`calc(100vh - ${props.shrink ? '535px' : '480px'})`"
style="width: 100%"
>
<el-table-column type="index" label="组次" width="60" />
@@ -188,12 +193,13 @@
v-if="showDialog"
/>
<!-- 查看 -->
<ViewRow ref="viewRowRef"
:activeName="activeName"
:formContent="props.formContent"
@close="viewDialog = false"
v-if="viewDialog"
/>
<ViewRow
ref="viewRowRef"
:activeName="activeName"
:formContent="props.formContent"
@close="viewDialog = false"
v-if="viewDialog"
/>
</div>
</template>
@@ -201,7 +207,7 @@
import { type PropType, ref, nextTick } from 'vue'
import Tree from './tree.vue'
import Commun from './communication.vue'
import {type CascaderOption, ElMessageBox} from 'element-plus'
import { type CascaderOption, ElMessageBox } from 'element-plus'
import { getTreeData } from '@/api/check/test'
import { CirclePlus, Delete, Check, CopyDocument, View, EditPen } from '@element-plus/icons-vue'
import type { TestScript } from '@/api/device/interface/testScript'
@@ -230,6 +236,9 @@ const props = defineProps({
formContent: {
type: Object,
required: true
},
shrink: {
type: Boolean
}
})
const showDialog = ref(false)
@@ -265,7 +274,7 @@ const getTree = () => {
}).then(res => {
if (res.code === 'A0000') {
treeData.value = res.data
console.log('tree',treeData.value)
console.log('tree', treeData.value)
// 添加tab子项
props.options.forEach((k: any, i: number) => {
tabData.value[i].children = []
@@ -308,7 +317,7 @@ const setTab = row => {
const copyActiveName = ref('')
// 获取通讯脚本点击
const getCommunication = () => {
console.log('123123',communRef.value[0]?.getData())
console.log('123123', communRef.value[0]?.getData())
communicationList.value = communRef.value[0]?.getData()
}
// 切换大tab控制小tab
@@ -347,8 +356,6 @@ const inquireTable = () => {
tableData.value = res.data
}
})
}
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> = {}) => {
@@ -359,48 +366,47 @@ const openDialog = (titleType: string, row: Partial<TestScript.ResTestScript> =
}
// 复制
const copyRow = async (row: any) => {
ElMessageBox.confirm('是否复制当前检测项目?', '提示', {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: 'warning',
draggable: true
}).then(async () => {
let checkDataList: any = []
await communRef.value[0]?.getData().forEach((item: any) => {
item.children.forEach((k: any) => {
if (k.enable != 0 || k.errorFlag != 0) {
checkDataList.push({
pid: k.pid,
valueType: k.id,
dataType: k.dataType,
enable: k.enable,
errorFlag: k.errorFlag
})
}
})
})
let { data } = await scriptDtlsCheckDataList({ checkDataList: checkDataList, ...row, retryCompute: true })
let copyRow = JSON.parse(JSON.stringify(row))
delete copyRow.index
await addScriptDtls({ ...copyRow, scriptType: activeName.value, checkDataList: data }).then(res => {
if (res.code === 'A0000') {
ElMessage.success({
message: '复制成功!',
type: 'success'
ElMessageBox.confirm('是否复制当前检测项目?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
draggable: true
}).then(async () => {
let checkDataList: any = []
await communRef.value[0]?.getData().forEach((item: any) => {
item.children.forEach((k: any) => {
if (k.enable != 0 || k.errorFlag != 0) {
checkDataList.push({
pid: k.pid,
valueType: k.id,
dataType: k.dataType,
enable: k.enable,
errorFlag: k.errorFlag
})
}
})
})
let { data } = await scriptDtlsCheckDataList({ checkDataList: checkDataList, ...row, retryCompute: true })
let copyRow = JSON.parse(JSON.stringify(row))
delete copyRow.index
await addScriptDtls({ ...copyRow, scriptType: activeName.value, checkDataList: data }).then(res => {
if (res.code === 'A0000') {
ElMessage.success({
message: '复制成功!',
type: 'success'
})
getTree()
}
})
getTree()
}
})
})
}
// 查看
const view = (row: Partial<TestScript.ResTestScript> = {}) => {
getCommunication()
console.log('communicationList',communicationList.value)
console.log('communicationList', communicationList.value)
//当前点击的一级tab
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称';
const parentTabName = communicationList.value.find(t => t.id === activeName.value)?.name || '未找到对应名称'
//当前点击的二级tab
const childrenTabName = ref('')
tabData.value.forEach((item: any) => {
@@ -416,12 +422,11 @@ const view = (row: Partial<TestScript.ResTestScript> = {}) => {
setTimeout(() => {
viewRowRef.value?.open(row, communicationList.value, parentTabName, childrenTabName.value)
}, 0)
}
// 删除
const deleteRow = async (row: any) => {
await useHandleData(deleteDtls, { enable: row.enable, index: row.index, scriptId: row.scriptId }, `删除`)
getTree()
await useHandleData(deleteDtls, { enable: row.enable, index: row.index, scriptId: row.scriptId }, `删除`)
getTree()
}
// 启用
const enableRow = async (row: any) => {
@@ -453,7 +458,7 @@ const addTab = (row: any) => {
const saveTheNewsletter = () => {}
onMounted(() => {
getTree()
console.log('testScriptDetail',props.options)
console.log('testScriptDetail', props.options)
props.options.forEach((item: any) => {
tabData.value.push({
label: item.label.replace(/准确度|检测/g, ''),
@@ -466,7 +471,6 @@ onMounted(() => {
valueCode.value = dictStore
.getDictData('Script_Value_Type')
.filter(item => item.id == props.formContent.valueType)[0].code
})
</script>
<style lang="scss" scoped>
@@ -477,16 +481,14 @@ onMounted(() => {
.content-tree {
width: 260px;
height: calc(100vh - 315px);
border: 1px solid #dcdfe6;
border-radius: 4px;
// margin-right: 10px;
overflow: auto; /* 同时启用垂直和水平滚动 */
overflow-x: hidden;
}
.scriptTree {
height: calc(100vh - 520px);
}
/* 确保 el-tree 内容可以超出容器宽度 */
.el-tree {

View File

@@ -35,7 +35,7 @@
:disabled="!form[0].dipFlag"
/>
</el-form-item>
<el-form-item label-width="120px" label="持续时间(s)">
<el-form-item label-width="120px" label="持续时间(周波)">
<el-input
type="number"
v-model="form[0].dipData.retainTime"

View File

@@ -1,6 +1,6 @@
<template>
<div>
<el-card style="margin-bottom: 10px" class="cardTop">
<el-card style="margin-bottom: 10px" class="cardTop" :style="{ height: height }">
<el-form
:model="formContent"
:inline="true"
@@ -30,6 +30,18 @@
<el-option v-for="item in stencil" :key="item.value" :label="item.name" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item>
<div class="formBut">
<el-button
type="primary"
:icon="shrink ? ArrowUpBold : ArrowDownBold"
@click="shrinkChange"
></el-button>
<el-button type="primary" :icon="Select" @click="save">保存</el-button>
<el-button :icon="Close" @click="close">返回</el-button>
</div>
</el-form-item>
<el-form-item label="检测脚本值类型" prop="valueType">
<el-select
v-model="formContent.valueType"
@@ -46,16 +58,30 @@
/>
</el-select>
</el-form-item>
<el-form-item>
<div class="formBut">
<el-button type="primary" :icon="Select" @click="save">保存</el-button>
<el-button :icon="Close" @click="close">返回</el-button>
</div>
<el-form-item label="额定电流" prop="ratedCurr">
<el-input-number
v-model.trim="formContent.ratedCurr"
min="0"
max="20"
style="width: 100%"
placeholder="请输入额定电流"
clearable
/>
</el-form-item>
<el-form-item label="额定电压" prop="ratedVolt">
<el-input-number
v-model.trim="formContent.ratedVolt"
min="0"
max="380"
style="width: 100%"
placeholder="请输入额定电压"
clearable
/>
</el-form-item>
</el-form>
</el-card>
<el-card v-if="show">
<TestScriptDetail :options="secondLevelOptions" :formContent="formContent" />
<TestScriptDetail :options="secondLevelOptions" :formContent="formContent" :shrink="shrink" />
</el-card>
</div>
</template>
@@ -67,11 +93,12 @@ import { type TestScript } from '@/api/device/interface/testScript'
import type { Dict } from '@/api/system/dictionary/interface'
import { getDictTreeByCode } from '@/api/system/dictionary/dictTree'
import type { CascaderOption } from 'element-plus'
import { Select, Close } from '@element-plus/icons-vue'
import { Select, Close, ArrowDownBold, ArrowUpBold } from '@element-plus/icons-vue'
import { pqScriptAdd, pqScriptUpdate } from '@/api/device/testScript'
import { useRouter } from 'vue-router'
const modeId = ref()
const show = ref(false)
const height = ref('125px')
const router = useRouter()
const secondLevelOptions: any[] = []
@@ -87,10 +114,13 @@ function useMetaInfo() {
pattern: modeId.value,
standardName: '',
standardTime: '',
state: 1
state: 1,
ratedCurr: 0,
ratedVolt: 0
})
return { titleType, formContent }
}
const shrink = ref(true)
const stencil = [
{ name: '脚本', value: 0 },
{ name: '模版', value: 1 }
@@ -100,11 +130,17 @@ const rules = {
standardName: [{ required: true, message: '请输入参照标准名称', trigger: 'blur' }],
standardTime: [{ required: true, message: '请选择标准推行年份', trigger: 'change' }],
type: [{ required: true, message: '请选择模版类型', trigger: 'change' }],
valueType: [{ required: true, message: '请选择检测脚本值类型', trigger: 'change' }]
valueType: [{ required: true, message: '请选择检测脚本值类型', trigger: 'change' }],
ratedCurr: [{ required: true, message: '请填写额定电流', trigger: 'change' }],
ratedVolt: [{ required: true, message: '请填写额定电压', trigger: 'change' }]
}
const { titleType, formContent } = useMetaInfo()
// 收缩
const shrinkChange = () => {
shrink.value = !shrink.value
shrink.value ? (height.value = '125px') : (height.value = '70px')
}
// 清空formContent
const resetFormContent = () => {
formContent.value = {
@@ -114,13 +150,14 @@ const resetFormContent = () => {
pattern: '',
standardName: '',
standardTime: '',
state: 1
state: 1,
ratedCurr: 0,
ratedVolt: 0
}
router.go(-1)
}
// 关闭弹窗
const close = () => {
// 清空dialogForm中的值
resetFormContent()
// 重置表单
@@ -151,6 +188,9 @@ const save = () => {
}
})
}
} else {
shrink.value = true
height.value = '125px'
}
})
}
@@ -163,7 +203,7 @@ const open = async (title: string, row: any) => {
} else {
let list = JSON.parse(row)
formContent.value = list
console.log('🚀 ~ open ~ list:', formContent.value )
console.log('🚀 ~ open ~ list:', formContent.value)
show.value = true
}
// 重置表单
@@ -239,7 +279,7 @@ defineExpose({ open })
// justify-content: space-between;
.el-form-item {
display: flex;
width: 15.8%;
width: 18.8%;
.el-form-item__content {
flex: 1;