|
|
@ -1,9 +1,9 @@ |
|
|
|
<template> |
|
|
|
<a-spin :spinning="confirmLoading"> |
|
|
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol" :rules="rules" :model="formData"> |
|
|
|
<a-row> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="监控相机" v-bind="validateInfos.cameraId"> |
|
|
|
<a-form-item label="监控相机" v-bind="validateInfos.cameraId" name="cameraId"> |
|
|
|
<a-tree-select |
|
|
|
ref="cameraTree" |
|
|
|
v-model:value="formData.cameraId" |
|
|
@ -60,17 +60,22 @@ |
|
|
|
<a-textarea v-model:value="formData.drawdata" :rows="4" placeholder="请输入画图数据" :disabled="disabled"></a-textarea> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="所属场景" v-bind="validateInfos.sceneId" name="sceneId"> |
|
|
|
<!-- <a-input v-model:value="formData.sceneId" placeholder="请输入所属场景" :disabled="disabled"></a-input> --> |
|
|
|
<a-select v-model:value="formData.sceneId" placeholder="请选择所属场景" :disabled="disabled"> |
|
|
|
<template :key="code.sceneCode" v-for="code in sceneCodeList"> |
|
|
|
<a-select-option :value="code.sceneCode">{{ code.sceneName }}</a-select-option> |
|
|
|
</template> |
|
|
|
</a-select> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<!-- <a-col :span="24"> |
|
|
|
<a-form-item label="备注" v-bind="validateInfos.remark"> |
|
|
|
<a-input v-model:value="formData.remark" placeholder="请输入备注" :disabled="disabled"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> --> |
|
|
|
<!-- |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="备用2" v-bind="validateInfos.field2"> |
|
|
|
<a-input v-model:value="formData.field2" placeholder="请输入备用2" :disabled="disabled"></a-input> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="备用3" v-bind="validateInfos.field3"> |
|
|
|
<a-input v-model:value="formData.field3" placeholder="请输入备用3" :disabled="disabled"></a-input> |
|
|
@ -100,6 +105,7 @@ |
|
|
|
import { saveOrUpdate } from '../DtAiMonitorArea.api'; |
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
import locationPng from '@/assets/images/getLocation.png'; |
|
|
|
import type { Rule } from 'ant-design-vue/es/form'; |
|
|
|
// 引入视频标注组件 |
|
|
|
import SelectCom from '../selectCom/SelectCom.vue'; |
|
|
|
|
|
|
@ -123,6 +129,15 @@ |
|
|
|
const getmodelCodeList = () => { |
|
|
|
return defHttp.get({ url: '/military/dtAiModel/list' }, { isTransformResponse: false }); |
|
|
|
}; |
|
|
|
// 场景编码 |
|
|
|
const sceneCodeList: any = ref([]); |
|
|
|
// 获取场景编码 |
|
|
|
const getsceneCodeList = () => { |
|
|
|
defHttp.get({ url: '/military/msMapScene/list' }, { isTransformResponse: false }).then((res) => { |
|
|
|
sceneCodeList.value = res.result.records; |
|
|
|
}); |
|
|
|
}; |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
formDisabled: { type: Boolean, default: false }, |
|
|
|
formData: { type: Object, default: () => {} }, |
|
|
@ -137,10 +152,10 @@ |
|
|
|
modelName: '', |
|
|
|
areaData: '', |
|
|
|
drawdata: '', |
|
|
|
sceneId: '', |
|
|
|
// rtspUrl: '', |
|
|
|
cameraId: undefined, |
|
|
|
remark: '', |
|
|
|
field2: '', |
|
|
|
field3: '', |
|
|
|
sysAreaCode: '', |
|
|
|
sysUnitCode: '', |
|
|
@ -151,11 +166,18 @@ |
|
|
|
const confirmLoading = ref<boolean>(false); |
|
|
|
//表单验证 |
|
|
|
const validatorRules = {}; |
|
|
|
const rules: Record<string, Rule[]> = { |
|
|
|
cameraId: [{ required: true, message: '请选择监控相机!' }], |
|
|
|
modelCode: [{ required: true, message: '请输入监控模型!' }], |
|
|
|
sceneId: [{ required: true, message: '请选择所属场景!' }], |
|
|
|
}; |
|
|
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
// 获取相机数据 |
|
|
|
getCameraList(); |
|
|
|
// 获取场景编码 |
|
|
|
getsceneCodeList(); |
|
|
|
//获取模型编码 |
|
|
|
getmodelCodeList().then((response) => { |
|
|
|
if (response.success) { |
|
|
@ -286,37 +308,40 @@ |
|
|
|
*/ |
|
|
|
async function submitForm() { |
|
|
|
// 触发表单验证 |
|
|
|
await validate(); |
|
|
|
confirmLoading.value = true; |
|
|
|
const isUpdate = ref<boolean>(false); |
|
|
|
//时间格式化 |
|
|
|
let model = formData; |
|
|
|
if (model.id) { |
|
|
|
isUpdate.value = true; |
|
|
|
} |
|
|
|
//循环数据 |
|
|
|
for (let data in model) { |
|
|
|
//如果该数据是数组并且是字符串类型 |
|
|
|
if (model[data] instanceof Array) { |
|
|
|
let valueType = getValueType(formRef.value.getProps, data); |
|
|
|
//如果是字符串类型的需要变成以逗号分割的字符串 |
|
|
|
if (valueType === 'string') { |
|
|
|
model[data] = model[data].join(','); |
|
|
|
} |
|
|
|
// await validate(); |
|
|
|
|
|
|
|
formRef.value.validate().then(async () => { |
|
|
|
confirmLoading.value = true; |
|
|
|
const isUpdate = ref<boolean>(false); |
|
|
|
//时间格式化 |
|
|
|
let model = formData; |
|
|
|
if (model.id) { |
|
|
|
isUpdate.value = true; |
|
|
|
} |
|
|
|
} |
|
|
|
await saveOrUpdate(model, isUpdate.value) |
|
|
|
.then((res) => { |
|
|
|
if (res.success) { |
|
|
|
createMessage.success(res.message); |
|
|
|
emit('ok'); |
|
|
|
} else { |
|
|
|
createMessage.warning(res.message); |
|
|
|
//循环数据 |
|
|
|
for (let data in model) { |
|
|
|
//如果该数据是数组并且是字符串类型 |
|
|
|
if (model[data] instanceof Array) { |
|
|
|
let valueType = getValueType(formRef.value.getProps, data); |
|
|
|
//如果是字符串类型的需要变成以逗号分割的字符串 |
|
|
|
if (valueType === 'string') { |
|
|
|
model[data] = model[data].join(','); |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
confirmLoading.value = false; |
|
|
|
}); |
|
|
|
} |
|
|
|
await saveOrUpdate(model, isUpdate.value) |
|
|
|
.then((res) => { |
|
|
|
if (res.success) { |
|
|
|
createMessage.success(res.message); |
|
|
|
emit('ok'); |
|
|
|
} else { |
|
|
|
createMessage.warning(res.message); |
|
|
|
} |
|
|
|
}) |
|
|
|
.finally(() => { |
|
|
|
confirmLoading.value = false; |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
defineExpose({ |
|
|
|