Commit cda77963a7c40093ad2b191232c137f1d802c8c2
1 parent
5e5c176e
fix:修复设备配置点击默认新增返回400问题,fix:修改通知管理status为0,1,和添加按钮权限
Showing
11 changed files
with
186 additions
and
29 deletions
... | ... | @@ -53,9 +53,9 @@ export const columns: BasicColumn[] = [ |
53 | 53 | .then(() => { |
54 | 54 | record.status = newStatus; |
55 | 55 | if (record.status == 1) { |
56 | - createMessage.success(`配置成功`); | |
56 | + createMessage.success(`已配置`); | |
57 | 57 | } else { |
58 | - createMessage.error('未配置成功'); | |
58 | + createMessage.error('未配置'); | |
59 | 59 | } |
60 | 60 | }) |
61 | 61 | .finally(() => { |
... | ... | @@ -131,7 +131,7 @@ export const formSchema: FormSchema[] = [ |
131 | 131 | field: 'organizationId', |
132 | 132 | label: '所属组织', |
133 | 133 | component: 'ApiTreeSelect', |
134 | - // required: true, | |
134 | + required: true, | |
135 | 135 | componentProps: { |
136 | 136 | api: async () => { |
137 | 137 | const data = await getOrganizationList(); | ... | ... |
... | ... | @@ -77,7 +77,7 @@ |
77 | 77 | let transportTypeObj = reactive({ |
78 | 78 | transportType: '', |
79 | 79 | }); |
80 | - const profileDataObj = reactive({ | |
80 | + let profileDataObj = reactive({ | |
81 | 81 | profileData: null, |
82 | 82 | }); |
83 | 83 | |
... | ... | @@ -142,7 +142,8 @@ |
142 | 142 | let getPic = null; |
143 | 143 | getStepTwoData = await proxy.$refs.DeviceProfileStep2Ref?.getStep2DataFunc(); |
144 | 144 | profileDataObj.profileData = getStepTwoData; |
145 | - transportTypeObj.transportType = getStepTwoData.transportConfiguration.type; | |
145 | + transportTypeObj.transportType = getStepTwoData?.transportConfiguration?.transportType; | |
146 | + delete profileDataObj?.profileData?.transportConfiguration?.transportType; | |
146 | 147 | //没有点击下一步 |
147 | 148 | if (!isNextStatus.value) { |
148 | 149 | const getStep1Obj = await proxy.$refs.DeviceProfileStep1Ref?.getStep1Func(); |
... | ... | @@ -153,6 +154,10 @@ |
153 | 154 | }; |
154 | 155 | } |
155 | 156 | const id = isUpdate.value == 1 ? '' : postEditId.value; |
157 | + | |
158 | + if (Object.keys(getStepTwoData?.transportConfiguration).length == 0) { | |
159 | + profileDataObj.profileData = null; | |
160 | + } | |
156 | 161 | postDeviceConfogData = { |
157 | 162 | ...getStepOneData, |
158 | 163 | ...profileDataObj, |
... | ... | @@ -162,6 +167,7 @@ |
162 | 167 | if (isUpdate.value == 1) { |
163 | 168 | delete postDeviceConfogData.id; |
164 | 169 | } |
170 | + | |
165 | 171 | await deviceConfigAddOrEdit(postDeviceConfogData); |
166 | 172 | createMessage.success(isUpdate.value == 1 ? '新增' + '成功' : '编辑' + '成功'); |
167 | 173 | closeModal(); | ... | ... |
... | ... | @@ -81,7 +81,7 @@ |
81 | 81 | async function customResetFunc() { |
82 | 82 | emit('prev'); |
83 | 83 | } |
84 | - watch(isChangeType, async (v) => { | |
84 | + watch(isChangeType, (v) => { | |
85 | 85 | isMqttType.value = v; |
86 | 86 | }); |
87 | 87 | const getStep2DataFunc = async () => { |
... | ... | @@ -92,6 +92,7 @@ |
92 | 92 | step2Data.transportConfiguration = { |
93 | 93 | ...getMqttVal, |
94 | 94 | ...getCoapVal, |
95 | + ...val, | |
95 | 96 | }; |
96 | 97 | return step2Data; |
97 | 98 | }; | ... | ... |
... | ... | @@ -254,3 +254,51 @@ export const CoapSchemas: FormSchema[] = [ |
254 | 254 | isProtobuf(values.transportPayloadType) && !isEfentoNb(values.coapDeviceType), |
255 | 255 | }, |
256 | 256 | ]; |
257 | + | |
258 | +export const deviceTelemetryProtoSchemaData = ` | |
259 | +syntax ="proto3"; | |
260 | +package telemetry; | |
261 | + | |
262 | +message SensorDataReading { | |
263 | + optional double temperature = 1; | |
264 | + optional double humidity = 2; | |
265 | + InnerObject innerObject = 3; | |
266 | + message InnerObject { | |
267 | + optional string key1 = 1; | |
268 | + optional bool key2 = 2; | |
269 | + optional double key3 = 3; | |
270 | + optional int32 key4 = 4; | |
271 | + optional string key5 = 5; | |
272 | + } | |
273 | +} | |
274 | +`; | |
275 | + | |
276 | +export const deviceAttributesProtoSchemaData = ` | |
277 | +syntax ="proto3"; | |
278 | +package attributes; | |
279 | + | |
280 | +message SensorConfiguration { | |
281 | + optional string firmwareVersion = 1; | |
282 | + optional string serialNumber = 2; | |
283 | +} | |
284 | +`; | |
285 | + | |
286 | +export const deviceRpcRequestProtoSchemaData = ` | |
287 | +syntax ="proto3"; | |
288 | +package rpc; | |
289 | + | |
290 | +message RpcRequestMsg { | |
291 | + optional string method = 1; | |
292 | + optional int32 requestId = 2; | |
293 | + optional string params = 3; | |
294 | +} | |
295 | +`; | |
296 | + | |
297 | +export const deviceRpcResponseProtoSchemaData = ` | |
298 | +syntax ="proto3"; | |
299 | +package rpc; | |
300 | + | |
301 | +message RpcResponseMsg { | |
302 | + optional string payload = 1; | |
303 | +} | |
304 | +`; | ... | ... |
... | ... | @@ -16,7 +16,13 @@ |
16 | 16 | <script lang="ts"> |
17 | 17 | import { defineComponent, reactive } from 'vue'; |
18 | 18 | import { BasicForm, useForm } from '/@/components/Form'; |
19 | - import { CoapSchemas } from './Coap'; | |
19 | + import { | |
20 | + CoapSchemas, | |
21 | + deviceTelemetryProtoSchemaData, | |
22 | + deviceAttributesProtoSchemaData, | |
23 | + deviceRpcRequestProtoSchemaData, | |
24 | + deviceRpcResponseProtoSchemaData, | |
25 | + } from './Coap'; | |
20 | 26 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
21 | 27 | |
22 | 28 | export default defineComponent({ |
... | ... | @@ -69,16 +75,28 @@ |
69 | 75 | pagingTransmissionWindow: v.clientSettings?.pagingTransmissionWindow, |
70 | 76 | deviceTelemetryProtoSchema: |
71 | 77 | v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration |
72 | - ?.deviceTelemetryProtoSchema, | |
78 | + ?.deviceTelemetryProtoSchema == null | |
79 | + ? deviceTelemetryProtoSchemaData | |
80 | + : v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration | |
81 | + ?.deviceTelemetryProtoSchema, | |
73 | 82 | deviceAttributesProtoSchema: |
74 | 83 | v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration |
75 | - ?.deviceAttributesProtoSchema, | |
84 | + ?.deviceAttributesProtoSchema == null | |
85 | + ? deviceAttributesProtoSchemaData | |
86 | + : v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration | |
87 | + ?.deviceAttributesProtoSchema, | |
76 | 88 | deviceRpcRequestProtoSchema: |
77 | 89 | v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration |
78 | - ?.deviceRpcRequestProtoSchema, | |
90 | + ?.deviceRpcRequestProtoSchema == null | |
91 | + ? deviceRpcRequestProtoSchemaData | |
92 | + : v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration | |
93 | + ?.deviceRpcRequestProtoSchema, | |
79 | 94 | deviceRpcResponseProtoSchema: |
80 | 95 | v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration |
81 | - ?.deviceRpcResponseProtoSchema, | |
96 | + ?.deviceRpcResponseProtoSchema == null | |
97 | + ? deviceRpcResponseProtoSchemaData | |
98 | + : v?.coapDeviceTypeConfiguration?.transportPayloadTypeConfiguration | |
99 | + ?.deviceRpcResponseProtoSchema, | |
82 | 100 | }); |
83 | 101 | }; |
84 | 102 | const customClearStepTwoValueFunc = () => { | ... | ... |
... | ... | @@ -57,7 +57,7 @@ export const MqttSchemas: FormSchema[] = [ |
57 | 57 | { |
58 | 58 | field: 'transportPayloadType', |
59 | 59 | component: 'Select', |
60 | - label: '设备Payload', | |
60 | + label: '设备信息', | |
61 | 61 | defaultValue: 'JSON', |
62 | 62 | componentProps: { |
63 | 63 | options: [ |
... | ... | @@ -180,3 +180,51 @@ export const MqttSchemas: FormSchema[] = [ |
180 | 180 | ifShow: ({ values }) => isProtobuf(values.transportPayloadType), |
181 | 181 | }, |
182 | 182 | ]; |
183 | + | |
184 | +export const deviceTelemetryProtoSchemaData = ` | |
185 | +syntax ="proto3"; | |
186 | +package telemetry; | |
187 | + | |
188 | +message SensorDataReading { | |
189 | + optional double temperature = 1; | |
190 | + optional double humidity = 2; | |
191 | + InnerObject innerObject = 3; | |
192 | + message InnerObject { | |
193 | + optional string key1 = 1; | |
194 | + optional bool key2 = 2; | |
195 | + optional double key3 = 3; | |
196 | + optional int32 key4 = 4; | |
197 | + optional string key5 = 5; | |
198 | + } | |
199 | +} | |
200 | +`; | |
201 | + | |
202 | +export const deviceAttributesProtoSchemaData = ` | |
203 | +syntax ="proto3"; | |
204 | +package attributes; | |
205 | + | |
206 | +message SensorConfiguration { | |
207 | + optional string firmwareVersion = 1; | |
208 | + optional string serialNumber = 2; | |
209 | +} | |
210 | +`; | |
211 | + | |
212 | +export const deviceRpcRequestProtoSchemaData = ` | |
213 | +syntax ="proto3"; | |
214 | +package rpc; | |
215 | + | |
216 | +message RpcRequestMsg { | |
217 | + optional string method = 1; | |
218 | + optional int32 requestId = 2; | |
219 | + optional string params = 3; | |
220 | +} | |
221 | +`; | |
222 | + | |
223 | +export const deviceRpcResponseProtoSchemaData = ` | |
224 | +syntax ="proto3"; | |
225 | +package rpc; | |
226 | + | |
227 | +message RpcResponseMsg { | |
228 | + optional string payload = 1; | |
229 | +} | |
230 | +`; | ... | ... |
... | ... | @@ -16,7 +16,13 @@ |
16 | 16 | <script lang="ts"> |
17 | 17 | import { defineComponent, reactive } from 'vue'; |
18 | 18 | import { BasicForm, useForm } from '/@/components/Form'; |
19 | - import { MqttSchemas } from './Mqtt'; | |
19 | + import { | |
20 | + MqttSchemas, | |
21 | + deviceTelemetryProtoSchemaData, | |
22 | + deviceAttributesProtoSchemaData, | |
23 | + deviceRpcRequestProtoSchemaData, | |
24 | + deviceRpcResponseProtoSchemaData, | |
25 | + } from './Mqtt'; | |
20 | 26 | import { Alert, Divider, Descriptions } from 'ant-design-vue'; |
21 | 27 | |
22 | 28 | export default defineComponent({ |
... | ... | @@ -56,13 +62,21 @@ |
56 | 62 | setFieldsValue({ |
57 | 63 | transportPayloadType: v?.transportPayloadTypeConfiguration?.transportPayloadType, |
58 | 64 | deviceTelemetryProtoSchema: |
59 | - v?.transportPayloadTypeConfiguration?.deviceTelemetryProtoSchema, | |
65 | + v?.transportPayloadTypeConfiguration?.deviceTelemetryProtoSchema == null | |
66 | + ? deviceTelemetryProtoSchemaData | |
67 | + : v?.transportPayloadTypeConfiguration?.deviceTelemetryProtoSchema, | |
60 | 68 | deviceAttributesProtoSchema: |
61 | - v?.transportPayloadTypeConfiguration?.deviceAttributesProtoSchema, | |
69 | + v?.transportPayloadTypeConfiguration?.deviceAttributesProtoSchema == null | |
70 | + ? deviceAttributesProtoSchemaData | |
71 | + : v?.transportPayloadTypeConfiguration?.deviceAttributesProtoSchema, | |
62 | 72 | deviceRpcRequestProtoSchema: |
63 | - v?.transportPayloadTypeConfiguration?.deviceRpcRequestProtoSchema, | |
73 | + v?.transportPayloadTypeConfiguration?.deviceRpcRequestProtoSchema == null | |
74 | + ? deviceRpcRequestProtoSchemaData | |
75 | + : v?.transportPayloadTypeConfiguration?.deviceRpcRequestProtoSchema, | |
64 | 76 | deviceRpcResponseProtoSchema: |
65 | - v?.transportPayloadTypeConfiguration?.deviceRpcResponseProtoSchema, | |
77 | + v?.transportPayloadTypeConfiguration?.deviceRpcResponseProtoSchema == null | |
78 | + ? deviceRpcResponseProtoSchemaData | |
79 | + : v?.transportPayloadTypeConfiguration?.deviceRpcResponseProtoSchema, | |
66 | 80 | enableCompatibilityWithJsonPayloadFormat: |
67 | 81 | v?.transportPayloadTypeConfiguration?.enableCompatibilityWithJsonPayloadFormat, |
68 | 82 | useJsonPayloadFormatForDefaultDownlinkTopics: | ... | ... |
... | ... | @@ -6,7 +6,7 @@ import { copyTransFun } from '/@/utils/fnUtils'; |
6 | 6 | import { Tag } from 'ant-design-vue'; |
7 | 7 | |
8 | 8 | export enum IsOrgEnum { |
9 | - IS_ORG_ENUM = '1', | |
9 | + IS_ORG_ENUM = 1, | |
10 | 10 | } |
11 | 11 | export const isOrg = (type: string) => { |
12 | 12 | return type === IsOrgEnum.IS_ORG_ENUM; |
... | ... | @@ -46,7 +46,7 @@ export const columns: BasicColumn[] = [ |
46 | 46 | width: 200, |
47 | 47 | customRender: ({ record }) => { |
48 | 48 | const status = record.status; |
49 | - const enable = status === '已发布' ? '已发布' : status === '草稿' ? '草稿' : '其他'; | |
49 | + const enable = status === 0 ? '已发布' : status === 1 ? '草稿' : '其他'; | |
50 | 50 | const color = enable === '已发布' ? 'green' : enable === '草稿' ? 'yellow' : 'red'; |
51 | 51 | const text = enable === '已发布' ? '已发布' : enable === '草稿' ? '草稿' : '其他'; |
52 | 52 | return h(Tag, { color }, () => text); |
... | ... | @@ -113,8 +113,8 @@ export const formSchema: FormSchema[] = [ |
113 | 113 | componentProps: { |
114 | 114 | placeholder: '接收者', |
115 | 115 | options: [ |
116 | - { label: '全部', value: '0' }, | |
117 | - { label: '组织', value: '1' }, | |
116 | + { label: '全部', value: 0 }, | |
117 | + { label: '组织', value: 1 }, | |
118 | 118 | ], |
119 | 119 | }, |
120 | 120 | }, | ... | ... |
... | ... | @@ -15,21 +15,23 @@ |
15 | 15 | icon: 'ant-design:eye-outlined', |
16 | 16 | onClick: handleView.bind(null, record), |
17 | 17 | ifShow: (_action) => { |
18 | - return record.status === '已发布'; | |
18 | + return record.status === 1 && rolePermission == 'CUSTOMER_USER'; | |
19 | 19 | }, |
20 | 20 | }, |
21 | 21 | { |
22 | 22 | label: '编辑', |
23 | 23 | icon: 'clarity:note-edit-line', |
24 | 24 | onClick: handleEdit.bind(null, record), |
25 | + // auth: 'isTenant' || 'isCustomer', | |
25 | 26 | ifShow: (_action) => { |
26 | - return record.status === '草稿'; | |
27 | + return record.status === 0 && record.creator == userId; | |
27 | 28 | }, |
28 | 29 | }, |
29 | 30 | { |
30 | 31 | label: '删除', |
31 | 32 | icon: 'ant-design:delete-outlined', |
32 | 33 | color: 'error', |
34 | + ifShow: record.creator == userId || record.tenantId == tenantId, | |
33 | 35 | popConfirm: { |
34 | 36 | title: '是否确认删除', |
35 | 37 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
... | ... | @@ -48,7 +50,7 @@ |
48 | 50 | </div> |
49 | 51 | </template> |
50 | 52 | <script lang="ts"> |
51 | - import { defineComponent, ref } from 'vue'; | |
53 | + import { defineComponent, ref, computed } from 'vue'; | |
52 | 54 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
53 | 55 | import { useDrawer } from '/@/components/Drawer'; |
54 | 56 | import NotifyManagerDrawer from './useDrawer.vue'; |
... | ... | @@ -56,13 +58,26 @@ |
56 | 58 | import { columns, searchFormSchema } from './config.d'; |
57 | 59 | import { notifyGetTableApi, notifyDeleteApi } from '/@/api/stationnotification/stationnotifyApi'; |
58 | 60 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
61 | + import { USER_INFO_KEY } from '/@/enums/cacheEnum'; | |
62 | + import { getAuthCache } from '/@/utils/auth'; | |
63 | + import { RoleEnum } from '/@/enums/roleEnum'; | |
64 | + import { usePermission } from '/@/hooks/web/usePermission'; | |
65 | + import { useUserStore } from '/@/store/modules/user'; | |
66 | + | |
59 | 67 | export default defineComponent({ |
60 | 68 | name: 'Notificationmannager', |
61 | 69 | components: { BasicTable, NotifyManagerDrawer, TableAction, tableViewChild }, |
62 | 70 | setup() { |
71 | + const { hasPermission } = usePermission(); | |
72 | + const userStore = useUserStore(); | |
73 | + const isTenant = computed(() => userStore.getRoleList.includes(RoleEnum.TENANT_ADMIN)); | |
74 | + const isCustomer = computed(() => userStore.getRoleList.includes(RoleEnum.CUSTOMER_USER)); | |
75 | + const userInfo: any = getAuthCache(USER_INFO_KEY); | |
76 | + const userId = userInfo.userId; | |
77 | + const tenantId = userInfo.tenantId; | |
78 | + const rolePermission: string = userInfo.roles[0]; | |
63 | 79 | const [registerDrawer, { openDrawer }] = useDrawer(); |
64 | 80 | const [registerAdd, { openDrawer: openDrawerAdd }] = useDrawer(); |
65 | - | |
66 | 81 | // 批量删除 |
67 | 82 | const { hasBatchDelete, handleDeleteOrBatchDelete, selectionOptions } = useBatchDelete( |
68 | 83 | notifyDeleteApi, |
... | ... | @@ -123,6 +138,12 @@ |
123 | 138 | handleSuccess, |
124 | 139 | handleDeleteOrBatchDelete, |
125 | 140 | NotifyManagerDrawerRef, |
141 | + rolePermission, | |
142 | + userId, | |
143 | + tenantId, | |
144 | + hasPermission, | |
145 | + isTenant, | |
146 | + isCustomer, | |
126 | 147 | }; |
127 | 148 | }, |
128 | 149 | }); | ... | ... |
... | ... | @@ -46,8 +46,8 @@ |
46 | 46 | //编辑 |
47 | 47 | if (data.isUpdate) { |
48 | 48 | noticeId.value = data.record.id; |
49 | - Reflect.set(data.record, 'receiverType', data.record.receiverType === '全部' ? '0' : '1'); | |
50 | - if (data.record.receiverType === '1') { | |
49 | + Reflect.set(data.record, 'receiverType', data.record.receiverType === '全部' ? 0 : 1); | |
50 | + if (data.record.receiverType === 1) { | |
51 | 51 | if (!data.record.pointId.length) return; |
52 | 52 | const organizationId = data.record.pointId.split(','); |
53 | 53 | Reflect.set(data.record, 'organizationId', organizationId); |
... | ... | @@ -60,7 +60,7 @@ |
60 | 60 | const valid = await validate(); |
61 | 61 | if (!valid) return; |
62 | 62 | const field = getFieldsValue(); |
63 | - const pointId = field.receiverType === '1' ? field.organizationId + '' : null; | |
63 | + const pointId = field.receiverType === 1 ? field.organizationId + '' : null; | |
64 | 64 | // 新增情况 |
65 | 65 | try { |
66 | 66 | const editNotice = { |
... | ... | @@ -78,7 +78,7 @@ |
78 | 78 | const handleSaveDraft = async () => { |
79 | 79 | await validate(); |
80 | 80 | const field = getFieldsValue(); |
81 | - const pointId = field.receiverType === '1' ? field.organizationId + '' : null; | |
81 | + const pointId = field.receiverType === 1 ? field.organizationId + '' : null; | |
82 | 82 | if (!unref(isUpdate)) { |
83 | 83 | const saveDraft = { |
84 | 84 | ...field, | ... | ... |