feat: 引擎初始化
commit
dcb096d509
|
@ -37,6 +37,8 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@riophae/vue-treeselect": "0.4.0",
|
"@riophae/vue-treeselect": "0.4.0",
|
||||||
|
"@vue/compiler-core": "^3.4.26",
|
||||||
|
"@vue/compiler-ssr": "^3.4.26",
|
||||||
"axios": "0.24.0",
|
"axios": "0.24.0",
|
||||||
"clipboard": "2.0.8",
|
"clipboard": "2.0.8",
|
||||||
"codemirror": "^5.65.16",
|
"codemirror": "^5.65.16",
|
||||||
|
@ -54,7 +56,7 @@
|
||||||
"screenfull": "5.0.2",
|
"screenfull": "5.0.2",
|
||||||
"sortablejs": "1.10.2",
|
"sortablejs": "1.10.2",
|
||||||
"vue": "2.6.12",
|
"vue": "2.6.12",
|
||||||
"vue-codemirror": "^6.1.1",
|
"vue-codemirror": "^4.0.6",
|
||||||
"vue-count-to": "1.0.13",
|
"vue-count-to": "1.0.13",
|
||||||
"vue-cropper": "0.5.5",
|
"vue-cropper": "0.5.5",
|
||||||
"vue-meta": "2.4.0",
|
"vue-meta": "2.4.0",
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
import request from '@/utils/request'
|
||||||
|
|
||||||
|
// 查询资产授权列表
|
||||||
|
export function listAuth(query) {
|
||||||
|
return request({
|
||||||
|
url: '/source/auth/list',
|
||||||
|
method: 'get',
|
||||||
|
params:query
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 新增资产授权
|
||||||
|
export function addAuth(data) {
|
||||||
|
return request({
|
||||||
|
url: '/source/auth',
|
||||||
|
method: 'post',
|
||||||
|
data: data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除资产授权
|
||||||
|
export function delAuth(data) {
|
||||||
|
return request({
|
||||||
|
url: '/source/auth/remove' ,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
|
@ -65,3 +65,34 @@ export function delRuleengine(id) {
|
||||||
method: 'delete'
|
method: 'delete'
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function details(data){
|
||||||
|
return request({
|
||||||
|
url: '/rule/rule/details?id='+data,
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
export function versionsAdd(data){
|
||||||
|
return request({
|
||||||
|
url: '/rule/versions/versionsAdd',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function engineOnOff(data){
|
||||||
|
return request({
|
||||||
|
url: '/rule/rule/engineOnOff',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function statusOnOff(data){
|
||||||
|
return request({
|
||||||
|
url: '/rule/rule/statusOnOff',
|
||||||
|
method: 'post',
|
||||||
|
data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
<template>
|
||||||
|
<div style="height: 800px">
|
||||||
|
<codemirror ref="codeMirror" :value="code" :options="cmOptions" style="height: 800px"/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { codemirror } from 'vue-codemirror'
|
||||||
|
|
||||||
|
import 'codemirror/mode/clike/clike';
|
||||||
|
// cm-setting.js
|
||||||
|
// 组件样式
|
||||||
|
import 'codemirror/lib/codemirror.css';
|
||||||
|
// 主题
|
||||||
|
import 'codemirror/theme/eclipse.css';
|
||||||
|
// html代码高亮
|
||||||
|
import 'codemirror/mode/htmlmixed/htmlmixed.js';
|
||||||
|
|
||||||
|
// 语言模式
|
||||||
|
import 'codemirror/mode/javascript/javascript.js';
|
||||||
|
import 'codemirror/mode/css/css.js';
|
||||||
|
import 'codemirror/mode/xml/xml.js';
|
||||||
|
// 代码展开折叠
|
||||||
|
import 'codemirror/addon/fold/foldcode.js';
|
||||||
|
import 'codemirror/addon/fold/foldgutter.js';
|
||||||
|
import 'codemirror/addon/fold/foldgutter.css';
|
||||||
|
import 'codemirror/addon/fold/brace-fold.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
codemirror,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
default: "",
|
||||||
|
type: String
|
||||||
|
},
|
||||||
|
readOnly: {
|
||||||
|
default: false,
|
||||||
|
type: Boolean
|
||||||
|
}
|
||||||
|
},
|
||||||
|
name: "Encoding",
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
codemirror: null,
|
||||||
|
code: this.value,
|
||||||
|
cmOptions: {
|
||||||
|
autoRefresh: true, // 重点是这句,为true
|
||||||
|
value: '', // 初始内容
|
||||||
|
mode: 'text/x-java', //实现Java代码高亮
|
||||||
|
tabSize: 4, // tab的空格宽度
|
||||||
|
styleActiveLine: true, // 设置光标所在行高亮true/false
|
||||||
|
lineNumbers: true, //显示行号
|
||||||
|
theme: 'eclipse', //设置主题cobalt/monokai
|
||||||
|
// json: true,
|
||||||
|
readOnly: this.readOnly, // 设置为只读true/false;也可设置为"nocursor"失去焦点
|
||||||
|
lineWrapping: false,
|
||||||
|
foldGutter: true,
|
||||||
|
gutters: [
|
||||||
|
'CodeMirror-lint-markers', //代码错误检测
|
||||||
|
'CodeMirror-linenumbers',
|
||||||
|
'CodeMirror-foldgutter', //展开折叠
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods: {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
|
||||||
|
.CodeMirror {
|
||||||
|
font-family: 'JetBrainsMono-Medium', monospace;
|
||||||
|
height: 500px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.CodeMirror-lines {
|
||||||
|
line-height: 1.5; /* 这里的1.5是示例,表示行间距是字体大小的1.5倍 */
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -70,6 +70,12 @@ 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: '规则维护', icon: 'dashboard', affix: true}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
|
@ -0,0 +1,140 @@
|
||||||
|
<template>
|
||||||
|
<el-col :span="22" :offset="1">
|
||||||
|
<el-card>
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>公共配置</span>
|
||||||
|
</div>
|
||||||
|
<el-form ref="form" :model="ruleEngineCommonConfig" label-width="120px">
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="24">
|
||||||
|
<el-form-item label="规则基础目录">
|
||||||
|
<el-input v-model="ruleEngineCommonConfig.packageName" disabled></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="自定义基础目录">
|
||||||
|
<el-input v-model="ruleEngineCommonConfig.customName" disabled></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="模板基础目录">
|
||||||
|
<el-input v-model="ruleEngineCommonConfig.templateName" disabled></el-input>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
</el-card>
|
||||||
|
<el-col>
|
||||||
|
<el-card>
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>作用域</span>
|
||||||
|
</div>
|
||||||
|
<el-tabs type="border-card" v-model="codeCardStatus">
|
||||||
|
<el-tab-pane v-for="scope in scopeList" :label="scope.type" :name="scope.value">
|
||||||
|
<encoding v-if="codeCardStatus === scope.value" style="height: 600px" v-model="scope.code" :read-only="true"></encoding>
|
||||||
|
</el-tab-pane>
|
||||||
|
</el-tabs>
|
||||||
|
</el-card>
|
||||||
|
</el-col>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
import Encoding from "@/components/Encoding/index.vue";
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "EngineConfig",
|
||||||
|
components: {Encoding},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
codeCardStatus: "taskContext",
|
||||||
|
ruleEngineCommonConfig: {
|
||||||
|
packageName: "com.muyu.rule.engine",
|
||||||
|
customName: "custom",
|
||||||
|
templateName: "template",
|
||||||
|
},
|
||||||
|
scopeList: [
|
||||||
|
{ type: "任务", value: "taskContext", "code":
|
||||||
|
"package com.muyu.scope;\n" +
|
||||||
|
"\n" +
|
||||||
|
"/**\n" +
|
||||||
|
" * @Author: DongZeLiang\n" +
|
||||||
|
" * @date: 2024/4/29\n" +
|
||||||
|
" * @Description: 任务上下文\n" +
|
||||||
|
" * @Version: 1.0\n" +
|
||||||
|
" */\n" +
|
||||||
|
"public class TaskContext {\n" +
|
||||||
|
"\n" +
|
||||||
|
" public static TaskContext build(){\n" +
|
||||||
|
" return new TaskContext();\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}\n"
|
||||||
|
},
|
||||||
|
{ type: "资产集", value: "recordContext", "code":
|
||||||
|
"package com.muyu.scope;\n" +
|
||||||
|
"\n" +
|
||||||
|
"/**\n" +
|
||||||
|
" * @Author: DongZeLiang\n" +
|
||||||
|
" * @date: 2024/4/29\n" +
|
||||||
|
" * @Description: 数据集\n" +
|
||||||
|
" * @Version: 1.0\n" +
|
||||||
|
" */\n" +
|
||||||
|
"public class DataSetContext {\n" +
|
||||||
|
"\n" +
|
||||||
|
" private final RecordContext recordContext;\n" +
|
||||||
|
"\n" +
|
||||||
|
" public DataSetContext (RecordContext recordContext) {\n" +
|
||||||
|
" this.recordContext = recordContext;\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}\n" },
|
||||||
|
{ type: "资产记录", value: "dataSetContext", "code":
|
||||||
|
"package com.muyu.scope;\n" +
|
||||||
|
"\n" +
|
||||||
|
"/**\n" +
|
||||||
|
" * @Author: DongZeLiang\n" +
|
||||||
|
" * @date: 2024/4/29\n" +
|
||||||
|
" * @Description: 记录/资产模型\n" +
|
||||||
|
" * @Version: 1.0\n" +
|
||||||
|
" */\n" +
|
||||||
|
"public class RecordContext {\n" +
|
||||||
|
"\n" +
|
||||||
|
" private final TaskContext taskContext;\n" +
|
||||||
|
"\n" +
|
||||||
|
" public RecordContext (TaskContext taskContext) {\n" +
|
||||||
|
" this.taskContext = taskContext;\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}\n" },
|
||||||
|
{ type: "资产模型", value: "dataModelContext", "code":
|
||||||
|
"package com.muyu.scope;\n" +
|
||||||
|
"\n" +
|
||||||
|
"/**\n" +
|
||||||
|
" * @Author: DongZeLiang\n" +
|
||||||
|
" * @date: 2024/4/29\n" +
|
||||||
|
" * @Description: 数据模型\n" +
|
||||||
|
" * @Version: 1.0\n" +
|
||||||
|
" */\n" +
|
||||||
|
"public class DataModelContext {\n" +
|
||||||
|
"\n" +
|
||||||
|
" private final DataSetContext dataSetContext;\n" +
|
||||||
|
"\n" +
|
||||||
|
" public DataModelContext (DataSetContext dataSetContext) {\n" +
|
||||||
|
" this.dataSetContext = dataSetContext;\n" +
|
||||||
|
" }\n" +
|
||||||
|
"}\n" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
},
|
||||||
|
methods: {}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.el-col {
|
||||||
|
margin-top: 20px;
|
||||||
|
}
|
||||||
|
</style>
|
|
@ -0,0 +1,466 @@
|
||||||
|
<template>
|
||||||
|
<div class="app-container">
|
||||||
|
<el-descriptions class="margin-top" :title="ruleEngineInfo.name" :column="3" border>
|
||||||
|
<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.ruleengine.isActivate === 'no-activate' ? "激活":"禁用")+'引擎'}}</el-dropdown-item>
|
||||||
|
<el-dropdown-item command="status">{{(ruleEngineInfo.ruleengine.status === '0' ? "关闭": "开启")+'引擎'}}</el-dropdown-item>
|
||||||
|
</el-dropdown-menu>
|
||||||
|
</el-dropdown>
|
||||||
|
|
||||||
|
</template>
|
||||||
|
<el-descriptions-item label="规则名称">
|
||||||
|
{{ruleEngineInfo.ruleengine.name}}
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则类型">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_type" :value="ruleEngineInfo.ruleengine.type"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则作用域">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_level" :value="ruleEngineInfo.ruleengine.level"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="引擎编码"> {{ruleEngineInfo.ruleengine.code + " ("+ruleEngineInfo.ruleengine.engineCode+")"}} </el-descriptions-item>
|
||||||
|
<el-descriptions-item label="是否激活">
|
||||||
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineInfo.ruleengine.isActivate"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="规则状态">
|
||||||
|
<dict-tag :options="dict.type.sys_normal_disable" :value="ruleEngineInfo.ruleengine.status"/>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<editor style="margin-top: 20px" :read-only="true" v-model="ruleEngineInfo.ruleengine.description"></editor>
|
||||||
|
|
||||||
|
<el-card class="box-card" v-if="ruleEngineInfo.engineVersionList.length>0">
|
||||||
|
<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}">测试规则</el-dropdown-item>
|
||||||
|
<el-dropdown-item :command="{event: 'status', ruleEngineVersion: ruleEngineVersion}" :disabled="ruleEngineVersion.status !== '2'">
|
||||||
|
{{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 :data="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"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</el-drawer>
|
||||||
|
<el-drawer
|
||||||
|
title="规则版本测试" size="80%" :before-close="ruleEngineVersionTestStatusClose"
|
||||||
|
:visible.sync="ruleEngineVersionTestStatus"
|
||||||
|
:direction="'rtl'" v-if="ruleEngineVersionInfoAndTest.status === 1" v-else-if="ruleEngineVersionInfoAndTest.status">
|
||||||
|
<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>
|
||||||
|
<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.name"
|
||||||
|
:value="_assetStructure.name"
|
||||||
|
:label="_assetStructure.name+'('+_assetStructure.systemName+')'"
|
||||||
|
></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.name"
|
||||||
|
: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>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import {details, versionsAdd, engineOnOff,statusOnOff} from "@/api/rule/maintenance"
|
||||||
|
import Encoding from "@/components/Encoding/index.vue";
|
||||||
|
export default {
|
||||||
|
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() {
|
||||||
|
return {
|
||||||
|
ruleEngineId:this.$route.params && this.$route.params.id,
|
||||||
|
ruleEngineInfo: {
|
||||||
|
ruleengine:{
|
||||||
|
id:null,
|
||||||
|
name:null,
|
||||||
|
code:null,
|
||||||
|
type:null,
|
||||||
|
level:null,
|
||||||
|
isActivate:null,
|
||||||
|
status:null,
|
||||||
|
description:null,
|
||||||
|
engineCode:null
|
||||||
|
},
|
||||||
|
engineVersionList:[],
|
||||||
|
},
|
||||||
|
// 新增版本
|
||||||
|
addVersionStatus: false,
|
||||||
|
engineVersionForm: {
|
||||||
|
ruleId:0,
|
||||||
|
name:null,
|
||||||
|
code:null,
|
||||||
|
status: "0",
|
||||||
|
versionCode : null,
|
||||||
|
isActivate: "no-activate",
|
||||||
|
description: null,
|
||||||
|
codeIng: null,
|
||||||
|
isTest:"0"
|
||||||
|
},
|
||||||
|
// 详情抽屉状态
|
||||||
|
ruleEngineVersionInfoStatus: false,
|
||||||
|
// 测试抽屉状态
|
||||||
|
ruleEngineVersionTestStatus: false,
|
||||||
|
// 弹框抽屉
|
||||||
|
ruleEngineVersionInfoAndTest:{},
|
||||||
|
show:null,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
created() {
|
||||||
|
this.initRuleEngine();
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
//保存代码
|
||||||
|
saveCoding: function() {
|
||||||
|
},
|
||||||
|
//规则版本详情
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
this.engineVersionForm.versionCode = this.ruleEngineInfo.ruleengine.engineCode + "_" + this.engineVersionForm.code
|
||||||
|
this.engineVersionForm.codeIng= this.getCodeIng(this.ruleEngineInfo.ruleengine.level)
|
||||||
|
},
|
||||||
|
//引擎末班
|
||||||
|
getCodeIng(value){
|
||||||
|
let parentClass=null
|
||||||
|
console.log("规则作用域",value)
|
||||||
|
if (value === 'taskContext') {
|
||||||
|
parentClass = "DataSetContext";
|
||||||
|
}else if (value === 'recordContext'){
|
||||||
|
parentClass = "RecordContext";
|
||||||
|
}else if (value === 'dataSetContext'){
|
||||||
|
parentClass = "DataModelEngine";
|
||||||
|
}
|
||||||
|
let packageName = "com.muyu.rule.engine";
|
||||||
|
let customName = "custom";
|
||||||
|
let templateName = "template";
|
||||||
|
|
||||||
|
|
||||||
|
let codeIng = `package ${packageName}.${customName};
|
||||||
|
|
||||||
|
|
||||||
|
import com.muyu.engine.action.ActionDiscard;
|
||||||
|
import com.muyu.engine.scope.${parentClass};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author: DongZeLiang
|
||||||
|
* @date: 2024/5/6
|
||||||
|
* @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;
|
||||||
|
},
|
||||||
|
// 确定新增
|
||||||
|
addVersionSubmission(){
|
||||||
|
this.engineVersionForm.ruleId=this.$route.params.id
|
||||||
|
console.log("engineVersionForm",this.engineVersionForm)
|
||||||
|
versionsAdd(this.engineVersionForm).then(res=>{
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
this.addVersionStatus=false
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
this.engineVersionForm={}
|
||||||
|
}else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
this.addVersionStatus=false
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
this.engineVersionForm={}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
// 取消新增
|
||||||
|
addVersionCancel(){
|
||||||
|
this.addVersionStatus = false
|
||||||
|
},
|
||||||
|
handleClick(clickType){
|
||||||
|
console.log("clickType",clickType)
|
||||||
|
if (clickType === "add"){
|
||||||
|
//添加引擎版本
|
||||||
|
this.addVersionStatus = true;
|
||||||
|
}else if(clickType === "activate"){
|
||||||
|
//修改是否激活引擎
|
||||||
|
this.ruleEngineInfo.ruleengine.isActivate = 'no-activate' === this.ruleEngineInfo.ruleengine.isActivate ? 'activated' : 'no-activate'
|
||||||
|
engineOnOff(this.ruleEngineInfo.ruleengine).then(res=>{
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
}else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}else if(clickType === "status"){
|
||||||
|
//修改规则引擎的状态
|
||||||
|
this.ruleEngineInfo.ruleengine.status = '0' === this.ruleEngineInfo.ruleengine.status ? '1' : '0'
|
||||||
|
statusOnOff(this.ruleEngineInfo.ruleengine).then(res=>{
|
||||||
|
if (res.code === 200) {
|
||||||
|
this.$message.success(res.msg)
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
}else {
|
||||||
|
this.$message.error(res.msg)
|
||||||
|
this.initRuleEngine(this.ruleEngineId)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//查规则引擎信息和版本信息
|
||||||
|
initRuleEngine(){
|
||||||
|
details(this.$route.params.id).then(res=>{
|
||||||
|
this.ruleEngineInfo=res.data
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<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>
|
|
@ -109,18 +109,6 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
@click="loader(scope.row)"
|
|
||||||
>加载
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
|
||||||
size="mini"
|
|
||||||
type="text"
|
|
||||||
@click="addEngine(scope.row)"
|
|
||||||
>代码编辑
|
|
||||||
</el-button>
|
|
||||||
<el-button
|
<el-button
|
||||||
size="mini"
|
size="mini"
|
||||||
type="text"
|
type="text"
|
||||||
|
@ -243,31 +231,16 @@
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<!--编写代码-->
|
|
||||||
<el-dialog
|
|
||||||
title="代码编辑器"
|
|
||||||
:visible.sync="dialogVisible"
|
|
||||||
width="50%"
|
|
||||||
>
|
|
||||||
<div ref="editor" style="height: 300px; border: 1px solid #ccc; padding: 10px;"></div>
|
|
||||||
<div slot="footer" class="dialog-footer">
|
|
||||||
<el-button type="primary" @click="tosend">确 定</el-button>
|
|
||||||
</div>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import 'codemirror/lib/codemirror.css';
|
import 'codemirror/lib/codemirror.css';
|
||||||
import 'codemirror/mode/javascript/javascript.js';
|
import 'codemirror/mode/javascript/javascript.js';
|
||||||
import CodeMirror from 'codemirror';
|
|
||||||
import {
|
import {
|
||||||
addRuleengine, delRuleengine,
|
addRuleengine, delRuleengine,
|
||||||
getRuleengine,
|
getRuleengine,
|
||||||
listRuleengine,
|
listRuleengine,
|
||||||
loader,
|
|
||||||
ruleengine,
|
|
||||||
updateRuleengine
|
updateRuleengine
|
||||||
} from '@/api/rule/maintenance'
|
} from '@/api/rule/maintenance'
|
||||||
|
|
||||||
|
@ -343,28 +316,31 @@ export default {
|
||||||
this.getList();
|
this.getList();
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
addEngine(row) {
|
//代码编辑
|
||||||
this.ruleContentReq.ruleId=row.id
|
// addEngine(row) {
|
||||||
this.isEditorVisible = true
|
// this.ruleContentReq.ruleId=row.id
|
||||||
this.dialogVisible = true;
|
// this.isEditorVisible = true
|
||||||
// 初始化 CodeMirror(如果尚未初始化)
|
// this.dialogVisible = true;
|
||||||
if (!this.editor) {
|
// // 初始化 CodeMirror(如果尚未初始化)
|
||||||
this.$nextTick(() => {
|
// if (!this.editor) {
|
||||||
this.editor = CodeMirror(this.$refs.editor, {
|
// this.$nextTick(() => {
|
||||||
value: "public class Test {\n public boolean execute(String name) {\n if (name == null || name.length() == 0) {\n System.out.println(\"哈哈哈哈\");\n return true;\n }\n return false;\n }\n}",
|
// this.editor = CodeMirror(this.$refs.editor, {
|
||||||
mode: "javascript",
|
// value: "public class Test {\n public boolean execute(String name) {\n if (name == null || name.length() == 0) {\n System.out.println(\"哈哈哈哈\");\n return true;\n }\n return false;\n }\n}",
|
||||||
lineNumbers: true,
|
// mode: "javascript",
|
||||||
});
|
// lineNumbers: true,
|
||||||
});
|
// });
|
||||||
}
|
// });
|
||||||
},
|
// }
|
||||||
loader(row){
|
// },
|
||||||
loader(row.id).then(
|
//引擎记载
|
||||||
res=>{
|
// loader(row){
|
||||||
this.$message.success(res.data)
|
// loader(row.id).then(
|
||||||
}
|
// res=>{
|
||||||
)
|
// this.$message.success(res.data)
|
||||||
},
|
// }
|
||||||
|
// )
|
||||||
|
// },
|
||||||
|
//编辑代码
|
||||||
tosend(){
|
tosend(){
|
||||||
const code = this.editor.getValue();
|
const code = this.editor.getValue();
|
||||||
this.ruleContentReq.ruleContent=code
|
this.ruleContentReq.ruleContent=code
|
||||||
|
@ -377,7 +353,7 @@ export default {
|
||||||
},
|
},
|
||||||
toEngineVersion(row) {
|
toEngineVersion(row) {
|
||||||
console.log(row)
|
console.log(row)
|
||||||
this.$router.push({path: '/rule/engineVersion/',query: {id: row.id}});
|
this.$router.push({ path: `/ruleengine/engineVersion/${row.id}`});
|
||||||
},
|
},
|
||||||
/** 查询规则引擎列表 */
|
/** 查询规则引擎列表 */
|
||||||
getList() {
|
getList() {
|
||||||
|
|
Loading…
Reference in New Issue