新增检测计划列表

This commit is contained in:
sjl
2024-10-29 11:17:04 +08:00
parent ff892d9e24
commit f9bb15ad24
12 changed files with 672 additions and 714 deletions

View File

@@ -1,9 +1,12 @@
{
"cSpell.words": [
"Chns",
"daterange",
"devicedata",
"errordata",
"errordetail",
"logdata",
"plandata",
"resourcedata",
"resourcename",
"rmark"

View File

@@ -11,3 +11,8 @@ export const getDeviceList = (params: Device.ReqDeviceParams) => {
return http.post<ResPage<Device.ResDeviceList>>(`/RoleList_Post`, params)
// return http.post<ResPage<Role.ResRoleList>>(`${rePrefix}/device/list`, params)
}
export const getPlan_DeviceList = (params: Device.DeviceList) => {
//return http.post<ResPage<Device.ResDeviceList>>(`/RoleList_Post`, params)
// return http.post<ResPage<Role.ResRoleList>>(`${rePrefix}/device/list`, params)
}

View File

@@ -45,4 +45,51 @@ const data = [
},
]
export default data
const plan_devicedata = [
{
id: '1', //装置序号ID
Name: '设备1', //设备名称
Dev_Type: 'PQS882A',//设备类型
Dev_Chns: 1, //设备通道数
Check_Result: '合格', //检测结果
Report_State: '已生成', //报告状态
Document_State: '归档', //归档状态
Check_State:'检测完成',//检测状态
ReCheck_Num: 0, //复检次数
},
{
id: '2', //装置序号ID
Name: '设备2', //设备名称
Dev_Type: 'PQS882B4',//设备类型
Dev_Chns: 4, //设备通道数
Check_Result: '/', //检测结果
Report_State: '未生成', //报告状态
Document_State: '未归档', //归档状态
Check_State:'未检',//检测状态
ReCheck_Num: 0, //复检次数
},
{
id: '3', //装置序号ID
Name: '设备3', //设备名称
Dev_Type: 'PQS882B4',//设备类型
Dev_Chns: 4, //设备通道数
Check_Result: '/', //检测结果
Report_State: '未生成', //报告状态
Document_State: '未归档', //归档状态
Check_State:'检测中',//检测状态
ReCheck_Num: 0, //复检次数
},
{
id: '4', //装置序号ID
Name: '设备4', //设备名称
Dev_Type: 'PQS882B4',//设备类型
Dev_Chns: 4, //设备通道数
Check_Result: '不合格', //检测结果
Report_State: '未生成', //报告状态
Document_State: '未归档', //归档状态
Check_State:'检测完成',//检测状态
ReCheck_Num: 1, //复检次数
},
]
export default {data,plan_devicedata}

View File

@@ -28,4 +28,41 @@ export namespace Device {
deviceCompany: string;//设备厂家
deviceModel: string; //设备模式 模拟 数字 比对
}
// 被检设备列表
export interface DeviceList {
id: string; //装置序号ID
Name: string; //设备名称
Pattern?: string; //设备模式 模拟 数字 比对
Dev_Type: string;//设备类型
Dev_Chns: number; //设备通道数
Dev_Volt?: number; //额定电压V
Dev_Curr?: number; //额定电流A
Manufacturer?: string;//生产厂家
CreateDate?: string; //生产日期
CreateId?: string; //出厂编号
Hardware_Version?: string; //固件版本
Software_Version?: string; //软件版本
IP?: string; //IP地址
Port?: number; //端口号
IsEncryption?: string; //装置是否为加密版本
Series?: string; //装置识别码3ds加密
Dev_Key?: string; //装置秘钥3ds加密
SampleID?: string; //样品编号
Arrived_Date?: string; //送样日期
City_Name?: string; //所属地市名称
GD_Name?: string; //所属供电公司名称
Sub_Name?: string; //所属电站名称
Check_State: string; //检测状态
Check_Result: string; //检测结果
Report_State: string; //报告状态
Document_State: string; //归档状态
ReCheck_Num: number; //复检次数
State?: number; //状态
Create_By?: string; //创建用户
Create_Time?: string; //创建时间
Update_By?: string; //更新用户
Update_Time?: string; //更新时间
}
}

View File

