gaoluyang
2026-06-24 bfdc0e0e6d5e47aa501f9b6fadd143d9c97cf00a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!-- 基础信息配置组件 -->
<script setup lang="ts">
import type { RuleSceneApi } from '#/api/iot/rule/scene';
 
import { DICT_TYPE } from '../../../../../../packages/constants/src';
import { getDictOptions } from '../../../../../../packages/effects/hooks/src';
import { IconifyIcon } from '../../../../../../packages/icons/src';
 
import { useVModel } from '@vueuse/core';
import { Card, Col, Form, Input, Radio, Row } from 'ant-design-vue';
 
import { DictTag } from '#/components/dict-tag';
 
/** 基础信息配置组件 */
defineOptions({ name: 'BasicInfoSection' });
 
const props = defineProps<{
  modelValue: RuleSceneApi.SceneRule;
}>();
 
const emit = defineEmits<{
  (e: 'update:modelValue', value: RuleSceneApi.SceneRule): void;
}>();
 
const formData = useVModel(props, 'modelValue', emit); // 表单数据
</script>
 
<template>
  <Card class="rounded-[8px] mb-[10px]! border border-primary" shadow="never">
    <template #title>
      <div class="flex items-center justify-between">
        <div class="gap-[8px] flex items-center">
          <IconifyIcon icon="ep:info-filled" class="text-[18px] text-primary" />
          <span class="text-[16px] font-semibold text-foreground">
            基础信息
          </span>
        </div>
        <div class="gap-[8px] flex items-center">
          <DictTag :type="DICT_TYPE.COMMON_STATUS" :value="formData.status" />
        </div>
      </div>
    </template>
 
    <div class="p-0">
      <Row :gutter="24" class="mb-[24px]">
        <Col :span="12">
          <Form.Item label="场景名称" name="name" required>
            <Input
              v-model:value="formData.name"
              placeholder="请输入场景名称"
              :maxlength="50"
              show-word-limit
              allow-clear
            />
          </Form.Item>
        </Col>
        <Col :span="12">
          <Form.Item label="场景状态" name="status" required>
            <Radio.Group v-model:value="formData.status">
              <Radio
                v-for="(dict, index) in getDictOptions(
                  DICT_TYPE.COMMON_STATUS,
                  'number',
                )"
                :key="index"
                :value="dict.value"
              >
                {{ dict.label }}
              </Radio>
            </Radio.Group>
          </Form.Item>
        </Col>
      </Row>
      <Form.Item label="场景描述" name="description">
        <Input.TextArea
          v-model:value="formData.description"
          placeholder="请输入场景描述(可选)"
          :rows="3"
          :maxlength="200"
          show-word-limit
          resize="none"
        />
      </Form.Item>
    </div>
  </Card>
</template>
 
<style scoped>
:deep(.ant-form-item) {
  margin-bottom: 20px;
}
 
:deep(.ant-form-item:last-child) {
  margin-bottom: 0;
}
</style>