Compare commits
2 Commits
28479396f9
...
288b153e43
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
288b153e43 | ||
|
|
fdc07134a8 |
12
.vscode/settings.json
vendored
12
.vscode/settings.json
vendored
@ -237,5 +237,15 @@
|
||||
"nolebase",
|
||||
"rollup",
|
||||
"vitest"
|
||||
]
|
||||
],
|
||||
"editor.gotoLocation.alternativeDeclarationCommand": "editor.action.revealDefinition",
|
||||
"editor.gotoLocation.alternativeDefinitionCommand": "editor.action.revealDefinition",
|
||||
"editor.gotoLocation.alternativeTypeDefinitionCommand": "editor.action.revealDefinition",
|
||||
"editor.selectionHighlight": false,
|
||||
"files.autoSave": "onFocusChange",
|
||||
"editor.quickSuggestions": {
|
||||
"other": "on",
|
||||
"comments": "off",
|
||||
"strings": "on"
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
@ -23,8 +23,6 @@ import {
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
import ThingModelInfoModal from '#/views/thingmodelinfo/ioTPlatformThingModelInfo/index.vue';
|
||||
|
||||
import {
|
||||
addProductFormSchema,
|
||||
editProductFormSchemaEdit,
|
||||
@ -78,10 +76,6 @@ const editRow: Record<string, any> = ref({});
|
||||
// 声明文件变量,用于存储选择的文件
|
||||
let selectedFile: File | null = null;
|
||||
|
||||
// 物模型模态框相关状态
|
||||
const thingModelModalVisible = ref(false);
|
||||
const currentProductInfo = ref<any>({});
|
||||
|
||||
// 设置文件选择回调
|
||||
setFileSelectedCallback((file) => {
|
||||
selectedFile = file;
|
||||
@ -330,22 +324,15 @@ function onDeviceManagement(record: any) {
|
||||
// 物模型管理函数
|
||||
function onThingModelManagement(record: any) {
|
||||
console.log('物模型管理按钮被点击', record);
|
||||
// 设置当前产品信息
|
||||
currentProductInfo.value = {
|
||||
productId: record.ioTPlatformProductId,
|
||||
productName: record.productName,
|
||||
ioTPlatform: '2', // OneNET平台类型为2
|
||||
};
|
||||
console.log('设置产品信息:', currentProductInfo.value);
|
||||
// 打开物模型模态框
|
||||
thingModelModalVisible.value = true;
|
||||
console.log('模态框状态设置为:', thingModelModalVisible.value);
|
||||
}
|
||||
|
||||
// 关闭物模型模态框
|
||||
function closeThingModelModal() {
|
||||
thingModelModalVisible.value = false;
|
||||
currentProductInfo.value = {};
|
||||
// 跳转到物模型管理页面,传递平台类型和平台产品ID作为参数
|
||||
router.push({
|
||||
path: '/thingmodelinfo/ioTPlatformThingModelInfo',
|
||||
query: {
|
||||
productId: record.ioTPlatformProductId, // 平台产品ID
|
||||
productName: record.productName,
|
||||
ioTPlatform: '2', // OneNET平台类型为2
|
||||
},
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -428,14 +415,5 @@ function closeThingModelModal() {
|
||||
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||
<component :is="editRow.id ? EditForm : AddForm" />
|
||||
</UserModal>
|
||||
|
||||
<!-- 物模型信息模态框 -->
|
||||
<ThingModelInfoModal
|
||||
v-model:visible="thingModelModalVisible"
|
||||
:product-id="currentProductInfo.productId"
|
||||
:product-name="currentProductInfo.productName"
|
||||
:io-t-platform="currentProductInfo.ioTPlatform"
|
||||
@close="closeThingModelModal"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@ -2,21 +2,24 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { h, nextTick, ref, watch } from 'vue';
|
||||
import { h, nextTick, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import { message as Message, Modal, Tag } from 'ant-design-vue';
|
||||
import { message as Message, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postCtWingProductListAsync,
|
||||
postIoTplatformThingModelInfoCopyAnotherThingModelAsync,
|
||||
postIoTplatformThingModelInfoCopyStandardThingModel,
|
||||
postIoTplatformThingModelInfoCreateAsync,
|
||||
postIoTplatformThingModelInfoDeleteAsync,
|
||||
postIoTplatformThingModelInfoPageAsync,
|
||||
postIoTplatformThingModelInfoUpdateAsync,
|
||||
postOneNetProductListAsync,
|
||||
} from '#/api-client';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { $t } from '#/locales';
|
||||
@ -30,32 +33,88 @@ import {
|
||||
} from './schema';
|
||||
|
||||
defineOptions({
|
||||
name: 'ThingModelInfoModal',
|
||||
name: 'IoTPlatformThingModelInfo',
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<Props>(), {
|
||||
visible: false,
|
||||
productId: '',
|
||||
productName: '',
|
||||
ioTPlatform: '2',
|
||||
});
|
||||
const route = useRoute();
|
||||
|
||||
// 定义emits
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
'update:visible': [value: boolean];
|
||||
}>();
|
||||
|
||||
// 定义props
|
||||
interface Props {
|
||||
visible?: boolean;
|
||||
productId?: string;
|
||||
productName?: string;
|
||||
ioTPlatform?: string;
|
||||
}
|
||||
// 从路由参数获取产品信息
|
||||
const productId = ref<string>((route.query.productId as string) || '');
|
||||
const productName = ref<string>((route.query.productName as string) || '');
|
||||
const ioTPlatform = ref<string>((route.query.ioTPlatform as string) || '2');
|
||||
|
||||
const formOptions: VbenFormProps = {
|
||||
schema: querySchema.value,
|
||||
initialValues: {
|
||||
ioTPlatform: route.query.ioTPlatform ? String(route.query.ioTPlatform) : undefined,
|
||||
ioTPlatformProductId: route.query.productId ? String(route.query.productId) : undefined,
|
||||
},
|
||||
submitOnChange: false,
|
||||
handleValuesChange: async (values, changedFields) => {
|
||||
// 当平台类型变化时,清空产品ID
|
||||
if (changedFields.includes('ioTPlatform')) {
|
||||
if (values.ioTPlatform) {
|
||||
ioTPlatform.value = String(values.ioTPlatform);
|
||||
// 清空产品ID,因为平台变化了
|
||||
if (gridApi?.formApi) {
|
||||
await gridApi.formApi.setValues({
|
||||
ioTPlatformProductId: undefined,
|
||||
});
|
||||
}
|
||||
productId.value = '';
|
||||
productName.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// 当产品ID变化时,更新响应式变量并重新加载数据
|
||||
if (changedFields.includes('ioTPlatformProductId')) {
|
||||
if (values.ioTPlatformProductId) {
|
||||
productId.value = String(values.ioTPlatformProductId);
|
||||
// 从产品列表中获取产品名称
|
||||
const platform = values.ioTPlatform;
|
||||
if (platform) {
|
||||
try {
|
||||
const api = platform === 2 || platform === '2'
|
||||
? postOneNetProductListAsync
|
||||
: platform === 1 || platform === '1'
|
||||
? postCtWingProductListAsync
|
||||
: null;
|
||||
if (api) {
|
||||
const { data } = await api({
|
||||
body: {
|
||||
pageIndex: 1,
|
||||
pageSize: 1000,
|
||||
},
|
||||
});
|
||||
const items = data?.items || [];
|
||||
const selectedProduct = items.find((item: any) =>
|
||||
String(item.ioTPlatformProductId) === String(values.ioTPlatformProductId)
|
||||
);
|
||||
if (selectedProduct) {
|
||||
productName.value = selectedProduct.productName || '';
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取产品名称失败:', error);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
productId.value = '';
|
||||
productName.value = '';
|
||||
}
|
||||
|
||||
// 延迟重新加载数据,确保表单值已更新
|
||||
setTimeout(async () => {
|
||||
if (gridApi && gridApi.reload) {
|
||||
try {
|
||||
await gridApi.reload();
|
||||
} catch (error) {
|
||||
console.error('重新加载数据时出错:', error);
|
||||
}
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
@ -76,20 +135,40 @@ const gridOptions: VxeGridProps<any> = {
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }, formValues) => {
|
||||
const { data } = await postIoTplatformThingModelInfoPageAsync({
|
||||
query: {
|
||||
input: {
|
||||
// 优先使用表单值,如果没有则使用响应式变量
|
||||
const currentPlatform = formValues?.ioTPlatform || ioTPlatform.value;
|
||||
const currentProductId = formValues?.ioTPlatformProductId || productId.value;
|
||||
|
||||
// 如果没有产品ID,直接返回空数据,让表格正常显示空白状态
|
||||
if (!currentProductId || !currentPlatform) {
|
||||
hasData.value = false;
|
||||
return {
|
||||
items: [],
|
||||
totalCount: 0,
|
||||
};
|
||||
}
|
||||
|
||||
try {
|
||||
const { data } = await postIoTplatformThingModelInfoPageAsync({
|
||||
body: {
|
||||
pageIndex: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
||||
ioTPlatformProductId: props.productId,
|
||||
ioTPlatform: Number.parseInt(String(currentPlatform)) as 1 | 2,
|
||||
ioTPlatformProductId: String(currentProductId),
|
||||
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
|
||||
},
|
||||
},
|
||||
});
|
||||
// 更新数据状态,检查是否有数据
|
||||
hasData.value = data?.items && data.items.length > 0;
|
||||
return data;
|
||||
});
|
||||
// 更新数据状态,检查是否有数据
|
||||
hasData.value = data?.items && data.items.length > 0;
|
||||
return data || { items: [], totalCount: 0 };
|
||||
} catch (error) {
|
||||
console.error('查询物模型信息失败:', error);
|
||||
hasData.value = false;
|
||||
return {
|
||||
items: [],
|
||||
totalCount: 0,
|
||||
};
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -183,41 +262,84 @@ const [CopyForm, copyFormApi] = useVbenForm({
|
||||
wrapperClass: 'grid-cols-2',
|
||||
});
|
||||
|
||||
// 监听props变化,自动设置筛选条件
|
||||
// 监听路由参数变化,自动加载数据
|
||||
watch(
|
||||
() => [props.visible, props.productId, props.ioTPlatform],
|
||||
async ([visible, productId, ioTPlatform]) => {
|
||||
console.log('物模型模态框props变化:', { visible, productId, ioTPlatform });
|
||||
console.log('所有props:', props);
|
||||
if (visible && productId) {
|
||||
// 延迟执行,确保组件完全初始化
|
||||
() => [route.query.productId, route.query.ioTPlatform],
|
||||
async ([newProductId, newIoTPlatform]) => {
|
||||
if (newProductId) {
|
||||
productId.value = newProductId as string;
|
||||
}
|
||||
if (newIoTPlatform) {
|
||||
ioTPlatform.value = newIoTPlatform as string;
|
||||
}
|
||||
if (route.query.productName) {
|
||||
productName.value = route.query.productName as string;
|
||||
}
|
||||
|
||||
// 延迟执行,确保组件完全初始化
|
||||
if (gridApi) {
|
||||
setTimeout(async () => {
|
||||
try {
|
||||
// 设置表单筛选条件(如果有搜索关键词等筛选字段)
|
||||
const filterValues: any = {};
|
||||
|
||||
// 注意:ioTPlatformProductId 已经在 API 调用中通过 props.productId 传递
|
||||
// 这里只需要设置查询表单中存在的字段(如 SearchKeyWords)
|
||||
|
||||
console.log('设置筛选条件:', filterValues);
|
||||
|
||||
// 设置筛选表单的值
|
||||
if (Object.keys(filterValues).length > 0) {
|
||||
await gridApi.formApi.setValues(filterValues);
|
||||
}
|
||||
// 重新加载数据(即使没有筛选条件也要重新加载,因为 productId 可能已变化)
|
||||
await gridApi.reload();
|
||||
} catch (error) {
|
||||
console.error('设置筛选条件时出错:', error);
|
||||
console.error('加载数据时出错:', error);
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
{ immediate: false },
|
||||
);
|
||||
|
||||
// 页面初始化时加载数据
|
||||
onMounted(async () => {
|
||||
// 从路由参数初始化
|
||||
if (route.query.productId) {
|
||||
productId.value = route.query.productId as string;
|
||||
}
|
||||
if (route.query.productName) {
|
||||
productName.value = route.query.productName as string;
|
||||
}
|
||||
if (route.query.ioTPlatform) {
|
||||
ioTPlatform.value = route.query.ioTPlatform as string;
|
||||
}
|
||||
|
||||
// 延迟加载数据,确保表格已初始化
|
||||
// 即使没有 productId,也要触发一次查询,让表格显示空白状态
|
||||
await nextTick();
|
||||
setTimeout(async () => {
|
||||
if (gridApi && gridApi.reload) {
|
||||
try {
|
||||
// 如果表单中有值,确保表单值已设置
|
||||
if (route.query.ioTPlatform || route.query.productId) {
|
||||
const formValues = await gridApi.formApi.getValues();
|
||||
if (route.query.ioTPlatform && !formValues.ioTPlatform) {
|
||||
await gridApi.formApi.setValues({
|
||||
ioTPlatform: route.query.ioTPlatform,
|
||||
});
|
||||
}
|
||||
if (route.query.productId && !formValues.ioTPlatformProductId) {
|
||||
await gridApi.formApi.setValues({
|
||||
ioTPlatformProductId: route.query.productId,
|
||||
});
|
||||
}
|
||||
await nextTick();
|
||||
}
|
||||
await gridApi.reload();
|
||||
} catch (error) {
|
||||
console.error('初始化加载数据时出错:', error);
|
||||
}
|
||||
}
|
||||
}, 300);
|
||||
});
|
||||
|
||||
// 新增和编辑提交的逻辑
|
||||
async function submit() {
|
||||
// 检查是否有产品ID
|
||||
if (!productId.value) {
|
||||
Message.error('产品ID不存在,无法保存物模型信息');
|
||||
return;
|
||||
}
|
||||
|
||||
const isEdit = !!editRow.value.id;
|
||||
const formApi = isEdit ? editFormApi : addFormApi;
|
||||
const api = isEdit
|
||||
@ -230,14 +352,14 @@ async function submit() {
|
||||
const fetchParams: any = {
|
||||
...formValues,
|
||||
// 自动添加平台和产品信息
|
||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
||||
ioTPlatformProductId: props.productId,
|
||||
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||
ioTPlatformProductId: productId.value,
|
||||
// 编辑时需要添加ID
|
||||
...(isEdit && { id: editRow.value.id }),
|
||||
};
|
||||
|
||||
try {
|
||||
const resp = await api({ query: { input: fetchParams } });
|
||||
const resp = await api({ body: fetchParams });
|
||||
if (resp.data) {
|
||||
Message.success(
|
||||
editRow.value.id ? $t('common.editSuccess') : $t('common.addSuccess'),
|
||||
@ -270,16 +392,22 @@ const openAddModal = async () => {
|
||||
|
||||
// 打开复制已有模型模态框
|
||||
const openCopyAnotherThingModelModal = async () => {
|
||||
console.log('打开复制模态框,当前props:', {
|
||||
productId: props.productId,
|
||||
productName: props.productName,
|
||||
ioTPlatform: props.ioTPlatform,
|
||||
console.log('打开复制模态框,当前参数:', {
|
||||
productId: productId.value,
|
||||
productName: productName.value,
|
||||
ioTPlatform: ioTPlatform.value,
|
||||
});
|
||||
copyModalApi.open();
|
||||
};
|
||||
|
||||
// 复制提交逻辑
|
||||
async function submitCopy() {
|
||||
// 检查是否有产品ID
|
||||
if (!productId.value) {
|
||||
Message.error('产品ID不存在,无法复制物模型信息');
|
||||
return;
|
||||
}
|
||||
|
||||
const { valid } = await copyFormApi.validate();
|
||||
if (!valid) return;
|
||||
|
||||
@ -287,21 +415,19 @@ async function submitCopy() {
|
||||
|
||||
console.log('复制提交参数:', {
|
||||
formValues,
|
||||
props: {
|
||||
productId: props.productId,
|
||||
productName: props.productName,
|
||||
ioTPlatform: props.ioTPlatform,
|
||||
params: {
|
||||
productId: productId.value,
|
||||
productName: productName.value,
|
||||
ioTPlatform: ioTPlatform.value,
|
||||
},
|
||||
});
|
||||
|
||||
try {
|
||||
const resp = await postIoTplatformThingModelInfoCopyAnotherThingModelAsync({
|
||||
query: {
|
||||
input: {
|
||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
||||
ioTPlatformProductId: props.productId,
|
||||
sourceProductId: formValues.ioTPlatformProductId,
|
||||
},
|
||||
body: {
|
||||
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||
ioTPlatformProductId: productId.value,
|
||||
sourceProductId: formValues.ioTPlatformProductId,
|
||||
},
|
||||
});
|
||||
|
||||
@ -322,9 +448,7 @@ async function submitCopy() {
|
||||
async function onDel(record: any) {
|
||||
try {
|
||||
const resp = await postIoTplatformThingModelInfoDeleteAsync({
|
||||
query: {
|
||||
input: { id: record.id },
|
||||
},
|
||||
body: { id: record.id },
|
||||
});
|
||||
if (resp.data) {
|
||||
Message.success($t('common.deleteSuccess'));
|
||||
@ -340,13 +464,17 @@ async function onDel(record: any) {
|
||||
|
||||
// 复制标准模型函数
|
||||
async function copyStandardThingModel() {
|
||||
// 检查是否有产品ID
|
||||
if (!productId.value) {
|
||||
Message.error('产品ID不存在,无法复制标准模型');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
|
||||
query: {
|
||||
input: {
|
||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
||||
ioTPlatformProductId: props.productId,
|
||||
},
|
||||
body: {
|
||||
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||
ioTPlatformProductId: productId.value,
|
||||
},
|
||||
});
|
||||
if (resp.data) {
|
||||
@ -360,80 +488,73 @@ async function copyStandardThingModel() {
|
||||
Message.error('复制标准模型失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭模态框
|
||||
function closeModal() {
|
||||
emit('update:visible', false);
|
||||
emit('close');
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :open="visible" :title="`${props.ioTPlatform === 1 ? 'CTWing' : 'OneNET'}物模型管理 - ${productName || '产品'}`"
|
||||
width="90%" :footer="null" @cancel="closeModal" @ok="closeModal"
|
||||
:body-style="{ height: '70vh', overflow: 'hidden' }">
|
||||
<div style="display: flex; flex-direction: column; height: 100%">
|
||||
<Grid style="flex: 1; overflow: hidden">
|
||||
<template #toolbar-actions>
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
{
|
||||
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
||||
type: 'default',
|
||||
icon: 'ant-design:copy-outlined',
|
||||
onClick: copyStandardThingModel,
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
{
|
||||
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
||||
type: 'default',
|
||||
icon: 'ant-design:copy-outlined',
|
||||
onClick: openCopyAnotherThingModelModal,
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
ifShow: !hasData,
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
icon: 'ant-design:plus-outlined',
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
disabled: !productId,
|
||||
},
|
||||
{
|
||||
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
||||
type: 'default',
|
||||
icon: 'ant-design:copy-outlined',
|
||||
onClick: copyStandardThingModel,
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
disabled: !productId,
|
||||
},
|
||||
{
|
||||
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
||||
type: 'default',
|
||||
icon: 'ant-design:copy-outlined',
|
||||
onClick: openCopyAnotherThingModelModal,
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
ifShow: !hasData,
|
||||
disabled: !productId,
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
|
||||
<template #isValueNeedConvert="{ row }">
|
||||
<component :is="h(
|
||||
Tag,
|
||||
{ color: row.isValueNeedConvert ? 'blue' : 'default' },
|
||||
() => (row.isValueNeedConvert ? '是' : '否'),
|
||||
)
|
||||
" />
|
||||
</template>
|
||||
<template #isValueNeedConvert="{ row }">
|
||||
<component :is="h(
|
||||
Tag,
|
||||
{ color: row.isValueNeedConvert ? 'blue' : 'default' },
|
||||
() => (row.isValueNeedConvert ? '是' : '否'),
|
||||
)
|
||||
" />
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
<template #action="{ row }">
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
popConfirm: {
|
||||
title: $t('common.askConfirmDelete'),
|
||||
confirm: onDel.bind(null, row),
|
||||
},
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
type: 'link',
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Delete'],
|
||||
popConfirm: {
|
||||
title: $t('common.askConfirmDelete'),
|
||||
confirm: onDel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
</Grid>
|
||||
</div>
|
||||
},
|
||||
]" />
|
||||
</template>
|
||||
</Grid>
|
||||
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||
<component :is="editRow.id ? EditForm : AddForm" />
|
||||
</ThingModelModal>
|
||||
@ -442,5 +563,5 @@ function closeModal() {
|
||||
<CopyModal title="复制已有模型" class="w-[600px]">
|
||||
<CopyForm />
|
||||
</CopyModal>
|
||||
</Modal>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
@ -6,11 +6,95 @@ import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
getCommonGetSelectList,
|
||||
postAggregationIoTplatformGetIoTplatformProductInfoAsync,
|
||||
postOneNetProductListAsync,
|
||||
} from '#/api-client';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const querySchema = computed(() => [
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'ioTPlatform',
|
||||
label: $t('abp.deviceInfos.ioTPlatform'),
|
||||
componentProps: {
|
||||
api: getCommonGetSelectList,
|
||||
params: {
|
||||
query: {
|
||||
typeName: 'IoTPlatformTypeEnum',
|
||||
},
|
||||
},
|
||||
labelField: 'value',
|
||||
valueField: 'key',
|
||||
optionsPropName: 'options',
|
||||
immediate: true,
|
||||
allowClear: true,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.deviceInfos.ioTPlatform')}`,
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
return res;
|
||||
}
|
||||
if (res && Array.isArray(res.items)) {
|
||||
return res.items;
|
||||
}
|
||||
if (res && Array.isArray(res.data)) {
|
||||
return res.data;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'ApiSelect',
|
||||
fieldName: 'ioTPlatformProductId',
|
||||
label: $t('common.BelongingProductName'),
|
||||
dependencies: {
|
||||
show(values: any) {
|
||||
return !!values.ioTPlatform;
|
||||
},
|
||||
triggerFields: ['ioTPlatform'],
|
||||
},
|
||||
componentProps: (formValues: any) => {
|
||||
const platform = formValues?.ioTPlatform;
|
||||
|
||||
return {
|
||||
api: platform
|
||||
? postAggregationIoTplatformGetIoTplatformProductInfoAsync
|
||||
: null,
|
||||
params: {
|
||||
body: {
|
||||
// 聚合服务要求 JSON Body 格式参数
|
||||
ioTPlatformType:
|
||||
typeof platform === 'string'
|
||||
? Number.parseInt(platform)
|
||||
: platform,
|
||||
},
|
||||
},
|
||||
labelField: 'productName',
|
||||
valueField: 'ioTPlatformProductId',
|
||||
optionsPropName: 'options',
|
||||
immediate: false,
|
||||
allowClear: true,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('common.BelongingProductName')}`,
|
||||
afterFetch: (res: any) => {
|
||||
// 确保返回的是数组格式
|
||||
if (Array.isArray(res)) {
|
||||
return res;
|
||||
}
|
||||
if (res && Array.isArray(res.items)) {
|
||||
return res.items;
|
||||
}
|
||||
if (res && Array.isArray(res.data)) {
|
||||
return res.data;
|
||||
}
|
||||
if (res && res.data && Array.isArray(res.data.items)) {
|
||||
return res.data.items;
|
||||
}
|
||||
return [];
|
||||
},
|
||||
};
|
||||
},
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'SearchKeyWords',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user