@@ -0,0 +1,44 @@
import type { ReqPage } from '@/api/interface'
import type { DatetimeFormatProps } from 'vue-i18n';
// 检测计划模块
export namespace Plan {
// 检测计划列表
export interface PlanList {
id: string; //检测计划ID
name: string; //检测计划名称
pattern: string; //模式,字典表(数字、模拟、比对)
father_Plan_Id: string; //父计划ID
dataSource_Id: string; //数据源ID
script_Id: string; //检测脚本ID
error_Sys_Id: string;//误差体系ID
test_State: string; //检测状态
report_State: string; //报告生成状态
result: string;//检测结果
state: number; //状态
create_By?: string; //创建用户
create_Time?: string;//创建时间
update_By?: string; //更新用户
update_Time?: string; //更新时间
}
// 被检设备参数
export interface ReqPlanParams extends ReqPage {
id: string; //检测计划ID
name: string; //检测计划名称
pattern: string; //模式,字典表(数字、模拟、比对)
father_Plan_Id: string; //父计划ID
dataSource_Id: string; //数据源ID
script_Id: string; //检测脚本ID
error_Sys_Id: string;//误差体系ID
test_State: string; //检测状态
report_State: string; //报告生成状态
result: string;//检测结果
state: number; //状态
create_By?: string; //创建用户
create_Time?: string;//创建时间
update_By?: string; //更新用户
update_Time?: string; //更新时间
}
}

View File

@@ -0,0 +1,125 @@
import type {Plan} from "./interface"
const plandata = ref<Plan.PlanList[]>([
{
'id': '1',
'name': '检测计划1',
'pattern':'模拟式',
'father_Plan_Id':'/',
'dataSource_Id':'分钟统计数据最大值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 1650.2- 2016',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '2',
'name': '检测子计划1-1',
'pattern':'模拟式',
'father_Plan_Id':'检测计划1',
'dataSource_Id':'分钟统计数据最大值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 1650.2- 2016',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '3',
'name': '检测子计划1-2',
'pattern':'模拟式',
'father_Plan_Id':'检测计划1',
'dataSource_Id':'分钟统计数据最大值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 1650.2- 2016',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '4',
'name': '检测计划2',
'pattern':'模拟式',
'father_Plan_Id':'/',
'dataSource_Id':'分钟统计数据最小值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 10650.2 - 2021',
'test_State':'检测完成',
'report_State':'部分生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '5',
'name': '检测计划3',
'pattern':'模拟式',
'father_Plan_Id':'/',
'dataSource_Id':'分钟统计数据最大值',
'script_Id':'/',
'error_Sys_Id':'/',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '6',
'name': '检测子计划4',
'pattern':'模拟式',
'father_Plan_Id':'/',
'dataSource_Id':'分钟统计数据CP95值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 1650.2- 2016',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
{
'id': '7',
'name': '检测子计划4-1',
'pattern':'模拟式',
'father_Plan_Id':'检测计划4',
'dataSource_Id':'分钟统计数据CP95值',
'script_Id':'国网入网检测脚本(单影响量-模拟式)',
'error_Sys_Id':'Q/GDW 1650.2- 2016',
'test_State':'未检',
'report_State':'未生成',
'result':'符合',
'state': 1,
'create_By':'',
'create_Time':'',
'update_By':'',
'update_Time':'',
},
])
export default plandata

View File

@@ -43,10 +43,11 @@
class='triangle-button'
type='primary'
@click='prevPeriod'
@change="emitDateChange"
>
<div class='left_triangle'></div>
</el-button>
<el-button class='triangle-button' type='primary' @click='goToCurrent'>
<el-button class='triangle-button' type='primary' @click='goToCurrent' >
当前
</el-button>
<el-button
@@ -108,6 +109,7 @@ interface TimeUnit {
// 发出日期变化事件
const emitDateChange = () => {
emit('update-dates', startDate.value, endDate.value);
//console.log('emitDateChange', startDate.value, endDate.value);
};
// 在组件挂载时更新日期范围
@@ -228,6 +230,7 @@ interface TimeUnit {
endDateAdjusted.setHours(0, 0, 0, 0);
// 仅比较日期部分
isNextDisabled.value = endDateAdjusted >= maxDate;
emitDateChange(); // 变化时也发出更新事件
}
// 限制开始日期不能选择超过当前日期
@@ -241,10 +244,7 @@ interface TimeUnit {
return date > today.value || (start && date <= start);
}
defineExpose({
startDate,
endDate,
})
</script>

View File

@@ -13,6 +13,8 @@
<el-button type='primary' :icon='Upload'>导出csv</el-button>
</template>
</ProTable>
</div>
</template>
@@ -24,7 +26,7 @@ import ProTable from '@/components/ProTable/index.vue'
import { Upload ,DataAnalysis} from '@element-plus/icons-vue'
import logDataList from '@/api/log/logData'
import type { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
import { reactive,ref } from 'vue'
import { reactive,ref,watch } from 'vue'
let multipleSelection = ref<string[]>([])
const logData = logDataList
// 定义包含和排除的单位
@@ -53,7 +55,7 @@ const columns = reactive<ColumnProps<Log.LogList>[]>([
width: 200,
search: {
span: 2,
render: ({ searchParam }) => {
render: () => {
return (
<div class='flx-flex-start'>
<TimeControl
@@ -90,11 +92,10 @@ const columns = reactive<ColumnProps<Log.LogList>[]>([
// 处理选择变化
const handleSelectionChange = (selection: Log.LogList[]) => {
multipleSelection.value = selection.map(row => row.id) // 更新选中的行
}
</script>
<style scoped>

View File

@@ -0,0 +1,130 @@
<template>
<el-dialog :title="dialogTitle" :model-value="visible" @close="handleCancel" v-bind="dialogSmall">
<el-form :model="formData" >
<el-form-item label="名称" prop="name">
<el-input v-model="formData.name" :disabled="isReadOnly"/>
</el-form-item>
<el-form-item label="父计划" prop="type">
<el-select v-model="formData.father_Plan_Id" placeholder="请选择父计划" :disabled="isReadOnly">
<el-option
v-for="plan in fatherPlanList"
:key="plan.value"
:label="plan.label"
:value="plan.value">
</el-option>
</el-select>
</el-form-item> <el-form-item label="数据源" prop="type">
<el-select v-model="formData.dataSource_Id" placeholder="请选择数据源" :disabled="isReadOnly">
<el-option
v-for="plan in sourceList"
:key="plan.value"
:label="plan.label"
:value="plan.value">
</el-option>
</el-select>
</el-form-item> <el-form-item label="检测脚本" prop="type">
<el-select v-model="formData.script_Id" placeholder="请选择检测脚本" :disabled="isReadOnly">
<el-option
v-for="plan in scriptList"
:key="plan.value"
:label="plan.label"
:value="plan.value">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="误差体系" prop="type">
<el-select v-model="formData.error_Sys_Id" placeholder="请选择误差体系" :disabled="isReadOnly">
<el-option
v-for="plan in errorList"
:key="plan.value"
:label="plan.label"
:value="plan.value">
</el-option>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleCancel"> </el-button>
<el-button type="primary" @click="handleSubmit" :disabled="isReadOnly"> </el-button>
</div>
</template>
</el-dialog>
</template>
<script setup lang="ts">
import { defineProps, defineEmits, reactive,watch,ref } from 'vue';
import { dialogSmall} from '@/utils/elementBind'
const props = defineProps<{
visible: boolean;
dialogTitle: string;
isReadOnly: boolean,
formData: {
id:string;
name: string;
pattern: string; //模式,字典表(数字、模拟、比对)
father_Plan_Id: string; //父计划ID
dataSource_Id: string; //数据源ID
script_Id: string; //检测脚本ID
error_Sys_Id: string;//误差体系ID
test_State: string; //检测状态
report_State: string; //报告生成状态
result: string;//检测结果
state: number; //状态
};
}>();
const fatherPlanList = [
{ label: '/', value: 'type0' },
{ label: '检测计划1', value: 'type1' },
{ label: '检测计划2', value: 'type2' },
{ label: '检测计划3', value: 'type3' },
{ label: '检测计划4', value: 'type4' },
];
const sourceList = [
{ label: '分钟统计数据最大值', value: 'type0' },
{ label: '分钟统计数据最大值', value: 'type1' },
{ label: '分钟统计数据CP95值', value: 'type2' },
];
const scriptList = [
{ label: '/', value: 'type0' },
{ label: '国网入网检测脚本(单影响量-模拟式)', value: 'type1' },
{ label: '国网入网检测脚本Q/GDW 10650.4 - 2021) 数字式', value: 'type1' },
];
const errorList = [
{ label: 'Q/GDW 1650.2- 2016', value: 'type0' },
{ label: 'Q/GDW 10650.2 - 2021', value: 'type1' },
];
const emit = defineEmits<{
(e: 'update:visible', value: boolean): void;
(e: 'submit', data: any): void;
}>();
const handleCancel = () => {
emit('update:visible', false); // 关闭对话框
};
const handleSubmit = () => {
emit('submit', props.formData); // 提交表单数据
emit('update:visible', false); // 提交后关闭对话框
};
// 当 props.visible 改变时,更新 formData
watch(() => props.visible, (newVal) => {
if (!newVal) {
// 这里可以重置表单数据,如果需要的话
}
});
</script>
<style scoped>
</style>

View File

@@ -0,0 +1,122 @@
<!--单列-->
<template>
<el-dialog class='table-box'
v-model='dialogVisible'
top='114px'
:style="{height:height,maxHeight:height,overflow:'hidden'}"
:title='title'
:width='width'
:modal='false'>
<div class='table-box'>
<ProTable
ref='proTable'
:columns='columns'
:data='deviceData'
type='selection'
@selection-change="handleSelectionChange"
>
<!-- 表格 header 按钮 -->
<template #tableHeader>
<el-button type='primary' :icon='Download' >导入设备</el-button>
<el-button type='primary' :icon='Download' >下载报告</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!multipleSelection.length'>
批量删除
</el-button>
</template>
<!-- 表格操作 -->
<template #operation>
<el-button type='primary' link :icon='View'>查看</el-button>
<el-button type='primary' link :icon='Delete' >删除</el-button>
</template>
</ProTable>
</div>
</el-dialog>
</template>
<script setup lang='tsx'>
import { Delete, View ,Upload,Download} from '@element-plus/icons-vue'
import { reactive,ref } from 'vue'
import type { Device } from '@/api/device/interface'
import ProTable from '@/components/ProTable/index.vue'
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
import deviceDataList from '@/api/device/deviceData'
const deviceData = deviceDataList.plan_devicedata
const dialogVisible = ref(false)
const title = ref('')
let multipleSelection = ref<string[]>([])
// 表格配置项
const columns = reactive<ColumnProps<Device.DeviceList>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{
prop: 'Name',
label: '名称',
minWidth: 120,
},
{
prop: 'Dev_Type',
label: '类型',
minWidth: 100,
},
{
prop: 'Dev_Chns',
label: '通道数',
minWidth: 70,
},
{
prop: 'ReCheck_Num',
label: '复检次数',
minWidth: 70,
},
{
prop: 'Report_State',
label: '报告状态',
minWidth: 130,
},
{
prop: 'Check_Result',
label: '检测结果',
minWidth: 130,
},
{
prop: 'Check_State',
label: '检测状态',
minWidth: 130,
},
{
prop: 'Document_State',
label: '归档状态',
minWidth: 130,
},
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 200 },
])
const open = (textTitle: string) => {
dialogVisible.value = true
title.value = textTitle
}
defineExpose({ open })
const props = defineProps({
width: {
type: String,
default: '800px',
},
height: {
type: String,
default: '744px',
},
})
//选中
// 处理选择变化
const handleSelectionChange = (selection:Device.DeviceList[]) => {
multipleSelection.value = selection.map(row => row.id); // 更新选中的行
};
</script>
<style>
</style>

View File

@@ -1,239 +0,0 @@
<template>
<el-dialog
v-model="dialogVisible"
:title="dialogTitle"
width="50%"
:before-close="handleClose"
:draggable="true"
:destroy-on-close="true"
:append-to-body="true"
>
<div class="container">
<el-form
ref="ruleFormRef"
style="max-width: 600px"
:model="ruleForm"
:rules="rules"
label-width="auto"
class="demo-ruleForm"
:size="formSize"
status-icon
>
<el-form-item label="Activity name" prop="name">
<el-input v-model="ruleForm.name" />
</el-form-item>
<el-form-item label="Activity zone" prop="region">
<el-select v-model="ruleForm.region" placeholder="Activity zone">
<el-option label="Zone one" value="shanghai" />
<el-option label="Zone two" value="beijing" />
</el-select>
</el-form-item>
<el-form-item label="Activity count" prop="count">
<el-select-v2
v-model="ruleForm.count"
placeholder="Activity count"
:options="options"
/>
</el-form-item>
<el-form-item label="Activity time" required>
<el-col :span="11">
<el-form-item prop="date1">
<el-date-picker
v-model="ruleForm.date1"
type="date"
aria-label="Pick a date"
placeholder="Pick a date"
style="width: 100%"
/>
</el-form-item>
</el-col>
<el-col class="text-center" :span="2">
<span class="text-gray-500">-</span>
</el-col>
<el-col :span="11">
<el-form-item prop="date2">
<el-time-picker
v-model="ruleForm.date2"
aria-label="Pick a time"
placeholder="Pick a time"
style="width: 100%"
/>
</el-form-item>
</el-col>
</el-form-item>
<el-form-item label="Instant delivery" prop="delivery">
<el-switch v-model="ruleForm.delivery" />
</el-form-item>
<el-form-item label="Activity location" prop="location">
<el-segmented v-model="ruleForm.location" :options="locationOptions" />
</el-form-item>
<el-form-item label="Activity type" prop="type">
<el-checkbox-group v-model="ruleForm.type">
<el-checkbox value="Online activities" name="type">
Online activities
</el-checkbox>
<el-checkbox value="Promotion activities" name="type">
Promotion activities
</el-checkbox>
<el-checkbox value="Offline activities" name="type">
Offline activities
</el-checkbox>
<el-checkbox value="Simple brand exposure" name="type">
Simple brand exposure
</el-checkbox>
</el-checkbox-group>
</el-form-item>
<el-form-item label="Resources" prop="resource">
<el-radio-group v-model="ruleForm.resource">
<el-radio value="Sponsorship">Sponsorship</el-radio>
<el-radio value="Venue">Venue</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="Activity form" prop="desc">
<el-input v-model="ruleForm.desc" type="textarea" />
</el-form-item>
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="resetForm(ruleFormRef)">取消</el-button>
<el-button type="primary" @click="submitForm(ruleFormRef)">
确定
</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import type { ComponentSize, FormInstance, FormRules } from 'element-plus'
interface RuleForm {
name: string
region: string
count: string
date1: string
date2: string
delivery: boolean
location: string
type: string[]
resource: string
desc: string
}
const formSize = ref<ComponentSize>('default')
const ruleFormRef = ref<FormInstance>()
const ruleForm = reactive<RuleForm>({
name: 'Hello',
region: '',
count: '',
date1: '',
date2: '',
delivery: false,
location: '',
type: [],
resource: '',
desc: '',
})
const locationOptions = ['Home', 'Company', 'School']
const rules = reactive<FormRules<RuleForm>>({
name: [
{ required: true, message: 'Please input Activity name', trigger: 'blur' },
{ min: 3, max: 5, message: 'Length should be 3 to 5', trigger: 'blur' },
],
region: [
{
required: true,
message: 'Please select Activity zone',
trigger: 'change',
},
],
count: [
{
required: true,
message: 'Please select Activity count',
trigger: 'change',
},
],
date1: [
{
type: 'date',
required: true,
message: 'Please pick a date',
trigger: 'change',
},
],
date2: [
{
type: 'date',
required: true,
message: 'Please pick a time',
trigger: 'change',
},
],
location: [
{
required: true,
message: 'Please select a location',
trigger: 'change',
},
],
type: [
{
type: 'array',
required: true,
message: 'Please select at least one activity type',
trigger: 'change',
},
],
resource: [
{
required: true,
message: 'Please select activity resource',
trigger: 'change',
},
],
desc: [
{ required: true, message: 'Please input activity form', trigger: 'blur' },
],
})
const submitForm = async (formEl: FormInstance | undefined) => {
if (!formEl) return
await formEl.validate((valid, fields) => {
if (valid) {
console.log('submit!')
close()
} else {
console.log('error submit!', fields)
}
})
}
const resetForm = (formEl: FormInstance | undefined) => {
close()
if (!formEl) return
formEl.resetFields()
}
const options = Array.from({ length: 10000 }).map((_, idx) => ({
value: `${idx + 1}`,
label: `${idx + 1}`,
}))
onMounted(() => {
console.log();
});
const dialogVisible = ref<boolean>(false);
const dialogTitle = ref<string>("");
const open = (title: string) => {
dialogTitle.value = title;
dialogVisible.value = true;
};
const close=()=>{
dialogVisible.value = false;
}
onMounted(() => {
console.log();
});
defineExpose({ open });
</script>
<style lang="scss" scoped></style>

View File

@@ -1,481 +1,164 @@
<template>
<div class="table-box planList">
<ProTable
ref="proTable"
:columns="columns"
:request-api="getTableList"
:init-param="initParam"
:data-callback="dataCallback"
@drag-sort="sortTable"
>
<!-- 表格 header 按钮 -->
<template #tableHeader>
<el-form :model="searchForm">
<el-form-item label="检测时间">
<el-select
v-model="searchForm.intervalType"
style="width: 80px !important"
>
<el-option :value="0" label="按周">按周</el-option>
<el-option :value="1" label="按月">按月</el-option>
<el-option :value="2" label="按日">按日</el-option>
</el-select>
</el-form-item>
<el-form-item label="">
<!-- <el-date-picker v-model="searchForm.time"></el-date-picker> -->
<el-date-picker
style="width: 220px"
v-model="searchForm.time"
type="daterange"
unlink-panels
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:shortcuts="shortcuts"
/>
</el-form-item>
<el-form-item label="检测状态">
<el-select v-model="searchForm.checkStatus">
<el-option :value="0" label="全部"></el-option>
<el-option :value="1" label="未检测"></el-option>
<el-option :value="2" label="检测中"></el-option>
<el-option :value="3" label="检测完成"></el-option>
</el-select>
</el-form-item>
<el-form-item label="检测报告状态">
<el-select v-model="searchForm.checkReportStatus">
<el-option :value="0" label="全部"></el-option>
<el-option :value="1" label="未生成"></el-option>
<el-option :value="2" label="部分生成"></el-option>
<el-option :value="3" label="全部生成"></el-option>
</el-select>
</el-form-item>
<el-form-item label="检测结果">
<el-select v-model="searchForm.checkResult">
<el-option :value="0" label="全部"></el-option>
<el-option :value="1" label="/"></el-option>
<el-option :value="2" label="符合"></el-option>
<el-option :value="3" label="不符合"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Search" @click="handleSearch"
>查询</el-button
>
<el-button :icon="Refresh" @click="handleRefresh">重置</el-button>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Upload" @click="handleRefresh"
>导入</el-button
>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Check" @click="handleRefresh"
>合并</el-button
>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="Plus" @click="handleRefresh"
>新增</el-button
>
</el-form-item>
<el-form-item>
<el-button type="danger" :icon="Delete" @click="handleRefresh"
>删除</el-button
>
</el-form-item>
</el-form>
<!-- <el-button
v-auth="'add'"
type="primary"
:icon="CirclePlus"
@click="openDrawer('新增')"
>新增用户</el-button
>
<el-button
v-auth="'batchAdd'"
type="primary"
:icon="Upload"
plain
@click="batchAdd"
>批量添加用户</el-button
>
<el-button
v-auth="'export'"
type="primary"
:icon="Download"
plain
@click="downloadFile"
>导出用户数据</el-button
>
<el-button type="primary" plain @click="toDetail"
>To 子集详情页面</el-button
>
<el-button
type="danger"
:icon="Delete"
plain
:disabled="!scope.isSelected"
@click="batchDelete(scope.selectedListIds)"
>
批量删除用户
</el-button> -->
</template>
<!-- Expand -->
<!-- <template #expand="scope">
{{ scope.row }}
</template> -->
<div class='table-box' ref='popupBaseView'>
<ProTable
ref='proTable'
:columns='columns'
:data='planData'
>
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button type='primary' :icon='Download' >导入</el-button>
<el-button type='primary' :icon='CirclePlus' >合并</el-button>
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
批量删除
</el-button>
</template>
<!-- 表格操作 -->
<template #operation="scope">
<el-button
type="primary"
link
:icon="View"
@click="handleDetails('查看', scope.row)"
>查看</el-button
>
<el-button
type="primary"
link
:icon="EditPen"
@click="openDrawer('编辑', scope.row)"
>导出</el-button
>
<el-button
type="primary"
link
:icon="Delete"
@click="deleteAccount(scope.row)"
>删除</el-button
>
</template>
</ProTable>
</div>
<plan-details ref="detailsRef"></plan-details>
<template #operation='scope'>
<el-button type='primary' link :icon='View' @click="handleRowClick(scope.row)">查看</el-button>
<el-button type='primary' link :icon='Upload'>导出</el-button>
<el-button type='primary' link :icon='EditPen' @click="openEditDialog(scope.row)">编辑</el-button>
<el-button type='primary' link :icon='Delete' >删除</el-button>
<el-button type='primary' link :icon='List' @click="showDeviceOpen(scope.row)">设备</el-button>
</template>
</ProTable>
<!-- 新增/编辑误差体系对话框 -->
<PlanDialog
:visible="dialogFormVisible"
:formData="dialogForm"
:dialogTitle="dialogTitle"
:is-read-only="isReadOnly"
@update:visible="dialogFormVisible = $event"
/>
</div>
<open :width='viewWidth' :height='viewHeight' ref='openView' />
</template>
<script setup lang="tsx" name="useProTable">
import { useRouter } from "vue-router";
import { User } from "@/api/interface";
import { useHandleData } from "@/hooks/useHandleData";
import { useDownload } from "@/hooks/useDownload";
import { ElMessage, ElMessageBox } from "element-plus";
import ProTable from "@/components/ProTable/index.vue";
import ImportExcel from "@/components/ImportExcel/index.vue";
import planDetails from "./components/details.vue";
import {
CirclePlus,
Delete,
EditPen,
Download,
Upload,
View,
Check,
Plus,
Refresh,
Search,
} from "@element-plus/icons-vue";
import { getPlanList } from "@/api/plan/planList";
const router = useRouter();
const value1 = ref("");
const value2 = ref("");
<script setup lang="ts" name='useProTable'>
import ProTable from '@/components/ProTable/index.vue'
import type { ColumnProps } from '@/components/ProTable/interface'
import { CirclePlus, Delete,EditPen,View,Upload,Download,List} from '@element-plus/icons-vue'
import planDataList from '@/api/plan/planData'
import { reactive,ref } from 'vue'
import type { Plan } from '@/api/plan/interface'
import PlanDialog from "@/views/plan/planList/components/PlanDialog.vue"; // 导入子组件
import Open from '@/views/plan/planList/components/PlanOpen.vue'
import { useViewSize } from '@/hooks/useViewSize'
const shortcuts = [
{
text: "最近一周",
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
return [start, end];
},
},
{
text: "最近一个月",
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
return [start, end];
},
},
{
text: "最近三个月",
value: () => {
const end = new Date();
const start = new Date();
start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
return [start, end];
},
},
];
// 跳转详情页
const toDetail = () => {
router.push(
`/proTable/useProTable/detail/${Math.random().toFixed(3)}?params=detail-page`
);
};
const searchForm = ref({
intervalType: 0,
time: ["2024-08-20", "2024-08-27"],
searchBeginTime: "",
searchEndTime: "",
checkStatus: 0,
checkReportStatus: 0,
checkResult: 0,
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
const openView = ref()
const planData = planDataList
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const isReadOnly = ref(false)
const dialogForm = ref<Plan.PlanList>({
id: '',
name: '',
pattern:'',
father_Plan_Id:'',
dataSource_Id:'',
script_Id:'',
error_Sys_Id:'',
test_State: '',
report_State: '',
state:0,
result:'',
});
// ProTable 实例
const proTable = ref<ProTableInstance>();
// 如果表格需要初始化请求参数,直接定义传给 ProTable (之后每次请求都会自动带上该参数,此参数更改之后也会一直带上,改变此参数会自动刷新表格数据)
const initParam = reactive({ type: 1, pageNum: 1, pageSize: 10 });
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const tableList = ref([]);
const dataCallback = (data: any) => {
return {
list: data || data.data || data.list,
total: data.length || data.total,
};
};
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数params 为当前所有的请求参数(包括分页),最后返回请求列表接口
// 默认不做操作就直接在 ProTable 组件上绑定 :requestApi="getUserList"
const getTableList = (params: any) => {
let newParams = JSON.parse(JSON.stringify(params));
newParams.createTime && (newParams.startTime = newParams.createTime[0]);
newParams.createTime && (newParams.endTime = newParams.createTime[1]);
delete newParams.createTime;
return getPlanList(newParams);
};
//查看详情
const detailsRef: any = ref();
const handleDetails = () => {
console.log(detailsRef.value, "+++++++++++++++");
detailsRef.value.open("查看计划");
};
// 表格配置项
const columns = reactive<ColumnProps<User.ResUserList>[]>([
{ type: "selection", fixed: "left", width: 70 },
{ type: "sort", label: "Sort", width: 80 },
{ type: "expand", label: "Expand", width: 85 },
{
prop: "planName",
label: "计划名称",
width: 120,
},
{
prop: "checkMode",
label: "检测模式",
width: 120,
render: (scope) => {
return scope.row.checkMode == 0
? "模拟式"
: scope.row.checkMode == 1
? "对比式"
: scope.row.checkMode == 2
? "数字式"
: scope.row.checkMode;
},
},
{
prop: "checkFrom",
label: "检测源",
width: 120,
render: (scope) => {
return scope.row.checkFrom == 0
? "标准源-福禄克-6100A"
: scope.row.checkFrom == 1
? "标准源-昂立-PF2"
: scope.row.checkFrom == 2
? "高精度设备-PQS882-1"
: scope.row.checkFrom;
},
},
{
prop: "numberFromName",
label: "源名称",
render: (scope) => {
return scope.row.numberFromName == 0
? "分钟统计数据最大值"
: scope.row.numberFromName == 1
? "分钟统计数据最小值"
: scope.row.numberFromName == 2
? "分钟统计数据CP95值"
: scope.row.numberFromName;
},
},
{
prop: "checkExe",
label: "检测脚本",
width: 120,
render: (scope) => {
return scope.row.checkExe == 0
? "国网入网检测脚本(单影响量-模拟式)"
: scope.row.checkExe == 1
? "国网入网检测脚本"
: scope.row.checkExe == 2
? "/"
: scope.row.checkExe;
},
},
{
prop: "wctx",
label: "误差体系",
width: 120,
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;
},
},
{
type: "tag",
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: "operation", label: "操作", fixed: "right", width: 250 },
]);
//重置查询条件
const resetSearchForm = () => {
searchForm.value = {
intervalType: 0,
time: ["2024-08-20", "2024-08-27"],
searchBeginTime: "",
searchEndTime: "",
checkStatus: 0,
checkReportStatus: 0,
checkResult: 0,
const columns = reactive<ColumnProps<Plan.PlanList>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{
prop: 'name',
label: '检测计划名称',
width: 200,
},
{
prop: 'dataSource_Id',
label: '数据源名称',
width: 200,
},
{
prop: 'script_Id',
label: '检测脚本',
width: 300,
},
{
prop: 'error_Sys_Id',
label: '误差体系',
width: 200,
},
{
prop: 'test_State',
label: '检测状态',
width: 100,
search: { el: 'select', props: { filterable: true } },
},
{
prop: 'report_State',
label: '检测报告状态',
width: 150,
search: { el: 'select', props: { filterable: true } },
},
{
prop: 'result',
label: '检测结果',
width: 100,
search: { el: 'select', props: { filterable: true } },
},
{
prop: 'father_Plan_Id',
label: '父节点',
width: 200,
},
{ prop: 'operation', label: '操作', fixed: 'right' ,width: 350, },
])
// 打开编辑对话框
const openEditDialog = (planSystem: Plan.PlanList) => {
dialogForm.value = {...planSystem};
dialogTitle.value = '编辑检测计划';
isReadOnly.value = false;
dialogFormVisible.value = true; // 打开对话框
};
const openAddDialog = () => {
dialogForm.value = {
id: '',
name: '',
pattern:'',
father_Plan_Id:'',
dataSource_Id:'',
script_Id:'',
error_Sys_Id:'',
test_State: '',
report_State: '',
state:0,
result:'',
};
};
//查询
const handleSearch = () => {
proTable.value?.getTableList();
};
//重置
const handleRefresh = () => {
proTable.value?.getTableList();
};
// 表格拖拽排序
const sortTable = ({
newIndex,
oldIndex,
}: {
newIndex?: number;
oldIndex?: number;
}) => {
console.log(newIndex, oldIndex);
console.log(proTable.value?.tableData);
ElMessage.success("修改列表排序成功");
dialogTitle.value = '新增检测计划';
isReadOnly.value = false;
dialogFormVisible.value = true; // 打开对话框
};
// 删除用户信息
const deleteAccount = async (params: User.ResUserList) => {
await useHandleData(
deleteUser,
{ id: [params.id] },
`删除【${params.username}`
);
proTable.value?.getTableList();
};
const handleRowClick = (planSystem: Plan.PlanList) =>{
dialogForm.value = {...planSystem};
dialogTitle.value = '查看检测计划';
isReadOnly.value = true;
dialogFormVisible.value = true; // 打开对话框
}
// 批量删除用户信息
const batchDelete = async (id: string[]) => {
await useHandleData(deleteUser, { id }, "删除所选用户信息");
proTable.value?.clearSelection();
proTable.value?.getTableList();
};
// 重置用户密码
const resetPass = async (params: User.ResUserList) => {
await useHandleData(
resetUserPassWord,
{ id: params.id },
`重置【${params.username}】用户密码`
);
proTable.value?.getTableList();
};
// 切换用户状态
const changeStatus = async (row: User.ResUserList) => {
await useHandleData(
changeUserStatus,
{ id: row.id, status: row.status == 1 ? 0 : 1 },
`切换【${row.username}】用户状态`
);
proTable.value?.getTableList();
};
onMounted(() => {
console.log(proTable.value?.tableData);
});
const showDeviceOpen = (planSystem: Plan.PlanList) => {
openView.value.open('设备列表')
}
</script>
<style lang="scss" scoped>
.planList {
width: 100%;
// height: calc(100vh - 165px);
height: 100%;
}
:deep(.el-select) {
width: 150px !important;
}
<style scoped>
.el-form {
width: 100%;
display: flex;
flex-wrap: wrap;
.el-form-item {
display: flex;
align-items: center;
justify-content: space-between;
.el-button {
margin: 0 !important;
margin-right: 10px !important;
}
}
}
</style>
</style>