范围列表

This commit is contained in:
Yuan 2023-08-23 09:17:50 +08:00
parent 6768738344
commit 5d5527f692
4 changed files with 123 additions and 25 deletions

View File

@ -1,21 +1,93 @@
<script setup lang="ts"> <script setup lang="ts">
import { getDeviceAreaList } from 'src/api/ConfigApi'; import { IAreaConfigListItem, getDeviceAreaList } from 'src/api/ConfigApi';
import { onMounted } from 'vue'; import { ref } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import DraggableDialog from './common/DraggableDialog.vue';
import { QTable } from 'quasar';
const lineId = useRoute().params.id as string; const lineId = useRoute().params.id as string;
console.log(lineId); const tableRef = ref<QTable>();
const columns: QTable['columns'] = [
onMounted(async () => { { name: 'id', label: 'ID', field: 'id', align: 'center' },
const resp = await getDeviceAreaList({ lineId, current: 1, size: 10 }); { name: 'lineId', label: '线路ID', field: 'lineId', align: 'center' },
console.log(resp); { name: 'areaName', label: '名称', field: 'areaName', align: 'center' },
{
name: 'deviceType',
label: '设备类型',
field: 'deviceType',
align: 'center',
},
{ name: 'operations', label: '操作', field: 'operations', align: 'center' },
];
const rows = ref<IAreaConfigListItem[]>([]);
const loading = ref(false);
const pagination = ref({
sortBy: 'desc',
descending: false,
page: 1,
rowsPerPage: 10,
rowsNumber: 10,
}); });
const onRequest: QTable['onRequest'] = async (props) => {
const { page, rowsPerPage } = props.pagination;
loading.value = true;
const resp = await getDeviceAreaList({
lineId,
current: page,
size: rowsPerPage,
});
pagination.value.page = resp.current;
pagination.value.rowsNumber = resp.total;
pagination.value.rowsPerPage = resp.size;
rows.value = resp.records;
loading.value = false;
};
const onDialogShow = () => {
tableRef.value?.requestServerInteraction();
};
const dialogRef = ref<InstanceType<typeof DraggableDialog>>();
const props = defineProps<{
onEditClick: (row: IAreaConfigListItem) => void;
}>();
function onEdit(row: IAreaConfigListItem) {
props.onEditClick(row);
}
</script> </script>
<template> <template>
<q-card> <draggable-dialog
<q-card-section> ref="dialogRef"
<div class="text-h6">范围列表</div> @show="onDialogShow"
</q-card-section> title="范围列表"
</q-card> :width="800"
>
<q-table
ref="tableRef"
row-key="id"
v-model:pagination="pagination"
:loading="loading"
:rows="rows"
:columns="columns"
@request="onRequest"
:rows-per-page-options="[10, 20, 50, 100]"
>
<template v-slot:body-cell-operations="props">
<q-td :props="props">
<div class="q-gutter-sm row justify-center">
<q-btn color="primary" label="编辑" @click="onEdit(props.row)" />
<!-- <q-btn
color="red"
label="删除"
@click="deleteData(props.row)"
/> -->
</div>
</q-td>
</template>
</q-table>
</draggable-dialog>
</template> </template>

View File

