版本2.0更新

This commit is contained in:
yunian
2022-06-20 14:03:57 +08:00
parent 50563d3815
commit 64981a609e
253 changed files with 66927 additions and 1 deletions

View File

@@ -0,0 +1,427 @@
<style>
.rule {
display: flex;
/* margin-left: 5px; */
position: relative;
}
.Rule_cont {
width: 30px;
border-top: 1px dashed #C7C6C8;
/* border-top: 1px dashed rgb(1,1,1); */
margin-top: 7px;
flex-grow: 0;
height: 1px;
/* background-color: #C7C6C8; */
margin: 12px 0px 0 0;
height: 0;
}
.RuleIcon {
background-color: #EBEBEB;
border: #DADADA 1px solid;
border-radius: 4px;
padding: 4px 6px 4px 2px;
}
.RuleSelcet .el-input__inner {
border-radius: 0 4px 4px 0;
}
.RuleCont_for_out {
border-left: 1px dashed #ccc;
border-bottom: 1px dashed #ccc;
border-right: 1px dashed #ccc;
padding-top: 5px;
position: relative;
}
</style>
<template>
<div class="rule" :style="{marginLeft:ZIndex==1?'20px':'0px'}" v-if="data">
<div :style="{position: 'absolute',top:'0px', left: '-20px',marginTop: top===0?'0':'8px'}" class="RuleIcon">
<el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
<i class="el-icon-s-operation" :style="{color: color[ZIndex%5] ,fontSize: '16px'}"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-plus" command="addRule" v-if="data.conditionType!=3">添加规则
</el-dropdown-item>
<el-dropdown-item icon="el-icon-circle-plus-outline" command="addlogical">添加关系</el-dropdown-item>
<el-dropdown-item icon="el-icon-close" command="delect" v-if="ZIndex!=1&&data.conditionType!=4">
删除此节点</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<div v-if="data.conditionType==1" class="RuleSelcet">
<div :style="{width: '80px',marginTop: top===0?'0':'8px'}">
<el-select v-model="data.logical" placeholder="请选择" size="mini">
<el-option :key="1" label="AND" value="&&"></el-option>
<el-option :key="2" label="OR" value="||"></el-option>
</el-select>
</div>
</div>
<div style="width: 10px;height: 0;border-top: 1px dashed #C7C6C8;margin-top: 19px;margin-left: 5px;">
</div>
<div>
<div
:style="{border: '1px dashed '+ color[ZIndex%5],borderRadius: '5px',paddingRight: '5px',paddingBottom: '5px',position:'relative',minWidth:'30px',minHeight:'40px'}">
<div
:style="{border:'',margin:'',padding:'',paddingLeft:'0px'}">
<div v-for="(item,index) in data.children" style="display: flex;margin-top: 7px;">
<div class="Rule_cont"
:style="{marginTop:item.conditionType===0?'12px':(index===0?'11px':'20px')}">
</div>
<!-- conditionType==2 规则部分 -->
<div v-if="item.conditionType==2" style="display: flex;">
<!-- {{fieldType}} -->
<div v-if="fieldType!='for'" style="display: flex;">
<!-- 普通规则部分 -->
<!-- 不为输出节点 则拉选 fielduser-->
<div style="display: flex;">
<el-select v-model="item.opType" placeholder="请选择" size="mini" style="width: 100px;" @change="emptyOpKey($event,item)">
<el-option :key="value.value" :label="value.label" :value="value.value" v-for="value in ruleList"></el-option>
</el-select>
<el-cascader v-if="item.opType!='count'" v-model="item.opKey" filterable size="mini" :options="fieldUserObj" clearable @change="ruleCascaderChange(item)"
:key="keyValue+(item.random?item.random:0)" style="margin-left: 10px;" :props="{ expandTrigger: 'hover' }" @visible-change="randomAdd(item,$event)">
</el-cascader>
<ruleRelation v-model="item.operator" :value2.sync="item.variableValue"
:variableType.sync="item.variableType"
:valueType="GetValueTypeByJSONEn(item.opKey)" size="mini" :variableDis="[2]"
:interceptCustom="true" @CustomCallback="$emit('CustomCallback',item)"
></ruleRelation>
</div>
</div>
<i class="el-icon-circle-close" style="color: #fa4949;margin-left: 5px;"
@click="deleteSon(index)"></i>
</div>
<!-- conditionType==1 关系节点 conditionType==3 for的输出的关系节点 节点部分 -->
<div v-if="item.conditionType==1">
<!-- {{fieldType}} -->
<rule :data="item" :top="index" :ZIndex="ZIndex+1"
:index="index" @delectLogical="delectLogical"
:ruleList="ruleList"
:customUserObj="customUserObj"
>
</rule>
</div>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import ruleRelation from '@/components/common/ruleRelation.vue'
import bigElCascader from '@/components/common/bigElCascader.vue'
export default {
components: {
ruleRelation,
bigElCascader
},
name: 'rule',
data() {
return {
color: ['#0D183E', '#409EFF', '#67C23A', '#F56C6C', '#FFCD43'],
keyValue: 1, //用于给级联选择框重新渲染
keyValueReady: false
}
},
created() {
},
mounted() {
if (this.data) {
if (Array.isArray(this.data.fieldEn)) {
if (this.data.fieldEn.length > 0) {
this.EnChange(this.data.fieldEn, false)
}
}
}
},
props: {
fieldType: {
type: String,
default: ''
},
ZIndex: {
type: Number,
default: -1
},
data: {
type: Object,
default () {
return {}
}
},
top: {
tyep: String,
default: '8px'
},
index: {
type: Number,
default: -1
},
ruleList:{ //算子
type:Array||null,
default:null
},
customUserObj:{ //自定义规则下拉
type:Array||null,
default:null
}
},
computed: {
fieldUserObj() {
if(this.customUserObj){
return this.customUserObj
}else{
return []
}
// if (this.$store.state.FieldUserObj) {
// return this.$store.state.FieldUserObj.data.fieldList
// } else {
// return []
// }
},
fielduserArr() {
let arr = []
// console.log(11,this.fielduser)
if (this.fielduser.length > 1) {
if (this.fieldType != "for") { // 如果元素不为 for 则 用fielduser里的 json 格式指标
arr = this.fielduser.filter((value) => {
return value.valueType == 6
})
arr = arr.map((value) => {
let obj = {
value: value.fieldEn,
label: value.fieldCn,
}
obj.children = this.getdeepArr(JSON.parse(value.jsonValue))
return obj
})
}
// console.log(arr)
return arr
} else {
return []
}
},
fielduser() {
if (this.$store.state.FieldUser) {
return this.$store.state.FieldUser.data.fieldList
} else {
return []
}
},
},
methods: {
emptyOpKey(e,item){
console.log(e,item)
if(e=='count'){
item.opKey = []
}
},
GetValueTypeByJSONEn(en){
if(!en){
return
}
console.log(en)
let obj
en.forEach((value,index)=>{
if(index==0){
obj = this.fieldUserObj.find(x=>x.value==value)
console.log(this.fieldUserObj)
console.log(obj)
// debugger
}else{
obj = obj.children.find(x=>x.value==value)
}
})
return obj&&obj.valueType
},
getvalueTypebyEn(e) { //通过en 获取 valueType
if (!Array.isArray(e)) {
return
}
if (e[0][0] !== '%') {
return this.mixinGetValueTypeByEn(e[0])
}
if (e[e.length - 1] == 'length') {
return 1
}
},
EnChange(e, clear = true) {
this.en = e.join('.')
if (!clear) return
this.deepClearEn(this.data)
},
deepClearEn(obj) { // 递归清除用到父级的 en
obj.children.forEach(value => {
if (Array.isArray(value.fieldEn)) {
if (value.fieldEn[0][0] == "%") {
value.fieldEn = ""
}
}
if (value.children.length > 0) {
this.deepClearEn(value)
}
})
},
getdeepArr(obj) {
if (Array.isArray(obj)) {
return false
} else if (typeof obj == 'object') {
let arr = []
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (Array.isArray(obj[key])) {
arr.push({
value: key,
label: key
})
} else if (typeof obj[key] == 'object') {
arr.push({
value: key,
label: key,
children: this.getdeepArr(obj[key])
})
}
}
}
return arr
} else {
return []
}
},
delectLogical(index) {
this.data.children.splice(index, 1)
},
handleCommand(str) {
if (str == "addRule") { //添加规则
// console.log(this.data)
this.data.children.push({
"logical": null,
"opKey": '',
"operator": "",
"variableValue": "",
"conditionType": 2,
"variableType": 1,
"children": [],
"opType": "",
})
} else if (str == "addlogical") { //添加链接符
let obj = {
"logical": '&&',
"fieldId": "",
"operator": "",
"fieldValue": "",
"conditionType": 1,
"children": [],
}
this.data.children.push(obj)
} else if (str == "delect") {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$emit('delectLogical', this.index)
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
}
},
deleteSon(index) {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.data.children.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
ruleCascaderChange(item) {
item.valueType = this.mixinGetValueTypeByJSONEn(item.fieldEn)
item.fieldValue = ""
item.operator = ""
},
},
watch: {
fielduserArr() {
if (this.keyValueReady) {
this.keyValue++
}
}
}
}
</script>

