feat: 引擎维护回显操作
parent
b0be771679
commit
58cbf4c98d
|
@ -65,3 +65,43 @@ export function delRuleengine(id) {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function findRuleEngineById(id) {
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/findRuleEngineById?id='+id,
|
||||||
|
method: 'post',
|
||||||
|
params:id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function addEngineversion(data){
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/addEngineversion',
|
||||||
|
method: 'post',
|
||||||
|
data:data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateRuleActivate(data){
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/updateRuleActivate',
|
||||||
|
method: 'post',
|
||||||
|
data:data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateRuleStatus(data){
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/updateRuleStatus',
|
||||||
|
method: 'post',
|
||||||
|
data:data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function updateEngineCodeIng(data){
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/updateEngineCodeIng',
|
||||||
|
method: 'post',
|
||||||
|
data:data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div style="height: 800px">
|
<div style="height: 800px">
|
||||||
<codemirror ref="codeMirror" v-model="code" :options="cmOptions" style="height: 800px"/>
|
<codemirror ref="codeMirror" v-model="code" :value="code" :options="cmOptions" style="height: 800px"/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -68,11 +68,14 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
code: {
|
'code': {
|
||||||
handler(val) {
|
handler(val) {
|
||||||
|
if (val!=null){
|
||||||
this.$emit('input', val);
|
this.$emit('input', val);
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
immediate: true
|
// immediate: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
|
|
|
@ -70,8 +70,15 @@ export const constantRoutes = [
|
||||||
component: () => import('@/views/index'),
|
component: () => import('@/views/index'),
|
||||||
name: 'Index',
|
name: 'Index',
|
||||||
meta: {title: '首页', icon: 'dashboard', affix: true}
|
meta: {title: '首页', icon: 'dashboard', affix: true}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
path:'ruleengine/engineVersion/:id',
|
||||||
|
name:'EngineVersion',
|
||||||
|
component:()=>import('@/views/ruleengine/engineVersion'),
|
||||||
|
meta:{title:'规则维护',affix:true}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/user',
|
path: '/user',
|
||||||
|
|
|
@ -1,78 +1,523 @@
|
||||||
<template>
|
<template>
|
||||||
<div>
|
<div class="app-container">
|
||||||
{{ruleEngineId}}
|
<el-descriptions class="margin-top" :title="ruleEngineInfo.name" :column="3" border>
|
||||||
<div ref="editor" style="height: 300px; border: 1px solid #ccc; padding: 10px;"></div>
|
<template slot="extra">
|
||||||
|
<el-dropdown split-button type="primary" @command="handleClick">
|
||||||
|
更多操作
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item command="add">版本添加</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="activate">{{(ruleEngineInfo.isActivate === 'no-activate' ? "激活": "禁用")+'引擎'}}</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="status">{{(ruleEngineInfo.status === '0' ? "关闭": "开启")+'引擎'}}</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<el-descriptions-item label="规则名称"> {{ruleEngineInfo.name}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则类型">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_type" :value="ruleEngineInfo.type"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则作用域">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_level" :value="ruleEngineInfo.level"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="引擎编码"> {{ruleEngineInfo.code + " ("+ruleEngineInfo.engineCode+")"}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineInfo.isActivate"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则状态">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_version_status" :value="ruleEngineInfo.status"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<editor style="margin-top: 20px" :read-only="true" v-model="ruleEngineInfo.description"></editor>
|
||||||
|
<el-card class="box-card">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>规则引擎版本</span>
|
||||||
|
</div>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12" v-for="ruleEngineVersion in ruleEngineInfo.engineversionList">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>{{ruleEngineVersion.name + "-" + ruleEngineVersion.code}}</span>
|
||||||
|
<el-dropdown style="float: right; padding: 3px 0" @command="checkRuleEngineVersion">
|
||||||
|
<span class="el-dropdown-link">
|
||||||
|
更多操作<i class="el-icon-arrow-down el-icon--right"></i>
|
||||||
|
</span>
|
||||||
|
<el-dropdown-menu slot="dropdown">
|
||||||
|
<el-dropdown-item :command="{event: 'info', ruleEngineVersion: ruleEngineVersion}">规则详情</el-dropdown-item>
|
||||||
|
<el-dropdown-item :command="{event: 'test', ruleEngineVersion: ruleEngineVersion}"
|
||||||
|
:disabled="ruleEngineVersion.isTest === '0'"
|
||||||
|
>测试规则</el-dropdown-item>
|
||||||
|
<el-dropdown-item :command="{event: 'status', ruleEngineVersion: ruleEngineVersion}"
|
||||||
|
:disabled="ruleEngineVersion.isTest === '0'">
|
||||||
|
{{ruleEngineVersion.isActivate !== 'no-activate' ? "禁用" : "激活"}}规则
|
||||||
|
</el-dropdown-item>
|
||||||
|
<el-dropdown-item
|
||||||
|
:command="{event: 'publish', ruleEngineVersion: ruleEngineVersion}"
|
||||||
|
v-if="ruleEngineVersion.status === '1' && ruleEngineVersion.isTest === '1'">
|
||||||
|
发布规则
|
||||||
|
</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
</div>
|
||||||
|
<el-descriptions class="margin-top" :column="2" border>
|
||||||
|
<el-descriptions-item label="版本类" :span="2"> {{ruleEngineVersion.versionCode}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本名称"> {{ruleEngineVersion.name}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本CODE"> {{ruleEngineVersion.code}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineVersion.isActivate"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本状态">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_version_status" :value="ruleEngineVersion.status"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否测试">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_is_test" :value="ruleEngineVersion.isTest"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<editor style="margin-top: 10px" :read-only="true" v-model="ruleEngineVersion.description"></editor>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-card>
|
||||||
|
<el-dialog
|
||||||
|
title="新增版本" :visible.sync="addVersionStatus"
|
||||||
|
width="75%">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>基本信息</span>
|
||||||
|
<el-button style="float: right; padding: 3px 0" type="text" @click="genEngineVersion">生成引擎版本类</el-button>
|
||||||
|
</div>
|
||||||
|
<el-form :label-position="engineVersionForm" label-width="80px" :model="engineVersionForm">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="版本类">
|
||||||
|
<el-input v-model="engineVersionForm.versionCode" disabled placeholder="点击类生成自动生成类名称"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="名称">
|
||||||
|
<el-input v-model="engineVersionForm.name"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="编码">
|
||||||
|
<el-input v-model="engineVersionForm.code"></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="状态">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_version_status" :value="engineVersionForm.status"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="engineVersionForm.isActivate"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<editor v-model="engineVersionForm.description" :min-height="150"/>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="box-card" v-if="engineVersionForm.codeIng != null">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>引擎编码</span>
|
||||||
|
</div>
|
||||||
|
<encoding style="height: 800px" v-model="engineVersionForm.codeIng"></encoding>
|
||||||
|
</el-card>
|
||||||
|
|
||||||
|
<span slot="footer" class="dialog-footer">
|
||||||
|
<el-button @click="addVersionCancel">取 消</el-button>
|
||||||
|
<el-button type="primary" @click="addVersionSubmission">确 定</el-button>
|
||||||
|
</span>
|
||||||
|
</el-dialog>
|
||||||
|
<el-drawer
|
||||||
|
title="规则版本详情" size="80%" :before-close="ruleEngineVersionInfoStatusClose"
|
||||||
|
:visible.sync="ruleEngineVersionInfoStatus"
|
||||||
|
:direction="'rtl'">
|
||||||
|
<div class="app-container">
|
||||||
|
<el-descriptions v-if="ruleEngineVersionInfoAndTest != null" class="margin-top" :column="2" border>
|
||||||
|
<el-descriptions-item label="版本类" :span="2"> {{ruleEngineVersionInfoAndTest.versionCode}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本名称"> {{ruleEngineVersionInfoAndTest.name}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本CODE"> {{ruleEngineVersionInfoAndTest.code}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineVersionInfoAndTest.isActivate"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本状态">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_version_status" :value="ruleEngineVersionInfoAndTest.status"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否测试">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_is_test" :value="ruleEngineVersionInfoAndTest.isTest"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<editor style="margin-top: 10px" :read-only="true" :min-height="100" v-model="ruleEngineVersionInfoAndTest.description"></editor>
|
||||||
|
<el-row style="margin-top: 10px">
|
||||||
|
<el-button @click="saveCoding">保存代码</el-button>
|
||||||
|
</el-row>
|
||||||
|
<encoding style="height: 800px; margin-top: 20px" v-model="ruleEngineVersionInfoAndTest.codeIng"></encoding>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</el-drawer>
|
||||||
|
<el-drawer
|
||||||
|
title="规则版本测试" size="80%" :before-close="ruleEngineVersionTestStatusClose"
|
||||||
|
:visible.sync="ruleEngineVersionTestStatus"
|
||||||
|
:direction="'rtl'">
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-descriptions v-if="ruleEngineVersionInfoAndTest != null" class="margin-top" :column="2" border>
|
||||||
|
<el-descriptions-item label="版本类" :span="2"> {{ruleEngineVersionInfoAndTest.versionCode}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本名称"> {{ruleEngineVersionInfoAndTest.name}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本CODE"> {{ruleEngineVersionInfoAndTest.code}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineVersionInfoAndTest.isActivate"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="版本状态">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_version_status" :value="ruleEngineVersionInfoAndTest.status"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否测试">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_is_test" :value="ruleEngineVersionInfoAndTest.isTest"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<editor style="margin-top: 10px" :read-only="true" :min-height="105" v-model="ruleEngineVersionInfoAndTest.description"></editor>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col :span="12">
|
||||||
|
<encoding style="margin-top: 20px" v-model="ruleEngineVersionInfoAndTest.codeIng" :read-only="true"></encoding>
|
||||||
|
</el-col>
|
||||||
|
<!-- {{_assetStructure}}-->
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-col :span="assetStructure == null ? 24 : 12">
|
||||||
|
<el-card class="box-card">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>选择数据接入</span>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<el-select v-model="assetStructure" style="width: 100%;">
|
||||||
|
<el-option v-for="_assetStructure in assetStructureList"
|
||||||
|
:key="_assetStructure.accessSourceName"
|
||||||
|
:value="_assetStructure.id"
|
||||||
|
:label="_assetStructure.accessSourceName+'('+_assetStructure.dataSourceSystemName+')'"
|
||||||
|
@change="findInformationById(_assetStructure.id)"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12" v-if="assetStructure != null">
|
||||||
|
<el-card class="box-card" >
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>选择资产结构</span>
|
||||||
|
</div>
|
||||||
|
<el-select v-model="assets" style="width: 100%;">
|
||||||
|
<el-option v-for="_assets in assetsList"
|
||||||
|
:key="_assets.name"
|
||||||
|
:value="_assets.id"
|
||||||
|
:label="_assets.name+'('+_assets.as+')'"
|
||||||
|
></el-option>
|
||||||
|
</el-select>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-card class="box-card" v-if="assets != null">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>选择资产模型</span>
|
||||||
|
</div>
|
||||||
|
<el-descriptions direction="vertical" :column="3" border>
|
||||||
|
<el-descriptions-item v-for="_dataModel in dataModelList"
|
||||||
|
:label='_dataModel.name + "("+_dataModel.comment+")"'>
|
||||||
|
<el-radio v-model="dataMode" :label="_dataModel.name" :value="_dataModel.id">{{dataModeMap[_dataModel.name]}}</el-radio>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="24" style="margin-top: 10px" v-if="dataMode != null">
|
||||||
|
<el-button>测试</el-button>
|
||||||
|
<el-input style="margin-top: 10px" v-model="testResult" type="textarea" placeholder="请点击测试" />
|
||||||
|
</el-col>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-drawer>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import 'codemirror/lib/codemirror.css';
|
import Encoding from "@/components/Encoding/index.vue";
|
||||||
import 'codemirror/mode/javascript/javascript.js';
|
import {
|
||||||
import CodeMirror from 'codemirror';
|
addEngineversion,
|
||||||
import {getRuleContent, ruleengine} from "@/api/ruleengine/ruleengine";
|
findRuleEngineById,
|
||||||
|
updateEngineCodeIng,
|
||||||
|
updateRuleActivate,
|
||||||
|
updateRuleStatus,
|
||||||
|
} from "@/api/ruleengine/ruleengine";
|
||||||
|
import {findAssetStructure, findDataBaseByInformationId, findInformationById} from "@/api/dataSource/source";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "EngineVersion",
|
name: "EngineVersion",
|
||||||
|
components: {Encoding},
|
||||||
|
dicts: ['rule_engine_activate_status', 'rule_engine_type', 'sys_normal_disable',
|
||||||
|
'rule_engine_level', 'rule_engine_version_status', 'rule_engine_activate_is_test'],
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
ruleEngineId:0,
|
ruleEngineId: this.$route.params && this.$route.params.id,
|
||||||
editor: null,
|
ruleEngineInfo: {},
|
||||||
ruleContentReq:{},
|
// 新增版本
|
||||||
value:''
|
addVersionStatus: false,
|
||||||
|
engineVersionForm: {
|
||||||
|
"name": "",
|
||||||
|
"code": "",
|
||||||
|
"status": 0,
|
||||||
|
"versionCode": "",
|
||||||
|
"isActivate": "no-activate",
|
||||||
|
"description": "",
|
||||||
|
"codeIng": null
|
||||||
|
},
|
||||||
|
// 详情抽屉状态
|
||||||
|
ruleEngineVersionInfoStatus: false,
|
||||||
|
// 测试抽屉状态
|
||||||
|
ruleEngineVersionTestStatus: false,
|
||||||
|
// 弹框抽屉
|
||||||
|
ruleEngineVersionInfoAndTest: {},
|
||||||
|
// 数据接入集合
|
||||||
|
assetStructureList: [],
|
||||||
|
// 数据接入集合选择
|
||||||
|
assetStructure: null,
|
||||||
|
// 数据资产
|
||||||
|
assetsList: [],
|
||||||
|
// 数据资产选择
|
||||||
|
assets: null,
|
||||||
|
// 数据模型
|
||||||
|
dataModelList: [],
|
||||||
|
// 数据模型选择
|
||||||
|
dataMode: null,
|
||||||
|
// 数据示例
|
||||||
|
dataModeMap: {
|
||||||
|
id: 1,
|
||||||
|
name: "张三",
|
||||||
|
sex: 1,
|
||||||
|
price: "653.69",
|
||||||
|
create_time: "2024-5-7 16:37:16",
|
||||||
|
},
|
||||||
|
testResult: ""
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
'$route.query.id': function(toVal, oldVal) {
|
"assetStructure":{
|
||||||
this.ruleEngineId = toVal;
|
handler(val) {
|
||||||
if (this.ruleEngineId) {
|
console.log("123",val)
|
||||||
this.getRuleContentAndUpdateEditor();
|
if (val != null) {
|
||||||
|
findInformationById(val).then(
|
||||||
|
res=>{
|
||||||
|
this.assetsList=res.data;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"assets":{
|
||||||
|
handler(val){
|
||||||
|
console.log(val)
|
||||||
|
if (val!=null){
|
||||||
|
findDataBaseByInformationId(val).then(
|
||||||
|
res=>{
|
||||||
|
this.dataModelList=res.data;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.ruleEngineId=this.$route.query && this.$route.query.id
|
this.initRuleEngine();
|
||||||
// 初始化 CodeMirror(如果尚未初始化)
|
this.findAssetStructure();
|
||||||
if (!this.editor) {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.editor = CodeMirror(this.$refs.editor, {
|
|
||||||
value: "",
|
|
||||||
mode: "javascript",
|
|
||||||
lineNumbers: true,
|
|
||||||
});
|
|
||||||
if (this.ruleEngineId) {
|
|
||||||
this.getRuleContentAndUpdateEditor();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getRuleContentAndUpdateEditor() {
|
|
||||||
getRuleContent(this.ruleEngineId).then(
|
findInformationById(id){
|
||||||
|
console.log("123",id)
|
||||||
|
findInformationById(id).then(
|
||||||
res=>{
|
res=>{
|
||||||
if (res && res.data && res.data.ruleContent) {
|
this.assetsList=res.data;
|
||||||
console.log('Received rule content:', res.data.ruleContent);
|
|
||||||
this.editor.setValue(res.data.ruleContent);
|
|
||||||
} else {
|
|
||||||
console.log('No rule content found for id', this.ruleEngineId);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
).catch(error => {
|
|
||||||
console.error('Error fetching rule content:', error);
|
|
||||||
});
|
|
||||||
},
|
|
||||||
tosend(){
|
|
||||||
const code = this.editor.getValue();
|
|
||||||
this.ruleContentReq.ruleContent=code
|
|
||||||
console.log(this.ruleContentReq)
|
|
||||||
ruleengine(this.ruleContentReq).then(
|
|
||||||
res=>{
|
|
||||||
this.$message.success(res.data)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
saveCoding(){
|
||||||
|
updateEngineCodeIng(this.ruleEngineVersionInfoAndTest).then(
|
||||||
|
res=>{
|
||||||
|
this.$message.success(res.msg);
|
||||||
|
// 详情抽屉状态
|
||||||
|
this.ruleEngineVersionInfoStatus=false
|
||||||
|
this.ruleEngineVersionInfoAndTest()
|
||||||
|
},
|
||||||
|
)
|
||||||
|
},
|
||||||
|
ruleEngineVersionInfoStatusClose(done) {
|
||||||
|
this.$confirm('确认关闭?')
|
||||||
|
.then(_ => {
|
||||||
|
this.ruleEngineVersionInfoAndTest = {};
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(_ => {});
|
||||||
|
},
|
||||||
|
ruleEngineVersionTestStatusClose(done) {
|
||||||
|
this.$confirm('确认关闭?')
|
||||||
|
.then(_ => {
|
||||||
|
this.ruleEngineVersionInfoAndTest = {};
|
||||||
|
done();
|
||||||
|
})
|
||||||
|
.catch(_ => {});
|
||||||
|
},
|
||||||
|
// 点击规则事件
|
||||||
|
checkRuleEngineVersion(command) {
|
||||||
|
switch (command.event) {
|
||||||
|
case "info"://详情
|
||||||
|
this.ruleEngineVersionInfoStatus = true;
|
||||||
|
this.ruleEngineVersionInfoAndTest = command.ruleEngineVersion;
|
||||||
|
break;
|
||||||
|
case "test"://测试
|
||||||
|
this.ruleEngineVersionTestStatus = true;
|
||||||
|
this.ruleEngineVersionInfoAndTest = command.ruleEngineVersion;
|
||||||
|
break;
|
||||||
|
case "status"://激活状态
|
||||||
|
command.ruleEngineVersion.isActivate = 'no-activate' === command.ruleEngineVersion.isActivate ? 'activated' : 'no-activate'
|
||||||
|
break;
|
||||||
|
case "publish"://发布
|
||||||
|
command.ruleEngineVersion.status = '2'
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
console.log(command.event);
|
||||||
|
console.log(command.ruleEngineVersion);
|
||||||
|
},
|
||||||
|
// 生成规则版本
|
||||||
|
genEngineVersion(){
|
||||||
|
if (this.engineVersionForm.name == null || this.engineVersionForm.name === "") {
|
||||||
|
this.$message.error('规则名称不可为空');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.engineVersionForm.code == null || this.engineVersionForm.code === "") {
|
||||||
|
this.$message.error('规则CODE不可为空');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (this.engineVersionForm.description == null || this.engineVersionForm.description === "") {
|
||||||
|
this.$message.error('规则版本使用描述不可为空');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.engineVersionForm.versionCode = this.ruleEngineInfo.engineCode + "_" + this.engineVersionForm.code
|
||||||
|
this.engineVersionForm.codeIng = this.getCodeIng()
|
||||||
|
},
|
||||||
|
// 确定新增
|
||||||
|
addVersionSubmission(){
|
||||||
|
// this.ruleEngineInfo.ruleEngineVersionList.push({... this.engineVersionForm})
|
||||||
|
this.engineVersionForm.ruleId = this.ruleEngineInfo.id
|
||||||
|
addEngineversion(this.engineVersionForm).then(
|
||||||
|
res=>{
|
||||||
|
this.$modal.msgSuccess(res.msg);
|
||||||
|
this.addVersionStatus = false;
|
||||||
|
this.initRuleEngine();
|
||||||
|
}
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
|
},
|
||||||
|
// 取消新增
|
||||||
|
addVersionCancel(){
|
||||||
|
this.engineVersionForm = {
|
||||||
|
"name": "", "code": "", "status": "0", "isTest": "0",
|
||||||
|
"versionCode": "",
|
||||||
|
"isActivate": "no-activate",
|
||||||
|
"description": "",
|
||||||
|
"codeIng": null, "ruleEngineVersionList": []
|
||||||
|
};
|
||||||
|
this.addVersionStatus = false;
|
||||||
|
},
|
||||||
|
handleClick(clickType){
|
||||||
|
if (clickType === "add"){
|
||||||
|
this.addVersionStatus = true;
|
||||||
|
}else if(clickType === "activate"){
|
||||||
|
|
||||||
|
this.ruleEngineInfo.isActivate = 'no-activate' === this.ruleEngineInfo.isActivate ? 'activated' : 'no-activate'
|
||||||
|
console.log(this.ruleEngineInfo.isActivate)
|
||||||
|
updateRuleActivate(this.ruleEngineInfo).then(
|
||||||
|
res=>{
|
||||||
|
this.$modal.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// this.$modal.msgSuccess("引擎激活状态修改成功");
|
||||||
|
}else if(clickType === "status"){
|
||||||
|
this.ruleEngineInfo.status = '0' === this.ruleEngineInfo.status ? '1' : '0'
|
||||||
|
updateRuleStatus(this.ruleEngineInfo).then(
|
||||||
|
res=>{
|
||||||
|
this.$modal.msgSuccess(res.msg);
|
||||||
|
}
|
||||||
|
)
|
||||||
|
// this.$modal.msgSuccess("引擎状态操作成功");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
findAssetStructure(){
|
||||||
|
findAssetStructure().then(
|
||||||
|
res=>{
|
||||||
|
this.assetStructureList = res.data;
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
initRuleEngine(){
|
||||||
|
console.log("123",this.ruleEngineId)
|
||||||
|
findRuleEngineById(this.ruleEngineId).then(
|
||||||
|
res=>{
|
||||||
|
this.ruleEngineInfo = res.data;
|
||||||
|
console.log(this.ruleEngineInfo)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
},
|
||||||
|
// 获取代码模板
|
||||||
|
getCodeIng(){
|
||||||
|
|
||||||
|
let packageName = "com.muyu.rule.engine";
|
||||||
|
let customName = "custom";
|
||||||
|
let templateName = "template";
|
||||||
|
let parentClass = "DataModelEngine";
|
||||||
|
let codeIng = `package ${packageName}.${customName};
|
||||||
|
|
||||||
|
import com.muyu.engine.action.ActionDiscard;
|
||||||
|
import com.muyu.engine.scope.${parentClass};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: LiuDeKang
|
||||||
|
* @date: ${new Date().toLocaleString()}
|
||||||
|
* @Description: ${this.engineVersionForm.name}-${this.engineVersionForm.code}
|
||||||
|
* @Version: 1.0
|
||||||
|
*/
|
||||||
|
public class ${this.engineVersionForm.versionCode} extends ${parentClass} {
|
||||||
|
@Override
|
||||||
|
public void execution () {
|
||||||
|
Object value = getValue();
|
||||||
|
|
||||||
|
if (value == null || "".equals(value) || "null".equals(value)) {
|
||||||
|
throw new ActionDiscard();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}`;
|
||||||
|
return codeIng;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
.box-card{
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
.el-dropdown-link {
|
||||||
|
cursor: pointer;
|
||||||
|
color: #409EFF;
|
||||||
|
}
|
||||||
|
.el-icon-arrow-down {
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
.CodeMirror {
|
||||||
|
height: 600px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -86,6 +86,7 @@
|
||||||
<el-table v-loading="loading" :data="engineList" @selection-change="handleSelectionChange">
|
<el-table v-loading="loading" :data="engineList" @selection-change="handleSelectionChange">
|
||||||
<el-table-column type="selection" width="55" align="center"/>
|
<el-table-column type="selection" width="55" align="center"/>
|
||||||
<el-table-column label="规则名称" align="center" prop="name"/>
|
<el-table-column label="规则名称" align="center" prop="name"/>
|
||||||
|
<el-table-column label="编码" align="center" prop="engineCode"/>
|
||||||
<el-table-column label="规则类型" align="center" prop="type">
|
<el-table-column label="规则类型" align="center" prop="type">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<dict-tag :options="dict.type.rule_engine_type" :value="scope.row.type"/>
|
<dict-tag :options="dict.type.rule_engine_type" :value="scope.row.type"/>
|
||||||
|
@ -171,6 +172,11 @@
|
||||||
<el-input v-model="form.code" placeholder="请输入规则编码"/>
|
<el-input v-model="form.code" placeholder="请输入规则编码"/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-col>
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="编码" prop="code">
|
||||||
|
<el-input v-model="form.engineCode" placeholder="请输入编码"/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
|
@ -263,7 +269,7 @@ import 'codemirror/lib/codemirror.css';
|
||||||
import 'codemirror/mode/javascript/javascript.js';
|
import 'codemirror/mode/javascript/javascript.js';
|
||||||
import CodeMirror from 'codemirror';
|
import CodeMirror from 'codemirror';
|
||||||
import {
|
import {
|
||||||
addRuleengine,
|
addRuleengine, delRuleengine,
|
||||||
getRuleengine,
|
getRuleengine,
|
||||||
listRuleengine,
|
listRuleengine,
|
||||||
loader,
|
loader,
|
||||||
|
@ -377,7 +383,7 @@ export default {
|
||||||
},
|
},
|
||||||
toEngineVersion(row) {
|
toEngineVersion(row) {
|
||||||
console.log(row)
|
console.log(row)
|
||||||
this.$router.push({path: '/ruleengine/engineVersion', query: {id: row.id}});
|
this.$router.push({ path:`/ruleengine/engineVersion/${row.id} `});
|
||||||
},
|
},
|
||||||
/** 查询规则引擎列表 */
|
/** 查询规则引擎列表 */
|
||||||
getList() {
|
getList() {
|
||||||
|
|
|
@ -35,7 +35,7 @@ module.exports = {
|
||||||
proxy: {
|
proxy: {
|
||||||
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
// detail: https://cli.vuejs.org/config/#devserver-proxy
|
||||||
[process.env.VUE_APP_BASE_API]: {
|
[process.env.VUE_APP_BASE_API]: {
|
||||||
target: `http://localhost:8080`,
|
target: `http://localhost:18080`,
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
pathRewrite: {
|
pathRewrite: {
|
||||||
['^' + process.env.VUE_APP_BASE_API]: ''
|
['^' + process.env.VUE_APP_BASE_API]: ''
|
||||||
|
|
Loading…
Reference in New Issue