解决冲突 frontend/src/api/index.ts

This commit is contained in:
sjl
2024-11-14 11:36:25 +08:00
26 changed files with 1892 additions and 737 deletions

112
.merge_file_uAPEJh Normal file
View File

@@ -0,0 +1,112 @@
import axios, { AxiosInstance, AxiosError, AxiosRequestConfig, InternalAxiosRequestConfig, AxiosResponse } from "axios";
import { showFullScreenLoading, tryHideFullScreenLoading } from "@/components/Loading/fullScreen";
import { LOGIN_URL } from "@/config";
import { ElMessage } from "element-plus";
import { ResultData } from "@/api/interface";
import { ResultEnum } from "@/enums/httpEnum";
import { checkStatus } from "./helper/checkStatus";
import { useUserStore } from "@/stores/modules/user";
import router from "@/routers";
export interface CustomAxiosRequestConfig extends InternalAxiosRequestConfig {
loading?: boolean;
}
const config = {
// 默认地址请求地址,可在 .env.** 文件中修改
baseURL: import.meta.env.VITE_API_URL as string,
// 设置超时时间
timeout: ResultEnum.TIMEOUT as number,
// 跨域时候允许携带凭证
withCredentials: true,
// post请求指定数据类型以及编码
headers: { 'Content-Type': 'application/json;charset=utf-8' }
};
class RequestHttp {
service: AxiosInstance;
public constructor(config: AxiosRequestConfig) {
// 创建实例
this.service = axios.create(config);
/**
* @description 请求拦截器
* 客户端发送请求 -> [请求拦截器] -> 服务器
* token校验(JWT) : 接受服务器返回的 token,存储到 vuex/pinia/本地储存当中
*/
this.service.interceptors.request.use(
(config: CustomAxiosRequestConfig) => {
const userStore = useUserStore();
// 当前请求不需要显示 loading在 api 服务中通过指定的第三个参数: { loading: false } 来控制
config.loading ?? (config.loading = true);
config.loading && showFullScreenLoading();
if (config.headers && typeof config.headers.set === "function") {
config.headers.set("x-access-token", userStore.token);
}
return config;
},
(error: AxiosError) => {
return Promise.reject(error);
}
);
/**
* @description 响应拦截器
* 服务器换返回信息 -> [拦截统一处理] -> 客户端JS获取到信息
*/
this.service.interceptors.response.use(
(response: AxiosResponse) => {
const { data } = response;
const userStore = useUserStore();
tryHideFullScreenLoading();
// 登陆失效
if (data.code == ResultEnum.OVERDUE) {
userStore.setToken("");
router.replace(LOGIN_URL);
ElMessage.error(data.message);
return Promise.reject(data);
}
// 全局错误信息拦截(防止下载文件的时候返回数据流,没有 code 直接报错)
if (data.code && data.code !== ResultEnum.SUCCESS) {
ElMessage.error(data.message);
return Promise.reject(data);
}
// 成功请求(在页面上除非特殊情况,否则不用处理失败逻辑)
return data;
},
async (error: AxiosError) => {
const { response } = error;
tryHideFullScreenLoading();
// 请求超时 && 网络错误单独判断,没有 response
if (error.message.indexOf("timeout") !== -1) ElMessage.error("请求超时!请您稍后重试");
if (error.message.indexOf("Network Error") !== -1) ElMessage.error("网络错误!请您稍后重试");
// 根据服务器响应的错误状态码,做不同的处理
if (response) checkStatus(response.status);
// 服务器结果都没有返回(可能服务器错误可能客户端断网),断网处理:可以跳转到断网页面
if (!window.navigator.onLine) router.replace("/500");
return Promise.reject(error);
}
);
}
/**
* @description 常用请求方法封装
*/
get<T>(url: string, params?: object, _object = {}): Promise<ResultData<T>> {
return this.service.get(url, { params, ..._object });
}
post<T>(url: string, params?: object | string, _object = {}): Promise<ResultData<T>> {
return this.service.post(url, params, _object);
}
put<T>(url: string, params?: object, _object = {}): Promise<ResultData<T>> {
return this.service.put(url, params, _object);
}
delete<T>(url: string, params?: any, _object = {}): Promise<ResultData<T>> {
return this.service.delete(url, { params, ..._object });
}
download(url: string, params?: object, _object = {}): Promise<BlobPart> {
return this.service.post(url, params, { ..._object, responseType: "blob" });
}
}
export default new RequestHttp(config);

View File

@@ -20,5 +20,5 @@ VITE_API_URL=/api
# 开发环境跨域代理,支持配置多个
VITE_PROXY=[["/api","http://192.168.1.124:18092/"]]
#VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
# VITE_PROXY=[["/api","http://192.168.1.125:18092/"]]
# VITE_PROXY=[["/api","http://192.168.1.138:8080/"]]张文

View File

@@ -108,15 +108,6 @@ class RequestHttp {
download(url: string, params?: object, _object = {}): Promise<BlobPart> {
return this.service.post(url, params, { ..._object, responseType: "blob" });
}
/**
* @description 批量导入专用请求方法
*/
batchImport<T>(url: string, formData: FormData, _object = {}): Promise<ResultData<T>> {
return this.service.post(url, formData, {
..._object,
headers: { 'Content-Type': 'multipart/form-data' }
});
}
}

View File

