|
@@ -21,6 +21,7 @@ import { PermissionButton } from '@/components';
|
|
|
import { onlyMessage } from '@/utils/util';
|
|
import { onlyMessage } from '@/utils/util';
|
|
|
import { message } from 'antd';
|
|
import { message } from 'antd';
|
|
|
import { InstanceModel, service as instanceService } from '@/pages/device/Instance';
|
|
import { InstanceModel, service as instanceService } from '@/pages/device/Instance';
|
|
|
|
|
+import { service as productService } from '@/pages/device/Product';
|
|
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
|
type: MetadataType;
|
|
type: MetadataType;
|
|
@@ -49,7 +50,7 @@ const BaseMetadata = observer((props: Props) => {
|
|
|
|
|
|
|
|
const removeItem = async (record: MetadataItem) => {
|
|
const removeItem = async (record: MetadataItem) => {
|
|
|
const removeDB = () => {
|
|
const removeDB = () => {
|
|
|
- return DB.getDB(param.id).table(`${type}`).delete(record.id!);
|
|
|
|
|
|
|
+ return DB.getDB().table(`${type}`).delete(record.id!);
|
|
|
};
|
|
};
|
|
|
const _currentData = removeMetadata(type, [record], typeMap.get(target), removeDB);
|
|
const _currentData = removeMetadata(type, [record], typeMap.get(target), removeDB);
|
|
|
const result = await asyncUpdateMedata(target, _currentData);
|
|
const result = await asyncUpdateMedata(target, _currentData);
|
|
@@ -129,11 +130,17 @@ const BaseMetadata = observer((props: Props) => {
|
|
|
];
|
|
];
|
|
|
|
|
|
|
|
const initData = useCallback(async () => {
|
|
const initData = useCallback(async () => {
|
|
|
- // resetMetadata()
|
|
|
|
|
- const result = await DB.getDB(param.id).table(`${type}`).toArray();
|
|
|
|
|
- console.log('------sssss--', result);
|
|
|
|
|
-
|
|
|
|
|
- setData(result.sort((a, b) => b?.sortsIndex - a?.sortsIndex));
|
|
|
|
|
|
|
+ // const result = await DB.getDB().table(`${type}`).toArray();
|
|
|
|
|
+ const resp =
|
|
|
|
|
+ target === 'product'
|
|
|
|
|
+ ? await productService.detail(param.id)
|
|
|
|
|
+ : await instanceService.detail(param.id);
|
|
|
|
|
+ if (resp.status === 200) {
|
|
|
|
|
+ InstanceModel.detail = resp?.result || [];
|
|
|
|
|
+ const item = JSON.parse(resp.result?.metadata || '{}');
|
|
|
|
|
+ // console.log(item)
|
|
|
|
|
+ setData(item[type]?.sort((a: any, b: any) => b?.sortsIndex - a?.sortsIndex));
|
|
|
|
|
+ }
|
|
|
}, [param.id, type]);
|
|
}, [param.id, type]);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
@@ -159,7 +166,7 @@ const BaseMetadata = observer((props: Props) => {
|
|
|
// .startsWithAnyOfIgnoreCase(name)
|
|
// .startsWithAnyOfIgnoreCase(name)
|
|
|
// .toArray();
|
|
// .toArray();
|
|
|
// setData(result.sort((a, b) => b?.sortsIndex - a?.sortsIndex));
|
|
// setData(result.sort((a, b) => b?.sortsIndex - a?.sortsIndex));
|
|
|
- const result = await DB.getDB(param.id).table(`${type}`).toArray();
|
|
|
|
|
|
|
+ const result = await DB.getDB().table(`${type}`).toArray();
|
|
|
const arr = result
|
|
const arr = result
|
|
|
.filter((item) => item.name.indexOf(name) > -1)
|
|
.filter((item) => item.name.indexOf(name) > -1)
|
|
|
.sort((a, b) => b?.sortsIndex - a?.sortsIndex);
|
|
.sort((a, b) => b?.sortsIndex - a?.sortsIndex);
|