2019-07-26 13:32:43 +08:00
|
|
|
<template>
|
|
|
|
<div>
|
2019-08-08 10:31:46 +08:00
|
|
|
<el-form :model="modalData" ref="modalData" :rules="rules" label-width="80px" class="actionInfo" label-position="right" style="margin-top:15px">
|
|
|
|
<el-form-item label="动作类型" class="conditionVO" prop="action.type">
|
|
|
|
<el-select v-model="modalData.action.type " placeholder="请选择动作类型" @change="changeType" class="inputStyle">
|
2019-07-26 13:32:43 +08:00
|
|
|
<el-option v-for="actionType in actionTypeList" :key="actionType.label" :label="actionType.label" :value="actionType.value"></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="完成时间" class="conditionVO">
|
2019-08-08 10:31:46 +08:00
|
|
|
<el-input-number v-model="modalData.action.time " class="inputStyle" :min="0"></el-input-number>
|
2019-07-26 13:32:43 +08:00
|
|
|
</el-form-item>
|
2019-08-08 10:31:46 +08:00
|
|
|
<el-form-item label="回复消息" class="conditionVO" prop="action.reply" v-if="isConversitionAdd">
|
|
|
|
<el-input v-model="modalData.action.reply" type="textarea" class="textareaStyle" rows="3"></el-input>
|
2019-07-26 13:32:43 +08:00
|
|
|
</el-form-item>
|
2019-08-08 10:31:46 +08:00
|
|
|
<el-form-item label="设备指令" class="conditionVO" prop="action.deviceCommand" v-if="isCommandAdd">
|
|
|
|
<el-select v-model="modalData.action.deviceCommand " placeholder="请选择设备指令" @change="changeCommand" class="inputStyle">
|
|
|
|
<el-option v-for="deviceCommand in deviceCommandList" :key="deviceCommand.deviceCommand" :label="deviceCommand.label" :value="deviceCommand.deviceCommand"></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="起始站台" class="conditionVO" v-if="isJinLu" prop="param.startStation">
|
|
|
|
<el-select v-model="modalData.param.startStation " placeholder="请选择起始站台" class="inputStyle">
|
|
|
|
<el-option v-for="station in stationList" :key="station.code" :label="station.name" :value="station.code"></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<el-form-item label="终点站台" class="conditionVO" v-if="isJinLu" prop="param.endStation">
|
|
|
|
<el-select v-model="modalData.param.endStation " placeholder="请选择终点站台" class="inputStyle">
|
|
|
|
<el-option v-for="station in stationList" :key="station.code" :label="station.name" :value="station.code"></el-option>
|
|
|
|
</el-select>
|
|
|
|
</el-form-item>
|
|
|
|
<!-- <command-Form :commandParam="form" :commandParamModal="formModel" :rules="commandRules"></command-Form> -->
|
|
|
|
<!-- <div id="commandParam"></div> -->
|
2019-07-26 13:32:43 +08:00
|
|
|
<el-form-item>
|
2019-08-08 10:31:46 +08:00
|
|
|
<el-button type="primary" @click="addQuestAction('modalData')">{{buttonName}}</el-button>
|
2019-07-26 13:32:43 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
import Vue from 'vue';
|
2019-08-08 10:31:46 +08:00
|
|
|
import DeviceTypeDic from '@/scripts/DeviceTypeDic';
|
|
|
|
// import CommandForm from "./commandForm";
|
|
|
|
import {postMemberBehaviorAction,getAvailableDeviceCommand,getDeviceCodeByDeviceType} from '@/api/simulation';
|
2019-07-26 13:32:43 +08:00
|
|
|
export default {
|
|
|
|
name: 'addAction',
|
|
|
|
props: {
|
|
|
|
group: {
|
|
|
|
type: String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
memberId:{
|
|
|
|
type:String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
behaviorId:{
|
|
|
|
type:String,
|
|
|
|
required: true
|
2019-08-08 10:31:46 +08:00
|
|
|
},
|
|
|
|
buttonName:{
|
|
|
|
type:String,
|
|
|
|
required: true
|
|
|
|
},
|
|
|
|
operateType:{
|
|
|
|
type:String,
|
|
|
|
required: true
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
},
|
2019-08-08 10:31:46 +08:00
|
|
|
// components:{
|
|
|
|
// CommandForm,
|
|
|
|
// },
|
2019-07-26 13:32:43 +08:00
|
|
|
data() {
|
|
|
|
return {
|
2019-08-08 10:31:46 +08:00
|
|
|
modalData:{
|
|
|
|
action:{
|
|
|
|
reply:"",
|
|
|
|
time:0,
|
|
|
|
type:"Conversation",
|
|
|
|
deviceCommand:null,
|
|
|
|
commandParamList:[]
|
|
|
|
},
|
|
|
|
param:{
|
|
|
|
startStation:"",
|
|
|
|
endStation:"",
|
|
|
|
},
|
2019-07-26 13:32:43 +08:00
|
|
|
},
|
2019-08-08 10:31:46 +08:00
|
|
|
actionTypeList:DeviceTypeDic.ConstSelect.actionType,
|
|
|
|
isConversitionAdd:true,
|
|
|
|
isCommandAdd:false,
|
|
|
|
deviceCommandList:[],
|
|
|
|
stationList:[],
|
2019-07-26 13:32:43 +08:00
|
|
|
rules:{
|
2019-08-08 10:31:46 +08:00
|
|
|
action:{
|
|
|
|
reply: [
|
2019-07-26 13:32:43 +08:00
|
|
|
{ required: true, message: '请输入回复消息', trigger: 'blur' }
|
2019-08-08 10:31:46 +08:00
|
|
|
],
|
|
|
|
type:[
|
|
|
|
{ required: true, message: '请选择角色类型', trigger: 'change' }
|
|
|
|
],
|
|
|
|
deviceCommand:[
|
|
|
|
{ required: true, message: '请选择设备指令', trigger: 'change' }
|
|
|
|
]
|
|
|
|
},
|
|
|
|
param:{
|
|
|
|
startStation:[
|
|
|
|
{ required: true, message: '请选择起始站台', trigger: 'change' }
|
|
|
|
],
|
|
|
|
endStation:[
|
|
|
|
{ required: true, message: '请选择终点站台', trigger: 'change' }
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
commandRules:{},
|
|
|
|
formModel:{},
|
|
|
|
form:{},
|
|
|
|
isJinLu:false,
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
},
|
2019-08-08 10:31:46 +08:00
|
|
|
mounted(){
|
|
|
|
this.initData();
|
|
|
|
},
|
2019-07-26 13:32:43 +08:00
|
|
|
methods:{
|
|
|
|
addQuestAction(formName){
|
|
|
|
this.$refs[formName].validate((valid) => {
|
|
|
|
if (valid) {
|
|
|
|
let group=this.$props.group;
|
|
|
|
let memberId=this.$props.memberId;
|
|
|
|
let behaviorId=this.$props.behaviorId;
|
2019-08-08 10:31:46 +08:00
|
|
|
if(this.modalData.action.deviceCommand==null){
|
|
|
|
delete this.modalData.action.deviceCommand;
|
|
|
|
}
|
|
|
|
if(this.modalData.action.deviceCommand=="Train_Manual_Route_Blocking_Drive")
|
|
|
|
{this.modalData.action.commandParamList=[this.modalData.param.startStation,this.modalData.param.endStation];}
|
|
|
|
let data=this.modalData.action;
|
|
|
|
let obj=this;
|
2019-07-26 13:32:43 +08:00
|
|
|
postMemberBehaviorAction(group,memberId,behaviorId,data).then(response=>{
|
2019-08-08 10:31:46 +08:00
|
|
|
delete this.modalData.action.id;
|
|
|
|
obj.modalData.action.type="Conversation";
|
|
|
|
obj.modalData.action.time=0;
|
|
|
|
obj.modalData.action.reply="";
|
|
|
|
obj.modalData.param.startStation="";
|
|
|
|
obj.isConversitionAdd=true;
|
|
|
|
obj.isCommandAdd=false;
|
|
|
|
obj.isJinLu=false;
|
|
|
|
obj.modalData.action.deviceCommand=null;
|
|
|
|
this.modalData.param.endStation="";
|
|
|
|
if(this.$props.operateType=="add")
|
|
|
|
{
|
|
|
|
this.$message.success('添加动作成功');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.$emit('modifyButtonName');
|
|
|
|
this.$message.success('修改动作成功');
|
|
|
|
}
|
|
|
|
this.$emit('create');
|
2019-07-26 13:32:43 +08:00
|
|
|
}).catch(error => {
|
2019-08-08 10:31:46 +08:00
|
|
|
if(this.$props.operateType=="add")
|
|
|
|
{
|
|
|
|
this.$messageBox(`添加动作失败: ${error.message}`);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.$messageBox(`修改动作失败: ${error.message}`);
|
|
|
|
}
|
|
|
|
});
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
console.log('error submit!!');
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2019-08-08 10:31:46 +08:00
|
|
|
initData(){
|
|
|
|
getAvailableDeviceCommand().then(response=>{
|
|
|
|
this.deviceCommandList=response.data;
|
|
|
|
});
|
|
|
|
let params = {deviceType:"StationStand"};
|
|
|
|
let group=this.$props.group;
|
|
|
|
getDeviceCodeByDeviceType(group,params).then(response =>{
|
|
|
|
let resultData=response.data;
|
|
|
|
resultData=JSON.parse(JSON.stringify(response.data).replace(/groupNumber/g,"name"));
|
|
|
|
this.stationList=resultData;
|
|
|
|
})
|
|
|
|
},
|
|
|
|
changeCommand(index){
|
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case "Train_Manual_Route_Blocking_Drive":{
|
|
|
|
this.isJinLu=true;
|
|
|
|
this.initData();
|
|
|
|
// this.form={
|
|
|
|
// labelWidth:'100px',
|
|
|
|
// items: [
|
|
|
|
// { prop: 'startStation', label: '起始车站', type: 'select', required: false, change: true },
|
|
|
|
// ]
|
|
|
|
// };
|
|
|
|
// this.formModel={
|
|
|
|
// startStation:"",
|
|
|
|
// };
|
|
|
|
// const cfConstructor = Vue.component(CommandForm);
|
|
|
|
// const instance = new cfConstructor({}).$mount('#commandParam');
|
|
|
|
// instance.$mount('#commandParam');
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
this.isJinLu=false;
|
|
|
|
this.initData();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
changeType(index){
|
|
|
|
switch(index)
|
|
|
|
{
|
|
|
|
case "Conversation":{
|
|
|
|
this.isConversitionAdd=true;
|
|
|
|
this.isCommandAdd=false;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case "Command":{
|
|
|
|
this.isConversitionAdd=false;
|
|
|
|
this.isCommandAdd=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
doShow(data){
|
|
|
|
if(data)
|
|
|
|
{
|
|
|
|
this.initData();
|
|
|
|
this.modalData.action.id=data.id;
|
|
|
|
this.modalData.action.type=data.type;
|
|
|
|
this.modalData.action.time=data.time;
|
|
|
|
if(data.type=="Conversation")
|
|
|
|
{
|
|
|
|
this.isConversitionAdd=true;
|
|
|
|
this.isCommandAdd=false;
|
|
|
|
this.modalData.action.reply=data.reply;
|
|
|
|
}
|
|
|
|
else if(data.type=="Command")
|
|
|
|
{
|
|
|
|
this.isConversitionAdd=false;
|
|
|
|
this.isCommandAdd=true;
|
|
|
|
this.modalData.action.reply="";
|
|
|
|
this.modalData.action.deviceCommand=data.deviceCommand;
|
|
|
|
if(this.modalData.action.deviceCommand=="Train_Manual_Route_Blocking_Drive")
|
|
|
|
{
|
|
|
|
this.isJinLu=true;
|
|
|
|
this.modalData.param.startStation=data.commandParamList[0];
|
|
|
|
this.modalData.param.endStation=data.commandParamList[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
<style rel="stylesheet/scss" lang="scss" scoped>
|
|
|
|
@import "src/styles/mixin.scss";
|
|
|
|
.addAction{
|
|
|
|
margin-top: 20px;
|
|
|
|
margin-left: 5px;
|
|
|
|
font-size: 15px;
|
|
|
|
}
|
|
|
|
.actionInfo{
|
|
|
|
margin-top: 30px;
|
|
|
|
margin-left: 5px;
|
|
|
|
font-size: 15px;
|
|
|
|
width:98%;
|
|
|
|
}
|
|
|
|
.inputStyle{
|
2019-08-08 10:31:46 +08:00
|
|
|
width:300px;
|
2019-07-26 13:32:43 +08:00
|
|
|
height:30px;
|
|
|
|
}
|
2019-08-08 10:31:46 +08:00
|
|
|
.textareaStyle{
|
|
|
|
width:300px;
|
|
|
|
}
|
2019-07-26 13:32:43 +08:00
|
|
|
</style>
|