Commit 8a5dc05f77d216480c7cf0649a99e9b20b50d673

Authored by fengtao
1 parent 56f2df68

pref:更换场景联动设备列表接口

... ... @@ -76,9 +76,10 @@ export const deleteDevice = (ids: string[]) => {
76 76 * 查询设备配置
77 77 * @param params pageSize page name
78 78 */
79   -export const deviceProfile = () => {
  79 +export const deviceProfile = (params) => {
80 80 return defHttp.get({
81 81 url: DeviceManagerApi.DEVICE_PROFILE_URL_ME,
  82 + params,
82 83 });
83 84 };
84 85
... ...
... ... @@ -21,7 +21,7 @@ enum ScreenManagerApi {
21 21 // GET_ATTRBUTELIST = '/device/keys',
22 22 GET_ATTRBUTELIST = '/device/attributes/',
23 23 ALARM_PROFILE = '/alarm/profile/',
24   - MASTER_GET_DEVICE = '/device/list/master',
  24 + MASTER_GET_DEVICE = '/device/list',
25 25 }
26 26
27 27 /**
... ... @@ -125,8 +125,8 @@ export const byOrganizationIdGetMasterDevice = (params: {
125 125 }) => {
126 126 const { organizationId, deviceProfileId } = params;
127 127 return defHttp.get({
128   - url: `${ScreenManagerApi.MASTER_GET_DEVICE}/${organizationId}`,
129   - params: { deviceProfileId },
  128 + url: `${ScreenManagerApi.MASTER_GET_DEVICE}`,
  129 + params: { deviceProfileId, organizationId },
130 130 });
131 131 };
132 132 //TODO-fengtao
... ...
... ... @@ -245,6 +245,7 @@
245 245 operationType: trigger?.triggerCondition?.condition?.condition[0]?.valueType,
246 246 detail: trigger?.triggerCondition?.alarmDetails,
247 247 entityId: trigger?.entityId,
  248 + deviceType: trigger?.deviceType,
248 249 deviceProfileId: trigger?.deviceProfileId,
249 250 replaceValue: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
250 251 time: trigger?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
... ... @@ -325,6 +326,7 @@
325 326 operationType: condition?.triggerCondition?.condition?.condition[0]?.valueType,
326 327 detail: condition?.triggerCondition?.alarmDetails,
327 328 entityId: condition?.entityId,
  329 + deviceType: condition?.deviceType,
328 330 deviceProfileId: condition?.deviceProfileId,
329 331 replaceValue: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
330 332 time: condition?.triggerCondition?.condition?.spec?.predicate?.defaultValue,
... ... @@ -397,6 +399,7 @@
397 399 deviceId: action.deviceId,
398 400 alarm_config: action.alarmProfileId,
399 401 alarm_level: action.doContext.alarmLevel,
  402 + deviceType: action.deviceType,
400 403 });
401 404 // 如果是设备输出设置脚本值
402 405 if (action.outTarget === 'DEVICE_OUT') {
... ... @@ -436,6 +439,7 @@
436 439 .valueType,
437 440 detail: action.doContext.clearRule[index].triggerCondition.alarmDetails,
438 441 entityId: action.doContext.clearRule[index].entityId,
  442 + deviceType: action.doContext.clearRule[index].entityId?.deviceType,
439 443 deviceProfileId: action.doContext.clearRule[index]?.deviceProfileId,
440 444 replaceValue:
441 445 action.doContext.clearRule[index].triggerCondition.condition.spec.predicate
... ...
... ... @@ -193,6 +193,7 @@ export const trigger_condition_schema: FormSchema[] = [
193 193 field: 'triggered',
194 194 label: '',
195 195 component: 'Select',
  196 + defaultValue: 'SIMPLE',
196 197 componentProps: {
197 198 placeholder: '请选择触发类型',
198 199 options: [
... ... @@ -204,14 +205,44 @@ export const trigger_condition_schema: FormSchema[] = [
204 205 colProps: { span: 6 },
205 206 },
206 207 {
207   - field: 'deviceProfileId',
  208 + field: 'deviceType',
208 209 label: '',
209 210 component: 'ApiSelect',
210 211 colProps: { span: 6 },
  212 + defaultValue: 'SENSOR',
211 213 componentProps: ({ formActionType }) => {
  214 + const { setFieldsValue } = formActionType;
  215 + return {
  216 + api: findDictItemByCode,
  217 + params: {
  218 + dictCode: 'device_type',
  219 + },
  220 + placeholder: '请选择类型',
  221 + labelField: 'itemText',
  222 + valueField: 'itemValue',
  223 + getPopupContainer: () => document.body,
  224 + onChange(e) {
  225 + if (e) {
  226 + setFieldsValue({ deviceProfileId: '' });
  227 + }
  228 + },
  229 + };
  230 + },
  231 + },
  232 + {
  233 + field: 'deviceProfileId',
  234 + label: '',
  235 + component: 'ApiSelect',
  236 + colProps: { span: 6 },
  237 + componentProps: ({ formActionType, formModel }) => {
212 238 const { updateSchema, setFieldsValue } = formActionType;
  239 + const deviceType = formModel['deviceType'];
213 240 return {
214 241 api: deviceProfile,
  242 + params: {
  243 + deviceType,
  244 + },
  245 + showSearch: true,
215 246 placeholder: '请选择产品',
216 247 labelField: 'name',
217 248 valueField: 'id',
... ... @@ -372,14 +403,38 @@ export const actionSchema: FormSchema[] = [
372 403 colProps: { span: 6 },
373 404 },
374 405 {
  406 + field: 'deviceType',
  407 + label: '',
  408 + component: 'ApiSelect',
  409 + colProps: { span: 6 },
  410 + defaultValue: 'SENSOR',
  411 + componentProps: () => {
  412 + return {
  413 + api: findDictItemByCode,
  414 + params: {
  415 + dictCode: 'device_type',
  416 + },
  417 + placeholder: '请选择类型',
  418 + labelField: 'itemText',
  419 + valueField: 'itemValue',
  420 + getPopupContainer: () => document.body,
  421 + };
  422 + },
  423 + ifShow: ({ values }) => isDeviceOut(values.outTarget),
  424 + },
  425 + {
375 426 field: 'deviceProfileId',
376 427 label: '',
377 428 component: 'ApiSelect',
378 429 colProps: { span: 6 },
379   - componentProps: ({ formActionType }) => {
  430 + componentProps: ({ formActionType, formModel }) => {
380 431 const { setFieldsValue } = formActionType;
  432 + const deviceType = formModel['deviceType'];
381 433 return {
382 434 api: deviceProfile,
  435 + params: {
  436 + deviceType,
  437 + },
383 438 placeholder: '请选择产品',
384 439 labelField: 'name',
385 440 valueField: 'id',
... ...
... ... @@ -18,6 +18,7 @@ export const genTriggerOrConditionData = (triggerData) => {
18 18 timeUnit,
19 19 replaceValue,
20 20 deviceProfileId,
  21 + deviceType,
21 22 } = triggerData;
22 23 const mapPredicate = predicate?.map((item) => {
23 24 return {
... ... @@ -45,6 +46,7 @@ export const genTriggerOrConditionData = (triggerData) => {
45 46 triggerType,
46 47 entityType: device,
47 48 entityId: entityId?.length ? entityId : null,
  49 + deviceType,
48 50 triggerCondition: {
49 51 alarmDetails: detail,
50 52 condition: {
... ... @@ -83,6 +85,7 @@ export const genActionData = (actionData) => {
83 85 callType,
84 86 service,
85 87 thingsModelId,
  88 + deviceType,
86 89 } = actionData;
87 90 const clearRule = clearRules.map((item) => {
88 91 const mapPredicate = item.predicate.map((pred) => {
... ... @@ -117,6 +120,7 @@ export const genActionData = (actionData) => {
117 120 triggerType: item.triggerType,
118 121 entityType: item.device,
119 122 entityId: item.device === 'PART' ? item.entityId : null,
  123 + deviceType,
120 124 deviceProfileId: item.deviceProfileId,
121 125 triggerCondition: {
122 126 alarmDetails: item.detail,
... ... @@ -138,6 +142,7 @@ export const genActionData = (actionData) => {
138 142 {
139 143 alarmProfileId: alarm_config,
140 144 outTarget,
  145 + deviceType,
141 146 entityType: device ?? 'ALL',
142 147 deviceId: device === 'PART' ? deviceId : null,
143 148 deviceProfileId,
... ...