@ -1,8 +1,11 @@
<script setup lang="ts"> <script setup lang="ts">
import { QBar, useDialogPluginComponent } from 'quasar'; import { QBar, useDialogPluginComponent } from 'quasar';
import { ref, onMounted, onUnmounted, reactive, withDefaults } from 'vue'; import { ref, onMounted, onUnmounted, reactive } from 'vue';
const emit = defineEmits([...useDialogPluginComponent.emits]); const emit = defineEmits({
...useDialogPluginComponent.emitsObject,
show: () => true,
});
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
@ -70,6 +73,7 @@ function onHide() {
ref="dialogRef" ref="dialogRef"
@hide="onHide" @hide="onHide"
v-bind="$attrs" v-bind="$attrs"
@show="emit('show')"
transitionShow="jump-up" transitionShow="jump-up"
transitionHide="jump-down" transitionHide="jump-down"
class="column" class="column"

View File

@ -75,12 +75,16 @@ const props = defineProps({
const route = useRoute(); const route = useRoute();
const lineStore = useLineStore(); const lineStore = useLineStore();
const $q = useQuasar(); const $q = useQuasar();
const rangeConfig = reactive({ const rangeConfig = reactive<{
areaName: string;
deviceType: `${DeviceType}` | '';
device: string;
}>({
areaName: '', areaName: '',
deviceType: '', deviceType: '',
device: '', device: '',
}); });
const device = ref([] as string[]); const device = ref<string[]>([]);
const optionsType = [ const optionsType = [
{ label: '逻辑区段', value: LogicSection.Type }, { label: '逻辑区段', value: LogicSection.Type },
@ -89,8 +93,8 @@ const optionsType = [
{ label: '站台', value: Platform.Type }, { label: '站台', value: Platform.Type },
]; ];
enum deviceType { enum DeviceType {
station = 'DEVICE_TYPE_RTU', Station = 'DEVICE_TYPE_RTU',
Turnout = 'DEVICE_TYPE_SWITCH', Turnout = 'DEVICE_TYPE_SWITCH',
LogicSection = 'DEVICE_TYPE_TRACK', LogicSection = 'DEVICE_TYPE_TRACK',
Platform = 'DEVICE_TYPE_PLATFORM', Platform = 'DEVICE_TYPE_PLATFORM',
@ -108,6 +112,7 @@ watch(props, () => {
watch( watch(
() => lineStore.selectedGraphics, () => lineStore.selectedGraphics,
(val) => { (val) => {
console.log(11);
if (val && val.length > 0) { if (val && val.length > 0) {
const deviceFilter = lineStore.selectedGraphics?.filter( const deviceFilter = lineStore.selectedGraphics?.filter(
(g) => g.type == rangeConfig.deviceType (g) => g.type == rangeConfig.deviceType
@ -147,7 +152,7 @@ async function onSubmit() {
await deviceRangeSet({ await deviceRangeSet({
lineId: lineId, lineId: lineId,
areaName: rangeConfig.areaName, areaName: rangeConfig.areaName,
deviceType: (deviceType as never)[rangeConfig.deviceType + ''], deviceType: (DeviceType as never)[rangeConfig.deviceType + ''],
data: rangeConfig.device, data: rangeConfig.device,
}); });
$q.notify({ $q.notify({

View File

@ -3,6 +3,9 @@
<q-header reveal class="bg-primary text-white"> <q-header reveal class="bg-primary text-white">
<q-toolbar> <q-toolbar>
<q-toolbar-title> {{ mapName }} </q-toolbar-title> <q-toolbar-title> {{ mapName }} </q-toolbar-title>
<q-btn class="q-mr-xl" color="primary" @click="openRangeList"
>范围列表</q-btn
>
<q-btn color="info" label="返回" @click="backConfirm" /> <q-btn color="info" label="返回" @click="backConfirm" />
</q-toolbar> </q-toolbar>
<q-resize-observer @resize="onHeaderResize" /> <q-resize-observer @resize="onHeaderResize" />
@ -26,7 +29,10 @@ import { loadLineDatas, getLineApp } from 'src/drawApp/lineApp';
import { loadLineNetDatas, getLineNetApp } from 'src/drawApp/lineNetApp'; import { loadLineNetDatas, getLineNetApp } from 'src/drawApp/lineNetApp';
import rangeConfig from 'src/components/rangeConfig.vue'; import rangeConfig from 'src/components/rangeConfig.vue';
import RangeList from 'src/components/RangeList.vue'; import RangeList from 'src/components/RangeList.vue';
import { useQuasar } from 'quasar';
import { IAreaConfigListItem } from 'src/api/ConfigApi';
const $q = useQuasar();
const canvasWidth = ref(0); const canvasWidth = ref(0);
const canvasHeight = ref(0); const canvasHeight = ref(0);
const headerHeight = ref(0); const headerHeight = ref(0);
@ -36,12 +42,7 @@ const mapType = ref(route.params.type as string);
const lineStore = useLineStore(); const lineStore = useLineStore();
const lineNetStore = useLineNetStore(); const lineNetStore = useLineNetStore();
const drawerRight = ref(); const drawerRight = ref();
const rangeConfigEdit = reactive({ const rangeConfigEdit = ref<IAreaConfigListItem & { device: string[] }>();
id: '',
areaName: '',
deviceType: '',
device: [] as string[],
});
const mapName = computed(() => lineStore.lineName || lineNetStore.lineNetName); const mapName = computed(() => lineStore.lineName || lineNetStore.lineNetName);
@ -92,4 +93,20 @@ onMounted(() => {
lineStore.setLineId(null); lineStore.setLineId(null);
} }
}); });
function openRangeList() {
const dialog = $q.dialog({
component: RangeList,
componentProps: {
onEditClick: (row: IAreaConfigListItem) => {
// dialog.hide();
console.log(row.data);
// rangeConfigEdit.value = {
// ...row,
// device: [row.data],
// };
},
},
});
}
</script> </script>