mirror of
http://112.124.100.131/ebiz-ai/ebiz-ai-knowledge-manage.git
synced 2025-12-16 14:26:50 +08:00
feat(应用管理): 优化规则编辑对话框和主页面的字段类型过滤功能
- 在 RuleEditDialog 组件中添加规则类型变更事件处理,更新字段类型列表- 在主页面中添加规则类型变更事件处理,更新字段类型列表 - 优化字段类型列表的过滤逻辑,根据选中的规则类型动态显示相关字段 -调整字段类型列表的数据结构,使用 id 作为 key 值
This commit is contained in:
@@ -18,12 +18,13 @@
|
|||||||
v-model="ruleForm.ruleType"
|
v-model="ruleForm.ruleType"
|
||||||
placeholder="请选择规则类型"
|
placeholder="请选择规则类型"
|
||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
|
@change="handleRuleTypeChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in ruleTypeList"
|
v-for="item in ruleTypeList"
|
||||||
:key="item.typeCode"
|
:key="item.typeCode"
|
||||||
:label="item.typeName"
|
:label="item.typeName"
|
||||||
:value="item.typeCode"
|
:value="item.typeName"
|
||||||
>
|
>
|
||||||
</el-option>
|
</el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
@@ -37,7 +38,7 @@
|
|||||||
style="width: 100%"
|
style="width: 100%"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in fieldTypeList"
|
v-for="item in filteredFieldTypeList"
|
||||||
:key="item.fieldName"
|
:key="item.fieldName"
|
||||||
:label="item.fieldComment"
|
:label="item.fieldComment"
|
||||||
:value="item.fieldName"
|
:value="item.fieldName"
|
||||||
@@ -168,6 +169,7 @@ export default {
|
|||||||
ruleStatus: 1,
|
ruleStatus: 1,
|
||||||
runType: 'ai'
|
runType: 'ai'
|
||||||
},
|
},
|
||||||
|
filteredFieldTypeList: [],
|
||||||
// 表单验证规则
|
// 表单验证规则
|
||||||
rules: {
|
rules: {
|
||||||
ruleType: [
|
ruleType: [
|
||||||
@@ -248,6 +250,8 @@ export default {
|
|||||||
handler(val) {
|
handler(val) {
|
||||||
if (val && Object.keys(val).length > 0) {
|
if (val && Object.keys(val).length > 0) {
|
||||||
this.ruleForm = Object.assign({}, val)
|
this.ruleForm = Object.assign({}, val)
|
||||||
|
|
||||||
|
console.log(this.ruleForm)
|
||||||
} else {
|
} else {
|
||||||
this.ruleForm = {
|
this.ruleForm = {
|
||||||
id: '',
|
id: '',
|
||||||
@@ -263,14 +267,65 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
immediate: true
|
immediate: true
|
||||||
|
},
|
||||||
|
// 监听规则类型列表变化
|
||||||
|
ruleTypeList: {
|
||||||
|
handler() {
|
||||||
|
this.updateFieldTypeList()
|
||||||
|
},
|
||||||
|
immediate: true
|
||||||
|
},
|
||||||
|
// 监听规则类型选择变化
|
||||||
|
'ruleForm.ruleType': {
|
||||||
|
handler() {
|
||||||
|
this.updateFieldTypeList()
|
||||||
|
},
|
||||||
|
immediate: true,
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
// 更新字段类型列表
|
||||||
|
updateFieldTypeList() {
|
||||||
|
// 如果规则类型列表为空,设置字段类型列表为空数组
|
||||||
|
if (!this.ruleTypeList || this.ruleTypeList.length === 0) {
|
||||||
|
this.filteredFieldTypeList = []
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果未选择规则类型,返回所有字段类型
|
||||||
|
if (!this.ruleForm.ruleType) {
|
||||||
|
this.filteredFieldTypeList = this.fieldTypeList
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
const ruleType = this.ruleTypeList.find(
|
||||||
|
item => item.typeName === this.ruleForm.ruleType
|
||||||
|
)
|
||||||
|
|
||||||
|
if (ruleType) {
|
||||||
|
console.log(ruleType, 1)
|
||||||
|
this.filteredFieldTypeList = this.fieldTypeList.filter(item => {
|
||||||
|
console.log(item)
|
||||||
|
return item.ruleTypeId === ruleType.id
|
||||||
|
})
|
||||||
|
|
||||||
|
console.log(this.filteredFieldTypeList)
|
||||||
|
} else {
|
||||||
|
this.filteredFieldTypeList = []
|
||||||
|
}
|
||||||
|
},
|
||||||
// 关闭对话框
|
// 关闭对话框
|
||||||
handleClose() {
|
handleClose() {
|
||||||
this.$refs.ruleForm.resetFields()
|
this.$refs.ruleForm.resetFields()
|
||||||
this.$emit('update:visible', false)
|
this.$emit('update:visible', false)
|
||||||
},
|
},
|
||||||
|
// 处理规则类型变更事件,与主页面保持一致效果
|
||||||
|
handleRuleTypeChange(value) {
|
||||||
|
this.ruleForm.ruleField = ''
|
||||||
|
// 更新已由watch处理,无需额外操作
|
||||||
|
this.updateFieldTypeList()
|
||||||
|
},
|
||||||
// 提交表单
|
// 提交表单
|
||||||
handleSubmit() {
|
handleSubmit() {
|
||||||
this.$refs.ruleForm.validate(valid => {
|
this.$refs.ruleForm.validate(valid => {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
size="medium"
|
size="medium"
|
||||||
clearable
|
clearable
|
||||||
placeholder="请选择规则类型"
|
placeholder="请选择规则类型"
|
||||||
|
@change="handleRuleTypeChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in ruleTypeList"
|
v-for="item in ruleTypeList"
|
||||||
@@ -43,10 +44,10 @@
|
|||||||
placeholder="请选择字段类型"
|
placeholder="请选择字段类型"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in fieldTypeList"
|
v-for="item in fieldTypeListCopy"
|
||||||
:label="item.fieldComment"
|
:label="item.fieldComment"
|
||||||
:value="item.fieldName"
|
:value="item.fieldName"
|
||||||
:key="item.fieldName"
|
:key="item.id"
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -172,6 +173,7 @@ export default {
|
|||||||
ruleTypeList: [],
|
ruleTypeList: [],
|
||||||
// 字段类型选项列表
|
// 字段类型选项列表
|
||||||
fieldTypeList: [],
|
fieldTypeList: [],
|
||||||
|
fieldTypeListCopy: [],
|
||||||
// 风险类型选项列表
|
// 风险类型选项列表
|
||||||
riskTypeList: [],
|
riskTypeList: [],
|
||||||
// 规则状态选项列表
|
// 规则状态选项列表
|
||||||
@@ -240,7 +242,7 @@ export default {
|
|||||||
isRedraw: true,
|
isRedraw: true,
|
||||||
render: (h, params) => {
|
render: (h, params) => {
|
||||||
const buttons = []
|
const buttons = []
|
||||||
|
|
||||||
// 所有状态都显示查看详情按钮
|
// 所有状态都显示查看详情按钮
|
||||||
buttons.push(
|
buttons.push(
|
||||||
h(
|
h(
|
||||||
@@ -258,7 +260,7 @@ export default {
|
|||||||
''
|
''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
// 规则状态为"停用"(ruleStatus === 1)时显示编辑和删除按钮
|
// 规则状态为"停用"(ruleStatus === 1)时显示编辑和删除按钮
|
||||||
if (params.row.ruleStatus === 1) {
|
if (params.row.ruleStatus === 1) {
|
||||||
buttons.push(
|
buttons.push(
|
||||||
@@ -292,7 +294,7 @@ export default {
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// 显示启用/停用按钮(根据当前状态显示不同图标)
|
// 显示启用/停用按钮(根据当前状态显示不同图标)
|
||||||
buttons.push(
|
buttons.push(
|
||||||
h(
|
h(
|
||||||
@@ -312,7 +314,7 @@ export default {
|
|||||||
''
|
''
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return h('div', buttons)
|
return h('div', buttons)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,6 +331,19 @@ export default {
|
|||||||
this.getRiskTypeList()
|
this.getRiskTypeList()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
handleRuleTypeChange(value) {
|
||||||
|
let ruleType = this.ruleTypeList.filter(
|
||||||
|
item => item.typeCode === value
|
||||||
|
)[0]
|
||||||
|
if (ruleType) {
|
||||||
|
this.fieldTypeListCopy = this.fieldTypeList.filter(item => {
|
||||||
|
console.log(item)
|
||||||
|
return item.ruleTypeId === ruleType.id
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
this.fieldTypeListCopy = []
|
||||||
|
}
|
||||||
|
},
|
||||||
// 获取规则列表数据
|
// 获取规则列表数据
|
||||||
getList() {
|
getList() {
|
||||||
this.loading = true
|
this.loading = true
|
||||||
|
|||||||
Reference in New Issue
Block a user