Commit 9b5298c4716502766226566567afdbb48456c92e
Merge branch 'main_dev' of http://git.yunteng.com/yunteng/thingskit-front into f…
…eat/device-new-protocol
Showing
8 changed files
with
157 additions
and
17 deletions
... | ... | @@ -45,6 +45,7 @@ enum DeviceManagerApi { |
45 | 45 | DEVICE_PUBLIC = '/customer/public/device', |
46 | 46 | |
47 | 47 | DEVICE_PRIVATE = '/customer/device', |
48 | + DEVICE_COLLECT = '/device/collect ', //收藏 | |
48 | 49 | |
49 | 50 | /** |
50 | 51 | * @description 通过设备列表获取设备信息 |
... | ... | @@ -61,6 +62,13 @@ export const devicePage = (params: DeviceQueryParam) => { |
61 | 62 | }); |
62 | 63 | }; |
63 | 64 | |
65 | +export const deviceCollect = (params: Array<any>) => { | |
66 | + return defHttp.post({ | |
67 | + url: `${DeviceManagerApi.DEVICE_COLLECT}`, | |
68 | + params, | |
69 | + }); | |
70 | +}; | |
71 | + | |
64 | 72 | /** |
65 | 73 | * 分页查询设备配置页面 |
66 | 74 | * @param params pageSize page name | ... | ... |
... | ... | @@ -12,7 +12,7 @@ export const columns: BasicColumn[] = [ |
12 | 12 | { |
13 | 13 | title: '状态', |
14 | 14 | dataIndex: 'deviceState', |
15 | - width: 80, | |
15 | + width: 110, | |
16 | 16 | slots: { customRender: 'deviceState' }, |
17 | 17 | }, |
18 | 18 | { |
... | ... | @@ -167,4 +167,17 @@ export const searchFormSchema: FormSchema[] = [ |
167 | 167 | }; |
168 | 168 | }, |
169 | 169 | }, |
170 | + { | |
171 | + field: 'isCollect', | |
172 | + label: '是否收藏', | |
173 | + component: 'Select', | |
174 | + colProps: { span: 6 }, | |
175 | + componentProps: { | |
176 | + options: [ | |
177 | + { label: '是', value: 1 }, | |
178 | + { label: '否', value: 0 }, | |
179 | + ], | |
180 | + placeholder: '请选择', | |
181 | + }, | |
182 | + }, | |
170 | 183 | ]; | ... | ... |
... | ... | @@ -34,6 +34,11 @@ |
34 | 34 | 批量分配 |
35 | 35 | </a-button> |
36 | 36 | </Authority> |
37 | + <!-- <Authority> | |
38 | + <a-button type="primary" @click="handelCollect()" :disabled="!isExistOption"> | |
39 | + 批量收藏 | |
40 | + </a-button> | |
41 | + </Authority> --> | |
37 | 42 | </template> |
38 | 43 | <template #img="{ record }"> |
39 | 44 | <TableImg |
... | ... | @@ -85,7 +90,13 @@ |
85 | 90 | </Tag> |
86 | 91 | </template> |
87 | 92 | <template #deviceState="{ record }"> |
93 | + <!-- <HeartOutlined v-if="!record.isCollect" class="mr-1" style="color: red" /> --> | |
94 | + <Tooltip> | |
95 | + <template #title> 我的收藏</template> | |
96 | + <HeartTwoTone v-if="record.isCollect" class="mr-1" twoToneColor="#3B82F6" /> | |
97 | + </Tooltip> | |
88 | 98 | <Tag |
99 | + :style="{ marginLeft: !record.isCollect ? '17px' : '' }" | |
89 | 100 | :color=" |
90 | 101 | record.deviceState == DeviceState.INACTIVE |
91 | 102 | ? 'warning' |
... | ... | @@ -154,6 +165,18 @@ |
154 | 165 | icon: 'ant-design:rise-outlined', |
155 | 166 | onClick: handleUpAndDownRecord.bind(null, record), |
156 | 167 | }, |
168 | + !record.isCollect | |
169 | + ? { | |
170 | + label: '收藏', | |
171 | + icon: 'ant-design:heart-outlined', | |
172 | + onClick: handelCollect.bind(null, record), | |
173 | + } | |
174 | + : { | |
175 | + label: '取消收藏', | |
176 | + auth: 'api:yt:device:online:record', | |
177 | + icon: 'ant-design:heart-outlined', | |
178 | + onClick: handelCollect.bind(null, record), | |
179 | + }, | |
157 | 180 | { |
158 | 181 | label: '删除', |
159 | 182 | auth: 'api:yt:device:delete', |
... | ... | @@ -195,10 +218,12 @@ |
195 | 218 | } from '/@/api/device/model/deviceModel'; |
196 | 219 | import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table'; |
197 | 220 | import { columns, searchFormSchema } from './config/device.data'; |
198 | - import { Tag, Popover, Popconfirm, Button } from 'ant-design-vue'; | |
221 | + import { Tag, Popover, Popconfirm, Button, Tooltip } from 'ant-design-vue'; | |
222 | + import { HeartTwoTone } from '@ant-design/icons-vue'; | |
199 | 223 | import { |
200 | 224 | deleteDevice, |
201 | 225 | devicePage, |
226 | + deviceCollect, | |
202 | 227 | cancelDispatchCustomer, |
203 | 228 | getGATEWAY, |
204 | 229 | privateDevice, |
... | ... | @@ -244,6 +269,9 @@ |
244 | 269 | Popconfirm, |
245 | 270 | BatchImportModal, |
246 | 271 | Button, |
272 | + // HeartOutlined, | |
273 | + HeartTwoTone, | |
274 | + Tooltip, | |
247 | 275 | }, |
248 | 276 | setup(_) { |
249 | 277 | const { isCustomer } = useAuthDeviceDetail(); |
... | ... | @@ -465,6 +493,26 @@ |
465 | 493 | } catch (error) {} |
466 | 494 | }; |
467 | 495 | |
496 | + // 收藏 && 批量收藏 | |
497 | + const handelCollect = async (record?: Recordable) => { | |
498 | + let ids: string[] = []; | |
499 | + if (record) { | |
500 | + ids.push(record.id); | |
501 | + } else { | |
502 | + ids = await getSelectRowKeys(); | |
503 | + } | |
504 | + try { | |
505 | + setLoading(true); | |
506 | + await deviceCollect(ids); | |
507 | + createMessage.success('操作成功'); | |
508 | + handleReload(); | |
509 | + } catch (error) { | |
510 | + throw error; | |
511 | + } finally { | |
512 | + setLoading(false); | |
513 | + } | |
514 | + }; | |
515 | + | |
468 | 516 | onMounted(() => { |
469 | 517 | const queryParams = ROUTE.query as Record<'deviceProfileId', undefined | string>; |
470 | 518 | const { setFieldsValue } = getForm(); |
... | ... | @@ -492,6 +540,7 @@ |
492 | 540 | copySN, |
493 | 541 | isExistOption, |
494 | 542 | handleDelete, |
543 | + handelCollect, | |
495 | 544 | // hasBatchDelete, |
496 | 545 | // handleDeleteOrBatchDelete, |
497 | 546 | handleReload, | ... | ... |
... | ... | @@ -55,10 +55,18 @@ |
55 | 55 | const { createMessage } = useMessage(); |
56 | 56 | let config = {}; |
57 | 57 | if (values.messageType === 'PHONE_MESSAGE') { |
58 | - config = { | |
59 | - accessKeyId: values.accessKeyId, | |
60 | - accessKeySecret: values.accessKeySecret, | |
61 | - }; | |
58 | + if (values.platformType === 'ALI_CLOUD') { | |
59 | + config = { | |
60 | + accessKeyId: values.accessKeyId, | |
61 | + accessKeySecret: values.accessKeySecret, | |
62 | + }; | |
63 | + } else { | |
64 | + config = { | |
65 | + appId: values.appId, | |
66 | + secretId: values.secretId, | |
67 | + secretKey: values.secretKey, | |
68 | + }; | |
69 | + } | |
62 | 70 | } else if (values.messageType === 'EMAIL_MESSAGE') { |
63 | 71 | config = { |
64 | 72 | host: values.host, | ... | ... |
... | ... | @@ -79,6 +79,9 @@ export const isMessage = (type: string) => { |
79 | 79 | export const isEmail = (type: string) => { |
80 | 80 | return type === MessageEnum.IS_EMAIL; |
81 | 81 | }; |
82 | +export const messageTypeIsTencentCloud = (type: string) => { | |
83 | + return type === 'TENCENT_CLOUD'; | |
84 | +}; | |
82 | 85 | |
83 | 86 | export const formSchema: FormSchema[] = [ |
84 | 87 | { |
... | ... | @@ -121,15 +124,53 @@ export const formSchema: FormSchema[] = [ |
121 | 124 | ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), |
122 | 125 | }, |
123 | 126 | { |
127 | + field: 'appId', | |
128 | + label: 'appId', | |
129 | + required: true, | |
130 | + component: 'Input', | |
131 | + componentProps: { | |
132 | + maxLength: 36, | |
133 | + placeholder: '请输入appId', | |
134 | + }, | |
135 | + ifShow: ({ values }) => messageTypeIsTencentCloud(Reflect.get(values, 'platformType')), | |
136 | + }, | |
137 | + { | |
138 | + field: 'secretId', | |
139 | + label: 'secretId', | |
140 | + required: true, | |
141 | + component: 'Input', | |
142 | + helpMessage: ['腾讯云:API密钥参考地址: https://console.cloud.tencent.com/cam/capi'], | |
143 | + componentProps: { | |
144 | + maxLength: 36, | |
145 | + placeholder: '请输入secretId', | |
146 | + }, | |
147 | + ifShow: ({ values }) => messageTypeIsTencentCloud(Reflect.get(values, 'platformType')), | |
148 | + }, | |
149 | + { | |
150 | + field: 'secretKey', | |
151 | + label: 'secretKey', | |
152 | + required: true, | |
153 | + componentProps: { | |
154 | + maxLength: 36, | |
155 | + placeholder: '请输入secretKey', | |
156 | + }, | |
157 | + | |
158 | + component: 'Input', | |
159 | + ifShow: ({ values }) => messageTypeIsTencentCloud(Reflect.get(values, 'platformType')), | |
160 | + }, | |
161 | + { | |
124 | 162 | field: 'accessKeyId', |
125 | 163 | label: 'accessKeyId', |
126 | 164 | required: true, |
127 | 165 | component: 'Input', |
166 | + helpMessage: ['阿里云:API密钥参考地址:https://ram.console.aliyun.com/manage/ak'], | |
128 | 167 | componentProps: { |
129 | 168 | maxLength: 36, |
130 | 169 | placeholder: '请输入accessKeyId', |
131 | 170 | }, |
132 | - ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
171 | + ifShow: ({ values }) => | |
172 | + isMessage(Reflect.get(values, 'messageType')) && | |
173 | + !messageTypeIsTencentCloud(Reflect.get(values, 'platformType')), | |
133 | 174 | }, |
134 | 175 | { |
135 | 176 | field: 'accessKeySecret', |
... | ... | @@ -141,7 +182,9 @@ export const formSchema: FormSchema[] = [ |
141 | 182 | }, |
142 | 183 | |
143 | 184 | component: 'Input', |
144 | - ifShow: ({ values }) => isMessage(Reflect.get(values, 'messageType')), | |
185 | + ifShow: ({ values }) => | |
186 | + isMessage(Reflect.get(values, 'messageType')) && | |
187 | + !messageTypeIsTencentCloud(Reflect.get(values, 'platformType')), | |
145 | 188 | }, |
146 | 189 | { |
147 | 190 | field: 'host', | ... | ... |
... | ... | @@ -6,7 +6,7 @@ |
6 | 6 | </BasicModal> |
7 | 7 | </template> |
8 | 8 | <script lang="ts"> |
9 | - import { defineComponent } from 'vue'; | |
9 | + import { defineComponent, ref } from 'vue'; | |
10 | 10 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
11 | 11 | import { BasicForm, FormSchema, useForm } from '/@/components/Form/index'; |
12 | 12 | import { sendSms } from '/@/api/message/template'; |
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | label: '短信参数', |
77 | 77 | required: true, |
78 | 78 | componentProps: { |
79 | - placeholder: '示例:{"code":"3654"}', | |
79 | + placeholder: '示例:{"code":"1234"}', | |
80 | 80 | }, |
81 | 81 | dynamicRules: () => { |
82 | 82 | return [ |
... | ... | @@ -90,10 +90,10 @@ |
90 | 90 | if (typeof JSON.parse(value) == 'object') { |
91 | 91 | return Promise.resolve(); |
92 | 92 | } |
93 | - return Promise.reject('请输入JSON格式例如{"code":"123"}'); | |
93 | + return Promise.reject('请输入JSON格式例如{"code":"1234"}'); | |
94 | 94 | } |
95 | 95 | } catch { |
96 | - return Promise.reject('请输入JSON格式例如{"code":"123"}'); | |
96 | + return Promise.reject('请输入JSON格式例如{"code":"1234"}'); | |
97 | 97 | } |
98 | 98 | }, |
99 | 99 | }, |
... | ... | @@ -126,8 +126,9 @@ |
126 | 126 | export default defineComponent({ |
127 | 127 | components: { BasicModal, BasicForm }, |
128 | 128 | setup() { |
129 | + const platformType = ref(''); | |
129 | 130 | const { createMessage } = useMessage(); |
130 | - const [registerForm, { validate, resetFields, setFieldsValue }] = useForm({ | |
131 | + const [registerForm, { validate, resetFields, setFieldsValue, updateSchema }] = useForm({ | |
131 | 132 | labelWidth: 70, |
132 | 133 | schemas, |
133 | 134 | showActionButtonGroup: false, |
... | ... | @@ -136,6 +137,14 @@ |
136 | 137 | }, |
137 | 138 | }); |
138 | 139 | const [register, { closeModal }] = useModalInner(async (data) => { |
140 | + platformType.value = data.record?.messageConfig?.platformType; | |
141 | + updateSchema({ | |
142 | + field: 'params', | |
143 | + componentProps: { | |
144 | + placeholder: | |
145 | + platformType.value !== 'TENCENT_CLOUD' ? '示例:{"code":"1234"}' : '示例:["123456"]', | |
146 | + }, | |
147 | + }); | |
139 | 148 | await resetFields(); |
140 | 149 | await setFieldsValue({ |
141 | 150 | ...data.record, |
... | ... | @@ -143,9 +152,17 @@ |
143 | 152 | }); |
144 | 153 | |
145 | 154 | async function handleOK() { |
155 | + let smsParams: any = null; | |
146 | 156 | const values = await validate(); |
147 | - //将字符串转为json | |
148 | - const smsParams = JSON.parse(Reflect.get(values, 'params')); | |
157 | + if (platformType.value === 'TENCENT_CLOUD') { | |
158 | + //腾讯云发送格式 将字符串转为数组 | |
159 | + smsParams = { | |
160 | + tencent_param: JSON.parse(Reflect.get(values, 'params')), | |
161 | + }; | |
162 | + } else { | |
163 | + //阿里云发送格式 将字符串转为json | |
164 | + smsParams = JSON.parse(Reflect.get(values, 'params')); | |
165 | + } | |
149 | 166 | Reflect.set(values, 'params', smsParams); |
150 | 167 | await sendSms(values); |
151 | 168 | closeModal(); | ... | ... |
... | ... | @@ -247,10 +247,11 @@ export const formSchema: FormSchema[] = [ |
247 | 247 | helpMessage: `告警通知模板平台提供如下参数: |
248 | 248 | { |
249 | 249 | "type":"告警类型", |
250 | - "device_name":"设备名称", | |
250 | + "deviceName":"设备名称", | |
251 | 251 | "severity":"告警等级", |
252 | 252 | "organization":"设备所属组织", |
253 | - "createTime":告警时间 | |
253 | + "createTime":"告警时间", | |
254 | + "triggerValue":"触发值", | |
254 | 255 | }`, |
255 | 256 | }); |
256 | 257 | } else if (value === 'FOR_SET_PASSWORD') { | ... | ... |
... | ... | @@ -50,6 +50,7 @@ |
50 | 50 | label: BusinessConvertScriptTextEnum.BUSINESS_EDIT_TEXT.slice(0, 2), |
51 | 51 | icon: 'clarity:note-edit-line', |
52 | 52 | auth: PermissionConvertScriptEnum.PERMISSION_UPDATE, |
53 | + ifShow: record.status == 0, | |
53 | 54 | onClick: handleBusinessModal.bind( |
54 | 55 | null, |
55 | 56 | BusinessConvertScriptTextEnum.BUSINESS_EDIT_TEXT, | ... | ... |