This commit is contained in:
sjl
2024-12-13 16:35:27 +08:00
parent 8bd5351d29
commit 0db5fa650f
16 changed files with 480 additions and 339 deletions

View File

@@ -49,9 +49,9 @@ export namespace Device {
qRCode?: string| null; //设备关键信息二维码 qRCode?: string| null; //设备关键信息二维码
reCheckNum: number; //复检次数 reCheckNum: number; //复检次数
planId?:string;//检测计划Id planId?:string;//检测计划Id
TimeCheckResult?:number;//守时检测结果(0:不符合1:符合) timeCheckResult?:number;//守时检测结果(0:不符合1:符合)
FactorFlag?:number;//是否支持系数校准(0:不支持,1:支持) factorFlag?:number;//是否支持系数校准(0:不支持,1:支持)
FactorCheckResult?: number;//系数校准结果(0:不符合1:符合) factorCheckResult?: number;//系数校准结果(0:不符合1:符合)
state: number; //状态 state: number; //状态
createBy?: string| null; //创建用户 createBy?: string| null; //创建用户
createTime?: string| null; //创建时间 createTime?: string| null; //创建时间

View File

@@ -34,9 +34,9 @@ export namespace TestSource {
} }
export interface ParameterType{ export interface ParameterType{
id:string; id:string;
sourceParamType:string; type:string;
sourceParamDesc:string; desc:string;
sourceParamValue:string; value:string;
sort:number; sort:number;
pId:string; pId:string;
children?:ParameterType[]; children?:ParameterType[];

View File

@@ -32,7 +32,7 @@ export namespace Plan {
export interface ReqPlan extends ResPlan { export interface ReqPlan extends ResPlan {
datasourceIds:string; datasourceIds:string;
sourceIds: string[]; sourceIds: string;
planId:string; planId:string;
scriptName: string ; scriptName: string ;
errorSysName: string; errorSysName: string;

View File

@@ -15,12 +15,12 @@ export const getPlanList = (params: Plan.ReqPlanParams) => {
} }
// 新增检测计划 // 新增检测计划
export const addPlan = (params: Plan.ResPlan) => { export const addPlan = (params:any) => {
return http.post(`/adPlan/add`, params) return http.post(`/adPlan/add`, params)
} }
// 编辑检测计划 // 编辑检测计划
export const updatePlan = (params: Plan.ResPlan) => { export const updatePlan = (params: any) => {
return http.post(`/adPlan/update`, params) return http.post(`/adPlan/update`, params)
} }
@@ -51,10 +51,15 @@ export const getUnboundPqDevList = (params: Plan.ReqPlan) => {
//根据检测计划id查询出所有已绑定的设备 //根据检测计划id查询出所有已绑定的设备
export const getBoundPqDevList = (params: any) => { export const getBoundPqDevList = (params: any) => {
return http.post(`/pqDev/listBoundByPlanId`,params) return http.post(`/pqDev/listByPlanId`,params)
} }
//检测计划绑定设备 //检测计划绑定设备
export const BindPqDevList = (params: any) => { export const BindPqDevList = (params: any) => {
return http.post(`/adPlan/bindDev`,params) return http.post(`/pqDev/bindDev`,params)
}
// 按照模式查询检测计划(用于首页展示)
export const getPlanListByPattern = (params:Plan.ReqPlan) => {
return http.get(`/adPlan/listByPattern?pattern=${params.pattern}`)
} }

View File

@@ -3,16 +3,16 @@
<!-- :request-api="getTableList" --> <!-- :request-api="getTableList" -->
<ProTable <ProTable
ref="proTable" ref="proTable"
:columns="columns" :columns="columns"
:data='deviceData' :data ='deviceData'
:init-param="initParam"
:data-callback="dataCallback"
@drag-sort="sortTable" @drag-sort="sortTable"
:default-sort="{ prop: 'check_State', order: 'ascending' }" :default-sort="{ prop: 'check_State', order: 'ascending' }"
:stripe="true" :stripe="true"
:pagination = "false" :pagination = "false"
:key="tableKey" :key="tableKey"
@selection-change='handleSelectionChange' @selection-change='handleSelectionChange'
:request-api='getTableList'
> >
<!-- :height="tableHeight" --> <!-- :height="tableHeight" -->
<!-- 表格 header 按钮 --> <!-- 表格 header 按钮 -->
@@ -57,17 +57,6 @@
></el-option> ></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<!-- <el-form-item label="检测结果">
<el-select v-model="form.checkResult" clearable>
<el-option
v-for="(item, index) in checkResultList"
:label="item.label"
:value="item.value"
:disabled="item.disabled"
:key="index"
></el-option>
</el-select>
</el-form-item> -->
<el-form-item> <el-form-item>
<el-button type="primary" :icon="Search" @click="handleSearch" <el-button type="primary" :icon="Search" @click="handleSearch"
>查询</el-button >查询</el-button
@@ -75,7 +64,6 @@
<el-button :icon="Delete" @click="handleRefresh" <el-button :icon="Delete" @click="handleRefresh"
>重置</el-button >重置</el-button
> >
<!-- :disabled='!scope.isSelected' --> <!-- :disabled='!scope.isSelected' -->
<el-button <el-button
type="primary" type="primary"
@@ -265,9 +253,11 @@ import testPopup from "./testPopup.vue";
import reportPopup from "./reportPopup.vue"; import reportPopup from "./reportPopup.vue";
import dataCheckPopup from "./dataCheckPopup.vue"; import dataCheckPopup from "./dataCheckPopup.vue";
import dataCheckChangeErrSysPopup from "./dataCheckChangeErrSysPopup.vue"; import dataCheckChangeErrSysPopup from "./dataCheckChangeErrSysPopup.vue";
import { getBoundPqDevList } from '@/api/plan/plan.ts'
import { onMounted, reactive, ref, watch } from "vue";
import { useDictStore } from '@/stores/modules/dict'
import { reactive, ref } from "vue"; const dictStore = useDictStore()
let devNum = 0;//当前选取的被检设备数量 let devNum = 0;//当前选取的被检设备数量
let devChannelsNum = 0;//当前选择的被检设备通道总数 let devChannelsNum = 0;//当前选择的被检设备通道总数
let devTestedNum = 0;//当前选择的已完成检测的被检设备数量 let devTestedNum = 0;//当前选择的已完成检测的被检设备数量
@@ -294,10 +284,26 @@ const dialogForm = ref<any>({
const shouldShowOption = (item) => { const shouldShowOption = (item) => {
return !item.disabled; return !item.disabled;
}; };
const plan_devicedata = [
{
id: '1', //装置序号ID
name: '240001', //设备名称
dev_Type: 'PQS-882B4',//设备类型
dev_Chns: 4, //设备通道数
check_Result: '未检', //检测结果
report_State: '未生成', //报告状态
document_State: '未归档', //归档状态
check_State:'未检',//检测状态
reCheck_Num: 0, //复检次数
}]
//console.log(window.innerHeight, "+++++++++"); //console.log(window.innerHeight, "+++++++++");
tableHeight.value = window.innerHeight - 600; tableHeight.value = window.innerHeight - 600;
//const deviceData = deviceDataList.plan_devicedata //const deviceData = deviceDataList.plan_devicedata
const deviceData = ref([]); const deviceData = ref<Device.ResPqDev[]>([]);
deviceData.value = deviceDataList.plan_devicedata.filter((item) => item.document_State === "未归档") deviceData.value = deviceDataList.plan_devicedata.filter((item) => item.document_State === "未归档")
const operationShow = ref(false); const operationShow = ref(false);
const documentStateShow = ref(false); const documentStateShow = ref(false);
@@ -305,6 +311,13 @@ const checkStateShow = ref(true);
const operationMinWidth = ref(200); const operationMinWidth = ref(200);
const selectionShow = ref(true); const selectionShow = ref(true);
const props = defineProps({
id: {
type: String,
required: true,
},
})
//下拉框数据 //下拉框数据
//检测状态数据 //检测状态数据
let checkStatusList = reactive([ let checkStatusList = reactive([
@@ -404,16 +417,33 @@ const dataCallback = (data: any) => {
}; };
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口 // 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList" // 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => { // const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params)); // console.log('11111111111111111',props.id);
newParams.createTime && (newParams.startTime = newParams.createTime[0]); // let newParams = JSON.parse(JSON.stringify(params));
newParams.createTime && (newParams.endTime = newParams.createTime[1]); // newParams.createTime && (newParams.startTime = newParams.createTime[0]);
delete newParams.createTime; // newParams.createTime && (newParams.endTime = newParams.createTime[1]);
return getPlanList(newParams); // delete newParams.createTime;
// return getPlanList(newParams);
// };
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
const getTableList = async (params: any) => {
deviceData.value = plan_devicedata.filter((item) => item.document_State === "未归档")
const pqDevList_Result2 = await getBoundPqDevList({'planId': props.id, 'checkStateList':[0,1,2]});
boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[];
console.log('qwe',boundPqDevList.value)
console.log('qwe123',props.id)
return getBoundPqDevList({'planId': props.id, 'checkStateList':[0,1,2]});
}; };
// 表格配置项 // 表格配置项
const columns = reactive([ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
{ type: 'selection', fixed: 'left', width: 70, isShow:selectionShow }, { type: 'selection', fixed: 'left', width: 70, isShow:selectionShow },
{ type: 'index', fixed: 'left', width: 70, label: '序号' }, { type: 'index', fixed: 'left', width: 70, label: '序号' },
{ {
@@ -422,18 +452,20 @@ const columns = reactive([
minWidth: 220, minWidth: 220,
}, },
{ {
prop: 'dev_Type', prop: 'devType',
label: '设备类型', label: '设备类型',
minWidth: 100, minWidth: 100,
enum: dictStore.getDictData('Dev_Type'),
fieldNames: { label: 'name', value: 'id' },
}, },
{ {
prop: 'dev_Chns', prop: 'devChns',
label: '通道数', label: '通道数',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
}, },
{ {
prop: 'reCheck_Num', prop: 'reCheckNum',
label: '检测次数', label: '检测次数',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
@@ -445,40 +477,36 @@ const columns = reactive([
// </template> // </template>
}, },
{ {
prop: 'check_State', prop: 'checkState',
label: '检测状态', label: '检测状态',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
isShow:checkStateShow, isShow:checkStateShow,
}, },
{ {
prop: 'check_Result', prop: 'checkResult',
label: '检测结果', label: '检测结果',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
render: (scope) => { render: (scope) => {
if(scope.row.check_Result === '不符合') if (scope.row.checkResult === 2)
{ {
return ( return (<el-tag type='danger'>{ scope.row.checkResult }</el-tag>)
<el-tag type='danger'>{ scope.row.check_Result }</el-tag> }
) else
} {
else return (<span>{ scope.row.checkResult }</span>)
{ }
return ( },
<span>{ scope.row.check_Result }</span>
)
}
},
}, },
{ {
prop: 'report_State', prop: 'reportState',
label: '报告状态', label: '报告状态',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
}, },
{ {
prop: 'document_State', prop: 'documentState',
label: '归档状态', label: '归档状态',
minWidth: 100, minWidth: 100,
sortable:true, sortable:true,
@@ -487,149 +515,82 @@ const columns = reactive([
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 200 ,isShow: operationShow}, { prop: 'operation', label: '操作', fixed: 'right', minWidth: 200 ,isShow: operationShow},
]) ])
// const columns = reactive<ColumnProps<User.ResUserList>[]>([
// { type: "selection", fixed: "left", width: 70 }, // // 表格配置项
// { // const columns = reactive([
// prop: "checkMode", // { type: 'selection', fixed: 'left', width: 70, isShow:selectionShow },
// label: "设备序列号", // { type: 'index', fixed: 'left', width: 70, label: '序号' },
// width: 140, // {
// render: (scope) => { // prop: 'name',
// return scope.row.checkMode == 0 // label: '设备名称',
// ? "设备1" // minWidth: 220,
// : scope.row.checkMode == 1
// ? "设备2"
// : scope.row.checkMode == 2
// ? "设备3"
// : scope.row.checkMode;
// }, // },
// }, // {
// { // prop: 'dev_Type',
// prop: "checkMode", // label: '设备类型',
// label: "设备类型", // minWidth: 100,
// width: 140,
// render: (scope) => {
// return scope.row.checkMode == 0
// ? "PQS991"
// : scope.row.checkMode == 1
// ? "PQS882"
// : scope.row.checkMode == 2
// ? "PQS6666"
// : scope.row.checkMode;
// }, // },
// }, // {
// { // prop: 'dev_Chns',
// prop: "checkFrom", // label: '通道数',
// label: "制造厂商", // minWidth: 100,
// width: 140, // sortable:true,
// render: (scope) => {
// return scope.row.checkFrom == 0
// ? "南京灿能"
// : scope.row.checkFrom == 1
// ? "南瑞继保"
// : scope.row.checkFrom == 2
// ? "/"
// : scope.row.checkFrom;
// }, // },
// }, // {
// { // prop: 'reCheck_Num',
// prop: "numberFromName", // label: '检测次数',
// label: "MAC/IP", // minWidth: 100,
// render: (scope) => { // sortable:true,
// return scope.row.numberFromName == 0 // // <template #header>
// ? "192.168.0.1" // // <span>检测次数</span>
// : scope.row.numberFromName == 1 // // <el-tooltip content = "最大检测次数为3次超过会强制归档" placement="top" style="align-items: bottom;">
// ? "192.168.0.2" // // <el-icon><InfoFilled /></el-icon>
// : scope.row.numberFromName == 2 // // </el-tooltip>
// ? "192.168.0.3" // // </template>
// : scope.row.numberFromName;
// }, // },
// {
// prop: 'check_State',
// label: '检测状态',
// minWidth: 100,
// sortable:true,
// isShow:checkStateShow,
// },
// {
// prop: 'check_Result',
// label: '检测结果',
// minWidth: 100,
// sortable:true,
// render: (scope) => {
// if(scope.row.check_Result === '不符合')
// {
// return (
// <el-tag type='danger'>{ scope.row.check_Result }</el-tag>
// )
// }
// else
// {
// return (
// <span>{ scope.row.check_Result }</span>
// )
// }
// }, // },
// { // },
// prop: "checkExe", // {
// label: "检测脚本", // prop: 'report_State',
// render: (scope) => { // label: '报告状态',
// return scope.row.checkExe == 0 // minWidth: 100,
// ? "国网入网检测脚本(单影响量-模拟式)" // sortable:true,
// : scope.row.checkExe == 1 // },
// ? "国网入网检测脚本" // {
// : scope.row.checkExe == 2 // prop: 'document_State',
// ? "/" // label: '归档状态',
// : scope.row.checkExe; // minWidth: 100,
// }, // sortable:true,
// }, // isShow: documentStateShow,
// { // },
// prop: "wctx", // { prop: 'operation', label: '操作', fixed: 'right', minWidth: 200 ,isShow: operationShow},
// label: "误差体系", // ])
// render: (scope) => {
// return scope.row.wctx == 0
// ? "Q/GDW 1650.2- 2016"
// : scope.row.wctx == 1
// ? "Q/GDW 10650.2 - 2021"
// : scope.row.wctx == 2
// ? "/"
// : scope.row.wctx;
// },
// },
// {
// prop: "checkStatus",
// label: "检测状态",
// width: 120,
// render: (scope) => {
// return scope.row.checkStatus == 1
// ? "未检"
// : scope.row.checkStatus == 2
// ? "检测中"
// : scope.row.checkStatus == 3
// ? "检测完成"
// : scope.row.checkStatus;
// },
// },
// {
// prop: "checkReport",
// label: "检测报告",
// width: 120,
// render: (scope) => {
// return scope.row.checkReport == 1
// ? "未生成"
// : scope.row.checkReport == 2
// ? "部分生成"
// : scope.row.checkReport == 3
// ? "全部生成"
// : scope.row.checkReport;
// },
// },
// {
// prop: "checkResult",
// label: "检测结果",
// width: 120,
// render: (scope) => {
// return scope.row.checkReport == 1
// ? "/"
// : scope.row.checkReport == 2
// ? "符合"
// : scope.row.checkReport == 3
// ? "不符合"
// : scope.row.checkReport;
// },
// },
// {
// prop: "parentNode",
// label: "父节点",
// width: 90,
// render: (scope) => {
// return scope.row.checkReport == 0
// ? "/"
// : scope.row.checkReport == 1
// ? "检测计划1"
// : scope.row.checkReport == 2
// ? "检测计划2"
// : scope.row.checkReport == 3
// ? "检测计划3"
// : scope.row.checkReport;
// },
// },
// { prop: "operation", label: "操作", fixed: "right", width: 250 },
// ]);
// 跳转详情页 // 跳转详情页
const toDetail = () => { const toDetail = () => {
router.push( router.push(
@@ -1016,6 +977,19 @@ const openDrawer = (title: string, row: any) => {
onMounted(() => { onMounted(() => {
//console.log(proTable.value?.tableData); //console.log(proTable.value?.tableData);
}); });
// 监听 props.id 的变化
watch(
() => props.id,
(newId) => {
console.log(`props.id changed to ${newId}`);
// 调用获取数据的方法
getTableList({ type: 1, pageNum: 1, pageSize: 10 });
},
{ immediate: true } // 立即执行一次
);
defineExpose({ changeActiveTabs }); defineExpose({ changeActiveTabs });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -33,7 +33,9 @@
</div> </div>
</template> </template>
<script lang='ts' setup> <script lang='ts' setup>
import { type Plan } from '@/api/plan/interface';
import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue' import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue'
import { onMounted, ref, watch } from 'vue';
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
const router = useRouter() const router = useRouter()
@@ -46,11 +48,13 @@ const defaultProps = {
const searchForm = ref({ const searchForm = ref({
planName: '', planName: '',
}) })
const defaultChecked = ref([]) const defaultChecked = ref<number[]>([]) // 明确类型为 number[]
const getTreeData = (val: any) => { const getTreeData = (val: any) => {
defaultChecked.value = [] defaultChecked.value = []
data.value = val data.value = val
defaultChecked.value.push(data.value[0].children[0].id) if (data.value.length > 0 && data.value[0].children.length > 0) {
defaultChecked.value.push(data.value[0].children[0].id as number)
}
} }
const filterText = ref('') const filterText = ref('')
const treeRef = ref() const treeRef = ref()
@@ -66,11 +70,10 @@ watch(
deep: true, deep: true,
}, },
) )
const handleNodeClick = (data) => { const handleNodeClick = (data: Plan.ResPlan) => {
// console.log(data) updateSelectedTreeNode(data.id)
updateSelectedTreeNode()
} }
const filterNode = (value: string, data) => { const filterNode = (value: string, data: any) => {
if (!value) return true if (!value) return true
return data.name.includes(value) return data.name.includes(value)
} }

View File

@@ -2,7 +2,7 @@
<template> <template>
<div class="static"> <div class="static">
<div class="left_tree"> <div class="left_tree">
<tree ref="treeRef" :updateSelectedTreeNode="getPieData || (() => {})"/> <tree ref="treeRef" :updateSelectedTreeNode="getPieData || (() => {})" />
</div> </div>
<!-- <span class="new_span">测试scss颜色</span> --> <!-- <span class="new_span">测试scss颜色</span> -->
<div class="right_container"> <div class="right_container">
@@ -89,14 +89,14 @@
<el-tab-pane :label="tabLabel1" :style="{ height: tabPaneHeight }"> <el-tab-pane :label="tabLabel1" :style="{ height: tabPaneHeight }">
<!-- 列表数据 --> <!-- 列表数据 -->
<div class="container_table" :style="{ height: tableHeight }"> <div class="container_table" :style="{ height: tableHeight }">
<Table ref="tableRef1"></Table> <Table ref="tableRef1" :id='currentId'></Table>
</div> </div>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="已检设备" v-if="tabShow" :style="{ height: tabPaneHeight }"> <el-tab-pane label="已检设备" v-if="tabShow" :style="{ height: tabPaneHeight }">
<!-- 列表数据 --> <!-- 列表数据 -->
<div class="container_table" :style="{ height: tableHeight }"> <div class="container_table" :style="{ height: tableHeight }">
<Table ref="tableRef2"></Table> <Table ref="tableRef2" :id='currentId'></Table>
</div> </div>
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@@ -109,9 +109,19 @@ import pie from "@/components/echarts/pie/default.vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import tree from "../components/tree.vue"; import tree from "../components/tree.vue";
import Table from "../components/table.vue"; import Table from "../components/table.vue";
import { data } from "@/api/plan/static.json"; //import { data } from "@/api/plan/static.json";
import deviceDataList from '@/api/device/device/deviceData' import deviceDataList from '@/api/device/device/deviceData'
import {getPlanListByPattern } from '@/api/plan/plan.ts'
import { onMounted, onUnmounted, ref, watch } from "vue";
import { useModeStore } from '@/stores/modules/mode'; // 引入模式 store
import { useDictStore } from '@/stores/modules/dict'
import { type Plan } from "@/api/plan/interface";
import type { CollapseModelValue } from "element-plus/es/components/collapse/src/collapse.mjs";
import { type Device } from "@/api/device/interface/device";
import { getBoundPqDevList } from '@/api/plan/plan.ts'
const dictStore = useDictStore()
const modeStore = useModeStore();
const chartsInfoRef = ref<HTMLElement | null>(null); const chartsInfoRef = ref<HTMLElement | null>(null);
const chartsWidth = ref<number>(0); const chartsWidth = ref<number>(0);
const deviceData = deviceDataList.plan_devicedata const deviceData = deviceDataList.plan_devicedata
@@ -136,15 +146,18 @@ const tabsHeight = ref('calc(100vh - 538px)'); // 初始高度
const tabPaneHeight = ref('calc(100% - 5px)'); // 初始高度 const tabPaneHeight = ref('calc(100% - 5px)'); // 初始高度
const tableHeight = ref('calc(100% - 5px)'); // 初始高度 const tableHeight = ref('calc(100% - 5px)'); // 初始高度
const handleChange = (val: string[]) => { const handleChange = (val: string[]) => {
// console.log(val)
} }
const handleCollapseChange = (val: string[]) => { const handleCollapseChange = (val: CollapseModelValue) => {
console.log(val)
console.log(val.length)
// 计算新的高度 // 计算新的高度
const newHeight = val.length > 0 ? 'calc(100vh - 538px)' : 'calc(100vh - 333px)'; let newHeight;
if (Array.isArray(val)) {
newHeight = val.length > 0 ? 'calc(100vh - 538px)' : 'calc(100vh - 333px)';
} else {
newHeight = val ? 'calc(100vh - 538px)' : 'calc(100vh - 333px)';
}
//const newtableHeight= val.length > 0 ? 'calc(100vh - 638px)' : 'calc(100vh - 433px)'; //const newtableHeight= val.length > 0 ? 'calc(100vh - 638px)' : 'calc(100vh - 433px)';
tabsHeight.value = newHeight; tabsHeight.value = newHeight;
tabPaneHeight.value = `calc(100% - 5px)`; tabPaneHeight.value = `calc(100% - 5px)`;
@@ -154,7 +167,7 @@ const handleCollapseChange = (val: string[]) => {
// tableRef2.value.resize(); // tableRef2.value.resize();
}; };
const handleTabsChange = (val) => { const handleTabsChange = (val: any) => {
form.value.activeTabs = 0; form.value.activeTabs = 0;
form.value.activeTabs = 3; form.value.activeTabs = 3;
form.value.activeChildTabs = Number(val); form.value.activeChildTabs = Number(val);
@@ -199,7 +212,7 @@ const tabsList = ref([
form.value.activeTabs = tabsList.value[0].value; form.value.activeTabs = tabsList.value[0].value;
const tableRef1 = ref(); const tableRef1 = ref();
const tableRef2 = ref(); const tableRef2 = ref();
const currentId = ref('');
watch( watch(
() => form.value, () => form.value,
@@ -248,13 +261,23 @@ const pieRef1 = ref(),
pieRef3 = ref(); pieRef3 = ref();
const changeSelect = () => { const changeSelect = () => {
console.log(form.value.activeTabs); console.log(form.value.activeTabs);
getPieData(); //getPieData();
}; };
const chartsData1: any = ref([]), const chartsData1: any = ref([]),
chartsData2: any = ref([]), chartsData2: any = ref([]),
chartsData3: any = ref([]); chartsData3: any = ref([]);
const getPieData = () => { const getPieData = async (id: string) => {
console.log('123111',id);
currentId.value = id; // 设置当前ID
const boundPqDevList=ref<Device.ResPqDev[]>([])//根据检测计划id查询出所有已绑定的设备
const pqDevList_Result2 = await getBoundPqDevList({'planId': id, 'checkStateList':[0,1,2]});
boundPqDevList.value = pqDevList_Result2.data as Device.ResPqDev[];
console.log('饼图',boundPqDevList.value)
chartsData1.value = [ chartsData1.value = [
{ value: 12, name: "未检", itemStyle: { color: '#fac858' } }, { value: 12, name: "未检", itemStyle: { color: '#fac858' } },
{ value: 0, name: "检测中", itemStyle: { color: '#ee6666' } }, { value: 0, name: "检测中", itemStyle: { color: '#ee6666' } },
@@ -265,24 +288,11 @@ const getPieData = () => {
{ value: 12, name: "未检" , itemStyle: { color: '#fac858' } }, { value: 12, name: "未检" , itemStyle: { color: '#fac858' } },
{ value: 3, name: "不符合" , itemStyle: { color: '#ee6666' } }, { value: 3, name: "不符合" , itemStyle: { color: '#ee6666' } },
{ value: 5, name: "符合", itemStyle: { color: '#91cc75' } }, { value: 5, name: "符合", itemStyle: { color: '#91cc75' } },
// { value: Math.floor(Math.random() * 100) + 1, name: "有不合格项" , itemStyle: { color: '#ee6666' } },
// { value: Math.floor(Math.random() * 100) + 1, name: "全部合格", itemStyle: { color: '#91cc75' } },
]; ];
// pieRef2.value.init();
chartsData3.value = [ chartsData3.value = [
// { value: Math.floor(Math.random() * 100) + 1, name: "已生成报告" },
// { value: Math.floor(Math.random() * 100) + 1, name: "未生成报告" },
{ value: 12, name: "未检" , itemStyle: { color: '#fac858' } }, { value: 12, name: "未检" , itemStyle: { color: '#fac858' } },
{ value: 4, name: "未生成" , itemStyle: { color: '#ee6666' } }, { value: 4, name: "未生成" , itemStyle: { color: '#ee6666' } },
{ value: 4, name: "已生成", itemStyle: { color: '#91cc75' } }, { value: 4, name: "已生成", itemStyle: { color: '#91cc75' } },
// { value: Math.floor(Math.random() * 100) + 1, name: "未检" , itemStyle: { color: '#fac858' } },
// { value: Math.floor(Math.random() * 100) + 1, name: "有不合格项未生成报告" },
// { value: Math.floor(Math.random() * 100) + 1, name: "全部合格未生成报告" },
// { value: Math.floor(Math.random() * 100) + 1, name: "有不合格项已生成报告" },
// { value: Math.floor(Math.random() * 100) + 1, name: "全部合格已生成报告" },
]; ];
pieRef1.value.init(); pieRef1.value.init();
@@ -292,13 +302,8 @@ const getPieData = () => {
// pieRef2.value.reSize(470,145,true); // pieRef2.value.reSize(470,145,true);
// pieRef3.value.reSize(470,145,true); // pieRef3.value.reSize(470,145,true);
}; };
const getTree = () => { const getTree = (data?: any) => {
treeRef.value.getTreeData(data); treeRef.value.getTreeData(data);
// getStaticTreeData({ userName: "zhangsan", planName: "111" }).then((res) => {
// console.log(res, "99999999");
// // treeRef.value.getTreeData(res.data);
// treeRef.value.getTreeData(data);
// });
}; };
//前往检测 //前往检测
const handleDetection = () => { const handleDetection = () => {
@@ -353,6 +358,7 @@ const handleCheckFunction = (val: any) => {
}; };
const resizeObserver = new ResizeObserver(entries => { const resizeObserver = new ResizeObserver(entries => {
for (let entry of entries) { for (let entry of entries) {
chartsWidth.value = entry.contentRect.width; chartsWidth.value = entry.contentRect.width;
@@ -364,21 +370,47 @@ const resizeObserver = new ResizeObserver(entries => {
} }
}); });
onMounted(() => { onMounted(async () => {
// console.log(); const patternId = dictStore.getDictData('Pattern').find(item=>item.name=== modeStore.currentMode)?.id ?? ''//获取数据字典中对应的id
const reqPlan: Plan.ReqPlan = {
pattern: patternId,
datasourceIds: "",
sourceIds: [],
planId: "",
scriptName: "",
errorSysName: "",
sourceName: "",
devIds: [],
id: "",
name: "",
dataSourceId: "",
scriptId: "",
errorSysId: "",
timeCheck: 0,
testState: 0,
reportState: 0,
result: 0,
code: 0,
state: 0
};
const planList = await getPlanListByPattern(reqPlan);
console.log('1111111111111111')
if (chartsInfoRef.value) { if (chartsInfoRef.value) {
resizeObserver.observe(chartsInfoRef.value); resizeObserver.observe(chartsInfoRef.value);
} }
getTree(); getTree(planList.data);
getPieData();
});
//getPieData('');
});
onUnmounted(() => { onUnmounted(() => {
if (chartsInfoRef.value) { if (chartsInfoRef.value) {
resizeObserver.unobserve(chartsInfoRef.value); resizeObserver.unobserve(chartsInfoRef.value);
} }
}); });
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.static { .static {

View File

@@ -131,7 +131,13 @@
</el-form-item> </el-form-item>
<el-form-item label='所属电站' prop='subName' clearable placeholder="请输入所属电站" v-if="MonIsShow"> <el-form-item label='所属电站' prop='subName' clearable placeholder="请输入所属电站" v-if="MonIsShow">
<el-input v-model='formContent.subName' /> <el-input v-model='formContent.subName' />
</el-form-item> </el-form-item>
<el-form-item v-auth.device="'factorFlag'" label="是否支持系数校准" prop='factorFlag'>
<el-radio-group v-model="formContent.factorFlag" >
<el-radio :value="1"></el-radio>
<el-radio :value="0"></el-radio>
</el-radio-group>
</el-form-item>
</el-form> </el-form>
</div> </div>
</el-tab-pane> </el-tab-pane>
@@ -195,6 +201,7 @@ const disabledDate = (time: Date) => {
encryptionFlag: 0, encryptionFlag: 0,
reCheckNum:0, reCheckNum:0,
state: 1, state: 1,
factorFlag:0,
}) })
return { dialogVisible, titleType, formContent } return { dialogVisible, titleType, formContent }
} }
@@ -221,6 +228,7 @@ const disabledDate = (time: Date) => {
encryptionFlag: 0, encryptionFlag: 0,
reCheckNum:0, reCheckNum:0,
state: 1, state: 1,
factorFlag:0,
} }
} }

View File

@@ -51,7 +51,10 @@ const proTable = ref<ProTableInstance>()
const devicePopup = ref() const devicePopup = ref()
// 定义包含和排除的单位 // 定义包含和排除的单位
const getTableList = (params: any) => {
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
const getTableList = async (params: any) => {
let newParams = JSON.parse(JSON.stringify(params)) let newParams = JSON.parse(JSON.stringify(params))
newParams.searchEndTime = endDate.value newParams.searchEndTime = endDate.value
newParams.searchBeginTime = startDate.value newParams.searchBeginTime = startDate.value

View File

@@ -4,14 +4,15 @@
<el-tab-pane label="基础信息"> <el-tab-pane label="基础信息">
<div > <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-three">
<el-form-item label="误差体系名称" prop="name" > <el-form-item label="标准号" prop="standardName" >
<el-input v-model='formContent.name' placeholder="标准号+年份+设备等级"/> <el-input v-model='formContent.standardName' placeholder="请填写标准号"/>
</el-form-item> </el-form-item>
<el-form-item label="参照标准名称" prop="standardName" > <el-form-item label="标准推行年份" prop="standardTime" >
<el-input v-model='formContent.standardName'/> <el-date-picker
</el-form-item> v-model="formContent.standardTime"
<el-form-item label="发布时间" prop="standardTime" > type="year"
<el-input v-model="formContent.standardTime" /> placeholder="请选择标准推行年份"
/>
</el-form-item> </el-form-item>
<el-form-item label="适用设备等级" prop="devLevel" > <el-form-item label="适用设备等级" prop="devLevel" >
<el-select v-model='formContent.devLevel' placeholder="请选择设备等级"> <el-select v-model='formContent.devLevel' placeholder="请选择设备等级">
@@ -104,7 +105,7 @@
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({ const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{ required: true, message: '误差体系名称必填!', trigger: 'blur' }], name: [{ required: true, message: '误差体系名称必填!', trigger: 'blur' }],
standardName: [{ required: true, message: '参照标准名称必填!', trigger: 'blur' }], standardName: [{ required: true, message: '参照标准名称必填!', trigger: 'blur' }],
standardTime: [{ required: true, message: '标准推行时间必填', trigger: 'blur' }], standardTime: [{ required: true, message: '标准推行年份必选', trigger: 'blur' }],
devLevel:[{ required: true, message: '请选择一项设备等级', trigger: 'change' },], devLevel:[{ required: true, message: '请选择一项设备等级', trigger: 'change' },],
enable:[{ required: true, message: '请选择一项状态', trigger: 'change '},] enable:[{ required: true, message: '请选择一项状态', trigger: 'change '},]
}); });
@@ -124,7 +125,7 @@
try { try {
dialogFormRef.value?.validate(async (valid: boolean) => { dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
formContent.value.pqErrSysDtlsList = tableData.value formContent.value.pqErrSysDtlsList = tableData.value
if (formContent.value.id) { if (formContent.value.id) {
await updatePqErrSys(formContent.value); await updatePqErrSys(formContent.value);

View File

@@ -52,11 +52,11 @@ const columns = ref<ColumnProps<ErrorSystem.ErrorSystemList>[]>([
}, },
{ {
prop: 'standardName', prop: 'standardName',
label: '参照标准名称', label: '标准号',
}, },
{ {
prop: 'standardTime', prop: 'standardTime',
label: '标准实施年份', label: '标准推行年份',
width: 200, width: 200,
search: { el: 'input' }, search: { el: 'input' },
}, },

View File

@@ -15,15 +15,15 @@
:props="defaultProps" :props="defaultProps"
/> />
</el-form-item> </el-form-item>
<el-form-item label="源参数描述" :label-width="100" prop="sourceParamDesc"> <el-form-item label="源参数描述" :label-width="100" prop="desc">
<el-input v-model="formContent.sourceParamDesc" autocomplete="off"/> <el-input v-model="formContent.desc" autocomplete="off"/>
</el-form-item> </el-form-item>
<el-form-item label="源参数类型" :label-width="100" prop="sourceParamType"> <el-form-item label="源参数类型" :label-width="100" prop="type">
<el-input v-model="formContent.sourceParamType" autocomplete="off"/> <el-input v-model="formContent.type" autocomplete="off"/>
</el-form-item> </el-form-item>
<el-form-item label="源参数值" :label-width="100" <el-form-item label="源参数值" :label-width="100"
prop="sourceParamValue"> prop="value">
<el-input v-model="formContent.sourceParamValue" autocomplete="off"/> <el-input v-model="formContent.value" autocomplete="off"/>
</el-form-item> </el-form-item>
<el-form-item label="排序" :label-width="100"> <el-form-item label="排序" :label-width="100">
<el-input-number v-model="formContent.sort" :min='1' :max='999'/> <el-input-number v-model="formContent.sort" :min='1' :max='999'/>
@@ -69,7 +69,7 @@ const displayPid = computed({
// 树形节点配置 // 树形节点配置
const defaultProps = { const defaultProps = {
children: 'children', children: 'children',
label: 'sourceParamDesc', label: 'desc',
value: 'id' value: 'id'
}; };
@@ -82,9 +82,9 @@ function useMetaInfo() {
const formContent = reactive<TestSource.ParameterType>({ const formContent = reactive<TestSource.ParameterType>({
id: "", id: "",
sourceParamType: "", type: "",
sourceParamValue: "", value: "",
sourceParamDesc: "", desc: "",
sort: 100, sort: 100,
pId: "0", pId: "0",
}) })
@@ -93,8 +93,8 @@ function useMetaInfo() {
} }
const rules: reactive<Record<string, Array<FormItemRule>>> = reactive({ const rules: reactive<Record<string, Array<FormItemRule>>> = reactive({
sourceParamDesc: [{required: true, message: '源参数描述必填!', trigger: 'blur'}], desc: [{required: true, message: '源参数描述必填!', trigger: 'blur'}],
sourceParamType: [{required: true, message: '源参数类型必填!', trigger: 'blur'}], type: [{required: true, message: '源参数类型必填!', trigger: 'blur'}],
sort: [{required: true, message: '排序必填!', trigger: 'blur'}] sort: [{required: true, message: '排序必填!', trigger: 'blur'}]
}) })
@@ -114,9 +114,9 @@ let dialogTitle = computed(() => {
const resetFormContent = () => { const resetFormContent = () => {
Object.assign(formContent, { Object.assign(formContent, {
id: "", id: "",
sourceParamType: "", type: "",
sourceParamValue: "", value: "",
sourceParamDesc: "", desc: "",
sort: 100, sort: 100,
pId: "0", pId: "0",
}) })

View File

@@ -123,17 +123,17 @@ const columns = reactive<ColumnProps<any>[]>([
}, },
{type: 'index', fixed: 'left', width: 70, label: '序号'}, {type: 'index', fixed: 'left', width: 70, label: '序号'},
{ {
prop: 'sourceParamType', prop: 'type',
label: '参数类型', label: '参数类型',
minWidth: 180, minWidth: 180,
}, },
{ {
prop: 'sourceParamDesc', prop: 'desc',
label: '参数描述', label: '参数描述',
minWidth: 220, minWidth: 220,
}, },
{ {
prop: 'sourceParamValue', prop: 'value',
label: '值', label: '值',
minWidth: 150, minWidth: 150,
}, },
@@ -193,7 +193,7 @@ const copyRow = (row) => {
} }
const getParameter = (data: TestSource.ParameterType) => { const getParameter = (data: TestSource.ParameterType) => {
if (originalParameterArr.some(item => item.sourceParamType == data.sourceParamType)) { if (originalParameterArr.some(item => item.type == data.type)) {
ElMessage.error({message: '参数类型已存在!'}) ElMessage.error({message: '参数类型已存在!'})
return; return;
} }

View File

@@ -52,7 +52,9 @@
label: i.name, label: i.name,
tips: i.description tips: i.description
})) }))
return [...unboundData, ...boundData] return [...unboundData, ...boundData]
} }
const allData = computed(() => generateData()) const allData = computed(() => generateData())
@@ -63,7 +65,7 @@ const filterMethod = (query: string, item: { label?: string }) => {
} }
// 打开弹窗,可能是新增,也可能是编辑 // 打开弹窗,可能是新增,也可能是编辑
const open = async (data: Plan.ReqPlan,) => { const open = async (data: Plan.ReqPlan) => {
dialogVisible.value = true dialogVisible.value = true
planData.value = data planData.value = data

View File

@@ -1,82 +1,91 @@
<template> <template>
<!-- 基础信息弹出框 --> <!-- 基础信息弹出框 -->
<el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogSmall"> <el-dialog :title="dialogTitle" v-model='dialogVisible' @close="close" v-bind="dialogBig">
<div> <div>
<el-form :model="formContent" ref='dialogFormRef' :rules='rules'> <el-row :gutter="24">
<el-form-item label="名称" prop="name" :label-width="100"> <el-col :span="12">
<el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off"/> <el-form :model="formContent" ref='dialogFormRef' :rules='rules'>
</el-form-item> <el-form-item label="名称" prop="name" :label-width="100">
<el-form-item label='检测源' prop='sourceIds' :label-width='100'> <el-input v-model="formContent.name" placeholder="请输入名称" autocomplete="off"/>
<el-select v-model="formContent.sourceIds" multiple collapse-tags placeholder="请选择检测源"> </el-form-item>
<el-form-item label='检测源' prop='sourceIds' :label-width='100'>
<el-select v-model="formContent.sourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择检测源">
<el-option <el-option
v-for="(option, index) in pqSourceArray" v-for="(option, index) in pqSourceArray"
:key="index" :key="index"
:label="option.label" :label="option.label"
:value="option.value" :value="option.value"
/> />
</el-select> </el-select>
</el-form-item>
<el-form-item label="数据源" prop="datasourceIds" :label-width="100">
<el-select v-model="formContent.datasourceIds" :multiple="selectByMode" collapse-tags placeholder="请选择数据源" autocomplete="off">
<el-option
v-for="item in dictStore.getDictData(dataSourceType)"
:key="item.id"
:label="item.name"
:value="item.value || ''"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="数据源" prop="datasourceIds" :label-width="100">
<el-select v-model="formContent.datasourceIds" multiple collapse-tags placeholder="请选择数据源" autocomplete="off" >
<el-option
v-for="item in dictStore.getDictData(dataSourceType)"
:key="item.id"
:label="item.name"
:value="item.value || ''"
/>
</el-select>
</el-form-item>
<el-form-item label="检测脚本" prop="scriptId" :label-width="100"> <el-form-item label="检测脚本" prop="scriptId" :label-width="100">
<el-select v-model="formContent.scriptId" placeholder="请选择检测脚本" autocomplete="off" > <el-select v-model="formContent.scriptId" placeholder="请选择检测脚本" autocomplete="off">
<el-option <el-option
v-for="(option, index) in pqScriptArray" v-for="(option, index) in pqScriptArray"
:key="index" :key="index"
:label="option.label" :label="option.label"
:value="option.value" :value="option.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="误差体系" prop="errorSysId" :label-width="100"> <el-form-item label="误差体系" prop="errorSysId" :label-width="100">
<el-select v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off"> <el-select v-model="formContent.errorSysId" placeholder="请选择误差体系" autocomplete="off">
<el-option <el-option
v-for="(option, index) in pqErrorArray" v-for="(option, index) in pqErrorArray"
:key="index" :key="index"
:label="option.label" :label="option.label"
:value="option.value" :value="option.value"
/>
</el-select>
</el-form-item>
<el-form-item label='被检设备' :label-width='100' prop='devIds'>
<el-select v-model="formContent.devIds" multiple collapse-tags placeholder="请选择被检设备">
<el-option
v-for="(option, index) in pqDevArray"
:key="index"
:label="option.label"
:value="option.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="守时检测" :label-width="100" prop='timeCheck'> <el-form-item label="守时检测" :label-width="100" prop='timeCheck'>
<el-radio-group v-model="formContent.timeCheck" > <el-radio-group v-model="formContent.timeCheck">
<el-radio :value="1"></el-radio> <el-radio :value="1"></el-radio>
<el-radio :value="0"></el-radio> <el-radio :value="0"></el-radio>
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-col>
<el-col :span="12">
<el-transfer
v-model="value"
filterable
:filter-method="filterMethod"
filter-placeholder="请输入内容搜索"
:data="allData"
:titles="['未绑定设备', '已绑定设备']">
<template #default="{ option }">
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
<span>{{ option.label }}</span>
</el-tooltip>
</template>
</el-transfer>
</el-col>
</el-row>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click='close()'> </el-button>
<el-button type="primary" @click='save()'> </el-button>
</div> </div>
<template #footer> </template>
<div class="dialog-footer"> </el-dialog>
<el-button @click='close()'> </el-button>
<el-button type="primary" @click='save()' > </el-button>
</div>
</template>
</el-dialog>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import{ElMessage, type FormInstance,type FormItemRule}from'element-plus' import{ElMessage, type FormInstance,type FormItemRule}from'element-plus'
import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue'; import { defineProps, defineEmits, reactive,watch,ref, type Ref, computed } from 'vue';
import { dialogSmall} from '@/utils/elementBind' import { dialogBig} from '@/utils/elementBind'
import { type Plan } from '@/api/plan/interface'; import { type Plan } from '@/api/plan/interface';
import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList } from '@/api/plan/plan.ts' import { addPlan, updatePlan,getUnboundPqDevList,getBoundPqDevList,getPqErrSysList,getPqScriptList,getTestSourceList } from '@/api/plan/plan.ts'
import { useDictStore } from '@/stores/modules/dict' import { useDictStore } from '@/stores/modules/dict'
@@ -89,6 +98,7 @@
// 定义弹出组件元信息 // 定义弹出组件元信息
const dialogFormRef = ref() const dialogFormRef = ref()
const mode = ref() const mode = ref()
const selectByMode = ref(true)
const pqSourceList=ref<TestSource.ResTestSource[]>([])//获取指定模式下所有检测源 const pqSourceList=ref<TestSource.ResTestSource[]>([])//获取指定模式下所有检测源
const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测源 const pqScriptList=ref<TestScript.ResTestScript[]>([])//获取指定模式下所有检测源
const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有检测源 const pqErrSysList=ref<ErrorSystem.ErrorSystemList[]>([])//获取指定模式下所有检测源
@@ -98,6 +108,32 @@
const pqScriptArray = ref<{ label: string; value: string; }[]>() const pqScriptArray = ref<{ label: string; value: string; }[]>()
const pqErrorArray = ref<{ label: string; value: string; }[]>() const pqErrorArray = ref<{ label: string; value: string; }[]>()
const pqDevArray = ref<{ label: string; value: string; }[]>() const pqDevArray = ref<{ label: string; value: string; }[]>()
const unboundPqDevList=ref<Device.ReqPqDevParams[]>([])//指定模式下所有未绑定的设备
const boundPqDevList=ref<Device.ReqPqDevParams[]>([])//根据检测计划id查询出所有已绑定的设备
const value = ref<string[]>([])
const allData = computed(() => generateData())
const generateData = () => {
const unboundData = unboundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
key: i.id,
label: i.name,
//tips: i.description
}))
const boundData = boundPqDevList.value.map((i: Device.ReqPqDevParams) => ({
key: i.id,
label: i.name,
//tips: i.description
}))
return [...unboundData, ...boundData]
}
const filterMethod = (query: string, item: { label?: string }) => {
return item.label?.toLowerCase().includes(query.toLowerCase()) ?? false
}
function useMetaInfo() { function useMetaInfo() {
const dialogVisible = ref(false) const dialogVisible = ref(false)
const titleType = ref('add') const titleType = ref('add')
@@ -120,7 +156,7 @@
errorSysName:'', errorSysName:'',
sourceName:'', sourceName:'',
devIds:[], devIds:[],
sourceIds:[], sourceIds:'',
datasourceIds:'', datasourceIds:'',
}) })
return { dialogVisible, titleType, formContent } return { dialogVisible, titleType, formContent }
@@ -150,7 +186,7 @@
errorSysName:'', errorSysName:'',
sourceName:'', sourceName:'',
devIds:[], devIds:[],
sourceIds:[], sourceIds:'',
datasourceIds:'', datasourceIds:'',
} }
) )
@@ -188,18 +224,44 @@ const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
try { try {
dialogFormRef.value?.validate(async (valid: boolean) => { dialogFormRef.value?.validate(async (valid: boolean) => {
if (valid) { if (valid) {
formContent.devIds = value.value
// 将 formContent.devIds 转换为 ReqPqDevParams 数组
boundPqDevList.value = pqDevList.value
.filter(device => formContent.devIds.includes(device.id))
.map(device => ({
id: device.id,
name: device.name,
devType: device.devType,
createTime: device.createDate,
pattern: device.pattern,
pageNum: 1,
pageSize: 10
}));
console.log('保持',formContent.devIds)
if (formContent.id) { if (formContent.id) {
await updatePlan(formContent); if( mode.value === '比对式'){
await updatePlan(formContent)
}else{
await updatePlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
}
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })
console.log('保存完成后还有吗',boundPqDevList)
console.log('保存完成后还有吗1',formContent.devIds)
console.log('保存完成后还有吗2',unboundPqDevList)
} else { } else {
// 新增需要把设备模式转成字典ID // 新增需要把设备模式转成字典ID
const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.pattern); const patternItem = dictStore.getDictData('Pattern').find(item => item.name === formContent.pattern);
if (patternItem) { if (patternItem) {
formContent.pattern = patternItem.id; formContent.pattern = patternItem.id;
} }
await addPlan(formContent); if( mode.value === '比对式'){
await addPlan(formContent);
}else{
await addPlan({...formContent,'sourceIds':[formContent.sourceIds],'datasourceIds':[formContent.datasourceIds]});
}
ElMessage.success({ message: `${dialogTitle.value}成功!` }) ElMessage.success({ message: `${dialogTitle.value}成功!` })
} }
close() close()
// 刷新表格 // 刷新表格
await props.refreshTable!() await props.refreshTable!()
@@ -225,7 +287,7 @@ const open = async (sign: string,
dialogVisible.value = true dialogVisible.value = true
const pqSource_Result = await getTestSourceList(data); const pqSource_Result = await getTestSourceList(data);
pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[]; pqSourceList.value = pqSource_Result.data as TestSource.ResTestSource[];
const PqScript_Result = await getPqScriptList(data); const PqScript_Result = await getPqScriptList(data);
pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[]; pqScriptList.value = PqScript_Result.data as TestScript.ResTestScript[];
const PqErrSys_Result = await getPqErrSysList(); const PqErrSys_Result = await getPqErrSysList();
@@ -243,22 +305,73 @@ const open = async (sign: string,
{ {
const pqDevList_Result = await getUnboundPqDevList(data); const pqDevList_Result = await getUnboundPqDevList(data);
pqDevList.value = pqDevList_Result.data as Device.ResPqDev[]; pqDevList.value = pqDevList_Result.data as Device.ResPqDev[];
// 初始化 boundPqDevList 为空数组
unboundPqDevList.value = pqDevList.value.map((item) => ({
id: item.id,
name: item.name,
devType: item.devType,
createTime: item.createDate,
pattern: item.pattern,
pageNum: 1,
pageSize: 10
}));
boundPqDevList.value = [];
}else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值 }else{//编辑时先给表单赋值(这会没接收被检设备),需要手动再给被检设备复制后整体表单赋值
const boundPqDevList_Result = await getBoundPqDevList({ 'planId': data.id }); const boundPqDevList_Result = await getBoundPqDevList({ 'planId': data.id });
const unboundPqDevList_Result = await getUnboundPqDevList(data); const unboundPqDevList_Result = await getUnboundPqDevList(data);
const boundData = Array.isArray(boundPqDevList_Result.data) ? boundPqDevList_Result.data : []; const boundData = Array.isArray(boundPqDevList_Result.data) ? boundPqDevList_Result.data : [];
const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : []; const unboundData = Array.isArray(unboundPqDevList_Result.data) ? unboundPqDevList_Result.data : [];
console.log('编辑boundData', boundData)
pqDevList.value = [...boundData,...unboundData] as Device.ResPqDev[]; pqDevList.value = [...boundData,...unboundData] as Device.ResPqDev[];
formContent.devIds = boundData.map(i => i.id );// 已绑定设备id集合 formContent.devIds = boundData.map(i => i.id );// 已绑定设备id集合
Object.assign(formContent,{ ...data }) Object.assign(formContent,{ ...data })
//设备绑定显示
unboundPqDevList.value = unboundPqDevList_Result.data as Device.ReqPqDevParams[];
boundPqDevList.value = boundPqDevList_Result.data as Device.ReqPqDevParams[];
console.log('编辑打开时', formContent.devIds)
} }
pqToArray();//将对象转为数组 pqToArray();//将对象转为数组
if( mode.value != '比对式'){
selectByMode.value = false
// 将 formContent.sourceIds 从数组转换为字符串
if (Array.isArray(formContent.sourceIds)) {
formContent.sourceIds = formContent.sourceIds.join(',');
}
// 将 formContent.sourceIds 从数组转换为字符串
if (Array.isArray(formContent.datasourceIds)) {
formContent.datasourceIds = formContent.datasourceIds.join(',');
}
}
// //设备绑定显示
// const pqDevList_Result1 = await getUnboundPqDevList(data);
// unboundPqDevList.value = pqDevList_Result1.data as Device.ReqPqDevParams[];
// const pqDevList_Result2 = await getBoundPqDevList({'planId': data.id});
// boundPqDevList.value = pqDevList_Result2.data as Device.ReqPqDevParams[];
// value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
// console.log('1245',value.value)
//设备绑定显示
// if(sign == 'add') {
// } else {
// }
value.value = boundPqDevList.value.map((i: { id: { toString: () => any } }) => i.id.toString());
console.log('1245',value.value)
} }
function pqToArray() { function pqToArray() {
const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : [] const sourceArray1 = Array.isArray(pqSourceList.value) ? pqSourceList.value : []
// 将 pqSource_Result 转换成 { label, value } 数组 // 将 pqSource_Result 转换成 { label, value } 数组
@@ -309,7 +422,7 @@ const props = defineProps<{
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
:deep(.dialog-small .el-dialog__body){ // :deep(.dialog-small .el-dialog__body){
max-height: 330px !important; // max-height: 330px !important;
} // }
</style> </style>

View File

@@ -21,7 +21,7 @@
<template #operation='scope'> <template #operation='scope'>
<el-button type='primary' link :icon='EditPen' @click="openDialog('edit',scope.row)">编辑</el-button> <el-button type='primary' link :icon='EditPen' @click="openDialog('edit',scope.row)">编辑</el-button>
<el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button> <el-button type='primary' link :icon='Delete' @click='handleDelete(scope.row)'>删除</el-button>
<el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> <!-- <el-button type='primary' link :icon='List' @click='showDeviceOpen(scope.row)'>设备绑定</el-button> -->
</template> </template>
</ProTable> </ProTable>
</div> </div>
@@ -32,8 +32,8 @@
<ErrorStandardPopup :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/> <ErrorStandardPopup :refresh-table='proTable?.getTableList' ref="errorStandardPopup"/>
<!-- 查看检测源 --> <!-- 查看检测源 -->
<TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/> <TestSourcePopup :refresh-table='proTable?.getTableList' ref="testSourcePopup"/>
<!-- 查看设备绑定 --> <!-- 查看设备绑定
<DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> <DevTransfer :refresh-table='proTable?.getTableList' ref='devTransferPopup'/> -->
</template> </template>
@@ -225,7 +225,7 @@ const columns = reactive<ColumnProps<Plan.ReqPlan>[]>([
) )
}, },
}, },
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 }, { prop: 'operation', label: '操作', fixed: 'right', width: 200 },
]) ])
const handleSourceClicked = (id: string) => { const handleSourceClicked = (id: string) => {