方案数据改为列表点击修改测试项,数据绑定修改设备绑定

This commit is contained in:
zhujiyan
2024-09-26 13:42:14 +08:00
parent 6803a04d07
commit 1c9e53869c
3 changed files with 32 additions and 15 deletions

View File

@@ -23,7 +23,7 @@
</el-form> </el-form>
<!-- 测试项信息&数据绑定页面 --> <!-- 测试项信息&数据绑定页面 -->
<el-tabs type="border-card" v-model="activeName" v-if="popupType != 0 && popupType != 1"> <el-tabs type="border-card" v-model="activeName" v-if="popupType != 0 && popupType != 1">
<el-tab-pane label="测试项信息" :name="0"> <el-tab-pane label="测试项信息" :name="0" v-if="openType == 'tree'">
<el-form <el-form
:model="form1" :model="form1"
ref="ruleFormRef2" ref="ruleFormRef2"
@@ -167,7 +167,7 @@
</el-form-item> </el-form-item>
</el-form> </el-form>
</el-tab-pane> </el-tab-pane>
<el-tab-pane label="数据绑定" :name="2"> <el-tab-pane label="数据绑定" :name="1" v-if="openType == 'table'">
<TreeTransfers :fromData="unBindList" :toData="bindList" @getData="getData" /> <TreeTransfers :fromData="unBindList" :toData="bindList" @getData="getData" />
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@@ -386,9 +386,19 @@ const title: any = ref('')
const popupType: any = ref(null) const popupType: any = ref(null)
//方案/测试项id //方案/测试项id
const planId: any = ref('') const planId: any = ref('')
//打开的类型
const openType = ref('')
const detailsType = (val: any) => {
openType.value = val
if (val == 'tree') {
activeName.value = 0
}
if (val == 'table') {
activeName.value = 1
}
}
//回显方案、测试项操作 //回显方案、测试项操作
const details = (val: any) => { const details = (val: any) => {
console.log(val, '回显方案测试项操作66666')
if (val.records && val.records.length != 0) { if (val.records && val.records.length != 0) {
form.value = { form.value = {
describe: val.describe, describe: val.describe,
@@ -425,7 +435,6 @@ const open = async (val: any, id: any) => {
title.value = val == 0 ? '新增方案' : val == 1 ? '修改方案' : val == 2 ? '新增测试项' : '修改测试项' title.value = val == 0 ? '新增方案' : val == 1 ? '修改方案' : val == 2 ? '新增测试项' : '修改测试项'
dialogVisible.value = true dialogVisible.value = true
planId.value = id planId.value = id
console.log(11111, val, '==============>>>>>>>>')
//新增方案或者测试项数据 //新增方案或者测试项数据
if (val == 0 || val == 2) { if (val == 0 || val == 2) {
initForm() initForm()
@@ -444,7 +453,7 @@ const open = async (val: any, id: any) => {
getDeviceList({ id: id, isTrueFlag: 1 }).then(res => { getDeviceList({ id: id, isTrueFlag: 1 }).then(res => {
bindList.value = res.data bindList.value = res.data
}) })
activeName.value = 0 // activeName.value = 0
} }
} }
//获取选择的绑定的数据 //获取选择的绑定的数据
@@ -558,6 +567,17 @@ const submit = () => {
} }
//修改测试项 //修改测试项
if (popupType.value == 3) { if (popupType.value == 3) {
let subForm = JSON.parse(JSON.stringify(form1.value))
subForm.list = checkedIdList.value
updateRecord(subForm).then((res: any) => {
if (res.code == 'A0000') {
ElMessage.success('修改测试项成功')
initForm()
emit('onSubmit')
close()
}
})
return
ruleFormRef2.value.validate((valid: any) => { ruleFormRef2.value.validate((valid: any) => {
if (valid) { if (valid) {
let subForm = JSON.parse(JSON.stringify(form1.value)) let subForm = JSON.parse(JSON.stringify(form1.value))
@@ -576,7 +596,7 @@ const submit = () => {
}) })
} }
} }
defineExpose({ open, details }) defineExpose({ open, details, detailsType })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
::v-deep .el-form-item__content { ::v-deep .el-form-item__content {

View File

@@ -188,20 +188,20 @@ const add = (node: any, data: any) => {
} }
/** 编辑树节点 */ /** 编辑树节点 */
const edit = async (node: Node, data: any) => { const edit = async (node: Node, data: any) => {
console.log(data, '????????????')
planId.value = data.id planId.value = data.id
await getTestRecordInfo(planId.value) await getTestRecordInfo(planId.value)
.then(res => { .then(res => {
console.log(res, '++++++++++++++++++++195========>')
//修改方案 //修改方案
if (data.children) { if (data.children) {
dialogRef.value.details(res.data) dialogRef.value.details(res.data)
dialogRef.value.detailsType("")
handleOpen(1, planId.value) handleOpen(1, planId.value)
} }
//修改测试项 //修改测试项
else { else {
monitorId.value = data.id monitorId.value = data.id
dialogRef.value.details(res.data.records[0]) dialogRef.value.details(res.data.records[0])
dialogRef.value.detailsType("tree")
handleOpen(3, planId.value) handleOpen(3, planId.value)
} }
}) })

View File

@@ -272,7 +272,6 @@ const nodeClick = async (e: anyObj) => {
const dialogRef = ref() const dialogRef = ref()
const dailogForm = ref() const dailogForm = ref()
const handleOpen = (val: any) => { const handleOpen = (val: any) => {
console.log(deviceData.value, '++++++++')
deviceData.value.records.map((item: any) => { deviceData.value.records.map((item: any) => {
if (item.id == activeName.value) { if (item.id == activeName.value) {
dailogForm.value = item dailogForm.value = item
@@ -281,12 +280,15 @@ const handleOpen = (val: any) => {
dialogRef.value.details(dailogForm.value) dialogRef.value.details(dailogForm.value)
// deviceData.value.records[0].id // deviceData.value.records[0].id
let ids = '' let ids = ''
//数据绑定
if (val == 3) { if (val == 3) {
ids = deviceData.value.records.find((item: any) => { ids = deviceData.value.records.find((item: any) => {
return item.id == activeName.value return item.id == activeName.value
})?.id })?.id
dialogRef.value.detailsType("table")
} else { } else {
ids = '' ids = ''
dialogRef.value.detailsType("")
} }
dialogRef.value.open(val, ids) dialogRef.value.open(val, ids)
} }
@@ -302,7 +304,6 @@ const range = (start: any, end: any, step: any) => {
} }
const init = () => { const init = () => {
//调用子组件的方法切换的时候tree的节点也变化 //调用子组件的方法切换的时候tree的节点也变化
console.log(activeName.value, '000000')
let list: any = [] let list: any = []
loading.value = true loading.value = true
//颜色数组 //颜色数组
@@ -371,7 +372,6 @@ const init = () => {
getHistoryTrend(obj) getHistoryTrend(obj)
.then((res: any) => { .then((res: any) => {
console.log(res, '+++++++++3666')
if (res.code === 'A0000') { if (res.code === 'A0000') {
historyDataList.value = res.data historyDataList.value = res.data
echartsData.value = null echartsData.value = null
@@ -390,9 +390,6 @@ const init = () => {
xAxis = timeList.sort((a: any, b: any) => { xAxis = timeList.sort((a: any, b: any) => {
return new Date(a).getTime() - new Date(b).getTime() return new Date(a).getTime() - new Date(b).getTime()
}) })
// xAxis.map((item:any)=>{
// item=item.replace(" ","\n")
// })
echartsData.value = { echartsData.value = {
options: { options: {
title: [ title: [
@@ -447,7 +444,7 @@ const init = () => {
height: 50 height: 50
}, },
grid: { grid: {
left: '5%', left: historyDataList.value.length != 0 ? '5%' : '1%',
right: '5%', right: '5%',
bottom: '10%', bottom: '10%',
top: '8%', top: '8%',