2025-01-20 01:42:19 +00:00
|
|
|
|
// import { h } from 'vue'
|
2025-02-19 08:06:46 +00:00
|
|
|
|
import { NButton, NInputNumber, NSwitch } from 'naive-ui'
|
2025-01-20 01:42:19 +00:00
|
|
|
|
import { useModal } from '@/views/Content/hooks/modal'
|
2025-01-23 01:05:13 +00:00
|
|
|
|
import Detection from '@/views/Payload/Detection.jsx'
|
|
|
|
|
import Communication from '@/views/Payload/Communication.jsx'
|
2025-02-19 08:06:46 +00:00
|
|
|
|
import { updateMbPayload } from '@/api/Mubiao'
|
|
|
|
|
import { useEntity } from '@/hooks/entity'
|
|
|
|
|
import { useMubiao } from './mubiao'
|
2025-01-23 01:05:13 +00:00
|
|
|
|
|
2025-01-20 01:42:19 +00:00
|
|
|
|
const { openDetailsModal } = useModal()
|
|
|
|
|
export const useMubiaoDetail = () => {
|
2025-02-19 08:06:46 +00:00
|
|
|
|
const payloadData = ref([])
|
|
|
|
|
|
|
|
|
|
function addCommunicationPayload(mbData) {
|
|
|
|
|
const { id, targetType, extendInfo } = mbData
|
|
|
|
|
|
|
|
|
|
const payLoadType = window.settings.mbDict[targetType].payload
|
|
|
|
|
if (payLoadType === 'radar') {
|
|
|
|
|
payloadData.value = [
|
|
|
|
|
{
|
|
|
|
|
id,
|
|
|
|
|
radius: null,
|
|
|
|
|
minimumClock: null,
|
|
|
|
|
maximumClock: 90,
|
|
|
|
|
minimumCone: null,
|
|
|
|
|
maximumCone: null,
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
} else if (payLoadType === 'conic') {
|
|
|
|
|
payloadData.value = [
|
|
|
|
|
{
|
|
|
|
|
id,
|
|
|
|
|
angle: null,
|
|
|
|
|
show: false,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
const { mbPayloadShowMap } = useEntity()
|
|
|
|
|
|
|
|
|
|
function renderMubiaoDetailsContent(mbData) {
|
|
|
|
|
payloadData.value = []
|
|
|
|
|
const { id, targetType, extendInfo } = mbData
|
|
|
|
|
const payLoadType = window.settings.mbDict[targetType].payload
|
2025-01-20 01:42:19 +00:00
|
|
|
|
|
2025-02-19 08:06:46 +00:00
|
|
|
|
if (extendInfo) {
|
|
|
|
|
payloadData.value = [
|
|
|
|
|
{
|
|
|
|
|
id,
|
|
|
|
|
...extendInfo.detectingPayload,
|
|
|
|
|
show: mbPayloadShowMap.get(id).detectingPayload.show,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
// return h(
|
|
|
|
|
// 'div',
|
|
|
|
|
// {},
|
|
|
|
|
// Object.keys(mbData).map(key => h('div', {}, `${key}:${mbData[key]}`))
|
|
|
|
|
// )
|
|
|
|
|
return () => (
|
|
|
|
|
<div class="detail-container w-[45vw]">
|
|
|
|
|
<div class="detail-item-title">基本信息</div>
|
|
|
|
|
<div>
|
|
|
|
|
{Object.keys(mbData).map(key => (
|
|
|
|
|
<div>
|
|
|
|
|
{key}:{mbData[key]}
|
|
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
{/* <div class="detail-item-title">探测载荷</div>
|
|
|
|
|
*/}
|
|
|
|
|
<div class="flex justify-between">
|
|
|
|
|
<div class="detail-item-title">探测载荷</div>
|
|
|
|
|
{payloadData.value.length === 0 && (
|
|
|
|
|
<NButton
|
|
|
|
|
quaternary
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={() => addCommunicationPayload(mbData)}
|
|
|
|
|
>
|
|
|
|
|
添加
|
|
|
|
|
</NButton>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
{payloadData.value.length > 0 && (
|
|
|
|
|
<Detection target="mb" type={payLoadType} data={payloadData.value} />
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
<div class="flex justify-end gap-2">
|
|
|
|
|
<NButton
|
|
|
|
|
type="primary"
|
|
|
|
|
onClick={() =>
|
|
|
|
|
updateMbLoad({
|
|
|
|
|
mbData,
|
|
|
|
|
detection: payloadData.value,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
>
|
|
|
|
|
确定
|
|
|
|
|
</NButton>
|
|
|
|
|
{/* <NButton onClick={closeDetailsModal}>取消</NButton> */}
|
|
|
|
|
</div>
|
2025-01-20 01:42:19 +00:00
|
|
|
|
</div>
|
2025-02-19 08:06:46 +00:00
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
function showDetailsMubiao(mbData) {
|
|
|
|
|
openDetailsModal({
|
|
|
|
|
titleString: 'zb详情',
|
|
|
|
|
contentSlot: renderMubiaoDetailsContent(mbData),
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateMbLoad({ mbData, detection }) {
|
|
|
|
|
const { getMubiaoData } = useMubiao()
|
|
|
|
|
const { id, show, ...detectionData } = detection[0]
|
|
|
|
|
const payloadData = {
|
|
|
|
|
id: mbData.id,
|
|
|
|
|
extendInfo: {
|
|
|
|
|
detectingPayload: { ...detectionData },
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
// console.log(payloadData)
|
|
|
|
|
updateMbPayload(payloadData).then(res => {
|
|
|
|
|
if (res.code === '200') {
|
|
|
|
|
window.$message.success('保存成功')
|
|
|
|
|
getMubiaoData()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return { showDetailsMubiao }
|
2025-01-20 01:42:19 +00:00
|
|
|
|
}
|