|
|
@ -1,4 +1,5 @@
|
|
|
|
<template>
|
|
|
|
<template>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div class="card" style="box-sizing:border-box;height:550px;margin:10px;">
|
|
|
|
<div class="card" style="box-sizing:border-box;height:550px;margin:10px;">
|
|
|
|
<div class="card-header">
|
|
|
|
<div class="card-header">
|
|
|
|
{{device.displayName}}{{this.code}}
|
|
|
|
{{device.displayName}}{{this.code}}
|
|
|
@ -333,15 +334,40 @@
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div v-if="edit" class="card">
|
|
|
|
</div>
|
|
|
|
EDIT
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="edit" class="card" style="box-sizing:border-box;margin:10px;">
|
|
|
|
|
|
|
|
<div class="card-header">遥控器匹配</div>
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 m-2" v-on:click="execApi(device.number,'/Ir/MathAir1')" value="1">空调匹配</button>
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 m-2" v-on:click="execApi(device.number,'/Ir/MathAir2')" value="2">电视匹配</button>
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 m-2" v-on:click="execApi(device.number,'/Ir/MathAir3')" value="3">机顶盒匹配</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div v-if="edit" class="card" style="box-sizing:border-box;margin:10px;">
|
|
|
|
|
|
|
|
<div class="card-header">
|
|
|
|
|
|
|
|
自定义指令
|
|
|
|
|
|
|
|
<div class="float-right">
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2" v-on:click="add()">添加</button>
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2" v-on:click="save($event)">保存</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
|
|
|
<div class="row p-2" v-for="button in getCustomButtons()">
|
|
|
|
|
|
|
|
<input class="form-control col" type="text" name="name" :value="button.name" placeholder="名称" />
|
|
|
|
|
|
|
|
<input class="form-control col" type="text" name="value" :value="button.value" placeholder="按键" />
|
|
|
|
|
|
|
|
<input class="form-control col" type="text" name="order" :value="button.order" placeholder="序号" />
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 mx-2" v-on:click="study(button.value)">学习</button>
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 mx-2" v-on:click="test(button.value)">测试</button>
|
|
|
|
|
|
|
|
<button type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 mx-2" v-on:click="remove(button.name)">移除</button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
</template>
|
|
|
|
<script>
|
|
|
|
<script>
|
|
|
|
({
|
|
|
|
({
|
|
|
|
props: ['device','edit'],
|
|
|
|
props: ['device', 'edit'],
|
|
|
|
mounted: function () {
|
|
|
|
mounted: function () {
|
|
|
|
weui.tab('.weui-tab');
|
|
|
|
weui.tab('.weui-tab');
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -399,6 +425,46 @@
|
|
|
|
return Enumerable.from(JSON.parse(getDeviceDataValue(this.device, "指令")))
|
|
|
|
return Enumerable.from(JSON.parse(getDeviceDataValue(this.device, "指令")))
|
|
|
|
.orderBy(function (o) { return o.order; })
|
|
|
|
.orderBy(function (o) { return o.order; })
|
|
|
|
.toArray();
|
|
|
|
.toArray();
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
add: function () {
|
|
|
|
|
|
|
|
var data = Enumerable.from(this.device.data)
|
|
|
|
|
|
|
|
.where(function (o) { return o.name === "指令"; })
|
|
|
|
|
|
|
|
.firstOrDefault();
|
|
|
|
|
|
|
|
var buttons = this.getCustomButtons();
|
|
|
|
|
|
|
|
var newBtn = { name: "测试", value: "603", order: 100 };
|
|
|
|
|
|
|
|
buttons.push(newBtn);
|
|
|
|
|
|
|
|
data.value = JSON.stringify(buttons);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
remove: function (name) {
|
|
|
|
|
|
|
|
var data = Enumerable.from(this.device.data)
|
|
|
|
|
|
|
|
.where(function (o) { return o.name === "指令"; })
|
|
|
|
|
|
|
|
.firstOrDefault();
|
|
|
|
|
|
|
|
var buttons = this.getCustomButtons();
|
|
|
|
|
|
|
|
for (var i = buttons.length - 1; i >= 0; i--) {
|
|
|
|
|
|
|
|
if (buttons[i].name === name) {
|
|
|
|
|
|
|
|
buttons.splice(i, 1);
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
data.value = JSON.stringify(buttons);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
study: function (code) {
|
|
|
|
|
|
|
|
execApi(this.device.number, '/Ir/Study', 'type=' + 5 + '&code=' + code);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
test: function (code) {
|
|
|
|
|
|
|
|
execApi(this.device.number, '/Ir/Send', 'type=' + 5 + '&code=' + code);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
save: function (e) {
|
|
|
|
|
|
|
|
var buttons = [];
|
|
|
|
|
|
|
|
$(e.target).parents('.card').find('.row').each(function () {
|
|
|
|
|
|
|
|
buttons.push({
|
|
|
|
|
|
|
|
name: $(this).find("input[name='name']").val(),
|
|
|
|
|
|
|
|
value: $(this).find("input[name='value']").val(),
|
|
|
|
|
|
|
|
order: $(this).find("input[name='order']").val()
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
var value = JSON.stringify(buttons);
|
|
|
|
|
|
|
|
execApi(this.device.number, '/Ir/Buttons', 'buttons=' + value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
computed: {
|
|
|
|