提交: 场景控制,定时触发以及手动触发方式添加, 优化问题
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 { getDicts } from "@/api/system/dict/data";
|
||||||
import { getConfigKey } from "@/api/system/config";
|
import { getConfigKey } from "@/api/system/config";
|
||||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree, selectDictDesc } from "@/utils/smartpower";
|
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 Pagination from "@/components/Pagination";
|
||||||
import VueClipboard from 'vue-clipboard2'
|
import VueClipboard from 'vue-clipboard2'
|
||||||
|
|
||||||
|
@ -41,6 +41,7 @@ Vue.prototype.download = download
|
||||||
Vue.prototype.handleTree = handleTree
|
Vue.prototype.handleTree = handleTree
|
||||||
Vue.prototype.copeFu = pluginsCope
|
Vue.prototype.copeFu = pluginsCope
|
||||||
Vue.prototype.selectDictDesc = selectDictDesc
|
Vue.prototype.selectDictDesc = selectDictDesc
|
||||||
|
Vue.prototype.getGuid = getGuid
|
||||||
|
|
||||||
Vue.prototype.msgSuccess = function (msg) {
|
Vue.prototype.msgSuccess = function (msg) {
|
||||||
this.$message({ showClose: true, message: msg, type: "success" });
|
this.$message({ showClose: true, message: msg, type: "success" });
|
||||||
|
|
|
@ -299,3 +299,16 @@ export const timeDiff = ($begin_time, $end_time ) => {
|
||||||
return $res
|
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: {
|
form: {
|
||||||
deviceName: "",
|
deviceName: "",
|
||||||
deviceId: "",
|
deviceId: "",
|
||||||
prodId: "",
|
prodKey: "",
|
||||||
guid: "",
|
guid: "",
|
||||||
cmdKey: "",
|
cmdKey: "",
|
||||||
ctlJson: "",
|
ctlJson: "",
|
||||||
|
@ -200,16 +200,15 @@ export default {
|
||||||
},
|
},
|
||||||
deep: true,
|
deep: true,
|
||||||
},
|
},
|
||||||
// paramsDevcie: {
|
paramsDevcie: {
|
||||||
// handler(val, oldVal) {
|
handler(val, oldVal) {
|
||||||
// this.form = this.paramsDevcie;
|
this.form = this.paramsDevcie;
|
||||||
// },
|
},
|
||||||
// deep: true,
|
deep: true,
|
||||||
// }
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.form = this.paramsDevcie;
|
this.form = this.paramsDevcie;
|
||||||
console.log('form---', this.form)
|
|
||||||
if (this.form.deviceId) {
|
if (this.form.deviceId) {
|
||||||
this.farstInput = false;
|
this.farstInput = false;
|
||||||
if (this.form.ctlJson) {
|
if (this.form.ctlJson) {
|
||||||
|
@ -370,7 +369,7 @@ export default {
|
||||||
if (data.type === "dblclick") {
|
if (data.type === "dblclick") {
|
||||||
this.form.deviceName = data.value.deviceName;
|
this.form.deviceName = data.value.deviceName;
|
||||||
this.form.deviceId = data.value.deviceId;
|
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.form.deviceKey = data.value.deviceKey;
|
||||||
this.selectTableShow = false;
|
this.selectTableShow = false;
|
||||||
this.form.cmdKey = "";
|
this.form.cmdKey = "";
|
||||||
|
@ -381,7 +380,7 @@ export default {
|
||||||
this.selectResult = {};
|
this.selectResult = {};
|
||||||
this.selectResult.deviceId = data.value.deviceId;
|
this.selectResult.deviceId = data.value.deviceId;
|
||||||
this.selectResult.deviceName = data.value.deviceName;
|
this.selectResult.deviceName = data.value.deviceName;
|
||||||
this.selectResult.prodId = data.value.prodKey;
|
this.selectResult.prodKey = data.value.prodKey;
|
||||||
this.selectResult.deviceKey = data.value.deviceKey;
|
this.selectResult.deviceKey = data.value.deviceKey;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -389,7 +388,7 @@ export default {
|
||||||
resuleClick() {
|
resuleClick() {
|
||||||
this.form.deviceName = this.selectResult.deviceName;
|
this.form.deviceName = this.selectResult.deviceName;
|
||||||
this.form.deviceId = this.selectResult.deviceId;
|
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.form.deviceKey = this.selectResult.deviceKey;
|
||||||
this.selectTableShow = false;
|
this.selectTableShow = false;
|
||||||
this.form.cmdKey = "";
|
this.form.cmdKey = "";
|
||||||
|
@ -408,15 +407,6 @@ export default {
|
||||||
this.$forceUpdate();
|
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>
|
</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 { actionType, defaultConfig, notifierType } from "../config"
|
||||||
import { listContacts } from "@/api/iot/contacts";
|
import { listContacts } from "@/api/iot/contacts";
|
||||||
import ESelect from './ESelect'
|
import ESelect from './ESelect'
|
||||||
import ESelectDevice from './ESelectDevice'
|
|
||||||
import EDeviceParam from './EDeviceParam'
|
import EDeviceParam from './EDeviceParam'
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,7 +16,7 @@ export default {
|
||||||
default: '200'
|
default: '200'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { ESelect, ESelectDevice, EDeviceParam },
|
components: { ESelect, EDeviceParam },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
method: 'DEVICE',
|
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: '手动触发',
|
MANUAL: '手动触发',
|
||||||
TIMER: '定时触发',
|
TIMER: '定时触发',
|
||||||
DEVICE: '设备触发',
|
DEVICE: '设备触发',
|
||||||
SCENE: '场景触发',
|
// SCENE: '场景触发',
|
||||||
}
|
|
||||||
|
|
||||||
export const actionType = {
|
|
||||||
NOTIFIER: '消息通知',
|
|
||||||
DEVOUTPUT: '设备输出',
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const defaultConfig = {
|
export const defaultConfig = {
|
||||||
title: '触发器',
|
title: '触发器',
|
||||||
actionTitle: '执行动作'
|
actionTitle: '执行动作'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const notifierType = {
|
|
||||||
SMS: '短信',
|
|
||||||
WEEXIN: '微信'
|
|
||||||
}
|
|
||||||
|
|
|
@ -217,8 +217,8 @@ export default {
|
||||||
} else if (data.type === "click") {
|
} else if (data.type === "click") {
|
||||||
if (data.otherOption.tableType === "device") {
|
if (data.otherOption.tableType === "device") {
|
||||||
this.selectResult = {
|
this.selectResult = {
|
||||||
id: data.value.deviceId,
|
deviceId: data.value.deviceId,
|
||||||
name: data.value.deviceName,
|
deviceName: data.value.deviceName,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
this.selectResult.tableType = data.otherOption.tableType;
|
this.selectResult.tableType = data.otherOption.tableType;
|
||||||
|
@ -236,8 +236,8 @@ export default {
|
||||||
// close 数据
|
// close 数据
|
||||||
close() {
|
close() {
|
||||||
this.form = {
|
this.form = {
|
||||||
id: "",
|
deviceId: "",
|
||||||
name: "",
|
deviceName: "",
|
||||||
netType: 0,
|
netType: 0,
|
||||||
};
|
};
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
|
|
|
@ -165,15 +165,6 @@ export default {
|
||||||
this.triggerMinInput = true;
|
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>
|
</script>
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { triggerMethod, defaultConfig } from "../config"
|
||||||
import selectMethod from './ESelect'
|
import selectMethod from './ESelect'
|
||||||
import ESelectDevice from './ESelectDevice'
|
import ESelectDevice from './ESelectDevice'
|
||||||
import EConditionTemp from './EConditionTemp'
|
import EConditionTemp from './EConditionTemp'
|
||||||
|
import EasyCron from "@/components/EasyCron";
|
||||||
|
import CronValidator from "@/components/EasyCron/validator";
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -16,16 +18,18 @@ export default {
|
||||||
default: '200'
|
default: '200'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: { selectMethod, ESelectDevice, EConditionTemp },
|
components: { selectMethod, ESelectDevice, EConditionTemp, EasyCron },
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
method: 'DEVICE'
|
method: 'DEVICE',
|
||||||
|
exeStartTime: "",
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
if (this.$refs.eCondition && this.dataItem.sceneTriggerDevices[0]['deviceId']) {
|
if (this.$refs.eCondition && this.dataItem.sceneTriggerDevices[0]['deviceId']) {
|
||||||
this.$refs.eCondition.getcomdlist(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: {
|
methods: {
|
||||||
methodChange(v) {
|
methodChange(v) {
|
||||||
|
@ -33,7 +37,7 @@ export default {
|
||||||
// 切换类型 必定制空其他选择项;
|
// 切换类型 必定制空其他选择项;
|
||||||
this.dataItem.sceneTriggerDevices = [];
|
this.dataItem.sceneTriggerDevices = [];
|
||||||
this.dataItem.conditions = [];
|
this.dataItem.conditions = [];
|
||||||
|
this.dataItem.execScript = v === 'TIMER' ? '* * * * * ? *' : '';
|
||||||
this.$forceUpdate();
|
this.$forceUpdate();
|
||||||
this.$emit('change', this.dataItem);
|
this.$emit('change', this.dataItem);
|
||||||
},
|
},
|
||||||
|
@ -89,26 +93,38 @@ export default {
|
||||||
dataItem.method === 'DEVICE' ?
|
dataItem.method === 'DEVICE' ?
|
||||||
<div>
|
<div>
|
||||||
<div class="b-select-device">
|
<div class="b-select-device">
|
||||||
<e-select-device
|
<e-select-device
|
||||||
form={dataItem.sceneTriggerDevices[0] || {}}
|
form={dataItem.sceneTriggerDevices[0] || {}}
|
||||||
onInput={this.handleDeviceChange}
|
onInput={this.handleDeviceChange}
|
||||||
pwidth={inputWidth}/>
|
pwidth={inputWidth}/>
|
||||||
</div>
|
</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 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>
|
</div>
|
||||||
: null
|
: 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>
|
</div>
|
||||||
: null
|
: null
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,8 +120,9 @@
|
||||||
class="eldialog-wrap"
|
class="eldialog-wrap"
|
||||||
width="880px"
|
width="880px"
|
||||||
append-to-body
|
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-row :gutter="10">
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-form-item label="场景名称:" prop="sceneName">
|
<el-form-item label="场景名称:" prop="sceneName">
|
||||||
|
@ -241,15 +242,14 @@
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-form>
|
</el-form>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button type="primary" @click="submitForm">确 定</el-button>
|
<el-button type="primary" size="mini" @click="submitForm">确 定</el-button>
|
||||||
<el-button @click="cancel">取 消</el-button>
|
<el-button @click="cancel" size="mini">取 消</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import { strAndNumber } from "@/utils/validate";
|
|
||||||
import {
|
import {
|
||||||
projectSceneList,
|
projectSceneList,
|
||||||
projectSceneAdd,
|
projectSceneAdd,
|
||||||
|
@ -260,7 +260,7 @@ import {
|
||||||
import DialogTemplate from "@/components/DialogTemplate";
|
import DialogTemplate from "@/components/DialogTemplate";
|
||||||
import ESceneTriggers from "./ESceneTriggers/index";
|
import ESceneTriggers from "./ESceneTriggers/index";
|
||||||
import ETagCard from "@/components/Cards/ETagCard";
|
import ETagCard from "@/components/Cards/ETagCard";
|
||||||
import ESceneAction from "./ESceneTriggers/action";
|
import ESceneAction from "./ESceneAction/index";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "ESceneManage",
|
name: "ESceneManage",
|
||||||
|
@ -372,6 +372,7 @@ export default {
|
||||||
intervalVal: '',
|
intervalVal: '',
|
||||||
intervalUnit: "SECONDS",
|
intervalUnit: "SECONDS",
|
||||||
sceneTriggerDevices: [],
|
sceneTriggerDevices: [],
|
||||||
|
execScript: ''
|
||||||
};
|
};
|
||||||
this.form.triggers.push(obj);
|
this.form.triggers.push(obj);
|
||||||
},
|
},
|
||||||
|
@ -509,16 +510,7 @@ export default {
|
||||||
this.tableLoading = false;
|
this.tableLoading = false;
|
||||||
this.total = res.total;
|
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>
|
</script>
|
||||||
|
|
Loading…
Reference in New Issue