Commit 5a4cd84d9e840ba2d1d78290cfc088d9b7bd6e74

Authored by xp.Huang
2 parents 3f7fc1aa 60e9e4d9

Merge branch 'perf_device_access' into 'main_dev'

perf: 设备接入信息管理修改更新请求方式为put

See merge request yunteng/thingskit-front!1218
... ... @@ -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 30 export const getDeviceAccessInformationList = (params) => {
... ...
... ... @@ -18,11 +18,12 @@
18 18 });
19 19
20 20 const [registerDrawer, { setDrawerProps }] = useDrawerInner(async (data) => {
21   - setDrawerProps({ confirmLoading: false });
  21 + setDrawerProps({ confirmLoading: true });
22 22 const dataValue = {
23 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 29 </script>
... ...
... ... @@ -4,7 +4,10 @@
4 4 import { BasicModal, useModalInner } from '/@/components/Modal';
5 5 import { deleteFormField, schemas } from '../index';
6 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 11 import { useMessage } from '/@/hooks/web/useMessage';
9 12 import { ipRegex } from '/@/utils/rules';
10 13
... ... @@ -16,7 +19,7 @@
16 19
17 20 const { createMessage } = useMessage();
18 21
19   - const [registerForm, { getFieldsValue, setFieldsValue, validate }] = useForm({
  22 + const [registerForm, { getFieldsValue, setFieldsValue, validate, resetFields }] = useForm({
20 23 labelWidth: 150,
21 24 schemas,
22 25 actionColOptions: {
... ... @@ -28,6 +31,7 @@
28 31 const recordInfo = ref<Recordable>({});
29 32
30 33 const [register, { closeModal, setModalProps }] = useModalInner(async (data) => {
  34 + await resetFields();
31 35 setModalProps({ confirmLoading: false, loading: true });
32 36 isUpdate.value = data?.isUpdate;
33 37 recordInfo.value = data?.record;
... ... @@ -52,9 +56,6 @@
52 56 const handleOk = async () => {
53 57 await validate();
54 58 let values = getFieldsValue();
55   - if (unref(isUpdate)) {
56   - values = { ...values, id: unref(recordInfo).id };
57   - }
58 59 const { intranetIpAndPort, outerIpAndPort } = values;
59 60 values.intranetIp = intranetIpAndPort.inputIp;
60 61 values.intranetPort = intranetIpAndPort.inputPort;
... ... @@ -81,7 +82,13 @@
81 82 deleteFormField.forEach((deleteItem) => {
82 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 92 createMessage.success('操作成功');
86 93 emit('handleReload');
87 94 handleCancel();
... ...