标准流程管理+流程创建
This commit is contained in:
39
rc_autoplc_front/src/api/tb/flowinfo.ts
Normal file
39
rc_autoplc_front/src/api/tb/flowinfo.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function flowInfoadd(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/flowInfo/add',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function flowInfodel(id: string | number) {
|
||||||
|
return request({
|
||||||
|
url: `/flowInfo/del/${id}`,
|
||||||
|
method: 'delete',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function flowInfoupd(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/flowInfo/update',
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function flowInfolist(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/flowInfo/listPage',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function flowInfobyid(id: string | number) {
|
||||||
|
return request({
|
||||||
|
url: `/flowInfo/getById/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
39
rc_autoplc_front/src/api/tb/stepinfo.ts
Normal file
39
rc_autoplc_front/src/api/tb/stepinfo.ts
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
export function stepInfoadd(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/stepInfo/add',
|
||||||
|
method: 'post',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stepInfodel(id: string | number) {
|
||||||
|
return request({
|
||||||
|
url: `/stepInfo/del/${id}`,
|
||||||
|
method: 'delete',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stepInfoupd(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/stepInfo/update',
|
||||||
|
method: 'put',
|
||||||
|
data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stepInfolist(data: any) {
|
||||||
|
return request({
|
||||||
|
url: '/stepInfo/listPage',
|
||||||
|
method: 'get',
|
||||||
|
params: data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function stepInfobyid(id: string | number) {
|
||||||
|
return request({
|
||||||
|
url: `/stepInfo/getById/${id}`,
|
||||||
|
method: 'get',
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -52,6 +52,16 @@ const router = createRouter({
|
|||||||
name: 'plc-devinfo',
|
name: 'plc-devinfo',
|
||||||
component: () => import('../views/devinfo/plc.vue'),
|
component: () => import('../views/devinfo/plc.vue'),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
path: '/flow-info',
|
||||||
|
name: 'flow-info',
|
||||||
|
component: () => import('../views/flowinfo/index.vue'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path: '/step-info',
|
||||||
|
name: 'step-info',
|
||||||
|
component: () => import('../views/stepinfo/index.vue'),
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -79,6 +79,20 @@
|
|||||||
<span>PLC设备管理</span>
|
<span>PLC设备管理</span>
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</el-sub-menu>
|
</el-sub-menu>
|
||||||
|
<el-sub-menu index="flow">
|
||||||
|
<template #title>
|
||||||
|
<el-icon><List /></el-icon>
|
||||||
|
<span>流程管理</span>
|
||||||
|
</template>
|
||||||
|
<el-menu-item index="/flow-info">
|
||||||
|
<el-icon><component :is="getMenuIcon('标准流程管理')" /></el-icon>
|
||||||
|
<span>标准流程管理</span>
|
||||||
|
</el-menu-item>
|
||||||
|
<el-menu-item index="/step-info">
|
||||||
|
<el-icon><EditPen /></el-icon>
|
||||||
|
<span>流程创建</span>
|
||||||
|
</el-menu-item>
|
||||||
|
</el-sub-menu>
|
||||||
</el-menu>
|
</el-menu>
|
||||||
</el-aside>
|
</el-aside>
|
||||||
|
|
||||||
@@ -94,7 +108,7 @@
|
|||||||
import { ref, computed } from 'vue'
|
import { ref, computed } from 'vue'
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
import { User, Setting, Avatar, OfficeBuilding, Briefcase, Document, CaretBottom, UserFilled, Grid, Monitor, Connection, Plus } from '@element-plus/icons-vue'
|
import { User, Setting, Avatar, OfficeBuilding, Briefcase, Document, CaretBottom, UserFilled, Grid, Monitor, Connection, List, EditPen, Files, Tickets, Management, FolderOpened } from '@element-plus/icons-vue'
|
||||||
import { useAuthStore } from '@/stores/auth'
|
import { useAuthStore } from '@/stores/auth'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -111,6 +125,24 @@ const activeMenu = computed(() => {
|
|||||||
return route.path
|
return route.path
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 根据菜单名称获取图标
|
||||||
|
const getMenuIcon = (menuName: string) => {
|
||||||
|
const iconMap: Record<string, any> = {
|
||||||
|
'标准流程管理': Files, // 文件图标,适合标准流程管理
|
||||||
|
'流程创建': EditPen,
|
||||||
|
'用户管理': User,
|
||||||
|
'角色管理': Avatar,
|
||||||
|
'部门管理': OfficeBuilding,
|
||||||
|
'职位管理': Briefcase,
|
||||||
|
'操作日志管理': Document,
|
||||||
|
'用户角色管理': UserFilled,
|
||||||
|
'功能岛管理': Setting,
|
||||||
|
'设备管理': Monitor,
|
||||||
|
'PLC设备管理': Connection,
|
||||||
|
}
|
||||||
|
return iconMap[menuName] || EditPen
|
||||||
|
}
|
||||||
|
|
||||||
// 处理下拉菜单命令
|
// 处理下拉菜单命令
|
||||||
const handleCommand = (command: string) => {
|
const handleCommand = (command: string) => {
|
||||||
if (command === 'logout') {
|
if (command === 'logout') {
|
||||||
|
|||||||
@@ -754,22 +754,14 @@ const paramTypeOptions = [
|
|||||||
{ label: '整数', value: 'integer' },
|
{ label: '整数', value: 'integer' },
|
||||||
{ label: '浮点数', value: 'float' },
|
{ label: '浮点数', value: 'float' },
|
||||||
{ label: '布尔值', value: 'boolean' },
|
{ label: '布尔值', value: 'boolean' },
|
||||||
{ label: '日期', value: 'date' },
|
|
||||||
{ label: '时间', value: 'datetime' },
|
|
||||||
{ label: 'JSON', value: 'json' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// 表单控件选项(常用表单控件)
|
// 表单控件选项(常用表单控件)
|
||||||
const formTypeOptions = [
|
const formTypeOptions = [
|
||||||
{ label: '输入框', value: 'input' },
|
{ label: '文本输入框', value: 'input' },
|
||||||
{ label: '文本域', value: 'textarea' },
|
|
||||||
{ label: '数字输入框', value: 'number' },
|
{ label: '数字输入框', value: 'number' },
|
||||||
{ label: '下拉选择', value: 'select' },
|
{ label: '下拉框', value: 'select' },
|
||||||
{ label: '单选按钮', value: 'radio' },
|
{ label: '文本域', value: 'textarea' },
|
||||||
{ label: '复选框', value: 'checkbox' },
|
|
||||||
{ label: '日期选择器', value: 'datepicker' },
|
|
||||||
{ label: '时间选择器', value: 'timepicker' },
|
|
||||||
{ label: '开关', value: 'switch' },
|
|
||||||
]
|
]
|
||||||
|
|
||||||
// 获取参数序号
|
// 获取参数序号
|
||||||
@@ -816,6 +808,20 @@ const getParamList = async () => {
|
|||||||
? data
|
? data
|
||||||
: []
|
: []
|
||||||
|
|
||||||
|
// 按主键id升序排列(没有id的排在最后)
|
||||||
|
records.sort((a: any, b: any) => {
|
||||||
|
const idA = a.id ?? 0
|
||||||
|
const idB = b.id ?? 0
|
||||||
|
// 如果都没有id,保持原顺序
|
||||||
|
if (idA === 0 && idB === 0) return 0
|
||||||
|
// 如果a没有id,a排在后面
|
||||||
|
if (idA === 0) return 1
|
||||||
|
// 如果b没有id,b排在后面
|
||||||
|
if (idB === 0) return -1
|
||||||
|
// 都有id,按id升序
|
||||||
|
return idA - idB
|
||||||
|
})
|
||||||
|
|
||||||
const totalValue =
|
const totalValue =
|
||||||
data.total ?? data.count ?? data.totalCount ?? records.length ?? 0
|
data.total ?? data.count ?? data.totalCount ?? records.length ?? 0
|
||||||
|
|
||||||
@@ -864,7 +870,7 @@ const handleAddParamRow = () => {
|
|||||||
isEditing: true,
|
isEditing: true,
|
||||||
isNew: true, // 标记为新添加的行
|
isNew: true, // 标记为新添加的行
|
||||||
}
|
}
|
||||||
paramList.value.unshift(newRow)
|
paramList.value.push(newRow)
|
||||||
paramTotal.value += 1
|
paramTotal.value += 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
581
rc_autoplc_front/src/views/flowinfo/index.vue
Normal file
581
rc_autoplc_front/src/views/flowinfo/index.vue
Normal file
@@ -0,0 +1,581 @@
|
|||||||
|
<template>
|
||||||
|
<div class="flowinfo-page">
|
||||||
|
<!-- 搜索栏 -->
|
||||||
|
<el-card class="search-card" shadow="never">
|
||||||
|
<div class="search-bar">
|
||||||
|
<el-form :inline="true" :model="queryForm" label-width="100px">
|
||||||
|
<el-form-item label="标准流程名称">
|
||||||
|
<el-input
|
||||||
|
v-model="queryForm.flowName"
|
||||||
|
placeholder="输入标准流程名称"
|
||||||
|
clearable
|
||||||
|
style="width: 200px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item>
|
||||||
|
<el-button type="primary" @click="handleSearch">查询</el-button>
|
||||||
|
<el-button @click="resetSearch">重置</el-button>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<div class="toolbar">
|
||||||
|
<el-button type="primary" @click="handleAdd">
|
||||||
|
<el-icon><Plus /></el-icon>
|
||||||
|
新增流程
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 流程信息列表 -->
|
||||||
|
<el-card shadow="never">
|
||||||
|
<el-table
|
||||||
|
:data="tableData"
|
||||||
|
stripe
|
||||||
|
border
|
||||||
|
style="width: 100%"
|
||||||
|
v-loading="loading"
|
||||||
|
>
|
||||||
|
<el-table-column
|
||||||
|
prop="flowIndex"
|
||||||
|
label="标准流程序号"
|
||||||
|
width="130"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="flowName"
|
||||||
|
label="标准流程名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="busyCode"
|
||||||
|
label="业务编号"
|
||||||
|
min-width="120"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="goodsCode"
|
||||||
|
label="样品编号"
|
||||||
|
min-width="120"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="goodsName"
|
||||||
|
label="样品名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="checkCode"
|
||||||
|
label="检样编号"
|
||||||
|
min-width="120"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="programName"
|
||||||
|
label="项目名称"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="testMethod"
|
||||||
|
label="检测方法"
|
||||||
|
min-width="150"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column
|
||||||
|
prop="scanNum"
|
||||||
|
label="扫描编号"
|
||||||
|
min-width="120"
|
||||||
|
:formatter="formatCell"
|
||||||
|
/>
|
||||||
|
<el-table-column label="操作" width="180" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button type="primary" link @click="handleEdit(scope.row)">编辑</el-button>
|
||||||
|
<el-button type="danger" link @click="handleDelete(scope.row)">删除</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<div class="pagination">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="pagination.pageNum"
|
||||||
|
v-model:page-size="pagination.pageSize"
|
||||||
|
:page-sizes="[10, 20, 50, 100]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
:total="total"
|
||||||
|
background
|
||||||
|
@current-change="handleCurrentChange"
|
||||||
|
@size-change="handleSizeChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<!-- 新增/编辑抽屉 -->
|
||||||
|
<el-drawer
|
||||||
|
v-model="drawerVisible"
|
||||||
|
:title="drawerTitle"
|
||||||
|
direction="rtl"
|
||||||
|
size="600px"
|
||||||
|
:before-close="handleDrawerClose"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="formRef"
|
||||||
|
:model="formData"
|
||||||
|
:rules="formRules"
|
||||||
|
label-width="120px"
|
||||||
|
label-position="left"
|
||||||
|
>
|
||||||
|
<el-form-item label="标准流程序号" prop="flowIndex">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.flowIndex"
|
||||||
|
placeholder="请输入标准流程序号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="标准流程名称" prop="flowName">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.flowName"
|
||||||
|
placeholder="请输入标准流程名称"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="业务编号">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.busyCode"
|
||||||
|
placeholder="请输入业务编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="样品编号">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.goodsCode"
|
||||||
|
placeholder="请输入样品编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="样品名称">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.goodsName"
|
||||||
|
placeholder="请输入样品名称"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="检样编号">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.checkCode"
|
||||||
|
placeholder="请输入检样编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="项目名称">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.programName"
|
||||||
|
placeholder="请输入项目名称"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="检测方法">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.testMethod"
|
||||||
|
placeholder="请输入检测方法"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="扫描编号">
|
||||||
|
<el-input
|
||||||
|
v-model="formData.scanNum"
|
||||||
|
placeholder="请输入扫描编号"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<div class="drawer-footer">
|
||||||
|
<el-button @click="handleDrawerClose">取消</el-button>
|
||||||
|
<el-button type="primary" @click="handleSubmit" :loading="submitting">
|
||||||
|
确定
|
||||||
|
</el-button>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</el-drawer>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { ref, reactive, onMounted } from 'vue'
|
||||||
|
import type { FormInstance, FormRules } from 'element-plus'
|
||||||
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||||
|
import { Plus } from '@element-plus/icons-vue'
|
||||||
|
import {
|
||||||
|
flowInfoadd,
|
||||||
|
flowInfodel,
|
||||||
|
flowInfoupd,
|
||||||
|
flowInfolist,
|
||||||
|
flowInfobyid,
|
||||||
|
} from '@/api/tb/flowinfo'
|
||||||
|
|
||||||
|
interface FlowInfoItem {
|
||||||
|
id?: number | string
|
||||||
|
flowIndex?: number | string
|
||||||
|
flowName?: string
|
||||||
|
busyCode?: string
|
||||||
|
goodsCode?: string
|
||||||
|
goodsName?: string
|
||||||
|
checkCode?: string
|
||||||
|
programName?: string
|
||||||
|
testMethod?: string
|
||||||
|
scanNum?: string
|
||||||
|
islandIdList?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
const loading = ref(false)
|
||||||
|
const submitting = ref(false)
|
||||||
|
const tableData = ref<FlowInfoItem[]>([])
|
||||||
|
const total = ref(0)
|
||||||
|
|
||||||
|
// 查询表单
|
||||||
|
const queryForm = reactive({
|
||||||
|
flowName: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
const pagination = reactive({
|
||||||
|
pageNum: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
})
|
||||||
|
|
||||||
|
// 抽屉相关
|
||||||
|
const drawerVisible = ref(false)
|
||||||
|
const drawerTitle = ref('新增流程')
|
||||||
|
const isEdit = ref(false)
|
||||||
|
const formRef = ref<FormInstance>()
|
||||||
|
|
||||||
|
// 表单数据
|
||||||
|
const formData = reactive<FlowInfoItem>({
|
||||||
|
id: undefined,
|
||||||
|
flowIndex: '',
|
||||||
|
flowName: '',
|
||||||
|
busyCode: '',
|
||||||
|
goodsCode: '',
|
||||||
|
goodsName: '',
|
||||||
|
checkCode: '',
|
||||||
|
programName: '',
|
||||||
|
testMethod: '',
|
||||||
|
scanNum: '',
|
||||||
|
})
|
||||||
|
|
||||||
|
// 表单验证规则
|
||||||
|
const formRules: FormRules = {
|
||||||
|
flowIndex: [
|
||||||
|
{ required: true, message: '请输入标准流程序号', trigger: 'blur' },
|
||||||
|
{
|
||||||
|
validator: (_rule, value, callback) => {
|
||||||
|
// required 规则已经处理了空值,这里只处理非空值
|
||||||
|
const strValue = String(value).trim()
|
||||||
|
// 检查是否为数字(包括整数和小数)
|
||||||
|
if (!/^\d+(\.\d+)?$/.test(strValue)) {
|
||||||
|
callback(new Error('标准流程序号必须为数字'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
// 检查是否为非负数字
|
||||||
|
const numValue = Number(strValue)
|
||||||
|
if (numValue < 0) {
|
||||||
|
callback(new Error('标准流程序号必须为非负数'))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
callback()
|
||||||
|
},
|
||||||
|
trigger: 'blur',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
flowName: [
|
||||||
|
{ required: true, message: '请输入标准流程名称', trigger: 'blur' },
|
||||||
|
],
|
||||||
|
}
|
||||||
|
|
||||||
|
// 格式化单元格
|
||||||
|
const formatCell = (_row: any, _column: any, value: any) => {
|
||||||
|
if (value === 0) return 0
|
||||||
|
return value === undefined || value === null || value === '' ? '暂无' : value
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取流程信息列表
|
||||||
|
const getFlowInfoList = async () => {
|
||||||
|
try {
|
||||||
|
loading.value = true
|
||||||
|
const params: any = {
|
||||||
|
pageNum: pagination.pageNum,
|
||||||
|
pageSize: pagination.pageSize,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加查询条件(过滤空值)
|
||||||
|
if (queryForm.flowName && queryForm.flowName.trim()) {
|
||||||
|
params.flowName = queryForm.flowName.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
const res: any = await flowInfolist(params)
|
||||||
|
|
||||||
|
const data = res?.data ?? res ?? {}
|
||||||
|
|
||||||
|
// 兼容多种返回格式
|
||||||
|
const recordsFromData =
|
||||||
|
data.records ||
|
||||||
|
data.list ||
|
||||||
|
data.rows ||
|
||||||
|
data.items ||
|
||||||
|
(Array.isArray(data.data) ? data.data : undefined)
|
||||||
|
|
||||||
|
const records = Array.isArray(recordsFromData)
|
||||||
|
? recordsFromData
|
||||||
|
: Array.isArray(data)
|
||||||
|
? data
|
||||||
|
: []
|
||||||
|
|
||||||
|
const totalValue =
|
||||||
|
data.total ?? data.count ?? data.totalCount ?? records.length ?? 0
|
||||||
|
|
||||||
|
tableData.value = records
|
||||||
|
total.value = Number(totalValue) || 0
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取流程信息列表失败:', error)
|
||||||
|
ElMessage.error('获取流程信息列表失败')
|
||||||
|
tableData.value = []
|
||||||
|
total.value = 0
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询
|
||||||
|
const handleSearch = () => {
|
||||||
|
pagination.pageNum = 1
|
||||||
|
getFlowInfoList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置查询
|
||||||
|
const resetSearch = () => {
|
||||||
|
queryForm.flowName = ''
|
||||||
|
handleSearch()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页大小改变
|
||||||
|
const handleSizeChange = (size: number) => {
|
||||||
|
pagination.pageSize = size
|
||||||
|
getFlowInfoList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 当前页改变
|
||||||
|
const handleCurrentChange = (page: number) => {
|
||||||
|
pagination.pageNum = page
|
||||||
|
getFlowInfoList()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 重置表单
|
||||||
|
const resetForm = () => {
|
||||||
|
formData.id = undefined
|
||||||
|
formData.flowIndex = ''
|
||||||
|
formData.flowName = ''
|
||||||
|
formData.busyCode = ''
|
||||||
|
formData.goodsCode = ''
|
||||||
|
formData.goodsName = ''
|
||||||
|
formData.checkCode = ''
|
||||||
|
formData.programName = ''
|
||||||
|
formData.testMethod = ''
|
||||||
|
formData.scanNum = ''
|
||||||
|
formRef.value?.clearValidate()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 打开新增抽屉
|
||||||
|
const handleAdd = () => {
|
||||||
|
isEdit.value = false
|
||||||
|
drawerTitle.value = '新增流程'
|
||||||
|
resetForm()
|
||||||
|
drawerVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 编辑流程信息
|
||||||
|
const handleEdit = async (row: FlowInfoItem) => {
|
||||||
|
try {
|
||||||
|
if (!row.id) {
|
||||||
|
ElMessage.warning('缺少流程信息ID')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
const res: any = await flowInfobyid(row.id)
|
||||||
|
|
||||||
|
if (res.code === '0' || res.code === 0) {
|
||||||
|
const data = res.data || res || row
|
||||||
|
formData.id = data.id ?? row.id
|
||||||
|
const flowIndexValue = data.flowIndex ?? row.flowIndex
|
||||||
|
formData.flowIndex = flowIndexValue !== undefined && flowIndexValue !== null ? String(flowIndexValue) : ''
|
||||||
|
formData.flowName = data.flowName ?? row.flowName ?? ''
|
||||||
|
formData.busyCode = data.busyCode ?? row.busyCode ?? ''
|
||||||
|
formData.goodsCode = data.goodsCode ?? row.goodsCode ?? ''
|
||||||
|
formData.goodsName = data.goodsName ?? row.goodsName ?? ''
|
||||||
|
formData.checkCode = data.checkCode ?? row.checkCode ?? ''
|
||||||
|
formData.programName = data.programName ?? row.programName ?? ''
|
||||||
|
formData.testMethod = data.testMethod ?? row.testMethod ?? ''
|
||||||
|
formData.scanNum = data.scanNum ?? row.scanNum ?? ''
|
||||||
|
|
||||||
|
isEdit.value = true
|
||||||
|
drawerTitle.value = '编辑流程'
|
||||||
|
drawerVisible.value = true
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message || res.msg || '获取流程信息失败')
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error('获取流程信息失败:', error)
|
||||||
|
ElMessage.error('获取流程信息失败')
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除流程信息
|
||||||
|
const handleDelete = async (row: FlowInfoItem) => {
|
||||||
|
if (!row.id) {
|
||||||
|
ElMessage.warning('缺少流程信息ID')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await ElMessageBox.confirm(
|
||||||
|
`确定要删除流程信息"${row.flowName || '未命名'}"吗?`,
|
||||||
|
'提示',
|
||||||
|
{
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning',
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
loading.value = true
|
||||||
|
const res: any = await flowInfodel(row.id)
|
||||||
|
|
||||||
|
if (res.code === '0' || res.code === 0) {
|
||||||
|
ElMessage.success('删除成功')
|
||||||
|
getFlowInfoList()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message || res.msg || '删除失败')
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error !== 'cancel') {
|
||||||
|
console.error('删除流程信息失败:', error)
|
||||||
|
ElMessage.error('删除流程信息失败')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 提交表单
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!formRef.value) return
|
||||||
|
|
||||||
|
try {
|
||||||
|
await formRef.value.validate()
|
||||||
|
submitting.value = true
|
||||||
|
|
||||||
|
// 将 flowIndex 字符串转换为数字
|
||||||
|
const flowIndexNum = formData.flowIndex !== '' && formData.flowIndex !== undefined && formData.flowIndex !== null
|
||||||
|
? Number(String(formData.flowIndex).trim())
|
||||||
|
: undefined
|
||||||
|
|
||||||
|
const submitData: any = {
|
||||||
|
flowIndex: flowIndexNum,
|
||||||
|
flowName: formData.flowName,
|
||||||
|
busyCode: formData.busyCode || undefined,
|
||||||
|
goodsCode: formData.goodsCode || undefined,
|
||||||
|
goodsName: formData.goodsName || undefined,
|
||||||
|
checkCode: formData.checkCode || undefined,
|
||||||
|
programName: formData.programName || undefined,
|
||||||
|
testMethod: formData.testMethod || undefined,
|
||||||
|
scanNum: formData.scanNum || undefined,
|
||||||
|
}
|
||||||
|
|
||||||
|
// 移除空字符串字段
|
||||||
|
Object.keys(submitData).forEach((key) => {
|
||||||
|
if (submitData[key] === '' || submitData[key] === null) {
|
||||||
|
delete submitData[key]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
let res: any
|
||||||
|
if (isEdit.value && formData.id) {
|
||||||
|
// 编辑 - 需传入流程信息ID,其他字段可选(非空则更新)
|
||||||
|
res = await flowInfoupd({
|
||||||
|
id: formData.id,
|
||||||
|
...submitData,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
// 新增
|
||||||
|
res = await flowInfoadd(submitData)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (res.code === '0' || res.code === 0) {
|
||||||
|
ElMessage.success(isEdit.value ? '编辑成功' : '新增成功')
|
||||||
|
drawerVisible.value = false
|
||||||
|
getFlowInfoList()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res.message || res.msg || (isEdit.value ? '编辑失败' : '新增失败'))
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
if (error !== false) {
|
||||||
|
console.error('提交失败:', error)
|
||||||
|
ElMessage.error('提交失败,请检查表单')
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
submitting.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 关闭抽屉
|
||||||
|
const handleDrawerClose = () => {
|
||||||
|
drawerVisible.value = false
|
||||||
|
resetForm()
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化
|
||||||
|
onMounted(() => {
|
||||||
|
getFlowInfoList()
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="scss" scoped>
|
||||||
|
.flowinfo-page {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-card {
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-bar {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.toolbar {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pagination {
|
||||||
|
margin-top: 16px;
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
}
|
||||||
|
|
||||||
|
.drawer-footer {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -696,21 +696,35 @@ const handleBindDevice = async () => {
|
|||||||
|
|
||||||
if (Array.isArray(allDevices)) {
|
if (Array.isArray(allDevices)) {
|
||||||
if (isEdit.value && formData.id) {
|
if (isEdit.value && formData.id) {
|
||||||
// 编辑模式:显示未绑定的设备 + 已绑定该功能岛的设备
|
// 编辑模式:显示未绑定的设备 + 已绑定该功能岛的设备,排除设备型号为PLC的设备
|
||||||
deviceListForBind.value = allDevices.filter((device: any) =>
|
deviceListForBind.value = allDevices.filter((device: any) => {
|
||||||
!device.islandId ||
|
// 排除设备型号为PLC的设备
|
||||||
device.islandId === formData.id ||
|
if (device.devModel && String(device.devModel).toUpperCase() === 'PLC') {
|
||||||
device.islandId === String(formData.id) ||
|
return false
|
||||||
device.islandId === 0 ||
|
}
|
||||||
device.islandId === '0'
|
// 筛选条件:islandId为0或空的设备,或者已绑定该功能岛的设备
|
||||||
)
|
return (
|
||||||
|
!device.islandId ||
|
||||||
|
device.islandId === formData.id ||
|
||||||
|
device.islandId === String(formData.id) ||
|
||||||
|
device.islandId === 0 ||
|
||||||
|
device.islandId === '0'
|
||||||
|
)
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
// 新增模式:只显示未绑定的设备
|
// 新增模式:只显示未绑定的设备,排除设备型号为PLC的设备
|
||||||
deviceListForBind.value = allDevices.filter((device: any) =>
|
deviceListForBind.value = allDevices.filter((device: any) => {
|
||||||
!device.islandId ||
|
// 排除设备型号为PLC的设备
|
||||||
device.islandId === 0 ||
|
if (device.devModel && String(device.devModel).toUpperCase() === 'PLC') {
|
||||||
device.islandId === '0'
|
return false
|
||||||
)
|
}
|
||||||
|
// 筛选条件:islandId为0或空的设备
|
||||||
|
return (
|
||||||
|
!device.islandId ||
|
||||||
|
device.islandId === 0 ||
|
||||||
|
device.islandId === '0'
|
||||||
|
)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
deviceListForBind.value = []
|
deviceListForBind.value = []
|
||||||
|
|||||||
1188
rc_autoplc_front/src/views/stepinfo/index.vue
Normal file
1188
rc_autoplc_front/src/views/stepinfo/index.vue
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,5 +1,4 @@
|
|||||||
{
|
{
|
||||||
|
|
||||||
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
"exclude": ["src/**/__tests__/*"],
|
"exclude": ["src/**/__tests__/*"],
|
||||||
|
|||||||
Reference in New Issue
Block a user