|
@@ -2,12 +2,12 @@
|
|
|
<BasicModal
|
|
|
v-bind="$attrs"
|
|
|
@register="register"
|
|
|
- :title="t('routes.devices.addCamera')"
|
|
|
+ :title="t('routes.devices.editCamera')"
|
|
|
@visible-change="handleVisibleChange"
|
|
|
@ok="handleSubmit"
|
|
|
>
|
|
|
<div class="pt-2px pr-3px">
|
|
|
- <BasicForm @register="registerForm" :model="model" />
|
|
|
+ <BasicForm @register="registerForm" />
|
|
|
</div>
|
|
|
</BasicModal>
|
|
|
</template>
|
|
@@ -16,8 +16,10 @@
|
|
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
|
|
import { BasicForm, FormSchema, useForm } from '/@/components/Form/index';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
- import { allCompanyApi, addCameraApi } from '/@/api/device/list';
|
|
|
+ // allCompanyApi
|
|
|
+ import { editCameraApi } from '/@/api/device/list';
|
|
|
import { useI18n } from '/@/hooks/web/useI18n';
|
|
|
+
|
|
|
// address: "11111"
|
|
|
// balance: "111"
|
|
|
// cameraType: "4"
|
|
@@ -39,6 +41,12 @@
|
|
|
const { createMessage } = useMessage();
|
|
|
const schemas: FormSchema[] = [
|
|
|
{
|
|
|
+ field: 'id',
|
|
|
+ component: 'Input',
|
|
|
+ label: 'id',
|
|
|
+ show: false,
|
|
|
+ },
|
|
|
+ {
|
|
|
field: 'own',
|
|
|
component: 'Select',
|
|
|
label: t('routes.devices.own'),
|
|
@@ -46,6 +54,7 @@
|
|
|
span: 24,
|
|
|
},
|
|
|
componentProps: {
|
|
|
+ // disabled: true,
|
|
|
options: [0, 2, 1, 3].map((ele) => {
|
|
|
return { value: ele, key: ele, label: renderOwnTypeLabel(ele) };
|
|
|
}),
|
|
@@ -56,6 +65,7 @@
|
|
|
field: 'cameraType',
|
|
|
component: 'Select',
|
|
|
label: t('routes.devices.cameraType'),
|
|
|
+
|
|
|
required: true,
|
|
|
colProps: {
|
|
|
span: 24,
|
|
@@ -94,12 +104,18 @@
|
|
|
colProps: {
|
|
|
span: 24,
|
|
|
},
|
|
|
+ componentProps: {
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
},
|
|
|
{
|
|
|
field: 'wifiName',
|
|
|
component: 'Input',
|
|
|
label: t('routes.devices.wifiName'),
|
|
|
required: true,
|
|
|
+ componentProps: {
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
colProps: {
|
|
|
span: 24,
|
|
|
},
|
|
@@ -109,6 +125,7 @@
|
|
|
component: 'Input',
|
|
|
required: true,
|
|
|
label: t('routes.devices.address'),
|
|
|
+ disabled: true,
|
|
|
colProps: {
|
|
|
span: 24,
|
|
|
},
|
|
@@ -118,6 +135,9 @@
|
|
|
component: 'Input',
|
|
|
label: t('routes.devices.snCode'),
|
|
|
required: true,
|
|
|
+ componentProps: {
|
|
|
+ disabled: true,
|
|
|
+ },
|
|
|
ifShow: ({ model }) => {
|
|
|
console.log('record', model.cameraType);
|
|
|
|
|
@@ -127,51 +147,44 @@
|
|
|
span: 24,
|
|
|
},
|
|
|
},
|
|
|
- {
|
|
|
- field: 'balance',
|
|
|
- component: 'Input',
|
|
|
- label: t('routes.devices.balance'),
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- },
|
|
|
// {
|
|
|
- // field: 'orderSn',
|
|
|
+ // field: 'balance',
|
|
|
// component: 'Input',
|
|
|
- // label: t('routes.devices.orderSn'),
|
|
|
+ // label: t('routes.devices.balance'),
|
|
|
+ // colProps: {
|
|
|
+ // span: 24,
|
|
|
+ // },
|
|
|
+ // },
|
|
|
+
|
|
|
+ // {
|
|
|
+ // field: 'companyId',
|
|
|
+ // component: 'ApiSelect',
|
|
|
+ // label: t('routes.devices.companyId'),
|
|
|
+ // componentProps: {
|
|
|
+ // api: allCompanyApi,
|
|
|
+ // numberToString: true,
|
|
|
+ // labelField: 'companyName',
|
|
|
+ // valueField: 'id',
|
|
|
+ // immediate: true,
|
|
|
+ // params: {
|
|
|
+ // page: 1,
|
|
|
+ // limit: 1000,
|
|
|
+ // },
|
|
|
+ // },
|
|
|
// colProps: {
|
|
|
// span: 24,
|
|
|
// },
|
|
|
- // required: true,
|
|
|
// },
|
|
|
- {
|
|
|
- field: 'companyId',
|
|
|
- component: 'ApiSelect',
|
|
|
- label: t('routes.devices.companyId'),
|
|
|
- componentProps: {
|
|
|
- api: allCompanyApi,
|
|
|
- numberToString: true,
|
|
|
- labelField: 'companyName',
|
|
|
- valueField: 'id',
|
|
|
- immediate: true,
|
|
|
- params: {
|
|
|
- page: 1,
|
|
|
- limit: 1000,
|
|
|
- },
|
|
|
- },
|
|
|
- colProps: {
|
|
|
- span: 24,
|
|
|
- },
|
|
|
- },
|
|
|
];
|
|
|
const [
|
|
|
registerForm,
|
|
|
{
|
|
|
- getFieldsValue,
|
|
|
- validateFields,
|
|
|
+ // getFieldsValue,
|
|
|
+ // validateFields,
|
|
|
// appendSchemaByField,
|
|
|
// removeSchemaByFiled,
|
|
|
- // setFieldsValue,
|
|
|
+ setFieldsValue,
|
|
|
+ validate,
|
|
|
// setProps
|
|
|
},
|
|
|
] = useForm({
|
|
@@ -219,24 +232,24 @@
|
|
|
}
|
|
|
function onDataReceive(data) {
|
|
|
console.log('Data Received', data);
|
|
|
- const { addList } = data;
|
|
|
- if (typeof addList === 'function') {
|
|
|
- //是函数 其中 FunName 为函数名称
|
|
|
- addListFunc = addList;
|
|
|
- }
|
|
|
+ setFieldsValue({
|
|
|
+ ...data,
|
|
|
+ cameraType: Number(data.cameraType),
|
|
|
+ });
|
|
|
}
|
|
|
const handleSubmit = async () => {
|
|
|
- console.log('getFieldsValue()', getFieldsValue());
|
|
|
+ // console.log('getFieldsValue()', getFieldsValue());
|
|
|
try {
|
|
|
- const data = await validateFields();
|
|
|
- const param = await getFieldsValue();
|
|
|
- let res = await addCameraApi(param);
|
|
|
- console.log('getFieldsValue()', res, data, param);
|
|
|
- if (res.code) {
|
|
|
- createMessage.error(res.error || t('common.optFail'));
|
|
|
- } else {
|
|
|
- emit('getList');
|
|
|
- closeModal();
|
|
|
+ const values = await validate();
|
|
|
+ console.log('values', values);
|
|
|
+ if (values) {
|
|
|
+ const res = await editCameraApi(values);
|
|
|
+ if (res.code) {
|
|
|
+ createMessage.error(res.error || t('common.optFail'));
|
|
|
+ } else {
|
|
|
+ emit('update');
|
|
|
+ closeModal();
|
|
|
+ }
|
|
|
}
|
|
|
} catch (error) {
|
|
|
console.log('not passing', error);
|