From fe38c3dfb19d3734bbf53827986d0594b6604cb1 Mon Sep 17 00:00:00 2001 From: joylink_cuiweidong <364937672@qq.com> Date: Fri, 9 Aug 2019 10:33:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/index.js | 2 +- .../display/scriptRecord/addBehavior.vue | 65 ++++++++++--------- src/views/display/scriptRecord/getAction.vue | 59 +++++++++-------- .../display/scriptRecord/getBehavior.vue | 6 +- .../scriptRecord/roleConditionScript.vue | 1 + src/views/display/tipScriptRecord.vue | 12 +--- 6 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/router/index.js b/src/router/index.js index 66d4e2510..ec8e373ce 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -377,7 +377,7 @@ export const asyncRouter = [ path: '/script', component: Layout, meta: { - roles: [admin, user] + roles: [admin, lessonCreater] }, children: [ { diff --git a/src/views/display/scriptRecord/addBehavior.vue b/src/views/display/scriptRecord/addBehavior.vue index 1c9f0888e..32a6811f4 100644 --- a/src/views/display/scriptRecord/addBehavior.vue +++ b/src/views/display/scriptRecord/addBehavior.vue @@ -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(); diff --git a/src/views/display/scriptRecord/getAction.vue b/src/views/display/scriptRecord/getAction.vue index ee6b49c84..320b1b0ed 100644 --- a/src/views/display/scriptRecord/getAction.vue +++ b/src/views/display/scriptRecord/getAction.vue @@ -1,34 +1,36 @@