modelOfMatter.ts
5.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
import { BasicPageParams } from '../model/baseModel';
import {
BatchGetObjectModelItemType,
GetModelTslParams,
ImportModelOfMatterType,
ModelOfMatterItemRecordType,
ModelOfMatterParams,
Tsl,
UpdateSortThingsModeItemType,
} from './model/modelOfMatterModel';
import { FunctionTypeEnum } from '/@/enums/objectModelEnum';
import { defHttp } from '/@/utils/http/axios';
enum ModelOfMatter {
CREATE = '/things_model',
UPDATE = '/things_model',
DELETE = '/things_model',
TSL = '/things_model',
LIST = '/things_model/page',
RELEASE = '/things_model',
IMPORT = '/things_model/import',
GET_MODEL_SERVICE = '/things_model/get_services',
CATEGORY = '/things_model/category',
CATEGORY_IMPORT = '/things_model/categoryImport',
CATEGORY_EXPORT = '/things_model/categoryGetExport',
IMPORT_CSV = '/things_model/csvImport',
EXCEL_EXPORT = '/things_model/download/template',
BATCH_GET_TSL_BY_DEVICE_PROFILES = '/things_model/batch/get_tsl',
UPDATE_SORT = '/things_model/updateSort',
}
export const getModelList = (
params: BasicPageParams & {
deviceProfileId?: string;
functionTyp?: FunctionTypeEnum;
nameOrIdentifier?: string;
selectType?: string | undefined;
orderFiled?: string | undefined;
id?: string;
}
) => {
return defHttp.get<ModelOfMatterItemRecordType[]>({
url: `${ModelOfMatter.LIST}`,
params,
});
};
export const getModelTsl = (params: GetModelTslParams) => {
const { functionType = 'all', deviceProfileId } = params;
return defHttp.get<Tsl[]>({
url: `${ModelOfMatter.TSL}/${functionType}/${deviceProfileId}`,
});
};
export const createModel = (params: Partial<ModelOfMatterParams>) => {
return defHttp.post({
url: ModelOfMatter.CREATE,
params,
});
};
export const updateModel = (params: Partial<ModelOfMatterParams>) => {
return defHttp.put({
url: ModelOfMatter.UPDATE,
params,
});
};
export const deleteModel = (params: string[]) => {
return defHttp.delete({
url: ModelOfMatter.DELETE,
params: {
ids: params,
},
});
};
export const releaseModel = (deviceProfileId: string) => {
return defHttp.put({
url: `${ModelOfMatter.RELEASE}/${deviceProfileId}`,
});
};
export const getModelServices = (params: { deviceProfileId: string }) => {
const { deviceProfileId } = params;
return defHttp.get<ModelOfMatterParams[]>({
url: `${ModelOfMatter.GET_MODEL_SERVICE}/${deviceProfileId}`,
});
};
export const importModelOfMatter = (data: ImportModelOfMatterType) => {
return defHttp.post({
url: ModelOfMatter.IMPORT,
data,
});
};
// 产品品类接口
// 新增
export const createModelCategory = (params: Partial<ModelOfMatterParams>) => {
return defHttp.post({
url: ModelOfMatter.CATEGORY,
params,
});
};
// 修改
export const updateModelCategory = (params: Partial<ModelOfMatterParams>) => {
return defHttp.put({
url: ModelOfMatter.CATEGORY,
params,
});
};
// 删除
export const deleteModelCategory = (params: string[]) => {
return defHttp.delete({
url: ModelOfMatter.CATEGORY,
params: {
ids: params,
},
});
};
// 导入
export const importModelCategory = (data: ImportModelOfMatterType) => {
return defHttp.post({
url: ModelOfMatter.CATEGORY_IMPORT,
data,
});
};
// 导出
export const ExportModelCategory = (params: any) => {
const { functionType, deviceProfileId } = params;
return defHttp.get({
url: `${ModelOfMatter.CATEGORY_EXPORT}/${functionType}/${deviceProfileId}`,
params,
});
};
/**
* 物模型产品品类界面excel导入
*/
export const importCsvCategory = (params: {
categoryId?: string;
deviceProfileId?: string;
file: FormData;
type?: string;
}) => {
const { categoryId, type } = params || {};
return defHttp.post<any>({
url: `${ModelOfMatter.IMPORT_CSV}?categoryId=${categoryId}&type=${type}`,
params: params.file,
});
};
/**
* 物模型产品物模型界面excel导入
*/
export const importCsvDeviceProfileId = (params: {
categoryId?: string;
deviceProfileId?: string;
file: FormData;
type?: string;
}) => {
const { deviceProfileId, type } = params || {};
return defHttp.post<any>({
url: `${ModelOfMatter.IMPORT_CSV}?deviceProfileId=${deviceProfileId}&type=${type}`,
params: params.file,
});
};
/**
* 物模型excel导出模板
*/
export const excelExport = (type?: string) => {
return defHttp.get({
url: `${ModelOfMatter.EXCEL_EXPORT}`,
params: { type },
responseType: 'blob',
});
};
export const batchGetObjectModel = ({
deviceProfileIds,
functionTypeEnum = 'all',
}: {
deviceProfileIds: string[];
functionTypeEnum?: FunctionTypeEnum | 'all';
}) => {
return defHttp.post<BatchGetObjectModelItemType[]>(
{
url: ModelOfMatter.BATCH_GET_TSL_BY_DEVICE_PROFILES,
data: { deviceProfileIds, functionTypeEnum },
},
{ withShareToken: true }
);
};
//物模型排序
export const updateSortThingsModel = (data: UpdateSortThingsModeItemType) => {
return defHttp.post({
url: `${ModelOfMatter.UPDATE_SORT}?id=${data.id}&isCategory=${data.isCategory}&sortType=${data.sortType}`,
});
};