Commit c79a9d7eb238041a261678059aad71a291ba462c
Merge branch 'f-dev' into 'main'
fix:修改Teambition上的任务 See merge request huang/yun-teng-iot-front!247
Showing
8 changed files
with
114 additions
and
131 deletions
| ... | ... | @@ -31,7 +31,7 @@ export const alarmSearchSchemas: FormSchema[] = [ |
| 31 | 31 | }, |
| 32 | 32 | { |
| 33 | 33 | field: 'alarmType', |
| 34 | - label: '告警类型', | |
| 34 | + label: '告警场景', | |
| 35 | 35 | component: 'Input', |
| 36 | 36 | colProps: { span: 6 }, |
| 37 | 37 | componentProps: { |
| ... | ... | @@ -74,7 +74,7 @@ export const alarmColumns: BasicColumn[] = [ |
| 74 | 74 | width: 100, |
| 75 | 75 | }, |
| 76 | 76 | { |
| 77 | - title: '类型', | |
| 77 | + title: '告警场景', | |
| 78 | 78 | dataIndex: 'type', |
| 79 | 79 | width: 160, |
| 80 | 80 | }, |
| ... | ... | @@ -138,7 +138,7 @@ export const alarmSchemasForm: FormSchema[] = [ |
| 138 | 138 | }, |
| 139 | 139 | { |
| 140 | 140 | field: 'type', |
| 141 | - label: '告警类型', | |
| 141 | + label: '告警场景', | |
| 142 | 142 | component: 'Input', |
| 143 | 143 | componentProps: { |
| 144 | 144 | disabled: true, | ... | ... |
| ... | ... | @@ -104,6 +104,13 @@ |
| 104 | 104 | try { |
| 105 | 105 | const { createMessage } = useMessage(); |
| 106 | 106 | const values = await validate(); |
| 107 | + if (values.name == undefined || values.name == '') | |
| 108 | + return createMessage.error('请填写视频名字'); | |
| 109 | + if (values.sn == undefined || values.sn == '') | |
| 110 | + return createMessage.error('请填写摄像头编号'); | |
| 111 | + if (values.videoUrl == undefined || values.videoUrl == '') | |
| 112 | + return createMessage.error('请填写视频流'); | |
| 113 | + if (!values) return; | |
| 107 | 114 | if (tenantLogo.value !== '') { |
| 108 | 115 | values.avatar = tenantLogo.value; |
| 109 | 116 | } | ... | ... |
| ... | ... | @@ -96,7 +96,7 @@ export const alarmSearchSchemas: FormSchema[] = [ |
| 96 | 96 | }, |
| 97 | 97 | { |
| 98 | 98 | field: 'alarmType', |
| 99 | - label: '告警类型', | |
| 99 | + label: '告警场景', | |
| 100 | 100 | component: 'Input', |
| 101 | 101 | colProps: { span: 6 }, |
| 102 | 102 | componentProps: { |
| ... | ... | @@ -125,7 +125,7 @@ export const alarmColumns: BasicColumn[] = [ |
| 125 | 125 | width: 100, |
| 126 | 126 | }, |
| 127 | 127 | { |
| 128 | - title: '类型', | |
| 128 | + title: '告警场景', | |
| 129 | 129 | dataIndex: 'type', |
| 130 | 130 | width: 160, |
| 131 | 131 | }, |
| ... | ... | @@ -189,7 +189,7 @@ export const alarmSchemasForm: FormSchema[] = [ |
| 189 | 189 | }, |
| 190 | 190 | { |
| 191 | 191 | field: 'type', |
| 192 | - label: '告警类型', | |
| 192 | + label: '告警场景', | |
| 193 | 193 | component: 'Input', |
| 194 | 194 | componentProps: { |
| 195 | 195 | disabled: true, | ... | ... |
| ... | ... | @@ -72,37 +72,47 @@ |
| 72 | 72 | |
| 73 | 73 | const handleCancel = () => { |
| 74 | 74 | resetFields(); |
| 75 | + unref(jsonInstance).set({}); | |
| 75 | 76 | }; |
| 76 | 77 | const handleOk = async () => { |
| 77 | - disable.value = true; | |
| 78 | - // 验证 | |
| 79 | - const valid = await validate(); | |
| 80 | - if (!valid) return; | |
| 81 | - // 收集表单数据 | |
| 82 | - const field = getFieldsValue(); | |
| 83 | - jsonData.value = unref(jsonInstance).get(); | |
| 84 | - jsonData.value.persistent = true; | |
| 85 | - jsonData.value.additionalInfo = { | |
| 86 | - cmdType: 'API', | |
| 87 | - }; | |
| 88 | - commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) | |
| 89 | - .then((res) => { | |
| 90 | - if (!res) return; | |
| 91 | - createMessage.success('命令下发成功'); | |
| 92 | - disable.value = true; | |
| 93 | - // 请求 | |
| 94 | - handleCancel(); | |
| 95 | - }) | |
| 96 | - .catch((e) => { | |
| 97 | - if (e?.message) { | |
| 98 | - createMessage.error(e?.message); | |
| 99 | - } | |
| 100 | - }) | |
| 101 | - .finally(() => { | |
| 102 | - setTimeout(() => { | |
| 103 | - disable.value = false; | |
| 104 | - }, 300); | |
| 105 | - }); | |
| 78 | + try { | |
| 79 | + disable.value = true; | |
| 80 | + // 验证 | |
| 81 | + const valid = await validate(); | |
| 82 | + if (!valid) return; | |
| 83 | + // 收集表单数据 | |
| 84 | + const field = getFieldsValue(); | |
| 85 | + const getJson = unref(jsonInstance).get(); | |
| 86 | + jsonData.value.persistent = true; | |
| 87 | + jsonData.value.additionalInfo = { | |
| 88 | + cmdType: 'API', | |
| 89 | + }; | |
| 90 | + jsonData.value.method = 'setGpio'; | |
| 91 | + jsonData.value.params = { ...getJson }; | |
| 92 | + commandIssuanceApi(field.commandType, props.deviceDetail.tbDeviceId, jsonData.value) | |
| 93 | + .then((res) => { | |
| 94 | + if (!res) return; | |
| 95 | + createMessage.success('命令下发成功'); | |
| 96 | + disable.value = true; | |
| 97 | + // 请求 | |
| 98 | + handleCancel(); | |
| 99 | + }) | |
| 100 | + .catch((e) => { | |
| 101 | + if (e?.message) { | |
| 102 | + createMessage.error(e?.message); | |
| 103 | + } | |
| 104 | + handleCancel(); | |
| 105 | + }) | |
| 106 | + .finally(() => { | |
| 107 | + setTimeout(() => { | |
| 108 | + disable.value = false; | |
| 109 | + }, 300); | |
| 110 | + }); | |
| 111 | + } catch (e) { | |
| 112 | + //这里捕获json插件的错误 | |
| 113 | + createMessage.error('请填写正确的json格式数据'); | |
| 114 | + disable.value = false; | |
| 115 | + } | |
| 106 | 116 | }; |
| 107 | 117 | return { |
| 108 | 118 | registerForm, | ... | ... |
| ... | ... | @@ -51,7 +51,9 @@ |
| 51 | 51 | </template> |
| 52 | 52 | <template #name="{ record }"> |
| 53 | 53 | <div> |
| 54 | - {{ record.name }} | |
| 54 | + <Tooltip :title="record.name" placement="topRight"> | |
| 55 | + {{ record.name }} | |
| 56 | + </Tooltip> | |
| 55 | 57 | </div> |
| 56 | 58 | <Tooltip title="设备SN码" placement="topRight"> |
| 57 | 59 | <a-button type="link" @click="copySN(record.sn)" style="padding: 0"> |
| ... | ... | @@ -151,7 +153,7 @@ |
| 151 | 153 | </div> |
| 152 | 154 | </template> |
| 153 | 155 | <script lang="ts"> |
| 154 | - import { defineComponent, reactive, unref, nextTick, ref } from 'vue'; | |
| 156 | + import { defineComponent, reactive, unref, nextTick } from 'vue'; | |
| 155 | 157 | import { DeviceState, DeviceTypeEnum } from '/@/api/device/model/deviceModel'; |
| 156 | 158 | import { BasicTable, useTable, TableAction, TableImg } from '/@/components/Table'; |
| 157 | 159 | import { columns, searchFormSchema } from './config/device.data'; | ... | ... |
| ... | ... | @@ -55,13 +55,7 @@ export const columns: BasicColumn[] = [ |
| 55 | 55 | title: '状态', |
| 56 | 56 | dataIndex: 'status', |
| 57 | 57 | width: 120, |
| 58 | - customRender: ({ record }) => { | |
| 59 | - const status = record.status; | |
| 60 | - const enable = ~~status === 1; | |
| 61 | - const color = enable ? '#2aae67' : '#eb846f'; | |
| 62 | - const text = enable ? '启用' : '禁用'; | |
| 63 | - return h(Tag, { color: color }, () => text); | |
| 64 | - }, | |
| 58 | + slots: { customRender: 'status' }, | |
| 65 | 59 | }, |
| 66 | 60 | { |
| 67 | 61 | title: '描述', | ... | ... |
| ... | ... | @@ -64,32 +64,19 @@ |
| 64 | 64 | return record.status == 0; |
| 65 | 65 | }, |
| 66 | 66 | }, |
| 67 | - { | |
| 68 | - label: '启用', | |
| 69 | - icon: 'ant-design:check-circle-outlined', | |
| 70 | - color: 'success', | |
| 71 | - popConfirm: { | |
| 72 | - title: '是否启用?', | |
| 73 | - confirm: handleEnableOrDisable.bind(null, record), | |
| 74 | - }, | |
| 75 | - ifShow: (_action) => { | |
| 76 | - return record.status == 0; | |
| 77 | - }, | |
| 78 | - }, | |
| 79 | - { | |
| 80 | - label: '禁用', | |
| 81 | - icon: 'ant-design:close-circle-outlined', | |
| 82 | - popConfirm: { | |
| 83 | - title: '是否禁用?', | |
| 84 | - confirm: handleDisable.bind(null, record), | |
| 85 | - }, | |
| 86 | - ifShow: (_action) => { | |
| 87 | - return record.status == 1; | |
| 88 | - }, | |
| 89 | - }, | |
| 90 | 67 | ]" |
| 91 | 68 | /> |
| 92 | 69 | </template> |
| 70 | + <template #status="{ record }"> | |
| 71 | + <Switch | |
| 72 | + :disabled="disabledSwitch" | |
| 73 | + :checked="record.status === 1" | |
| 74 | + :loading="record.pendingStatus" | |
| 75 | + checkedChildren="启用" | |
| 76 | + unCheckedChildren="禁用" | |
| 77 | + @change="(checked:boolean)=>statusChange(checked,record)" | |
| 78 | + /> | |
| 79 | + </template> | |
| 93 | 80 | </BasicTable> |
| 94 | 81 | <div> |
| 95 | 82 | <DataTransferDrawer @register="registerModal" @success="handleSuccess" /> |
| ... | ... | @@ -110,11 +97,13 @@ |
| 110 | 97 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 111 | 98 | import { Authority } from '/@/components/Authority'; |
| 112 | 99 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
| 100 | + import { Switch } from 'ant-design-vue'; | |
| 113 | 101 | |
| 114 | 102 | export default defineComponent({ |
| 115 | 103 | name: 'Index', |
| 116 | - components: { BasicTable, TableAction, DataTransferDrawer, Authority }, | |
| 104 | + components: { BasicTable, TableAction, DataTransferDrawer, Authority, Switch }, | |
| 117 | 105 | setup() { |
| 106 | + const disabledSwitch = ref(false); | |
| 118 | 107 | const enableObj = reactive({ |
| 119 | 108 | convertIds: [], |
| 120 | 109 | status: 0, |
| ... | ... | @@ -191,64 +180,6 @@ |
| 191 | 180 | }); |
| 192 | 181 | }, 10); |
| 193 | 182 | }; |
| 194 | - | |
| 195 | - const handleEnableOrDisable = async (record: Recordable) => { | |
| 196 | - setLoading(true); | |
| 197 | - enableObj.convertIds.length = 0; | |
| 198 | - try { | |
| 199 | - enableObj.status = record.status; | |
| 200 | - enableObj.convertIds.push(record.id as never); | |
| 201 | - if (enableObj.status == 0) { | |
| 202 | - enableObj.status = 1; | |
| 203 | - } | |
| 204 | - const res = await isEnableOrDisableApi(enableObj as never); | |
| 205 | - if (res !== '') { | |
| 206 | - createMessage.success('流转配置启用成功'); | |
| 207 | - setLoading(false); | |
| 208 | - handleSuccess(); | |
| 209 | - singleStopDeleteStatus.value = true; | |
| 210 | - disabledStatus1.value = true; | |
| 211 | - disabledStatus2.value = true; | |
| 212 | - disabledStatus3.value = true; | |
| 213 | - resetSelectedRowKeys(); | |
| 214 | - clearSelectedRowKeys(); | |
| 215 | - } else { | |
| 216 | - createMessage.error('流转配置启用失败'); | |
| 217 | - } | |
| 218 | - } catch (e) { | |
| 219 | - return e; | |
| 220 | - } finally { | |
| 221 | - setLoading(false); | |
| 222 | - } | |
| 223 | - }; | |
| 224 | - const handleDisable = async (record: Recordable) => { | |
| 225 | - setLoading(true); | |
| 226 | - enableObj.convertIds.length = 0; | |
| 227 | - try { | |
| 228 | - enableObj.status = record.status; | |
| 229 | - enableObj.convertIds.push(record.id as never); | |
| 230 | - if (enableObj.status == 1) { | |
| 231 | - enableObj.status = 0; | |
| 232 | - } | |
| 233 | - const res = await isEnableOrDisableApi(enableObj as never); | |
| 234 | - if (res !== '') { | |
| 235 | - createMessage.success('流转配置禁用成功'); | |
| 236 | - setLoading(false); | |
| 237 | - handleSuccess(); | |
| 238 | - singleStopDeleteStatus.value = true; | |
| 239 | - disabledStatus1.value = true; | |
| 240 | - disabledStatus2.value = true; | |
| 241 | - disabledStatus3.value = true; | |
| 242 | - resetSelectedRowKeys(); | |
| 243 | - clearSelectedRowKeys(); | |
| 244 | - } else { | |
| 245 | - createMessage.error('流转配置禁用失败'); | |
| 246 | - } | |
| 247 | - } catch (e) { | |
| 248 | - } finally { | |
| 249 | - setLoading(false); | |
| 250 | - } | |
| 251 | - }; | |
| 252 | 183 | const useSelectionChange = () => { |
| 253 | 184 | selectedRowKeys.value = getSelectRowKeys(); |
| 254 | 185 | isJudgeSelectRowsArr.value = getSelectRows(); |
| ... | ... | @@ -310,7 +241,6 @@ |
| 310 | 241 | clearSelectedRowKeys(); |
| 311 | 242 | } |
| 312 | 243 | }; |
| 313 | - | |
| 314 | 244 | const handleMutiuteEnable = async () => { |
| 315 | 245 | enableObj.convertIds.length = 0; |
| 316 | 246 | try { |
| ... | ... | @@ -339,6 +269,38 @@ |
| 339 | 269 | clearSelectedRowKeys(); |
| 340 | 270 | } |
| 341 | 271 | }; |
| 272 | + const statusChange = async (checked, record) => { | |
| 273 | + try { | |
| 274 | + setProps({ | |
| 275 | + loading: true, | |
| 276 | + }); | |
| 277 | + disabledSwitch.value = true; | |
| 278 | + enableObj.convertIds.length = 0; | |
| 279 | + resetSelectedRowKeys(); | |
| 280 | + clearSelectedRowKeys(); | |
| 281 | + const newStatus = checked ? 1 : 0; | |
| 282 | + enableObj.convertIds.push(record.id as never); | |
| 283 | + enableObj.status = newStatus; | |
| 284 | + const res = await isEnableOrDisableApi(enableObj as never); | |
| 285 | + if (res && newStatus) { | |
| 286 | + createMessage.success(`流转配置启用成功`); | |
| 287 | + } else { | |
| 288 | + createMessage.success('流转配置禁用成功'); | |
| 289 | + } | |
| 290 | + singleStopDeleteStatus.value = true; | |
| 291 | + disabledStatus1.value = true; | |
| 292 | + disabledStatus2.value = true; | |
| 293 | + disabledStatus3.value = true; | |
| 294 | + } finally { | |
| 295 | + setTimeout(() => { | |
| 296 | + setProps({ | |
| 297 | + loading: false, | |
| 298 | + }); | |
| 299 | + disabledSwitch.value = false; | |
| 300 | + }, 500); | |
| 301 | + reload(); | |
| 302 | + } | |
| 303 | + }; | |
| 342 | 304 | |
| 343 | 305 | return { |
| 344 | 306 | disabledStatus1, |
| ... | ... | @@ -351,13 +313,13 @@ |
| 351 | 313 | registerModal, |
| 352 | 314 | handleSuccess, |
| 353 | 315 | handleEdit, |
| 354 | - handleEnableOrDisable, | |
| 355 | 316 | useSelectionChange, |
| 356 | 317 | handleMutiuteDisable, |
| 357 | - handleDisable, | |
| 358 | 318 | hasBatchDelete, |
| 359 | 319 | handleDeleteOrBatchDelete, |
| 360 | 320 | singleStopDeleteStatus, |
| 321 | + statusChange, | |
| 322 | + disabledSwitch, | |
| 361 | 323 | }; |
| 362 | 324 | }, |
| 363 | 325 | }); | ... | ... |
| ... | ... | @@ -86,11 +86,19 @@ export const genActionData = (actionData) => { |
| 86 | 86 | valueType: item.operationType, |
| 87 | 87 | // value: null, |
| 88 | 88 | predicate: { |
| 89 | - type: item.operationType, | |
| 89 | + type: item.operationType === 'DATE_TIME' ? 'NUMERIC' : item.operationType, | |
| 90 | 90 | operation: pred.operation, |
| 91 | 91 | ignoreCase: item.operationType === 'STRING' ? pred.ignoreCase : undefined, |
| 92 | + // value: { | |
| 93 | + // defaultValue: pred.value, | |
| 94 | + // // userValue: null, | |
| 95 | + // // dynamicValue: null, | |
| 96 | + // }, | |
| 92 | 97 | value: { |
| 93 | - defaultValue: pred.value, | |
| 98 | + defaultValue: | |
| 99 | + item.operationType === 'DATE_TIME' | |
| 100 | + ? Number(formatToDateTime(pred.value, 'x')) | |
| 101 | + : pred.value, | |
| 94 | 102 | // userValue: null, |
| 95 | 103 | // dynamicValue: null, |
| 96 | 104 | }, | ... | ... |