适配定时预案界面,添加开机预案菜单

This commit is contained in:
fangxiang 2021-12-17 16:55:13 +08:00
parent 4003b1b715
commit d78f822d64
10 changed files with 280 additions and 7 deletions

View File

@ -534,7 +534,7 @@ export default class ClientConnection {
);
}
public setApplicationConfig(wall_row: number, wall_col: number) {
public setWallRowCol(wall_row: number, wall_col: number) {
this.ws?.send(
JSON.stringify(
new Protocol.SetApplicationConfigRequestEntity(
@ -555,6 +555,14 @@ export default class ClientConnection {
);
}
public setPowerOnPlan(uuid: string) {
this.ws?.send(
JSON.stringify(
new Protocol.SetApplicationConfigRequestEntity(0, "power_on_plan", uuid)
)
);
}
public windowFitGrid(window_id: number) {
this.ws?.send(
JSON.stringify(

View File

@ -99,6 +99,10 @@ export default class Initializer {
"setDeviceScreenHeight",
global_data.applicationConfig.screen_height
);
$store.commit(
"setPowerOnPlan",
global_data.applicationConfig.power_on_plan
);
}
}

View File

@ -57,6 +57,10 @@ export default class RemoteDataExangeProcesser {
"setDeviceScreenHeight",
global_data.applicationConfig.screen_height
);
$store.commit(
"setPowerOnPlan",
global_data.applicationConfig.power_on_plan
);
}
}
}

View File

@ -123,7 +123,7 @@ export default defineComponent({
try {
GlobalData.getInstance()
.getCurrentClient()
?.setApplicationConfig(rows.value, cols.value);
?.setWallRowCol(rows.value, cols.value);
show_dialog.value = false;
} catch {}
loading.value = false;

View File

@ -1,6 +1,6 @@
<template>
<q-dialog persistent v-model="show_dialog" @before-hide="resetData">
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 45vw">
<q-card class="overflow-hidden" style="overflow-y: scroll; max-width: 50vw">
<q-form @submit="onSubmit">
<q-card-section class="q-ma-none q-pa-sm">
<div class="row">
@ -33,7 +33,7 @@
<q-separator />
<q-card-section style="max-height: 50vh; width: 45vw" class="scroll">
<q-card-section style="max-height: 70vh; width: 50vw" class="scroll">
<q-list>
<q-item>
<q-item-label>{{ $t("parent group") }}:</q-item-label>
@ -138,6 +138,7 @@
<q-input
type="number"
v-model="props.row.value"
min="180"
dense
autofocus
>
@ -175,6 +176,57 @@
</q-table>
</q-item-section>
</q-item>
<q-separator />
<q-item>
<q-item-section avatar class="width_5_1">{{
$t("timing cycle") + ":"
}}</q-item-section>
<q-item-section>
<q-select
v-model="timing_cycle"
:loading="loading"
:options="[$t('enable'), $t('disable')]"
/>
</q-item-section>
</q-item>
<q-item v-if="timing_cycle != $t('disable')">
<q-item-section avatar class="width_5_1">{{
$t("time") + ":"
}}</q-item-section>
<q-item-section>
<q-input v-model="time_" :loading="loading" type="time" />
</q-item-section>
</q-item>
<q-item v-if="timing_cycle != $t('disable')">
<q-item-section avatar class="width_5_1">{{
$t("loop") + ":"
}}</q-item-section>
<q-item-section>
<q-checkbox v-model="day1" :label="$t('monday')" />
</q-item-section>
<q-item-section>
<q-checkbox v-model="day2" :label="$t('tuesday')" />
</q-item-section>
<q-item-section>
<q-checkbox v-model="day3" :label="$t('wednesday')" />
</q-item-section>
<q-item-section>
<q-checkbox v-model="day4" :label="$t('thursday')" />
</q-item-section>
</q-item>
<q-item v-if="timing_cycle != $t('disable')">
<q-item-section avatar class="width_5_1" />
<q-item-section>
<q-checkbox v-model="day5" :label="$t('friday')" />
</q-item-section>
<q-item-section>
<q-checkbox v-model="day6" :label="$t('saturday')" />
</q-item-section>
<q-item-section>
<q-checkbox v-model="day7" :label="$t('sunday')" />
</q-item-section>
<q-item-section> </q-item-section>
</q-item>
</q-list>
</q-card-section>
<q-separator />
@ -231,6 +283,10 @@
cursor: wait;
pointer-events: none;
}
.width_5_1 {
width: 18%;
}
</style>
<script lang="ts">
@ -242,6 +298,55 @@ import { useI18n } from "vue-i18n";
import { StringKeyValueEntity } from "src/entities/StringKeyValueEntity";
import { PlanEntity } from "src/entities/PlanEntity";
enum EWeekDays {
EWeekNone = 0x00,
EWeekMonday = 0x01,
EWeekTuesday = 0x02,
EWeekWednesday = 0x04,
EWeekThursday = 0x08,
EWeekFriday = 0x10,
EWeekSaturday = 0x20,
EWeekSunday = 0x40,
EWeekAll = EWeekMonday |
EWeekTuesday |
EWeekWednesday |
EWeekThursday |
EWeekFriday |
EWeekSaturday |
EWeekSunday,
}
const _week_days_map = new Map<string, EWeekDays>([
["EWeekDays.EWeekNone", EWeekDays.EWeekNone],
["EWeekDays.EWeekMonday", EWeekDays.EWeekMonday],
["EWeekDays.EWeekTuesday", EWeekDays.EWeekTuesday],
["EWeekDays.EWeekWednesday", EWeekDays.EWeekWednesday],
["EWeekDays.EWeekThursday", EWeekDays.EWeekThursday],
["EWeekDays.EWeekFriday", EWeekDays.EWeekFriday],
["EWeekDays.EWeekSaturday", EWeekDays.EWeekSaturday],
["EWeekDays.EWeekSunday", EWeekDays.EWeekSunday],
["EWeekDays.EWeekAll", EWeekDays.EWeekAll],
]);
const eWeekDaysToStr = (week_days: EWeekDays) => {
let ret = "EWeekDays.EWeekNone";
_week_days_map.forEach((v, k, m) => {
if (v == week_days) {
ret = k;
}
});
return ret;
};
const getEWeekDays = (str: string) => {
try {
return _week_days_map.get(str);
} catch (e) {
return EWeekDays.EWeekNone;
}
};
export default defineComponent({
name: "ComponentPlanDialog",
@ -280,6 +385,17 @@ export default defineComponent({
let target_dom: any = ref(document.body.children[0]);
let current_index = 0;
let timing_cycle = ref($t.t("disable"));
let time_ = ref("09:00:00");
let week_days = ref(EWeekDays.EWeekAll);
let day1 = ref(true);
let day2 = ref(true);
let day3 = ref(true);
let day4 = ref(true);
let day5 = ref(true);
let day6 = ref(true);
let day7 = ref(true);
const tree_nodes = computed({
get: () => $store.state.plan_tree,
set: (val) => {},
@ -296,10 +412,25 @@ export default defineComponent({
const requestAddPlan = async () => {
let entity = new PlanEntity();
for (let i = 1; i < datas.value.length; i += 2) {
if (parseInt(datas.value[i].value) < 180) {
datas.value[i].value = "180";
}
}
entity.group_uuid = selected.value;
entity.uuid = uuid.value;
entity.name = name.value ?? "";
entity.datas = datas.value;
entity.time_ = time_.value;
entity.timing_cycle = timing_cycle.value == $t.t("enable");
entity.week_days = EWeekDays.EWeekNone;
if (day1.value) entity.week_days |= EWeekDays.EWeekMonday;
if (day2.value) entity.week_days |= EWeekDays.EWeekTuesday;
if (day3.value) entity.week_days |= EWeekDays.EWeekWednesday;
if (day4.value) entity.week_days |= EWeekDays.EWeekThursday;
if (day5.value) entity.week_days |= EWeekDays.EWeekFriday;
if (day6.value) entity.week_days |= EWeekDays.EWeekSaturday;
if (day7.value) entity.week_days |= EWeekDays.EWeekSunday;
let response = await GlobalData.getInstance()
.getCurrentClient()
?.addPlan(entity);
@ -319,10 +450,26 @@ export default defineComponent({
const requestEditPlan = async () => {
let entity = new PlanEntity();
for (let i = 1; i < datas.value.length; i += 2) {
if (parseInt(datas.value[i].value) < 180) {
datas.value[i].value = "180";
}
}
entity.group_uuid = selected.value;
entity.uuid = uuid.value;
entity.name = name.value ?? "";
entity.datas = datas.value;
entity.time_ = time_.value;
entity.timing_cycle = timing_cycle.value == $t.t("enable");
entity.week_days = EWeekDays.EWeekNone;
if (day1.value) entity.week_days |= EWeekDays.EWeekMonday;
if (day2.value) entity.week_days |= EWeekDays.EWeekTuesday;
if (day3.value) entity.week_days |= EWeekDays.EWeekWednesday;
if (day4.value) entity.week_days |= EWeekDays.EWeekThursday;
if (day5.value) entity.week_days |= EWeekDays.EWeekFriday;
if (day6.value) entity.week_days |= EWeekDays.EWeekSaturday;
if (day7.value) entity.week_days |= EWeekDays.EWeekSunday;
let response = await GlobalData.getInstance()
.getCurrentClient()
?.editPlan(entity);
@ -353,21 +500,41 @@ export default defineComponent({
target_dom,
tree_nodes,
modes,
week_days,
time_,
timing_cycle,
day1,
day2,
day3,
day4,
day5,
day6,
day7,
loga(a: any) {
console.log(a);
},
showDialog(options: any) {
if (options) {
type.value = options.type ?? 1;
time_.value = "09:00:00";
timing_cycle.value = $t.t("disable");
week_days.value = EWeekDays.EWeekAll;
if (type.value == 2) {
name.value = options.data?.name ?? null;
console.log(options);
name.value = options.data?.name ?? $t.t("new plan 1");
selected.value = options.data?.item_data?.group_uuid ?? null;
uuid.value = options.data?.item_data?.uuid ?? null;
week_days.value =
options.data?.item_data?.week_days ?? EWeekDays.EWeekAll;
time_.value = options.data?.item_data?.time_ ?? "09:00:00";
timing_cycle.value = options.data?.item_data?.timing_cycle
? $t.t("enable")
: $t.t("disable");
datas.value = JSON.parse(
JSON.stringify(options.data?.item_data?.datas ?? [])
);
} else {
name.value = options.data?.name ?? null;
name.value = options.data?.name ?? $t.t("new plan 1");
selected.value = options.data?.uuid ?? null;
uuid.value = options.data?.uuid ?? null;
datas.value = options.data?.item_data?.datas ?? [];
@ -405,6 +572,28 @@ export default defineComponent({
}
datas.value = temp;
}
for (let i = 1; i < datas.value.length; i += 2) {
if (parseInt(datas.value[i].value) < 180) {
datas.value[i].value = "180";
}
}
day1.value =
(week_days.value & EWeekDays.EWeekMonday) == 0 ? false : true;
day2.value =
(week_days.value & EWeekDays.EWeekTuesday) == 0 ? false : true;
day3.value =
(week_days.value & EWeekDays.EWeekWednesday) == 0 ? false : true;
day4.value =
(week_days.value & EWeekDays.EWeekThursday) == 0 ? false : true;
day5.value =
(week_days.value & EWeekDays.EWeekFriday) == 0 ? false : true;
day6.value =
(week_days.value & EWeekDays.EWeekSaturday) == 0 ? false : true;
day7.value =
(week_days.value & EWeekDays.EWeekSunday) == 0 ? false : true;
show_dialog.value = true;
},
resetData() {
@ -423,7 +612,7 @@ export default defineComponent({
datas.value.push({
key: "param_delay",
value: "3000",
value: "180",
});
},
onContextMenu(

View File

@ -68,6 +68,38 @@
/></q-item-section>
<q-item-section>{{ $t("add group") }}</q-item-section>
</q-item>
<q-item
clickable
v-ripple
v-close-popup
v-if="
prop.node.item_data &&
power_on_plan != prop.node.item_data.uuid
"
@click="(evt) => setPowerOnPlan(evt, prop.node.item_data.uuid)"
>
<q-item-section avatar><q-icon name="timer" /></q-item-section>
<q-item-section>{{ $t("set power on start") }}</q-item-section>
</q-item>
<q-item
clickable
v-ripple
v-close-popup
v-if="
prop.node.item_data &&
power_on_plan == prop.node.item_data.uuid
"
@click="
(evt) => unsetPowerOnPlan(evt, prop.node.item_data.uuid)
"
>
<q-item-section avatar
><q-icon name="timer_off"
/></q-item-section>
<q-item-section>{{
$t("unset power on start")
}}</q-item-section>
</q-item>
<q-item
clickable
v-ripple
@ -141,6 +173,11 @@ export default defineComponent({
set: (val) => {},
});
const power_on_plan = computed({
get: () => $store.state.power_on_plan,
set: (val) => {},
});
const tree: any | null = ref(null);
onMounted(async () => {
@ -153,6 +190,7 @@ export default defineComponent({
return {
tree,
tree_nodes,
power_on_plan,
loga(a: any) {
console.log(a);
},
@ -197,6 +235,14 @@ export default defineComponent({
timeout: 1000,
});
},
unsetPowerOnPlan(evt: PointerEvent, uuid: string) {
evt.stopPropagation();
GlobalData.getInstance().getCurrentClient()?.setPowerOnPlan("");
},
setPowerOnPlan(evt: PointerEvent, uuid: string) {
evt.stopPropagation();
GlobalData.getInstance().getCurrentClient()?.setPowerOnPlan(uuid);
},
};
},
});

View File

@ -18,4 +18,5 @@ export default class ApplicationConfigEntity {
httpserver_port: string = "";
root_fs_upload_path: string = "";
media_upload_dir: string = "";
power_on_plan: string = "";
}

View File

@ -5,6 +5,9 @@ export class PlanEntity extends BaseEntity {
group_uuid: string = "";
name: string = "";
datas: StringKeyValueEntity[] = [];
timing_cycle: boolean = false;
time_: string = "09:00:00";
week_days: number = 0;
public static copy(dest: PlanEntity, src?: PlanEntity) {
if (!src) {

View File

@ -227,4 +227,17 @@ export default {
"use ntp": "使用NTP服务器",
"current datetime": "当前日期时间",
"time zone": "时区",
"new plan 1": "新建预案1",
monday: "星期一",
tuesday: "星期二",
wednesday: "星期三",
thursday: "星期四",
friday: "星期五",
saturday: "星期六",
sunday: "星期七",
"timing cycle": "定时执行",
time: "时间",
loop: "循环",
"unset power on start": "取消开机预案",
"set power on start": "设置为开机预案",
};

View File

@ -39,6 +39,7 @@ export interface StateInterface {
device_screen_height: number;
windows: WindowOpenNotifyEntity[];
device_ip_address: string;
power_on_plan: string;
}
// provide typings for `this.$store`
@ -264,6 +265,7 @@ export default store(function (/* { ssrContext } */) {
device_screen_height: 1080,
windows: [],
device_ip_address: "localhost",
power_on_plan: "",
},
mutations: {
@ -627,6 +629,9 @@ export default store(function (/* { ssrContext } */) {
setDeviceIpAddress(state: StateInterface, playload?: any) {
state.device_ip_address = playload;
},
setPowerOnPlan(state: StateInterface, playload?: any) {
state.power_on_plan = playload;
},
},
// enable strict mode (adds overhead!)