You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

116 lines
2.8 KiB

2 years ago
<template>
2 years ago
<a-form :model="formState" :label-col="labelCol" :wrapper-col="wrapperCol">
2 years ago
<a-form-item label="相机名称">
<a-input v-model:value="formState.name" />
</a-form-item>
<a-form-item label="相机IP">
<a-input v-model:value="formState.ip" />
</a-form-item>
<a-form-item label="相机参数 Id">
<a-input v-model:value="formState.CbCameraParamsId" />
</a-form-item>
<a-form-item label="登录名">
<a-input v-model:value="formState.userName" />
</a-form-item>
<a-form-item label="密码">
<a-input-password v-model:value="formState.password" />
</a-form-item>
<a-form-item label="用户类型">
<a-select v-model:value="formState.userType" placeholder="请选择用户类型">
<a-select-option value="shanghai">Zone one</a-select-option>
<a-select-option value="beijing">Zone two</a-select-option>
</a-select>
</a-form-item>
<a-form-item label="是否启用">
<a-switch v-model:checked="formState.state" />
</a-form-item>
<a-form-item label="备注">
<a-input v-model:value="formState.remark" type="textarea" />
</a-form-item>
<!-- <a-form-item :wrapper-col="{ span: 14, offset: 4 }">
<a-button type="primary" @click="onSubmit">Create</a-button>
<a-button style="margin-left: 10px">Cancel</a-button>
</a-form-item> -->
</a-form>
</template>
<script setup lang='ts'>
2 years ago
import { onMounted, reactive, toRaw, UnwrapRef, watch } from 'vue';
import * as cameraApi from '@/axios/cameraBase/cameraApi';
import Msg from '@/utils/message';
2 years ago
interface FormState {
name: string;
ip: string;
CbCameraParamsId: string;
userName: string;
password: string;
userType: string | undefined;
state: boolean;
remark: string;
}
const props = defineProps({
2 years ago
editData: Object
2 years ago
});
2 years ago
let labelCol = { span: 6 }
let wrapperCol = { span: 14 }
2 years ago
const formState: UnwrapRef<FormState> = reactive({
2 years ago
name: '',
ip: '',
CbCameraParamsId: '',
userName: '',
password: '',
userType: undefined,
state: false,
remark: '',
});
2 years ago
2 years ago
//新增
function add() {
console.log('新增!', toRaw(formState));
return cameraApi.Add(toRaw(formState)).then(res => {
console.log(res);
if (res.data.code == 200) {
Msg.success('添加成功')
return true
}
else {
Msg.error('添加失败,' + res.data.message)
return false
}
}).catch((err: any) => {
Msg.error('添加失败,' + err)
return false
})
}
2 years ago
2 years ago
//编辑
function edit() {
console.log('编辑!', toRaw(formState));
2 years ago
}
2 years ago
//暴露方法
defineExpose({
add,
edit
})
//编辑/新增
onMounted(() => {
console.log("收到了", props.editData);
if (props.editData != null || props.editData != undefined){
}
})
2 years ago
</script>
<style lang="less" scoped>
2 years ago
:deep(.ant-input) {
color: #000;
2 years ago
}
</style>