|
@@ -10,7 +10,10 @@
|
|
</n-space>
|
|
</n-space>
|
|
<n-space align="center" :size="18">
|
|
<n-space align="center" :size="18">
|
|
<n-input-group>
|
|
<n-input-group>
|
|
- <n-input v-model:value="topic" />
|
|
|
|
|
|
+ <n-input v-model:value="formValue.subscribe_topic_name" placeholder="输入订阅主题名称" />
|
|
|
|
+ <n-input v-model:value="formValue.publish_topic_name" placeholder="输入发布主题名称" />
|
|
|
|
+ <n-input v-model:value="formValue.user_name" placeholder="输入用户姓名" />
|
|
|
|
+ <n-input v-model:value="formValue.pasture_name" placeholder="输入牧场名称" />
|
|
<n-button type="primary" @click="handleSearch">搜索</n-button>
|
|
<n-button type="primary" @click="handleSearch">搜索</n-button>
|
|
</n-input-group>
|
|
</n-input-group>
|
|
<n-button size="small" type="primary" @click="getTableData">
|
|
<n-button size="small" type="primary" @click="getTableData">
|
|
@@ -25,7 +28,8 @@
|
|
:type="modalType"
|
|
:type="modalType"
|
|
:edit-data="editData"
|
|
:edit-data="editData"
|
|
:pasture-enum-list-data="pastureEnumListData"
|
|
:pasture-enum-list-data="pastureEnumListData"
|
|
- :topic-enum-list-data="topicEnumListData"
|
|
|
|
|
|
+ :subscribe-topic-enum-list-data="subscribeTopicEnumListData"
|
|
|
|
+ :publish-topic-enum-list-data="publishTopicEnumListData"
|
|
/>
|
|
/>
|
|
</n-card>
|
|
</n-card>
|
|
</div>
|
|
</div>
|
|
@@ -44,19 +48,30 @@ import type { ModalType } from '../authentication/components/table-action-modal.
|
|
|
|
|
|
const { loading, startLoading, endLoading } = useLoading(false);
|
|
const { loading, startLoading, endLoading } = useLoading(false);
|
|
const { bool: visible, setTrue: openModal } = useBoolean();
|
|
const { bool: visible, setTrue: openModal } = useBoolean();
|
|
-const topic = ref('');
|
|
|
|
|
|
+const formValue = ref<Mqtt.SearchAuth>({
|
|
|
|
+ publish_topic_name: '',
|
|
|
|
+ subscribe_topic_name: '',
|
|
|
|
+ pasture_name: '',
|
|
|
|
+ user_name: ''
|
|
|
|
+});
|
|
|
|
+
|
|
const tableData = ref<ApiMqttAuth.Auth[]>([]);
|
|
const tableData = ref<ApiMqttAuth.Auth[]>([]);
|
|
const editData = ref<Mqtt.Auth | null>(null);
|
|
const editData = ref<Mqtt.Auth | null>(null);
|
|
const modalType = ref<ModalType>('add');
|
|
const modalType = ref<ModalType>('add');
|
|
const pastureEnumListData = ref<SelectOption[]>([]);
|
|
const pastureEnumListData = ref<SelectOption[]>([]);
|
|
-const topicEnumListData = ref<SelectOption[]>([]);
|
|
|
|
|
|
+const subscribeTopicEnumListData = ref<SelectOption[]>([]);
|
|
|
|
+const publishTopicEnumListData = ref<SelectOption[]>([]);
|
|
|
|
|
|
function setPastureList(data: SelectOption[]) {
|
|
function setPastureList(data: SelectOption[]) {
|
|
pastureEnumListData.value = data;
|
|
pastureEnumListData.value = data;
|
|
}
|
|
}
|
|
|
|
|
|
-function setTopicList(data: SelectOption[]) {
|
|
|
|
- topicEnumListData.value = data;
|
|
|
|
|
|
+function setSubscribeTopicList(data: SelectOption[]) {
|
|
|
|
+ subscribeTopicEnumListData.value = data;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+function setPublishTopicList(data: SelectOption[]) {
|
|
|
|
+ publishTopicEnumListData.value = data;
|
|
}
|
|
}
|
|
|
|
|
|
function setEditData(data: Mqtt.Auth | null) {
|
|
function setEditData(data: Mqtt.Auth | null) {
|
|
@@ -74,7 +89,7 @@ function setModalType(type: ModalType) {
|
|
async function getTableData() {
|
|
async function getTableData() {
|
|
startLoading();
|
|
startLoading();
|
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
- const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, topic.value);
|
|
|
|
|
|
+ const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, formValue.value);
|
|
if (data) {
|
|
if (data) {
|
|
setTableData(data);
|
|
setTableData(data);
|
|
endLoading();
|
|
endLoading();
|
|
@@ -92,12 +107,17 @@ async function getPastureEnumList() {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-async function getTopicEnumList() {
|
|
|
|
- const { data } = await topicEnumList();
|
|
|
|
|
|
+async function getTopicByPublishEnumList() {
|
|
|
|
+ const { data } = await topicEnumList(1);
|
|
if (data) {
|
|
if (data) {
|
|
- setTimeout(() => {
|
|
|
|
- setTopicList(data);
|
|
|
|
- }, 1000);
|
|
|
|
|
|
+ setPublishTopicList(data);
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+async function getTopicBySubscribeEnumList() {
|
|
|
|
+ const { data } = await topicEnumList(2);
|
|
|
|
+ if (data) {
|
|
|
|
+ setSubscribeTopicList(data);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -132,13 +152,18 @@ const columns: Ref<DataTableColumns<ApiMqttAuth.Auth>> = ref([
|
|
align: 'center'
|
|
align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- key: 'topic_name_stings',
|
|
|
|
- title: 'topic名称',
|
|
|
|
|
|
+ key: 'subscribe_topic_name_stings',
|
|
|
|
+ title: '订阅topic名称',
|
|
align: 'center'
|
|
align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
key: 'subscribe_acl',
|
|
key: 'subscribe_acl',
|
|
- title: '发布topic',
|
|
|
|
|
|
+ title: '订阅topic',
|
|
|
|
+ align: 'center'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ key: 'publish_topic_name_stings',
|
|
|
|
+ title: '发布topic名称',
|
|
align: 'center'
|
|
align: 'center'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
@@ -203,11 +228,11 @@ const pagination: PaginationProps = reactive({
|
|
});
|
|
});
|
|
|
|
|
|
async function handleSearch() {
|
|
async function handleSearch() {
|
|
- if (!topic.value) {
|
|
|
|
- window.$message?.warning('请输入主题名称');
|
|
|
|
|
|
+ if (!formValue.value) {
|
|
|
|
+ window.$message?.warning('请输入相关名称');
|
|
} else {
|
|
} else {
|
|
startLoading();
|
|
startLoading();
|
|
- const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, topic.value);
|
|
|
|
|
|
+ const { data } = await fetchMqttAuthList(pagination.page, pagination.pageSize, formValue.value);
|
|
if (data) {
|
|
if (data) {
|
|
setTableData(data);
|
|
setTableData(data);
|
|
endLoading();
|
|
endLoading();
|
|
@@ -244,7 +269,8 @@ function handleAddTable() {
|
|
function init() {
|
|
function init() {
|
|
getTableData();
|
|
getTableData();
|
|
getPastureEnumList();
|
|
getPastureEnumList();
|
|
- getTopicEnumList();
|
|
|
|
|
|
+ getTopicByPublishEnumList();
|
|
|
|
+ getTopicBySubscribeEnumList();
|
|
}
|
|
}
|
|
|
|
|
|
// 初始化
|
|
// 初始化
|