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",
|
"nolebase",
|
||||||
"rollup",
|
"rollup",
|
||||||
"vitest"
|
"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 { TableAction } from '#/components/table-action';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
import ThingModelInfoModal from '#/views/thingmodelinfo/ioTPlatformThingModelInfo/index.vue';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
addProductFormSchema,
|
addProductFormSchema,
|
||||||
editProductFormSchemaEdit,
|
editProductFormSchemaEdit,
|
||||||
@ -78,10 +76,6 @@ const editRow: Record<string, any> = ref({});
|
|||||||
// 声明文件变量,用于存储选择的文件
|
// 声明文件变量,用于存储选择的文件
|
||||||
let selectedFile: File | null = null;
|
let selectedFile: File | null = null;
|
||||||
|
|
||||||
// 物模型模态框相关状态
|
|
||||||
const thingModelModalVisible = ref(false);
|
|
||||||
const currentProductInfo = ref<any>({});
|
|
||||||
|
|
||||||
// 设置文件选择回调
|
// 设置文件选择回调
|
||||||
setFileSelectedCallback((file) => {
|
setFileSelectedCallback((file) => {
|
||||||
selectedFile = file;
|
selectedFile = file;
|
||||||
@ -330,22 +324,15 @@ function onDeviceManagement(record: any) {
|
|||||||
// 物模型管理函数
|
// 物模型管理函数
|
||||||
function onThingModelManagement(record: any) {
|
function onThingModelManagement(record: any) {
|
||||||
console.log('物模型管理按钮被点击', record);
|
console.log('物模型管理按钮被点击', record);
|
||||||
// 设置当前产品信息
|
// 跳转到物模型管理页面,传递平台类型和平台产品ID作为参数
|
||||||
currentProductInfo.value = {
|
router.push({
|
||||||
productId: record.ioTPlatformProductId,
|
path: '/thingmodelinfo/ioTPlatformThingModelInfo',
|
||||||
productName: record.productName,
|
query: {
|
||||||
ioTPlatform: '2', // OneNET平台类型为2
|
productId: record.ioTPlatformProductId, // 平台产品ID
|
||||||
};
|
productName: record.productName,
|
||||||
console.log('设置产品信息:', currentProductInfo.value);
|
ioTPlatform: '2', // OneNET平台类型为2
|
||||||
// 打开物模型模态框
|
},
|
||||||
thingModelModalVisible.value = true;
|
});
|
||||||
console.log('模态框状态设置为:', thingModelModalVisible.value);
|
|
||||||
}
|
|
||||||
|
|
||||||
// 关闭物模型模态框
|
|
||||||
function closeThingModelModal() {
|
|
||||||
thingModelModalVisible.value = false;
|
|
||||||
currentProductInfo.value = {};
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@ -428,14 +415,5 @@ function closeThingModelModal() {
|
|||||||
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
<UserModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||||
<component :is="editRow.id ? EditForm : AddForm" />
|
<component :is="editRow.id ? EditForm : AddForm" />
|
||||||
</UserModal>
|
</UserModal>
|
||||||
|
|
||||||
<!-- 物模型信息模态框 -->
|
|
||||||
<ThingModelInfoModal
|
|
||||||
v-model:visible="thingModelModalVisible"
|
|
||||||
:product-id="currentProductInfo.productId"
|
|
||||||
:product-name="currentProductInfo.productName"
|
|
||||||
:io-t-platform="currentProductInfo.ioTPlatform"
|
|
||||||
@close="closeThingModelModal"
|
|
||||||
/>
|
|
||||||
</Page>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -2,21 +2,24 @@
|
|||||||
import type { VbenFormProps } from '#/adapter/form';
|
import type { VbenFormProps } from '#/adapter/form';
|
||||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
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 { useVbenForm } from '#/adapter/form';
|
||||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||||
import {
|
import {
|
||||||
|
postCtWingProductListAsync,
|
||||||
postIoTplatformThingModelInfoCopyAnotherThingModelAsync,
|
postIoTplatformThingModelInfoCopyAnotherThingModelAsync,
|
||||||
postIoTplatformThingModelInfoCopyStandardThingModel,
|
postIoTplatformThingModelInfoCopyStandardThingModel,
|
||||||
postIoTplatformThingModelInfoCreateAsync,
|
postIoTplatformThingModelInfoCreateAsync,
|
||||||
postIoTplatformThingModelInfoDeleteAsync,
|
postIoTplatformThingModelInfoDeleteAsync,
|
||||||
postIoTplatformThingModelInfoPageAsync,
|
postIoTplatformThingModelInfoPageAsync,
|
||||||
postIoTplatformThingModelInfoUpdateAsync,
|
postIoTplatformThingModelInfoUpdateAsync,
|
||||||
|
postOneNetProductListAsync,
|
||||||
} from '#/api-client';
|
} from '#/api-client';
|
||||||
import { TableAction } from '#/components/table-action';
|
import { TableAction } from '#/components/table-action';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
@ -30,32 +33,88 @@ import {
|
|||||||
} from './schema';
|
} from './schema';
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: 'ThingModelInfoModal',
|
name: 'IoTPlatformThingModelInfo',
|
||||||
});
|
});
|
||||||
|
|
||||||
const props = withDefaults(defineProps<Props>(), {
|
const route = useRoute();
|
||||||
visible: false,
|
|
||||||
productId: '',
|
|
||||||
productName: '',
|
|
||||||
ioTPlatform: '2',
|
|
||||||
});
|
|
||||||
|
|
||||||
// 定义emits
|
// 从路由参数获取产品信息
|
||||||
const emit = defineEmits<{
|
const productId = ref<string>((route.query.productId as string) || '');
|
||||||
close: [];
|
const productName = ref<string>((route.query.productName as string) || '');
|
||||||
'update:visible': [value: boolean];
|
const ioTPlatform = ref<string>((route.query.ioTPlatform as string) || '2');
|
||||||
}>();
|
|
||||||
|
|
||||||
// 定义props
|
|
||||||
interface Props {
|
|
||||||
visible?: boolean;
|
|
||||||
productId?: string;
|
|
||||||
productName?: string;
|
|
||||||
ioTPlatform?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
const formOptions: VbenFormProps = {
|
const formOptions: VbenFormProps = {
|
||||||
schema: querySchema.value,
|
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> = {
|
const gridOptions: VxeGridProps<any> = {
|
||||||
@ -76,20 +135,40 @@ const gridOptions: VxeGridProps<any> = {
|
|||||||
proxyConfig: {
|
proxyConfig: {
|
||||||
ajax: {
|
ajax: {
|
||||||
query: async ({ page }, formValues) => {
|
query: async ({ page }, formValues) => {
|
||||||
const { data } = await postIoTplatformThingModelInfoPageAsync({
|
// 优先使用表单值,如果没有则使用响应式变量
|
||||||
query: {
|
const currentPlatform = formValues?.ioTPlatform || ioTPlatform.value;
|
||||||
input: {
|
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,
|
pageIndex: page.currentPage,
|
||||||
pageSize: page.pageSize,
|
pageSize: page.pageSize,
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
ioTPlatform: Number.parseInt(String(currentPlatform)) as 1 | 2,
|
||||||
ioTPlatformProductId: props.productId,
|
ioTPlatformProductId: String(currentProductId),
|
||||||
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
|
...(formValues?.SearchKeyWords && { searchKeyWords: formValues.SearchKeyWords }),
|
||||||
},
|
},
|
||||||
},
|
});
|
||||||
});
|
// 更新数据状态,检查是否有数据
|
||||||
// 更新数据状态,检查是否有数据
|
hasData.value = data?.items && data.items.length > 0;
|
||||||
hasData.value = data?.items && data.items.length > 0;
|
return data || { items: [], totalCount: 0 };
|
||||||
return data;
|
} catch (error) {
|
||||||
|
console.error('查询物模型信息失败:', error);
|
||||||
|
hasData.value = false;
|
||||||
|
return {
|
||||||
|
items: [],
|
||||||
|
totalCount: 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -183,41 +262,84 @@ const [CopyForm, copyFormApi] = useVbenForm({
|
|||||||
wrapperClass: 'grid-cols-2',
|
wrapperClass: 'grid-cols-2',
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听props变化,自动设置筛选条件
|
// 监听路由参数变化,自动加载数据
|
||||||
watch(
|
watch(
|
||||||
() => [props.visible, props.productId, props.ioTPlatform],
|
() => [route.query.productId, route.query.ioTPlatform],
|
||||||
async ([visible, productId, ioTPlatform]) => {
|
async ([newProductId, newIoTPlatform]) => {
|
||||||
console.log('物模型模态框props变化:', { visible, productId, ioTPlatform });
|
if (newProductId) {
|
||||||
console.log('所有props:', props);
|
productId.value = newProductId as string;
|
||||||
if (visible && productId) {
|
}
|
||||||
// 延迟执行,确保组件完全初始化
|
if (newIoTPlatform) {
|
||||||
|
ioTPlatform.value = newIoTPlatform as string;
|
||||||
|
}
|
||||||
|
if (route.query.productName) {
|
||||||
|
productName.value = route.query.productName as string;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 延迟执行,确保组件完全初始化
|
||||||
|
if (gridApi) {
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
try {
|
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();
|
await gridApi.reload();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('设置筛选条件时出错:', error);
|
console.error('加载数据时出错:', error);
|
||||||
}
|
}
|
||||||
}, 100);
|
}, 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() {
|
async function submit() {
|
||||||
|
// 检查是否有产品ID
|
||||||
|
if (!productId.value) {
|
||||||
|
Message.error('产品ID不存在,无法保存物模型信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const isEdit = !!editRow.value.id;
|
const isEdit = !!editRow.value.id;
|
||||||
const formApi = isEdit ? editFormApi : addFormApi;
|
const formApi = isEdit ? editFormApi : addFormApi;
|
||||||
const api = isEdit
|
const api = isEdit
|
||||||
@ -230,14 +352,14 @@ async function submit() {
|
|||||||
const fetchParams: any = {
|
const fetchParams: any = {
|
||||||
...formValues,
|
...formValues,
|
||||||
// 自动添加平台和产品信息
|
// 自动添加平台和产品信息
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||||
ioTPlatformProductId: props.productId,
|
ioTPlatformProductId: productId.value,
|
||||||
// 编辑时需要添加ID
|
// 编辑时需要添加ID
|
||||||
...(isEdit && { id: editRow.value.id }),
|
...(isEdit && { id: editRow.value.id }),
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await api({ query: { input: fetchParams } });
|
const resp = await api({ body: fetchParams });
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
Message.success(
|
Message.success(
|
||||||
editRow.value.id ? $t('common.editSuccess') : $t('common.addSuccess'),
|
editRow.value.id ? $t('common.editSuccess') : $t('common.addSuccess'),
|
||||||
@ -270,16 +392,22 @@ const openAddModal = async () => {
|
|||||||
|
|
||||||
// 打开复制已有模型模态框
|
// 打开复制已有模型模态框
|
||||||
const openCopyAnotherThingModelModal = async () => {
|
const openCopyAnotherThingModelModal = async () => {
|
||||||
console.log('打开复制模态框,当前props:', {
|
console.log('打开复制模态框,当前参数:', {
|
||||||
productId: props.productId,
|
productId: productId.value,
|
||||||
productName: props.productName,
|
productName: productName.value,
|
||||||
ioTPlatform: props.ioTPlatform,
|
ioTPlatform: ioTPlatform.value,
|
||||||
});
|
});
|
||||||
copyModalApi.open();
|
copyModalApi.open();
|
||||||
};
|
};
|
||||||
|
|
||||||
// 复制提交逻辑
|
// 复制提交逻辑
|
||||||
async function submitCopy() {
|
async function submitCopy() {
|
||||||
|
// 检查是否有产品ID
|
||||||
|
if (!productId.value) {
|
||||||
|
Message.error('产品ID不存在,无法复制物模型信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const { valid } = await copyFormApi.validate();
|
const { valid } = await copyFormApi.validate();
|
||||||
if (!valid) return;
|
if (!valid) return;
|
||||||
|
|
||||||
@ -287,21 +415,19 @@ async function submitCopy() {
|
|||||||
|
|
||||||
console.log('复制提交参数:', {
|
console.log('复制提交参数:', {
|
||||||
formValues,
|
formValues,
|
||||||
props: {
|
params: {
|
||||||
productId: props.productId,
|
productId: productId.value,
|
||||||
productName: props.productName,
|
productName: productName.value,
|
||||||
ioTPlatform: props.ioTPlatform,
|
ioTPlatform: ioTPlatform.value,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await postIoTplatformThingModelInfoCopyAnotherThingModelAsync({
|
const resp = await postIoTplatformThingModelInfoCopyAnotherThingModelAsync({
|
||||||
query: {
|
body: {
|
||||||
input: {
|
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
ioTPlatformProductId: productId.value,
|
||||||
ioTPlatformProductId: props.productId,
|
sourceProductId: formValues.ioTPlatformProductId,
|
||||||
sourceProductId: formValues.ioTPlatformProductId,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -322,9 +448,7 @@ async function submitCopy() {
|
|||||||
async function onDel(record: any) {
|
async function onDel(record: any) {
|
||||||
try {
|
try {
|
||||||
const resp = await postIoTplatformThingModelInfoDeleteAsync({
|
const resp = await postIoTplatformThingModelInfoDeleteAsync({
|
||||||
query: {
|
body: { id: record.id },
|
||||||
input: { id: record.id },
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
Message.success($t('common.deleteSuccess'));
|
Message.success($t('common.deleteSuccess'));
|
||||||
@ -340,13 +464,17 @@ async function onDel(record: any) {
|
|||||||
|
|
||||||
// 复制标准模型函数
|
// 复制标准模型函数
|
||||||
async function copyStandardThingModel() {
|
async function copyStandardThingModel() {
|
||||||
|
// 检查是否有产品ID
|
||||||
|
if (!productId.value) {
|
||||||
|
Message.error('产品ID不存在,无法复制标准模型');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
|
const resp = await postIoTplatformThingModelInfoCopyStandardThingModel({
|
||||||
query: {
|
body: {
|
||||||
input: {
|
ioTPlatform: Number.parseInt(ioTPlatform.value) as 1 | 2,
|
||||||
ioTPlatform: Number.parseInt(props.ioTPlatform) as 1 | 2,
|
ioTPlatformProductId: productId.value,
|
||||||
ioTPlatformProductId: props.productId,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (resp.data) {
|
if (resp.data) {
|
||||||
@ -360,80 +488,73 @@ async function copyStandardThingModel() {
|
|||||||
Message.error('复制标准模型失败');
|
Message.error('复制标准模型失败');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 关闭模态框
|
|
||||||
function closeModal() {
|
|
||||||
emit('update:visible', false);
|
|
||||||
emit('close');
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<Modal :open="visible" :title="`${props.ioTPlatform === 1 ? 'CTWing' : 'OneNET'}物模型管理 - ${productName || '产品'}`"
|
<Page auto-content-height>
|
||||||
width="90%" :footer="null" @cancel="closeModal" @ok="closeModal"
|
<Grid>
|
||||||
:body-style="{ height: '70vh', overflow: 'hidden' }">
|
<template #toolbar-actions>
|
||||||
<div style="display: flex; flex-direction: column; height: 100%">
|
<TableAction :actions="[
|
||||||
<Grid style="flex: 1; overflow: hidden">
|
{
|
||||||
<template #toolbar-actions>
|
label: $t('common.add'),
|
||||||
<TableAction :actions="[
|
type: 'primary',
|
||||||
{
|
icon: 'ant-design:plus-outlined',
|
||||||
label: $t('common.add'),
|
onClick: openAddModal.bind(null),
|
||||||
type: 'primary',
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
icon: 'ant-design:plus-outlined',
|
disabled: !productId,
|
||||||
onClick: openAddModal.bind(null),
|
},
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
{
|
||||||
},
|
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
||||||
{
|
type: 'default',
|
||||||
label: $t('abp.thingModelInfos.copyStandardThingModel'),
|
icon: 'ant-design:copy-outlined',
|
||||||
type: 'default',
|
onClick: copyStandardThingModel,
|
||||||
icon: 'ant-design:copy-outlined',
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
onClick: copyStandardThingModel,
|
disabled: !productId,
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
},
|
||||||
},
|
{
|
||||||
{
|
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
||||||
label: $t('abp.thingModelInfos.copyAnotherThingModelModal'),
|
type: 'default',
|
||||||
type: 'default',
|
icon: 'ant-design:copy-outlined',
|
||||||
icon: 'ant-design:copy-outlined',
|
onClick: openCopyAnotherThingModelModal,
|
||||||
onClick: openCopyAnotherThingModelModal,
|
auth: ['AbpIdentity.Users.Create'],
|
||||||
auth: ['AbpIdentity.Users.Create'],
|
ifShow: !hasData,
|
||||||
ifShow: !hasData,
|
disabled: !productId,
|
||||||
},
|
},
|
||||||
]" />
|
]" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #isValueNeedConvert="{ row }">
|
<template #isValueNeedConvert="{ row }">
|
||||||
<component :is="h(
|
<component :is="h(
|
||||||
Tag,
|
Tag,
|
||||||
{ color: row.isValueNeedConvert ? 'blue' : 'default' },
|
{ color: row.isValueNeedConvert ? 'blue' : 'default' },
|
||||||
() => (row.isValueNeedConvert ? '是' : '否'),
|
() => (row.isValueNeedConvert ? '是' : '否'),
|
||||||
)
|
)
|
||||||
" />
|
" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #action="{ row }">
|
<template #action="{ row }">
|
||||||
<TableAction :actions="[
|
<TableAction :actions="[
|
||||||
{
|
{
|
||||||
label: $t('common.edit'),
|
label: $t('common.edit'),
|
||||||
type: 'link',
|
type: 'link',
|
||||||
size: 'small',
|
size: 'small',
|
||||||
auth: ['AbpIdentity.Users.Update'],
|
auth: ['AbpIdentity.Users.Update'],
|
||||||
onClick: onEdit.bind(null, row),
|
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',
|
</template>
|
||||||
type: 'link',
|
</Grid>
|
||||||
size: 'small',
|
|
||||||
auth: ['AbpIdentity.Users.Delete'],
|
|
||||||
popConfirm: {
|
|
||||||
title: $t('common.askConfirmDelete'),
|
|
||||||
confirm: onDel.bind(null, row),
|
|
||||||
},
|
|
||||||
},
|
|
||||||
]" />
|
|
||||||
</template>
|
|
||||||
</Grid>
|
|
||||||
</div>
|
|
||||||
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
<ThingModelModal :title="editRow.id ? $t('common.edit') : $t('common.add')" class="w-[800px]">
|
||||||
<component :is="editRow.id ? EditForm : AddForm" />
|
<component :is="editRow.id ? EditForm : AddForm" />
|
||||||
</ThingModelModal>
|
</ThingModelModal>
|
||||||
@ -442,5 +563,5 @@ function closeModal() {
|
|||||||
<CopyModal title="复制已有模型" class="w-[600px]">
|
<CopyModal title="复制已有模型" class="w-[600px]">
|
||||||
<CopyForm />
|
<CopyForm />
|
||||||
</CopyModal>
|
</CopyModal>
|
||||||
</Modal>
|
</Page>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@ -6,11 +6,95 @@ import dayjs from 'dayjs';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
getCommonGetSelectList,
|
getCommonGetSelectList,
|
||||||
|
postAggregationIoTplatformGetIoTplatformProductInfoAsync,
|
||||||
postOneNetProductListAsync,
|
postOneNetProductListAsync,
|
||||||
} from '#/api-client';
|
} from '#/api-client';
|
||||||
import { $t } from '#/locales';
|
import { $t } from '#/locales';
|
||||||
|
|
||||||
export const querySchema = computed(() => [
|
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',
|
component: 'Input',
|
||||||
fieldName: 'SearchKeyWords',
|
fieldName: 'SearchKeyWords',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user