模式添加索引

This commit is contained in:
fangxiang 2021-09-07 18:03:50 +08:00
parent 1156d2f4c7
commit e6b3d7ce94
5 changed files with 86 additions and 13 deletions

View File

@ -443,20 +443,21 @@ export default class ClientConnection {
} }
} }
public async addMode(group_uuid?: string, name?: string) { public async addMode(group_uuid?: string, name?: string, index?: number) {
try { try {
console.log(index);
return await this.doRpc<Protocol.AddModeResponseEntity>( return await this.doRpc<Protocol.AddModeResponseEntity>(
new Protocol.AddModeRequestEntity(0, name, group_uuid) new Protocol.AddModeRequestEntity(0, name, group_uuid, index)
); );
} catch (e) { } catch (e) {
console.error(e); console.error(e);
} }
} }
public async editMode(uuid?: string, name?: string) { public async editMode(uuid?: string, name?: string, index?: number) {
try { try {
return await this.doRpc<Protocol.EditModeResponseEntity>( return await this.doRpc<Protocol.EditModeResponseEntity>(
new Protocol.EditModeRequestEntity(0, name, uuid) new Protocol.EditModeRequestEntity(0, name, uuid, index)
); );
} catch (e) { } catch (e) {
console.error(e); console.error(e);

View File

@ -110,6 +110,32 @@
</q-input> </q-input>
</q-item-section> </q-item-section>
</q-item> </q-item>
<q-item>
<q-item-section>
<q-input
autofocus
:loading="loading"
:disable="loading"
filled
type="number"
min="0"
max="65535"
v-model.number="index"
:label="$t('mode index')"
:hint="$t('please input mode index')"
lazy-rules
:rules="[checkIndex]"
@keydown="
(evt) => {
if (evt.keyCode == 13) {
$refs?.accept?.click();
}
}
"
>
</q-input>
</q-item-section>
</q-item>
</q-list> </q-list>
</q-card-section> </q-card-section>
@ -151,6 +177,8 @@ import { useStore } from "src/store";
import GlobalData from "src/common/GlobalData"; import GlobalData from "src/common/GlobalData";
import { useQuasar } from "quasar"; import { useQuasar } from "quasar";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
import { api } from "boot/axios";
import { HttpProtocol } from "src/entities/HttpProtocol";
export default defineComponent({ export default defineComponent({
name: "ComponentModeDialog", name: "ComponentModeDialog",
@ -163,6 +191,7 @@ export default defineComponent({
let show_dialog = ref(false); let show_dialog = ref(false);
let type = ref(1); let type = ref(1);
let name = ref(null); let name = ref(null);
let index = ref(0);
let uuid = ref(""); let uuid = ref("");
const selected: any = ref(null); const selected: any = ref(null);
let loading = ref(false); let loading = ref(false);
@ -184,7 +213,7 @@ export default defineComponent({
const requestAddMode = async () => { const requestAddMode = async () => {
let response = await GlobalData.getInstance() let response = await GlobalData.getInstance()
.getCurrentClient() .getCurrentClient()
?.addMode(selected.value, name.value ?? ""); ?.addMode(selected.value, name.value ?? "", index.value);
if (response) { if (response) {
$q.notify({ $q.notify({
color: response.success ? "positive" : "negative", color: response.success ? "positive" : "negative",
@ -202,7 +231,7 @@ export default defineComponent({
const requestEditMode = async () => { const requestEditMode = async () => {
let response = await GlobalData.getInstance() let response = await GlobalData.getInstance()
.getCurrentClient() .getCurrentClient()
?.editMode(uuid.value, name.value ?? ""); ?.editMode(uuid.value, name.value ?? "", index.value);
if (response) { if (response) {
$q.notify({ $q.notify({
color: response.success ? "positive" : "negative", color: response.success ? "positive" : "negative",
@ -221,6 +250,7 @@ export default defineComponent({
show_dialog, show_dialog,
type, type,
name, name,
index,
uuid, uuid,
selected, selected,
loading, loading,
@ -233,6 +263,7 @@ export default defineComponent({
name.value = options.data?.name ?? null; name.value = options.data?.name ?? null;
selected.value = options.data?.item_data?.group_uuid ?? null; selected.value = options.data?.item_data?.group_uuid ?? null;
uuid.value = options.data?.item_data?.uuid ?? null; uuid.value = options.data?.item_data?.uuid ?? null;
index.value = options.data?.item_data?.number ?? 0;
} else { } else {
selected.value = options.data?.uuid ?? null; selected.value = options.data?.uuid ?? null;
uuid.value = options.data?.uuid ?? null; uuid.value = options.data?.uuid ?? null;
@ -248,7 +279,37 @@ export default defineComponent({
treeNodesFilter(node: any, filter: any) { treeNodesFilter(node: any, filter: any) {
return node.is_group; return node.is_group;
}, },
checkIndex(val: number) {
return new Promise(async (resolve, reject) => {
if (val < 0) {
resolve($t.t("Please type 0~65535"));
} else {
try {
let url = GlobalData.getInstance().createCurrentRequestUrl();
if (!url) {
url = new URL(window.location.hostname);
}
url.pathname = HttpProtocol.RequestCheckModeIndex;
url.searchParams.append("index", index.value.toString());
let response = (await api.get(url.toString())).data as boolean;
if (typeof response != "boolean") {
try {
response = JSON.parse(response);
} catch {
response = false;
}
}
if (!response) {
resolve($t.t("index exised!"));
} else {
resolve(true);
}
} catch (e) {
resolve($t.t("check error"));
}
}
});
},
async onSubmit() { async onSubmit() {
loading.value = true; loading.value = true;
try { try {

View File

@ -7,6 +7,7 @@ export namespace HttpProtocol {
export const RequestPathCreateDirectory = "/create_directory"; export const RequestPathCreateDirectory = "/create_directory";
export const RequestPathDeleteFile = "/delete_file"; export const RequestPathDeleteFile = "/delete_file";
export const RequestPathRenameFile = "/rename_file"; export const RequestPathRenameFile = "/rename_file";
export const RequestCheckModeIndex = "/check_mode_index";
export const HttpUploadTypeNormal = "U_T_Normal"; export const HttpUploadTypeNormal = "U_T_Normal";
export const UploadTypeBackgroundImage = "U_T_BACKGROUND_IMAGE"; export const UploadTypeBackgroundImage = "U_T_BACKGROUND_IMAGE";

View File

@ -692,12 +692,19 @@ export namespace Protocol {
export class AddModeRequestEntity extends Protocol.PacketEntity { export class AddModeRequestEntity extends Protocol.PacketEntity {
name: string; name: string;
group_uuid: string; group_uuid: string;
constructor(rcp_id?: number, name?: string, group_uuid?: string) { number: number;
constructor(
rcp_id?: number,
name?: string,
group_uuid?: string,
number?: number
) {
super(); super();
this.rpc_id = rcp_id ?? 0; this.rpc_id = rcp_id ?? 0;
this.command = Protocol.Commands.kRpcAddMode; this.command = Protocol.Commands.kRpcAddMode;
this.name = name ?? ""; this.name = name ?? "";
this.group_uuid = group_uuid ?? ""; this.group_uuid = group_uuid ?? "";
this.number = number ?? 0;
} }
} }
@ -713,12 +720,19 @@ export namespace Protocol {
export class EditModeRequestEntity extends Protocol.PacketEntity { export class EditModeRequestEntity extends Protocol.PacketEntity {
name: string; name: string;
uuid: string; uuid: string;
constructor(rcp_id?: number, name?: string, uuid?: string) { number: number;
constructor(
rcp_id?: number,
name?: string,
uuid?: string,
number?: number
) {
super(); super();
this.rpc_id = rcp_id ?? 0; this.rpc_id = rcp_id ?? 0;
this.command = Protocol.Commands.kRpcEditMode; this.command = Protocol.Commands.kRpcEditMode;
this.name = name ?? ""; this.name = name ?? "";
this.uuid = uuid ?? ""; this.uuid = uuid ?? "";
this.number = number ?? 0;
} }
} }

View File

@ -137,10 +137,6 @@ export default defineComponent({
const calcWallVWScaler = (wall_width: number, wall_height: number) => { const calcWallVWScaler = (wall_width: number, wall_height: number) => {
if (wall.value && wall.value.parentElement) { if (wall.value && wall.value.parentElement) {
console.log($store.state.device_screen_width);
console.log($store.state.device_screen_height);
console.log(wall_width);
console.log(wall_height);
wall_height_scaler.value = wall_height_scaler.value =
$store.state.device_screen_height / wall_height; $store.state.device_screen_height / wall_height;
wall_width_scaler.value = $store.state.device_screen_width / wall_width; wall_width_scaler.value = $store.state.device_screen_width / wall_width;