This commit is contained in:
ival 2019-08-09 15:10:28 +08:00
commit be0b7f7a2f
6 changed files with 74 additions and 71 deletions

View File

@ -352,7 +352,7 @@ export const asyncRouter = [
path: '/script',
component: Layout,
meta: {
roles: [admin, user]
roles: [admin, lessonCreater]
},
children: [
{

View File

@ -46,7 +46,7 @@
import Vue from 'vue';
import DeviceTypeDic from '@/scripts/DeviceTypeDic';
import DeviceCondition from './deviceCondition';
import {getMembersByGroup,postMemberBehavior} from '@/api/simulation';
import {getQuestRecord,postMemberBehavior} from '@/api/simulation';
export default {
name: 'addBehavior',
props: {
@ -123,8 +123,8 @@
loadInitData(obj) {
let group=obj.group;
let memberId=this.$props.memberId;
getMembersByGroup(group).then(response=>{
let datalist=response.data;
getQuestRecord(group).then(response=>{
let datalist=response.data.memberVOList;
this.targetMemberList=datalist;
});
},
@ -140,7 +140,7 @@
handleInputConfirm() {
let inputValue = this.inputValue;
if (inputValue) {
this.behavior.conditionVO.importantList.push(inputValue);
this.behavior.conditionVO.importantList.push(inputValue);
}
this.inputVisible = false;
this.inputValue = '';
@ -150,40 +150,49 @@
if (valid) {
let group=this.$props.group;
let memberId=this.$props.memberId;
if(this.behavior.conditionVO.triggerType=="DeviceCondition")
switch(this.behavior.conditionVO.triggerType)
{
if(this.isAdding)
case 'DeviceCondition':
{
this.behavior.conditionVO.deviceConditionList.pop();
this.$refs.deviceCondition.resetDisabled();
if(this.isAdding)
{
this.behavior.conditionVO.deviceConditionList.pop();
this.$refs.deviceCondition.resetDisabled();
}
if(this.behavior.conditionVO.deviceConditionList.length<=0)
{
this.$messageBox(`请添加设备条件`);
return;
}
break;
}
if(this.behavior.conditionVO.deviceConditionList.length<=0)
case 'None':
{
this.$messageBox(`请添加设备条件`);
return;
this.behavior.conditionVO={};
this.behavior.conditionVO.triggerType="None";
break;
}
}
if(this.behavior.conditionVO.triggerType=="None")
{
this.behavior.conditionVO={};
this.behavior.conditionVO.triggerType="None";
}
if(memberId)
{
let behavior=this.behavior;
postMemberBehavior(group,memberId,behavior).then(response=>{
this.behavior.auto=false;
this.behavior.description="";
this.behavior.conditionVO.triggerType="None";
this.behavior.conditionVO.importantList=[];
this.behavior.targetMemberId=null;
this.behavior.conditionVO.content="";
this.behavior.conditionVO.keyWord="";
this.behavior.id=null;
this.behavior={
auto:false,
description:"",
conditionVO:{
triggerType:"None",
importantList:[],
content:"",
keyWord:"",
deviceConditionList:[],
},
targetMemberId:null,
id:null
};
this.isConversationShow=false;
this.isDeviceShow=false;
this.behavior.conditionVO.deviceConditionList=[];
if(this.$props.operateType=="add")
if(this.$props.operateType==="add")
{
this.$message.success('添加行为成功');
}
@ -194,7 +203,7 @@
}
this.$emit('create');
}).catch(error => {
if(this.$props.operateType=="add")
if(this.$props.operateType==="add")
{
this.$messageBox(`添加行为失败: ${error.message}`);
}
@ -236,7 +245,6 @@
case 'DeviceCondition':{
this.isConversationShow=false;
this.isDeviceShow=true;
// this.$refs.deviceCondition.resetDisabled();
var newData=JSON.parse(JSON.stringify(data.conditionVO.deviceConditionList).replace(/\"code\"/g,'"isAdded":true,"code"'));
this.behavior.conditionVO.deviceConditionList=newData;
this.resetDisabled();
@ -249,7 +257,6 @@
}
},
resetDisabled(){
// debugger;
if(this.$refs['deviceCondition'])
{
this.$refs['deviceCondition'].resetDisabled();

View File

@ -1,34 +1,36 @@
<template>
<div>
<div class="actionList">
<i class="el-icon-back" @click="backToMember"></i>
<span class="titleStyle">{{memberName}}角色<span class="titleStyle">/</span><span class="titleStyle">{{behaviorName}}行为</span><span class="titleStyle">/</span><span class="titleStyle">动作信息</span></span>
<div class="tab-pane-big">
<el-scrollbar wrapClass="scrollbar-wrapper" ref="elActionScrollbar">
<div class="actionList">
<i class="el-icon-back" @click="backToMember"></i>
<span class="titleStyle">{{memberName}}角色<span class="titleStyle">/</span><span class="titleStyle">{{behaviorName}}行为</span><span class="titleStyle">/</span><span class="titleStyle">动作信息</span></span>
</div>
<add-action ref="addBehavior" :group="group" :memberId="memberId" :behaviorId="behaviorId" @create="create" :buttonName="buttonName" :operateType="operateType" @modifyButtonName="modifyButtonName"></add-action>
<el-table
v-loading="loading"
:data="actionList" border class="actionListTable">
<el-table-column prop="reply" label="回复消息" width="200">
</el-table-column>
<el-table-column prop="time" label="完成时间" width="200">
</el-table-column>
<el-table-column prop="type" label="动作类型" width="200">
</el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<el-row>
<el-button type="primary" size="mini" @click="modifyAction(scope.row)">修改</el-button>
<el-button type="primary" size="mini" @click="deleteAction(scope.row)">删除</el-button>
</el-row>
</template>
</el-table-column>
</el-table>
</el-scrollbar>
</div>
<add-action ref="addBehavior" :group="group" :memberId="memberId" :behaviorId="behaviorId" @create="create" :buttonName="buttonName" :operateType="operateType" @modifyButtonName="modifyButtonName"></add-action>
<el-table
v-loading="loading"
:data="actionList" border class="actionListTable">
<el-table-column prop="reply" label="回复消息" width="200">
</el-table-column>
<el-table-column prop="time" label="完成时间" width="200">
</el-table-column>
<el-table-column prop="type" label="动作类型" width="200">
</el-table-column>
<el-table-column label="操作" width="200">
<template slot-scope="scope">
<el-row>
<el-button type="primary" size="mini" @click="modifyAction(scope.row)">修改</el-button>
<el-button type="primary" size="mini" @click="deleteAction(scope.row)">删除</el-button>
</el-row>
</template>
</el-table-column>
</el-table>
</div>
</template>
<script>
import Vue from 'vue';
import AddAction from './addAction';
import {getMembersByGroup,deleteMemberBehaviorAction} from '@/api/simulation';
import {getQuestRecord,deleteMemberBehaviorAction} from '@/api/simulation';
export default {
name: 'getAction',
props: {
@ -68,8 +70,8 @@
let group=obj.group;
let memberId=this.$props.memberId;
let behaviorId=this.$props.behaviorId;
getMembersByGroup(group).then(response=>{
let datalist=response.data;
getQuestRecord(group).then(response=>{
let datalist=response.data.memberVOList;
let behaviorList=datalist.find(elem=>{return elem.id==memberId}).behaviorVOList;
this.actionList=behaviorList.find(elem=>{return elem.id==behaviorId}).actionVOList;
this.loading=false;
@ -96,7 +98,8 @@
this.reloadTable();
},
modifyAction(row){
this.$emit('backToTop');
var div = this.$refs['elActionScrollbar'].$refs['wrap'];
div.scrollTop=0;
this.operateType="modify";
this.buttonName="修改动作"
this.$refs.addBehavior.doShow(row);

View File

@ -45,7 +45,7 @@
</template>
<script>
import Vue from 'vue';
import {getMembersByGroup,deleteMemberBehavior} from '@/api/simulation';
import {getQuestRecord,deleteMemberBehavior} from '@/api/simulation';
import AddBehavior from './addBehavior';
export default {
name: 'behaviorList',
@ -80,8 +80,8 @@
loadInitData(obj) {
let group=obj.group;
let memberId=this.$props.memberId;
getMembersByGroup(group).then(response=>{
let datalist=response.data;
getQuestRecord(group).then(response=>{
let datalist=response.data.memberVOList;
this.behaviorList=datalist.find(elem=>{return elem.id==memberId}).behaviorVOList;
this.loading=false;
});

View File

@ -60,6 +60,7 @@
this.$store.dispatch('scriptRecord/updateDeviceCondition', deviceConditionList);
this.$store.dispatch('scriptRecord/updateMemberList', response.data.memberVOList);
this.$store.dispatch('scriptRecord/updateScript', response.data.script);
debugger;
if(response.data.mapLocation)
{
let mapLocation={"offsetX":response.data.mapLocation.x,"offsetY":response.data.mapLocation.y,"scaleRate":response.data.mapLocation.scale};

View File

@ -14,14 +14,10 @@
<role-condition-script :group="group" @getBehaviorList="getBehaviorList"></role-condition-script>
</template>
<template v-if="displayType=='behavior'">
<get-behavior ref="getBehavior" :group="group" :memberId="memberId" @backToMember="backToMember" @getActions="getActions"></get-behavior>
<get-behavior ref="getBehavior" :group="group" :memberId="memberId" @backToMember="backToMember" @getActions="getActions"></get-behavior>
</template>
<template v-if="displayType=='action'">
<div class="tab-pane-big">
<el-scrollbar wrapClass="scrollbar-wrapper" ref="elActionScrollbar">
<get-action ref="getAction" :group="group" :memberId="memberId" :behaviorId="behaviorId" @backToBehavior="backToBehavior" @backToTop="backToActionTop"></get-action>
</el-scrollbar>
</div>
<get-action ref="getAction" :group="group" :memberId="memberId" :behaviorId="behaviorId" @backToBehavior="backToBehavior"></get-action>
</template>
<el-button-group class="button-group">
<el-button type="primary" @click="saveMaplocation">更新定位</el-button>
@ -138,10 +134,6 @@
this.displayType="behavior";
this.memberId=id;
},
backToActionTop(){
var div = this.$refs['elActionScrollbar'].$refs['wrap'];
div.scrollTop=0;
},
saveMaplocation()
{
let data=Vue.prototype.$jlmap.$options;