Compare commits
2 Commits
4d7ee72d24
...
c6b8339a02
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6b8339a02 | ||
|
|
57d65c7e77 |
@ -585,7 +585,7 @@ export const CreateDataDictinaryInputSchema = {
|
||||
} as const;
|
||||
|
||||
export const CreateDeviceAggregationInputSchema = {
|
||||
required: ['deviceAddress', 'ioTPlatform', 'ioTPlatformProductId', 'platformPassword'],
|
||||
required: ['deviceAddress', 'ioTPlatform', 'ioTPlatformProductId'],
|
||||
type: 'object',
|
||||
properties: {
|
||||
deviceAddress: {
|
||||
@ -596,25 +596,10 @@ export const CreateDeviceAggregationInputSchema = {
|
||||
ioTPlatform: {
|
||||
'$ref': '#/components/schemas/IoTPlatformTypeEnum'
|
||||
},
|
||||
platformPassword: {
|
||||
minLength: 1,
|
||||
type: 'string',
|
||||
description: '电表密码'
|
||||
},
|
||||
ioTPlatformProductId: {
|
||||
minLength: 1,
|
||||
type: 'string',
|
||||
description: '集中器在物联网平台中对应的产品Id'
|
||||
},
|
||||
ioTPlatformDeviceOpenInfo: {
|
||||
type: 'string',
|
||||
description: '集中器在物联网平台中对应的设备Id或者名称',
|
||||
nullable: true
|
||||
},
|
||||
ioTPlatformAccountId: {
|
||||
type: 'string',
|
||||
description: '物联网平台中对应的账号Id',
|
||||
nullable: true
|
||||
}
|
||||
},
|
||||
additionalProperties: false,
|
||||
@ -1216,6 +1201,10 @@ export const DeviceManagementInfoDtoSchema = {
|
||||
type: 'string',
|
||||
description: '物联网平台返回的响应信息',
|
||||
nullable: true
|
||||
},
|
||||
isPlatformPushSuccess: {
|
||||
type: 'boolean',
|
||||
description: '物联网平台推送是否成功'
|
||||
}
|
||||
},
|
||||
additionalProperties: false
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -215,22 +215,10 @@ export type CreateDeviceAggregationInput = {
|
||||
*/
|
||||
deviceAddress: string;
|
||||
ioTPlatform: IoTPlatformTypeEnum;
|
||||
/**
|
||||
* 电表密码
|
||||
*/
|
||||
platformPassword: string;
|
||||
/**
|
||||
* 集中器在物联网平台中对应的产品Id
|
||||
*/
|
||||
ioTPlatformProductId: string;
|
||||
/**
|
||||
* 集中器在物联网平台中对应的设备Id或者名称
|
||||
*/
|
||||
ioTPlatformDeviceOpenInfo?: (string) | null;
|
||||
/**
|
||||
* 物联网平台中对应的账号Id
|
||||
*/
|
||||
ioTPlatformAccountId?: (string) | null;
|
||||
};
|
||||
|
||||
/**
|
||||
@ -557,6 +545,10 @@ export type DeviceManagementInfoDto = {
|
||||
* 物联网平台返回的响应信息
|
||||
*/
|
||||
ioTPlatformResponse?: (string) | null;
|
||||
/**
|
||||
* 物联网平台推送是否成功
|
||||
*/
|
||||
isPlatformPushSuccess?: boolean;
|
||||
};
|
||||
|
||||
export type DeviceManagementInfoDtoPagedResultDto = {
|
||||
@ -4522,6 +4514,16 @@ export type PostAggregationDeviceFindByIdAsyncResponse = (DeviceManagementInfoDt
|
||||
|
||||
export type PostAggregationDeviceFindByIdAsyncError = unknown;
|
||||
|
||||
export type PostAggregationDeviceRepushDeviceInfoToIoTplatformData = {
|
||||
query?: {
|
||||
input?: IdInput;
|
||||
};
|
||||
};
|
||||
|
||||
export type PostAggregationDeviceRepushDeviceInfoToIoTplatformResponse = (DeviceManagementInfoDto);
|
||||
|
||||
export type PostAggregationDeviceRepushDeviceInfoToIoTplatformError = unknown;
|
||||
|
||||
export type PostDeviceInfoFindByDeviceAddressData = {
|
||||
query?: {
|
||||
deviceAddress?: string;
|
||||
|
||||
@ -276,6 +276,10 @@
|
||||
"BelongingProductName": "Belonging ProductName",
|
||||
"CommunicationAddress": "Communication Address",
|
||||
"CommunicationAddressTLS": "TLS Communication Address",
|
||||
"DeviceThingModelFileName": "DeviceThingModelFileName"
|
||||
"DeviceThingModelFileName": "DeviceThingModelFileName",
|
||||
"IoTPlatformProductUpdateTime": "ProductUpdateTime",
|
||||
"IoTPlatformProductCreateTime": "ProductCreateTime",
|
||||
"CreationTime": "CreationTime",
|
||||
"LastModificationTime": "LastModificationTime"
|
||||
}
|
||||
}
|
||||
|
||||
@ -55,5 +55,7 @@
|
||||
"getDataFailed": "Failed to get data",
|
||||
"PhoneNumberFormatError": "PhoneNumber Format Error",
|
||||
"IoTPlatform": "IoTPlatform",
|
||||
"note": "note"
|
||||
"note": "note",
|
||||
"creationTime": "CreationTime",
|
||||
"lastModificationTime": "LastModificationTime"
|
||||
}
|
||||
|
||||
@ -278,6 +278,10 @@
|
||||
"BelongingProductName": "所属产品",
|
||||
"CommunicationAddress": "通讯地址",
|
||||
"CommunicationAddressTLS": "TLS通讯地址",
|
||||
"DeviceThingModelFileName": "物模型文件"
|
||||
"DeviceThingModelFileName": "物模型文件",
|
||||
"IoTPlatformProductUpdateTime": "平台更新时间",
|
||||
"IoTPlatformProductCreateTime": "平台创建时间",
|
||||
"CreationTime": "创建时间",
|
||||
"LastModificationTime": "更新时间"
|
||||
}
|
||||
}
|
||||
|
||||
@ -56,5 +56,7 @@
|
||||
"IsEnabled": "是否启用",
|
||||
"PhoneNumberFormatError": "手机号码格式错误",
|
||||
"IoTPlatform": "物联网平台",
|
||||
"note": "备注"
|
||||
"note": "备注",
|
||||
"creationTime": "创建时间",
|
||||
"lastModificationTime": "最后更新时间"
|
||||
}
|
||||
|
||||
@ -137,7 +137,7 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
pageSize: 1000,
|
||||
},
|
||||
},
|
||||
labelField: 'ProductName',
|
||||
labelField: 'label',
|
||||
valueField: 'ioTPlatformProductId',
|
||||
immediate: true,
|
||||
afterFetch: (res: any) => {
|
||||
@ -146,34 +146,29 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
const data = res.data;
|
||||
|
||||
// 确保返回的是数组格式
|
||||
let items = [];
|
||||
if (Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
// 如果是包装在 items 中的,提取出来
|
||||
if (data && Array.isArray(data.items)) {
|
||||
return data.items;
|
||||
}
|
||||
// 如果是包装在 data 中的,提取出来
|
||||
if (data && Array.isArray(data.data)) {
|
||||
return data.data;
|
||||
items = data;
|
||||
} else if (data && Array.isArray(data.items)) {
|
||||
items = data.items;
|
||||
} else if (data && Array.isArray(data.data)) {
|
||||
items = data.data;
|
||||
}
|
||||
|
||||
// 为每个产品项添加组合标签
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
label: `${item.productName || item.ProductName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||
}));
|
||||
}
|
||||
|
||||
// 如果都不是,返回空数组
|
||||
return [];
|
||||
},
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`,
|
||||
},
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'deviceName',
|
||||
label: $t('abp.deviceInfos.deviceName'),
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceName')}`,
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
@ -184,14 +179,6 @@ export const addDeviceFormSchema: any = computed(() => [
|
||||
message: `${$t('common.pleaseInput')}${$t('abp.deviceInfos.deviceAddress')}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
component: 'Input',
|
||||
fieldName: 'platformPassword',
|
||||
label: $t('abp.deviceInfos.platformPassword'),
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseInput')}${$t('common.info')}${$t('abp.deviceInfos.platformPassword')}`,
|
||||
}),
|
||||
},
|
||||
]);
|
||||
|
||||
export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
@ -240,7 +227,7 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
pageSize: 1000,
|
||||
},
|
||||
},
|
||||
labelField: 'ProductName',
|
||||
labelField: 'label',
|
||||
valueField: 'ioTPlatformProductId',
|
||||
immediate: true,
|
||||
afterFetch: (res: any) => {
|
||||
@ -249,26 +236,29 @@ export const editDeviceFormSchemaEdit: any = computed(() => [
|
||||
const data = res.data;
|
||||
|
||||
// 确保返回的是数组格式
|
||||
let items = [];
|
||||
if (Array.isArray(data)) {
|
||||
return data;
|
||||
}
|
||||
// 如果是包装在 items 中的,提取出来
|
||||
if (data && Array.isArray(data.items)) {
|
||||
return data.items;
|
||||
}
|
||||
// 如果是包装在 data 中的,提取出来
|
||||
if (data && Array.isArray(data.data)) {
|
||||
return data.data;
|
||||
items = data;
|
||||
} else if (data && Array.isArray(data.items)) {
|
||||
items = data.items;
|
||||
} else if (data && Array.isArray(data.data)) {
|
||||
items = data.data;
|
||||
}
|
||||
|
||||
// 为每个产品项添加组合标签
|
||||
return items.map((item: any) => ({
|
||||
...item,
|
||||
label: `${item.productName || item.ProductName || ''} (${item.ioTPlatformProductId || ''})`,
|
||||
}));
|
||||
}
|
||||
|
||||
// 如果都不是,返回空数组
|
||||
return [];
|
||||
},
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
||||
placeholder: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`,
|
||||
},
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingAccountName')}`,
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.BelongingProductName')}`,
|
||||
}),
|
||||
},
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
import type { VbenFormProps } from '#/adapter/form';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { h, ref, nextTick } from 'vue';
|
||||
import { h, nextTick, ref } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
import { Page, useVbenModal } from '@vben/common-ui';
|
||||
@ -12,12 +12,13 @@ import { message as Message, Tag } from 'ant-design-vue';
|
||||
import { useVbenForm } from '#/adapter/form';
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
postOneNetProductInsertAsync,
|
||||
postFilesDownload,
|
||||
postFilesUpload,
|
||||
postOneNetProductDeleteAsync,
|
||||
postOneNetProductInsertAsync,
|
||||
postOneNetProductListAsync,
|
||||
postOneNetProductModifyAsync,
|
||||
postFilesUpload,
|
||||
postFilesDownload,
|
||||
postOneNetProductProductStatusChangeAsync,
|
||||
} from '#/api-client';
|
||||
import { TableAction } from '#/components/table-action';
|
||||
import { $t } from '#/locales';
|
||||
@ -26,8 +27,8 @@ import {
|
||||
addProductFormSchema,
|
||||
editProductFormSchemaEdit,
|
||||
querySchema,
|
||||
tableSchema,
|
||||
setFileSelectedCallback,
|
||||
tableSchema,
|
||||
} from './schema';
|
||||
|
||||
defineOptions({
|
||||
@ -148,7 +149,9 @@ const [EditForm, editFormApi] = useVbenForm({
|
||||
async function submit() {
|
||||
const isEdit = !!editRow.value.id;
|
||||
const formApi = isEdit ? editFormApi : addFormApi;
|
||||
const api = isEdit ? postOneNetProductModifyAsync : postOneNetProductInsertAsync;
|
||||
const api = isEdit
|
||||
? postOneNetProductModifyAsync
|
||||
: postOneNetProductInsertAsync;
|
||||
const { valid } = await formApi.validate();
|
||||
if (!valid) return;
|
||||
|
||||
@ -180,7 +183,7 @@ async function submit() {
|
||||
userModalApi.setState({ loading: false, confirmLoading: false });
|
||||
return;
|
||||
}
|
||||
} catch (error) {
|
||||
} catch {
|
||||
Message.error('文件上传失败');
|
||||
userModalApi.setState({ loading: false, confirmLoading: false });
|
||||
return;
|
||||
@ -237,7 +240,9 @@ const openAddModal = async () => {
|
||||
// 删除函数
|
||||
async function onDel(record: any) {
|
||||
try {
|
||||
const resp = await postOneNetProductDeleteAsync({ body: { id: record.id } });
|
||||
const resp = await postOneNetProductDeleteAsync({
|
||||
body: { id: record.id },
|
||||
});
|
||||
if (resp.data) {
|
||||
Message.success($t('common.deleteSuccess'));
|
||||
// 重置文件选择
|
||||
@ -266,24 +271,46 @@ async function onDownloadFile(record: any) {
|
||||
const url = window.URL.createObjectURL(new Blob([data as Blob]));
|
||||
const link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.setAttribute('download', record.deviceThingModelFileName || 'device-model-file');
|
||||
link.setAttribute(
|
||||
'download',
|
||||
record.deviceThingModelFileName || 'device-model-file',
|
||||
);
|
||||
document.body.append(link);
|
||||
link.click();
|
||||
link.remove();
|
||||
window.URL.revokeObjectURL(url);
|
||||
Message.success('文件下载成功');
|
||||
} catch (error) {
|
||||
} catch {
|
||||
Message.error('文件下载失败');
|
||||
}
|
||||
}
|
||||
|
||||
// 状态更改函数
|
||||
async function onStatusChange(record: any) {
|
||||
try {
|
||||
const resp = await postOneNetProductProductStatusChangeAsync({
|
||||
body: {
|
||||
id: record.id,
|
||||
enabled: !record.isEnabled,
|
||||
},
|
||||
});
|
||||
if (resp.data) {
|
||||
Message.success(record.isEnabled ? '禁用成功' : '启用成功');
|
||||
gridApi.reload();
|
||||
} else {
|
||||
Message.error(record.isEnabled ? '禁用失败' : '启用失败');
|
||||
}
|
||||
} catch {
|
||||
Message.error(record.isEnabled ? '禁用失败' : '启用失败');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<Grid>
|
||||
<template #toolbar-actions>
|
||||
<TableAction
|
||||
:actions="[
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.add'),
|
||||
type: 'primary',
|
||||
@ -291,34 +318,26 @@ async function onDownloadFile(record: any) {
|
||||
onClick: openAddModal.bind(null),
|
||||
auth: ['AbpIdentity.Users.Create'],
|
||||
},
|
||||
]"
|
||||
/>
|
||||
]" />
|
||||
</template>
|
||||
|
||||
<template #isEnable="{ row }">
|
||||
<component
|
||||
:is="
|
||||
h(Tag, { color: row.enabled ? 'green' : 'red' }, () =>
|
||||
row.enabled ? $t('common.yes') : $t('common.no'),
|
||||
<component :is="h(Tag, { color: row.isEnabled ? 'green' : 'red' }, () =>
|
||||
row.isEnabled ? $t('common.yes') : $t('common.no'),
|
||||
)
|
||||
"
|
||||
/>
|
||||
" />
|
||||
</template>
|
||||
|
||||
<template #deviceThingModelFileName="{ row }">
|
||||
<a
|
||||
v-if="row.deviceThingModelFileName && row.deviceThingModelFileId"
|
||||
@click="onDownloadFile(row)"
|
||||
style="color: #1890ff; cursor: pointer; text-decoration: underline;"
|
||||
>
|
||||
<a v-if="row.deviceThingModelFileName && row.deviceThingModelFileId" @click="onDownloadFile(row)"
|
||||
style="color: #1890ff; text-decoration: underline; cursor: pointer">
|
||||
{{ row.deviceThingModelFileName }}
|
||||
</a>
|
||||
<span v-else>{{ row.deviceThingModelFileName || '-' }}</span>
|
||||
</template>
|
||||
|
||||
<template #action="{ row }">
|
||||
<TableAction
|
||||
:actions="[
|
||||
<TableAction :actions="[
|
||||
{
|
||||
label: $t('common.edit'),
|
||||
type: 'link',
|
||||
@ -326,8 +345,18 @@ async function onDownloadFile(record: any) {
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
onClick: onEdit.bind(null, row),
|
||||
},
|
||||
]"
|
||||
:drop-down-actions="[
|
||||
{
|
||||
label: row.isEnabled ? '禁用' : '启用',
|
||||
type: 'link',
|
||||
danger: row.isEnabled,
|
||||
size: 'small',
|
||||
auth: ['AbpIdentity.Users.Update'],
|
||||
popConfirm: {
|
||||
title: `确定要${row.isEnabled ? '禁用' : '启用'}该产品吗?`,
|
||||
confirm: onStatusChange.bind(null, row),
|
||||
},
|
||||
},
|
||||
]" :drop-down-actions="[
|
||||
{
|
||||
label: $t('common.delete'),
|
||||
icon: 'ant-design:delete-outlined',
|
||||
@ -338,14 +367,10 @@ async function onDownloadFile(record: any) {
|
||||
confirm: onDel.bind(null, row),
|
||||
},
|
||||
},
|
||||
]"
|
||||
/>
|
||||
]" />
|
||||
</template>
|
||||
</Grid>
|
||||
<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" />
|
||||
</UserModal>
|
||||
</Page>
|
||||
|
||||
@ -4,7 +4,7 @@ import { computed, h } from 'vue';
|
||||
|
||||
import { z } from '@vben/common-ui';
|
||||
|
||||
import { postOneNetAccountListAsync, postFilesUpload } from '#/api-client';
|
||||
import { postOneNetAccountListAsync } from '#/api-client';
|
||||
import { $t } from '#/locales';
|
||||
|
||||
export const querySchema = computed(() => [
|
||||
@ -53,6 +53,82 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
minWidth: '150',
|
||||
slots: { default: 'deviceThingModelFileName' },
|
||||
},
|
||||
{
|
||||
field: 'productCreateTime',
|
||||
title: $t('abp.OneNETManagement.IoTPlatformProductCreateTime'),
|
||||
minWidth: '150',
|
||||
formatter: ({ cellValue }: any) => {
|
||||
if (!cellValue) return '-';
|
||||
const date = new Date(cellValue);
|
||||
if (isNaN(date.getTime())) return '-';
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
}).replace(/\//g, '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'productUpdateTime',
|
||||
title: $t('abp.OneNETManagement.IoTPlatformProductUpdateTime'),
|
||||
minWidth: '150',
|
||||
formatter: ({ cellValue }: any) => {
|
||||
if (!cellValue) return '-';
|
||||
const date = new Date(cellValue);
|
||||
if (isNaN(date.getTime())) return '-';
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
}).replace(/\//g, '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'creationTime',
|
||||
title: $t('abp.OneNETManagement.CreationTime'),
|
||||
minWidth: '150',
|
||||
formatter: ({ cellValue }: any) => {
|
||||
if (!cellValue) return '-';
|
||||
const date = new Date(cellValue);
|
||||
if (isNaN(date.getTime())) return '-';
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
}).replace(/\//g, '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'lastModificationTime',
|
||||
title: $t('abp.OneNETManagement.LastModificationTime'),
|
||||
minWidth: '150',
|
||||
formatter: ({ cellValue }: any) => {
|
||||
if (!cellValue) return '-';
|
||||
const date = new Date(cellValue);
|
||||
if (isNaN(date.getTime())) return '-';
|
||||
return date.toLocaleString('zh-CN', {
|
||||
year: 'numeric',
|
||||
month: '2-digit',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false,
|
||||
}).replace(/\//g, '-');
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'isEnabled',
|
||||
title: $t('common.isEnable'),
|
||||
@ -63,7 +139,7 @@ export const tableSchema: any = computed((): VxeGridProps['columns'] => [
|
||||
title: $t('common.action'),
|
||||
field: 'action',
|
||||
fixed: 'right',
|
||||
width: '150',
|
||||
width: '200',
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
]);
|
||||
@ -161,23 +237,32 @@ export const addProductFormSchema: any = computed(() => [
|
||||
componentProps: {
|
||||
placeholder: '请选择文件',
|
||||
readonly: true,
|
||||
addonAfter: h('button', {
|
||||
addonAfter: h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
style: 'border: none; background: #1890ff; color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer;',
|
||||
style:
|
||||
'border: none; background: #1890ff; color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer;',
|
||||
onClick: () => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.json,.xlsx,.xls';
|
||||
input.onchange = (e: any) => {
|
||||
input.addEventListener('change', (e: any) => {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
// 只显示文件名,不上传
|
||||
const currentInput = document.querySelector('input[placeholder="请选择文件"]') as HTMLInputElement;
|
||||
const currentInput = document.querySelector(
|
||||
'input[placeholder="请选择文件"]',
|
||||
) as HTMLInputElement;
|
||||
if (currentInput) {
|
||||
currentInput.value = file.name;
|
||||
// 触发change事件
|
||||
currentInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
currentInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
currentInput.dispatchEvent(
|
||||
new Event('input', { bubbles: true }),
|
||||
);
|
||||
currentInput.dispatchEvent(
|
||||
new Event('change', { bubbles: true }),
|
||||
);
|
||||
|
||||
// 存储文件对象到全局变量,用于后续上传
|
||||
selectedFile = file;
|
||||
@ -186,12 +271,20 @@ export const addProductFormSchema: any = computed(() => [
|
||||
_onFileSelected(file);
|
||||
}
|
||||
}
|
||||
console.log('文件已选择:', file.name, '大小:', file.size, '字节');
|
||||
console.log(
|
||||
'文件已选择:',
|
||||
file.name,
|
||||
'大小:',
|
||||
file.size,
|
||||
'字节',
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
input.click();
|
||||
}
|
||||
}, '选择文件'),
|
||||
},
|
||||
},
|
||||
'选择文件',
|
||||
),
|
||||
},
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.DeviceThingModelFileName')}`,
|
||||
@ -299,23 +392,32 @@ export const editProductFormSchemaEdit: any = computed(() => [
|
||||
componentProps: {
|
||||
placeholder: '请选择文件',
|
||||
readonly: true,
|
||||
addonAfter: h('button', {
|
||||
addonAfter: h(
|
||||
'button',
|
||||
{
|
||||
type: 'button',
|
||||
style: 'border: none; background: #1890ff; color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer;',
|
||||
style:
|
||||
'border: none; background: #1890ff; color: white; padding: 4px 8px; border-radius: 4px; cursor: pointer;',
|
||||
onClick: () => {
|
||||
const input = document.createElement('input');
|
||||
input.type = 'file';
|
||||
input.accept = '.json,.xlsx,.xls';
|
||||
input.onchange = (e: any) => {
|
||||
input.addEventListener('change', (e: any) => {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
// 只显示文件名,不上传
|
||||
const currentInput = document.querySelector('input[placeholder="请选择文件"]') as HTMLInputElement;
|
||||
const currentInput = document.querySelector(
|
||||
'input[placeholder="请选择文件"]',
|
||||
) as HTMLInputElement;
|
||||
if (currentInput) {
|
||||
currentInput.value = file.name;
|
||||
// 触发change事件
|
||||
currentInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
currentInput.dispatchEvent(new Event('change', { bubbles: true }));
|
||||
currentInput.dispatchEvent(
|
||||
new Event('input', { bubbles: true }),
|
||||
);
|
||||
currentInput.dispatchEvent(
|
||||
new Event('change', { bubbles: true }),
|
||||
);
|
||||
|
||||
// 存储文件对象到全局变量,用于后续上传
|
||||
selectedFile = file;
|
||||
@ -324,12 +426,20 @@ export const editProductFormSchemaEdit: any = computed(() => [
|
||||
_onFileSelected(file);
|
||||
}
|
||||
}
|
||||
console.log('文件已选择:', file.name, '大小:', file.size, '字节');
|
||||
console.log(
|
||||
'文件已选择:',
|
||||
file.name,
|
||||
'大小:',
|
||||
file.size,
|
||||
'字节',
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
input.click();
|
||||
}
|
||||
}, '选择文件'),
|
||||
},
|
||||
},
|
||||
'选择文件',
|
||||
),
|
||||
},
|
||||
rules: z.string().min(1, {
|
||||
message: `${$t('common.pleaseSelect')}${$t('abp.OneNETManagement.DeviceThingModelFileName')}`,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user