erge branch 'master' of git.code.tencent.com:beijing-rtss-test/bj-rtss-client
This commit is contained in:
commit
4a410b5918
@ -54,28 +54,28 @@ import {
|
||||
RelateDevicelistItem,
|
||||
} from 'src/drawApp/pslApp';
|
||||
import { usePslDrawStore } from 'src/stores/psl-draw-store';
|
||||
import { PslButton } from 'src/graphics/pslButton/pslButton';
|
||||
import { PslKey } from 'src/graphics/pslKey/pslKey';
|
||||
import { PslLight } from 'src/graphics/pslLight/pslLight';
|
||||
|
||||
const pslDrawStore = usePslDrawStore();
|
||||
const $q = useQuasar();
|
||||
const tableRef = ref<QTable>();
|
||||
const deviceTypeMap = {
|
||||
6: '车站',
|
||||
};
|
||||
const columns: QTable['columns'] = [
|
||||
{ name: 'code', label: '组合类型', field: 'code', align: 'center' },
|
||||
{
|
||||
name: 'deviceType',
|
||||
label: '设备类型',
|
||||
field: (row) => deviceTypeMap[row.deviceType as keyof typeof deviceTypeMap],
|
||||
align: 'center',
|
||||
},
|
||||
{ name: 'code', label: '设备编号', field: 'code', align: 'center' },
|
||||
{
|
||||
name: 'combinationtypes',
|
||||
label: '关联的组合类型',
|
||||
name: 'refRelays',
|
||||
label: '关联的设备',
|
||||
field: (row: RelateDevicelistItem) => {
|
||||
if (row.combinationtypes) {
|
||||
const ref = row.combinationtypes.map(
|
||||
(combinationtype) => combinationtype.code
|
||||
if (row.refDevices) {
|
||||
const ref = row.refDevices.map(
|
||||
(id) =>
|
||||
(
|
||||
pslDrawStore.getDrawApp().queryStore.queryById(id) as
|
||||
| PslButton
|
||||
| PslKey
|
||||
| PslLight
|
||||
).datas.code
|
||||
);
|
||||
return ref.join('\\');
|
||||
}
|
||||
@ -126,8 +126,7 @@ function creatData() {
|
||||
}
|
||||
|
||||
function deleteData(row: RelateDevicelistItem) {
|
||||
$q.dialog({ message: `确定删除 "${row.code}" 吗?`, cancel: true }).onOk(
|
||||
async () => {
|
||||
$q.dialog({ message: '确定删除吗?', cancel: true }).onOk(async () => {
|
||||
try {
|
||||
deleteGatedRelateDevice(row);
|
||||
successNotify('删除数据成功!');
|
||||
@ -136,8 +135,7 @@ function deleteData(row: RelateDevicelistItem) {
|
||||
} finally {
|
||||
tableRef.value?.requestServerInteraction();
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -6,44 +6,19 @@
|
||||
</q-card-section>
|
||||
<q-separator inset></q-separator>
|
||||
<q-form ref="myForm" @submit="onSubmit" @reset="onReset">
|
||||
<q-select
|
||||
outlined
|
||||
v-model="relateDeviceConfig.deviceType"
|
||||
:options="optionsType"
|
||||
label="设备类型"
|
||||
:map-options="true"
|
||||
:emit-value="true"
|
||||
:rules="[(val) => val != undefined || '设备类型不能为空']"
|
||||
/>
|
||||
<q-input
|
||||
outlined
|
||||
label="设备编号"
|
||||
v-model="relateDeviceConfig.code"
|
||||
:rules="[(val) => val.trim() != '' || '名称不能为空']"
|
||||
/>
|
||||
<q-list bordered separator class="rounded-borders">
|
||||
<q-expansion-item
|
||||
expand-separator
|
||||
v-for="(
|
||||
combinationtype, index
|
||||
) in relateDeviceConfig.combinationtypes"
|
||||
:key="index"
|
||||
v-model="combinationtype.expanded"
|
||||
:label="combinationtype.code"
|
||||
@click="toggleItem(index)"
|
||||
>
|
||||
<q-card>
|
||||
<q-item>
|
||||
<q-item-section no-wrap class="q-gutter-y-sm column">
|
||||
<q-input
|
||||
outlined
|
||||
v-model="combinationtype.code"
|
||||
v-model="relateDeviceConfig.code"
|
||||
label="组合类型"
|
||||
lazy-rules
|
||||
/>
|
||||
<div class="q-gutter-sm row">
|
||||
<q-chip
|
||||
v-for="item in combinationtype.refDevicesCode"
|
||||
v-for="item in relateDeviceConfig.refDevicesCode"
|
||||
:key="item"
|
||||
square
|
||||
color="primary"
|
||||
@ -56,30 +31,18 @@
|
||||
</div>
|
||||
<div>
|
||||
<q-btn
|
||||
v-show="combinationtype.refDevicesCode.length > 0"
|
||||
v-show="relateDeviceConfig.refDevicesCode.length > 0"
|
||||
style="width: 130px"
|
||||
label="清空框选的设备"
|
||||
color="red"
|
||||
class="q-mr-md"
|
||||
@click="clearAllSelect(index)"
|
||||
/>
|
||||
<q-btn
|
||||
label="删除组合类型"
|
||||
color="secondary"
|
||||
@click="deleteCombinationtype(index)"
|
||||
@click="clearAllSelect()"
|
||||
/>
|
||||
</div>
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</q-list>
|
||||
<q-btn
|
||||
class="q-mt-md"
|
||||
label="增加组合类型"
|
||||
color="secondary"
|
||||
@click="addCombinationtype"
|
||||
/>
|
||||
<div class="q-gutter-sm q-pa-md row justify-center">
|
||||
<q-btn label="提交" type="submit" color="primary" class="q-mr-md" />
|
||||
<q-btn label="重置" type="reset" color="primary" class="q-mr-md" />
|
||||
@ -98,7 +61,6 @@ import { usePslDrawStore } from 'src/stores/psl-draw-store';
|
||||
import { PslKey } from 'src/graphics/pslKey/pslKey';
|
||||
import { PslButton } from 'src/graphics/pslButton/pslButton';
|
||||
import { PslLight } from 'src/graphics/pslLight/pslLight';
|
||||
import { pslGraphicData } from 'src/protos/pslGraphics';
|
||||
import {
|
||||
creatGatedRelateDevice,
|
||||
editGatedRelateDevice,
|
||||
@ -112,32 +74,21 @@ const pslDrawStore = usePslDrawStore();
|
||||
const $q = useQuasar();
|
||||
const showRangeConfig = ref(true);
|
||||
const relateDeviceConfig = ref<{
|
||||
deviceType: graphicData.RelatedRef.DeviceType | undefined;
|
||||
code: string;
|
||||
combinationtypes: {
|
||||
code: string;
|
||||
refDevices: string[];
|
||||
refDevicesCode: string[];
|
||||
expanded: boolean;
|
||||
}[];
|
||||
}>({
|
||||
deviceType: undefined,
|
||||
code: '',
|
||||
combinationtypes: [
|
||||
{ code: '组合类型', refDevices: [], refDevicesCode: [], expanded: false },
|
||||
],
|
||||
code: '组合类型',
|
||||
refDevices: [],
|
||||
refDevicesCode: [],
|
||||
});
|
||||
const handleState = ref('新建门控箱关联设备');
|
||||
|
||||
const optionsType = [
|
||||
{ label: '车站', value: graphicData.RelatedRef.DeviceType.station },
|
||||
];
|
||||
|
||||
let selectGraphic: JlGraphic[] = [];
|
||||
watch(
|
||||
() => pslDrawStore.selectedGraphics,
|
||||
(val) => {
|
||||
if (val && val.length > 0 && clickIndex !== null) {
|
||||
if (val && val.length > 0) {
|
||||
const selectFilter = pslDrawStore.selectedGraphics?.filter(
|
||||
(g) =>
|
||||
g.type == PslKey.Type ||
|
||||
@ -147,14 +98,14 @@ watch(
|
||||
selectGraphic.push(...selectFilter);
|
||||
selectGraphic = Array.from(new Set(selectGraphic));
|
||||
pslDrawStore.getDrawApp().updateSelected(...selectGraphic);
|
||||
relateDeviceConfig.value.combinationtypes[clickIndex].refDevicesCode =
|
||||
selectGraphic.map((g) =>
|
||||
relateDeviceConfig.value.refDevicesCode = selectGraphic.map((g) =>
|
||||
(g as PslKey | PslButton | PslLight).datas.code == ''
|
||||
? g.id
|
||||
: (g as PslKey | PslButton | PslLight).datas.code
|
||||
);
|
||||
relateDeviceConfig.value.combinationtypes[clickIndex].refDevices =
|
||||
selectGraphic.map((g) => g.id) as string[];
|
||||
relateDeviceConfig.value.refDevices = selectGraphic.map(
|
||||
(g) => g.id
|
||||
) as string[];
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -171,28 +122,19 @@ async function onSubmit() {
|
||||
myForm.value?.validate().then(async (res) => {
|
||||
if (res) {
|
||||
try {
|
||||
const combinationtypes: graphicData.DeviceCombinationtype[] = [];
|
||||
relateDeviceConfig.value.combinationtypes.forEach((combinationtype) => {
|
||||
combinationtypes.push(
|
||||
const combinationtype: graphicData.DeviceCombinationtype =
|
||||
new graphicData.DeviceCombinationtype({
|
||||
code: combinationtype.code,
|
||||
refDevices: combinationtype.refDevices,
|
||||
})
|
||||
);
|
||||
});
|
||||
const gatedRelateDevice = new pslGraphicData.GatedRelateDevice({
|
||||
deviceType: relateDeviceConfig.value.deviceType,
|
||||
code: relateDeviceConfig.value.code,
|
||||
combinationtypes: combinationtypes,
|
||||
refDevices: relateDeviceConfig.value.refDevices,
|
||||
});
|
||||
if (handleState.value == '新建门控箱关联设备') {
|
||||
handle.value = '创建成功';
|
||||
handleError.value = '创建失败';
|
||||
creatGatedRelateDevice(gatedRelateDevice);
|
||||
creatGatedRelateDevice(combinationtype);
|
||||
} else {
|
||||
handle.value = '更新成功';
|
||||
handleError.value = '更新失败';
|
||||
editGatedRelateDevice(editRow, gatedRelateDevice);
|
||||
editGatedRelateDevice(editRow, combinationtype);
|
||||
}
|
||||
pslDrawStore.table?.requestServerInteraction();
|
||||
$q.notify({
|
||||
@ -221,27 +163,18 @@ async function editRelateDevices(row: RelateDevicelistItem) {
|
||||
selectGraphic = [];
|
||||
drawApp.updateSelected();
|
||||
editRow = row;
|
||||
relateDeviceConfig.value.deviceType = row.deviceType;
|
||||
relateDeviceConfig.value.code = row.code;
|
||||
row.combinationtypes.forEach((combinationtype) => {
|
||||
const refCode: string[] = [];
|
||||
combinationtype.refDevices.forEach((id) => {
|
||||
const g = drawApp.queryStore.queryById(id);
|
||||
refCode.push(g.code);
|
||||
});
|
||||
combinationtype.refDevicesCode = refCode;
|
||||
combinationtype.expanded = false;
|
||||
});
|
||||
relateDeviceConfig.value.combinationtypes = [];
|
||||
row.combinationtypes.forEach((combinationtype) => {
|
||||
const { code, refDevices, refDevicesCode, expanded } = combinationtype;
|
||||
relateDeviceConfig.value.combinationtypes.push({
|
||||
code,
|
||||
refDevices,
|
||||
refDevicesCode: refDevicesCode as string[],
|
||||
expanded: expanded as boolean,
|
||||
});
|
||||
row.refDevices.forEach((id) => {
|
||||
const g = drawApp.queryStore.queryById(id) as
|
||||
| PslButton
|
||||
| PslKey
|
||||
| PslLight;
|
||||
refCode.push(g.datas.code);
|
||||
});
|
||||
row.refDevicesCode = refCode;
|
||||
relateDeviceConfig.value.code = row.code;
|
||||
relateDeviceConfig.value.refDevices = row.refDevices;
|
||||
relateDeviceConfig.value.refDevicesCode = row.refDevicesCode;
|
||||
} catch (err) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
@ -250,40 +183,19 @@ async function editRelateDevices(row: RelateDevicelistItem) {
|
||||
}
|
||||
}
|
||||
|
||||
let clickIndex: null | number = null;
|
||||
function toggleItem(index: number) {
|
||||
const drawApp = pslDrawStore.getDrawApp();
|
||||
selectGraphic = [];
|
||||
drawApp.updateSelected();
|
||||
const combinationtypes = relateDeviceConfig.value.combinationtypes;
|
||||
if (combinationtypes[index].expanded == true) {
|
||||
clickIndex = index;
|
||||
const select: JlGraphic[] = [];
|
||||
combinationtypes[index].refDevices.forEach((id: string) => {
|
||||
const g = drawApp.queryStore.queryById(id);
|
||||
select.push(g);
|
||||
});
|
||||
drawApp.updateSelected(...select);
|
||||
} else {
|
||||
clickIndex = null;
|
||||
}
|
||||
}
|
||||
|
||||
function removeSelect(code: string) {
|
||||
const clickTarget =
|
||||
relateDeviceConfig.value.combinationtypes[clickIndex as number];
|
||||
const removeIndex = clickTarget.refDevicesCode.findIndex(
|
||||
const removeIndex = relateDeviceConfig.value.refDevicesCode.findIndex(
|
||||
(item) => item == code
|
||||
);
|
||||
selectGraphic.splice(removeIndex, 1);
|
||||
clickTarget.refDevicesCode.splice(removeIndex, 1);
|
||||
clickTarget.refDevices.splice(removeIndex, 1);
|
||||
relateDeviceConfig.value.refDevicesCode.splice(removeIndex, 1);
|
||||
relateDeviceConfig.value.refDevices.splice(removeIndex, 1);
|
||||
pslDrawStore.getDrawApp().updateSelected(...selectGraphic);
|
||||
}
|
||||
|
||||
function clearAllSelect(index: number) {
|
||||
relateDeviceConfig.value.combinationtypes[index].refDevices = [];
|
||||
relateDeviceConfig.value.combinationtypes[index].refDevicesCode = [];
|
||||
function clearAllSelect() {
|
||||
relateDeviceConfig.value.refDevices = [];
|
||||
relateDeviceConfig.value.refDevicesCode = [];
|
||||
clearAllSelectAtCanvas();
|
||||
}
|
||||
|
||||
@ -292,29 +204,12 @@ function clearAllSelectAtCanvas() {
|
||||
pslDrawStore.getDrawApp().updateSelected();
|
||||
}
|
||||
|
||||
function addCombinationtype() {
|
||||
relateDeviceConfig.value.combinationtypes.push({
|
||||
function onReset() {
|
||||
handleState.value = '新建门控箱关联设备';
|
||||
relateDeviceConfig.value = {
|
||||
code: '组合类型',
|
||||
refDevices: [],
|
||||
refDevicesCode: [],
|
||||
expanded: false,
|
||||
});
|
||||
}
|
||||
|
||||
function deleteCombinationtype(index: number) {
|
||||
relateDeviceConfig.value.combinationtypes.splice(index, 1);
|
||||
clearAllSelectAtCanvas();
|
||||
}
|
||||
|
||||
function onReset() {
|
||||
clickIndex = null;
|
||||
handleState.value = '新建门控箱关联设备';
|
||||
relateDeviceConfig.value = {
|
||||
deviceType: undefined,
|
||||
code: '',
|
||||
combinationtypes: [
|
||||
{ code: '组合类型', refDevices: [], refDevicesCode: [], expanded: false },
|
||||
],
|
||||
};
|
||||
clearAllSelectAtCanvas();
|
||||
}
|
||||
|
@ -231,35 +231,28 @@ export async function loadPslDrawDatas(): Promise<IGraphicStorage> {
|
||||
|
||||
//关联设备列表的增删改查
|
||||
export interface RelateDevicelistItem {
|
||||
deviceType: graphicData.RelatedRef.DeviceType | undefined;
|
||||
code: string;
|
||||
combinationtypes: {
|
||||
code: string;
|
||||
refDevices: string[];
|
||||
refDevicesCode?: string[];
|
||||
expanded?: boolean;
|
||||
}[];
|
||||
}
|
||||
|
||||
let refDevicesList: pslGraphicData.GatedRelateDevice[] = [];
|
||||
let refDevicesList: graphicData.DeviceCombinationtype[] = [];
|
||||
export function loadGatedRelateDeviceList() {
|
||||
return refDevicesList;
|
||||
}
|
||||
|
||||
export function creatGatedRelateDevice(row: pslGraphicData.GatedRelateDevice) {
|
||||
export function creatGatedRelateDevice(row: graphicData.DeviceCombinationtype) {
|
||||
refDevicesList.push(row);
|
||||
console.log(refDevicesList, '====');
|
||||
drawApp?.emit('postdataloaded');
|
||||
}
|
||||
|
||||
export function editGatedRelateDevice(
|
||||
editRow: RelateDevicelistItem,
|
||||
newData: pslGraphicData.GatedRelateDevice
|
||||
newData: graphicData.DeviceCombinationtype
|
||||
) {
|
||||
for (let i = 0; i < refDevicesList.length; i++) {
|
||||
if (
|
||||
refDevicesList[i].deviceType == editRow.deviceType &&
|
||||
refDevicesList[i].code == editRow.code
|
||||
) {
|
||||
if (refDevicesList[i].code == editRow.code) {
|
||||
refDevicesList[i] = newData;
|
||||
break;
|
||||
}
|
||||
@ -269,10 +262,7 @@ export function editGatedRelateDevice(
|
||||
|
||||
export function deleteGatedRelateDevice(row: RelateDevicelistItem) {
|
||||
for (let i = 0; i < refDevicesList.length; i++) {
|
||||
if (
|
||||
refDevicesList[i].deviceType == row.deviceType &&
|
||||
refDevicesList[i].code == row.code
|
||||
) {
|
||||
if (refDevicesList[i].code == row.code) {
|
||||
refDevicesList.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user