@@ -3,7 +3,7 @@
"data": [
{
"id": 0,
"name": "频率准度检测",
"name": "频率准度检测",
"children": [
{
"pid": 0,
@@ -11,16 +11,22 @@
"name": "额定工作条件下的检测",
"children": [
{
"scriptIdx":1,
"isChildNode":true,
"pid": "0-1",
"id": "0-1-1",
"name": "输入:频率 42.5Hz..."
},
{
"scriptIdx":2,
"isChildNode":true,
"pid": "0-1",
"id": "0-1-2",
"name": "输入:频率 50.0Hz..."
},
{
"scriptIdx":3,
"isChildNode":true,
"pid": "0-1",
"id": "0-1-3",
"name": "输入:频率 50.05Hz..."
@@ -33,16 +39,22 @@
"name": "电压对频率测量的影响",
"children": [
{
"scriptIdx":4,
"isChildNode":true,
"pid": "0-2",
"id": "0-2-1",
"name": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"scriptIdx":5,
"isChildNode":true,
"pid": "0-2",
"id": "0-2-1",
"name": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"scriptIdx":6,
"isChildNode":true,
"pid": "0-2",
"id": "0-2-2",
"name": "输入:频率 52.05Hz Ua =10%Un..."
@@ -55,6 +67,8 @@
"name": "谐波对频率测量的影响",
"children": [
{
"scriptIdx":7,
"isChildNode":true,
"pid": "0-3",
"id": "0-3-1",
"name": "输入:频率 50.05Hz Ua =100%Un..."
@@ -73,16 +87,22 @@
"name": "额定工作条件下的检测",
"children": [
{
"scriptIdx":8,
"isChildNode":true,
"pid": "1-1",
"id": "1-1-1",
"name": "输入:频率 42.5Hz..."
},
{
"scriptIdx":9,
"isChildNode":true,
"pid": "1-1",
"id": "1-1-2",
"name": "输入:频率 50.0Hz..."
},
{
"scriptIdx":10,
"isChildNode":true,
"pid": "1-1",
"id": "1-1-3",
"name": "输入:频率 50.05Hz..."
@@ -95,16 +115,22 @@
"name": "电压对频率测量的影响",
"children": [
{
"scriptIdx":11,
"isChildNode":true,
"pid": "1-2",
"id": "1-2-1",
"name": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"scriptIdx":12,
"isChildNode":true,
"pid": "1-2",
"id": "1-2-1",
"name": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"scriptIdx":13,
"isChildNode":true,
"pid": "1-2",
"id": "1-2-2",
"name": "输入:频率 52.05Hz Ua =10%Un..."
@@ -117,6 +143,8 @@
"name": "谐波对频率测量的影响",
"children": [
{
"scriptIdx":14,
"isChildNode":true,
"pid": "0-3",
"id": "0-3-1",
"name": "输入:频率 50.05Hz Ua =100%Un..."
@@ -136,16 +164,19 @@
"name": "额定工作条件下的检测",
"children": [
{
"scriptIdx":15,
"pid": "2-1",
"id": "2-1-1",
"name": "输入:频率 42.5Hz..."
},
{
"scriptIdx":16,
"pid": "2-1",
"id": "2-1-2",
"name": "输入:频率 50.0Hz..."
},
{
"scriptIdx":17,
"pid": "2-1",
"id": "2-1-3",
"name": "输入:频率 50.05Hz..."
@@ -158,16 +189,19 @@
"name": "电压对频率测量的影响",
"children": [
{
"scriptIdx":18,
"pid": "2-2",
"id": "2-2-1",
"name": "输入:频率 50.05Hz Ua =10%Un..."
},
{
"scriptIdx":19,
"pid": "2-2",
"id": "2-2-1",
"name": "输入:频率 51.05Hz Ua =10%Un..."
},
{
"scriptIdx":20,
"pid": "2-2",
"id": "2-2-2",
"name": "输入:频率 52.05Hz Ua =10%Un..."
@@ -180,6 +214,7 @@
"name": "谐波对频率测量的影响",
"children": [
{
"scriptIdx":21,
"pid": "2-3",
"id": "2-3-1",
"name": "输入:频率 50.05Hz Ua =100%Un..."

View File

@@ -27,6 +27,7 @@ export namespace Plan {
// 检测计划 + 检测源
export interface PlanAndSourceBO extends PlanBO {
testSourceName: string;//计划所属检测源
testSourceList?: string[];//临时测试
}
// // 检测计划列表
// export interface PlanList {

View File

@@ -178,6 +178,7 @@ const planData = ref<Plan.PlanAndSourceBO[]>([
'test_State':'1',
'report_State':'1',
'result':'1',
},
{
'id': '2',
@@ -191,6 +192,9 @@ const planData = ref<Plan.PlanAndSourceBO[]>([
'test_State':'2',
'report_State':'2',
'result':'0',
"testSourceList":[
'高精度设备-PQV520-1','高精度设备-PQV520-2',
]
},
{
'id': '3',

View File

@@ -1,30 +1,30 @@
<template>
<RenderTableColumn v-bind="column" />
<RenderTableColumn v-bind='column' />
</template>
<script setup lang="tsx" name="TableColumn">
import { ColumnProps, RenderScope, HeaderRenderScope } from "@/components/ProTable/interface";
import { filterEnum, formatValue, handleProp, handleRowAccordingToProp } from "@/utils";
<script setup lang='tsx' name='TableColumn'>
import { ColumnProps, RenderScope, HeaderRenderScope } from '@/components/ProTable/interface'
import { filterEnum, formatValue, handleProp, handleRowAccordingToProp } from '@/utils'
defineProps<{ column: ColumnProps }>();
defineProps<{ column: ColumnProps }>()
const slots = useSlots();
const slots = useSlots()
const enumMap = inject("enumMap", ref(new Map()));
const enumMap = inject('enumMap', ref(new Map()))
// 渲染表格数据
const renderCellData = (item: ColumnProps, scope: RenderScope<any>) => {
return enumMap.value.get(item.prop) && item.isFilterEnum
? filterEnum(handleRowAccordingToProp(scope.row, item.prop!), enumMap.value.get(item.prop)!, item.fieldNames)
: formatValue(handleRowAccordingToProp(scope.row, item.prop!));
};
: formatValue(handleRowAccordingToProp(scope.row, item.prop!))
}
// 获取 tag 类型
const getTagType = (item: ColumnProps, scope: RenderScope<any>) => {
return (
filterEnum(handleRowAccordingToProp(scope.row, item.prop!), enumMap.value.get(item.prop), item.fieldNames, "tag") || "primary"
);
};
filterEnum(handleRowAccordingToProp(scope.row, item.prop!), enumMap.value.get(item.prop), item.fieldNames, 'tag') || 'primary'
)
}
const RenderTableColumn = (item: ColumnProps) => {
return (
@@ -32,26 +32,26 @@ const RenderTableColumn = (item: ColumnProps) => {
{item.isShow && (
<el-table-column
{...item}
align={item.align ?? "center"}
showOverflowTooltip={item.showOverflowTooltip ?? item.prop !== "operation"}
align={item.align ?? 'center'}
showOverflowTooltip={item.showOverflowTooltip ?? item.prop !== 'operation'}
>
{{
default: (scope: RenderScope<any>) => {
if (item._children) return item._children.map(child => RenderTableColumn(child));
if (item.render) return item.render(scope);
if (item.prop && slots[handleProp(item.prop)]) return slots[handleProp(item.prop)]!(scope);
if (item.tag) return <el-tag type={getTagType(item, scope)}>{renderCellData(item, scope)}</el-tag>;
return renderCellData(item, scope);
if (item._children) return item._children.map(child => RenderTableColumn(child))
if (item.render) return item.render(scope)
if (item.prop && slots[handleProp(item.prop)]) return slots[handleProp(item.prop)]!(scope)
if (item.tag) return <el-tag type={getTagType(item, scope)}>{renderCellData(item, scope)}</el-tag>
return renderCellData(item, scope)
},
header: (scope: HeaderRenderScope<any>) => {
if (item.headerRender) return item.headerRender(scope);
if (item.prop && slots[`${handleProp(item.prop)}Header`]) return slots[`${handleProp(item.prop)}Header`]!(scope);
return item.label;
}
if (item.headerRender) return item.headerRender(scope)
if (item.prop && slots[`${handleProp(item.prop)}Header`]) return slots[`${handleProp(item.prop)}Header`]!(scope)
return item.label
},
}}
</el-table-column>
)}
</>
);
};
)
}
</script>

View File

@@ -306,8 +306,6 @@
// font-family:;
.el-dialog__headerbtn {
top: 5px;
.el-icon {
color: var(--el-color-white);
}
@@ -480,3 +478,15 @@
}
}
}
.cn-render-buttons {
cursor: pointer;
display: inline-block;
margin-left: 13px;
line-height: 18px;
padding: 2px;
.icon {
font-size: 12px !important;
// color: var(--ba-bg-color-overlay) !important;
}
}

View File

@@ -1,5 +1,5 @@
export const dialogSmall = {
width:'400px',
width:'500px',
closeOnClickModal:false,
draggable:true,
class:'dialog-small'

View File

@@ -1,7 +1,7 @@
import { isArray } from "@/utils/is";
import { FieldNamesProps } from "@/components/ProTable/interface";
import { isArray } from '@/utils/is'
import { FieldNamesProps } from '@/components/ProTable/interface'
const mode = import.meta.env.VITE_ROUTER_MODE;
const mode = import.meta.env.VITE_ROUTER_MODE
/**
* @description 获取localStorage
@@ -9,11 +9,11 @@ const mode = import.meta.env.VITE_ROUTER_MODE;
* @returns {String}
*/
export function localGet(key: string) {
const value = window.localStorage.getItem(key);
const value = window.localStorage.getItem(key)
try {
return JSON.parse(window.localStorage.getItem(key) as string);
return JSON.parse(window.localStorage.getItem(key) as string)
} catch (error) {
return value;
return value
}
}
@@ -24,7 +24,7 @@ export function localGet(key: string) {
* @returns {void}
*/
export function localSet(key: string, value: any) {
window.localStorage.setItem(key, JSON.stringify(value));
window.localStorage.setItem(key, JSON.stringify(value))
}
/**
@@ -33,7 +33,7 @@ export function localSet(key: string, value: any) {
* @returns {void}
*/
export function localRemove(key: string) {
window.localStorage.removeItem(key);
window.localStorage.removeItem(key)
}
/**
@@ -41,7 +41,7 @@ export function localRemove(key: string) {
* @returns {void}
*/
export function localClear() {
window.localStorage.clear();
window.localStorage.clear()
}
/**
@@ -50,9 +50,9 @@ export function localClear() {
* @returns {String}
*/
export function isType(val: any) {
if (val === null) return "null";
if (typeof val !== "object") return typeof val;
else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase();
if (val === null) return 'null'
if (typeof val !== 'object') return typeof val
else return Object.prototype.toString.call(val).slice(8, -1).toLocaleLowerCase()
}
/**
@@ -60,13 +60,13 @@ export function isType(val: any) {
* @returns {String}
*/
export function generateUUID() {
let uuid = "";
let uuid = ''
for (let i = 0; i < 32; i++) {
let random = (Math.random() * 16) | 0;
if (i === 8 || i === 12 || i === 16 || i === 20) uuid += "-";
uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16);
let random = (Math.random() * 16) | 0
if (i === 8 || i === 12 || i === 16 || i === 20) uuid += '-'
uuid += (i === 12 ? 4 : i === 16 ? (random & 3) | 8 : random).toString(16)
}
return uuid;
return uuid
}
/**
@@ -76,22 +76,22 @@ export function generateUUID() {
* @returns {Boolean} 相同返回 true反之 false
*/
export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string]: any }) {
if (!a || !b) return false;
let aProps = Object.getOwnPropertyNames(a);
let bProps = Object.getOwnPropertyNames(b);
if (aProps.length != bProps.length) return false;
if (!a || !b) return false
let aProps = Object.getOwnPropertyNames(a)
let bProps = Object.getOwnPropertyNames(b)
if (aProps.length != bProps.length) return false
for (let i = 0; i < aProps.length; i++) {
let propName = aProps[i];
let propA = a[propName];
let propB = b[propName];
if (!b.hasOwnProperty(propName)) return false;
let propName = aProps[i]
let propA = a[propName]
let propB = b[propName]
if (!b.hasOwnProperty(propName)) return false
if (propA instanceof Object) {
if (!isObjectValueEqual(propA, propB)) return false;
if (!isObjectValueEqual(propA, propB)) return false
} else if (propA !== propB) {
return false;
return false
}
}
return true;
return true
}
/**
@@ -101,8 +101,8 @@ export function isObjectValueEqual(a: { [key: string]: any }, b: { [key: string]
* @returns {Number}
*/
export function randomNum(min: number, max: number): number {
let num = Math.floor(Math.random() * (min - max) + max);
return num;
let num = Math.floor(Math.random() * (min - max) + max)
return num
}
/**
@@ -110,13 +110,13 @@ export function randomNum(min: number, max: number): number {
* @returns {String}
*/
export function getTimeState() {
let timeNow = new Date();
let hours = timeNow.getHours();
if (hours >= 6 && hours <= 10) return `早上好 ⛅`;
if (hours >= 10 && hours <= 14) return `中午好 🌞`;
if (hours >= 14 && hours <= 18) return `下午好 🌞`;
if (hours >= 18 && hours <= 24) return `晚上好 🌛`;
if (hours >= 0 && hours <= 6) return `凌晨好 🌛`;
let timeNow = new Date()
let hours = timeNow.getHours()
if (hours >= 6 && hours <= 10) return `早上好 ⛅`
if (hours >= 10 && hours <= 14) return `中午好 🌞`
if (hours >= 14 && hours <= 18) return `下午好 🌞`
if (hours >= 18 && hours <= 24) return `晚上好 🌛`
if (hours >= 0 && hours <= 6) return `凌晨好 🌛`
}
/**
@@ -124,14 +124,14 @@ export function getTimeState() {
* @returns {String}
*/
export function getBrowserLang() {
let browserLang = navigator.language ? navigator.language : navigator.browserLanguage;
let defaultBrowserLang = "";
if (["cn", "zh", "zh-cn"].includes(browserLang.toLowerCase())) {
defaultBrowserLang = "zh";
let browserLang = navigator.language ? navigator.language : navigator.browserLanguage
let defaultBrowserLang = ''
if (['cn', 'zh', 'zh-cn'].includes(browserLang.toLowerCase())) {
defaultBrowserLang = 'zh'
} else {
defaultBrowserLang = "en";
defaultBrowserLang = 'en'
}
return defaultBrowserLang;
return defaultBrowserLang
}
/**
@@ -141,9 +141,9 @@ export function getBrowserLang() {
export function getUrlWithParams() {
const url = {
hash: location.hash.substring(1),
history: location.pathname + location.search
};
return url[mode];
history: location.pathname + location.search,
}
return url[mode]
}
/**
@@ -152,8 +152,8 @@ export function getUrlWithParams() {
* @returns {Array}
*/
export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[] {
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList));
return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])]);
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList))
return newMenuList.flatMap(item => [item, ...(item.children ? getFlatMenuList(item.children) : [])])
}
/**
@@ -162,11 +162,11 @@ export function getFlatMenuList(menuList: Menu.MenuOptions[]): Menu.MenuOptions[
* @returns {Array}
* */
export function getShowMenuList(menuList: Menu.MenuOptions[]) {
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList));
let newMenuList: Menu.MenuOptions[] = JSON.parse(JSON.stringify(menuList))
return newMenuList.filter(item => {
item.children?.length && (item.children = getShowMenuList(item.children));
return !item.meta?.isHide;
});
item.children?.length && (item.children = getShowMenuList(item.children))
return !item.meta?.isHide
})
}
/**
@@ -178,11 +178,11 @@ export function getShowMenuList(menuList: Menu.MenuOptions[]) {
*/
export const getAllBreadcrumbList = (menuList: Menu.MenuOptions[], parent = [], result: { [key: string]: any } = {}) => {
for (const item of menuList) {
result[item.path] = [...parent, item];
if (item.children) getAllBreadcrumbList(item.children, result[item.path], result);
result[item.path] = [...parent, item]
if (item.children) getAllBreadcrumbList(item.children, result[item.path], result)
}
return result;
};
return result
}
/**
* @description 使用递归处理路由菜单 path生成一维数组 (第一版本地路由鉴权会用到,该函数暂未使用)
@@ -192,10 +192,10 @@ export const getAllBreadcrumbList = (menuList: Menu.MenuOptions[], parent = [],
*/
export function getMenuListPath(menuList: Menu.MenuOptions[], menuPathArr: string[] = []): string[] {
for (const item of menuList) {
if (typeof item === "object" && item.path) menuPathArr.push(item.path);
if (item.children?.length) getMenuListPath(item.children, menuPathArr);
if (typeof item === 'object' && item.path) menuPathArr.push(item.path)
if (item.children?.length) getMenuListPath(item.children, menuPathArr)
}
return menuPathArr;
return menuPathArr
}
/**
@@ -206,13 +206,13 @@ export function getMenuListPath(menuList: Menu.MenuOptions[], menuPathArr: strin
*/
export function findMenuByPath(menuList: Menu.MenuOptions[], path: string): Menu.MenuOptions | null {
for (const item of menuList) {
if (item.path === path) return item;
if (item.path === path) return item
if (item.children) {
const res = findMenuByPath(item.children, path);
if (res) return res;
const res = findMenuByPath(item.children, path)
if (res) return res
}
}
return null;
return null
}
/**
@@ -223,10 +223,10 @@ export function findMenuByPath(menuList: Menu.MenuOptions[], path: string): Menu
* */
export function getKeepAliveRouterName(menuList: Menu.MenuOptions[], keepAliveNameArr: string[] = []) {
menuList.forEach(item => {
item.meta.isKeepAlive && item.name && keepAliveNameArr.push(item.name);
item.children?.length && getKeepAliveRouterName(item.children, keepAliveNameArr);
});
return keepAliveNameArr;
item.meta.isKeepAlive && item.name && keepAliveNameArr.push(item.name)
item.children?.length && getKeepAliveRouterName(item.children, keepAliveNameArr)
})
return keepAliveNameArr
}
/**
@@ -238,8 +238,8 @@ export function getKeepAliveRouterName(menuList: Menu.MenuOptions[], keepAliveNa
* */
export function formatTableColumn(row: number, col: number, callValue: any) {
// 如果当前值为数组,使用 / 拼接(根据需求自定义)
if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
return callValue ?? "--";
if (isArray(callValue)) return callValue.length ? callValue.join(' / ') : '/'
return (callValue && callValue.length > 0) ? callValue : '/'
}
/**
@@ -249,8 +249,8 @@ export function formatTableColumn(row: number, col: number, callValue: any) {
* */
export function formatValue(callValue: any) {
// 如果当前值为数组,使用 / 拼接(根据需求自定义)
if (isArray(callValue)) return callValue.length ? callValue.join(" / ") : "--";
return callValue ?? "--";
if (isArray(callValue)) return callValue.length ? callValue.join(' / ') : '/'
return (callValue && callValue.length > 0) ? callValue : '/'
}
/**
@@ -260,9 +260,9 @@ export function formatValue(callValue: any) {
* @returns {*}
* */
export function handleRowAccordingToProp(row: { [key: string]: any }, prop: string) {
if (!prop.includes(".")) return row[prop] ?? "--";
prop.split(".").forEach(item => (row = row[item] ?? "--"));
return row;
if (!prop.includes('.')) return row[prop] ?? '/'
prop.split('.').forEach(item => (row = row[item] ?? '/'))
return row
}
/**
@@ -271,9 +271,9 @@ export function handleRowAccordingToProp(row: { [key: string]: any }, prop: stri
* @returns {String}
* */
export function handleProp(prop: string) {
const propArr = prop.split(".");
if (propArr.length == 1) return prop;
return propArr[propArr.length - 1];
const propArr = prop.split('.')
if (propArr.length == 1) return prop
return propArr[propArr.length - 1]
}
/**
@@ -284,18 +284,18 @@ export function handleProp(prop: string) {
* @param {String} type 过滤类型(目前只有 tag
* @returns {String}
* */
export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: "tag") {
const value = fieldNames?.value ?? "value";
const label = fieldNames?.label ?? "label";
const children = fieldNames?.children ?? "children";
let filterData: { [key: string]: any } = {};
export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNamesProps, type?: 'tag') {
const value = fieldNames?.value ?? 'value'
const label = fieldNames?.label ?? 'label'
const children = fieldNames?.children ?? 'children'
let filterData: { [key: string]: any } = {}
// 判断 enumData 是否为数组
if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children);
if (Array.isArray(enumData)) filterData = findItemNested(enumData, callValue, value, children)
// 判断是否输出的结果为 tag 类型
if (type == "tag") {
return filterData?.tagType ? filterData.tagType : "";
if (type == 'tag') {
return filterData?.tagType ? filterData.tagType : ''
} else {
return filterData ? filterData[label] : "--";
return filterData ? filterData[label] : '/'
}
}
@@ -304,8 +304,8 @@ export function filterEnum(callValue: any, enumData?: any, fieldNames?: FieldNam
* */
export function findItemNested(enumData: any, callValue: any, value: string, children: string) {
return enumData.reduce((accumulator: any, current: any) => {
if (accumulator) return accumulator;
if (current[value] === callValue) return current;
if (current[children]) return findItemNested(current[children], callValue, value, children);
}, null);
if (accumulator) return accumulator
if (current[value] === callValue) return current
if (current[children]) return findItemNested(current[children], callValue, value, children)
}, null)
}

View File

@@ -0,0 +1,136 @@
<template>
<!-- 基础信息弹出框 -->
<el-dialog :model-value="dialogVisible" title="误差体系编辑" v-bind="dialogSmall" @close="handleCancel" width="500" draggable>
<div>
<el-form :model="data"
ref='formRuleRef'
:rules='rules'
>
<el-form-item label="设备名称" prop='name' :label-width="100">
<el-input v-model="data.name" placeholder="请输入名称" autocomplete="off" />
</el-form-item>
<el-form-item label="选择误差体系" prop='type' :label-width="100">
<el-select v-model="data.type" placeholder="请选择误差体系" autocomplete="off">
<el-option
v-for="item in dictStore.getDictData('roleType')"
:key="item.id"
:label="item.label"
:value="item.code"
/>
</el-select>
<el-button type="primary" @click="handleOK">
生成报告
</el-button>
</el-form-item>
<!-- <el-form-item label="描述" prop='remark' :label-width="100">
<el-input v-model="data.remark" :rows="2" type="textarea" placeholder="请输入备注" autocomplete="off" />
</el-form-item> -->
</el-form>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleOK">
保存
</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { FormInstance,FormItemRule } from 'element-plus'
import { ProTableInstance } from '@/components/ProTable/interface'
import { ref,computed } from 'vue'
import { Role } from '@/api/role/interface'
import {dialogSmall} from '@/utils/elementBind'
import { useDictStore } from '@/stores/modules/dict'
import {
addRole,
editRole,
} from '@/api/role/role'
const dictStore = useDictStore()
const {dialogVisible,title,data,openType,getTableList} = defineProps<{
dialogVisible:boolean;
title:string;
openType:string;
getTableList:Function;
data:{
id?: string; //角色类型ID
name: string; //角色类型名称
code: string; //角色代码
type: number;
remark:string; //角色描述
}
}>();
//定义规则
const formRuleRef = ref<FormInstance>()
//定义校验规则
const rules: Ref<Record<string, Array<FormItemRule>>> = ref({
name: [{ required: true, message: '名称必填!', trigger: 'blur' }],
code: [{ required: true, message: '编码必填!', trigger: 'blur' }],
})
const emit = defineEmits<{
(e:'update:visible',value:boolean):void;
}>();
const handleCancel = () => {
emit('update:visible',false)
}
const handleOK = () => {
ElMessage.info('角色数据提交')
try {
formRuleRef.value?.validate((valid: boolean) => {
if (valid) {
// 将表单数据转为json,发送到后端
// let confirmFormData = JSON.parse(JSON.stringify(form.value))
// console.log(confirmFormData)
if(openType === "add")
{
addRole(data).then(res => {
// if(res.code === "200")
// {
ElMessage.success(res.message)
getTableList()
// }
// else
// ElMessage.error(res.message)
})
}
if(openType === "edit")
{
editRole(data).then(res => {
// if(res.code === "200")
// {
ElMessage.success(res.message)
getTableList()
// }
// else
// ElMessage.error(res.message)
})
}
emit('update:visible',false)
} else {
ElMessage.error('表单验证失败!')
}
})
} catch (error) {
console.error('验证过程中发生错误', error)
}
}
</script>

View File

@@ -55,13 +55,13 @@
type="primary"
@click="handleTest"
v-if="form.activeTabs === 0"
>启动自动检测</el-button
>自动检测</el-button
>
<el-button
type="primary"
@click="handleTest"
v-if="form.activeTabs === 1"
>启动手动检测</el-button
v-if="form.activeTabs === 0"
>手动检测</el-button
>
<el-button type="primary" v-if="form.activeTabs === 2"
>不合格项复检</el-button
@@ -71,7 +71,7 @@
>
<el-button type="primary" v-if="form.activeTabs === 3"
>批量生成报告</el-button
>报告批量生成</el-button
>
<el-button type="primary" v-if="form.activeTabs === 4"
@@ -81,29 +81,31 @@
</el-form>
</template>
<!-- 表格操作 -->
<!-- <template #operation="scope">
<template #operation="scope">
<el-button
dictType="primary"
type="primary"
link
:icon="View"
@click="openDrawer('查看', scope.row)"
>查看</el-button
@click="openDrawer('报告查看', scope.row)"
v-if="form.activeTabs === 3"
>报告查看</el-button
>
<el-button
dictType="primary"
type="primary"
link
:icon="EditPen"
@click="openDrawer('编辑', scope.row)"
>导出</el-button
@click="openDrawer('误差体系编辑', scope.row)"
v-if="form.activeTabs === 5"
>误差体系编辑</el-button
>
<el-button
<!-- <el-button
dictType="primary"
link
:icon="Delete"
@click="deleteAccount(scope.row)"
>删除</el-button
>
</template> -->
> -->
</template>
</ProTable>
</div>
</template>
@@ -116,7 +118,7 @@ import { ElMessage, ElMessageBox } from "element-plus";
import ProTable from "@/components/ProTable/index.vue";
import { type ProTableInstance, type ColumnProps } from '@/components/ProTable/interface'
import {
Search,
Search,View,EditPen
} from "@element-plus/icons-vue";
import { getPlanList } from "@/api/plan/planList";
import deviceDataList from '@/api/device/deviceData'
@@ -129,7 +131,7 @@ const tableHeight = ref(0);
console.log(window.innerHeight, "+++++++++");
tableHeight.value = window.innerHeight - 630;
const deviceData = deviceDataList.plan_devicedata
const operationShow = ref(false);
//下拉框数据
//检测状态数据
let checkStatusList = reactive([
@@ -305,29 +307,29 @@ const columns = reactive<ColumnProps<Device.ResPqDev>[]>([
{
prop: 'reCheck_Num',
label: '复检次数',
minWidth: 70,
minWidth: 100,
},
{
prop: 'report_State',
label: '报告状态',
minWidth: 130,
minWidth: 100,
},
{
prop: 'check_Result',
label: '检测结果',
minWidth: 130,
minWidth: 100,
},
{
prop: 'check_State',
label: '检测状态',
minWidth: 130,
minWidth: 100,
},
{
prop: 'document_State',
label: '归档状态',
minWidth: 130,
minWidth: 100,
},
// { prop: 'operation', label: '操作', fixed: 'right', minWidth: 200 },
{ prop: 'operation', label: '操作', fixed: 'right', minWidth: 150 ,isShow: operationShow},
])
// 表格配置项
@@ -567,36 +569,41 @@ function tableHeaderInit(val: number) {
form.value.checkResult = 0;//检测结果默认为未出结果
disableCheckStatus("检测中")
disableCheckStatus("归档")
operationShow.value = false;
break;
case 2://设备复检
form.value.checkStatus = 2;//检测状态默认为检测完成
form.value.checkReportStatus = 0;//检测报告状态默认为未生成报告
form.value.checkResult = 1;//检测结果默认为不合格
disableCheckStatus("未检")
disableCheckStatus("未检")
disableCheckStatus("检测中")
disableCheckStatus("归档")
disablecheckResultList("未出结果")
operationShow.value = false;
break;
case 3://报告生成
form.value.checkStatus = 2;//检测状态默认为检测完成
form.value.checkReportStatus = 0;//检测报告状态默认为未生成报告
form.value.checkResult = 2;//检测结果默认为合格
disableCheckStatus("未检")
disableCheckStatus("未检")
disableCheckStatus("检测中")
disableCheckStatus("归档")
disablecheckResultList("未出结果")
operationShow.value = true;
break;
case 4://设备归档
form.value.checkStatus = 2;//检测状态默认为检测完成
form.value.checkReportStatus = 1;//检测报告状态默认为已生成报告
form.value.checkResult = 2;//检测结果默认为合格
disableCheckStatus("未检")
disableCheckStatus("未检")
disableCheckStatus("检测中")
disableCheckStatus("归档")
disableCheckReportStatus("未生成报告")
disablecheckResultList("未出结果")
operationShow.value = false;
break;
case 5://报告浏览
case 5://设备浏览
operationShow.value = true;
break;
}
}
@@ -656,6 +663,16 @@ const handleTest = () => {
}
};
// 打开 drawer(新增、查看、编辑)
const openDrawer = (title: string, row: any) => {
if (title === '报告查看')
console.log(title);
else if (title === '误差体系编辑')
console.log(title);
}
onMounted(() => {
console.log(proTable.value?.tableData);
});

View File

@@ -32,7 +32,7 @@
</div>
</template>
<script lang='ts' setup>
import { Menu, Platform } from '@element-plus/icons-vue'
import { Menu, Platform, CircleCheck,Loading } from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'
const router = useRouter()
@@ -53,6 +53,9 @@ const getTreeData = (val: any) => {
}
const filterText = ref('')
const treeRef = ref()
const {updateSelectedTreeNode} = defineProps<{
updateSelectedTreeNode:Function;
}>();
watch(
() => searchForm.value.planName,
(val) => {
@@ -64,6 +67,7 @@ watch(
)
const handleNodeClick = (data) => {
console.log(data)
updateSelectedTreeNode()
}
const filterNode = (value: string, data) => {
if (!value) return true
@@ -110,12 +114,10 @@ defineExpose({ getTreeData })
.tree_container {
flex: 1;
overflow-y: auto;
width: 100%;
overflow-x: auto;
.el-tree {
height: 100%;
// width: 2000px;
width: 100%;
}
}
}

View File

@@ -2,7 +2,7 @@
<template>
<div class="static">
<div class="left_tree">
<tree ref="treeRef" />
<tree ref="treeRef" :updateSelectedTreeNode="getPieData || (() => {})"/>
</div>
<!-- <span class="new_span">测试scss颜色</span> -->
<div class="right_container">
@@ -15,7 +15,7 @@
"
v-for="(item, index) in tabsList"
:key="index"
@click="handleCheckFunction(index)"
@click="handleCheckFunction(item.value)"
>
<div class="item_img">
<img :src="item.img" alt="" />
@@ -25,6 +25,10 @@
</div>
</div>
</div>
<!-- <el-collapse v-model="activeNames" @change="handleChange">
<el-collapse-item title="检测进度展示" name="1"> -->
<!-- 饼图 -->
<div class="container_charts">
<div class="charts_info">
@@ -75,10 +79,27 @@
></pie>
</div>
</div>
<!-- </el-collapse-item>
</el-collapse> -->
<el-tabs type="border-card" @tab-change="handleTabsChange" v-model="editableTabsValue">
<el-tab-pane :label="tabLabel1">
<!-- 列表数据 -->
<div class="container_table">
<Table ref="tableRef"></Table>
<Table ref="tableRef1"></Table>
</div>
</el-tab-pane>
<el-tab-pane label="已检设备" v-if="tabShow">
<!-- 列表数据 -->
<div class="container_table">
<Table ref="tableRef2"></Table>
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</template>
@@ -100,25 +121,32 @@ const form: any = ref({
manufacturer: 0, //制造厂商
});
const router = useRouter();
const activeNames = ref(['2'])
const tabShow= ref(false);
const tabLabel1 = ref('自动检测')
const editableTabsValue = ref('0')
const handleChange = (val: string[]) => {
console.log(val)
}
const handleTabsChange = (val) => {
form.value.activeTabs = 0;
form.value.activeTabs = 3;
console.log(val)
}
localStorage.setItem("color", "red");
//功能选择数据
const tabsList = ref([
{
label: "自动检测",
label: "设备检测",
value: 0,
img: "/src/assets/images/plan/static/1.svg",
checked: true,
},
{
label: "手动检测",
value: 1,
img: "/src/assets/images/plan/static/2.svg",
checked: false,
},
{
label: "设备复检",
value: 2,
img: "/src/assets/images/plan/static/6.svg",
img: "/src/assets/images/plan/static/2.svg",
checked: false,
},
{
@@ -133,21 +161,65 @@ const tabsList = ref([
img: "/src/assets/images/plan/static/4.svg",
checked: false,
},
{
label: "设备浏览",
value: 5,
img: "/src/assets/images/plan/static/5.svg",
checked: false,
},
]);
// const tabsList = ref([
// {
// label: "自动检测",
// value: 0,
// img: "/src/assets/images/plan/static/1.svg",
// checked: true,
// },
// {
// label: "手动检测",
// value: 1,
// img: "/src/assets/images/plan/static/2.svg",
// checked: false,
// },
// {
// label: "设备复检",
// value: 2,
// img: "/src/assets/images/plan/static/6.svg",
// checked: false,
// },
// {
// label: "报告生成",
// value: 3,
// img: "/src/assets/images/plan/static/3.svg",
// checked: false,
// },
// {
// label: "设备归档",
// value: 4,
// img: "/src/assets/images/plan/static/4.svg",
// checked: false,
// },
// {
// label: "设备浏览",
// value: 5,
// img: "/src/assets/images/plan/static/5.svg",
// checked: false,
// },
// ]);
form.value.activeTabs = tabsList.value[0].value;
const tableRef = ref();
const tableRef1 = ref();
const tableRef2 = ref();
watch(
() => form.value,
(val, oldVal) => {
if (val) {
tableRef.value && tableRef.value.changeActiveTabs(form.value.activeTabs);
tableRef1.value && tableRef1.value.changeActiveTabs(form.value.activeTabs);
}
},
{
immediate: true,
deep: true,
}
);
watch(
() => form.value,
(val, oldVal) => {
if (val) {
tableRef2.value && tableRef2.value.changeActiveTabs(form.value.activeTabs);
}
},
{
@@ -155,7 +227,6 @@ watch(
deep: true,
}
);
const pieRef1 = ref(),
pieRef2 = ref(),
pieRef3 = ref();
@@ -208,15 +279,37 @@ const planDetail = () => {
};
//功能选择css切换
const handleCheckFunction = (val: any) => {
console.log("test1",val);
console.log("test",val);
editableTabsValue.value = '0';
tabsList.value.map((item: any, index: any) => {
if (val == index) {
if (val == item.value) {
item.checked = true;
} else {
item.checked = false;
}
});
tabShow.value = false;
switch (val) {
case 0://自动检测
tabLabel1.value = "自动检测";
break;
case 1://手动检测
tabLabel1.value = "手动检测";
break;
case 2://设备复检
tabLabel1.value = "设备复检";
break;
case 3://报告生成
tabLabel1.value = "未检设备";
tabShow.value = true;
break;
case 4://设备归档
tabLabel1.value = "设备归档";
break;
}
form.value.activeTabs = val;
};
@@ -268,11 +361,11 @@ onMounted(() => {
.function_item {
flex: none;
width: 6%;
height: 70px;
height: 50px;
display: flex;
justify-content: space-between;
align-items: center;
flex-direction: column;
flex-direction: row;
cursor: pointer;
background-color: #607eab;
border-radius: 8px;
@@ -286,7 +379,7 @@ onMounted(() => {
display: flex;
align-items: center;
justify-content: center;
margin-right: 5px;
img {
width: 40px;
height: auto;
@@ -331,9 +424,29 @@ onMounted(() => {
}
}
.el-collapse {
width: 100% !important;
// min-height: 200px !important;
height:auto;
background-color: #eee;
// display: flex;
// justify-content: space-between;
// padding-left: 2ch;
margin-bottom: 10px;
}
.el-collapse-item{
width: 100% !important;
// min-height: 200px !important;
height:100% !important;
background-color: #eee;
// display: flex !important;
}
.container_charts {
width: 100%;
min-height: 200px !important;
min-height: 180px !important;
// height:100%;
background-color: #eee;
display: flex;
justify-content: space-between;
@@ -348,10 +461,15 @@ onMounted(() => {
}
}
.el-tabs{
width: 100% !important;
border-radius: 4px;
}
.container_table {
// width: 100%;
flex: 1 !important;
height: calc(100vh - 360px);
height: calc(100vh - 360px - 155px);
border-radius: 4px;
width: 100% !important;
// display: none;

View File

@@ -0,0 +1,276 @@
<template>
<el-dialog
title="数据查询"
v-model='dialogVisible'
v-bind="dialogBig"
draggable
>
<div class='table-box'>
<el-tabs type="border-card">
<el-tab-pane label="检测结果">
<!-- 列表数据 -->
<div class="container_table1">
<ProTable
ref='proTable1'
:columns='columns1'
:data="testResultDatas"
:toolButton="false"
>
</ProTable>
</div>
</el-tab-pane>
<el-tab-pane label="原始数据">
<!-- 列表数据 -->
<div class="container_table2">
<ProTable
ref='proTable2'
:columns='columns2'
:data="testDatas"
:toolButton="false"
>
</ProTable>
</div>
</el-tab-pane>
</el-tabs>
</div>
</el-dialog>
</template>
<script setup lang='tsx' name='useRole'>
import { Role } from '@/api/role/interface'
import { useHandleData } from '@/hooks/useHandleData'
import { useDownload } from '@/hooks/useDownload'
import { useAuthButtons } from '@/hooks/useAuthButtons'
import ProTable from '@/components/ProTable/index.vue'
import rolePopup from './components/rolePopup.vue'
import permissionUnit from './components/permissionUnit.vue'
import ImportExcel from '@/components/ImportExcel/index.vue'
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import {dialogBig,dialogMiddle,dialogSmall} from '@/utils/elementBind'
import { CirclePlus, Delete, EditPen, Share, Download, Upload, View, Refresh } from '@element-plus/icons-vue'
import { useDictStore } from '@/stores/modules/dict'
import {
getRoleList,
deleteRole,
} from '@/api/role/role'
import { deleteUser } from '@/api/user/user'
const dialogVisible = ref(false)
const open = () => {
dialogVisible.value = true
}
defineExpose({ open })
// ProTable 实例
const proTable1 = ref<ProTableInstance>()
const proTable2 = ref<ProTableInstance>()
// dataCallback 是对于返回的表格数据做处理,如果你后台返回的数据不是 list && total 这些字段,可以在这里进行处理成这些字段
// 或者直接去 hooks/useTable.ts 文件中把字段改为你后端对应的就行
const dataCallback = (data: any) => {
return {
records: data.list,
total: data.total,
current: data.pageNum,
size: data.pageSize,
}
}
// 如果你想在请求之前对当前请求参数做一些操作可以自定义如下函数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 getRoleList(newParams)
}
// 页面按钮权限(按钮权限既可以使用 hooks也可以直接使用 v-auth 指令指令适合直接绑定在按钮上hooks 适合根据按钮权限显示不同的内容)
const { BUTTONS } = useAuthButtons()
interface TestResultData {
standardData: number,//标准值
testedData: number,//被检值
errorData: number,//误差值
errorValue: number,//误差允许值
testResult: string,//检测结果(合格、不合格、无法比较)
}
interface TestData {
dataTime: string,//数据时间(合格、不合格、无法比较)
standardData: number,//标准值
testedData: number,//被检值
}
//检测结果数组
const testResultDatas = [
{
standardData: 57.74,//标准值
testedData: 57.73,//被检值
errorData: 0.01,//误差值
errorValue: 0.05774,//误差允许值
testResult: "合格",//检测结果(合格、不合格、无法比较)
}
];
//原始数据数组
const testDatas = [
{
dataTime: "2024-11-11 14:05:00",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:03",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:06",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:09",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:12",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:15",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:18",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:21",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:24",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:27",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:30",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:33",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:36",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:39",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:42",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:45",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:48",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:51",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:54",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
{
dataTime: "2024-11-11 14:05:57",//检测数据时间
standardData: 57.74,//标准值
testedData: 57.73,//被检值
},
];
// 表格配置项
const columns1 = reactive<ColumnProps<TestResultData>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'standardData',
label: '标准值',
minWidth: 150,
},
{
prop: 'testedData',
label: '被检值',
minWidth: 150,
},
{
prop: 'errorData',
label: '误差值',
minWidth: 150,
},
{
prop: 'errorValue',
label: '误差允许值',
minWidth: 150,
},
{
prop: 'testResult',
label: '检测结果',
minWidth: 150,
},
])
// 表格配置项
const columns2 = reactive<ColumnProps<TestData>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'dataTime',
label: '数据时间',
minWidth: 200,
},
{
prop: 'standardData',
label: '标准值',
minWidth: 150,
},
{
prop: 'testedData',
label: '被检值',
minWidth: 150,
},
])
</script>

View File

@@ -1,11 +1,11 @@
<template>
<div class="plan_tree">
<div class="search_view">
<!-- <div class="search_view">
<el-input
placeholder="请输入计划名称"
v-model="searchForm.planName"
></el-input>
</div>
</div> -->
<div class="tree_container">
<el-tree
:data="data"
@@ -19,12 +19,14 @@
@node-click="handleNodeClick"
@check-change="changeSelect"
>
<!-- scriptIdx -->
<template #default="{ node, data }">
<span
class="custom-tree-node"
style="display: flex; align-items: center"
>
<!-- <Platform v-if="!data.pid" style="width:18px;height: 18px;margin-right:8px;" :style="{color:node.label=='未检测'?'#F56C6C':node.label=='检测中'?'#E6A23C':'#67C23A'}"/> -->
<CircleCheck v-if="data.isChildNode && data.scriptIdx < currentIndex" style="width:18px;height: 18px;margin-right:8px;color:#67C23A;"/>
<Loading v-if="data.isChildNode && data.scriptIdx === currentIndex" style="width:18px;height: 18px;margin-right:8px;color:#E6A23C;"/>
<span>{{ node.label }}</span>
</span>
</template>
@@ -34,7 +36,7 @@
</template>
<script lang="ts" setup>
import { ref, onMounted, defineExpose, watch } from "vue";
import { Menu, Platform } from "@element-plus/icons-vue";
import { Menu, Platform, CircleCheck,Loading } from "@element-plus/icons-vue";
const emit = defineEmits(["jump"]);
const data: any = ref([]);
const defaultProps = {
@@ -55,6 +57,17 @@ const getTreeData = (val: any) => {
};
const filterText = ref("");
const treeRef = ref();
const currentIndex = ref(0);
const timer = setInterval(() => {
currentIndex.value++;
if (currentIndex.value > 14)
currentIndex.value = 0;
console.log(currentIndex.value);
}, 2000);
watch(
() => searchForm.value.planName,
(val) => {

View File

@@ -1,6 +1,24 @@
<template>
<!-- 自动检测页面 -->
<div class="test">
<!-- 顶部筛选条件&返回按钮 -->
<!-- {{ printText }} -->
<div class="test_top">
<!-- style="pointer-events: none" -->
<el-checkbox
v-for="(item, index) in detectionOptions"
v-model="item.selected"
:key="index"
:label="item.name"
></el-checkbox
>
<el-button type="primary" @click="handlePreTest">预检测</el-button>
<el-button type="primary" @click="handleAutoTest">正式检测</el-button>
<el-button type="primary" @click="handleBackDeviceList"
>返回首页</el-button
>
</div>
<div class="test_bot">
<div class="test_left">
<Tree ref="treeRef"></Tree>
</div>
@@ -24,6 +42,23 @@
/>
<div class="test_button">
<el-button
type="primary"
v-if="!isPause"
:icon="VideoPause"
@click="handlePauseTest"
>暂停检测</el-button
>
<el-button
type="warning"
v-if="isPause"
:icon="Refresh"
@click="handlePauseTest"
>继续检测</el-button
>
<el-button type="danger" :icon="Close" @click="handleFinishTest"
>停止检测</el-button
>
<!-- <el-button
type="danger"
v-if="!isPause"
:icon="Close"
@@ -39,10 +74,10 @@
>
<el-button type="primary" :icon="Check" @click="handleFinishTest"
>完成检测</el-button
>
> -->
</div>
</template>
<el-descriptions-item width="0px" label="上送数据总数">
<!-- <el-descriptions-item width="0px" label="上送数据总数">
{{ num }}
</el-descriptions-item>
<el-descriptions-item width="0px" label="已上送数据数">
@@ -50,13 +85,13 @@
</el-descriptions-item>
<el-descriptions-item width="0px" label="待上送数据数">
{{ num2 }}
</el-descriptions-item>
</el-descriptions-item> -->
</el-descriptions>
<!-- 右侧列表 -->
<div class="right_table">
<!-- 模拟列表样式 -->
<!-- 表头设备 -->
<div class="table_left">
<div class="table_left" v-if="false">
<p>测试项目</p>
<div v-for="(item, index) in deviceTestList" :key="index">
{{ item.name }}
@@ -74,9 +109,18 @@
v-for="(item, index) in deviceTestList"
:key="index"
>
<p v-for="(vv, vvs) in item.children" :key="vvs">
<!-- <p v-for="(vv, vvs) in item.children" :key="vvs">
{{ vv.status }}
</p>
</p> -->
<el-button
v-for="(vv, vvs) in item.children"
:key="vvs"
:type="vv.type"
text
@click="handleClick(item,index,vvs)"
>
{{ vv.label }}
</el-button>
</div>
</div>
</div>
@@ -98,7 +142,8 @@
</div>
<!-- 右侧状态加载 -->
<div class="right_status" ref="statusRef">
<p v-for="(item, index) in statusList" :key="index">
<!-- ,fontSize:index%5===0?'16px':'14px' -->
<p v-for="(item, index) in statusList" :key="index" :style="{color:index%5===0?'#F56C6C':'var(--el-text-color-regular)'}">
输入{{ item.remark }} -{{
item.status == 0 ? "输出完毕" : "输入中请稍后"
}}<br />
@@ -107,6 +152,9 @@
</div>
</div>
</div>
</div>
<ShowDataPopup ref='showDataPopup'/>
</template>
<script lang="ts" setup>
import { ref, onMounted, reactive, nextTick } from "vue";
@@ -116,6 +164,7 @@ import ProTable from "@/components/ProTable/index.vue";
import { useTransition } from "@vueuse/core";
import { getPlanList } from "@/api/plan/planList";
import { ElMessage, ElMessageBox } from "element-plus";
import ShowDataPopup from './components/ShowDataPopup.vue'
import {
CirclePlus,
Delete,
@@ -128,8 +177,136 @@ import {
Refresh,
Search,
Close,
VideoPause,
} from "@element-plus/icons-vue";
const treeRef = ref<any>();
const PopupVisible = ref(false)
const showDataPopup = ref()
//定义与预检测配置数组
const detectionOptions = ref([
{
id: 0,
name: "标准源通讯检测",//判断源通讯是否正常
selected: true,
},
{
id: 1,
name: "设备通讯检测",//判断设备的IP、Port、识别码、秘钥是否正常
selected: true,
},
{
id: 2,
name: "协议校验",//ICD报告触发测试
selected: true,
},
{
id: 3,
name: "相序校验",//判断装置的接线是否正确
selected: true,
},
{
id: 4,
name: "守时校验",//判断装置24小时内的守时误差是否小于1s
selected: true,
},
{
id: 5,
name: "通道系数校准",//通过私有协议与装置进行通讯,校准三相电压电流的通道系数
selected: true,
},
// {
// id: 6,
// name: "实时数据比对",
// },
// {
// id: 7,
// name: "录波数据比对",
// },
]);
const leftDeviceData = ref<any>([
// {
// id: 0,
// name: "设备1-预检测",
// status: 0,
// },
// {
// id: 1,
// name: "设备2-预检测",
// status: 1,
// },
// {
// id: 2,
// name: "设备3-预检测",
// status: 1,
// },
// {
// id: 3,
// name: "设备4-预检测",
// status: 0,
// },
// {
// id: 4,
// name: "设备5-预检测",
// status: 1,
// },
// {
// id: 5,
// name: "设备6-预检测",
// status: 0,
// },
]);
const initLeftDeviceData = () => {
leftDeviceData.value.map((item, index) => {
// handlePrintText(item.name, index);
});
};
// 点击数据结果
const handleClick = (item,index,vvs) => {
//const data = "检测脚本为:"+item.name+";被检设备为:"+item.children.value.devID+";被检通道序号为:"+ item.children.monitorIndex;
console.log(vvs,index,item.name,item.children)
PopupVisible.value = true
showDataPopup.value.open()
};
//启动预检测
const handlePreTest = () => {
ElMessage.success("启动预检测");
let count = 0;
if (timer) {
clearInterval(timer);
count = 0;
leftDeviceData.value = [];
}
if (count == 5) {
count = 0;
} else {
timer = setInterval(async () => {
count++;
if (count > 15) return;
await nextTick(() => {
leftDeviceData.value.push({
id: count,
name: "设备" + count + "预检测",
status: count % 2 == 0 ? 0 : 1,
});
});
}, 2000);
}
};
//进入检测流程
const handleAutoTest = () => {
router.push({
path: "/plan/autoTest",
});
};
//返回设备列表
const handleBackDeviceList = () => {
router.push({
path: "/plan/home/index",
});
};
// 表格配置项
const columns = reactive<ColumnProps<User.ResUserList>[]>([
{ type: "selection", fixed: "left", width: 70 },
@@ -283,22 +460,22 @@ const getTableList = (params: any) => {
const percentage = ref(0);
const customColors = [
{ color: "red", percentage: 0 },
{ color: "red", percentage: 10 },
{ color: "red", percentage: 20 },
{ color: "red", percentage: 30 }, //红
{ color: "red", percentage: 40 },
{ color: "#e6a23c", percentage: 50 },
{ color: "#e6a23c", percentage: 60 },
{ color: "#e6a23c", percentage: 70 }, //黄
{ color: "#e6a23c", percentage: 80 }, //1989fa
{ color: "#e6a23c", percentage: 90 }, //1989fa
// { color: "red", percentage: 0 },
// { color: "red", percentage: 10 },
// { color: "red", percentage: 20 },
// { color: "red", percentage: 30 }, //红
// { color: "red", percentage: 40 },
// { color: "#e6a23c", percentage: 50 },
// { color: "#e6a23c", percentage: 60 },
// { color: "#e6a23c", percentage: 70 }, //黄
// { color: "#e6a23c", percentage: 80 }, //1989fa
// { color: "#e6a23c", percentage: 90 }, //1989fa
{ color: "#5cb87a", percentage: 100 }, //绿
];
//加载进度条
const refreshProgress = () => {
if (percentage.value < 100) {
percentage.value += 10;
percentage.value += 1;
num1.value += 1001;
num2.value -= 1001;
} else {
@@ -323,21 +500,37 @@ const deviceData = ref([
id: 0,
name: "设备1通道1",
status: Math.floor(Math.random() * 4),
type:"info",
label:"/",
devID:"dev1",
monitorIndex:1,
},
{
id: 1,
name: "设备2通道2",
name: "设备1通道2",
status: Math.floor(Math.random() * 4),
type:"success",
label:"√",
devID:"dev1",
monitorIndex:2,
},
{
id: 2,
name: "设备3通道3",
name: "设备2通道1",
status: Math.floor(Math.random() * 4),
type:"danger",
label:"×",
devID:"dev2",
monitorIndex:1,
},
{
id: 3,
name: "设备4通道4",
name: "设备3通道1",
status: Math.floor(Math.random() * 4),
type:"success",
label:"√",
devID:"dev3",
monitorIndex:1,
},
]);
const interValTest = () => {
@@ -348,6 +541,8 @@ const interValTest = () => {
children: deviceData.value,
// status: Math.floor(Math.random() * 4),
});
// console.log(deviceTestList.value,11111);
refreshProgress();
}, 2000);
statusTimer.value = setInterval(() => {
@@ -431,7 +626,31 @@ onMounted(() => {
height: 100%;
box-sizing: border-box;
display: flex;
flex-direction: column;
justify-content: space-between;
.test_top {
width: 100%;
height: 50px;
display: flex;
background-color: #fff;
justify-content: flex-start;
align-items: center;
border-radius: 4px;
padding: 0 10px;
box-sizing: border-box;
.el-button {
margin-top: 10px;
margin-bottom: 10px;
margin-left: 20px;
}
}
.test_bot {
flex: 1;
margin-top: 10px;
display: flex;
height: calc(100vh - 240px);
.test_left {
max-width: 300px;
min-width: 200px;
@@ -484,11 +703,13 @@ onMounted(() => {
.right_device_title {
width: 100%;
display: flex;
justify-content: space-between;
justify-content: center;
// overflow-x: auto !important;
p {
flex: 1;
// max-width: 150px;
text-align: center;
width: auto;
padding: 0 10px;
margin: 0;
@@ -503,7 +724,7 @@ onMounted(() => {
display: flex;
justify-content: space-between;
align-items: center;
p {
.el-button {
flex: 1;
// max-width: 150px;
min-width: auto;
@@ -534,6 +755,7 @@ onMounted(() => {
}
}
}
}
}
::v-deep .header-button-lf {

View File

@@ -1,13 +1,20 @@
<template>
<!-- 权限信息弹出框 -->
<el-dialog :model-value="dialogVisible" title="编辑计划所属设备" v-bind="dialogBig" @close="handleCancel" width="600" draggable>
<el-dialog :model-value="dialogVisible" title="设备绑定" v-bind="dialogBig" @close="handleCancel" width="600" draggable>
<div>
<el-transfer v-model="value"
filterable
:filter-method="filterMethod"
filter-placeholder="请输入内容搜索"
:data="data"
:titles="['未绑定设备', '计划所属设备']"/>
:titles="['未绑定设备', '已绑定设备']">
<template #default="{ option }">
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
<span>{{ option.label }}</span>
</el-tooltip>
</template>
</el-transfer>
</div>
<template #footer>
<div class="dialog-footer">
@@ -34,6 +41,7 @@
key: number
label: string
initial: string
tips: string
}
const generateData = () => {
@@ -47,14 +55,21 @@
'易司拓测试装置',
'山大电力测试装置1',
'山大电力测试装置2',
'滚动条测试1',
'滚动条测试2',
'滚动条测试3',
'滚动条测试4',
'滚动条测试5',
'滚动条测试6',
]
const initials = ['CA', 'IL', 'MD', 'TX', 'FL', 'CO', 'CT', 'GT']
const initials = ['CA', 'IL', 'MD', 'TX', 'FL', 'CO', 'CT', 'GT', 'IL', 'MD', 'TX', 'FL', 'CO', 'CT', 'GT']
states.forEach((city, index) => {
data.push({
label: city,
key: index,
initial: initials[index],
tips:"PQS882A 192.16.1.136",
})
})
return data

View File

@@ -0,0 +1,119 @@
<template>
<!-- 权限信息弹出框 -->
<el-dialog :model-value="dialogVisible" title="检测源绑定" v-bind="dialogBig" @close="handleCancel" width="600" draggable>
<div>
<el-transfer v-model="value"
class="custom-transfer"
filterable
:filter-method="filterMethod"
filter-placeholder="请输入内容搜索"
:data="data"
:titles="['未绑定检测源', '已绑定检测源']">
<template #default="{ option }">
<el-tooltip :content="option.tips" placement="top" :show-after=1000>
<span>{{ option.label }}</span>
</el-tooltip>
</template>
</el-transfer>
</div>
<template #footer>
<div class="dialog-footer">
<el-button @click="handleCancel">取消</el-button>
<el-button type="primary" @click="handleCancel">
保存
</el-button>
</div>
</template>
</el-dialog>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import type { Device } from '@/api/device/interface'
import deviceDataList from '@/api/device/deviceData'
import { dialogBig } from '@/utils/elementBind'
const {dialogVisible} = defineProps<{
dialogVisible: boolean;
}>()
interface Option {
key: number
label: string
initial: string
tips: string
}
const generateData = () => {
const data: Option[] = []
const states = [
'标准源-福禄克-6100A',
'标准源-昂立-PF2',
'标准源-丹迪克-DKLN1',
'标准源-博电源-PQC600A',
'高精度设备-PQV520-1',
'高精度设备-PQV520-2',
]
const initials = ['FLUKE.6100A', 'ANGLI-FP2', 'DKLN-1', 'PQC600A', 'PQV520-1', 'PQV520-2']
states.forEach((city, index) => {
data.push({
label: city,
key: index,
initial: initials[index],
tips:"IP:192.16.1.124",
})
})
return data
}
const generateValue = () => {
const data: number[] = []
const states = [
'高精度设备-PQV520-1',
'高精度设备-PQV520-2',
]
const initials = ['PQV520-1', 'PQV520-2']
states.forEach((city, index) => {
const key = states.indexOf(city)
if (key !== -1) {
data.push(key)
}
})
return data
}
// const generateValue = () => {
// const data: Option[] = []
// const states = [
// '山大电力测试装置1',
// '山大电力测试装置2',
// ]
// const initials = ['AB', 'CD']
// states.forEach((city, index) => {
// data.push({
// label: city,
// key: index,
// initial: initials[index],
// })
// })
// return data
// }
const data = ref<Option[]>(generateData())
const value = ref<number[]>(generateValue())
const emit = defineEmits<{
(e:'update:visible',value:boolean):void;
}>();
const handleCancel = () => {
emit('update:visible',false)
}
const filterMethod = (query, item) => {
return item.label.toLowerCase().includes(query.toLowerCase())
}
</script>
<style scoped>
.custom-transfer .el-transfer-panel{
overflow-x: auto !important;
}
</style>

View File

@@ -0,0 +1,31 @@
<template>
<el-dropdown @command="handleCommand">
<span class="el-dropdown-link">
更多<el-icon class="el-icon--right"><arrow-down /></el-icon>
</span>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item command="a">高精度设备-PQV520-2</el-dropdown-item>
<el-dropdown-item command="b">高精度设备-PQV520-3</el-dropdown-item>
<el-dropdown-item command="c">高精度设备-PQV520-4</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</template>
<script lang="ts" setup>
import { ElMessage } from 'element-plus'
import { ArrowDown } from '@element-plus/icons-vue'
const handleCommand = (command: string | number | object) => {
ElMessage(`click on item ${command}`)
}
</script>
<style scoped>
.example-showcase .el-dropdown-link {
cursor: pointer;
color: var(--el-button-text-color);
display: flex;
align-items: center;
}
</style>

View File

@@ -7,96 +7,143 @@
>
<!-- 表格 header 按钮 -->
<template #tableHeader='scope'>
<el-button type='primary' :icon='Download' @click="importClick">导入</el-button>
<el-button type='primary' :icon='CirclePlus' :disabled='!(scope.selectedList.length > 1)' @click="combineClick">合并</el-button>
<el-button type='primary' :icon='CirclePlus' @click="openAddDialog">新增</el-button>
<el-button type='primary' :icon='Download' @click='importClick'>导入</el-button>
<el-button type='primary' :icon='CirclePlus' :disabled='!(scope.selectedList.length > 1)' @click='combineClick'>
合并
</el-button>
<el-button type='primary' :icon='CirclePlus' @click='openAddDialog'>新增</el-button>
<el-button type='danger' :icon='Delete' plain :disabled='!scope.isSelected'>
批量删除
</el-button>
<input type="file" style="display: none" ref="fileInput" @change="handleFiles">
<input type='file' style='display: none' ref='fileInput' @change='handleFiles'>
</template>
<!-- 表格操作 -->
<template #operation='scope'>
<!-- <el-button type='primary' link :icon='View' @click="handleRowClick(scope.row)">查看</el-button> -->
<el-button type='primary' link :icon='Upload' @click="exportClick">导出</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>
<el-button type='primary' link :icon='List' @click="showtestSourceOpen(scope.row)">所属检测源</el-button>
<el-button type='primary' link :icon='Upload' @click='exportClick'>导出</el-button>
<el-button type='primary' link :icon='EditPen' @click='openEditDialog(scope.row)'>编辑</el-button>
<div class='cn-render-buttons'>
<el-dropdown trigger='click'>
<el-button link type='primary' class='table-operate'>
<div class='table-operate-text'>更多</div>
</el-button>
<template #dropdown>
<el-dropdown-menu>
<el-dropdown-item :style="{color: 'var(--el-color-danger)'}" :icon='Delete'>
删除
</el-dropdown-item>
<el-dropdown-item :icon='List' @click='showDeviceOpen(scope.row)'>
设备绑定
</el-dropdown-item>
<el-dropdown-item :icon='Tools' @click='showtestSourceOpen(scope.row)'>
检测源绑定
</el-dropdown-item>
</el-dropdown-menu>
</template>
</el-dropdown>
</div>
</template>
</ProTable>
<!-- 向计划导入/导出设备对话框 -->
<planPopup
:visible="dialogFormVisible"
:formData="dialogForm"
:dialogTitle="dialogTitle"
:is-read-only="isReadOnly"
@update:visible="dialogFormVisible = $event"
/>
@update:visible="dialogFormVisible = $event"/>
<!-- 查看误差体系详细信息 -->
<ErrorStandardDialog
:visible='detail_dialogFormVisible'
:formData='detail_dialogForm'
:dialogTitle='detail_dialogTitle'
@update:visible='detail_dialogFormVisible = $event'
/>
</div>
<devTransfer
:dialogVisible=devTransferVisible
@update:visible='devTransferVisible = $event'
/>
<sourceTransfer
:dialogVisible=sourceTransferVisible
@update:visible='sourceTransferVisible = $event'
/>
<DeviceOpen :width='viewWidth' :height='viewHeight' ref='openDeviceView' />
<SourceOpen :width='viewWidth' :height='viewHeight' ref='openSourceView' />
</template>
<script setup lang="ts" name='useProTable'>
<script setup lang='tsx' name='useProTable'>
import ProTable from '@/components/ProTable/index.vue'
import TimeControl from '@/components/TimeControl/index.vue'
import type { ProTableInstance,ColumnProps } from '@/components/ProTable/interface'
import { CirclePlus, Delete,EditPen,View,Upload,Download,List} from '@element-plus/icons-vue'
import {dictPattern,dictTestState,dictReportState,dictResult,testPlanDataList,testSoureDataList,testScriptDataList,testErrSystDataList,planData,testFatherPlanList} from '@/api/plan/planData'
import { reactive,ref } from 'vue'
import type { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import { CirclePlus, Delete, EditPen, View, Upload, Download, List, Tools } from '@element-plus/icons-vue'
import {
dictPattern,
dictTestState,
dictReportState,
dictResult,
testPlanDataList,
testSoureDataList,
testScriptDataList,
testErrSystDataList,
planData,
testFatherPlanList,
} from '@/api/plan/planData'
import { reactive, ref } from 'vue'
import type { Plan } from '@/api/plan/interface'
import planPopup from "@/views/plan/planList/components/planPopup.vue"; // 导入子组件
import planPopup from '@/views/plan/planList/components/planPopup.vue' // 导入子组件
import DeviceOpen from '@/views/plan/planList/components/devPopup.vue'
import SourceOpen from '@/views/plan/planList/components/sourcePopup.vue'
import temp from './components/temp.vue'
import devTransfer from './components/devTransfer.vue'
import sourceTransfer from './components/sourceTransfer.vue'
import { useViewSize } from '@/hooks/useViewSize'
import { useRouter } from "vue-router";
import { useRouter } from 'vue-router'
import { useDictStore } from '@/stores/modules/dict'
import { ElMessage, ElMessageBox } from 'element-plus'
import type { Action } from 'element-plus'
import type { ErrorSystem } from '@/api/error/interface'
import ErrorStandardDialog from '@/views/machine/errorSystem/components/ErrorStandardDialog.vue' // 导入子组件
const dictStore = useDictStore()
// 定义包含和排除的单位
const includedUnits = ['日', '周', '月', '自定义']; // 可以根据需要包含的单位
const excludedUnits = ['季度','年']; // 要排除的单位
const defaultUnits = '日'; // 默认的单位
const includedUnits = ['日', '周', '月', '自定义'] // 可以根据需要包含的单位
const excludedUnits = ['季度', '年'] // 要排除的单位
const defaultUnits = '日' // 默认的单位
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
const openDeviceView = ref()
const openSourceView = ref()
const devTransferVisible = ref(false)
const sourceTransferVisible = ref(false)
// ProTable 实例
const proTable = ref<ProTableInstance>()
// const planData = planData
const dialogFormVisible = ref(false)
const dialogTitle = ref('')
const isReadOnly = ref(false)
const router = useRouter();
const router = useRouter()
const dialogForm = ref<Plan.PlanBO>({
id: '' ,
id: '',
name: '',
pattern:'',
father_Plan_Id:'',
dataSource_Id:'',
script_Id:'',
error_Sys_Id:'',
pattern: '',
father_Plan_Id: '',
dataSource_Id: '',
script_Id: '',
error_Sys_Id: '',
test_State: '',
report_State: '',
result:'',
result: '',
});
})
const detail_dialogFormVisible = ref(false)
const detail_dialogTitle = ref('Q/GDW 10650.2-2021 误差体系')
const detail_dialogForm = ref<ErrorSystem.Error_detail>({
measured: '',//被测量
deviceLevel: '',//检测装置级别
measurementType: '',
condition: '',//测量条件
maxErrorValue: '',//最大误差
})
// 表格配置项
const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
const columns = reactive<ColumnProps<Plan.PlanAndSourceBO>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
@@ -108,7 +155,25 @@ const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
{
prop: 'testSourceName',
label: '检测源名称',
width: 200,
width: 300,
render: scope => {
return (
// <el-button
// v-for="(button, index) in scope.row.testSourceList"
// :key="index"
// @click="handleClick(button)"
// >
// {{ button.text }}
// </el-button>
<div class='flx-flex-start'>
<el-button type='primary' link onClick={() => showData(scope.row.testSourceName)}>
{scope.row.testSourceName}
</el-button>
<temp></temp>
</div>
)
},
},
{
prop: 'script_Id',
@@ -116,6 +181,13 @@ const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
width: 300,
enum: testScriptDataList,
fieldNames: { label: 'label', value: 'id' },
render: scope => {
return (
<el-button type='primary' link onClick={() => showData(scope.row.script_Id)}>
{getScriptName(scope.row.script_Id)}
</el-button>
)
},
},
{
prop: 'error_Sys_Id',
@@ -123,6 +195,14 @@ const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
width: 200,
enum: testErrSystDataList,
fieldNames: { label: 'label', value: 'id' },
render: scope => {
const errSysName = getErrSysName(scope.row.error_Sys_Id)
return (
<el-button type='primary' link onClick={() => showData(errSysName || '')}>
{errSysName}
</el-button>
)
},
},
{
prop: 'dataSource_Id',
@@ -179,23 +259,41 @@ const columns = reactive<ColumnProps<Plan.PlanBO>[]>([
// },
// },
// },
{ prop: 'operation', label: '操作', fixed: 'right' ,width: 450, },
{ prop: 'operation', label: '操作', fixed: 'right', width: 250 },
])
function getScriptName(id: string) {
return testScriptDataList.find(item => item.id == id)?.label
}
const fileInput = ref<HTMLInputElement | null>(null); // 声明 fileInput
function openFileDialog() {
function getErrSysName(id: string) {
return testErrSystDataList.find(item => item.id == id)?.label
}
const fileInput = ref<HTMLInputElement | null>(null) // 声明 fileInput
function openFileDialog() {
if (fileInput.value) {
fileInput.value.click();
fileInput.value.click()
}
}
function showData(row: string) {
detail_dialogTitle.value = row
detail_dialogFormVisible.value = true // 显示对话框
// router.push({
// path: "/machine/device",
// query: { id: row }
// });
}
function handleFiles(event: Event) {
const target = event.target as HTMLInputElement;
const files = target.files;
const target = event.target as HTMLInputElement
const files = target.files
if (files && files.length > 0) {
// 处理文件
console.log(files);
console.log(files)
ElMessageBox.confirm(
'导入的数据与当前数据有冲突,请选择以哪个数据为主进行覆盖',
'数据冲突',
@@ -204,7 +302,7 @@ function handleFiles(event: Event) {
confirmButtonText: '以导入数据为主覆盖',
cancelButtonText: '以当前数据为主覆盖',
type: 'warning',
}
},
)
.then(() => {
ElMessage({
@@ -223,6 +321,7 @@ function handleFiles(event: Event) {
})
}
}
// 点击导入按钮
const importClick = () => {
openFileDialog()
@@ -240,10 +339,10 @@ const combineClick = () => {
{
confirmButtonText: '确定',
cancelButtonText: '取消',
}
},
)
.then(({ value }) => {
console.log(`合并后的计划名为:`,value)
console.log(`合并后的计划名为:`, value)
proTable.value?.clearSelection()
proTable.value?.getTableList()
})
@@ -251,45 +350,46 @@ const combineClick = () => {
// 打开编辑对话框
const openEditDialog = (planSystem: Plan.PlanBO) => {
dialogForm.value = {...planSystem};
dialogTitle.value = '编辑检测计划';
isReadOnly.value = false;
dialogFormVisible.value = true; // 打开对话框
};
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:'',
pattern: '',
father_Plan_Id: '',
dataSource_Id: '',
script_Id: '',
error_Sys_Id: '',
test_State: '',
report_State: '',
result:'',
};
dialogTitle.value = '新增检测计划';
isReadOnly.value = false;
dialogFormVisible.value = true; // 打开对话框
};
result: '',
}
dialogTitle.value = '新增检测计划'
isReadOnly.value = false
dialogFormVisible.value = true // 打开对话框
}
const handleRowClick = (planSystem: Plan.PlanBO) =>{
dialogForm.value = {...planSystem};
dialogTitle.value = '查看检测计划';
isReadOnly.value = true;
dialogFormVisible.value = true; // 打开对话框
const handleRowClick = (planSystem: Plan.PlanBO) => {
dialogForm.value = { ...planSystem }
dialogTitle.value = '查看检测计划'
isReadOnly.value = true
dialogFormVisible.value = true // 打开对话框
}
const showDeviceOpen = (planSystem: Plan.PlanBO) => {
devTransferVisible.value = true;
devTransferVisible.value = true
//openDeviceView.value.open('计划设备列表')
}
const showtestSourceOpen=(planSystem: Plan.PlanBO)=>{
openSourceView.value.open('计划检测源列表')
const showtestSourceOpen = (planSystem: Plan.PlanBO) => {
sourceTransferVisible.value = true
// openSourceView.value.open('计划检测源列表')
// router.push({
// path: "/machine/testSource",
// });

View File

@@ -13,10 +13,10 @@
>{{ item.name }}</el-checkbox
>
<el-button type="primary" @click="handlePreTest">启动预检测</el-button>
<el-button type="primary" @click="handleBackDeviceList"
>返回设备列表</el-button
>
<el-button type="primary" @click="handleAutoTest">进入检测流程</el-button>
<el-button type="primary" @click="handleBackDeviceList"
>返回检测首页</el-button
>
</div>
<div class="test_bot">
<div class="bot_left">
@@ -158,7 +158,7 @@ const handlePreTest = () => {
} else {
timer = setInterval(async () => {
count++;
if (count > 5) return;
if (count > 15) return;
await nextTick(() => {
leftDeviceData.value.push({
id: count,
@@ -178,7 +178,7 @@ const handleAutoTest = () => {
//返回设备列表
const handleBackDeviceList = () => {
router.push({
path: "/plan/singlePlanList",
path: "/plan/home/index",
});
};
//左侧数据

View File

@@ -1,6 +1,5 @@
<template>
<el-dialog v-model='dialogVisible' :title='dialogTitle' v-bind='dialogMiddle' @close="close">
<el-form :model='formContent' ref='dialogFormRef' :rules='rules' class='form-two'>
<el-divider >基础数据</el-divider>
<el-form-item label='数据模型' :label-width='140' prop='dataType'>
@@ -167,7 +166,6 @@
import { addDictPq, updateDictPq } from '@/api/system/dictionary/dictPq'
import { computed, type Ref, ref } from 'vue';
import { useDictStore } from '@/stores/modules/dict'
import { el } from 'element-plus/es/locale';
const dictStore = useDictStore()
const selectedStatMethods = ref<string[]>([])
// 定义弹出组件元信息
@@ -230,26 +228,13 @@ import { el } from 'element-plus/es/locale';
if (valid) {
formContent.value.statMethod = selectedStatMethods.value.join(',')
if (formContent.value.id) {
const result = await updateDictPq(formContent.value);
if(result.code != 'A0000'){
ElMessage.error({ message: result.message})
}else{
await updateDictPq(formContent.value);
ElMessage.success({ message: `${dialogTitle.value}成功!` })
}
} else {
const result = await addDictPq(formContent.value);
if(result.code != 'A0000'){
ElMessage.error({ message: result.message})
}else{
ElMessage.success({ message: `${dialogTitle.value}成功!` })
}
}
//ElMessage.success({ message: `${dialogTitle.value}成功!` })
close()
// 刷新表格
await props.refreshTable!()
@@ -264,7 +249,6 @@ import { el } from 'element-plus/es/locale';
const open = (sign: string, data: Dict.ResDictPq) => {
titleType.value = sign
dialogVisible.value = true
//console.log(dictStore)
selectedStatMethods.value = data.statMethod ? data.statMethod.split(',') : []
if (data.id) {
formContent.value = { ...data }

View File

@@ -19,33 +19,29 @@
</template>
</ProTable>
</div>
<PqPopup :refresh-table='proTable?.getTableList' ref='pqPopup'/>
</template>
<PqPopup :refresh-table='proTable?.getTableList' ref='pqPopup' />
</template>
<script setup lang='tsx' name='dict'>
import {CirclePlus, Delete, EditPen, Download, View} from '@element-plus/icons-vue'
import {type Dict} from '@/api/system/dictionary/interface'
import {ProTableInstance, ColumnProps} from '@/components/ProTable/interface'
import PqPopup from '@/views/system/dictionary/dictPq/components/pqPopup.vue'
import {useDictStore} from '@/stores/modules/dict'
import {useHandleData} from '@/hooks/useHandleData'
import {
<script setup lang='tsx' name='dict'>
import { CirclePlus, Delete, EditPen } from '@element-plus/icons-vue'
import { type Dict } from '@/api/system/dictionary/interface'
import { ProTableInstance, ColumnProps } from '@/components/ProTable/interface'
import PqPopup from '@/views/system/dictionary/dictPq/components/pqPopup.vue'
import { useDictStore } from '@/stores/modules/dict'
import { useHandleData } from '@/hooks/useHandleData'
import {
getDictPqList,
deleteDictPq,
} from '@/api/system/dictionary/dictPq'
import { reactive, ref } from 'vue'
} from '@/api/system/dictionary/dictPq'
import { reactive, ref } from 'vue'
const dictStore = useDictStore()
const dictStore = useDictStore()
const proTable = ref<ProTableInstance>()
const pqPopup = ref()
const proTable = ref<ProTableInstance>()
const pqPopup = ref()
const columns = reactive<ColumnProps<Dict.ResDictPq>[]>([
{type: 'selection', fixed: 'left', width: 70},
{type: 'index', fixed: 'left', width: 70, label: '序号'},
const columns = reactive<ColumnProps<Dict.ResDictPq>[]>([
{ type: 'selection', fixed: 'left', width: 70 },
{ type: 'index', fixed: 'left', width: 70, label: '序号' },
{
prop: 'dataType',
label: '数据模型',
@@ -68,10 +64,6 @@
minWidth: 300,
search: {
el: 'input',
},
render: (scope) => {
const codes = scope.row.otherName;
return codes || '/';
}
},
{
@@ -80,10 +72,6 @@
width: 180,
search: {
el: 'input',
},
render: (scope) => {
const codes = scope.row.showName;
return codes || '/';
}
},
{
@@ -96,20 +84,12 @@
{
prop: 'unit',
label: '单位',
width: 180,
render: (scope) => {
const codes = scope.row.unit;
return codes || '/';
}
width: 180
},
{
prop: 'type',
label: '指标数据类型',
width: 180,
render: (scope) => {
const codes = scope.row.type;
return codes || '/';
}
width: 180
},
{
prop: 'harmStart',
@@ -118,7 +98,7 @@
render: (scope) => {
return (scope.row.harmStart && scope.row.harmEnd)
? `${scope.row.harmStart}-${scope.row.harmEnd}`
: '/'; // 如果 harmStart 或 harmEnd 为空,返回 '/'
: '/' // 如果 harmStart 或 harmEnd 为空,返回 '/'
},
},
{
@@ -129,27 +109,25 @@
fieldNames: { label: 'name', value: 'code' },
render: (scope) => {
// 假设 statMethod 是一个数组,包含多个 'code' 值
const codes = scope.row.statMethod; // 获取当前行的 statMethod 字段
//console.log('codes',codes)
const codes = scope.row.statMethod // 获取当前行的 statMethod 字段
if (!codes) {
return '/'; // 如果 statMethod 为 undefined 或 null返回 '/'
return '/'
}
// 确保 codes 是一个字符串
const codeString = Array.isArray(codes) ? codes.join(',') : codes;
const codeArray = codeString.split(',');
const codeString = Array.isArray(codes) ? codes.join(',') : codes
const codeArray = codeString.split(',')
if (codeArray.length > 1) {
console.log('多个 code', codeString)
// 查找与每个 code 值匹配的 name然后拼接成逗号分割的字符串
//console.log('codeArray',codeArray)
const names = codeArray.map(code => {
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === code);
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
});
//console.log('names',names)
return names.join(', '); // 用逗号连接所有的 name
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === code)
return dictItem ? dictItem.name : '' // 如果找到匹配的项,返回对应的 name
})
return names.join(', ') // 用逗号连接所有的 name
}
// 查找单个 code 对应的 name
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === codeArray[0]);
return dictItem ? dictItem.name : ''; // 如果找到匹配的项,返回对应的 name
const dictItem = dictStore.getDictData('Stat_Method').find(item => item.code === codeArray[0])
return dictItem ? dictItem.name : '' // 如果找到匹配的项,返回对应的 name
},
},
{
@@ -165,11 +143,7 @@
label: '报表数据来源',
width: 180,
enum: dictStore.getDictData('Data_Day'),
fieldNames: { label: 'name', value: 'code' },
render: (scope) => {
const codes = scope.row.resourcesId;
return codes || '/';
}
fieldNames: { label: 'name', value: 'code' }
},
{
prop: 'operation',
@@ -177,31 +151,28 @@
fixed: 'right',
minWidth: 200,
},
])
])
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Dict.ResDictPq> = {}) => {
// 打开 drawer(新增、编辑)
const openDialog = (titleType: string, row: Partial<Dict.ResDictPq> = {}) => {
pqPopup.value?.open(titleType, row)
}
}
// 批量删除字典类型
const batchDelete = async (id: string[]) => {
// 批量删除字典类型
const batchDelete = async (id: string[]) => {
await useHandleData(deleteDictPq, id, '删除所选字典类型')
proTable.value?.clearSelection()
proTable.value?.getTableList()
}
}
// 删除字典类型
const handleDelete = async (params: Dict.ResDictPq) => {
// 删除字典类型
const handleDelete = async (params: Dict.ResDictPq) => {
await useHandleData(deleteDictPq, [params.id], `删除【${params.name}】指标字典类型`)
proTable.value?.getTableList()
}
}
</script>
</script>

View File

@@ -9,13 +9,13 @@
<el-input v-model='formContent.code' placeholder='请输入' autocomplete='off' />
</el-form-item>
<el-form-item label="开启等级" :label-width="100">
<el-radio-group v-model="formContent.openLevel" size="medium">
<el-radio-group v-model="formContent.openLevel" >
<el-radio-button label="开启" :value="1"></el-radio-button>
<el-radio-button label="关闭" :value="0"></el-radio-button>
</el-radio-group>
</el-form-item>
<el-form-item label="开启描述" :label-width="100">
<el-radio-group v-model="formContent.openDescribe" size="medium">
<el-radio-group v-model="formContent.openDescribe" >
<el-radio-button label="开启" :value="1"></el-radio-button>
<el-radio-button label="关闭" :value="0"></el-radio-button>
</el-radio-group>

View File

@@ -30,13 +30,11 @@ import { CirclePlus, Delete, Download, EditPen, View } from '@element-plus/icons
import { Dict } from '@/api/system/dictionary/interface'
import { ColumnProps, ProTableInstance } from '@/components/ProTable/interface'
import DictData from '@/views/system/dictionary/dictData/index.vue'
import { useDictStore } from '@/stores/modules/dict'
import { useHandleData } from '@/hooks/useHandleData'
import { useViewSize } from '@/hooks/useViewSize'
import { useDownload } from '@/hooks/useDownload'
import { deleteDictType, getDictTypeList, exportDictType } from '@/api/system/dictionary/dictType'
const dictStore = useDictStore()
const { popupBaseView, viewWidth, viewHeight } = useViewSize()
const proTable = ref<ProTableInstance>()
@@ -57,7 +55,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
{
prop: 'code',
label: '类型编码',
minWidth: 200,
minWidth: 220,
search: {
el: 'input',
},
@@ -65,7 +63,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
{
prop: 'remark',
label: '描述',
minWidth: 300,
minWidth: 250,
},
{
prop: 'sort',
@@ -81,7 +79,7 @@ const columns = reactive<ColumnProps<Dict.ResDictType>[]>([
prop: 'operation',
label: '操作',
fixed: 'right',
minWidth: 300,
minWidth: 250,
},
])