|
|
@@ -67,6 +67,8 @@
|
|
|
<a-select v-if="item[2] === 'select'" v-model:value="form[item[0]]" allow-clear :options="toOptions(item[4])" />
|
|
|
<a-select v-else-if="item[2] === 'device'" v-model:value="form[deviceFieldName]" allow-clear show-search :options="deviceOptions" :filter-option="filterOption" @change="handleDeviceChange" />
|
|
|
<a-select v-else-if="item[2] === 'channel'" v-model:value="form[channelFieldName]" allow-clear show-search :options="channelOptions" :filter-option="filterOption" />
|
|
|
+ <a-select v-else-if="item[2] === 'transmit'" v-model:value="form[item[0]]" allow-clear show-search :options="transmitOptions" :filter-option="filterOption" />
|
|
|
+ <a-select v-else-if="item[2] === 'protocol'" v-model:value="form[item[0]]" allow-clear show-search :options="protocolOptions" :filter-option="filterOption" />
|
|
|
<a-switch v-else-if="item[2] === 'switch'" v-model:checked="form[item[0]]" :checked-value="item[4]?.[0]?.[1] ?? true" :un-checked-value="item[4]?.[1]?.[1] ?? false" />
|
|
|
<a-input-number v-else-if="item[2] === 'number'" v-model:value="form[item[0]]" class="full-input" />
|
|
|
<a-date-picker v-else-if="item[2] === 'date'" v-model:value="form[item[0]]" value-format="YYYY-MM-DD" class="full-input" />
|
|
|
@@ -86,6 +88,8 @@ import BearJiaUtil from '@/utils/BearJiaUtil';
|
|
|
import { listStation } from '@/api/config/station';
|
|
|
import { listStationDevice } from '@/api/config/stationDevice';
|
|
|
import { listChannel } from '@/api/config/channel';
|
|
|
+import { listProtocol } from '@/api/config/protocol';
|
|
|
+import { listTransmit } from '@/api/config/transmit';
|
|
|
import TableActionBar from '@/components/TableActionBar/index.vue';
|
|
|
import TableToolbar from '@/components/BearJiaProTable/TableToolbar.vue';
|
|
|
import { useTableConfigStore } from '@/stores/tableConfig';
|
|
|
@@ -98,6 +102,8 @@ const rows = ref([]);
|
|
|
const stationOptions = ref([]);
|
|
|
const allDevices = ref([]);
|
|
|
const allChannels = ref([]);
|
|
|
+const allTransmits = ref([]);
|
|
|
+const allProtocols = ref([]);
|
|
|
const formOpen = ref(false);
|
|
|
const formRef = ref();
|
|
|
const selectedRowKeys = ref([]);
|
|
|
@@ -112,11 +118,15 @@ const form = reactive({});
|
|
|
const hasStation = computed(() => props.moduleConfig.hasStation !== false);
|
|
|
const deviceFieldName = computed(() => props.moduleConfig.fields.find((item) => item[2] === 'device')?.[0]);
|
|
|
const channelFieldName = computed(() => props.moduleConfig.fields.find((item) => item[2] === 'channel')?.[0]);
|
|
|
+const transmitFieldName = computed(() => props.moduleConfig.fields.find((item) => item[2] === 'transmit')?.[0]);
|
|
|
+const protocolFieldName = computed(() => props.moduleConfig.fields.find((item) => item[2] === 'protocol')?.[0]);
|
|
|
const fieldMap = computed(() => new Map(props.moduleConfig.fields.map((item) => [item[0], item])));
|
|
|
const searchFields = computed(() => props.moduleConfig.search.filter((name) => name !== stationField.value).map((name) => ({ name, label: fieldMap.value.get(name)?.[1] || name, type: fieldMap.value.get(name)?.[2], options: toOptions(fieldMap.value.get(name)?.[4]) })));
|
|
|
const columnTitle = (name) => {
|
|
|
if (name === 'stationName') return '场站';
|
|
|
if (name === 'channelName') return '通道';
|
|
|
+ if (name === 'configTransmitName') return '通信模块';
|
|
|
+ if (name === 'configProtocalName') return '协议模块';
|
|
|
return fieldMap.value.get(name)?.[1] || name;
|
|
|
};
|
|
|
const columns = computed(() => [
|
|
|
@@ -147,6 +157,8 @@ const deviceOptions = computed(() => allDevices.value
|
|
|
.filter((item) => !form[stationField.value] || String(item.stationId) === String(form[stationField.value]))
|
|
|
.map((item) => ({ label: item.deviceName || item.name || item.id, value: item.id, raw: item })));
|
|
|
const channelOptions = computed(() => allChannels.value.map((item) => ({ label: item.name || item.id, value: item.id })));
|
|
|
+const transmitOptions = computed(() => allTransmits.value.map((item) => ({ label: item.name || item.id, value: item.id })));
|
|
|
+const protocolOptions = computed(() => allProtocols.value.map((item) => ({ label: item.name || item.id, value: item.id })));
|
|
|
const rowSelection = computed(() => ({
|
|
|
selectedRowKeys: selectedRowKeys.value,
|
|
|
onChange: (keys) => { selectedRowKeys.value = keys; }
|
|
|
@@ -174,6 +186,16 @@ const loadChannels = async () => {
|
|
|
const res = await listChannel({ pageNum: 1, pageSize: 500 });
|
|
|
allChannels.value = res?.rows || res?.data || [];
|
|
|
};
|
|
|
+const loadTransmits = async () => {
|
|
|
+ if (!transmitFieldName.value) return;
|
|
|
+ const res = await listTransmit({ pageNum: 1, pageSize: 500 });
|
|
|
+ allTransmits.value = res?.rows || res?.data || [];
|
|
|
+};
|
|
|
+const loadProtocols = async () => {
|
|
|
+ if (!protocolFieldName.value) return;
|
|
|
+ const res = await listProtocol({ pageNum: 1, pageSize: 500 });
|
|
|
+ allProtocols.value = res?.rows || res?.data || [];
|
|
|
+};
|
|
|
const handleQuery = async () => {
|
|
|
loading.value = true;
|
|
|
try {
|
|
|
@@ -199,6 +221,8 @@ const handleTableChange = (page) => {
|
|
|
const openForm = async (record) => {
|
|
|
await loadDevices();
|
|
|
await loadChannels();
|
|
|
+ await loadTransmits();
|
|
|
+ await loadProtocols();
|
|
|
if (record?.id) {
|
|
|
const res = await props.api.get(record.id);
|
|
|
resetObject(form, { ...res.data });
|
|
|
@@ -274,6 +298,8 @@ const handleTableReset = () => {
|
|
|
loadStations();
|
|
|
loadDevices();
|
|
|
loadChannels();
|
|
|
+loadTransmits();
|
|
|
+loadProtocols();
|
|
|
handleQuery();
|
|
|
</script>
|
|
|
|