瀏覽代碼

refactor(规则模型): 优化条件表单的UI和逻辑

- 将“右侧内容区”注释改为“右侧添加条件抽屉”以更清晰描述功能
- 为开场白输入框添加动态占位符,显示当前索引
- 将添加开场白按钮改为仅在最后一个开场白项旁显示
- 调整滑块宽度以改善布局
- 添加“是否致命”开关项
- 重构条件表单初始化逻辑,移除冗余代码
闪电 8 月之前
父節點
當前提交
b5c8b20973
共有 1 個文件被更改,包括 24 次插入23 次删除
  1. 24 23
      src/views/rules/models.vue

+ 24 - 23
src/views/rules/models.vue

@@ -53,7 +53,7 @@
53 53
           <el-empty :image-size="200" />
54 54
         </div>
55 55
       </div>
56
-      <!-- 右侧内容区 -->
56
+      <!-- 右侧添加条件抽屉 -->
57 57
       <div class="flex-1 overflow-hidden">
58 58
         <el-drawer v-model="showConditionDrawer" title="添加条件" size="40%">
59 59
           <el-form :model="conditionForm" label-width="100px">
@@ -73,15 +73,16 @@
73 73
             <el-form-item label="开场白">
74 74
               <div v-for="(greeting, index) in conditionForm.greetings" :key="index" class="mb-2">
75 75
                 <div class="flex items-center">
76
-                  <el-input v-model="conditionForm.greetings[index]" placeholder="请输入开场白" class="flex-1" style="width: 500px;"/>
76
+                  <el-input v-model="conditionForm.greetings[index]" :placeholder="`请输入开场白${index + 1}`" class="flex-1" style="width: 500px;"/>
77 77
                   <el-button type="danger" @click="removeGreeting(index)" :icon="Delete" circle class="ml-2" />
78
+                  <el-button v-if="index === conditionForm.greetings.length - 1" @click="addGreeting" :icon="Plus" circle class="ml-2" />
78 79
                 </div>
79 80
               </div>
80
-              <el-button type="primary" @click="addGreeting">添加开场白</el-button>
81
+              <!-- <el-button type="primary" @click="addGreeting">添加开场白</el-button> -->
81 82
             </el-form-item>
82 83
             <el-form-item label="分值">
83 84
               <div class="flex items-center">
84
-                <el-slider v-model="conditionForm.score" :max="100" class="flex-1 mr-4" />
85
+                <el-slider v-model="conditionForm.score" :max="100" class="flex-1 mr-4" style="width: 400px;"/>
85 86
                 <el-input-number v-model="conditionForm.score" :min="0" :max="100" />
86 87
               </div>
87 88
             </el-form-item>
@@ -94,6 +95,9 @@
94 95
             <el-form-item label="是否预警">
95 96
               <el-switch v-model="conditionForm.warning" />
96 97
             </el-form-item>
98
+            <el-form-item label="是否致命">
99
+              <el-switch v-model="conditionForm.warning" />
100
+            </el-form-item>
97 101
           </el-form>
98 102
           <div class="flex justify-end mt-4">
99 103
             <el-button @click="showConditionDrawer = false">取消</el-button>
@@ -163,9 +167,9 @@
163 167
 </template>
164 168
 <script lang="ts" setup name="RuleModel">
165 169
 import { ref, onMounted } from 'vue';
166
-import { getPageListData } from '@/api/main/system/system'
167 170
 import { Edit, Delete, Search, Plus, MoreFilled } from '@element-plus/icons-vue';
168 171
 import moment from 'moment';
172
+import { createPageData, getPageListData, editPageData, deletePageData } from '@/api/main/system/system';
169 173
 
170 174
 const searchQuery = ref('');
171 175
 const selectedModel = ref(0);
@@ -184,14 +188,6 @@ const selectModel = (index: number) => {
184 188
   selectedModel.value = index;
185 189
 };
186 190
 const showConditionDrawer = ref(false);
187
-const conditionForm = ref({
188
-  type: '',
189
-  name: '',
190
-  greetings: [''] as string[],
191
-  score: 0,
192
-  operation: '',
193
-  warning: false
194
-});
195 191
 
196 192
 const addGreeting = () => {
197 193
   conditionForm.value.greetings.push('');
@@ -201,8 +197,22 @@ const removeGreeting = (index: number) => {
201 197
   conditionForm.value.greetings.splice(index, 1);
202 198
 };
203 199
 
204
-const addCondition = () => {
200
+const getModelCases = async () => {
201
+  // 获取模型案例逻辑
202
+  const res = await getPageListData(`/quality/qcresult/getInspectionRulesType`, {});
203
+  if (res?.data?.length) {
204
+    console.log('模型案例', res.data)
205
+  }
206
+  
207
+}
208
+
209
+const conditionForm: any = ref({});
210
+
211
+const addCondition = async () => {
205 212
   showConditionDrawer.value = true;
213
+
214
+  // 获取可用条件列表
215
+  await getModelCases();
206 216
   conditionForm.value = {
207 217
     type: '',
208 218
     name: '',
@@ -215,15 +225,6 @@ const addCondition = () => {
215 225
 const editCondition = (row: any) => {
216 226
   // 编辑条件逻辑
217 227
 };
218
-const deleteCondition = (row: any) => {
219
-  // 删除条件逻辑
220
-};
221
-const save = () => {
222
-  // 保存逻辑
223
-};
224
-const cancel = () => {
225
-  // 取消逻辑
226
-};
227 228
 
228 229
 const getPageList = async () => {
229 230
   const params = {