View File

@@ -0,0 +1,763 @@
<style>
.listOp_top {
display: flex;
}
.listOp_cont {}
.listOp_table_header {
width: 350px;
border-left: 1px solid #ddd;
border-bottom: 1px solid #ddd;
}
.listOp_table_comm {}
.listOp_score {
width: 199px;
height: 80px;
text-align: center;
line-height: 80px;
border-left: 1px solid #ddd;
border-bottom: 1px solid #ddd;
box-sizing: border-box;
}
.listOp_home {
border-top: 1px solid #ddd;
overflow: scroll;
flex: 1;
}
</style>
<template>
<!-- :style="{width:$store.state.barShrink?'95vw':'85vw'}" -->
<div class="dataManageRedact" v-loading="loading">
<div :class="smallHeader?'MR_header MR_headerSmall':'MR_header'">
<div>
<div>
<el-button type="primary" icon="el-icon-arrow-left" circle @click="mixinClose"></el-button>
</div>
<div>
<span v-if="id===0">新增集合 :</span>
<span v-else>编辑集合 :</span>
</div>
</div>
<div>
<el-button :icon="smallHeader?'el-icon-bottom':'el-icon-top'" circle @click="openHeader">
</el-button>
<el-button type="success" icon="el-icon-check" circle @click="submit" :disabled="addVersionStatus">
</el-button>
</div>
</div>
<div :class="smallHeader?'MR_input MR_inputSmall':'MR_input'">
<div>
<p>集合代码: </p>
<el-input placeholder="请输入集合代码" maxlength="30" v-model="code" clearable :disabled="addVersionStatus">
</el-input>
</div>
<div>
<p>集合名称:</p>
<el-input placeholder="请输入集合名称" maxlength="20" v-model="name" clearable :disabled="addVersionStatus">
</el-input>
</div>
<!-- <div>
<p>集合类型:</p>
<el-select v-model="opType" placeholder="请选择类型" @change="opTypeChange"
:disabled="addVersionStatus||id!=0">
<el-option v-for="item in opTypeList" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
</div> -->
</div>
<div :class="smallHeader?'MR_scope MR_scopeSmall':'MR_scope'">
<div>
<p>集合描述: </p>
<el-input placeholder="请输入决策描述" maxlength="300" v-model="description" clearable
:disabled="addVersionStatus" style="margin-left: 20px;"></el-input>
<p style="margin-left: 20px;">有效时间: </p>
<el-date-picker style="margin:0 20px;width: 500px;" v-model="validTime" type="daterange"
range-separator="" start-placeholder="开始日期" end-placeholder="结束日期" :disabled="addVersionStatus">
</el-date-picker>
</div>
</div>
<version style="margin:5px;" :id="id" :ruleVersionList="versionList" :version="version" @addVersion="addVersion"
@addVersionClose="addVersionClose" @copyVersion="copyVersion" @delectVersion="delectVersion"
@updateVersion="updateVersion" @addVersionSure="addVersionSure" :addVersionDialog="addVersionDialog"
@Dialog="addVersionDialog=$event" @addVersionExamine="addVersionExamine"
:addVersionLoading="addVersionLoading" @versionChange="versionChange" :addVersionStatus="addVersionStatus"
@StatusChange="addVersionStatus=$event"></version>
<!-- 版本部分 -->
<div class="listOp_home">
<opType :opType="opType" :data="version" @changeInputFieldEn="changeInputFieldEn"></opType>
</div>
</div>
</template>
<script>
import opType from '@/components/common/listOperation/opType.vue'
import mangeRedactMixin from '@/utils/contminxin/MangeRedactMixin.js'
import '@/assets/css/ManageRedact.css'
import version from '@/components/common/Version.vue'
const versionOrigin = {
inputFieldEn: [],
conditionAndOutPutList: [{
condition: {
logical: "&&",
conditionType: 1,
children: []
},
defaultOutput: [],
filterCondition: {
conditionType: 1,
logical: "&&",
children: [],
variableType: 1
},
failOutput: [],
successOutput: [],
listOperationBlock: {
name: "",
groupFields: [],
}
}]
}
export default {
mixins: [mangeRedactMixin],
components: {
version,
opType
},
props: {
fieldTypeId: {
type: Number,
default: 0,
},
getData: {
type: Object,
default () {
return {}
}
},
id: {
type: Number,
default: 0
},
type: {
type: Number,
default: 1
},
nameId: {
type: Number,
default: 0
}
},
data() {
return {
addVersionStatus: false,
addVersionLoading: false,
addVersionDialog: false,
tempadd: {},
loading: false,
priority: '',
code: '',
name: '',
description: '',
parentId: '',
versionList: [],
version: {},
opType: 2,
opTypeList: [{
value: 1,
label: '集合规则'
}, {
value: 2,
label: '集合处理'
}, ],
validTime: [],
}
},
created() {
if (this.id != 0) {
this.loading = true
this.getData.getVersion(this.id).then(res => {
if (res.status == '1') {
this.code = res.data.code
this.name = res.data.name
this.opType = res.data.opType
this.priority = res.data.priority
this.description = res.data.description
this.parentId = res.data.folderId
if (res.data.startTime) {
this.$set(this.validTime, 0, new Date(res.data.startTime))
}
if (res.data.endTime) {
this.$set(this.validTime, 1, new Date(res.data.endTime))
}
// 版本部分
this.versionList = res.data.versionList
let obj = JSON.parse(JSON.stringify(this.versionList[0]))
this.Enformat(obj, 'Array')
this.version = obj
this.loading = false
}
})
} else {
// 新增初始化
this.version = JSON.parse(JSON.stringify(versionOrigin))
console.log(this.version)
}
},
methods: {
changeInputFieldEn(e) {
this.version = JSON.parse(JSON.stringify(versionOrigin))
this.version.inputFieldEn = e
console.log(this.version)
},
// opTypeChange(e) {
// if (e == 1) {
// this.version.conditionAndOutPutList = [this.version.conditionAndOutPutList[0]]
// } else if (e == 2) {
// this.version.groupFields = []
// }
// },
versionChange(e) {
let obj = JSON.parse(JSON.stringify(e))
this.Enformat(obj, 'Array')
// debugger
this.version = obj
this.loading = false
},
addVersionExamine() {
if (this.getIsempty(this.version)) {
return
}
this.addVersionDialog = true
},
addVersionSure(tempVersion) {
this.addVersionLoading = true
let obj = JSON.parse(JSON.stringify(this.version))
obj.versionCode = tempVersion.versionCode
obj.description = tempVersion.description
obj.listOpId = this.id
this.Enformat(obj, 'String')
this.getData.addVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '添加版本成功',
type: 'success'
});
this.versionList = res.data
this.versionChange(this.versionList[0])
}
this.loading = false
this.addVersionStatus = false
this.addVersionDialog = false
this.addVersionLoading = false
})
},
updateVersion(tempVersion) {
if (this.getIsempty(this.version)) {
return
}
this.addVersionLoading = true
let obj = JSON.parse(JSON.stringify(this.version))
obj.versionCode = tempVersion.versionCode
obj.description = tempVersion.description
obj.listOpId = this.id
this.Enformat(obj, 'String')
this.getData.updateVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '版本重命名成功',
type: 'success'
});
this.versionList = res.data
this.versionChange(this.versionList[0])
}
this.addVersionDialog = false
this.addVersionLoading = false
})
},
delectVersion() {
this.getData.delectVersion({
status: -1,
ids: [this.version.id],
strategyId: this.id
}).then(res => {
if (res.status == "1") {
this.$message({
message: '删除成功',
type: 'success'
});
this.versionList = res.data
this.versionChange(this.versionList[0])
}
})
},
copyVersion(tempVersion) {
this.addVersionLoading = true
this.getData.copyVersion({
listOpId: this.id,
id: this.version.id,
versionCode: tempVersion.versionCode,
description: tempVersion.description
}).then(res => {
if (res.status == '1') {
this.$message({
message: '复制版本成功',
type: 'success'
});
this.versionList = res.data
this.versionChange(this.versionList[0])
}
this.loading = false
this.addVersionDialog = false
this.addVersionLoading = false
})
},
addVersionClose() {
this.version = this.tempadd
this.tempadd = {}
},
addVersion() {
this.tempadd = JSON.parse(JSON.stringify(this.version))
this.reset()
},
reset() {
this.version = JSON.parse(JSON.stringify(versionOrigin))
},
Enformat(obj, str) {
obj.inputFieldEn = getformat(obj.inputFieldEn)
// if (str == 'Array') {
// obj.groupFields = JSON.parse(obj.groupFields)
// }
// obj.groupFields = obj.groupFields.map(value => {
// return getformat(value)
// })
// if (str == 'String') {
// obj.groupFields = JSON.stringify(obj.groupFields)
// }
obj.conditionAndOutPutList.forEach(value => {
value.successOutput.forEach(item => {
item.outputOpKey = getformat(item.outputOpKey)
if (item.variableType == 2) {
item.outputValue = getformat(item.outputValue)
}
})
value.failOutput.forEach(item => {
item.outputOpKey = getformat(item.outputOpKey)
if (item.variableType == 2) {
item.outputValue = getformat(item.outputValue)
}
})
if (str == 'Array') {
if(value.listOperationBlock.groupFields){
value.listOperationBlock.groupFields = JSON.parse(value.listOperationBlock.groupFields)
}else{
value.listOperationBlock.groupFields = []
}
}
value.listOperationBlock.groupFields = value.listOperationBlock.groupFields.map(item => {
return getformat(item)
})
if (str == 'String') {
value.listOperationBlock.groupFields = JSON.stringify(value.listOperationBlock.groupFields)
}
value.filterCondition.children.forEach(item => {
item.opKey = getformat(item.opKey)
})
deepformat([value.condition])
// if(value.condition.children.length>0){
// value.defaultOutput = []
// }else{
// value.defaultOutput = value.successOutput
// }
})
function deepformat(arr) {
arr.forEach(value => {
if (value.children && value.children.length > 0) {
deepformat(value.children)
}
if (value.conditionType == 2) {
value.opKey = getformat(value.opKey)
if (value.variableType == 2) {
value.variableValue = getformat(value.variableValue)
}
}
})
}
function getformat(arr) {
if (str == "String") {
// debugger
return arr.join('.')
} else {
return arr.split('.')
}
}
},
examine() {
let reg = /[\u4e00-\u9fa5]+/g;
if (this.code.match(reg) != null) {
this.$message.error('代码不允许出现中文');
return true
}
if (this.verificationCode(this.code) || this.verificationName(this.name)) {
return true
}
if (this.code.trim() == '') {
this.$message.error('请填入集合代码,并检查空格');
return true
}
if (this.name.trim() == '') {
this.$message.error('请填入集合名称,并检查空格');
return true
}
if (this.description.trim() == '') {
this.$message.error('请填入集合描述,并检查空格');
return true
}
let is = {
is: false,
msg: '提交失败,请检查是否有未填项'
}
if (is.is) {
this.$message.error(is.msg)
return true
}
},
getIsempty(obj) {
let is = {
is: false,
msg: ''
}
if (!obj.inputFieldEn || obj.inputFieldEn.length == 0) {
is.is = true
is.msg = '请选择 数据 '
}
obj.conditionAndOutPutList.forEach(value => {
value.filterCondition.children.forEach(value => {
if (!value.opKey || value.opKey.length == 0) {
is.is = true
is.msg = '请选择 过滤的 Key'
}
if (!value.variableValue || value.variableValue.trim() == '') {
is.is = true
is.msg = '请填写 过滤 的值'
}
})
value.listOperationBlock.groupFields.forEach(value => {
// debugger
if (value.length == 0 || !value[0]) {
is.is = true
is.msg = '请选择 分组 '
}
})
if (is.is) {
return
}
value.successOutput.forEach(item => {
forVerify(is, item, '命中')
})
if (is.is) {
return
}
value.failOutput.forEach(item => {
forVerify(is, item, '未命中')
})
if (is.is) {
return
}
deepexamine(is, [value.condition])
if (is.is) {
return
}
this.verify(is, value.successOutput, '命中')
if (is.is) {
return
}
this.verify(is, value.failOutput, '命中')
})
if (is.is) {
this.$message.error(is.msg)
}
return is.is
function forVerify(is, item, str) {
console.log(item)
if (!item.outputKey.trim()) {
is.is = true
is.msg = `请输入${str}输出的KEY`
}
if (!item.outputOp) {
is.is = true
is.msg = `请选择${str}输出的算子`
}
if (!item.outputOpKey) {
is.is = true
is.msg = `请选择${str}输出的 计算条件`
}
if (item.outputOp != 'custom' && item.outputOp != 'list_element' && item.outputOp !=
'count') { //如果不为自定义
console.log(item)
if (!item.outputOpKey || item.outputOpKey.length == 0 || !item.outputOpKey[0]) {
is.is = true
is.msg = `请输入${str}输出的 计算依赖(只有算子为集合时可以不选择计算依赖)`
}
} else if (item.outputOp == 'custom') {
// if (item.variableType != 2) {
if (!item.outputValue || !item.outputValue.trim()) {
is.is = true
is.msg = `请输入${str}输出的 值`
}
}
}
function deepexamine(is, arr,index=1) {
arr.forEach(value => {
if (value.children && value.children.length > 0) {
deepexamine(is, value.children,index+1)
}
if (value.conditionType == 2) {
if (!value.opType) {
is.is = true
is.msg = '请选择 条件 的 算子'
}
if (!value.opKey) {
is.is = true
is.msg = '请选择 条件 的 入Key'
}
if (!value.operator) {
is.is = true
is.msg = '请选择 条件 的 运算符'
}
if (!value.variableValue || !value.variableValue.trim()) {
is.is = true
is.msg = '请选择 条件 的 值'
}
}
if (value.conditionType == 1&&value.children.length==0&&index!=1) {
is.is = true
is.msg = '关系符下不允许为空'
}
})
}
},
verify(is, item, str) {
let arr = []
item.forEach(value => {
if (value.outputOp == 'custom' && value.variableType == 3) {
console.log(value)
let obj = JSON.parse(value.outputValue)
let sarr = obj.formula.match(/@.*?@/)
if (sarr != null) {
sarr.forEach(cont => {
let subStr = cont
subStr = subStr.substring(1, subStr.length - 1)
if (!this.FieldUser.find(x => x.fieldCn == subStr) && !arr.find(x => x ==
subStr)) {
is.is = true
is.msg = `自定义中使用输出Key 只能使用同块并且在自身之上的Key 违规Key${subStr}`
}
})
}
}
arr.push(value.outputKey)
})
},
submit() {
this.loading = true
if (this.examine()) {
this.loading = false
return
}
if (this.getIsempty(this.version)) {
this.loading = false
return
}
let sobj = JSON.parse(JSON.stringify(this.version))
sobj.inputFieldType = 'list'
this.Enformat(sobj, 'String')
let obj = {
"code": this.code.trim(),
"name": this.name.trim(),
"description": String(this.description).trim(),
"opType": this.opType,
"versionList": [sobj],
"startTime": this.validTime && this.validTime[0] ? this.validTime[0] : null,
"endTime": this.validTime && this.validTime[1] ? this.validTime[1] : null,
}
if (this.id == 0) {
obj.versionList[0].versionCode = 'V:0'
obj.versionList[0].description = '初始版本'
obj.folderId = this.nameId == 99999999 ? 0 : this.nameId,
this.getData.setsave(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.versionList = res.data.versionList
this.$message({
message: '添加成功',
type: 'success'
});
this.$emit('Ok')
}
})
} else {
obj.id = this.id
obj.folderId = this.parentId
obj.versionList[0].id = this.version.id
obj.versionList[0].listOpId = this.id
this.getData.updatafield(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.versionList = res.data.versionList
this.$message({
message: '修改成功',
type: 'success'
});
}
})
}
}
},
watch: {
},
computed: {
}
}
</script>

View File

@@ -0,0 +1,239 @@
<template>
<div class="cont_cont">
<div class="cont_left" v-loading="leftloading" v-if="!listRedact">
<div class="cont_header">
<p class="cont_header_title">{{title}}</p>
<p class="cont_header_subtitle">{{title}}</p>
</div>
<contNewFule v-model="tempNewF" :newf.sync="newf" @newFileSure="newFileSure" @newFile="newFile" ></contNewFule>
<div class="cont_list">
<fileHome :data="list" @curr="clickCurrid" :currid="currid" @RenameFun="RenameFun" @RenameClose="RenameClose"
@updatafilelist="updatafilelist" @delectFun="delectFun">
</fileHome>
</div>
</div>
<div class="cont_right" v-loading="contloading" @click="tempHintLeft=null;tempHintTop=null;" >
<div v-if="!listRedact">
<div v-if="showRight===false" class="cont_right_hint">
请先选择左侧文件夹
</div>
<div v-else>
<div class="cont_right_top">
<div>
<el-button type="primary" @click="listRedact=true" :disabled="currid!=99999999?false:'disabled'">新增</el-button>
<el-button type="danger" @click="using(-1);$store.dispatch('regetcache', 'decisionTree')" :disabled="this.selection.length>0?false:'disabled'">删除</el-button>
<el-button type="success" @click="using(1)" :disabled="this.selection.length>0?false:'disabled'">启用</el-button>
<el-button type="warning" @click="using(0)" :disabled="this.selection.length>0?false:'disabled'">停用</el-button>
<el-select v-model="tempMove" placeholder="移动到:" style="margin-left: 10px;" :disabled="this.selection.length>0?false:'disabled'"
filterable @change="mixinMoveChange">
<el-option v-for="value in listunfold" :key="value.id" :label="value.name" :value="value.id" v-show="value.id!=99999999"></el-option>
</el-select>
</div>
<div>
<el-input placeholder="请输入搜索内容" v-model="search">
<i slot="suffix" class="el-input__icon el-icon-search" @click="getsearch"></i>
</el-input>
</div>
</div>
<div class="cont_right_cont">
<div v-if="data">
<el-table border :data="data.data.klist" @select-all="selectAll" @select="select" style="width: 100%"
:cell-style="{padding: '10px'}">
<el-table-column type="selection" width="70">
</el-table-column>
<el-table-column v-for="item in getData.row" :key="item.id" :prop="item.row" :label="item.label" align="center">
<template slot-scope="scope">
<span v-if="item.type==='Blooen'">
{{scope.row[item.row]?"":""}}
</span>
<span v-else-if="item.type==='State'">
{{scope.row[item.row]==1?'启用':'未启用'}}
</span>
<span v-else-if="item.type==='Time'" style="white-space: nowrap;" class="contText">{{
new Date(scope.row[item.row]).toLocaleDateString().replace(/\//g, "-") + " " + new Date(scope.row[item.row]).toTimeString().substr(0, 8)
}}</span>
<span v-else-if="item.fn">
<!-- {{scope.row[item.row]}} -->
{{item.fn(scope.row[item.row])}}
</span>
<span class="contText" v-else>
{{scope.row[item.row]}}
</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" size="s">
<template slot-scope="scope">
<el-button icon="el-icon-setting" circle size="mini" @click="dialogShow(scope.row.id)"></el-button>
</template>
</el-table-column>
</el-table>
<el-pagination style="float: right;margin-right: 40px;margin-top: 40px;" :current-page="currPage"
@current-change="clickpage" background layout="prev, pager, next" :total="data.data.pageInfo.total">
</el-pagination>
</div>
</div>
</div>
</div>
<div v-if="listRedact" style="height: 100%;overflow: hidden;">
<dataManageRedact v-if="listRedact" @close="listRedact=false;tempRedactId=0" @Ok="listRedact=false;tempRedactId=0;getlist()" :getData="getData"
:id='tempRedactId' :nameId="currid" :type="getData.type"></dataManageRedact>
</div>
</div>
</div>
</template>
<script>
import contNewFule from '@/components/common/contNewFile.vue'
import '@/assets/css/cont.css'
import fileHome from '@/components/common/fileHome.vue'
import dataManageRedact from './listOpManageRedact.vue'
import contmixin from '@/utils/contminxin/contmixin.js'
export default {
mixins: [
contmixin
],
components: {
fileHome,
dataManageRedact,
contNewFule
},
created() {
this.getData.getTree({
parentId: 0,
treeType: this.getData.treeType,
type: 1
}).then(res => {
this.list = this.listTreeDeep(res.data, 1)
this.clickCurrid(99999999)
})
},
props: {
title: {
type: String,
default: ''
},
getData: {
type: Object,
default: null
}
},
watch: {
list() {
if (this.list.length > 0) {
this.leftloading = false
}
}
},
data() {
return {
list: [],
tempMove: '',
leftloading: true,
search: "",
fileName: "",
fileList: [],
upShow: false,
currPage: 1,
currid: null,
data: null,
contloading: false,
newf: false,
tempNewF: "",
listRedact: false, //新增页面开启
tempRedactId: 0,
selection: []
}
},
methods: {
getsearch() {
this.contloading = true
let params = {
entity: {
name: this.search,
"folderId": String(this.currid) === "99999999" ? '' : String(this.currid),
},
key: "ruleName",
status: "0,1",
"pageNum": 1,
isSearch: 1
}
this.getData.getlist(params).then(res => {
this.data = res
this.contloading = false
})
this.currPage = 1
},
getlist() {
this.contloading = true
this.listRedact = false
let params = {
status: "0,1",
entity: {},
"pageNum": 1
}
if (String(this.currid) !== "99999999") {
params.entity.folderId = this.currid
}
this.getData.getlist(params).then(res => {
this.data = res
this.contloading = false
})
},
clickpage(e) {
this.currPage = e
this.contloading = true
let params = {
status: "0,1",
entity: {},
"pageNum": e
}
if (String(this.currid) !== "99999999") {
params.entity.folderId = this.currid
}
this.getData.getlist(params).then(res => {
if (res.status == 1) {
this.data = res
this.selection = []
this.contloading = false
}
})
},
newFileSure() {
this.leftloading = true
let params = {
parentId: String(this.currid),
name: this.tempNewF,
"treeType":this.getData.treeType,
"type": "1",
"engineId": ""
}
if(this.mixnewFileZindexVerify(this.list,this.currid)==6){
this.$message.error('已达到最深层级')
this.leftloading = false
return
}
this.mixnewFileSure(params)
}
}
}
</script>

View File

@@ -0,0 +1,646 @@
<style>
.opType1_subbtitle {
color: #666;
margin-top: 10px;
margin-bottom: 10px;
}
.opType2Cont {
background-color: #fff;
padding: 5px;
margin-top: 10px;
border-radius: 10px;
border: 1px dotted #aaa
}
.opTypeRow {
display: flex;
align-items: center;
margin-top: 10px;
border-bottom: 1px dotted #eee;
padding-bottom: 10px;
}
.opTypeRow>p:nth-of-type(1) {
width: 100px;
}
.opTypeDelete {
color: red;
margin-left: 10px;
font-size: 24px;
position: absolute;
top: 20px;
right: 20px;
}
.opType_ps {
color: #666;
font-size: 14px;
}
</style>
<template>
<div style="padding: 10px;">
<div class="opTypeRow">
<p class="opType1_subbtitle">
数据
</p>
<div>
<el-cascader v-model="data.inputFieldEn" filterable :options="FieldUserArr"
:key="(data.random?data.random:0)" @visible-change="randomAdd(data,$event)"
:props="{ expandTrigger: 'hover' }" @change="$emit('changeInputFieldEn',data.inputFieldEn)">
</el-cascader>
<p class="opType_ps">
*切换数据源会重置下面所选的信息 请谨慎切换
</p>
</div>
</div>
<div :class="opType==2?'opType2Cont':''" v-for="(value,index) in data.conditionAndOutPutList"
v-if="index==0||opType==2" style="position: relative;">
<div class="opTypeRow" v-if="opType==2">
<p class="opType1_subbtitle">
运算
</p>
<el-input v-model="value.listOperationBlock.name" style="width: 220px;"></el-input>
</div>
<div class="opTypeRow">
<p class="opType1_subbtitle">
过滤
</p>
<div>
<div v-if="value.filterCondition.children&&value.filterCondition.children.length>0&&ValueObj">
<div v-for="(item,index) in value.filterCondition.children"
style="margin-bottom: 10px;display: flex;align-items: center;">
<el-cascader v-if="item.operator!='black_list'" v-model="item.opKey" filterable
:options="ValueObj" :key="cascaKey+(item.random?item.random:0)"
@visible-change="randomAdd(item,$event)" :props="{ expandTrigger: 'hover' }"
style="margin-right: 20px;"></el-cascader>
<el-select v-model="item.operator" placeholder="请选择" @change="operatorChange(item)"
style="margin-right: 20px;">
<el-option v-for="cont in filterOptions" :key="cont.value" :label="cont.label"
:value="cont.value">
</el-option>
</el-select>
<el-input v-model="item.variableValue" placeholder="请以逗号分割"
v-if="item.operator!='black_list'">
</el-input>
<varialeSelect v-if="item.operator=='black_list'" :variableType.sync="item.variableType"
:disabled="[1,2]" :variableCascaderValue="ValueObj" :variableCascader="true"
size="medium" height="36px" v-model="item.variableValue" :interceptCustom="true"
@CustomCallback="CustomCallback(item,'variableValue','blackList')" style="margin-left: 10px;">
</varialeSelect>
<i class="el-icon-circle-close" style="color: red;margin-left: 10px;"
@click="deleteFilterCondition(value.filterCondition.children,index)"></i>
</div>
</div>
<el-button @click="addfilterCondition(value.filterCondition.children)">+</el-button>
</div>
</div>
<div class="opTypeRow">
<p class="opType1_subbtitle">
分组
</p>
<div>
<div
v-if="value.listOperationBlock.groupFields&&value.listOperationBlock.groupFields.length>0&&ValueObj">
<div v-for="(item,index) in value.listOperationBlock.groupFields" style="margin-bottom: 10px;">
<el-cascader v-model="value.listOperationBlock.groupFields[index]" filterable :options="ValueObj"
:key="cascaKey+(item.random?item.random:0)" @visible-change="randomAdd(item,$event)"
:props="{ expandTrigger: 'hover' }"></el-cascader>
<i class="el-icon-circle-close" style="color: red;margin-left: 10px;"
@click="deleteGroupFields(value.listOperationBlock.groupFields,index)"></i>
</div>
</div>
<el-button @click="addgroupFields(value.listOperationBlock.groupFields)">+</el-button>
</div>
</div>
<div class="opTypeRow">
<p class="opType1_subbtitle">
条件
</p>
<rule :data="value.condition" :ZIndex="1" :ruleList="opTypeList" :customUserObj="ValueObj"
@CustomCallback="CustomCallback"></rule>
</div>
<div class="opTypeRow">
<p class="opType1_subbtitle">
命中输出
</p>
<div>
<listOutPut :list="value.successOutput"
:option="[...opTypeList,{label:'集合',value:'list_element'},{label:'自定义',value:'custom'}]"
@CustomCallback="CustomCallback($event,'outputValue')" :ValueObj="ValueObj"></listOutPut>
</div>
</div>
<div class="opTypeRow">
<p class="opType1_subbtitle">
未命中输出
</p>
<div>
<listOutPut :list="value.failOutput"
:option="[...opTypeList,{label:'集合',value:'list_element'},{label:'自定义',value:'custom'}]"
@CustomCallback="CustomCallback($event,'outputValue')" :ValueObj="ValueObj"></listOutPut>
</div>
</div>
<p v-if="index>0">
<i class="el-icon-circle-close opTypeDelete" @click="deleteConditionAndOutPutList(index)"></i>
</p>
</div>
<el-button type="primary" v-if="opType==2" style="margin: 10px 0 40px 0;" @click="addConditionAndOutPutList"
plain>
添加处理</el-button>
<el-dialog title="值编辑器" v-if="dialogVisible" :visible.sync="dialogVisible" width="70%"
:close-on-click-modal="false" append-to-body @close="reSetTemp">
<teParam v-if="dialogVisible" v-model="tempValue" :paramList="tempParam" :tempAddOpkey="tempAddOpkey" :Disabled="teParamdisabled"
:variableCascaderValue="ValueObj">
</teParam>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible=false;reSetTemp()"> </el-button>
<el-button type="primary" @click="valueCompileCallback()"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import listOutPut from '@/components/common/listOutput.vue'
import varialeSelect from '@/components/models/varialeSelect.vue'
import teParam from '@/components/common/teParam.vue'
import rule from './RuleCont.vue'
import {
GetdeepObj
} from '@/utils/GetdeepObj.js'
export default {
components: {
rule,
teParam,
varialeSelect,
listOutPut
},
data() {
return {
valueCompileCallback: () => {}, //值编辑器确定回调
dialogVisible: false,
tempValue: '',
tempParam: [],
cascaKey: 0, //用于级联选择框重新渲染
opTypeList: [{ //算子
label: '个数',
value: 'count'
},
{
label: '去重个数',
value: 'distinct_count'
},
{
label: '最大',
value: 'max'
},
{
label: '最小',
value: 'min'
},
{
label: '平均',
value: 'avg'
},
],
tempAddOpkey: [], //用于命中未命中弹窗中选择 之前的
filterOptions: [{
value: 'in',
label: 'in'
}, {
value: 'not in',
label: 'not in'
}, {
value: 'black_list',
label: '匹配名单库'
}],
teParamdisabled:false
}
},
props: {
data: {
type: Object,
default () {
return {}
}
},
opType: {
type: Number,
default: 1
}
},
created() {
// if (!Array.isArray(this.data.groupFields)) {
// this.data.groupFields = [
// ['']
// ]
// }
console.log(this.data)
},
methods: {
operatorChange(item) {
if (item.operator == 'black_list') {
item.opKey = ['']
item.variableType = 3
} else {
item.variableType = 1
}
item.variableValue = ''
},
deleteFilterCondition(item, index) {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
item.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
addfilterCondition(value) {
if (!this.ValueObj) {
this.$message.error('此数据下无可用字段')
return
}
value.push({
children: [],
conditionType: 2,
logical: null,
variableType: 1,
variableValue: "",
opKey: [],
operator: "in"
})
},
reSetTemp() {
this.tempValue = '';
this.valueCompileCallback = () => {};
this.tempParam = []
this.teParamdisabled = false
},
deleteConditionAndOutPutList(index) {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.data.conditionAndOutPutList.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
addConditionAndOutPutList() {
this.data.conditionAndOutPutList.push({
condition: {
logical: "&&",
conditionType: 1,
children: []
},
defaultOutput: [],
failOutput: [],
successOutput: [],
filterCondition: {
conditionType: 1,
logical: "&&",
children: [],
variableType: 1
},
listOperationBlock: {
name: "",
groupFields: [],
}
})
},
CustomCallback(item, key = "variableValue",type="") {
// console.log(item)
if (!item[key]) {
item[key] = JSON.stringify({
farr: [],
formula: ''
})
}
this.tempValue = JSON.parse(item[key]).formula
this.tempParam = JSON.parse(item[key]).farr.filter(x=>!x.temp)
if (item.arr) {
this.tempAddOpkey = item.arr.map(x => {
return {
fieldEn: x,
fieldCn: x,
id: parseInt(Math.random() * -9999),
outputKey: true
}
})
}
if(type =='blackList'){
console.log(type)
this.teParamdisabled = true
}
this.dialogVisible = true
// console.log(this.tempParam)
this.tempParam.forEach(value => {
value.paramList = value.paramList ? value.paramList.map(item => {
item.value = item.type == 2 ? item.value.split('.') : item.value
return item
}) : []
})
this.valueCompileCallback = () => {
let arr = JSON.parse(JSON.stringify(this.tempParam))
let obj = {
farr: arr.map(value => {
return {
fieldCn: value.fieldCn,
fieldEn: value.fieldEn,
id: value.id,
valueType: value.valueType,
sqlStatement: value.sqlStatement,
jsonValue: value.jsonValue,
paramList: value.paramList ? value.paramList.map(cont => {
cont.value = cont.type == 2 ? cont.value.join('.') : cont.value
return cont
}) : ''
}
}),
formula: this.tempValue
}
if(type=='blackList'){
obj.formula = obj.farr[0]?`@${obj.farr[0].fieldCn}@`:''
}
if (this.examineVariableValue(obj)) {
return
}
let arr2 = obj.formula.match(/@.*?@/g)
if(arr2){
arr2 = arr2.filter(value=> !obj.farr.find(x=>x.fieldCn==value.substring(1,value.length-1)) )
arr2 = arr2.map(value=>{
return {
fieldCn:value.substring(1,value.length-1),
fieldEn:value.substring(1,value.length-1),
temp : true,
valueType:1
}
})
obj.farr.push(...arr2)
}
item[key] = JSON.stringify(obj)
this.dialogVisible = false
this.reSetTemp()
// console.log(item)
}
},
examineVariableValue(obj) {
let is = {
is: false,
msg: ''
}
if (!obj.formula) {
is.is = true
is.msg = '请输入自定义内容'
}
obj.farr.forEach(value => {
if (!value.id || !value.fieldEn) {
is.is = true
is.msg = '请选择入参指标'
}
if (value.paramList && value.paramList.length > 0) {
value.paramList.forEach(item => {
if (!item.value) {
is.is = true
is.msg = '请输入入参指标的次级参数'
}
})
}
})
// 验证是否有重名
let DuplicatesArr = obj.farr.map(x => x.id)
let DuplicatesArr2 = Array.from(new Set(DuplicatesArr))
if (DuplicatesArr.length !== DuplicatesArr2.length) {
is.is = true
is.msg = '请查看入参是否有重名'
}
// console.log(obj)
let arr = obj.formula.match(/@.*?@/g)
if (arr) {
arr.forEach(value => {
if (!obj.farr.find(x => x.fieldCn == value.substring(1, value.length - 1)) && !this
.tempAddOpkey.find(x => x.fieldCn == value.substring(1, value.length - 1))) {
is.is = true
is.msg = '请检查是否有 未入参 但已使用的 字段'
}
})
}
if (is.is) {
this.$message.error(is.msg)
}
return is.is
},
deleteGroupFields(item, index) {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
item.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
addgroupFields(value) { //添加分组
console.log(value)
if (!this.ValueObj) {
this.$message.error('此数据下无可用字段')
return
}
if (Array.isArray(value)) {
value.push([''])
// this.$set(value.groupFields,0,[''])
} else {
value = [
['']
]
// this.$set(value,'groupFields',[['']])
}
},
getdeepArr(obj) {
if (Array.isArray(obj)) {
return false
} else if (typeof obj == 'object') {
let arr = []
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (Array.isArray(obj[key])) {
arr.push({
value: key,
label: key
})
} else if (typeof obj[key] == 'object') {
arr.push({
value: key,
label: key,
children: this.getdeepArr(obj[key])
})
}
}
}
return arr
} else {
return []
}
}
},
computed: {
FieldUser() {
if (!this.$store.state.FieldUser) {
return []
} else {
return this.$store.state.FieldUser.data.fieldList
}
},
FieldUserObj() {
if (!this.$store.state.FieldUserObj) {
return []
} else {
return this.$store.state.FieldUserObj.data.fieldList
}
},
FieldUserArr() {
if (this.FieldUserObj.length == 0) {
return []
} else {
let arr = this.FieldUser.filter((value) => {
return value.valueType == 6
})
arr = arr.map((value) => {
let obj = {
value: value.fieldEn,
label: value.fieldCn,
}
obj.children = this.getdeepArr(JSON.parse(value.jsonValue))
return obj
})
// console.log(arr)
return arr
}
},
ValueObj() { //分组输入字段 的 元素 Obj
if (this.data.inputFieldEn && this.data.inputFieldEn.length > 0) {
let obj = this.FieldUserObj.find(x => x.value == this.data.inputFieldEn[0])
obj = JSON.parse(obj.jsonValue)
this.data.inputFieldEn.forEach((value, index) => {
if (index) {
obj = obj[value]
}
})
obj = obj[0]
obj = GetdeepObj(obj, false)
this.cascaKey++
return obj
} else {
return null
}
}
},
}
</script>