lzh 2 ヶ月 前
コミット
1396bd3167
1 ファイル変更127 行追加41 行削除
  1. 127 41
      src/views/rule/config/components/CreateDialog.vue

+ 127 - 41
src/views/rule/config/components/CreateDialog.vue

@@ -174,27 +174,17 @@
                         <div class="text-right">条件{{ sIndex + 1 }}</div>
                       </el-col>
                       <el-col :span="6">
-                        <div class="rule-condition">
+                        <div class="rule-condition" @click="openCategoryDialog(index, sIndex, 'qztj')">
                           <el-input
                             :value="getDisplayName(sItem.param1)"
                             placeholder="请选择"
                             size="small"
-                            style="width: calc(100% - 70px)"
                             readonly
-                            @click="openCategoryDialog(index, sIndex, 'qztj')"
+                            style="width: 100%"
                           />
-                          <el-button
-                            size="small"
-                            style="width: 70px"
-                            class="category-select"
-                            @click="openCategoryDialog(index, sIndex, 'qztj')"
-                          >
-                            <i class="el-icon-s-operation" style="margin-right: 5px" />
-                            选择
-                          </el-button>
                         </div>
                       </el-col>
-                      <el-col :span="4">
+                      <el-col :span="3">
                         <el-select
                           v-model="sItem.condition"
                           filterable
@@ -274,10 +264,23 @@
                       <el-col v-else-if="['等于', '不等于', '包含', '不包含', '大于', '小于', '大于等于', '小于等于'].includes(sItem.condition)" :span="6">
                         <div class="input-with-category">
                           <template v-if="sItem.hasChildOptions">
+                            <!-- 当有三级数据时显示只读输入框和选择按钮 -->
+                            <el-input
+                              v-if="sItem.hasThirdLevel"
+                              :value="sItem.param2"
+                              placeholder="请选择"
+                              size="small"
+                              readonly
+                              style="width: calc(100% - 90px)"
+                            />
+                            <!-- 当没有三级数据时显示多选下拉框 -->
                             <el-select
+                              v-else
                               v-model="sItem.param2"
                               multiple
                               collapse-tags
+                              filterable
+                              clearable
                               placeholder="请选择"
                               size="small"
                               style="width: calc(100% - 90px)"
@@ -300,12 +303,26 @@
                               @input="(value) => handleInput(value, index, sIndex, 'qztj')"
                             />
                           </template>
+                          <!-- 当有三级数据时显示选择按钮 -->
+                          <el-button
+                            v-if="sItem.hasThirdLevel"
+                            size="small"
+                            style="width: 90px"
+                            class="category-select"
+                            @click="openChildOptionsDialog(index, sIndex)"
+                          >
+                            <i class="el-icon-s-operation" style="margin-right: 5px" />
+                            选择
+                          </el-button>
+                          <!-- 当没有三级数据时显示类型选择 -->
                           <el-select
+                            v-else
                             v-model="sItem.categoryType"
                             size="small"
                             placeholder="文本"
-                            style="width: 70px"
+                            style="width: 90px"
                             class="category-select"
+                            :disabled="sItem.categoryTypeDisabled"
                           >
                             <i slot="prefix" class="el-icon-s-operation" />
                             <el-option
@@ -419,24 +436,14 @@
                         <div class="text-right">逻辑{{ sIndex + 1 }}</div>
                       </el-col>
                       <el-col :span="6">
-                        <div class="rule-condition">
+                        <div class="rule-condition" @click="openCategoryDialog(index, sIndex, 'rule')">
                           <el-input
                             :value="getDisplayName(sItem.param1)"
                             placeholder="请选择"
                             size="small"
-                            style="width: calc(100% - 70px)"
                             readonly
-                            @click="openCategoryDialog(index, sIndex, 'rule')"
+                            style="width: 100%"
                           />
-                          <el-button
-                            size="small"
-                            style="width: 70px"
-                            class="category-select"
-                            @click="openCategoryDialog(index, sIndex, 'rule')"
-                          >
-                            <i class="el-icon-s-operation" style="margin-right: 5px" />
-                            选择
-                          </el-button>
                         </div>
                       </el-col>
                       <el-col :span="3">
@@ -519,10 +526,23 @@
                       <el-col v-else-if="['等于', '不等于', '包含', '不包含', '大于', '小于', '大于等于', '小于等于'].includes(sItem.condition)" :span="6">
                         <div class="input-with-category">
                           <template v-if="sItem.hasChildOptions">
+                            <!-- 当有三级数据时显示只读输入框和选择按钮 -->
+                            <el-input
+                              v-if="sItem.hasThirdLevel"
+                              :value="sItem.param2"
+                              placeholder="请选择"
+                              size="small"
+                              readonly
+                              style="width: calc(100% - 90px)"
+                            />
+                            <!-- 当没有三级数据时显示多选下拉框 -->
                             <el-select
+                              v-else
                               v-model="sItem.param2"
                               multiple
                               collapse-tags
+                              filterable
+                              clearable
                               placeholder="请选择"
                               size="small"
                               style="width: calc(100% - 90px)"
@@ -545,12 +565,26 @@
                               @input="(value) => handleInput(value, index, sIndex, 'rule')"
                             />
                           </template>
+                          <!-- 当有三级数据时显示选择按钮 -->
+                          <el-button
+                            v-if="sItem.hasThirdLevel"
+                            size="small"
+                            style="width: 90px"
+                            class="category-select"
+                            @click="openChildOptionsDialog(index, sIndex)"
+                          >
+                            <i class="el-icon-s-operation" style="margin-right: 5px" />
+                            选择
+                          </el-button>
+                          <!-- 当没有三级数据时显示类型选择 -->
                           <el-select
+                            v-else
                             v-model="sItem.categoryType"
                             size="small"
                             placeholder="文本"
                             style="width: 90px"
                             class="category-select"
+                            :disabled="sItem.categoryTypeDisabled"
                           >
                             <i slot="prefix" class="el-icon-s-operation" />
                             <el-option
@@ -661,8 +695,16 @@
                       <el-col :span="2">
                         <div class="text-right">条件{{ sIndex + 1 }}</div>
                       </el-col>
-                      <el-col :span="6">
-                        <el-input v-model="sItem.input1" clearable placeholder="请输入" style="width: 100%;" />
+                      <el-col :span="8">
+                        <div class="rule-condition" @click="openCategoryDialog(index, sIndex, 'custom_basis')">
+                          <el-input
+                            :value="getDisplayName(sItem.param1)"
+                            placeholder="请选择"
+                            size="small"
+                            readonly
+                            style="width: 100%"
+                          />
+                        </div>
                       </el-col>
                       <el-col :span="6">
                         <div class="rule-condition">
@@ -727,24 +769,14 @@
                         <div class="text-right">事件</div>
                       </el-col>
                       <el-col :span="7">
-                        <div class="rule-condition">
+                        <div class="rule-condition" @click="openCategoryDialog(index, 0, 'custom_msg')">
                           <el-input
                             :value="getDisplayName(item.custom_msg.param1)"
                             placeholder="请选择"
                             size="small"
-                            style="width: calc(100% - 90px)"
                             readonly
-                            @click="openCategoryDialog(index, 0, 'custom_msg')"
+                            style="width: 100%"
                           />
-                          <el-button
-                            size="small"
-                            style="width: 90px"
-                            class="category-select"
-                            @click="openCategoryDialog(index, 0, 'custom_msg')"
-                          >
-                            <i class="el-icon-s-operation" style="margin-right: 5px" />
-                            选择
-                          </el-button>
                         </div>
                       </el-col>
                       <el-col :span="1"> + </el-col>
@@ -1519,12 +1551,14 @@ export default {
           if (condition) {
             condition.param1 = [parentField, subItem.field]
             condition.field_name = subItem.field_name
-
+            condition.categoryTypeDisabled = false
             // 检查子数据类型
             if (subItem.type === 2 && subItem.child && subItem.child.length > 0) {
               const dictData = subItem.child.find(item => item.type === 4)
               if (dictData) {
                 condition.hasChildOptions = true
+                condition.categoryType = '选择'
+                condition.categoryTypeDisabled = true // 重置禁用标志
                 // type=4 的情况,获取字典数据
                 get_dict_by_type({
                   table: dictData.field,
@@ -1542,6 +1576,49 @@ export default {
                 // type=3 的情况,直接使用 child 数据
                 condition.hasChildOptions = true
                 condition.childOptions = subItem.child
+                condition.categoryType = '选择' // 设置为选择类型
+                condition.categoryTypeDisabled = true // 添加禁用标志
+              } else {
+                // 没有子数据时重置标志
+                condition.categoryTypeDisabled = false
+                condition.hasChildOptions = false
+              }
+            }
+          }
+        } else if (this.currentSource === 'rule') {
+          const condition = this.ruleForm.rule[this.currentRuleIndex].condition_content[this.currentConditionIndex]
+          if (condition) {
+            condition.param1 = [parentField, subItem.field]
+            condition.field_name = subItem.field_name
+
+            condition.categoryTypeDisabled = false
+            if (subItem.type === 2 && subItem.child && subItem.child.length > 0) {
+              const dictData = subItem.child.find(item => item.type === 4)
+              if (dictData) {
+                condition.hasChildOptions = true
+                condition.categoryType = '选择'
+                condition.categoryTypeDisabled = true // 重置禁用标志
+                get_dict_by_type({
+                  table: dictData.field,
+                  field: dictData.field_name
+                }).then(res => {
+                  if (res?.p) {
+                    condition.childOptions = res.p.map(item => ({
+                      field: item.dep_name,
+                      field_name: item.dep_name
+                    }))
+                  }
+                })
+              } else if (subItem.child.some(item => item.type === 3)) {
+                // type=3 的情况,直接使用 child 数据
+                condition.hasChildOptions = true
+                condition.childOptions = subItem.child
+                condition.categoryType = '选择' // 设置为选择类型
+                condition.categoryTypeDisabled = true // 添加禁用标志
+              } else {
+                // 没有子数据时重置标志
+                condition.categoryTypeDisabled = false
+                condition.hasChildOptions = false
               }
             }
           }
@@ -2023,6 +2100,15 @@ export default {
   position: relative;
   display: flex;
   align-items: center;
+  cursor: pointer; // 添加手型光标
+
+  .el-input {
+    cursor: pointer;
+
+    ::v-deep .el-input__inner {
+      cursor: pointer;
+    }
+  }
 }
 
 .knowledge-content {