feat: 数据展示模型
parent
58cbf4c98d
commit
45ca9f2f5c
|
@ -124,3 +124,10 @@ export function updateDatabaseTable(data){
|
||||||
data:data,
|
data:data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
export function findDataSourceByDataBaseId(id){
|
||||||
|
return request({
|
||||||
|
url: '/dataSource/source/findDataSourceByDataBaseId?id='+id,
|
||||||
|
method: 'post',
|
||||||
|
params:id,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
|
@ -105,3 +105,12 @@ export function updateEngineCodeIng(data){
|
||||||
data:data,
|
data:data,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function engineGeneration(codeIng){
|
||||||
|
return request({
|
||||||
|
url: '/ruleengine/ruleengine/engineGeneration',
|
||||||
|
method: 'get',
|
||||||
|
params:codeIng,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineInfo.isActivate"/>
|
<dict-tag :options="dict.type.rule_engine_activate_status" :value="ruleEngineInfo.isActivate"/>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
<el-descriptions-item label="规则状态">
|
<el-descriptions-item label="规则状态">
|
||||||
<dict-tag :options="dict.type.rule_engine_version_status" :value="ruleEngineInfo.status"/>
|
<dict-tag :options="dict.type.sys_normal_disable" :value="ruleEngineInfo.status"/>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
<editor style="margin-top: 20px" :read-only="true" v-model="ruleEngineInfo.description"></editor>
|
<editor style="margin-top: 20px" :read-only="true" v-model="ruleEngineInfo.description"></editor>
|
||||||
|
@ -46,13 +46,12 @@
|
||||||
<el-dropdown-item :command="{event: 'test', ruleEngineVersion: ruleEngineVersion}"
|
<el-dropdown-item :command="{event: 'test', ruleEngineVersion: ruleEngineVersion}"
|
||||||
:disabled="ruleEngineVersion.isTest === '0'"
|
:disabled="ruleEngineVersion.isTest === '0'"
|
||||||
>测试规则</el-dropdown-item>
|
>测试规则</el-dropdown-item>
|
||||||
<el-dropdown-item :command="{event: 'status', ruleEngineVersion: ruleEngineVersion}"
|
<el-dropdown-item :command="{event: 'status', ruleEngineVersion: ruleEngineVersion}" :disabled="ruleEngineVersion.status !== '1'">
|
||||||
:disabled="ruleEngineVersion.isTest === '0'">
|
|
||||||
{{ruleEngineVersion.isActivate !== 'no-activate' ? "禁用" : "激活"}}规则
|
{{ruleEngineVersion.isActivate !== 'no-activate' ? "禁用" : "激活"}}规则
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
<el-dropdown-item
|
<el-dropdown-item
|
||||||
:command="{event: 'publish', ruleEngineVersion: ruleEngineVersion}"
|
:command="{event: 'publish', ruleEngineVersion: ruleEngineVersion}"
|
||||||
v-if="ruleEngineVersion.status === '1' && ruleEngineVersion.isTest === '1'">
|
v-if=" ruleEngineVersion.isTest === '1'">
|
||||||
发布规则
|
发布规则
|
||||||
</el-dropdown-item>
|
</el-dropdown-item>
|
||||||
</el-dropdown-menu>
|
</el-dropdown-menu>
|
||||||
|
@ -188,20 +187,17 @@
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<encoding style="margin-top: 20px" v-model="ruleEngineVersionInfoAndTest.codeIng" :read-only="true"></encoding>
|
<encoding style="margin-top: 20px" v-model="ruleEngineVersionInfoAndTest.codeIng" :read-only="true"></encoding>
|
||||||
</el-col>
|
</el-col>
|
||||||
<!-- {{_assetStructure}}-->
|
|
||||||
<el-col :span="12">
|
<el-col :span="12">
|
||||||
<el-col :span="assetStructure == null ? 24 : 12">
|
<el-col :span="assetStructure == null ? 24 : 12">
|
||||||
<el-card class="box-card">
|
<el-card class="box-card">
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>选择数据接入</span>
|
<span>选择数据接入</span>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<el-select v-model="assetStructure" style="width: 100%;">
|
<el-select v-model="assetStructure" style="width: 100%;">
|
||||||
<el-option v-for="_assetStructure in assetStructureList"
|
<el-option v-for="_assetStructure in assetStructureList"
|
||||||
:key="_assetStructure.accessSourceName"
|
:key="_assetStructure.dataSourceSystemName"
|
||||||
:value="_assetStructure.id"
|
:value="_assetStructure.id"
|
||||||
:label="_assetStructure.accessSourceName+'('+_assetStructure.dataSourceSystemName+')'"
|
:label="_assetStructure.dataSourceSystemName+'('+_assetStructure.databaseName+')'"
|
||||||
@change="findInformationById(_assetStructure.id)"
|
|
||||||
></el-option>
|
></el-option>
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-card>
|
</el-card>
|
||||||
|
@ -220,22 +216,52 @@
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24">
|
<el-col :span="24" v-if="assets != null">
|
||||||
<el-card class="box-card" v-if="assets != null">
|
<el-card class="box-card" v-if="this.ruleEngineInfo.level === 'data-field'">
|
||||||
<div slot="header" class="clearfix">
|
<div slot="header" class="clearfix">
|
||||||
<span>选择资产模型</span>
|
<span>选择资产模型</span>
|
||||||
|
<el-button style="float: right; padding: 3px 0" type="text" @click="dataModelRandom">随机数据</el-button>
|
||||||
</div>
|
</div>
|
||||||
<el-descriptions direction="vertical" :column="3" border>
|
<el-descriptions direction="vertical" :column="3" border>
|
||||||
|
|
||||||
<el-descriptions-item v-for="_dataModel in dataModelList"
|
<el-descriptions-item v-for="_dataModel in dataModelList"
|
||||||
:label='_dataModel.name + "("+_dataModel.comment+")"'>
|
:label='_dataModel.name + "("+_dataModel.comment+")"'>
|
||||||
<el-radio v-model="dataMode" :label="_dataModel.name" :value="_dataModel.id">{{dataModeMap[_dataModel.name]}}</el-radio>
|
|
||||||
|
<el-radio v-model="dataMode" :label="_dataModel.name" :value="_dataModel.id">{{dataModeMapList[dataModeMapIndex][_dataModel.name]}}</el-radio>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
</el-card>
|
||||||
|
<el-card class="box-card" v-if="this.ruleEngineInfo.level !== 'data-field'">
|
||||||
|
<div slot="header" class="clearfix">
|
||||||
|
<span>{{this.ruleEngineInfo.level === "data-set" ? "选择资产集" : "选择资产记录"}}</span>
|
||||||
|
</div>
|
||||||
|
<el-table :data="dataModeMapList" max-height="200px"
|
||||||
|
@selection-change="changeDataRow">
|
||||||
|
<el-table-column type="selection" width="55" v-if="this.ruleEngineInfo.level === 'data-set'"/>
|
||||||
|
<el-table-column v-for="dataModel in dataModelList" :label="dataModel.comment" :prop="dataModel.name"/>
|
||||||
|
<el-table-column label="操作" v-if="this.ruleEngineInfo.level !== 'data-set'">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button type="text" @click="dataRecordSelect(scope.row)">选择</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
</el-table>
|
||||||
|
<el-descriptions title="选择行数据" direction="vertical" :column="3" border style="margin-top: 20px" v-if="dataRecordSelectData != null">
|
||||||
|
<el-descriptions-item v-for="(val, key) in dataRecordSelectData"
|
||||||
|
:label='key'>
|
||||||
|
<el-checkbox v-model="dataRecordSelectKeyList" :label="key" :value="key">{{val}}</el-checkbox>
|
||||||
|
</el-descriptions-item>
|
||||||
|
</el-descriptions>
|
||||||
|
<el-descriptions title="选择模型" :column="3" border style="margin-top: 20px" v-if="changeDataList.length !== 0">
|
||||||
|
<el-descriptions-item v-for="_dataModel in dataModelList"
|
||||||
|
:label='_dataModel.comment'>
|
||||||
|
<el-checkbox v-model="dataRecordSelectKeyList" :label="_dataModel.name" :value="_dataModel.id"></el-checkbox>
|
||||||
</el-descriptions-item>
|
</el-descriptions-item>
|
||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</el-card>
|
</el-card>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="24" style="margin-top: 10px" v-if="dataMode != null">
|
<el-col :span="24" style="margin-top: 10px" v-if="dataMode != null || dataRecordSelectKeyList.length > 0">
|
||||||
<el-button>测试</el-button>
|
<el-button @click="dataTest">测试</el-button>
|
||||||
<el-input style="margin-top: 10px" v-model="testResult" type="textarea" placeholder="请点击测试" />
|
<el-input style="margin-top: 10px" v-model="testResult" type="textarea" placeholder="请点击测试" disabled/>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
|
@ -246,13 +272,18 @@
|
||||||
<script>
|
<script>
|
||||||
import Encoding from "@/components/Encoding/index.vue";
|
import Encoding from "@/components/Encoding/index.vue";
|
||||||
import {
|
import {
|
||||||
addEngineversion,
|
addEngineversion, engineGeneration,
|
||||||
findRuleEngineById,
|
findRuleEngineById,
|
||||||
updateEngineCodeIng,
|
updateEngineCodeIng,
|
||||||
updateRuleActivate,
|
updateRuleActivate,
|
||||||
updateRuleStatus,
|
updateRuleStatus,
|
||||||
} from "@/api/ruleengine/ruleengine";
|
} from "@/api/ruleengine/ruleengine";
|
||||||
import {findAssetStructure, findDataBaseByInformationId, findInformationById} from "@/api/dataSource/source";
|
import {
|
||||||
|
findAssetStructure,
|
||||||
|
findDataBaseByInformationId,
|
||||||
|
findDataSourceByDataBaseId,
|
||||||
|
findInformationById
|
||||||
|
} from "@/api/dataSource/source";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "EngineVersion",
|
name: "EngineVersion",
|
||||||
|
@ -292,40 +323,92 @@ export default {
|
||||||
dataModelList: [],
|
dataModelList: [],
|
||||||
// 数据模型选择
|
// 数据模型选择
|
||||||
dataMode: null,
|
dataMode: null,
|
||||||
// 数据示例
|
// 数据实例集合
|
||||||
dataModeMap: {
|
dataModeMapList : [],
|
||||||
id: 1,
|
dataModeMapIndex: 0,
|
||||||
name: "张三",
|
dataRecordSelectData: null,
|
||||||
sex: 1,
|
// 条记录选中key集合
|
||||||
price: "653.69",
|
dataRecordSelectKeyList: [],
|
||||||
create_time: "2024-5-7 16:37:16",
|
// 选择行记录List
|
||||||
},
|
changeDataList: [],
|
||||||
testResult: ""
|
testResult: "",
|
||||||
|
|
||||||
|
dataName:[],
|
||||||
|
|
||||||
|
dataVal:[],
|
||||||
|
|
||||||
|
newData:[],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
"assetStructure":{
|
"assetStructure":{
|
||||||
handler(val) {
|
handler(val) {
|
||||||
console.log("123",val)
|
|
||||||
if (val != null) {
|
if (val != null) {
|
||||||
findInformationById(val).then(
|
findInformationById(val).then(
|
||||||
res=>{
|
res=>{
|
||||||
this.assetsList=res.data;
|
this.assetsList=res.data;
|
||||||
|
// console.log("132",this.assetsList)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"assets":{
|
'assets': {
|
||||||
handler(val){
|
handler(newVal) {
|
||||||
console.log(val)
|
console.log("val", newVal)
|
||||||
if (val!=null){
|
findDataBaseByInformationId(newVal).then(res => {
|
||||||
findDataBaseByInformationId(val).then(
|
this.dataModelList = res.data
|
||||||
res=>{
|
this.dataName = []
|
||||||
this.dataModelList=res.data;
|
|
||||||
|
for (let resKey in res.data) {
|
||||||
|
console.log("resKey", resKey)
|
||||||
|
this.dataName.push(res.data[resKey].name)
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log("dataName", this.dataName)
|
||||||
|
console.log("ssssssssssssss", this.dataModelList)
|
||||||
|
})
|
||||||
|
//查询数据展示值
|
||||||
|
findDataSourceByDataBaseId(newVal).then(res => {
|
||||||
|
console.log("pp", res)
|
||||||
|
this.dataModeMapList = res.data
|
||||||
|
this.dataVal = []
|
||||||
|
for (let resKey in res.data) {
|
||||||
|
this.dataVal.push({
|
||||||
|
key: res.data[resKey].key,
|
||||||
|
value: res.data[resKey].value,
|
||||||
|
type: res.data[resKey].type
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if (this.dataVal != null) {
|
||||||
|
this.newData = []
|
||||||
|
let keys = this.dataName
|
||||||
|
let count = keys.length
|
||||||
|
const newData = this.dataVal.reduce((acc, curr, index) => {
|
||||||
|
if (index % count === 0 && index + count - 1 < this.dataVal.length) { // 确保不会超出数组边界
|
||||||
|
// 创建一个临时对象来存储键值对
|
||||||
|
const tempObj = {};
|
||||||
|
// 使用 keys 数组来迭代并设置 tempObj 的属性
|
||||||
|
for (let i = 0; i < keys.length; i++) {
|
||||||
|
// 访问 kvt 数组中对应位置的元素
|
||||||
|
tempObj[keys[i]] = (i === 0) ? parseInt(this.dataVal[index + i].value, 10) : this.dataVal[index + i].value;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将临时对象添加到 acc 数组中
|
||||||
|
acc.push(tempObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 始终返回累加器数组
|
||||||
|
return acc;
|
||||||
|
}, []);
|
||||||
|
this.newData = newData
|
||||||
}
|
}
|
||||||
)
|
this.dataModeMapList = this.newData
|
||||||
}
|
}
|
||||||
|
console.log("ss", this.dataModeMapList)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -335,13 +418,31 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|
||||||
findInformationById(id){
|
|
||||||
console.log("123",id)
|
// 测试
|
||||||
findInformationById(id).then(
|
dataTest(){
|
||||||
res=>{
|
let number = Math.floor(Math.random()*3);
|
||||||
this.assetsList=res.data;
|
if (number === 0){
|
||||||
}
|
this.testResult = "测试正常,无异常数据返回";
|
||||||
)
|
}else if (number === 1){
|
||||||
|
this.testResult = "测试失败:触发*****异常条例,数据发生动作【移除/忽略/记录】";
|
||||||
|
}else if (number === 2){
|
||||||
|
this.testResult = "程序异常:*******异常";
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// 选择数据行
|
||||||
|
changeDataRow(val){
|
||||||
|
this.changeDataList = val;
|
||||||
|
},
|
||||||
|
// 记录选中
|
||||||
|
dataRecordSelect(row){
|
||||||
|
this.dataRecordSelectKeyList = [];
|
||||||
|
this.dataRecordSelectData = row;
|
||||||
|
},
|
||||||
|
// 单条随机数据
|
||||||
|
dataModelRandom(){
|
||||||
|
this.dataModeMapIndex = Math.floor(Math.random()*this.dataModeMapList.length);
|
||||||
|
console.log(this.dataModeMapIndex)
|
||||||
},
|
},
|
||||||
saveCoding(){
|
saveCoding(){
|
||||||
updateEngineCodeIng(this.ruleEngineVersionInfoAndTest).then(
|
updateEngineCodeIng(this.ruleEngineVersionInfoAndTest).then(
|
||||||
|
@ -409,7 +510,6 @@ export default {
|
||||||
},
|
},
|
||||||
// 确定新增
|
// 确定新增
|
||||||
addVersionSubmission(){
|
addVersionSubmission(){
|
||||||
// this.ruleEngineInfo.ruleEngineVersionList.push({... this.engineVersionForm})
|
|
||||||
this.engineVersionForm.ruleId = this.ruleEngineInfo.id
|
this.engineVersionForm.ruleId = this.ruleEngineInfo.id
|
||||||
addEngineversion(this.engineVersionForm).then(
|
addEngineversion(this.engineVersionForm).then(
|
||||||
res=>{
|
res=>{
|
||||||
|
@ -438,13 +538,11 @@ export default {
|
||||||
}else if(clickType === "activate"){
|
}else if(clickType === "activate"){
|
||||||
|
|
||||||
this.ruleEngineInfo.isActivate = 'no-activate' === this.ruleEngineInfo.isActivate ? 'activated' : 'no-activate'
|
this.ruleEngineInfo.isActivate = 'no-activate' === this.ruleEngineInfo.isActivate ? 'activated' : 'no-activate'
|
||||||
console.log(this.ruleEngineInfo.isActivate)
|
|
||||||
updateRuleActivate(this.ruleEngineInfo).then(
|
updateRuleActivate(this.ruleEngineInfo).then(
|
||||||
res=>{
|
res=>{
|
||||||
this.$modal.msgSuccess(res.msg);
|
this.$modal.msgSuccess(res.msg);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// this.$modal.msgSuccess("引擎激活状态修改成功");
|
|
||||||
}else if(clickType === "status"){
|
}else if(clickType === "status"){
|
||||||
this.ruleEngineInfo.status = '0' === this.ruleEngineInfo.status ? '1' : '0'
|
this.ruleEngineInfo.status = '0' === this.ruleEngineInfo.status ? '1' : '0'
|
||||||
updateRuleStatus(this.ruleEngineInfo).then(
|
updateRuleStatus(this.ruleEngineInfo).then(
|
||||||
|
@ -452,7 +550,6 @@ export default {
|
||||||
this.$modal.msgSuccess(res.msg);
|
this.$modal.msgSuccess(res.msg);
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
// this.$modal.msgSuccess("引擎状态操作成功");
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
findAssetStructure(){
|
findAssetStructure(){
|
||||||
|
@ -463,22 +560,30 @@ export default {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
initRuleEngine(){
|
initRuleEngine(){
|
||||||
console.log("123",this.ruleEngineId)
|
|
||||||
findRuleEngineById(this.ruleEngineId).then(
|
findRuleEngineById(this.ruleEngineId).then(
|
||||||
res=>{
|
res=>{
|
||||||
this.ruleEngineInfo = res.data;
|
this.ruleEngineInfo = res.data;
|
||||||
console.log(this.ruleEngineInfo)
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
// 获取代码模板
|
// 获取代码模板
|
||||||
getCodeIng(){
|
getCodeIng(){
|
||||||
|
|
||||||
|
let parentClass=null;
|
||||||
|
if(this.ruleEngineInfo.level==="dataset"){
|
||||||
|
parentClass="DataSetContext"
|
||||||
|
}
|
||||||
|
if(this.ruleEngineInfo.level==="record"){
|
||||||
|
parentClass="RecordContext"
|
||||||
|
}
|
||||||
|
if(this.ruleEngineInfo.level==="record-field"){
|
||||||
|
parentClass="DataModelContext"
|
||||||
|
}
|
||||||
|
|
||||||
let packageName = "com.muyu.rule.engine";
|
let packageName = "com.muyu.rule.engine";
|
||||||
let customName = "custom";
|
let customName = "custom";
|
||||||
let templateName = "template";
|
let templateName = "template";
|
||||||
let parentClass = "DataModelEngine";
|
let codeIng = `package ${packageName}.${customName};
|
||||||
let codeIng = `package ${packageName}.${customName};
|
|
||||||
|
|
||||||
import com.muyu.engine.action.ActionDiscard;
|
import com.muyu.engine.action.ActionDiscard;
|
||||||
import com.muyu.engine.scope.${parentClass};
|
import com.muyu.engine.scope.${parentClass};
|
||||||
|
@ -499,8 +604,15 @@ public class ${this.engineVersionForm.versionCode} extends ${parentClass} {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}`;
|
}`;
|
||||||
|
// alert(codeIng)
|
||||||
|
// engineGeneration(codeIng).then(
|
||||||
|
// res=>{
|
||||||
|
// alert("ok")
|
||||||
|
// }
|
||||||
|
// )
|
||||||
return codeIng;
|
return codeIng;
|
||||||
}
|
|
||||||
|
},
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue