提交: 场景控制,定时触发以及手动触发方式添加, 优化问题
This commit is contained in:
parent
c91691c16f
commit
df2929ba2e
|
@ -17,7 +17,7 @@ import './permission' // permission control
|
|||
import { getDicts } from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree, selectDictDesc } from "@/utils/smartpower";
|
||||
import { pluginsCope } from "@/utils/hciot";
|
||||
import { pluginsCope, getGuid } from "@/utils/hciot";
|
||||
import Pagination from "@/components/Pagination";
|
||||
import VueClipboard from 'vue-clipboard2'
|
||||
|
||||
|
@ -41,6 +41,7 @@ Vue.prototype.download = download
|
|||
Vue.prototype.handleTree = handleTree
|
||||
Vue.prototype.copeFu = pluginsCope
|
||||
Vue.prototype.selectDictDesc = selectDictDesc
|
||||
Vue.prototype.getGuid = getGuid
|
||||
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
this.$message({ showClose: true, message: msg, type: "success" });
|
||||
|
|
|
@ -299,3 +299,16 @@ export const timeDiff = ($begin_time, $end_time ) => {
|
|||
return $res
|
||||
|
||||
}
|
||||
/**
|
||||
* 获取一个 随机 guid 值;
|
||||
* @returns
|
||||
*/
|
||||
export const getGuid = () => {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
||||
c
|
||||
) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
|
||||
export const actionType = {
|
||||
NOTIFIER: '消息通知',
|
||||
DEVOUTPUT: '设备输出',
|
||||
}
|
||||
|
||||
export const defaultConfig = {
|
||||
title: '触发器',
|
||||
actionTitle: '执行动作'
|
||||
}
|
||||
|
||||
export const notifierType = {
|
||||
SMS: '短信',
|
||||
WEEXIN: '微信'
|
||||
}
|
|
@ -175,7 +175,7 @@ export default {
|
|||
form: {
|
||||
deviceName: "",
|
||||
deviceId: "",
|
||||
prodId: "",
|
||||
prodKey: "",
|
||||
guid: "",
|
||||
cmdKey: "",
|
||||
ctlJson: "",
|
||||
|
@ -200,16 +200,15 @@ export default {
|
|||
},
|
||||
deep: true,
|
||||
},
|
||||
// paramsDevcie: {
|
||||
// handler(val, oldVal) {
|
||||
// this.form = this.paramsDevcie;
|
||||
// },
|
||||
// deep: true,
|
||||
// }
|
||||
paramsDevcie: {
|
||||
handler(val, oldVal) {
|
||||
this.form = this.paramsDevcie;
|
||||
},
|
||||
deep: true,
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.form = this.paramsDevcie;
|
||||
console.log('form---', this.form)
|
||||
if (this.form.deviceId) {
|
||||
this.farstInput = false;
|
||||
if (this.form.ctlJson) {
|
||||
|
@ -370,7 +369,7 @@ export default {
|
|||
if (data.type === "dblclick") {
|
||||
this.form.deviceName = data.value.deviceName;
|
||||
this.form.deviceId = data.value.deviceId;
|
||||
this.form.prodId = data.value.prodKey;
|
||||
this.form.prodKey = data.value.prodKey;
|
||||
this.form.deviceKey = data.value.deviceKey;
|
||||
this.selectTableShow = false;
|
||||
this.form.cmdKey = "";
|
||||
|
@ -381,7 +380,7 @@ export default {
|
|||
this.selectResult = {};
|
||||
this.selectResult.deviceId = data.value.deviceId;
|
||||
this.selectResult.deviceName = data.value.deviceName;
|
||||
this.selectResult.prodId = data.value.prodKey;
|
||||
this.selectResult.prodKey = data.value.prodKey;
|
||||
this.selectResult.deviceKey = data.value.deviceKey;
|
||||
}
|
||||
},
|
||||
|
@ -389,7 +388,7 @@ export default {
|
|||
resuleClick() {
|
||||
this.form.deviceName = this.selectResult.deviceName;
|
||||
this.form.deviceId = this.selectResult.deviceId;
|
||||
this.form.prodId = this.selectResult.prodKey;
|
||||
this.form.prodKey = this.selectResult.prodKey;
|
||||
this.form.deviceKey = this.selectResult.deviceKey;
|
||||
this.selectTableShow = false;
|
||||
this.form.cmdKey = "";
|
||||
|
@ -408,15 +407,6 @@ export default {
|
|||
this.$forceUpdate();
|
||||
});
|
||||
},
|
||||
getGuid() {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
||||
c
|
||||
) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -0,0 +1,37 @@
|
|||
<template>
|
||||
<div>
|
||||
<el-select v-model="value" :width="pwidth" @change="handleChange" placeholder="请选择">
|
||||
<el-option
|
||||
v-for="(value, keys) in optionMethod"
|
||||
:key="keys"
|
||||
:label="value"
|
||||
:value="keys"
|
||||
></el-option>
|
||||
</el-select>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'selectMethod',
|
||||
props: {
|
||||
optionMethod:{
|
||||
type: Object,
|
||||
default: {}
|
||||
},
|
||||
pwidth: {
|
||||
type: String
|
||||
},
|
||||
value: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {}
|
||||
},
|
||||
methods: {
|
||||
handleChange(v) {
|
||||
this.$emit('change', v)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
|
@ -2,7 +2,6 @@ import './style.scss'
|
|||
import { actionType, defaultConfig, notifierType } from "../config"
|
||||
import { listContacts } from "@/api/iot/contacts";
|
||||
import ESelect from './ESelect'
|
||||
import ESelectDevice from './ESelectDevice'
|
||||
import EDeviceParam from './EDeviceParam'
|
||||
|
||||
|
||||
|
@ -17,7 +16,7 @@ export default {
|
|||
default: '200'
|
||||
}
|
||||
},
|
||||
components: { ESelect, ESelectDevice, EDeviceParam },
|
||||
components: { ESelect, EDeviceParam },
|
||||
data() {
|
||||
return {
|
||||
method: 'DEVICE',
|
|
@ -0,0 +1,60 @@
|
|||
.e-scene-trigger {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
font-size: 14px;
|
||||
font-family: 'Source Han Sans CN';
|
||||
font-weight: 400;
|
||||
color: #344567;
|
||||
}
|
||||
.e-scene-trigger.e-trigger-block {
|
||||
min-height: 50px;
|
||||
}
|
||||
|
||||
.e-block-title {
|
||||
height: 35px;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
|
||||
.b-method {
|
||||
margin: 5px 0;
|
||||
}
|
||||
|
||||
.b-select-device {
|
||||
margin: 5px 0;
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.e-scene-action {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
.e-scene-action .action-method {
|
||||
width: 100%;
|
||||
display: flex;
|
||||
justify-content: flex-start;
|
||||
}
|
||||
.e-scene-action .action-contacts-transfer {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.e-scene-action .action-device-param {
|
||||
width: 100%;
|
||||
margin-top: 10px;
|
||||
margin-bottom: 5px;
|
||||
}
|
||||
|
||||
.e-form-item__error {
|
||||
color: #ff4949;
|
||||
font-size: 12px;
|
||||
}
|
||||
.e-button-del {
|
||||
color: #ff4949;
|
||||
font-size: 12px;
|
||||
margin-left: 20px;
|
||||
}
|
|
@ -2,20 +2,10 @@ export const triggerMethod = {
|
|||
MANUAL: '手动触发',
|
||||
TIMER: '定时触发',
|
||||
DEVICE: '设备触发',
|
||||
SCENE: '场景触发',
|
||||
}
|
||||
|
||||
export const actionType = {
|
||||
NOTIFIER: '消息通知',
|
||||
DEVOUTPUT: '设备输出',
|
||||
// SCENE: '场景触发',
|
||||
}
|
||||
|
||||
export const defaultConfig = {
|
||||
title: '触发器',
|
||||
actionTitle: '执行动作'
|
||||
}
|
||||
|
||||
export const notifierType = {
|
||||
SMS: '短信',
|
||||
WEEXIN: '微信'
|
||||
}
|
||||
|
|
|
@ -217,8 +217,8 @@ export default {
|
|||
} else if (data.type === "click") {
|
||||
if (data.otherOption.tableType === "device") {
|
||||
this.selectResult = {
|
||||
id: data.value.deviceId,
|
||||
name: data.value.deviceName,
|
||||
deviceId: data.value.deviceId,
|
||||
deviceName: data.value.deviceName,
|
||||
};
|
||||
}
|
||||
this.selectResult.tableType = data.otherOption.tableType;
|
||||
|
@ -236,8 +236,8 @@ export default {
|
|||
// close 数据
|
||||
close() {
|
||||
this.form = {
|
||||
id: "",
|
||||
name: "",
|
||||
deviceId: "",
|
||||
deviceName: "",
|
||||
netType: 0,
|
||||
};
|
||||
this.$forceUpdate();
|
||||
|
|
|
@ -165,15 +165,6 @@ export default {
|
|||
this.triggerMinInput = true;
|
||||
}
|
||||
},
|
||||
getGuid() {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
||||
c
|
||||
) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -3,6 +3,8 @@ import { triggerMethod, defaultConfig } from "../config"
|
|||
import selectMethod from './ESelect'
|
||||
import ESelectDevice from './ESelectDevice'
|
||||
import EConditionTemp from './EConditionTemp'
|
||||
import EasyCron from "@/components/EasyCron";
|
||||
import CronValidator from "@/components/EasyCron/validator";
|
||||
|
||||
|
||||
export default {
|
||||
|
@ -16,16 +18,18 @@ export default {
|
|||
default: '200'
|
||||
}
|
||||
},
|
||||
components: { selectMethod, ESelectDevice, EConditionTemp },
|
||||
components: { selectMethod, ESelectDevice, EConditionTemp, EasyCron },
|
||||
data() {
|
||||
return {
|
||||
method: 'DEVICE'
|
||||
method: 'DEVICE',
|
||||
exeStartTime: "",
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
if (this.$refs.eCondition && this.dataItem.sceneTriggerDevices[0]['deviceId']) {
|
||||
this.$refs.eCondition.getcomdlist(this.dataItem.sceneTriggerDevices[0]['deviceId']);
|
||||
};
|
||||
this.exeStartTime = this.parseTime(new Date(), "{y}-{m}-{d} {h}:{i}:{s}");
|
||||
},
|
||||
methods: {
|
||||
methodChange(v) {
|
||||
|
@ -33,7 +37,7 @@ export default {
|
|||
// 切换类型 必定制空其他选择项;
|
||||
this.dataItem.sceneTriggerDevices = [];
|
||||
this.dataItem.conditions = [];
|
||||
|
||||
this.dataItem.execScript = v === 'TIMER' ? '* * * * * ? *' : '';
|
||||
this.$forceUpdate();
|
||||
this.$emit('change', this.dataItem);
|
||||
},
|
||||
|
@ -89,26 +93,38 @@ export default {
|
|||
dataItem.method === 'DEVICE' ?
|
||||
<div>
|
||||
<div class="b-select-device">
|
||||
<e-select-device
|
||||
form={dataItem.sceneTriggerDevices[0] || {}}
|
||||
onInput={this.handleDeviceChange}
|
||||
pwidth={inputWidth}/>
|
||||
</div>
|
||||
|
||||
<div class="b-condition">
|
||||
<e-condition-temp
|
||||
ref="eCondition"
|
||||
conditionList={dataItem.conditions}
|
||||
sourceId={ dataItem.sceneTriggerDevices[0] ? dataItem.sceneTriggerDevices[0]['deviceId'] : ''}
|
||||
onChange={this.handleConditionChange}
|
||||
/>
|
||||
<el-button type="text" onClick={this.handleAddCondition}>添加</el-button>
|
||||
</div>
|
||||
<e-select-device
|
||||
form={dataItem.sceneTriggerDevices[0] || {}}
|
||||
onInput={this.handleDeviceChange}
|
||||
pwidth={inputWidth}/>
|
||||
</div>
|
||||
|
||||
<div class="b-condition">
|
||||
<e-condition-temp
|
||||
ref="eCondition"
|
||||
conditionList={dataItem.conditions}
|
||||
sourceId={ dataItem.sceneTriggerDevices[0] ? dataItem.sceneTriggerDevices[0]['deviceId'] : ''}
|
||||
onChange={this.handleConditionChange}
|
||||
/>
|
||||
<el-button type="text" onClick={this.handleAddCondition}>添加</el-button>
|
||||
</div>
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
||||
{
|
||||
dataItem.method === 'TIMER' ?
|
||||
<div>
|
||||
<easy-cron
|
||||
hideSecond={false}
|
||||
disabled={false}
|
||||
style="width: 100%;"
|
||||
v-model={dataItem['execScript']}
|
||||
exeStartTime={this.exeStartTime}
|
||||
></easy-cron>
|
||||
</div> : null
|
||||
}
|
||||
|
||||
</div>
|
||||
: null
|
||||
}
|
||||
|
|
|
@ -120,8 +120,9 @@
|
|||
class="eldialog-wrap"
|
||||
width="880px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
||||
<el-form ref="form" :model="form" style="padding-right: 20px;" :rules="rules" label-width="100px">
|
||||
<el-row :gutter="10">
|
||||
<el-col :span="12">
|
||||
<el-form-item label="场景名称:" prop="sceneName">
|
||||
|
@ -241,15 +242,14 @@
|
|||
</el-row>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
<el-button type="primary" size="mini" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel" size="mini">取 消</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { strAndNumber } from "@/utils/validate";
|
||||
import {
|
||||
projectSceneList,
|
||||
projectSceneAdd,
|
||||
|
@ -260,7 +260,7 @@ import {
|
|||
import DialogTemplate from "@/components/DialogTemplate";
|
||||
import ESceneTriggers from "./ESceneTriggers/index";
|
||||
import ETagCard from "@/components/Cards/ETagCard";
|
||||
import ESceneAction from "./ESceneTriggers/action";
|
||||
import ESceneAction from "./ESceneAction/index";
|
||||
|
||||
export default {
|
||||
name: "ESceneManage",
|
||||
|
@ -372,6 +372,7 @@ export default {
|
|||
intervalVal: '',
|
||||
intervalUnit: "SECONDS",
|
||||
sceneTriggerDevices: [],
|
||||
execScript: ''
|
||||
};
|
||||
this.form.triggers.push(obj);
|
||||
},
|
||||
|
@ -509,16 +510,7 @@ export default {
|
|||
this.tableLoading = false;
|
||||
this.total = res.total;
|
||||
});
|
||||
},
|
||||
getGuid() {
|
||||
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(
|
||||
c
|
||||
) {
|
||||
var r = (Math.random() * 16) | 0,
|
||||
v = c == "x" ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
});
|
||||
},
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue