事件补召,前置调整
This commit is contained in:
@@ -187,21 +187,37 @@
|
||||
|
||||
|
||||
<!-- 绑定进程号 -->
|
||||
<el-dialog draggable title="绑定进程号" v-model="popUps" :close-on-click-modal="false" width="400px">
|
||||
<el-select v-model="processNo" placeholder="请选择进程号" style="width: 100%">
|
||||
<el-option
|
||||
v-for="item in dataSource"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
></el-option>
|
||||
</el-select>
|
||||
<el-dialog draggable title="绑定进程号" v-model="popUps" :close-on-click-modal="false" width="400px">
|
||||
<el-form :model="bindProcessForm" ref="bindProcessFormRef" label-width="80px" :rules="rules2" >
|
||||
<el-form-item label="前置机" prop="nodeId">
|
||||
<el-select v-model="bindProcessForm.nodeId" placeholder="请选择前置机" style="width: 100%" clearable @change="handleNodeChange">
|
||||
<el-option
|
||||
v-for="item in tableStore.table.data"
|
||||
:key="item.id"
|
||||
:label="item.name"
|
||||
:value="item.id"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="进程号" prop="processNo">
|
||||
<el-select v-model="bindProcessForm.processNo" placeholder="请选择进程号" style="width: 100%" clearable>
|
||||
<el-option
|
||||
v-for="item in processOptions"
|
||||
:key="item.name"
|
||||
:label="item.name"
|
||||
:value="item.name"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="popUps = false">取 消</el-button>
|
||||
<el-button type="primary" @click="bindTheProcess">确 定</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
@@ -231,13 +247,21 @@ const height = mainHeight(70)
|
||||
const loading = ref(false)
|
||||
const popUps = ref(false)
|
||||
const tableRef = ref()
|
||||
const processNo = ref('')
|
||||
const ruleFormRef = ref()
|
||||
|
||||
const dataSource: any = ref([])
|
||||
const defaultProps = {
|
||||
children: 'deviceInfoList',
|
||||
label: 'name'
|
||||
}
|
||||
|
||||
const bindProcessFormRef = ref()
|
||||
const bindProcessForm = ref({
|
||||
nodeId: '',
|
||||
processNo: ''
|
||||
})
|
||||
const processOptions = ref<Array<{ name: string; processNo: string }>>([])
|
||||
|
||||
const formData: any = ref({
|
||||
name: '',
|
||||
ip: '',
|
||||
@@ -256,6 +280,11 @@ const rules = reactive({
|
||||
sort: [{ required: true, message: '排序不可为空', trigger: 'blur' }],
|
||||
remark: [{ required: true, message: '描述不可为空', trigger: 'blur' }]
|
||||
})
|
||||
|
||||
const rules2 = reactive({
|
||||
nodeId: [{ required: true, message: '请选择前置机', trigger: 'change' }],
|
||||
processNo: [{ required: true, message: '请选择进程号', trigger: 'change' }]
|
||||
})
|
||||
const dialogFormVisible = ref(false)
|
||||
|
||||
const dialogTitle = ref('新增前置机')
|
||||
@@ -417,21 +446,66 @@ const treeRef = ref()
|
||||
const change = (val: any) => {
|
||||
treeRef.value!.filter(filterText.value)
|
||||
}
|
||||
|
||||
|
||||
// 修改 edit 方法
|
||||
const edit = (data: any) => {
|
||||
processNo.value = data.nodeProcess
|
||||
bindProcessForm.value.processNo = data.nodeProcess
|
||||
bindProcessForm.value.nodeId = nodeId.value // 默认选中当前节点
|
||||
processId.value = data.id
|
||||
popUps.value = true
|
||||
|
||||
// 首次加载当前前置机的进程号选项
|
||||
loadProcessOptionsForNode(nodeId.value)
|
||||
}
|
||||
|
||||
const loadProcessOptionsForNode = (nodeId: string) => {
|
||||
// 请求该前置机下的进程列表
|
||||
nodeDeviceTree({ id: nodeId }).then(res => {
|
||||
if (res.data && res.data.processDeviceList) {
|
||||
// 处理进程列表数据
|
||||
processOptions.value = res.data.processDeviceList.map(item => ({
|
||||
...item,
|
||||
name: item.processNo + '' // 保持与原逻辑一致
|
||||
}))
|
||||
} else {
|
||||
processOptions.value = []
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
// 前置机切换
|
||||
const handleNodeChange = (nodeId: any) => {
|
||||
if (!nodeId) {
|
||||
processOptions.value = []
|
||||
bindProcessForm.value.processNo = ''
|
||||
return
|
||||
}
|
||||
// 清除之前选中的进程号
|
||||
bindProcessForm.value.processNo = ''
|
||||
// 加载新选中前置机的进程号选项
|
||||
loadProcessOptionsForNode(nodeId)
|
||||
}
|
||||
|
||||
|
||||
// 更新进程号
|
||||
const bindTheProcess = () => {
|
||||
updateProcess({
|
||||
id: processId.value,
|
||||
processNo: processNo.value
|
||||
}).then((res: any) => {
|
||||
ElMessage.success('修改成功!')
|
||||
popUps.value = false
|
||||
currentChangeEvent()
|
||||
bindProcessFormRef.value.validate((valid: any) => {
|
||||
if (valid) {
|
||||
updateProcess({
|
||||
id: processId.value,
|
||||
processNo: bindProcessForm.value.processNo,
|
||||
nodeId: bindProcessForm.value.nodeId
|
||||
}).then((res: any) => {
|
||||
ElMessage.success('修改成功!')
|
||||
popUps.value = false
|
||||
currentChangeEvent()
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
const filterNode = (value: string, data: any, node: any) => {
|
||||
if (!value) return true
|
||||
|
||||
Reference in New Issue
Block a user