Commit 60e9e4d958b1cfba3538a8f9353d1d24af6747e7
Committed by
xp.Huang
1 parent
3f7fc1aa
perf: 设备接入信息管理修改更新请求方式为put
Showing
3 changed files
with
27 additions
and
9 deletions
| @@ -15,6 +15,16 @@ export const deviceProfileAccessInformation = (params) => { | @@ -15,6 +15,16 @@ export const deviceProfileAccessInformation = (params) => { | ||
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | /** | 17 | /** |
| 18 | + * 修改设备接入信息 | ||
| 19 | + */ | ||
| 20 | +export const updateDeviceProfileAccessInformation = (params) => { | ||
| 21 | + return defHttp.put<any>({ | ||
| 22 | + url: `${Api.DEVICE_PROFILE_ACCESS_INFORMATIION}`, | ||
| 23 | + params, | ||
| 24 | + }); | ||
| 25 | +}; | ||
| 26 | + | ||
| 27 | +/** | ||
| 18 | * 获取设备接入信息列表 | 28 | * 获取设备接入信息列表 |
| 19 | */ | 29 | */ |
| 20 | export const getDeviceAccessInformationList = (params) => { | 30 | export const getDeviceAccessInformationList = (params) => { |
| @@ -18,11 +18,12 @@ | @@ -18,11 +18,12 @@ | ||
| 18 | }); | 18 | }); |
| 19 | 19 | ||
| 20 | const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { | 20 | const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => { |
| 21 | - setDrawerProps({ confirmLoading: false }); | 21 | + setDrawerProps({ confirmLoading: true }); |
| 22 | const dataValue = { | 22 | const dataValue = { |
| 23 | ...data, | 23 | ...data, |
| 24 | - ...data.sipExtend, | 24 | + ...data?.sipExtend, |
| 25 | }; | 25 | }; |
| 26 | - setDescProps({ data: dataValue }); | 26 | + setDrawerProps({ confirmLoading: false }); |
| 27 | + await setDescProps({ data: dataValue }); | ||
| 27 | }); | 28 | }); |
| 28 | </script> | 29 | </script> |
| @@ -4,7 +4,10 @@ | @@ -4,7 +4,10 @@ | ||
| 4 | import { BasicModal, useModalInner } from '/@/components/Modal'; | 4 | import { BasicModal, useModalInner } from '/@/components/Modal'; |
| 5 | import { deleteFormField, schemas } from '../index'; | 5 | import { deleteFormField, schemas } from '../index'; |
| 6 | import { useForm, BasicForm } from '/@/components/Form'; | 6 | import { useForm, BasicForm } from '/@/components/Form'; |
| 7 | - import { deviceProfileAccessInformation } from '/@/api/device/deviceAccess'; | 7 | + import { |
| 8 | + deviceProfileAccessInformation, | ||
| 9 | + updateDeviceProfileAccessInformation, | ||
| 10 | + } from '/@/api/device/deviceAccess'; | ||
| 8 | import { useMessage } from '/@/hooks/web/useMessage'; | 11 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 9 | import { ipRegex } from '/@/utils/rules'; | 12 | import { ipRegex } from '/@/utils/rules'; |
| 10 | 13 | ||
| @@ -16,7 +19,7 @@ | @@ -16,7 +19,7 @@ | ||
| 16 | 19 | ||
| 17 | const { createMessage } = useMessage(); | 20 | const { createMessage } = useMessage(); |
| 18 | 21 | ||
| 19 | - const [registerForm, { getFieldsValue, setFieldsValue, validate }] = useForm({ | 22 | + const [registerForm, { getFieldsValue, setFieldsValue, validate, resetFields }] = useForm({ |
| 20 | labelWidth: 150, | 23 | labelWidth: 150, |
| 21 | schemas, | 24 | schemas, |
| 22 | actionColOptions: { | 25 | actionColOptions: { |
| @@ -28,6 +31,7 @@ | @@ -28,6 +31,7 @@ | ||
| 28 | const recordInfo = ref<Recordable>({}); | 31 | const recordInfo = ref<Recordable>({}); |
| 29 | 32 | ||
| 30 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { | 33 | const [register, { closeModal, setModalProps }] = useModalInner(async (data) => { |
| 34 | + await resetFields(); | ||
| 31 | setModalProps({ confirmLoading: false, loading: true }); | 35 | setModalProps({ confirmLoading: false, loading: true }); |
| 32 | isUpdate.value = data?.isUpdate; | 36 | isUpdate.value = data?.isUpdate; |
| 33 | recordInfo.value = data?.record; | 37 | recordInfo.value = data?.record; |
| @@ -52,9 +56,6 @@ | @@ -52,9 +56,6 @@ | ||
| 52 | const handleOk = async () => { | 56 | const handleOk = async () => { |
| 53 | await validate(); | 57 | await validate(); |
| 54 | let values = getFieldsValue(); | 58 | let values = getFieldsValue(); |
| 55 | - if (unref(isUpdate)) { | ||
| 56 | - values = { ...values, id: unref(recordInfo).id }; | ||
| 57 | - } | ||
| 58 | const { intranetIpAndPort, outerIpAndPort } = values; | 59 | const { intranetIpAndPort, outerIpAndPort } = values; |
| 59 | values.intranetIp = intranetIpAndPort.inputIp; | 60 | values.intranetIp = intranetIpAndPort.inputIp; |
| 60 | values.intranetPort = intranetIpAndPort.inputPort; | 61 | values.intranetPort = intranetIpAndPort.inputPort; |
| @@ -81,7 +82,13 @@ | @@ -81,7 +82,13 @@ | ||
| 81 | deleteFormField.forEach((deleteItem) => { | 82 | deleteFormField.forEach((deleteItem) => { |
| 82 | Reflect.deleteProperty(values, deleteItem); | 83 | Reflect.deleteProperty(values, deleteItem); |
| 83 | }); | 84 | }); |
| 84 | - await deviceProfileAccessInformation(values); | 85 | + if (unref(isUpdate)) { |
| 86 | + // 更新 | ||
| 87 | + values = { ...values, id: unref(recordInfo).id }; | ||
| 88 | + await updateDeviceProfileAccessInformation(values); | ||
| 89 | + } else { | ||
| 90 | + await deviceProfileAccessInformation(values); | ||
| 91 | + } | ||
| 85 | createMessage.success('操作成功'); | 92 | createMessage.success('操作成功'); |
| 86 | emit('handleReload'); | 93 | emit('handleReload'); |
| 87 | handleCancel(); | 94 | handleCancel(); |