diff --git a/src/views/ops/pages/dc/server/components/DatacenterSelector.vue b/src/views/ops/pages/dc/server/components/DatacenterSelector.vue
new file mode 100644
index 0000000..36d8928
--- /dev/null
+++ b/src/views/ops/pages/dc/server/components/DatacenterSelector.vue
@@ -0,0 +1,357 @@
+
+
+
+
+ {{ datacenter.label }}
+
+
+
+
+ {{ floor.label }}
+
+
+
+
+ {{ rack.name }} ({{ rack.code }})
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/views/ops/pages/dc/server/components/ServerFormDialog.vue b/src/views/ops/pages/dc/server/components/ServerFormDialog.vue
index 6cb40a2..648b19f 100644
--- a/src/views/ops/pages/dc/server/components/ServerFormDialog.vue
+++ b/src/views/ops/pages/dc/server/components/ServerFormDialog.vue
@@ -47,27 +47,13 @@
-
-
-
-
-
- {{ location.label }}
-
-
-
+
+
@@ -125,6 +111,7 @@ import { ref, reactive, computed, watch } from 'vue'
import { Message } from '@arco-design/web-vue'
import { v4 as uuidv4 } from 'uuid'
import type { FormInstance } from '@arco-design/web-vue'
+import DatacenterSelector from './DatacenterSelector.vue'
interface Props {
visible: boolean
@@ -139,7 +126,7 @@ const emit = defineEmits(['update:visible', 'success'])
const formRef = ref()
const confirmLoading = ref(false)
-const selectedLocation = ref('')
+const datacenterSelectorRef = ref>()
const isEdit = computed(() => !!props.record?.id)
@@ -148,7 +135,9 @@ const formData = reactive({
name: '',
server_type: '',
os: '',
- location: '',
+ datacenter_id: undefined as number | undefined,
+ floor_id: undefined as number | undefined,
+ rack_id: undefined as number | undefined,
tags: '',
ip: '',
remote_port: '',
@@ -164,27 +153,41 @@ const rules = {
os: [{ required: true, message: '请选择操作系统' }],
}
-const locationOptions = ref([
- { label: 'A数据中心-3层-24机柜-5U位', value: 'A数据中心-3层-24机柜-5U位' },
- { label: 'A数据中心-3层-24机柜-6U位', value: 'A数据中心-3层-24机柜-6U位' },
- { label: 'B数据中心-1层-12机柜-1U位', value: 'B数据中心-1层-12机柜-1U位' },
- { label: 'B数据中心-1层-12机柜-2U位', value: 'B数据中心-1层-12机柜-2U位' },
- { label: 'C数据中心-2层-8机柜-3U位', value: 'C数据中心-2层-8机柜-3U位' },
-])
-
watch(
() => props.visible,
(val) => {
if (val) {
if (isEdit.value && props.record) {
- Object.assign(formData, props.record)
+ Object.assign(formData, {
+ unique_id: props.record.unique_id || '',
+ name: props.record.name || '',
+ server_type: props.record.server_type || '',
+ os: props.record.os || '',
+ datacenter_id: props.record.datacenter_id,
+ floor_id: props.record.floor_id,
+ rack_id: props.record.rack_id,
+ tags: props.record.tags || '',
+ ip: props.record.ip || '',
+ remote_port: props.record.remote_port || '',
+ agent_url: props.record.agent_url || '',
+ data_collection: props.record.data_collection || false,
+ collection_interval: props.record.collection_interval || 5,
+ remark: props.record.remark || '',
+ })
+
+ // 编辑模式下初始化加载下级列表
+ if (props.record.datacenter_id) {
+ datacenterSelectorRef.value?.initLoad()
+ }
} else {
Object.assign(formData, {
unique_id: '',
name: '',
server_type: '',
os: '',
- location: '',
+ datacenter_id: undefined,
+ floor_id: undefined,
+ rack_id: undefined,
tags: '',
ip: '',
remote_port: '',
@@ -193,15 +196,12 @@ watch(
collection_interval: 5,
remark: '',
})
+ datacenterSelectorRef.value?.reset()
}
}
}
)
-const handleLocationSelect = (value: string) => {
- formData.location = value
-}
-
const handleOk = async () => {
try {
await formRef.value?.validate()