|
@@ -191,6 +191,7 @@
|
|
|
placeholder="请选择归属租户"
|
|
|
:options="tenantOptions"
|
|
|
:style="inputStyle"
|
|
|
+ allow-clear
|
|
|
>
|
|
|
</a-select>
|
|
|
</a-form-item>
|
|
@@ -210,6 +211,32 @@
|
|
|
</template>
|
|
|
</a-input>
|
|
|
</a-form-item>
|
|
|
+ <a-form-item label="监护对象年龄" name="guardAge">
|
|
|
+ <a-input
|
|
|
+ v-model:value.trim="baseFormState.guardAge"
|
|
|
+ placeholder="请输入监护对象年龄"
|
|
|
+ :style="inputStyle"
|
|
|
+ >
|
|
|
+ <template #suffix>
|
|
|
+ <a-tooltip>
|
|
|
+ <template #title>
|
|
|
+ <div>年龄范围: 1 - 120</div>
|
|
|
+ </template>
|
|
|
+ <info-circle-outlined style="color: rgba(0, 0, 0, 0.45)" />
|
|
|
+ </a-tooltip>
|
|
|
+ </template>
|
|
|
+ </a-input>
|
|
|
+ </a-form-item>
|
|
|
+ <a-form-item label="监护对象类型" name="guardType">
|
|
|
+ <a-select
|
|
|
+ v-model:value="baseFormState.guardType"
|
|
|
+ placeholder="请选择监护对象类型"
|
|
|
+ :options="guardTypeOptions"
|
|
|
+ :style="inputStyle"
|
|
|
+ allow-clear
|
|
|
+ >
|
|
|
+ </a-select>
|
|
|
+ </a-form-item>
|
|
|
|
|
|
<div class="footer" :style="{ marginLeft: '100px' }">
|
|
|
<a-space>
|
|
@@ -236,6 +263,7 @@ import * as deviceApi from '@/api/device'
|
|
|
import * as tenantAPI from '@/api/tenant'
|
|
|
import type { TenantItem } from '@/api/tenant/types'
|
|
|
import { useUserStore } from '@/stores/user'
|
|
|
+import { useDict } from '@/hooks/useDict'
|
|
|
|
|
|
defineOptions({
|
|
|
name: 'deviceBaseConfig',
|
|
@@ -271,6 +299,8 @@ interface BaseFormState {
|
|
|
northAngle: NorthAngle // 正北向夹角
|
|
|
tenantId: ID // 租户id
|
|
|
fallingConfirm: ID // 跌倒确认
|
|
|
+ guardAge?: ID // 监护对象年龄
|
|
|
+ guardType?: ID // 监护对象类型
|
|
|
}
|
|
|
|
|
|
const spinning = ref(false)
|
|
@@ -288,6 +318,8 @@ const baseFormState = reactive<BaseFormState>({
|
|
|
northAngle: 0,
|
|
|
tenantId: null,
|
|
|
fallingConfirm: 53,
|
|
|
+ guardAge: null,
|
|
|
+ guardType: null,
|
|
|
})
|
|
|
|
|
|
// 范围输入框尺寸
|
|
@@ -328,6 +360,8 @@ const saveBaseConfig = async () => {
|
|
|
Number(baseFormState?.fallingConfirm) > 0
|
|
|
? Number(baseFormState?.fallingConfirm)
|
|
|
: null,
|
|
|
+ age: baseFormState?.guardAge ? Number(baseFormState?.guardAge) : null,
|
|
|
+ guardianshipType: baseFormState?.guardType ? String(baseFormState?.guardType) : null,
|
|
|
})
|
|
|
saveBaseLoading.value = false
|
|
|
message.success('保存成功')
|
|
@@ -383,6 +417,24 @@ const rules: Record<string, Rule[]> = {
|
|
|
trigger: ['change', 'blur'],
|
|
|
},
|
|
|
],
|
|
|
+ guardAge: [
|
|
|
+ {
|
|
|
+ validator: (_rule: Rule, value: string) => {
|
|
|
+ if (!value) {
|
|
|
+ return Promise.resolve()
|
|
|
+ }
|
|
|
+ if (!/^\d+$/.test(value)) {
|
|
|
+ return Promise.reject(new Error('必须为整数'))
|
|
|
+ }
|
|
|
+ const num = parseInt(value, 10)
|
|
|
+ if (num < 1 || num > 120) {
|
|
|
+ return Promise.reject(new Error('年龄范围: 1 - 120'))
|
|
|
+ }
|
|
|
+ return Promise.resolve()
|
|
|
+ },
|
|
|
+ trigger: ['change', 'blur'],
|
|
|
+ },
|
|
|
+ ],
|
|
|
// xRangeStart: [
|
|
|
// {
|
|
|
// required: true,
|
|
@@ -449,6 +501,19 @@ const fetchTenantList = async () => {
|
|
|
}
|
|
|
fetchTenantList()
|
|
|
|
|
|
+const guardTypeOptions = ref<{ label: string; value: string }[]>([])
|
|
|
+const { dictList, fetchDict } = useDict('guardianship_type')
|
|
|
+
|
|
|
+const fetchGuardTypeOptions = async () => {
|
|
|
+ fetchDict().then(() => {
|
|
|
+ guardTypeOptions.value = dictList.value.map((item) => ({
|
|
|
+ label: item.label,
|
|
|
+ value: item.value as string,
|
|
|
+ }))
|
|
|
+ })
|
|
|
+}
|
|
|
+fetchGuardTypeOptions()
|
|
|
+
|
|
|
// 获取设备回显数据
|
|
|
const fetchDeviceBaseInfo = async () => {
|
|
|
console.log('fetchDeviceDetail', props)
|
|
@@ -475,6 +540,8 @@ const fetchDeviceBaseInfo = async () => {
|
|
|
baseFormState.northAngle = res.data.northAngle
|
|
|
baseFormState.tenantId = res.data.tenantId
|
|
|
baseFormState.fallingConfirm = res.data.fallingConfirm
|
|
|
+ baseFormState.guardAge = res.data.age
|
|
|
+ baseFormState.guardType = res.data.guardianshipType
|
|
|
} catch (error) {
|
|
|
console.error('❌获取设备详情失败', error)
|
|
|
}
|