|
|
@ -2,7 +2,7 @@ |
|
|
|
* @Author: Fuyuu 1805498209@qq.com |
|
|
|
* @Date: 2023-11-24 10:15:24 |
|
|
|
* @LastEditors: Fuyuu 1805498209@qq.com |
|
|
|
* @LastEditTime: 2023-11-29 10:10:40 |
|
|
|
* @LastEditTime: 2023-12-29 11:22:51 |
|
|
|
* @FilePath: \dt-admin-pc\src\views\military\modules\prewarn\components\msWarnLevelForm.vue |
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE |
|
|
|
--> |
|
|
@ -11,23 +11,45 @@ |
|
|
|
<a-form ref="formRef" class="antd-modal-form" :labelCol="labelCol" :wrapperCol="wrapperCol"> |
|
|
|
<a-row> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="区域编号" v-bind="validateInfos.lineId"> |
|
|
|
<j-dict-select-tag v-model:value="formData.lineId" dictCode="ms_map_line,name,id" :string-to-number="true" placeholder="请选择区域编号" :disabled="disabled"/> |
|
|
|
<a-form-item label="报警区域" v-bind="validateInfos.lineId"> |
|
|
|
<!-- <j-dict-select-tag v-model:value="formData.lineId" dictCode="ms_map_line,name,id" :string-to-number="true" placeholder="请选择区域编号" :disabled="disabled"/> --> |
|
|
|
<a-tree-select |
|
|
|
ref="cameraTree" |
|
|
|
v-model:value="formData.lineId" |
|
|
|
allow-clear |
|
|
|
:treeData="nodeTree" |
|
|
|
:disabled="disabled" |
|
|
|
placeholder="请选择报警区域" |
|
|
|
> |
|
|
|
<template #suffixIcon><VideoCameraOutlined /></template> |
|
|
|
</a-tree-select> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="报警类型" v-bind="validateInfos.warnType"> |
|
|
|
<j-dict-select-tag v-model:value="formData.warnType" dictCode="ms_warn_type" :string-to-number="true" placeholder="请选择报警类型" :disabled="disabled"/> |
|
|
|
<j-dict-select-tag |
|
|
|
v-model:value="formData.warnType" |
|
|
|
dictCode="ms_warn_type" |
|
|
|
:string-to-number="true" |
|
|
|
placeholder="请选择报警类型" |
|
|
|
:disabled="disabled" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="报警级别" v-bind="validateInfos.warnLevel"> |
|
|
|
<j-dict-select-tag v-model:value="formData.warnLevel" dictCode="ms_warn_level" :string-to-number="true" placeholder="请选择报警级别" :disabled="disabled"/> |
|
|
|
<j-dict-select-tag |
|
|
|
v-model:value="formData.warnLevel" |
|
|
|
dictCode="ms_warn_level" |
|
|
|
:string-to-number="true" |
|
|
|
placeholder="请选择报警级别" |
|
|
|
:disabled="disabled" |
|
|
|
/> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
<a-col :span="24"> |
|
|
|
<a-form-item label="报警声音" v-bind="validateInfos.warnAudio"> |
|
|
|
<j-upload v-model:value="formData.warnAudio" :disabled="disabled" ></j-upload> |
|
|
|
<j-upload v-model:value="formData.warnAudio" :disabled="disabled"></j-upload> |
|
|
|
</a-form-item> |
|
|
|
</a-col> |
|
|
|
</a-row> |
|
|
@ -44,21 +66,86 @@ |
|
|
|
import { getValueType } from '/@/utils'; |
|
|
|
import { saveOrUpdate } from '../MsWarnLevel.api'; |
|
|
|
import { Form } from 'ant-design-vue'; |
|
|
|
|
|
|
|
// 登录用户信息 |
|
|
|
import { useUserStore } from '/@/store/modules/user'; |
|
|
|
// 获取当前权限下的场景id |
|
|
|
const sceneId = useUserStore().userInfo?.sceneId; |
|
|
|
// 场景列表 |
|
|
|
const sceneList: any = []; |
|
|
|
// 防区列表 |
|
|
|
const areaList: any = []; |
|
|
|
// 树状防区数据 |
|
|
|
const nodeTree: any = ref([]); |
|
|
|
// 获取当前场景及子场景信息 |
|
|
|
function getCurrentScene() { |
|
|
|
return defHttp.get( |
|
|
|
{ url: '/military/msMapScene/list', params: { sceneId: sceneId + '*', pageNo: 1, pageSize: 9999 } }, |
|
|
|
{ isTransformResponse: false } |
|
|
|
); |
|
|
|
} |
|
|
|
// 获取当前场景(包括其子场景)下的所有防区 |
|
|
|
function getCurrentSceneArea() { |
|
|
|
return defHttp.get({ url: '/military/msMapLine/list', params: { pageNo: 1, pageSize: 9999 } }, { isTransformResponse: false }); |
|
|
|
} |
|
|
|
// 处理相机树状数据 |
|
|
|
function handleCameraTree(data, index = undefined) { |
|
|
|
let arr: any = []; |
|
|
|
for (let i = 0; i < data.length; i++) { |
|
|
|
let obj: any = {}; |
|
|
|
let item = data[i]; |
|
|
|
obj.title = item.title; |
|
|
|
obj.value = obj.key = item.value; |
|
|
|
obj.disabled = item.children?.length >= 0 ? true : false; |
|
|
|
if (item.children && item.children.length > 0) { |
|
|
|
obj.children = []; |
|
|
|
let indexValue: any = index ? index + '-' + (i + 1) : i + 1; |
|
|
|
obj.children = handleCameraTree(item.children, indexValue); |
|
|
|
} |
|
|
|
arr.push(obj); |
|
|
|
} |
|
|
|
return arr; |
|
|
|
} |
|
|
|
onMounted(() => { |
|
|
|
// 将数据转化为树状结构 |
|
|
|
getCurrentScene().then((res) => { |
|
|
|
sceneList.value = res.result.records; |
|
|
|
getCurrentSceneArea().then((res1) => { |
|
|
|
areaList.value = res1.result.records; |
|
|
|
// 定义一个空数组作为树状数组的根节点 |
|
|
|
const tree: any = []; |
|
|
|
//遍历场景列表,查找当前场景(及子场景)数据 |
|
|
|
sceneList.value.forEach((row) => { |
|
|
|
const node = { title: row.sceneName, value: row.sceneId, children: [] }; |
|
|
|
tree.push(node); |
|
|
|
}); |
|
|
|
// 遍历防区列表,查找对应场景下的数据 |
|
|
|
areaList.value.forEach((row) => { |
|
|
|
const parentNode = tree.find((node) => node.value === row.sceneId); |
|
|
|
if (parentNode) { |
|
|
|
const node = { title: row.name, value: row.id, children: null }; |
|
|
|
parentNode.children.push(node); |
|
|
|
} |
|
|
|
}); |
|
|
|
// 转化为ant tree-select结构 |
|
|
|
nodeTree.value = handleCameraTree(tree); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
const props = defineProps({ |
|
|
|
formDisabled: { type: Boolean, default: false }, |
|
|
|
formData: { type: Object, default: ()=>{} }, |
|
|
|
formBpm: { type: Boolean, default: true } |
|
|
|
formData: { type: Object, default: () => {} }, |
|
|
|
formBpm: { type: Boolean, default: true }, |
|
|
|
}); |
|
|
|
const formRef = ref(); |
|
|
|
const useForm = Form.useForm; |
|
|
|
const emit = defineEmits(['register', 'ok']); |
|
|
|
const formData = reactive<Record<string, any>>({ |
|
|
|
id: '', |
|
|
|
lineId: '', |
|
|
|
lineId: undefined, |
|
|
|
warnType: undefined, |
|
|
|
warnLevel: undefined, |
|
|
|
warnAudio: '', |
|
|
|
warnAudio: '', |
|
|
|
}); |
|
|
|
const { createMessage } = useMessage(); |
|
|
|
const labelCol = ref<any>({ xs: { span: 24 }, sm: { span: 5 } }); |
|
|
@ -66,25 +153,24 @@ |
|
|
|
const confirmLoading = ref<boolean>(false); |
|
|
|
//表单验证 |
|
|
|
const validatorRules = { |
|
|
|
lineId: [{ required: true, message: '请选择区域编号!'},], |
|
|
|
warnType: [{ required: true, message: '请选择报警类型!'},], |
|
|
|
warnLevel: [{ required: true, message: '请选择报警级别!'},], |
|
|
|
lineId: [{ required: true, message: '请选择区域编号!' }], |
|
|
|
warnType: [{ required: true, message: '请选择报警类型!' }], |
|
|
|
warnLevel: [{ required: true, message: '请选择报警级别!' }], |
|
|
|
}; |
|
|
|
const { resetFields, validate, validateInfos } = useForm(formData, validatorRules, { immediate: true }); |
|
|
|
|
|
|
|
// 表单禁用 |
|
|
|
const disabled = computed(()=>{ |
|
|
|
if(props.formBpm === true){ |
|
|
|
if(props.formData.disabled === false){ |
|
|
|
const disabled = computed(() => { |
|
|
|
if (props.formBpm === true) { |
|
|
|
if (props.formData.disabled === false) { |
|
|
|
return false; |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
return props.formDisabled; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 新增 |
|
|
|
*/ |
|
|
@ -141,7 +227,6 @@ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
defineExpose({ |
|
|
|
add, |
|
|
|
edit, |
|
|
|