rt-sim-training-client/src/views/trainingManage/editOperate.vue

155 lines
4.8 KiB
Vue
Raw Normal View History

2022-08-29 11:06:11 +08:00
<template>
<div>
<div class="editContentTab">
<div v-if="dialogVisible" class="editContentTabLable" @click="minisize">
<span class="titleStyle">{{ $t('trainingManage.editTagTitle') }}</span>
</div>
</div>
<el-dialog :title="title" :visible.sync="dialogVisible" width="500" :modal="false" :close-on-click-modal="false" :show-close="false" center style="margin-left: 200px">
<el-row style="font-size: 16px;padding: 5px;">
<el-col :span="4">步骤描述</el-col>
<el-col :span="20">{{ stepDetail.description }}</el-col>
</el-row>
<el-row style="font-size: 16px;padding: 5px;overflow: hidden;word-wrap: break-word;">
<el-col :span="4">操作详情</el-col>
<el-col :span="20">
2022-08-31 17:03:10 +08:00
<!--<div v-for="item in stepDetail.operations" :key="item">
2022-08-29 11:06:11 +08:00
<div>{{ item }}</div>
</div>-->
<template v-for="(item, index) in stepDetail.operations">
<div :key="index">
2022-08-31 17:03:10 +08:00
<el-tag :type="tagIndex === index? 'success':''" closable @close="deleteOperation(index)" @click="changeTagIndex(index)">
2022-08-29 11:06:11 +08:00
{{ covertString(item) }}
</el-tag>
</div>
</template>
</el-col>
</el-row>
<span slot="footer" class="dialog-footer">
<el-button size="small" type="success" @click="backStepList">返回步骤列表</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
export default {
name: 'EditOperate',
data() {
return {
2022-08-30 09:30:27 +08:00
title: '编辑操作',
2022-08-29 11:06:11 +08:00
dialogVisible: false,
dialogWidth: 500,
2022-08-31 10:34:18 +08:00
dataIndex: 0,
2022-08-31 17:03:10 +08:00
tagIndex: 0,
2022-08-29 11:06:11 +08:00
stepDetail: {
id: '',
description: '',
operations: []
}
};
},
watch: {
'$store.state.trainingNew.trainingOperate': function (val) {
if (val && this.dialogVisible) {
const data = {
deviceCode: val.code || '',
userOperationType: val.userOperationType || '',
domId: val.operation || '',
operationType: val.cmdType ? val.cmdType.value : '',
params: val.params || {},
t: 'C'
};
this.stepDetail.operations.push(data);
}
}
},
methods: {
doShow(data) {
if (data) {
2022-08-31 10:34:18 +08:00
this.stepDetail.id = data.data.id;
this.stepDetail.description = data.data.description;
this.stepDetail.operations = data.data.operations || [];
this.dataIndex = data.index;
2022-08-29 11:06:11 +08:00
this.dialogVisible = true;
}
},
minisize() {
this.dialogVisible = true;
},
deleteOperation(index) {
2022-08-31 17:03:10 +08:00
if (this.tagIndex === index) {
this.tagIndex = 0;
}
2022-08-29 11:06:11 +08:00
this.stepDetail.operations.splice(index, 1);
},
2022-08-31 17:03:10 +08:00
changeTagIndex(index) {
this.tagIndex = index;
},
2022-08-29 11:06:11 +08:00
backStepList() {
2022-08-31 17:03:10 +08:00
const tipPosition = {};
if (this.stepDetail.operations[this.tagIndex]) {
tipPosition.domId = this.stepDetail.operations[this.tagIndex].domId;
tipPosition.deviceCode = this.stepDetail.operations[this.tagIndex].deviceCode;
tipPosition.operateIndex = this.tagIndex;
}
this.$emit('backStepList', { index: this.dataIndex, stepDetail: this.stepDetail, tipPosition: tipPosition });
2022-08-30 09:30:27 +08:00
this.dialogVisible = false;
2022-08-29 11:06:11 +08:00
this.stepDetail = {
id: '',
description: '',
operations: []
};
2022-08-31 10:34:18 +08:00
this.dataIndex = 0;
2022-08-31 17:03:10 +08:00
this.tagIndex = 0;
2022-08-29 11:06:11 +08:00
},
covertString(data) {
const userOperationTypeMap = {
rightClick: '右键点击',
leftClick: '左键点击',
chooseValue: '选择',
fillValue: '填写'
};
if (userOperationTypeMap[data.userOperationType]) {
return userOperationTypeMap[data.userOperationType] + data.domId;
} else {
return data.domId;
}
}
}
};
</script>
<style scoped>
/deep/ .el-dialog__wrapper {
width: 1px;
height: 1px;
top: auto;
right: auto;
bottom: auto;
left: auto;
overflow: visible !important;
}
/deep/ .el-dialog--center{
width: 600px;
}
.editContentTab{
position: absolute;
z-index: 10;
right: 12px;
top: calc(45% + 100px);
}
.editContentTabLable{
position: absolute;
background: #fff;
2022-08-31 17:03:10 +08:00
border-radius: 5px 0 0 5px ;
padding: 5px 0;
2022-08-29 11:06:11 +08:00
width: 23px;
text-align: center;
left: 50%;
transform: translateX(-50%);
cursor: pointer;
top:-28px;
}
</style>