版本2.0更新

This commit is contained in:
yunian
2022-06-20 13:38:00 +08:00
parent 34d4905010
commit 738574807a
164 changed files with 0 additions and 35631 deletions

View File

@@ -1,289 +0,0 @@
<template>
<div class="header">
<!-- 折叠按钮 -->
<div class="collapse-btn" @click="collapseChage">
<i v-if="!collapse" class="el-icon-s-fold"></i>
<i v-else class="el-icon-s-unfold"></i>
</div>
<div class="logo">决策引擎系统</div>
<div class="header-right">
<!-- {{fielduser}} -->
<!-- {{ruleList}} -->
<!-- {{fielduser==''}} -->
<!-- {{ruleList==null}} -->
<div class="header-user-con">
<!-- -->
<div class="btn-fullscreen" @click="ReGetStorage">
<!-- {{fielduser}} -->
<!-- {{ruleList=='[]'}} -->
<el-tooltip effect="dark" content="刷新缓存" placement="bottom">
<i :class="Loading?'el-icon-loading':'el-icon-refresh'"></i>
</el-tooltip>
</div>
<!-- 全屏显示 -->
<div class="btn-fullscreen" @click="handleFullScreen">
<el-tooltip effect="dark" :content="fullscreen?`取消全屏`:`全屏`" placement="bottom">
<i class="el-icon-rank"></i>
</el-tooltip>
</div>
<!-- 消息中心
<div class="btn-bell">
<el-tooltip
effect="dark"
:content="message?`有${message}条未读消息`:`消息中心`"
placement="bottom"
>
<router-link to="/tabs">
<i class="el-icon-bell"></i>
</router-link>
</el-tooltip>
<span class="btn-bell-badge" v-if="message"></span>
</div> -->
<!-- 用户头像 -->
<div class="user-avator">
<img src="../../assets/img/img.jpg" />
</div>
<!-- 用户名下拉菜单 -->
<el-dropdown class="user-name" trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
{{username}}
<i class="el-icon-caret-bottom"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item divided command="loginout">退出登录</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</div>
</template>
<script>
import bus from '../common/bus';
import {
getLogout
} from '../../api/index';
export default {
data() {
return {
collapse: false,
fullscreen: false,
name: '',
message: 2
};
},
created() {
bus.$on('collapseHeader', res => {
this.busCollapseChage(res)
})
this.$store.dispatch('getfielduser')
this.$store.dispatch('getRuleList')
Object.keys(this.$store.state.cacheList).forEach(value => {
this.$store.dispatch('getcache', value)
})
this.$store.commit('setbarShrink', this.collapse)
},
computed: {
username() {
if (localStorage.getItem('ms_username')) {
return localStorage.getItem('ms_username');
} else {
return "未命名"
}
},
fielduser() {
if (this.$store.state.FieldUser) {
return this.$store.state.FieldUser.data.fieldList
} else {
return null
}
},
ruleList() {
if (this.$store.state.RuleList) {
return this.$store.state.RuleList
// return this.$store.state.RuleList
} else {
return null
}
},
Loading() {
if (this.$store.state.FieldUser == null) {
return true
}
if (this.$store.state.Sourcelist == null) {
return true
}
return false
}
},
methods: {
ReGetStorage() {
if (this.Loading) {
return
}
this.mixinReGetStorage()
},
// 用户名下拉菜单选择事件
handleCommand(command) {
if (command == 'loginout') {
// 调用退出登录接口
getLogout();
localStorage.removeItem("engineId");
// localStorage.removeItem("token");
localStorage.removeItem('ms_username');
this.$router.push('/login');
}
},
// Bus侧边栏折叠
busCollapseChage(res) {
this.collapse = res;
this.$store.commit('setbarShrink', this.collapse)
bus.$emit('collapse', this.collapse);
},
// 侧边栏折叠
collapseChage() {
this.collapse = !this.collapse;
this.$store.commit('setbarShrink', this.collapse)
bus.$emit('collapse', this.collapse);
},
// 全屏事件
handleFullScreen() {
let element = document.documentElement;
if (this.fullscreen) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
} else {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.msRequestFullscreen) {
// IE11
element.msRequestFullscreen();
}
}
this.fullscreen = !this.fullscreen;
}
},
mounted() {
if (document.body.clientWidth < 1500) {
this.collapseChage();
}
}
};
</script>
<style scoped>
.header {
position: relative;
box-sizing: border-box;
width: 100%;
height: 70px;
font-size: 22px;
color: #fff;
}
.collapse-btn {
float: left;
padding: 0 21px;
cursor: pointer;
line-height: 70px;
}
.header .logo {
float: left;
width: 250px;
line-height: 70px;
}
.header-right {
float: right;
padding-right: 50px;
}
.header-user-con {
display: flex;
height: 70px;
align-items: center;
}
.btn-fullscreen {
transform: rotate(45deg);
margin-right: 5px;
font-size: 24px;
}
.btn-bell,
.btn-fullscreen {
position: relative;
width: 30px;
height: 30px;
text-align: center;
border-radius: 15px;
cursor: pointer;
}
.btn-bell-badge {
position: absolute;
right: 0;
top: -2px;
width: 8px;
height: 8px;
border-radius: 4px;
background: #f56c6c;
color: #fff;
}
.btn-bell .el-icon-bell {
color: #fff;
}
.user-name {
margin-left: 10px;
}
.user-avator {
margin-left: 20px;
}
.user-avator img {
display: block;
width: 40px;
height: 40px;
border-radius: 50%;
}
.el-dropdown-link {
color: #fff;
cursor: pointer;
}
.el-dropdown-menu__item {
text-align: center;
}
</style>

View File

@@ -1,51 +0,0 @@
<template>
<div class="wrapper">
<v-head></v-head>
<v-sidebar></v-sidebar>
<div class="content-box" :class="{'content-collapse':collapse}">
<v-tags></v-tags>
<div class="content" >
<transition name="move" mode="out-in">
<keep-alive :include="tagsList">
<router-view></router-view>
</keep-alive>
</transition>
<el-backtop target=".content"></el-backtop>
</div>
</div>
</div>
</template>
<script>
import vHead from './Header.vue';
import vSidebar from './Sidebar.vue';
import vTags from './Tags.vue';
import bus from './bus';
export default {
data() {
return {
tagsList: [],
collapse: false
};
},
components: {
vHead,
vSidebar,
vTags
},
created() {
bus.$on('collapse-content', msg => {
this.collapse = msg;
});
// 只有在标签页列表里的页面才使用keep-alive即关闭标签之后就不保存到内存中了。
bus.$on('tags', msg => {
let arr = [];
for (let i = 0, len = msg.length; i < len; i++) {
msg[i].name && arr.push(msg[i].name);
}
this.tagsList = arr;
});
},
};
</script>

View File

@@ -1,100 +0,0 @@
<template>
<div class="sidebar">
<el-menu class="sidebar-el-menu" :default-active="onRoutes" :collapse="collapse" background-color="#324157"
text-color="#bfcbd9" active-text-color="#20a0ff" unique-opened :router="true">
<template v-for="item in items">
<template v-if="item.subs">
<el-submenu :index="item.index" :key="item.index">
<template slot="title">
<i :class="item.icon"></i>
<span slot="title">{{ item.title }}</span>
</template>
<template v-for="subItem in item.subs">
<el-submenu v-if="subItem.subs" :index="subItem.index" :key="subItem.index">
<template slot="title">{{ subItem.title }}</template>
<el-menu-item v-for="(threeItem,i) in subItem.subs" :key="i" :index="threeItem.index">{{ threeItem.title }}</el-menu-item>
</el-submenu>
<el-menu-item v-else :index="subItem.index" :key="subItem.index">{{ subItem.title }}</el-menu-item>
</template>
</el-submenu>
</template>
<template v-else>
<el-menu-item :index="item.index" :key="item.index">
<i :class="item.icon"></i>
<span slot="title">{{ item.title }}</span>
</el-menu-item>
</template>
</template>
</el-menu>
</div>
</template>
<script>
import bus from './bus';
import {
getMenus
} from '../../api/index';
export default {
data() {
return {
collapse: false,
items: [],
};
},
computed: {
onRoutes() {
return this.$route.path
}
},
created() {
// 通过 Event Bus 进行组件间通信,来折叠侧边栏
bus.$on('collapse', msg => {
this.collapse = msg;
// bus.$emit('setcanvasn',msg)
bus.$emit('collapse-content', msg);
});
// 获取菜单接口
this.getMenus()
},
methods: {
async getMenus() {
const data = await getMenus({});
// console.log('菜单接口返回的数据',data);
if (data.status === "0") {
this.$message.error(data.msg);
if (data.error === "01000103") {
this.$router.push('/login')
}
}
this.items = data.data;
// console.log("items", this.items);
}
}
};
</script>
<style scoped>
.sidebar {
display: block;
position: absolute;
left: 0;
top: 70px;
bottom: 0;
overflow-y: scroll;
}
.sidebar::-webkit-scrollbar {
width: 0;
}
.sidebar-el-menu:not(.el-menu--collapse) {
width: 250px;
}
.sidebar>ul {
height: 100%;
}
</style>

View File

@@ -1,186 +0,0 @@
<template>
<div class="tags" v-if="showTags">
<ul>
<li class="tags-li" v-for="(item,index) in tagsList" :class="{'active': isActive(item.path)}" :key="index">
<router-link :to="item.path" class="tags-li-title">
{{item.title}}
</router-link>
<span class="tags-li-icon" @click="closeTags(index)"><i class="el-icon-close"></i></span>
</li>
</ul>
<div class="tags-close-box">
<el-dropdown @command="handleTags">
<el-button size="mini" type="primary">
标签选项<i class="el-icon-arrow-down el-icon--right"></i>
</el-button>
<el-dropdown-menu size="small" slot="dropdown">
<el-dropdown-item command="other">关闭其他</el-dropdown-item>
<el-dropdown-item command="all">关闭所有</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
</div>
</template>
<script>
import bus from './bus';
export default {
data() {
return {
tagsList: []
}
},
methods: {
isActive(path) {
return path === this.$route.fullPath;
},
// 关闭单个标签
closeTags(index) {
const delItem = this.tagsList.splice(index, 1)[0];
const item = this.tagsList[index] ? this.tagsList[index] : this.tagsList[index - 1];
if (item) {
delItem.path === this.$route.fullPath && this.$router.push(item.path);
}else{
this.$router.push('/');
}
},
// 关闭全部标签
closeAll(){
this.tagsList = [];
this.$router.push('/');
},
// 关闭其他标签
closeOther(){
const curItem = this.tagsList.filter(item => {
return item.path === this.$route.fullPath;
})
this.tagsList = curItem;
},
// 设置标签
setTags(route){
const isExist = this.tagsList.some(item => {
return item.path === route.fullPath;
})
if(!isExist){
if(this.tagsList.length >= 8){
this.tagsList.shift();
}
this.tagsList.push({
title: route.meta.title,
path: route.fullPath,
name: route.matched[1].components.default.name
})
}
bus.$emit('tags', this.tagsList);
},
handleTags(command){
command === 'other' ? this.closeOther() : this.closeAll();
}
},
computed: {
showTags() {
return this.tagsList.length > 0;
}
},
watch:{
$route(newValue, oldValue){
this.setTags(newValue);
}
},
created(){
this.setTags(this.$route);
// 监听关闭当前页面的标签页
bus.$on('close_current_tags', () => {
for (let i = 0, len = this.tagsList.length; i < len; i++) {
const item = this.tagsList[i];
if(item.path === this.$route.fullPath){
if(i < len - 1){
this.$router.push(this.tagsList[i+1].path);
}else if(i > 0){
this.$router.push(this.tagsList[i-1].path);
}else{
this.$router.push('/');
}
this.tagsList.splice(i, 1);
break;
}
}
})
}
}
</script>
<style>
.tags {
position: relative;
height: 30px;
overflow: hidden;
background: #fff;
padding-right: 120px;
box-shadow: 0 5px 10px #ddd;
}
.tags ul {
box-sizing: border-box;
width: 100%;
height: 100%;
}
.tags-li {
float: left;
margin: 3px 5px 2px 3px;
border-radius: 3px;
font-size: 12px;
overflow: hidden;
cursor: pointer;
height: 23px;
line-height: 23px;
border: 1px solid #e9eaec;
background: #fff;
padding: 0 5px 0 12px;
vertical-align: middle;
color: #666;
-webkit-transition: all .3s ease-in;
-moz-transition: all .3s ease-in;
transition: all .3s ease-in;
}
.tags-li:not(.active):hover {
background: #f8f8f8;
}
.tags-li.active {
color: #fff;
}
.tags-li-title {
float: left;
max-width: 80px;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
margin-right: 5px;
color: #666;
}
.tags-li.active .tags-li-title {
color: #fff;
}
.tags-close-box {
position: absolute;
right: 0;
top: 0;
box-sizing: border-box;
padding-top: 1px;
text-align: center;
width: 110px;
height: 30px;
background: #fff;
box-shadow: -3px 0 15px 3px rgba(0, 0, 0, .1);
z-index: 10;
}
</style>

View File

@@ -1,286 +0,0 @@
<template>
<div>
<div class="Rule_version">
<el-select value="V:0" placeholder="请选择版本" v-if="!id" :disabled="true" @change="versionChange" size='mini'>
</el-select>
<el-select v-model="version.id" placeholder="请选择版本" v-else :disabled="addVersionStatus"
@change="versionChange" size='mini'>
<el-option v-for="item in ruleVersionList" :key="item.id" :label="item.versionCode" :value="item.id">
</el-option>
</el-select>
<el-button plain class="Rule_version_buttom" style="margin-left: 10px;" size='mini' @click="addVersion"
v-show="!addVersionStatus" :disabled="!id">新增版本</el-button>
<el-button plain class="Rule_version_buttom" size='mini' type="success" @click="sureAddVersion"
v-show="addVersionStatus">确认新增</el-button>
<el-button plain class="Rule_version_buttom" size='mini' type="danger" @click="addVersionClose"
v-show="addVersionStatus">取消新增</el-button>
<el-button plain class="Rule_version_buttom" size='mini' @click="$emit('Dialog',true)"
:disabled="addVersionStatus||!id">复制版本</el-button>
<el-button plain class="Rule_version_buttom" size='mini' @click="updateVersion=true;$emit('Dialog',true)"
:disabled="addVersionStatus||!id">版本重命名</el-button>
<el-button plain class="Rule_version_buttom" size='mini' type="danger" @click="delectVersion"
:disabled="addVersionStatus||!id">删除此版本</el-button>
<el-button plain class="Rule_version_buttom" size='mini' @click="$emit('exportVersion')"
v-if="exportVersion" :disabled="addVersionStatus||!id">导出此版本</el-button>
<el-button plain class="Rule_version_buttom" size='mini' @click="importVersion" v-if="exportVersion"
:disabled="addVersionStatus||!id">导入版本</el-button>
<span style="font-size: 12px;color: #999;margin-left: 10px;">切换版本并不会自动保存内容 请手动保存</span>
</div>
<span style="color: #00A854;font-size: 14px;margin-left: 10px;">版本描述{{id?version.description:'初始版本'}}</span>
<el-dialog title="提示" :visible.sync="addVersionDialog" width="30%"
@close="updateVersion=false;tempVersion.versionCode='',tempVersion.description=''"
:close-on-click-modal="false" :close-on-press-escape="false" :show-close="false">
<div v-loading="addVersionLoading">
<p style="margin-top: 20px;"><span style="width: 30%;">新版本名称</span>
<el-input placeholder="请输入新版本名称" maxlength="30" v-model="tempVersion.versionCode" clearable
style="width: 70%;"></el-input>
</p>
<p style="margin-top: 20px;"><span style="width: 30%;">新版本描述</span>
<el-input placeholder="请输入新版本描述" maxlength="30" v-model="tempVersion.description" clearable
style="width: 70%;"></el-input>
</p>
<div slot="footer" class="dialog-footer" style="text-align: right;margin-top: 20px;">
<el-button @click="$emit('Dialog',false)"> </el-button>
<el-button type="primary" @click="addVersionSure"> </el-button>
</div>
</div>
</el-dialog>
<el-dialog title="提示" :visible.sync="importVersionDialog" width="30%" @close="" :close-on-click-modal="false"
:close-on-press-escape="false" :show-close="false">
<div v-loading="importVersionLoading">
<p style="margin-top: 20px;"><span style="width: 30%;">新版本名称</span>
<el-input placeholder="请输入新版本名称" maxlength="30" v-model="tempVersion.versionCode" clearable
style="width: 70%;"></el-input>
</p>
<p style="margin-top: 20px;"><span style="width: 30%;">新版本描述</span>
<el-input placeholder="请输入新版本描述" maxlength="30" v-model="tempVersion.description" clearable
style="width: 70%;"></el-input>
</p>
<div style="display: flex;justify-content: center;padding-top: 20px;">
<el-upload class="upload-demo" ref="upload" action="doUpload" :limit="1" :file-list="fileList"
:before-upload="beforeUpload" v-loading="Uploadloading">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传json文件且不超过5MB</div>
<div slot="tip" class="el-upload-list__item-name">{{fileName}}</div>
</el-upload>
</div>
<div slot="footer" class="dialog-footer" style="text-align: right;margin-top: 20px;">
<el-button @click="importVersionDialog=false"> </el-button>
<el-button type="primary" @click="importVersionSure"> </el-button>
</div>
</div>
</el-dialog>
</div>
</template>
<script>
export default {
props: {
ruleVersionList: {
type: Array,
default () {
return []
}
},
version: {
type: Object,
default () {
return {
id: '',
description: '',
versionCode: ''
}
}
},
id: {
type: Number,
default: 0
},
addVersionDialog: {
type: Boolean,
default: false
},
addVersionLoading: {
type: Boolean,
default: false
},
addVersionStatus: {
type: Boolean,
default: false
},
exportVersion: {
type: Boolean,
default: false
}
},
data() {
return {
tempJsonObj: null,
files: null,
fileName: '',
fileList: [],
importVersionDialog: false,
importVersionLoading: false,
Uploadloading: false,
tempVersion: {
versionCode: '',
description: '',
},
}
},
methods: {
beforeUpload(file) {
// console.log(file, '文件');
this.files = file;
const extension = file.name.split('.')[file.name.split('.').length - 1] === 'json'
const isLt2M = file.size / 1024 / 1024 < 5
if (!extension) {
this.$message.warning('上传模板只能是 json格式!')
return
}
if (!isLt2M) {
this.$message.warning('上传模板大小不能超过 5MB!')
return
}
this.fileName = file.name;
var reader = new FileReader() // 新建一个FileReader
reader.readAsText(file, 'UTF-8') // 读取文件
reader.onload =(evt)=>{ // 读取完文件之后会回来这里
this.tempJsonObj = JSON.parse(evt.target.result) // 读取文件内容
console.log(this.tempJsonObj)
}
return false // 返回false不会自动上传
},
importVersionSure() {
if(this.tempJsonObj==null){
this.$message.error('请上传文件')
return
}
if(this.tempVersion.versionCode.trim()===''){
this.$message.error('请填写新版本名称')
return
}
if(this.tempVersion.description.trim()===''){
this.$message.error('请填写新版本描述')
return
}
console.log(JSON.parse(JSON.stringify(this.tempJsonObj)))
this.$emit('importNewVersion',{data:JSON.parse(JSON.stringify(this.tempJsonObj)),name:JSON.parse(JSON.stringify(this.tempVersion))})
this.tempJsonObj=null
this.tempVersion.versionCode=''
this.tempVersion.description=''
this.importVersionDialog = false
},
importVersion() {
this.importVersionDialog = true
},
versionChange(e) {
this.ruleVersionList.forEach(value => {
if (value.id === this.version.id) {
this.$emit('versionChange', value)
}
})
},
addVersion(e) {
// this.addVersionStatus = true
this.$emit('StatusChange', true)
this.$emit('addVersion', e)
},
sureAddVersion(e) {
this.$emit('addVersionExamine', this.tempVersion)
// this.addVersionDialog = true
// this.$emit('Dialog',true)
},
delectVersion(e) {
if (this.ruleVersionList.length == 1) {
this.$message.error('最少要有一个版本存在')
return
}
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$emit('delectVersion', e)
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
});
},
addVersionSure(e) {
if (this.verificationTempVersion()) {
this.addVersionLoading = false
return
}
console.log(1)
if (this.addVersionStatus) { // 添加版本
this.$emit('addVersionSure', this.tempVersion)
} else if (this.updateVersion) { //重命名版本
this.$emit('updateVersion', this.tempVersion)
} else { // 复制版本
this.$emit('copyVersion', this.tempVersion)
}
// this.addVersionStatus = false
// this.$emit('StatusChange',false)
},
addVersionClose(e) {
// this.addVersionStatus = false
this.$emit('StatusChange', false)
this.$emit('addVersionClose', e)
},
verificationTempVersion() {
if (this.tempVersion.versionCode.trim() === "") {
this.$message.error('请填入新版本名称')
return true
}
let is = {
is: false,
msg: '',
}
this.ruleVersionList.forEach(value => {
if (value.versionCode === this.tempVersion.versionCode) {
is.is = true
is.msg = '已存在此版本名'
}
})
if (is.is) {
this.$message.error(is.msg)
return true
}
if (this.tempVersion.description.trim() === "") {
this.$message.error('请填入新版本描述')
return true
}
return false
},
}
}
</script>
<style>
.Rule_version {
/* margin-top: 20px; */
padding-left: 10px;
}
</style>

View File

@@ -1,108 +0,0 @@
<style>
.zoomView {
background-color: #eee;
height: 250px;
/* overflow: hidden; */
position: relative;
}
#zoomView_cont {
background-color: #DDDDDD;
height: 100%;
width: 100%;
transition: all 0.1s;
position: absolute;
user-select: none;
overflow: hidden;
}
.zoomView_modal{
/* background-color: #0000FF; */
position: absolute;
width: 100%;
height: 100%;
z-index: 9;
}
</style>
<template>
<div class="zoomView" @mouseup="mouseup" ref="zoomView">
<span style="font-size: 12px;color: #aaa;">双击回归原位置</span>
<div id="zoomView_cont" ref="zoomViewCont" :style="{transform: 'scale('+mult+','+mult+')',top:top,left:left}">
<div class="zoomView_modal">
</div>
<slot></slot>
</div>
</div>
</template>
<script>
export default {
data() {
return {
mult: 1,
ismove: false,
timeout: null,
top: '0px',
left: '0px',
ClientX: '',
ClientY: '',
OffsetLeft: '',
OffsetTop: '',
}
},
beforeDestroy() {
window.onmousemove = () => {}
window.mouseup = () => {}
},
mounted() {
this.$refs.zoomView.onmousewheel = (e) => {
this.mult -= e.deltaY / 1000
if (this.mult >= 1) {
} else {
this.mult = 1
}
}
this.$refs.zoomView.onmousedown = (e) => {
this.ismove = true
this.ClientX = e.clientX;
this.ClientY = e.clientY;
this.OffsetLeft = this.$refs.zoomViewCont.offsetLeft
this.OffsetTop = this.$refs.zoomViewCont.offsetTop
}
window.onmousemove = (e) => {
if (this.ismove && (new Date() - this.timeout > 50 || this.timeout == null)) {
this.top = e.clientY - (this.ClientY - this.OffsetTop) + 'px'
this.left = e.clientX - (this.ClientX - this.OffsetLeft) + 'px'
this.timeout = new Date()
}
}
window.mouseup = () => {
this.ismove = false
}
this.$refs.zoomViewCont.ondblclick = () => {
this.top = '0px'
this.left = '0px'
this.mult = 1
}
this.$refs.zoomView.ondblclick = () => {
this.top = '0px'
this.left = '0px'
this.mult = 1
}
},
methods: {
mouseup() {
this.ismove = false
}
}
}
</script>

View File

@@ -1,86 +0,0 @@
<template>
<el-cascader :value="value" @input="$emit('input',$evnet)" v-el-select-loadmore="loadMore(num)" filterable
:size="size" :options="MyOptions" clearable @change="$emit('change',$event)" :key="Mykey" :props="props">
</el-cascader>
</template>
<script>
export default {
props: {
value: {
type: Array,
default () {
return []
}
},
options: {
type: Array,
default () {
return []
}
},
Mykey: {
type: Number,
default: 1
},
props: {
type: Object,
default () {
return {
expandTrigger: 'hover'
}
}
},
size: {
type: String,
default: 'mini'
}
},
data() {
return {
num: 10,
MyOptions: [],
page: 1
}
},
created() {
this.loadMore()
},
methods: {
loadMore(n) {
let start = (this.page - 1) * 10
this.MyOptions.push(...this.options.splice(start, start + 10))
console.log(this.MyOptions)
this.page++
},
},
directives: {
'el-select-loadmore': (el, binding) => {
// 获取element-ui定义好的scroll盒子
const SELECTWRAP_DOM = el.querySelector(".el-cascader-menu .el-scrollbar__wrap");
console.log(SELECTWRAP_DOM)
if (SELECTWRAP_DOM) {
SELECTWRAP_DOM.addEventListener("scroll", function() {
/**
* scrollHeight 获取元素内容高度(只读)
* scrollTop 获取或者设置元素的偏移值,
* 常用于:计算滚动条的位置, 当一个元素的容器没有产生垂直方向的滚动条, 那它的scrollTop的值默认为0.
* clientHeight 读取元素的可见高度(只读)
* 如果元素滚动到底, 下面等式返回true, 没有则返回false:
* ele.scrollHeight - ele.scrollTop === ele.clientHeight;
*/
const condition = this.scrollHeight - this.scrollTop <= this.clientHeight;
if (condition) this.loadMore();
});
}
}
}
}
</script>
<style>
</style>

View File

@@ -1,6 +0,0 @@
import Vue from 'vue';
// 使用 Event Bus
const bus = new Vue();
export default bus;

View File

@@ -1,55 +0,0 @@
<template>
<div :id="sid" :style="{height: height,width:width}">
</div>
</template>
<script>
import * as echarts from 'echarts';
export default {
props: {
sid: {
type: String,
default: 'echartsId'
},
height: {
type: String,
default: '300px'
},
width: {
type: String,
default: '300px'
},
option: {
type: Object,
default () {
return {}
}
}
},
data() {
return {
chartDom: null,
myChart: null
}
},
mounted() {
this.chartDom = document.getElementById(this.sid);
this.myChart = echarts.init(this.chartDom);
this.myChart.setOption(this.option);
},
watch: {
option: {
handler: function() {
this.myChart.clear()
this.myChart.setOption(this.option);
},
// 开启深度监听只要obj中的任何一个属性发生改变都会触发相应的代码
deep: true
}
}
}
</script>
<style>
</style>

View File

@@ -1,56 +0,0 @@
<template>
<div>
<div>
<div>
+
</div>
<div>
X
</div>
<div>
<el-select v-model="value" placeholder="请选择">
<el-option
v-for="item in inp1"
:key="item.value"
:label="item.label"
:value="item.value">
</el-option>
</el-select>
</div>
<div>
<input type="text">
</div>
<div>
<input type="text">
</div>
<div>
<input type="text">
</div>
</div>
</div>
</template>
<script>
export default{
porps:{
},
data(){
return {
value:1,
}
}
}
</script>
<style>
</style>

View File

@@ -1,349 +0,0 @@
<template>
<div class="cont_cont">
<div class="cont_left" v-loading="leftloading">
<div class="cont_header">
<p class="cont_header_title">{{title}}</p>
<p class="cont_header_subtitle">{{title}}</p>
</div>
<div class="cont_new_file">
<div v-if="!newf" @click="newFile"><i class="el-icon-folder-add" @click="newFile" style="margin-right: 10px;"></i>新建文件夹</div>
<div v-else style="padding: 5px;box-sizing:border-box;">
<div style="display: flex;align-items: center;">
<i class="el-icon-folder-add" @click="newFile" style="margin-right: 10px;"></i>
<el-input v-model="tempNewF" placeholder="请输入新文件夹名字,最长20个字符" size="small"></el-input>
</div>
<el-button style="margin-left: 60px;margin-top: 10px;" type="danger" icon="el-icon-close" circle size="mini"
@click="newf=false;tempNewF=''"></el-button>
<el-button type="success" icon="el-icon-check" circle size="mini" @click="newFileSure"></el-button>
</div>
</div>
<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)" :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-select v-model="tempMove" placeholder="移动到:" style="margin-left: 10px;" :disabled="this.selection.length>0?false:'disabled'"
filterable @change="moveChange">
<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 v-if="getData.type==1">
<el-button @click="upShow=true">批量导入</el-button>
<el-button @click="down">模板下载</el-button>
</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==='type'">
{{scope.row[item.row]=="1"?'数值型':(scope.row[item.row]=="2"?'字符型':(scope.row[item.row]=="3"?'枚举型':(scope.row[item.row]=="4"?'小数型':(scope.row[item.row]=="5"?'数组型':(scope.row[item.row]=="6"?'JSON型':'')))))}}
</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 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.pager.total">
</el-pagination>
</div>
</div>
</div>
</div>
<template v-else>
<dataManageRedact @close="listRedact=false;tempRedactId=0" @Ok="listRedact=false;tempRedactId=0;getlist();currPage=1"
:updata="getData.updatafield" :id='tempRedactId' :fieldTypeId="currid" :setsave="getData.setsave" :getInfo="getData.getInfo"
:ftype="getData.type"></dataManageRedact>
</template>
</div>
<el-dialog title="上传文件" :visible.sync="upShow" width="30%" :before-close="upShowClose">
<div style="margin: 0 auto;display: flex;justify-content: center;">
<el-upload class="upload-demo" ref="upload" action="doUpload" :limit="1" :file-list="fileList" :before-upload="beforeUpload"
v-loading="Uploadloading">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传excel文件且不超过5MB</div>
<div slot="tip" class="el-upload-list__item-name">{{fileName}}</div>
</el-upload>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="upShow = false">取消</el-button>
<el-button type="primary" @click="submitUpload()">确定</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import '@/assets/css/cont.css'
import fileHome from '@/components/common/fileHome.vue'
import dataManageRedact from '@/components/common/dataManageRedact.vue'
import contmixin from '@/utils/contminxin/contmixin.js'
import {
updateFieldFolder
} from '@/api/index.js'
export default {
mixins: [
contmixin
],
components: {
fileHome,
dataManageRedact,
updateFieldFolder
},
props: {
title: {
type: String,
default: ''
},
getData: {
type: Object,
default: null
},
},
watch: {
list() {
if (this.list.length > 0) {
this.leftloading = false
}
}
},
data() {
return {
list: [],
Uploadloading: false,
tempMove: '',
leftloading: true,
fileName: "",
fileList: [],
upShow: false,
currPage: 1,
currid: null,
data: null,
contloading: false,
newf: false,
tempNewF: "",
tempHintTop: null,
tempHintLeft: null,
tempId: null,
listRedact: false, //新增页面开启
tempRedactId: 0,
selection: []
}
},
created() {
this.getData.getTree({
type: this.getData.type
}).then(res => {
this.list = this.listTreeDeep(res.data, 1)
this.clickCurrid(99999999)
})
},
methods: {
moveChange(e) { //移动文件夹
let arr = this.selection.map((value) => {
return value.id
})
if (arr.length < 1) {
this.$message.error('未选择任何文件');
return
}
let params = {
ids: arr,
folderId: e
}
updateFieldFolder(params).then(res => {
if (res.status == "1") {
this.clickCurrid(this.currid)
this.$message({
message: '移动成功',
type: 'success'
});
this.selection = []
}
})
this.tempMove = ""
},
down() {
window.open(window.origin + '/Riskmanage/v2/datamanage/field/downTemplate')
},
delectFun(id) {
let name
this.deepGetCurr(id, this.list, (value) => {
name = value.name
})
let params = {
status: -1,
id: id,
fieldType: name
}
this.getData.updatalist(params).then(res => {
if (res.status === "1") {
this.$message({
type: 'success',
message: '删除成功!'
});
this.deepGetCurr(id, this.list, (value, item, index) => {
item.splice(index, 1)
})
}
this.leftloading = false
this.currid = 99999999
this.getlist()
}).catch(() => {
this.$message.error("请求失败了" + '-_-');
this.leftloading = false
})
},
updatafilelist(params) {
this.leftloading = true
let tempNum = null
this.deepGetCurr(params.id, this.list, (value) => {
tempNum = value.parentId
})
params.parentId = tempNum == 99999999 ? 0 : tempNum
tempNum = null
let obj = {
fieldType: params.name,
id: params.id,
parentId: params.parentId
}
this.getData.updatalist(obj).then(res => {
if (res.status === "1") {
this.$message({
message: '修改成功',
type: 'success'
});
this.deepGetCurr(params.id, this.list, (value) => {
value.name = params.name
value.Rename = false
})
this.leftloading = false
} else {
this.leftloading = false
}
}).catch(() => {
this.$message.error("请求失败了" + '-_-');
this.leftloading = false
})
},
getlist() {
this.contloading = true
this.listRedact = false
let params = {
"isCommon": 1,
"fieldTypeId": String(this.currid),
"pageNo": 1
}
this.getData.getlist(params).then(res => {
this.data = res
this.contloading = false
})
},
clickpage(e) {
this.currPage = e
this.contloading = true
let params = {
"isCommon": 1,
"fieldTypeId": String(this.currid),
"pageNo": e
}
this.getData.getlist(params).then(res => {
if (res.status == "1") {
this.data = res
this.selection = []
this.contloading = false
}
})
},
using(id) {
let arr = this.selection.map((value) => {
return value.id
})
if (arr.length < 1) {
this.$message.error('未选择任何文件');
return
}
let params = {
status: id,
ids: arr.join(','),
fieldTypeId: this.currid
}
this.getData.fieldusing(params).then(res => {
if (res.status == "1") {
this.$message({
message: '操作成功',
type: 'success'
});
this.getlist()
this.$store.dispatch('reGetfielduser')
}
})
},
newFileSure() {
this.leftloading = true
let params = {
parentId: this.currid,
fieldType: this.tempNewF,
type: this.getData.type
}
this.mixnewFileSure(params)
}
}
}
</script>

View File

@@ -1,851 +0,0 @@
<style>
.dataManageRedact {
width: 100%;
white-space: nowrap;
}
/* .MR_header {
display: flex;
justify-content: space-between;
padding: 20px;
box-sizing: border-box;
border-bottom: 1px solid #ddd;
}
.MR_header>div:nth-of-type(1) {
display: flex;
align-items: center;
justify-content: space-between;
width: 12%;
font-size: 18px;
}
.MR_input {
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
border-bottom: 1px solid #ddd;
padding: 0 0 20px 0;
}
.MR_input>div {
width: 30%;
display: flex;
align-items: center;
justify-content: space-around;
margin-left: 2%;
margin-top: 20px;
}
.MR_input>div>p {
width: 30%;
} */
.MR_checkbox {
padding: 20px;
border-bottom: 1px solid #ddd;
}
.MR_scope {
padding: 20px;
border-bottom: 1px solid #ddd;
}
.MR_scope>div {
display: flex;
align-items: center;
}
.MR_scope>div>p {
width: 10%;
}
.MR_derive {
margin: 0 40px 0 40px;
}
.MR_rule_home {
overflow: scroll;
overflow-x: hidden;
height: 350px;
}
.MR_rule_home::-webkit-scrollbar {
display: none;
/* Chrome Safari */
}
.MR_toolbar {
background-color: #F0F0F0;
height: 40px;
display: flex;
justify-content: space-around;
align-items: center;
font-weight: bold;
font-size: 18px;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
}
.MR_toolbar>p:hover {
color: #fff;
}
</style>
<template>
<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="$emit('close')"></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"></el-button>
</div>
</div>
<div :class="smallHeader?'MR_input MR_inputSmall':'MR_input'">
<div>
<p>字段名称: </p>
<el-input placeholder="请输入字段名" maxlength="30" v-model="fieldEn" clearable></el-input>
</div>
<div>
<p>字段中文名: </p>
<el-input placeholder="请输入字段中文名" maxlength="20" v-model="fieldCn" clearable></el-input>
</div>
<div>
<p>值类型 : </p>
<el-select v-model="valueType" placeholder="请选择">
<el-option label="数值型" :value="1" />
<el-option label="字符型" :value="2" />
<!-- <el-option label="枚举型" :value="3" /> -->
<!-- <el-option label="小数型" :value="4" /> -->
<!-- <el-option label="数组型" :value="5" /> -->
<el-option label="JSON型" :value="6" />
</el-select>
</div>
</div>
<div style="flex: 1;overflow: auto;">
<div v-show="isDerivative=='Derivative'" class="MR_derive">
<el-tabs v-model="activeName">
<el-tab-pane label="条件区域" name="first">
<div class="MR_rule_home">
<rule :Data="ruledata" @faadd="faadd" @fadelect="fadelect" @sonadd="sonadd"
@sondelect="sondelect" @change="change"></rule>
</div>
</el-tab-pane>
<el-tab-pane label="公式编辑" name="second">
</el-tab-pane>
<el-tab-pane label="groovy脚本" name="third">
</el-tab-pane>
</el-tabs>
<div v-show="activeName!=='first'">
<teV2 v-model="formula" :hint="activeName=='second'">
</teV2>
</div>
</div>
<div v-if="Sourcelist">
<div v-show="isDerivative=='SQL'" class="MR_derive">
<el-select v-model="SQLType" placeholder="请选择数据源类型" style="margin-top: 20px;width: 200px;"
@change="SQLName = ''">
<el-option v-for="item in SourcelistType" :key="item.type" :label="item.type"
:value="item.type">
</el-option>
</el-select>
<el-select v-model="SQLName" placeholder="请选择数据源" style="margin-top: 20px;margin-left: 20px;">
<el-option v-for="item in Sourcelist" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<br />
<p
style="margin-top: 20px;border-top: 1px dotted #ddd;padding-top: 10px;display: flex;align-items: center;">
变量<i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size: 24px;"
@click="addsqlVariable"></i></p>
<div v-for="(value,index) in sqlVariable"
style="display: flex;align-items: center;margin-top: 10px;">
<el-input v-model="value.key" style="width: 200px;" placeholder="键"></el-input>
<p style="margin:10px;">:</p>
<el-input v-model="value.value" style="width: 200px;" placeholder="默认值"></el-input>
<i class="el-icon-circle-close" :style="{color:'#F56C6C',fontSize: '24px',marginLeft:'10px'}"
@click="delectsqlVariable(index)"></i>
</div>
<p
style="margin-top: 20px;border-top: 1px dotted #ddd;padding-top: 10px;display: flex;align-items: center;">
字典变量<i class="el-icon-circle-plus-outline" style="color:#409EFF;font-size: 24px;"
@click="addDictVariable"></i></p>
<div v-for="(value,index) in dictVariable"
style="display: flex;align-items: center;margin-top: 10px;">
<el-input v-model="value.key" style="width: 200px;" placeholder="键"></el-input>
<p style="margin:10px;">:</p>
<el-select v-model="value.type" placeholder="请选择类型">
<el-option v-for="item in dictVariableType" :key="item.value" :label="item.label"
:value="item.value">
</el-option>
</el-select>
<el-input v-model="value.value" style="width: 200px;margin-left: 20px;" placeholder="格式"></el-input>
<i class="el-icon-circle-close" :style="{color:'#F56C6C',fontSize: '24px',marginLeft:'10px'}"
@click="delectDictVariable(index)"></i>
</div>
<el-input type="textarea" v-model="SQLItem" rows="9" style="margin-top: 20px;"
placeholder="请输入SQL语句">
</el-input>
</div>
</div>
<div v-if="ftype==4">
<el-select v-model="interfaceId" placeholder="请选择接口" style="margin-top: 20px;margin-left: 20px;">
<el-option v-for="item in interfaceList" :key="item.id" :label="item.name" :value="item.id">
</el-option>
</el-select>
<el-cascader style="margin-left: 20px;" v-model="interfaceParseField" :key="keynum" :options="dataJson"
:props="{ checkStrictly: true }" clearable></el-cascader>
</div>
<div v-show="valueType==6" class="MR_derive">
<p style="margin-top: 20px;">JSON:</p>
<el-input type="textarea" v-model="jsonValue" :rows="9" style="margin-top: 20px;"
placeholder="请输入格式JSON">
</el-input>
</div>
</div>
</div>
</template>
<script>
// import fieldUserTable from './fieldUserTable.vue'
import '@/assets/css/ManageRedact.css'
import teV2 from '@/components/common/teV2.vue'
import mangeRedactMixin from '@/utils/contminxin/MangeRedactMixin.js'
import {
getInterfaceList
} from '@/api/index.js'
import rule from './rule.vue'
export default {
mixins: [mangeRedactMixin],
components: {
getInterfaceList,
// fieldUserTable,
rule,
teV2
},
props: {
fieldTypeId: {
type: Number,
default: 0,
},
setsave: {
type: Function,
default: () => {}
},
id: {
type: Number,
default: 0
},
getInfo: {
type: Function,
default: () => {}
},
updata: {
type: Function,
default: () => {}
},
ftype: {
type: Number,
default: 1
}
},
data() {
return {
sqlVariable: [],
interfaceParseField: [],
keynum: 1,
interfaceId: '',
jsonValue: '',
loading: false,
SQLItem: '',
SQLName: '',
tempFormula: '',
formula: '',
fieldEn: '',
fieldCn: '',
valueType: '',
SQLType: '',
isDerivative: "",
isOutput: false,
activeName: 'first',
isrecord: false, //开始记录
text: '', //剪出的字符串
tempIndex: null, //暂存index
lest: "", //暂存末尾
isshow: false,
islest: true,
interfaceList: [],
ruledata: [{
"fieldSubCond": [{
"fieldId": '',
"operator": "",
"fieldValue": "",
"logical": ""
}],
"conditionValue": "",
"fieldValue": ""
}],
dictVariable: [],
dictVariableType: [{
label: '时间',
value: 'date'
}]
}
},
created() {
if (this.ftype == 4) {
getInterfaceList({
pageNo: 0,
pageSize: 0,
interfaceInfo: {}
}).then(res => {
this.interfaceList = res.data.klist
})
}
if (this.ftype == 2) {
this.isDerivative = 'SQL'
console.log(1)
} else if (this.ftype == 3) {
this.isDerivative = 'Derivative'
}
this.$store.dispatch('getfielduser')
if (this.id != 0) {
this.loading = true
this.getInfo(this.id, {}).then(res => {
this.loading = false
if (res.status === "1") {
this.jsonValue = JSON.stringify(JSON.parse(res.data.fieldVo.jsonValue), null, 4)
this.fieldCn = res.data.fieldVo.fieldCn
this.fieldEn = res.data.fieldVo.fieldEn
this.valueType = res.data.fieldVo.valueType
this.interfaceId = res.data.fieldVo.interfaceId
this.interfaceParseField = res.data.fieldVo.interfaceParseField ? res.data.fieldVo
.interfaceParseField.split('.') : ''
this.fid = res.data.fieldVo.fieldTypeId
this.isOutput = res.data.fieldVo.isOutput == 1 ? true : false
if (res.data.fieldVo.isDerivative) {
this.isDerivative = 'Derivative'
} else if (res.data.fieldVo.useSql) {
this.isDerivative = 'SQL'
this.SQLType = this.$store.state.Sourcelist.find(x => x.id == res.data.fieldVo
.dataSourceId).type
this.SQLName = res.data.fieldVo.dataSourceId
this.SQLItem = res.data.fieldVo.sqlStatement
}
if (res.data.hasFormula == "y" || res.data.hasGroovy == "y") {
this.formula = JSON.parse(res.data.fieldVo.formula)[0].formula
if (res.data.hasFormula == "y") {
this.activeName = "second"
}
if (res.data.hasGroovy == "y") {
this.activeName = "third"
}
} else if (res.data.fieldVo.fieldCondList.length > 0) {
this.ruledata = res.data.fieldVo.fieldCondList
}
if (this.ftype == 2) {
if (res.data.fieldVo.sqlVariable == null) {
this.sqlVariable = []
} else {
this.sqlVariable = JSON.parse(res.data.fieldVo.sqlVariable)
}
if (res.data.fieldVo.dictVariable == null) {
this.dictVariable = []
} else {
this.dictVariable = JSON.parse(res.data.fieldVo.dictVariable)
}
}
// console.log(res.data.fieldVo.fieldCondList)
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
}
},
computed: {
dataJson() {
if (this.ftype != 4) {
return {}
}
let obj = {}
this.interfaceList.forEach(value => {
if (value.id == this.interfaceId) {
obj = JSON.parse(value.responseBody)
}
})
obj = this.deepGetLayout(obj)
console.log(obj)
return obj
},
FieldUser() {
return this.$store.state.FieldUser
},
SourcelistType() {
let arr = []
if (this.$store.state.Sourcelist) {
this.$store.state.Sourcelist.forEach(value => {
let sarr = arr.find(x => x.type == value.type)
if (sarr) {
sarr.data.push(value)
} else {
arr.push({
type: value.type,
data: [value]
})
}
})
}
console.log(arr)
return arr
},
Sourcelist() {
let arr = this.SourcelistType.find(x => x.type == this.SQLType)
if (arr) {
return arr.data
} else {
return []
}
}
},
mounted() {
// this.$refs.textarea.$refs.textarea.onkeydown = (e) => {
// if (e.key === 'Backspace') {
// this.text = ""
// }
// }
},
methods: {
addDictVariable() {
this.dictVariable.push({
key: '',
type: '',
value: ''
})
},
delectDictVariable(index) {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.dictVariable.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
delectsqlVariable(index) {
this.sqlVariable.splice(index, 1)
},
addsqlVariable() {
this.sqlVariable.push({
value: '',
key: ''
})
},
deepGetLayout(obj) {
let sobj = []
for (let key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] == 'object' && !Array.isArray(obj[key]) && obj[key] != null) {
sobj.push({
label: key,
value: key,
children: this.deepGetLayout(obj[key])
})
} else if (typeof obj[key] == 'object' && Array.isArray(obj[key]) && obj[key] != null) {
sobj.push({
label: key,
value: key,
children: [{
label: '元素',
value: '[]',
children: this.deepGetLayout(obj[key][0])
}]
})
} else {
sobj.push({
label: key,
value: key,
})
}
}
}
return sobj
},
submit() {
let reg = /[\u4e00-\u9fa5]+/g;
if (this.fieldEn.match(reg) != null) {
this.$message.error('代码不允许出现中文');
return
}
if (this.verificationNameCode(this.fieldEn) || this.verificationNameCode(this.fieldCn)) {
return
}
if (this.fieldEn.trim() == '' || this.fieldCn.trim() == '' || this.valueType == '') {
this.$message.error('请填入所有字段,并检查空格');
return
}
let is = {
is:true,
msg:'请填入页面中未填的部分'
}
if (this.isDerivative == "Derivative" && this.activeName == 'first') {
this.ruledata.forEach(value => {
if (value.conditionValue.length < 1) {
is.is = false
}
value.fieldSubCond.forEach((item, inde) => {
if (item.fieldId == "" || item.operator == "" || item.fieldValue.length < 1) {
is.is = false
}
if (item.logical == "" && inde !== value.fieldSubCond.length - 1) {
is.is = false
}
})
})
}
if (this.ftype == 2) {
this.sqlVariable.forEach(value => {
if (value.value.trim() === "" || value.key.trim() === "") {
is.is = false
}
})
this.dictVariable.forEach(value => {
if (value.key.trim() === "" || value.type=== ""|| value.value.trim()=== "") {
is.is = false
}
})
let arr = []
arr.push(...this.sqlVariable.map(value=>value.key))
arr.push(...this.dictVariable.map(value=>value.key))
if(arr.length!=Array.from(new Set(arr)).length){
is.is=false
is.msg = '不允许出现重复的变量'
}
}
if (this.ftype == 4 && !this.interfaceId) {
is.is = false
}
if (is.is === false) {
this.$message.error(is.msg);
return
}
if (this.valueType == 6 && !this.isJSON(this.jsonValue)) {
this.$message.error('请检查JSON格式');
return
}
let obj = {
searchKey: '',
fieldEn: this.fieldEn,
fieldCn: this.fieldCn,
valueType: this.valueType, //字段值类型
isDerivative: this.isDerivative == "Derivative" ? 1 : 0, //是否衍生字段
isOutput: this.isOutput ? 1 : 0, //是否输出字段
// valueScope: this.valueScope, //字段约束范围
fieldCondList: '',
formulaHidden: '',
isUseSql: this.isDerivative == "SQL" ? true : false, //是否使用sql
dataSourceId: 0,
sqlStatement: '', //sql语句
}
if (this.valueType == 6) {
obj.jsonValue = this.jsonValue
}
if (this.ftype == 2) {
if (this.sqlVariable.length == 0) {
obj.sqlVariable = null
} else {
obj.sqlVariable = JSON.stringify(this.sqlVariable)
}
obj.dictVariable = JSON.stringify(this.dictVariable)
}
if (this.ftype == 4) {
obj.isInterface = 1
obj.interfaceId = this.interfaceId
obj.interfaceParseField = this.interfaceParseField.join('.')
} else {
obj.isInterface = 0
}
// console.log(this.isDerivative)
if (this.isDerivative == "Derivative") {
if (this.activeName == "first") {
obj.fieldCondList = JSON.stringify(this.ruledata)
} else if (this.activeName == "second" || this.activeName == "third") {
let tempArr = []
let num = 0
for (let i of this.formula) {
if (i === "@") {
num++
}
}
if (num % 2 === 0 && num != 0) {
this.formula.match(/@.*?@/g).forEach(value => {
let tempObj = {
fieldCN: value.substring(1, value.length - 1),
fieldCond: ''
}
tempArr.push(tempObj)
})
}
obj.formulaHidden = JSON.stringify([{
fvalue: '',
formula: this.formula.trim(),
idx: '0',
farr: tempArr,
}])
}
} else if (this.isDerivative == "SQL") {
obj.dataSourceId = this.SQLName
obj.sqlStatement = this.SQLItem
}
let isT = true;
if (this.isDerivative == "SQL") {
let sqlCheck = obj.sqlStatement.match(/(create|update|delete|truncate|alert|drop)\s+/im);
if (sqlCheck != null) {
isT = false;
this.$message.error('存在有风险sql关键词:' + sqlCheck[0].toUpperCase());
}
}
if (isT) {
if (this.id == 0) {
obj.fieldTypeId = this.fieldTypeId == 99999999 ? 0 : this.fieldTypeId,
this.loading = true
this.setsave(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '添加成功',
type: 'success'
});
this.$emit('Ok')
// this.$store.dispatch('reGetisOutput')
this.$store.dispatch('reGetfielduser')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
} else {
obj.id = this.id
obj.fieldTypeId = this.fid
this.loading = true
this.updata(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '修改成功',
type: 'success'
});
this.$emit('Ok')
// this.$store.dispatch('reGetisOutput')
this.$store.dispatch('reGetfielduser')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
}
}
},
isJSON(str) {
if (typeof str == 'string') {
try {
var obj = JSON.parse(str);
if (typeof obj == 'object' && obj) {
return true;
} else {
return false;
}
} catch (e) {
console.log('error' + str + '!!!' + e);
return false;
}
}
},
change(index, inde) {
this.ruledata[index].fieldSubCond[inde].operator = ""
this.ruledata[index].fieldSubCond[inde].fieldValue = ""
},
sondelect(index, inde) {
this.ruledata[index].fieldSubCond.splice(inde, 1)
},
sonadd(index, inde) {
this.ruledata[index].fieldSubCond.splice(inde + 1, 0, {
"fieldId": "",
"operator": "",
"fieldValue": "",
"logical": ""
})
},
faadd(index) { //rule父节点添加
this.ruledata.splice(index + 1, 0, {
"conditionValue": "",
"fieldSubCond": [{
"fieldId": "",
"operator": "",
"fieldValue": "",
"logical": "",
}]
})
},
fadelect(index) {
this.ruledata.splice(index, 1)
},
textareaAdd(text) {
if (text === "fx") {
this.formula = "def main(_){\n\n}"
} else {
this.formula += text
}
},
dbclick(e) {
let T = ""
T = this.formula.split("")
T.splice(this.tempIndex, this.text.length + 1, '@' + e + '@')
this.formula = T.join("")
this.isshow = false
}
},
watch: {
interfaceId() {
this.keynum++
},
formula() {
let num = 0
for (let i of this.formula) {
if (i === "@") {
num++
}
}
if (num % 2 === 1) {
this.isshow = true
for (let i in this.formula) {
if (this.formula[i] !== this.tempFormula[i] && this.formula[i] == "@") {
if (this.islest) {
this.tempIndex = i
this.lest = this.formula.substring(parseInt(this.tempIndex) + 1, this.formula.length)
this.islest = false
}
// console.log('字段:' + this.formula[i] + "暂存字段:" + this.tempFormula[i])
break
}
}
let T = this.formula.substring(parseInt(this.tempIndex) + 1, this.formula.length)
if (this.lest !== "") {
// console.log(T)
T = T.substring(0, T.indexOf(this.lest))
} else {
T = T.substring(0, T.length)
}
this.text = T
// console.log('lest:' + this.lest, 'index:' + this.tempIndex, "T:" + T)
} else {
this.islest = true
this.text = ""
this.tempIndex = null
this.isshow = false
}
this.tempFormula = this.formula
}
}
}
</script>

View File

@@ -1,80 +0,0 @@
import Vue from 'vue';
// v-dialogDrag: 弹窗拖拽属性
Vue.directive('dialogDrag', {
bind(el, binding, vnode, oldVnode) {
const dialogHeaderEl = el.querySelector('.el-dialog__header');
const dragDom = el.querySelector('.el-dialog');
dialogHeaderEl.style.cssText += ';cursor:move;'
dragDom.style.cssText += ';top:0px;'
// 获取原有属性 ie dom元素.currentStyle 火狐谷歌 window.getComputedStyle(dom元素, null);
const sty = (() => {
if (window.document.currentStyle) {
return (dom, attr) => dom.currentStyle[attr];
} else {
return (dom, attr) => getComputedStyle(dom, false)[attr];
}
})()
dialogHeaderEl.onmousedown = (e) => {
// 鼠标按下,计算当前元素距离可视区的距离
const disX = e.clientX - dialogHeaderEl.offsetLeft;
const disY = e.clientY - dialogHeaderEl.offsetTop;
const screenWidth = document.body.clientWidth; // body当前宽度
const screenHeight = document.documentElement.clientHeight; // 可见区域高度(应为body高度可某些环境下无法获取)
const dragDomWidth = dragDom.offsetWidth; // 对话框宽度
const dragDomheight = dragDom.offsetHeight; // 对话框高度
const minDragDomLeft = dragDom.offsetLeft;
const maxDragDomLeft = screenWidth - dragDom.offsetLeft - dragDomWidth;
const minDragDomTop = dragDom.offsetTop;
const maxDragDomTop = screenHeight - dragDom.offsetTop - dragDomheight;
// 获取到的值带px 正则匹配替换
let styL = sty(dragDom, 'left');
let styT = sty(dragDom, 'top');
// 注意在ie中 第一次获取到的值为组件自带50% 移动之后赋值为px
if (styL.includes('%')) {
styL = +document.body.clientWidth * (+styL.replace(/\%/g, '') / 100);
styT = +document.body.clientHeight * (+styT.replace(/\%/g, '') / 100);
} else {
styL = +styL.replace(/\px/g, '');
styT = +styT.replace(/\px/g, '');
};
document.onmousemove = function (e) {
// 通过事件委托,计算移动的距离
let left = e.clientX - disX;
let top = e.clientY - disY;
// 边界处理
if (-(left) > minDragDomLeft) {
left = -(minDragDomLeft);
} else if (left > maxDragDomLeft) {
left = maxDragDomLeft;
}
if (-(top) > minDragDomTop) {
top = -(minDragDomTop);
} else if (top > maxDragDomTop) {
top = maxDragDomTop;
}
// 移动当前元素
dragDom.style.cssText += `;left:${left + styL}px;top:${top + styT}px;`;
};
document.onmouseup = function (e) {
document.onmousemove = null;
document.onmouseup = null;
};
}
}
})

View File

@@ -1,235 +0,0 @@
<template>
<div class="stop-condition">
<!-- 标题 -->
<div style="background-color: #aaa; height: 30px;line-height: 30px; color: #fff;padding: 10px; box-sizing: border-box; margin: 10px 0;display: flex;align-items: center;justify-content: space-between;">
<p>终止条件</p>
</div>
<!-- 按钮 -->
<el-button type="primary" round size="mini" @click="selRule(true)" style="margin-top: 10px;">
选择({{data.selectedRule.length}})</el-button>
<div v-if="data.selectedRule.length>0">
<div v-for="(condition,index) in data.conditions" :key="index" class="conditions-wrapper"
style="display: flex;">
<el-select v-model="condition.fieldCode" placeholder="条数/分数" size="mini" style="width: 110px;">
<slot>
</slot>
</el-select>
<ruleRelation v-model="condition.operator" :value2.sync="condition.value" :valueType="valueType" size="mini"
style="width:200px;"></ruleRelation>
<el-select v-model="condition.relativeOperator" placeholder="请选择" style="width: 70px;margin-left: 10px;"
size="mini" v-if="index!=data.conditions.length-1">
<el-option label="and" value="&&"></el-option>
<el-option label="or" value="||"></el-option>
</el-select>
<i class="el-icon-plus" style="font-size: 20px;color: #409EFF;" @click="addCondition(index)"></i>
<i class="el-icon-close" style="font-size: 20px;color: #F56C6C;" v-show="index!=0"
@click="delCondtion(index)"></i>
</div>
</div>
<div v-if="data.selectedRule.length>0">
<div
style="background-color: #aaa; height: 30px;line-height: 30px; color: #fff;padding: 10px; box-sizing: border-box; margin: 10px 0;display: flex;align-items: center;justify-content: space-between;">
<p>终止结果</p>
</div>
<div class="setting-wrapper">
<el-select v-model="data.output.fieldId" filterable placeholder="输出变量" @change="data.output.fieldCode = mixinGetvalueEn($event)" size="mini" style="width:130px;">
<el-option v-for="(item,index) in Fielduser" :key="index" :label="item.fieldCn" :value="item.id">
</el-option>
</el-select>
<div class="line">=</div>
<varialeSelect v-model="data.output.fieldValue" :valueType="mixinGetvalueType(data.output.fieldId)" :variableType.sync="data.output.variableType" height="28px"></varialeSelect>
</div>
</div>
<el-dialog title="选择条件(多选)" :visible="showRuleDialog" width="40%" :append-to-body="true" @close="cancelSelRule">
<div>
<el-checkbox-group v-model="currentSelectRule">
<el-table ref="ruleArr" :data="pageRuleList" size="mini">
<el-table-column width="60">
<template slot-scope="scope">
<el-checkbox :label="scope.row.id">&nbsp;</el-checkbox>
</template>
</el-table-column>
<el-table-column prop="id" label="id" >
</el-table-column>
<el-table-column :prop="name" label="名称">
</el-table-column>
<el-table-column :prop="code" label="code">
</el-table-column>
</el-table>
<el-pagination small layout="prev, pager, next" :total="list.length" :page-size="10"
@current-change="page=$event" style="margin-left: 70%;margin-top: 10px;">
</el-pagination>
</el-checkbox-group>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="cancelSelRule"> </el-button>
<el-button type="primary" @click="selRuleSure"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import ruleRelation from '@/components/common/ruleRelation.vue'
import varialeSelect from '@/components/models/varialeSelect.vue'
export default {
components:{ruleRelation,varialeSelect},
props: {
data: {
type: Object,
default: {}
}, //nodeJson.terminationInfo
list:{
type: Array,
default: []
},
onlyOne:{
type: Boolean,
default: false
},
valueType:{
type: Number,
default: 1
},
name:{
type: String,
default: 'name'
},
code:{
type: String,
default: 'code'
},
},
data() {
return {
showRuleDialog: false,
page: 1,
currentSelectRule:[]
}
},
created() {
},
computed: {
Fielduser() {
if (this.$store.state.FieldUser != null) {
this.loading = false
return this.$store.state.FieldUser.data.fieldList
} else {
return []
}
},
pageRuleList(){
return this.list.filter((value,index)=>{
return index>=(this.page-1)*10&&index<this.page*10
})
}
},
methods: {
addCondition(index) {
this.data.conditions.splice(index + 1, 0, {
"fieldCode": "",
"fieldName": "",
"valueType": this.valueType,
"operator": "",
"value": "",
"relativeOperator": ""
})
},
selRuleSure(){ //确定选择
this.data.selectedRule = this.list.filter(value=>{
return this.currentSelectRule.indexOf(value.id)!=-1
})
if(this.data.selectedRule.length==0){
this.$emit('reSetTerminationInfo')
}
this.showRuleDialog = false
},
cancelSelRule(){ //取消选择规则
this.showRuleDialog = false
},
selRule(isShow) {
if(this.onlyOne){
console.log(this.data.selectedRule,this.pageRuleList)
if(!this.pageRuleList[0]){
this.$message.warning('请先选择上方节点')
return
}
if(!this.data.selectedRule.length){
this.data.selectedRule = this.pageRuleList
this.$message.success('已为选中上方节点')
return
}else{
this.$emit('reSetTerminationInfo')
this.$message.success('已为你取消选中上方节点')
return
}
}
console.log(this.currentSelectRule )
if (this.list.length > 0 && isShow) {
this.showRuleDialog = true;
this.currentSelectRule = this.data.selectedRule.map(value=>value.id)
} else if (isShow) {
this.$message.error('请先选择策略!');
}
},
delCondtion(index){
this.data.conditions.splice(index, 1);
},
},
watch:{
list(newValue){
if(this.data.selectedRule&&this.data.selectedRule.length>0){
let num = -1
this.data.selectedRule.forEach((value,index)=>{
let is = true
newValue.forEach(item=>{
if(item.id==value.id){
console.log(item.id,value.id)
is = false
}
})
if(is){
num = index
}
})
if(num!=-1){
this.data.selectedRule.splice(num,1)
}
}
}
}
}
</script>
<style>
</style>

View File

@@ -1,208 +0,0 @@
<style>
.fieldUserTable {
background-color: #fff;
position: fixed;
width: 400px;
height: 400px;
overflow: hidden;
z-index: 9;
border: 6px solid #9bcdff;
border-radius: 5px;
box-sizing: border-box;
}
.FUT_header {
background-color: #3584d3;
color: #fff;
display: flex;
justify-content: space-between;
padding: 3px;
box-sizing: border-box;
position: absolute;
top: 0;
height: 30px;
width: 100%;
}
.FUT_table::-webkit-scrollbar {
display: none;
/* Chrome Safari */
}
.FUT_table{
height: 93%;
overflow: scroll;
overflow-x: hidden;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
margin-top: 30px;
}
.FUT_table>p {
margin-top: 2px;
}
.FUT_table>p:hover {
color: #fff;
background-color: #9bcdff;
}
#fieldUserTabletempcurr{
background-color: #d9ebff;
}
</style>
<template>
<div>
<div v-show="show" class="fieldUserTable" @mousedown="mousedowm" ref="UserTable" :style="{top:this.tempTop+'px',left:this.tempLeft+'px'}">
<div class="FUT_header" >
<p>字段列表</p>
<p><i class="el-icon-close" @click="$emit('close')"></i></p>
</div>
<div class="FUT_table" v-show="fieldUserRemind.length>0" id="FUT_table">
<p v-for="(item,index) in fieldUserRemind" @dblclick="dbc(item.fieldCn)" :id="index==tempCurIndex?'fieldUserTabletempcurr':''">{{item.fieldCn?item.fieldCn:item.fieldEn}}</p>
</div>
</div>
</div>
</template>
<script>
export default {
props: {
text: {
type: String,
default: ""
},
fieldUser: {
type: Array||Boolean,
default: false
},
show:{
type:Boolean,
default:false
}
},
data() {
return {
tempCurIndex:0,
tempTop:300,
tempLeft:800,
drag:false,
tempClientX:0,
tempClientY:0,
tempOffsetLeft:0,
tempOffsetTop:0,
temptext:"",
}
},
created() {
},
beforeUnmount() {
},
mounted() {
window.onmousemove=(e)=>{
if(this.drag){
this.tempTop=e.clientY-(this.tempClientY-this.tempOffsetTop)
this.tempLeft=e.clientX-(this.tempClientX-this.tempOffsetLeft)
}
},
window.onmouseup=()=>{
this.drag=false
}
},
computed: {
fieldUserRemind() {
if (this.show === true) {
let arr = []
this.fieldUser.forEach(value => {
if (value.fieldCn.indexOf(this.text) !== -1) {
arr.push({ ...value
})
}
})
return arr
} else {
return []
}
}
},
watch: {
show(){
// console.log(this.show)
if(this.show){
window.onkeydown=(e)=>{
if(e.key=='ArrowUp'||e.key=='ArrowDown'){
e.preventDefault()
var tempcurrDom = document.getElementById('fieldUserTabletempcurr')
var FUTTable = document.getElementById('FUT_table')
if(e.key=='ArrowUp'&&this.tempCurIndex>0){
this.tempCurIndex--
}
if(e.key=='ArrowDown'&&this.tempCurIndex<this.fieldUserRemind.length-1){
this.tempCurIndex++
}
FUTTable.scrollTop = tempcurrDom.offsetTop-180
}
if(e.key=='Enter'){
e.preventDefault()
this.dbc(this.fieldUserRemind[this.tempCurIndex].fieldCn)
}
}
}else{
window.onkeydown=()=>{
}
}
},
text(){
this.tempCurIndex = 0
var FUTTable = document.getElementById('FUT_table')
FUTTable.scrollTop =0
}
},
methods: {
mousedowm(e){
this.tempClientX = e.clientX;
this.tempClientY = e.clientY;
this.tempOffsetLeft=this.$refs.UserTable.offsetLeft
this.tempOffsetTop=this.$refs.UserTable.offsetTop
this.drag=true
},
dbc(e){
this.$emit('dbc',e)
}
}
}
</script>

View File

@@ -1,139 +0,0 @@
<template>
<div :style="{display:show?'block':'none',position:'relative'}">
<div @click="opening()" :style="{marginLeft:(5+retract*10)+'px',display:show?'flex':'none'}" class="file_file" @contextmenu.prevent="opening();$emit('fileRight',{e:$event,item:item})">
<p style="width: 16px;">
<i :class="open?'el-icon-arrow-down':'el-icon-arrow-right'" :style="{display:iconshow?'inline':'none'}"></i>
</p>
<i :class="iconshow?open?'el-icon-folder-opened file_icon':'el-icon-folder file_icon':'el-icon-folder file_icon'"></i>
<span class="file_name" v-show="Rename">
<el-input v-model="inputValue" placeholder="回车键确认,esc取消" size="mini" ref="input" @keyup.enter="submit"></el-input>
</span>
<span class="file_name" v-show="!Rename">{{name}}</span>
</div>
</div>
</template>
<script>
import bus from '@/components/common/bus.js'
export default {
props: {
item: {
type: Object,
default () {
return {}
}
}
},
data() {
return {
name: '',
Rename: '',
retract: '',
open: '',
show: '',
id: '',
inputValue: ''
}
},
mounted() {
this.$refs.input.$refs.input.onkeydown = (e) => {
this.keyDown(e)
}
this.setItem(this.item)
},
methods: {
setItem(e){
this.name =e.name
this.Rename=e.Rename
this.retract=e.ZIndex
this.open=e.open
this.show=e.show
this.id=e.id
},
keyDown(e) {
// console.log(e)
if (e.key === "Enter") {
if (this.inputValue.length > 20) {
this.$message({
message: '最大长度20个字符',
type: 'warning'
});
} else {
let params = {
name: this.inputValue.trim(),
id: this.id
}
this.$emit("updatafilelist", params)
}
} else if (e.key === "Escape") {
this.inputValue = ""
this.$emit('RenameClose', this.id)
}
},
opening() {
if (!this.Rename) {
this.$emit('curr', this.id)
}
},
submit(e) {
console.log(1)
}
},
watch: {
Rename() {
if (this.Rename === true) {
setTimeout(() => {
this.$refs.input.focus()
}, 10)
}
},
item: {
deep: true, //深度监听设置为 true
handler: function(e) {
this.setItem(e)
}
}
},
computed:{
iconshow(){
return !!this.item.children.length
}
}
}
</script>
<style>
.file_file {
transition: all .3s;
align-items: center;
padding: 5px;
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
}
.file_icon {
margin-right: 5px;
}
.file_name {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>

View File

@@ -1,147 +0,0 @@
<template>
<div>
<div v-for="item in data">
<file :class="item.id===currid?'file_select':''" @curr="curr" :item="item"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
<div v-for="value in item.children">
<file :class="value.id===currid?'file_select':''" @curr="curr" :item="value"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
<div v-for="cont in value.children">
<file :class="cont.id===currid?'file_select':''" @curr="curr" :item="cont"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
<div v-for="cont1 in cont.children">
<file :class="cont1.id===currid?'file_select':''" @curr="curr" :item="cont1"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
<div v-for="cont2 in cont1.children">
<file :class="cont2.id===currid?'file_select':''" @curr="curr" :item="cont2"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
<div v-for="cont3 in cont2.children">
<file :class="cont3.id===currid?'file_select':''" @curr="curr" :item="cont3"
@RenameClose="RenameClose" @updatafilelist="updatafilelist" @fileRight="fileRight"></file>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fileHint" :style="{top:tempHintTop+'px',left:tempHintLeft+'px',display:tempHintTop&&tempHintLeft?'block':'none'}">
<p>
<el-button type="text" size="mini" @click="RenameFun">重命名</el-button>
</p>
<p>
<el-button type="text" size="mini" @click="delectFun">删除</el-button>
</p>
<p>
<el-button type="text" size="mini" @click="tempHintLeft=null;tempHintTop=null">取消</el-button>
</p>
</div>
</div>
</template>
<script>
import file from './file.vue'
export default {
components: {
file
},
data(){
return {
tempHintTop : null,
tempHintLeft :null,
tempId:null
}
},
props: {
data: {
type: Array,
default () {
return []
}
},
currid:{
type:Number,
default : 99999999
}
},
created() {
setTimeout(() => {
console.log(this.data)
}, 1000)
},
methods: {
curr(e) {
this.tempHintLeft = null
this.tempHintTop = null
this.tempId = null
this.$emit('curr',e)
},
RenameClose() {
this.$emit('RenameClose',this.tempId )
},
updatafilelist(e) {
this.$emit('updatafilelist',e)
},
fileRight(e){
this.tempHintLeft = e.e.x
this.tempHintTop = e.e.y
this.tempId = e.item.id
},
RenameFun(){
this.$emit('RenameFun',this.tempId )
this.tempHintTop = null,
this.tempHintLeft =null,
this.tempId=null
},
delectFun(){
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$emit('delectFun',this.tempId )
this.tempHintTop = null,
this.tempHintLeft =null,
this.tempId=null
}).catch(() => {
this.$message({
type: 'info',
message: '已取消删除'
});
this.tempHintTop = null
this.tempHintLeft = null
});
}
}
}
</script>
<style>
</style>

View File

@@ -1,61 +0,0 @@
<template>
<div>
<el-drawer title="操作提示" :visible="open" @update:visible="$emit('update:open',false)">
<div v-for="value in data" style="padding-left: 10px;">
<p style="font-size: 18px;font-weight: bold;">{{value.title}}</p>
<div v-for="(item,index) in value.cont" style="padding-left: 10px;margin-top: 3px;">
<p :style="{color:item.type=='limit'?'#f56c6c':'#000'}">{{index+1}}.{{item.text}}</p>
</div>
</div>
</el-drawer>
</div>
</template>
<script>
export default {
props: {
open: false
},
data() {
return{
data:[{
title:'节点',
cont:[
{text:'红色节点以及名单库决策选项统称为策略节点'},
{text:'紫色节点统称为分支节点'},
{text:'分支节点后可以有多个节点,但策略节点后只能有一个节点'},
{text:'拖动节点可以改变位置,双击节点可以编辑节点内容'},
]
},{
title:'连线',
cont:[
{text:'右键点击节点可以呼出连线,再次右击可以连接下一个节点'},
{text:'连线不能封闭',type:'limit'},
{text:'并行节点后只能有策略节点,需要使用分支节点可以先聚合',type:'limit'},
{text:'多出口节点需要先定义出口并提交才能连线',type:'limit'},
{text:'多出口节点不能同时编辑和连线',type:'limit'},
]
},{
title:'版本',
cont:[
{text:'新建和复制版本会生成一个小版本,小版本部署成功后会变成主版本'},
]
}]
}
}
}
</script>
<style>
</style>

View File

@@ -1,30 +0,0 @@
export const messages = {
'zh': {
i18n: {
breadcrumb: '国际化产品',
tips: '通过切换语言按钮,来改变当前内容的语言。',
btn: '切换英文',
title1: '常用用法',
p1: '要是你把你的秘密告诉了风,那就别怪风把它带给树。',
p2: '没有什么比信念更能支撑我们度过艰难的时光了。',
p3: '只要能把自己的事做好,并让自己快乐,你就领先于大多数人了。',
title2: '组件插值',
info: 'Element组件需要国际化请参考 {action}。',
value: '文档'
}
},
'en': {
i18n: {
breadcrumb: 'International Products',
tips: 'Click on the button to change the current language. ',
btn: 'Switch Chinese',
title1: 'Common usage',
p1: "If you reveal your secrets to the wind you should not blame the wind for revealing them to the trees.",
p2: "Nothing can help us endure dark times better than our faith. ",
p3: "If you can do what you do best and be happy, you're further along in life than most people.",
title2: 'Component interpolation',
info: 'The default language of Element is Chinese. If you wish to use another language, please refer to the {action}.',
value: 'documentation'
}
}
}

View File

@@ -1,114 +0,0 @@
<template>
<div>
<div v-for="(value,index) in list" style="width: 800px;display: flex;align-items: center;margin-bottom: 10px;">
<el-input v-model="value.outputKey" placeholder="请输入Key" style="width: 160px;margin-right: 10px;">
</el-input>
:
<el-select v-model="value.outputOp" clearable placeholder="请选择" style="width: 120px;margin-left: 10px;"
@change="Opchange(value)">
<el-option v-for="item in option" :key="item.value" :label="item.label" :value="item.value">
</el-option>
</el-select>
<el-cascader v-model="value.outputOpKey" filterable :options="ValueObj" clearable placeholder="请选择计算依赖"
v-if="value.outputOp!='custom'&&value.outputOp!='count'" :key="(value.random?value.random:0)" style="margin-left: 10px;"
:props="{ expandTrigger: 'hover' }" @visible-change="randomAdd(value,$event)">
</el-cascader>
<varialeSelect v-if="value.outputOp=='custom'" :variableType.sync="value.variableType" :disabled="[2]"
:variableCascaderValue="ValueObj" :variableCascader="true" size="medium" height="36px"
v-model="value.outputValue" :interceptCustom="true" @CustomCallback="CustomCallback(value,list,index)"
style="margin-left: 10px;">
</varialeSelect>
<i class="el-icon-circle-close" style="color: red;margin-left: 10px;" @click="deleteOutput(index)"></i>
</div>
<el-button @click="addOutput">+</el-button>
</div>
</template>
<script>
import varialeSelect from '@/components/models/varialeSelect.vue'
export default {
components: {
varialeSelect
},
props: {
ValueObj: {
type: Array,
default () {
return []
}
},
list: {
type: Array,
default () {
return []
}
},
option: {
type: Array,
default () {
return []
}
},
},
methods: {
CustomCallback(value,list,index) {
let arr = JSON.parse(JSON.stringify(list))
arr = list.filter((value,index2) =>index2<index)
arr = arr.map(value => value.outputKey)
value.arr = []
value.arr = arr
this.$emit('CustomCallback', value)
},
Opchange(value) {
value.variableType = 1
value.outputValue = ''
value.outputOpKey = []
},
deleteOutput(index) {
this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.list.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
addOutput() {
this.list.push({
outputKey: '',
outputOp: '',
variableType: 1,
outputValue: '',
outputOpKey: []
})
}
}
}
</script>
<style>
</style>

View File

@@ -1,15 +0,0 @@
<template>
<div>
</div>
</template>
<script>
</script>
<style>
</style>

View File

@@ -1,109 +0,0 @@
<style>
.rule_home {
display: flex;
}
.rule_fa {
display: flex;
width: 20%;
height: 30%;
margin: 10px 10px 0 0;
}
.rule_son {
display: flex;
margin-top: 10px;
justify-content: flex-start;
}
</style>
<template>
<div>
<div v-if="Data&&FieldUser">
<div v-for="(item,index) in Data" class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="$emit('faadd',index)"></el-button>
<el-button icon="el-icon-close" circle @click="$emit('fadelect',index)" :disabled="index===0?'disabled':false" style="margin-right: 10px;"></el-button>
<el-input v-model="item.conditionValue" style="width: 200px;" maxlength="20" placeholder="请输入内容"></el-input>
</div>
<div>
<div v-for="(value,inde) in item.fieldSubCond" class="rule_son">
<el-button icon="el-icon-plus" circle @click="$emit('sonadd',index,inde)" ></el-button>
<el-button icon="el-icon-close" circle @click="$emit('sondelect',index,inde)" :disabled="inde===0?'disabled':false" style="margin-right: 10px;"></el-button>
<el-select v-model="value.fieldId" placeholder="请选择" filterable style="width: 200px;" @change="$emit('change',index,inde)">
<el-option v-for="cont in FieldUser.data.fieldList" :key="cont.id" :label="cont.fieldCn" :value="cont.id">
</el-option>
</el-select>
<ruleRelation v-model="value.operator" :value2.sync="value.fieldValue" :valueType="getvalueType(value.fieldId)" ></ruleRelation> 12312312
<!-- <el-input v-model="value.fieldValue" maxlength="30" placeholder="请输入内容,最长30位" style="width: 300px;margin-left: 10px;" v-show="getvalueType(value.fieldId)!==3">
</el-input>
<el-select v-model="value.fieldValue" placeholder="请选择" style="width: 300px;margin-left: 10px;" v-show="getvalueType(value.fieldId)===3">
<el-option label="是" value="1"></el-option>
<el-option label="否" value="0"></el-option>
</el-select> -->
<el-select v-model="value.logical" placeholder="请选择" style="width: 100px;margin-left: 10px;" v-show="inde!==item.fieldSubCond.length-1">
<el-option label="and" value="&&"></el-option>
<el-option label="or" value="or"></el-option>
</el-select>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
import ruleRelation from '@/components/common/ruleRelation.vue'
export default {
components:{
ruleRelation
},
data() {
return {
}
},
created() {
console.log(this.Data)
},
computed: {
FieldUser() {
return this.$store.state.FieldUser
}
},
props: {
Data: {
type: Array,
default () {
return []
}
}
},
methods:{
getvalueType(cont){
let num
this.FieldUser.data.fieldList.forEach(value=>{
if(value.id===cont){
num = value.valueType
}
})
return num
}
}
}
</script>

View File

@@ -1,489 +0,0 @@
<style>
.easyrule_com{
flex: 1;
overflow: scroll;
margin: 20px 0px 0px 10px;
padding-bottom: 100px;
}
</style>
<template>
<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 type="success" icon="el-icon-check" circle @click="submit"></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></el-input>
</div>
<div>
<p> 规则名称: </p>
<el-input placeholder="请输入规则名称" maxlength="20" v-model="name" clearable></el-input>
</div>
<div>
<p> : </p>
<el-select v-model="priority" placeholder="请选择">
<el-option label="0" :value="0" />
<el-option label="1" :value="1" />
<el-option label="2" :value="2" />
<el-option label="3" :value="3" />
<el-option label="4" :value="4" />
<el-option label="5" :value="5" />
<el-option label="6" :value="6" />
<el-option label="7" :value="7" />
<el-option label="8" :value="8" />
<el-option label="9" :value="9" />
</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></el-input>
</div>
</div>
<div class="easyrule_com">
<RuleDown :type="1" :Data="ruledata" @faadd="faadd" @outAdd="outAdd" @outDelect="outDelect" @fadelect="fadelect"
@change="change" :SpecialField="SpecialField" :outcontent="outcontent">
<div class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="outAdd(0)" disabled></el-button>
<el-button icon="el-icon-close" circle disabled='disabled' style="margin-right: 10px"></el-button>
</div>
<el-select v-model="resultFieldEn" filterable placeholder="请选择" style="width: 200px;">
<el-option v-for="item in FieldUser" :key="item.id" :label="item.fieldCn" :value="item.fieldEn">
</el-option>
</el-select>
<p style="margin: 10px;">
=
</p>
<el-select filterable value="是否命中" disabled style="width: 255px;">
</el-select>
</div>
<div class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="outAdd(0)"></el-button>
<el-button icon="el-icon-close" circle disabled='disabled' style="margin-right: 10px"></el-button>
</div>
<div style="display: flex;align-items: center;">
<el-select v-model="scoreFieldEn" filterable placeholder="请选择" style="width: 200px;">
<el-option v-for="item in FieldUser" :key="item.id" :label="item.fieldCn" :value="item.fieldEn">
</el-option>
</el-select>
<p style="margin: 10px;">=</p>
<div>
<el-input v-model="SpecialField.score" maxlength="30" style="width: 255px;">
<template slot="prepend">得分</template>
</el-input>
</div>
</div>
</div>
</RuleDown>
</div>
</div>
</template>
<script>
import mangeRedactMixin from '@/utils/contminxin/MangeRedactMixin.js'
import '@/assets/css/ManageRedact.css'
import RuleDown from '@/components/common/rule/ruleRule.vue'
export default {
mixins: [mangeRedactMixin],
components: {
RuleDown
},
props: {
fieldTypeId: {
type: Number,
default: 0,
},
setsave: {
type: Function,
default: () => {}
},
id: {
type: Number,
default: 0
},
type: {
type: Number,
default: 1
},
getInfo: {
type: Function,
default: () => {}
},
updata: {
type: Function,
default: () => {}
},
nameId: {
type: Number,
default: 0
}
},
data() {
return {
scoreFieldEn: '',
resultFieldEn: '',
loading: false,
priority: '',
code: '',
name: '',
description: '',
ruledata: null,
"outcontent": [],
SpecialField: {
score: '1',
ruleAudit: 5,
lastLogical: '-1'
},
tempisEmpty: false,
parentId: '',
}
},
created() {
this.$store.dispatch('getfielduser')
if (this.id != 0) {
this.loading = true
this.getInfo(this.id).then(res => {
this.scoreFieldEn = res.data.scoreFieldEn
this.resultFieldEn = res.data.resultFieldEn
this.code = res.data.code
this.name = res.data.name
this.priority = res.data.priority
this.description = res.data.description
this.parentId = res.data.parentId
this.ruledata = res.data.ruleFieldList ? res.data.ruleFieldList : [{
"logical": "",
"fieldId": "",
"operator": "",
"fieldValue": ""
}],
this.outcontent = res.data.tacticsOutputList
this.outcontent.forEach(value => {
if (!value.variableType) {
value.variableType = 1
}
if (value.variableType == 2) {
value.fieldValue = Number(value.fieldValue.split('|')[0])
}
})
this.SpecialField.score = res.data.score
this.SpecialField.ruleAudit = res.data.ruleAudit
this.SpecialField.lastLogical = res.data.lastLogical
console.log(res.data.tacticsOutputList)
this.loading = false
})
} else {
this.ruledata = [{
"logical": "",
"fieldId": "",
"operator": "",
"fieldValue": ""
}]
}
},
computed: {
FieldUser() {
return this.$store.state.FieldUser.data.fieldList
},
},
mounted() {
},
methods: {
getType(obj) {
if (obj.conditionType == 2 && !obj.valueType) {
obj.valueType = this.mixinGetvalueType(obj.fieldId)
}
if (obj.children.length > 0) {
obj.children.forEach(value => {
this.getType(value)
})
}
},
outAdd(index) {
this.outcontent.splice(index, 0, {
"fieldId": "",
tacticsType: 'base_rule',
"fieldValue": "",
variableType: 1
})
},
outDelect(index) {
this.outcontent.splice(index, 1)
},
submit() {
let reg = /[\u4e00-\u9fa5]+/g;
if (this.code.match(reg) != null) {
this.$message.error('代码不允许出现中文');
return
}
if (this.code.trim() === '') {
this.$message.error('请填入规则代码,并检查空格');
return
}
if (this.priority === '') {
this.$message.error('请选择规则优先级');
return
}
if (this.name.trim() === '') {
this.$message.error('请填入规则名称,并检查空格');
return
}
if (this.description === '') {
this.$message.error('请填入规则描述,并检查空格');
return
}
if (this.resultFieldEn === "" || this.resultFieldEn == null) {
this.$message.error('请选择命中时输出变量');
return
}
if (this.scoreFieldEn == "" || this.scoreFieldEn == null) {
this.$message.error('请选择得分时输出变量');
return
}
if (isNaN(Number(this.SpecialField.score)) || String(this.SpecialField.score).trim() === "") {
this.$message.error('得分只能是数字');
return
}
let is = {
is: true,
msg: '',
}
this.ruledata.forEach(value => {
if (value.logical === "") {
is.is = false
is.msg = '请检查是否有连接符未选'
}
if (value.fieldId === "") {
is.is = false
is.msg = '请检查是否有条件未选'
}
if (value.operator === "") {
is.is = false
is.msg = '请检查是否有运算符未选'
}
if (String(value.fieldValue).trim() === "") {
is.is = false
is.msg = '请检查是否有条件对比值未填'
}
})
if (this.SpecialField.score === "" || this.SpecialField.ruleAudit === "") {
is.is = false
is.msg = '请检查是否得分未填'
}
let str = ""
this.ruledata.forEach(value => {
str += value.logical
})
str += this.SpecialField.lastLogical
console.log(str)
if (!this.is_leagl_brackets(str)) {
this.$message.error('请检查括号完整性');
return
}
this.outcontent.forEach(value => {
if (value.fieldId === "" || String(value.fieldValue).trim() === "" || value.variableType === "") {
is.is = false
is.msg = '请检查自定义输出部分是否有未填项'
}
if (value.variableType == 3 && (String(value.fieldValue).trim() === "" || JSON.parse(value.fieldValue).formula.trim() ===
'')) {
is.is = false
is.msg = '请检查自定义输出部分是否有未填项'
}
})
if (is.is === false) {
this.$message.error(is.msg);
return
}
this.outcontent.forEach(value => {
value.fieldEn = this.mixinGetvalueEn(value.fieldId)
if (value.variableType == 2) {
value.fieldValue = value.fieldValue + '|' + this.mixinGetvalueEn(value.fieldValue)
}
})
let obj = {
"code": this.code.trim(),
"name": this.name.trim(),
"priority": this.priority,
"description": String(this.description).trim(),
score: this.SpecialField.score,
ruleAudit: this.SpecialField.ruleAudit,
scoreFieldEn: this.scoreFieldEn,
resultFieldEn: this.resultFieldEn
}
let arr = this.ruledata.map(value => {
value.valueType = this.getvalueType(value.fieldId)
console.log(value)
return value
})
obj.difficulty = 1
obj.ruleFieldList = arr
obj.tacticsOutputList = this.outcontent.length > 0 ? this.outcontent : null
obj.lastLogical = this.SpecialField.lastLogical
if (this.id == 0) {
this.loading = true
obj.parentId = this.nameId == 99999999 ? 0 : this.nameId,
this.setsave(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '添加成功',
type: 'success'
});
this.$emit('Ok')
this.$store.dispatch('reGetRuleList')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
} else {
obj.id = this.id
obj.parentId = this.parentId
this.loading = true
this.updata(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '修改成功',
type: 'success'
});
this.$emit('Ok')
this.$store.dispatch('reGetRuleList')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
}
},
change(index) {
this.ruledata[index].operator = ""
this.ruledata[index].fieldValue = ""
},
faadd(index) { //rule父节点添加
this.ruledata.splice(index + 1, 0, {
"logical": "",
"fieldId": "",
"operator": "",
"fieldValue": ""
})
},
fadelect(index) {
this.ruledata.splice(index, 1)
},
is_leagl_brackets(string) {
console.log(1)
var array = [];
for (var i = 0; i < string.length; i++) {
var item = string[i];
if (item === "(") {
array.push("(");
} else if (item === ")") {
if (array.length === 0) {
return false;
} else {
array.pop();
}
} else {
continue;
}
};
return array.length === 0;
},
getvalueType(cont) {
let num
this.FieldUser.forEach(value => {
if (value.id === parseInt(cont)) {
num = value.valueType
}
})
return num
},
getvalueEn(cont) {
let num
this.FieldUser.forEach(value => {
if (value.id === parseInt(cont)) {
num = value.fieldEn
console.log(1)
}
})
return num
}
},
watch: {
}
}
</script>

View File

@@ -1,332 +0,0 @@
<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>
<div class="cont_new_file">
<div v-if="!newf" @click="newFile"><i class="el-icon-folder-add" @click="newFile" style="margin-right: 10px;"></i>新建文件夹</div>
<div v-else style="padding: 5px;box-sizing:border-box;">
<div style="display: flex;align-items: center;">
<i class="el-icon-folder-add" @click="newFile" style="margin-right: 10px;"></i>
<el-input v-model="tempNewF" placeholder="请输入新文件夹名字,最长20个字符" size="small"></el-input>
</div>
<el-button style="margin-left: 60px;margin-top: 10px;" type="danger" icon="el-icon-close" circle size="mini"
@click="newf=false;tempNewF=''"></el-button>
<el-button type="success" icon="el-icon-check" circle size="mini" @click="newFileSure"></el-button>
</div>
</div>
<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)" :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 style="display: flex;">
<el-input placeholder="请输入搜索内容" v-model="search">
<i slot="suffix" class="el-input__icon el-icon-search" @click="getsearch"></i>
</el-input>
<el-button style="margin-left: 10px;" @click="upShow=true" v-if="getData.type==1">批量导入</el-button>
</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 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-else style="height: 100%;overflow: hidden;">
<easyDataManageRedact @close="listRedact=false;tempRedactId=0" @Ok="listRedact=false;tempRedactId=0;getlist()"
:updata="getData.updatafield" :id='tempRedactId' :nameId="currid" :setsave="getData.setsave" :getInfo="getData.getInfo"
:type="getData.type" v-if="getData.type==1">
</easyDataManageRedact>
<dataManageRedact @close="listRedact=false;tempRedactId=0" @Ok="listRedact=false;tempRedactId=0;getlist()" :getData="getData"
:id='tempRedactId' :nameId="currid" :type="getData.type" v-if="getData.type==2">
</dataManageRedact>
</div>
</div>
<el-dialog title="上传文件" :visible.sync="upShow" width="30%" :before-close="upShowClose">
<div style="margin: 0 auto;display: flex;justify-content: center;">
<el-upload class="upload-demo" ref="upload" action="doUpload" :limit="1" :file-list="fileList" :before-upload="beforeUpload"
v-loading="Uploadloading">
<el-button slot="trigger" size="small" type="primary">选取文件</el-button>
<div slot="tip" class="el-upload__tip">只能上传excel文件且不超过5MB</div>
<div slot="tip" class="el-upload-list__item-name">{{fileName}}</div>
</el-upload>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="upShow = false">取消</el-button>
<el-button type="primary" @click="submitUpload();" :disabled="fileName?false:'disabled'">确定</el-button>
</span>
</el-dialog>
<el-dialog title="导入结果" :visible.sync="upCallbackShow" width="60%" close-on-click-modal close-on-press-escape
show-close>
<p style="font-size: 18px;font-weight: bold;">
导入成功{{callbackresult.sucRows}},失败{{callbackresult.failRows}},重复{{callbackresult.repeatRows}},已存在{{callbackresult.existRows}}
</p>
<div style="">
<div style="width:98%;border-bottom: 1px dashed #ddd;padding: 1%;">
<p style="font-weight: bold;font-size: 16px;">文件夹不存在({{callbackresult.result.folderNotExistList.length}})</p>
<p v-for="value in callbackresult.result.folderNotExistList" style="margin-top: 10px;">{{value}}</p>
</div>
<div style="width:98%;border-bottom: 1px dashed #ddd;padding: 1%;">
<p style="font-weight: bold;font-size: 16px;">系统中已存在的代码({{callbackresult.result.existCodeList.length}})</p>
<p v-for="value in callbackresult.result.existCodeList" style="margin-top: 10px;">
{{value}}
</p>
</div>
<div style="width:98%;border-bottom: 1px dashed #ddd;padding: 1%;">
<p style="font-weight: bold;font-size: 16px;">系统中已存在的名称({{callbackresult.result.existNameList.length}})</p>
<p v-for="value in callbackresult.result.existNameList" style="margin-top: 10px;">{{value}}</p>
</div>
<div style="width:98%;border-bottom: 1px dashed #ddd;padding: 1%;">
<p style="font-weight: bold;font-size: 16px;">表格中重复的代码({{callbackresult.result.rpCodeList.length}})</p>
<p v-for="value in callbackresult.result.rpCodeList" style="margin-top: 10px;">{{value}}</p>
</div>
<div style="width:98%;border-bottom: 1px dashed #ddd;padding: 1%;">
<p style="font-weight: bold;font-size: 16px;">表格中重复的名称({{callbackresult.result.rpNameList.length}})</p>
<p v-for="value in callbackresult.result.rpNameList" style="margin-top: 10px;">{{value}}</p>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="upCallbackShow = false">取消</el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import '@/assets/css/cont.css'
import dataManageRedact from '@/components/common/rule/ruleManageRedact.vue'
import easyDataManageRedact from '@/components/common/rule/easyRuleManageRedact.vue'
import fileHome from '@/components/common/fileHome.vue'
import contmixin from '@/utils/contminxin/contmixin.js'
export default {
mixins: [
contmixin
],
components: {
easyDataManageRedact,
// file,
dataManageRedact,
fileHome
},
created() {
this.getData.getTree({
parentId: 0,
treeType:this.getData.treeType,
type: 1
}).then(res => {
this.list = this.listTreeDeep(res.data, 1)
this.clickCurrid(99999999)
})
this.$store.dispatch('getfielduser')
},
props: {
title: {
type: String,
default: ''
},
getData: {
type: Object,
default: null
}
},
watch: {
list() {
if (this.list.length > 0) {
this.leftloading = false
}
}
},
data() {
return {
list: [],
callbackresult: {
sucRows: '',
failRows: '',
repeatRows: '',
existRows: '',
result: {
existCodeList: [],
existNameList: [],
folderNotExistList: [],
rpCodeList: [],
rpNameList: []
}
},
upCallbackShow: false,
Uploadloading: false,
tempMove: '',
leftloading: false, //暂时关闭loading
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 = {
key: "ruleName",
status: "0,1",
"parentIds": String(this.currid) === "99999999" ? '' : String(this.currid),
"pageNum": 1,
isSearch: 1,
ruleInfo: {
name: this.search,
}
}
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",
ruleInfo: {},
"pageNum": 1
}
if (String(this.currid) !== "99999999") {
params.ruleInfo.parentId = 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",
ruleInfo: {},
"pageNum": e
}
if (String(this.currid) !== "99999999") {
params.ruleInfo.parentId = this.currid
}
this.getData.getlist(params).then(res => {
if (res.status == "1") {
this.data = res
this.contloading = false
this.selection = []
}
})
},
newFileSure() {
this.leftloading = true
let params = {
parentId: String(this.currid),
name: this.tempNewF,
"treeType": this.getData.treeType,
"type": "1",
"engineId": ""
}
// if (this.getData.type == 2) {
// params.treeType = '5'
// }
this.mixnewFileSure(params)
},
}
}
</script>

View File

@@ -1,824 +0,0 @@
<style>
.rule_com {
/* height: 51vh; */
flex: 1;
overflow: scroll;
/* overflow-x: hidden; */
margin: 0px 0px 0px 10px;
padding-bottom: 100px;
}
.rule_com::-webkit-scrollbar {
/* display: none; */
/* Chrome Safari */
}
.Rule_version_buttom {
/* width: 100px; */
margin-left: 20px !important;
}
.rule_outcontent_box {
border: 1px dotted #00000022;
margin-top: 20px;
padding:10px 0 10px 10px;
}
</style>
<template>
<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>
<div :class="smallHeader?'MR_scope MR_scopeSmall':'MR_scope'">
<div>
<p>规则描述: </p>
<el-input placeholder="请输入规则描述" maxlength="300" v-model="description" clearable
:disabled="addVersionStatus"></el-input>
</div>
</div>
<version style="margin:5px;" :id="id" :ruleVersionList="ruleVersionList" :version="version"
:addVersionStatus="addVersionStatus" :addVersionDialog="addVersionDialog"
:addVersionLoading="addVersionLoading" @addVersion="addVersion" @addVersionClose="addVersionClose"
@copyVersion="copyVersion" @delectVersion="delectVersion" @updateVersion="updateVersion"
@addVersionSure="addVersionSure" @Dialog="addVersionDialog=$event" @addVersionExamine="addVersionExamine"
@versionChange="versionChange" @StatusChange="addVersionStatus=$event" :exportVersion="true" @exportVersion="exportVersion" @importNewVersion="importNewVersion">
</version>
<div class="rule_com">
<rule :data="ruledata" :ZIndex="1"></rule>
<div class="rule_outcontent_box">
<p>命中输出</p>
<div class="rule_home" style="margin-top: 10px;">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="outAdd(0)" disabled></el-button>
<el-button icon="el-icon-close" circle disabled='disabled' style="margin-right: 10px">
</el-button>
</div>
<el-select v-model="resultFieldEn" filterable placeholder="请选择" style="width: 200px;" clearable>
<el-option v-for="item in FieldUser" :key="item.id" :label="item.fieldCn" :value="item.fieldEn">
</el-option>
</el-select>
<p style="margin: 10px;">
=
</p>
<el-select filterable value="是否命中" disabled style="width: 255px;">
</el-select>
</div>
<outcontent :outcontent="outcontent" :ruleOut="true" type="complex_rule" :outType="outTypeSuccess">
<div style="display: flex;align-items: center;">
<el-select v-model="scoreFieldEn" filterable placeholder="请选择" style="width: 200px;" clearable>
<el-option v-for="item in FieldUser" :key="item.id" :label="item.fieldCn"
:value="item.fieldEn">
</el-option>
</el-select>
<p style="margin: 10px;">=</p>
<div>
<el-input v-model="SpecialField.score" maxlength="30" style="width: 255px;">
<template slot="prepend">得分</template>
</el-input>
</div>
</div>
</outcontent>
</div>
<br>
<div class="rule_outcontent_box">
<p>未命中输出:</p>
<outcontent :outcontent="failOutputList" :unone="true" :ruleOut="true" type="complex_rule"
:outType="outTypeFail">
</outcontent>
<div>
</div>
</div>
</div>
</div>
</template>
<script>
import mangeRedactMixin from '@/utils/contminxin/MangeRedactMixin.js'
import '@/assets/css/ManageRedact.css'
import version from '@/components/common/Version.vue'
import outcontent from '@/components/models/outcontent.vue'
import rule from '@/components/models/RuleCont.vue'
export default {
mixins: [mangeRedactMixin],
components: {
rule,
outcontent,
version
},
props: {
fieldTypeId: {
type: Number,
default: 0,
},
id: {
type: Number,
default: 0
},
type: {
type: Number,
default: 1
},
nameId: {
type: Number,
default: 0
},
getData: {
type: Object,
default () {
return {}
}
}
},
data() {
return {
tempVersion: {
versionCode: '',
description: ''
},
addVersionLoading: false,
addVersionDialog: false,
version: {},
addVersionStatus: false,
ruleVersionList: [],
scoreFieldEn: '',
resultFieldEn: '',
loading: false,
valueScope: '',
priority: 0,
code: '',
name: '',
description: '',
ruledata: null,
outcontent: [],
failOutputList: [],
SpecialField: {
score: '1',
ruleAudit: 5
},
tempisEmpty: false,
parentId: '',
outTypeSuccess: {
outType: 'success'
},
outTypeFail: {
outType: 'fail'
},
}
},
created() {
this.$store.dispatch('getfielduser')
if (this.id != 0) {
this.loading = true
this.getData.getVersion(this.id).then(res => {
this.parentId = res.data.parentId
this.ruleVersionList = res.data.ruleVersionList
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.code = res.data.code
this.name = res.data.name
this.priority = res.data.priority
this.description = res.data.description
this.getRuleCont()
})
} else {
this.ruledata = {
"logical": "&&",
"fieldId": null,
"operator": null,
"fieldValue": null,
"conditionType": 1,
"children": [],
loopGroupActions: []
}
}
},
computed: {
FieldUser() {
if(this.$store.state.FieldUser){
console.log(this.$store.state.FieldUser.data.fieldList)
return this.$store.state.FieldUser.data.fieldList
}else{
return []
}
}
},
mounted() {
},
methods: {
importNewVersion(e){
this.addVersionLoading = true
console.log(e)
this.tempisEmpty = false
this.deepverify(e.data.ruleConditionVo)
if (this.tempisEmpty) {
this.addVersionLoading = false
return true
}
// return
let obj = {
versionCode: e.name.versionCode,
description: e.name.description,
ruleId: this.id,
score: e.data.score,
// ruleAudit: this.SpecialField.ruleAudit,
scoreFieldEn: e.data.scoreFieldEn,
resultFieldEn: e.data.resultFieldEn,
ruleConditionVo: e.data.ruleConditionVo,
tacticsOutputList: e.data.tacticsOutputList,
failOutputList: e.data.failOutputList
}
this.getData.addVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '添加版本成功',
type: 'success'
});
this.ruleVersionList = res.data
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.addVersionDialog = false
this.addVersionStatus = false
this.getRuleCont()
this.$store.dispatch('reGetRuleList')
}
this.addVersionLoading = false
})
},
async exportVersion(){
const res = await this.getData.getInfo({
id: this.version.id
})
if(res.status!='1'){
return
}
this.mixinSaveJSON(res.data,`${this.name}_${res.data.description}.json`)
},
addVersionExamine() {
if (this.verification()) {
return
}
this.addVersionDialog = true
},
addVersionSure(tempVersion) {
this.addVersionLoading = true
let tempRuleData = JSON.parse(JSON.stringify(this.ruledata))
this.deepTypetransition(tempRuleData)
let obj = {
versionCode: tempVersion.versionCode,
description: tempVersion.description,
ruleId: this.id,
score: this.SpecialField.score,
ruleAudit: this.SpecialField.ruleAudit,
scoreFieldEn: this.scoreFieldEn,
resultFieldEn: this.resultFieldEn,
ruleConditionVo: tempRuleData,
tacticsOutputList: this.outcontent,
failOutputList: this.failOutputList
}
this.getData.addVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '添加版本成功',
type: 'success'
});
this.ruleVersionList = res.data
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.addVersionDialog = false
this.addVersionStatus = false
this.getRuleCont()
this.$store.dispatch('reGetRuleList')
}
this.addVersionLoading = false
})
},
updateVersion(tempVersion) {
this.addVersionLoading = true
let tempRuleData = JSON.parse(JSON.stringify(this.ruledata))
this.deepTypetransition(tempRuleData)
let obj = {
ruleId: this.id,
id: this.version.id,
versionCode: tempVersion.versionCode,
description: tempVersion.description,
ruleId: this.id,
score: this.SpecialField.score,
ruleAudit: this.SpecialField.ruleAudit,
scoreFieldEn: this.scoreFieldEn,
resultFieldEn: this.resultFieldEn,
ruleConditionVo: tempRuleData,
tacticsOutputList: this.outcontent,
failOutputList: this.failOutputList
}
this.getData.updateVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '版本重命名成功',
type: 'success'
});
this.ruleVersionList = res.data
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.addVersionDialog = false
this.addVersionStatus = false
this.getRuleCont()
this.$store.dispatch('reGetRuleList')
}
this.addVersionLoading = false
})
},
copyVersion(tempVersion) {
this.addVersionLoading = true
let obj = {
ruleId: this.id,
id: this.version.id,
versionCode: tempVersion.versionCode,
description: tempVersion.description
}
this.getData.copyVersion(obj).then(res => {
if (res.status == '1') {
this.$message({
message: '复制版本成功',
type: 'success'
});
this.ruleVersionList = res.data
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.addVersionDialog = false
this.addVersionStatus = false
this.getRuleCont()
this.$store.dispatch('reGetRuleList')
}
this.addVersionLoading = false
})
},
getRuleCont() {
this.loading = true
this.getData.getInfo({
id: this.version.id
}).then(res => {
if (res.status == "1") {
this.scoreFieldEn = res.data.scoreFieldEn
this.resultFieldEn = res.data.resultFieldEn
this.getType(res.data.ruleConditionVo)
this.ruledata = res.data.ruleConditionVo ? res.data.ruleConditionVo : {
"logical": "&&",
"fieldId": null,
"operator": null,
"fieldValue": null,
"conditionType": 1,
"children": [],
}
this.outcontent = res.data.tacticsOutputList
this.failOutputList = res.data.failOutputList
this.outcontent.forEach(value => {
if (!value.variableType) {
value.variableType = 1
}
})
this.redeepverify(this.ruledata)
this.SpecialField.score = res.data.score
this.SpecialField.ruleAudit = res.data.ruleAudit
}
this.loading = false
})
},
versionChange() {
this.ruleVersionList.forEach(value => {
if (value.id === this.version.id) {
this.version = JSON.parse(JSON.stringify(value))
this.getRuleCont()
}
})
},
addVersion() {
this.addVersionStatus = true
this.tempadd = {
scoreFieldEn: this.scoreFieldEn,
resultFieldEn: this.resultFieldEn,
ruledata: this.ruledata,
outcontent: this.outcontent,
failOutputList: this.failOutputList,
score: this.SpecialField.score,
}
this.reset()
},
sureAddVersion() {
if (this.verification()) {
return
}
this.addVersionDialog = true
},
verification() {
let reg = /[\u4e00-\u9fa5]+/g;
if (this.code.match(reg) != null) {
this.$message.error('代码不允许出现中文');
return true
}
if(this.verificationNameCode(this.code)||this.verificationNameCode(this.name)){
return true
}
if (this.code.trim() === '') {
this.$message.error('请填入规则代码,并检查空格');
return true
}
if (this.priority === '') {
this.$message.error('请选择规则优先级');
return true
}
if (this.name.trim() === '') {
this.$message.error('请填入规则名称,并检查空格');
return true
}
if (this.description === '') {
this.$message.error('请填入规则描述,并检查空格');
return true
}
// if (this.resultFieldEn === "") {
// this.$message.error('请选择命中时输出变量');
// return true
// }
// if (this.scoreFieldEn == "") {
// this.$message.error('请选择得分时输出变量');
// return true
// }
if (isNaN(Number(this.SpecialField.score)) || String(this.SpecialField.score).trim() === "") {
this.$message.error('得分只能是数字');
return true
}
let is = true
this.tempisEmpty = false
this.deepverify(this.ruledata)
if (this.tempisEmpty) {
return true
}
this.outcontent.forEach(value => {
if (value.fieldId === "" || String(value.fieldValue).trim() === "" || value.variableType ===
"") {
is = false
}
if (value.variableType == 3 && (String(value.fieldValue).trim() === "" || JSON.parse(value
.fieldValue).formula.trim() ===
'')) {
is = false
}
})
this.failOutputList.forEach(value => {
if (value.fieldId === "" || String(value.fieldValue).trim() === "" || value.variableType ===
"") {
is = false
}
if (value.variableType == 3 && (String(value.fieldValue).trim() === "" || JSON.parse(value
.fieldValue).formula.trim() ===
'')) {
is = false
}
})
if (is === false) {
this.$message.error('请检查自定义输出部分是否有未填项');
return true
}
},
addVersionClose() {
this.addVersionStatus = false
this.SpecialField.score = this.tempadd.score
this.scoreFieldEn = this.tempadd.scoreFieldEn
this.resultFieldEn = this.tempadd.resultFieldEn
this.ruledata = this.tempadd.ruledata
this.outcontent = this.tempadd.outcontent
this.failOutputList = this.tempadd.failOutputList
},
reset() {
this.ruledata = {
"logical": "&&",
"fieldId": null,
"operator": null,
"fieldValue": null,
"conditionType": 1,
"children": [],
loopGroupActions: []
}
this.SpecialField.score = 1
this.outcontent = []
this.failOutputList = []
this.scoreFieldEn = ""
this.resultFieldEn = ""
},
delectVersion() {
this.getData.delectVersion({
status: -1,
ids: [this.version.id],
tacticsId: this.id
}).then(res => {
if (res.status == "1") {
this.$message({
message: '删除成功',
type: 'success'
});
this.ruleVersionList = res.data
this.version = JSON.parse(JSON.stringify(this.ruleVersionList[0]))
this.getRuleCont()
}
})
},
getType(obj) {
if (obj.conditionType == 2 && !obj.valueType) {
obj.valueType = this.mixinGetvalueType(obj.fieldId)
}
if (obj.children.length > 0) {
obj.children.forEach(value => {
this.getType(value)
})
}
},
outAdd(index) {
this.outcontent.splice(index, 0, {
"fieldId": "",
tacticsType: 'base_rule',
"fieldValue": "",
variableType: 1
})
},
submit() {
this.loading = true
if (this.verification()) {
this.loading = false
return
}
let tempRuleData = JSON.parse(JSON.stringify(this.ruledata))
this.deepTypetransition(tempRuleData)
this.outcontent.forEach(value => {
value.fieldEn = this.mixinGetvalueEn(value.fieldId)
})
this.failOutputList.forEach(value => {
value.fieldEn = this.mixinGetvalueEn(value.fieldId)
})
let obj = {
"code": this.code.trim(),
"name": this.name.trim(),
"priority": this.priority,
"description": String(this.description).trim(),
difficulty: 2,
ruleAudit: this.SpecialField.ruleAudit,
ruleVersionList: [{
score: this.SpecialField.score,
scoreFieldEn: this.scoreFieldEn,
resultFieldEn: this.resultFieldEn,
ruleConditionVo: tempRuleData,
tacticsOutputList: this.outcontent,
failOutputList: this.failOutputList
}],
}
if (this.id == 0) {
obj.ruleVersionList[0].versionCode = 'V:0'
obj.ruleVersionList[0].description = '初始版本'
obj.parentId = this.nameId == 99999999 ? 0 : this.nameId,
this.getData.setsave(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '添加成功',
type: 'success'
});
this.$emit('Ok')
this.$store.dispatch('reGetRuleList')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
} else {
obj.id = this.id
obj.parentId = this.parentId
obj.ruleVersionList[0].id = this.version.id
this.getData.updatafield(obj).then(res => {
this.loading = false
if (res.status === "1") {
this.$message({
message: '修改成功',
type: 'success'
});
// this.$emit('Ok')
this.$store.dispatch('reGetRuleList')
}
}).catch(err => {
this.loading = false
this.$message.error('网络出现问题-_-');
})
}
console.log(obj)
},
change(index) {
this.ruledata[index].operator = ""
this.ruledata[index].fieldValue = ""
},
redeepverify(obj) {
if (obj.fieldEn) {
if ((obj.fieldEn.indexOf('.') != -1 && obj.fieldEn[0] == '%') || obj.conditionType == 3||obj.conditionType===2) {
obj.fieldEn = obj.fieldEn.split('.')
}
}
if (obj.children.length > 0) {
obj.children.forEach(value => {
this.redeepverify(value)
})
}
if (obj.loopGroupActions.length > 0) {
obj.loopGroupActions.forEach(value => {
if (value.actionValue.indexOf('.') != -1) {
value.actionValue = value.actionValue.split('.')
}
})
}
},
deepverify(obj) {
if (this.tempisEmpty) {
return
}
if (obj.conditionType == 0) {
if (obj.fieldId && obj.fieldValue && obj.operator) {} else {
this.tempisEmpty = true
return
}
}
if (obj.children.length === 0 && obj.conditionType != 2) {
this.tempisEmpty = true
this.$message.error('非规则节点后不允许为空');
return
}
if (obj.conditionType == 5) { //如果是条件组
if (obj.children.length === 0 && obj.conditionType != 5) {
this.tempisEmpty = true
this.$message.error('条件组后不允许为空');
return
}
obj.condGroupResultCondition.children[0].fieldValue = obj.condGroupResultCondition.children[0]
.fieldValue.trim()
obj.condGroupResultCondition.children[1].fieldValue = obj.condGroupResultCondition.children[1]
.fieldValue.trim()
if (obj.condGroupResultCondition.children[0].fieldValue.trim() === "" || obj.condGroupResultCondition
.children[1].fieldValue
.trim() ===
"" || isNaN(Number(obj.condGroupResultCondition.children[0].fieldValue)) || isNaN(Number(obj
.condGroupResultCondition
.children[1].fieldValue))) {
if (obj.condGroupResultCondition.children[0].fieldValue !== 0 && obj.condGroupResultCondition
.children[1].fieldValue !==
0) {
this.tempisEmpty = true
this.$message.error('条件组命中条件只能为数字且不为空与空格');
return
}
}
if (obj.condGroupResultCondition.children[0].fieldValue < 0) {
this.tempisEmpty = true
this.$message.error('条件组命中左边不能小于0');
return
}
if (obj.condGroupResultCondition.children[1].fieldValue > obj.children.length) {
this.tempisEmpty = true
this.$message.error('条件组命中右边不能大于条件总个数');
return
}
if (Number(obj.condGroupResultCondition.children[0].fieldValue) > Number(obj.condGroupResultCondition
.children[1].fieldValue)) {
this.tempisEmpty = true
this.$message.error('条件组命中左边不能大于右边');
return
}
}
if (obj.conditionType == 3 && !obj.fieldEn) { //如果是for节点 且没有选择 被遍历的指标
this.tempisEmpty = true
this.$message.error('for后需要确定循环的数组');
return
}
if (obj.conditionType == 2) {
obj.fieldValue = obj.fieldValue.trim()
if (!obj.fieldEn || !obj.operator || !obj.fieldValue) {
if (obj.fieldValue !== 0) {
this.tempisEmpty = true
this.$message.error('规则节点不允许有空值');
return
}
}
}
if (obj.conditionType == 3 && obj.loopResultCondition.children.length === 0) { //如果是for节点 且没有子节点
this.tempisEmpty = true
this.$message.error('for的输出节点后不允许为空');
return
}
if (obj.conditionType == 3 && obj.loopResultCondition.children.length != 0) { //如果是for节点 且 有输出节点
obj.loopResultCondition.children.forEach(value => {
this.deepverify(value)
})
}
if (obj.children.length > 0) { //如果有子节点
obj.children.forEach(value => {
this.deepverify(value)
})
}
if (obj.loopGroupActions.length > 0) { //如果有输出节点
console.log(obj)
let is = false
obj.loopGroupActions.forEach(value => {
if (!value.actionKey || !value.actionType || !value.actionValue) {
if (value.actionValue === 0 && value.actionType != 1) {
this.tempisEmpty = true
is = true
}
}
})
if (is) {
this.$message.error('输出变量不允许有空值');
return
}
}
},
deepTypetransition(obj) {
if (Array.isArray(obj.fieldEn)) {
obj.fieldEn = obj.fieldEn.join('.')
}
if (obj.children.length > 0) {
obj.children.forEach(value => {
this.deepTypetransition(value)
})
}
if (obj.loopGroupActions.length > 0) {
obj.loopGroupActions.forEach(value => {
if (Array.isArray(value.actionValue)) {
value.actionValue = value.actionValue.join('.')
}
})
}
}
},
watch: {
}
}
</script>

View File

@@ -1,478 +0,0 @@
<style>
.rule_home {
display: flex;
}
.rule_fa {
display: flex;
width: 20%;
height: 30%;
margin: 10px 10px 0 0;
flex-shrink: 0;
}
.rule_son {
display: flex;
margin-top: 10px;
justify-content: flex-start;
}
.rule_dialg_header{
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 40px;
}
.rule_dialg_cont{
display: flex;
flex-wrap: wrap;
justify-content: flex-start;
height: 40vh;
overflow: scroll;
overflow-x: hidden;
align-items: flex-start;
align-content: flex-start;
}
.rule_dialg_cont>div{
width: 30%;
overflow: hidden;
margin-top: 10px;
margin-right: 10px;
background-color: #fff;
}
.rule_dialg_cont>div:hover{
overflow: unset;
}
</style>
<template>
<div style="margin-left: 20px;margin-top: 20px;">
<div v-if="Data&&FieldUser">
<div v-if="type==1">
条件
<div v-for="(item,index) in Data" class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="$emit('faadd',index)"></el-button>
<el-button icon="el-icon-close" circle @click="$emit('fadelect',index)" :disabled="index===0?'disabled':false"
style="margin-right: 10px;"></el-button>
</div>
<div style="display: flex;">
<el-select v-show="index===0" v-model="item.logical" placeholder="请选择" style="width: 200px;margin-right: 10px;">
<el-option label="(" value="("></el-option>
<el-option label="((" value="(("></el-option>
<el-option label="(((" value="((("></el-option>
<el-option label="空置" value="-1"></el-option>
</el-select>
<el-select v-show="index!=0" v-model="item.logical" placeholder="请选择" style="width: 200px;margin-right: 10px;">
<el-option v-for="cont in logical" :key="cont.id" :label="cont.label" :value="cont.value">
</el-option>
</el-select>
<el-select :value="getCn(item.fieldId,2)" placeholder="请选择" style="width: 200px;" @change="$emit('change',index)"
@focus="dataClick(index,item.fieldId)">
</el-select>
<ruleRelation v-model="item.operator" :value2.sync="item.fieldValue" :valueType="getvalueType(item.fieldId)"></ruleRelation>
<!-- <el-input v-model="item.fieldValue" maxlength="30" placeholder="请输入内容,最长30位" style="width: 300px;margin-left: 10px;"
v-show="getvalueType(item.fieldId)!==3">
</el-input>
<el-select v-model="item.fieldValue" placeholder="请选择" style="width: 300px;margin-left: 10px;" v-show="getvalueType(item.fieldId)===3">
<el-option label="是" value="1"></el-option>
<el-option label="否" value="0"></el-option>
</el-select> -->
</div>
</div>
<div class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle disabled='disabled'></el-button>
<el-button icon="el-icon-close" circle disabled='disabled' style="margin-right: 10px"></el-button>
</div>
<el-select v-model="SpecialField.lastLogical" placeholder="请选择" style="width: 200px;">
<el-option label=")" value=")"></el-option>
<el-option label="))" value="))"></el-option>
<el-option label=")))" value=")))"></el-option>
<el-option label="空置" value="-1"></el-option>
</el-select>
</div>
</div>
输出
<slot></slot>
<!-- <div class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle disabled='disabled'></el-button>
<el-button icon="el-icon-close" circle disabled='disabled' style="margin-right: 10px"></el-button>
</div>
<div style="display: flex;align-items: center;">
<el-input value="命中动作:" maxlength="30" style="width: 200px;margin-right: 10px;" disabled></el-input>
<p style="margin-right: 10px;">=</p>
<el-select v-model="SpecialField.ruleAudit" placeholder="请选择" style="width: 200px;">
<el-option label="终止决策流" :value="2"></el-option>
<el-option label="继续决策流" :value="5"></el-option>
</el-select>
</div>
</div> -->
<div v-for="(value,index) in outcontent" class="rule_home">
<div class="rule_fa">
<el-button icon="el-icon-plus" circle @click="$emit('outAdd',index+1)"></el-button>
<el-button icon="el-icon-close" circle @click="$emit('outDelect',index)" style="margin-right: 10px"></el-button>
</div>
<div style="display: flex;align-items: center;">
<el-select :value="getCn(value.fieldId)" placeholder="请选择" style="width: 200px;margin-right: 10px;" @focus="outClick(index)">
</el-select>
<p style="margin-right: 10px;">=</p>
<div style="display: flex;">
<div style="font-size: 14px;padding-right: 5px;width: 60px;height: 40px;background-color: #d4d4d4;border-radius: 4px;line-height: 40px;color: #fff;text-align: center;">
<!-- <el-select v-model="value.variableType" placeholder="请选择" @change="value.fieldValue=''">
<el-option label="常量" value="1"></el-option>
<el-option label="变量" value="2"></el-option>
</el-select> -->
<el-dropdown trigger="click" @command="value.variableType=$event;value.fieldValue=''">
<span class="el-dropdown-link" style="color: #fff;">
{{value.variableType==1?"常量":"变量"}}<i class="el-icon-arrow-down el-icon--right"></i>
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item icon="el-icon-caret-right" :command="1">常量</el-dropdown-item>
<el-dropdown-item icon="el-icon-caret-right" :command="2">变量</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</div>
<el-input v-show="value.variableType==1" v-model="value.fieldValue" maxlength="30" style="width: 200px;margin-right:10px;margin-left: -5px;"></el-input>
<!-- {{Number(value.fieldValue.split('|')[0])}} -->
<el-select v-show="value.variableType==2" filterable v-model="value.fieldValue" placeholder="请选择" style="width: 200px;margin-right:10px;margin-left: -5px;">
<el-option v-for="item in FieldUser" :label="item.fieldCn" :value="Number(item.id)"></el-option>
</el-select>
</div>
</div>
</div>
<el-dialog title="输入参数" :visible.sync="dialogVisible" width="50%">
<div class="rule_dialg_header">
请选择参数
<div>
<el-input v-model="search" maxlength="30" placeholder="快速搜索"></el-input>
</div>
</div>
<div class="rule_dialg_cont">
<div v-for="value in fradioList">
<el-radio v-model="radio" :label="value.id" border size="mini">{{value.fieldCn}}</el-radio>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible = false;radio='';search=''"> </el-button>
<el-button type="primary" @click="dialogSure()"> </el-button>
</span>
</el-dialog>
</div>
</div>
</template>
<script>
import ruleRelation from '@/components/common/ruleRelation.vue'
export default {
components: {
ruleRelation
},
data() {
return {
search: '',
tempcur: '',
radioList: [],
radio: '',
dialogVisible: false,
logical: [{
value: '&&',
label: 'and',
}, {
value: '||',
label: 'or',
}, {
value: '(',
label: '(',
}, {
value: '((',
label: '((',
}, {
value: '(((',
label: '(((',
}, {
value: ')',
label: ')',
}, {
value: '))',
label: '))',
}, {
value: ')))',
label: ')))',
}, {
value: '&&(',
label: 'and (',
}, {
value: '&&((',
label: 'and ((',
}, {
value: '&&(((',
label: 'and (((',
}, {
value: ')&&',
label: ') and',
}, {
value: '))&&',
label: '))and',
}, {
value: ')))&&',
label: ')))and',
}, {
value: ')&&(',
label: ')and(',
}, {
value: '))&&',
label: '))and',
}, {
value: ')&&((',
label: ') and ((',
}, {
value: ')&&(((',
label: ') and (((',
}, {
value: '))&&(',
label: ')) and (',
}, {
value: '))&&((',
label: ')) and ((',
}, {
value: '))&&(((',
label: ')) and (((',
}, {
value: ')))&&(',
label: '))) and (',
}, {
value: ')))&&((',
label: '))) and ((',
}, {
value: ')))&&(((',
label: '))) and (((',
}, {
value: '||(',
label: 'or (',
}, {
value: '||((',
label: 'or ((',
}, {
value: '||(((',
label: 'or(((',
}, {
value: ')||',
label: ') or ',
}, {
value: '))||',
label: ')) or ',
}, {
value: ')))||',
label: '))) or ',
}, {
value: ')||(',
label: ' ) or (',
}, {
value: ')||((',
label: ' ) or (( ',
}, {
value: '))||(',
label: ')) or ( ',
}, {
value: '))||((',
label: ')) or (( ',
}, {
value: '))||(((',
label: ')) or (((',
}, {
value: ')))||(',
label: ' ))) or (',
}, {
value: ')))||((',
label: '))) or ((',
}, {
value: ')))||(((',
label: '))) or (((',
}, {
value: '-1',
label: '空置',
}]
}
},
created() {
console.log(this.Data)
},
computed: {
FieldUser() {
if (this.$store.state.FieldUser) {
return this.$store.state.FieldUser.data.fieldList
} else {
return []
}
},
outPutUser() {
if (this.$store.state.Output) {
return this.$store.state.Output.data.paramMap.fieldList
} else {
return []
}
},
fradioList() {
if (this.search != "") {
let arr = []
arr = this.radioList.filter(value => {
if (value.fieldCn.indexOf(this.search) != -1) {
return true
} else {
return false
}
})
return arr
} else {
return this.radioList
}
}
},
props: {
type: {
type: Number,
default: 1
},
Data: {
type: Array,
default () {
return []
}
},
SpecialField: {
type: Object,
default () {
return {}
}
},
outcontent: {
type: Array,
default () {
return []
}
}
},
methods: {
dialogSure() {
if (this.radio == '') {
this.$message.error('请选择一个字段,或者选择取消')
} else {
if (this.tempcur.split('###')[1] === "Data") {
this.Data.forEach((value, index) => {
if (index === parseInt(this.tempcur.split('###')[0])) {
console.log(value)
value.fieldId = this.radio + '|' + this.getvalueEn(this.radio)
value.operator = ""
value.fieldValue = ""
}
})
} else if (this.tempcur.split('###')[1] === "out") {
console.log(this.outcontent)
this.outcontent.forEach((value, index) => {
if (index === parseInt(this.tempcur.split('###')[0])) {
value.fieldId = this.radio
value.fieldEn = this.mixinGetvalueEn(this.radio)
value.fieldValue = ''
}
})
}
this.dialogVisible = false;
this.radio = '';
this.search = '';
}
},
getCn(id, type) {
let Cn
if (type != 2) {
this.FieldUser.forEach(value => {
if (value.id == parseInt(id)) {
Cn = value.fieldCn
return
}
})
} else {
this.FieldUser.forEach(value => {
if (value.id == parseInt(id)) {
Cn = value.fieldCn
return
}
})
}
return Cn
},
getvalueEn(cont) {
let num
console.log(cont)
this.FieldUser.forEach(value => {
if (value.id === parseInt(cont)) {
num = value.fieldEn
console.log(1)
}
})
return num
},
dataClick(index, id) {
this.tempcur = index + '###Data'
this.radioList = this.FieldUser
this.radio = Number(id.split('|')[0])
console.log(id)
this.dialogVisible = true
},
outClick(index) {
this.tempcur = index + '###out'
console.log(this.tempcur)
this.radioList = this.FieldUser
this.dialogVisible = true
},
getvalueType(cont) {
let num
this.FieldUser.forEach(value => {
if (value.id === parseInt(cont)) {
num = value.valueType
}
})
return num
}
}
}
</script>

View File

@@ -1,140 +0,0 @@
<template>
<div style="display: inline;">
<div style="display: flex;align-items: center;">
<el-select v-model="data" :size="size" :filterable="type==2?'filterable':false" placeholder="请选择"
ref="select" style="width: 100px;margin-left: 10px;" @change="change" @blur="$emit('blur')">
<el-option label="大于" value=">" v-show="[2,3,5,6].indexOf(valueType)==-1"></el-option>
<el-option label="大于等于" value=">=" v-show="[2,3,5,6].indexOf(valueType)==-1"></el-option>
<el-option label="等于" value="==" v-show="[5].indexOf(valueType)==-1"></el-option>
<el-option label="小于" value="<" v-show="[2,3,5,6].indexOf(valueType)==-1"></el-option>
<el-option label="小于等于" value="<=" v-show="[2,3,5,6].indexOf(valueType)==-1"></el-option>
<el-option label="不等于" value="!=" v-show="[5].indexOf(valueType)==-1"></el-option>
<el-option label="包含" value="contains" v-show="[2,5,6].indexOf(valueType)!=-1"></el-option>
<el-option label="不包含" value="not contains" v-show="[2,5,6].indexOf(valueType)!=-1"></el-option>
<el-option label="为空" value="is empty" v-show="[6].indexOf(valueType)!=-1"></el-option>
<el-option label="不为空" value="not empty" v-show="[6].indexOf(valueType)!=-1"></el-option>
<el-option label="正则匹配" value="regex" v-show="[2].indexOf(valueType)!=-1"></el-option>
</el-select>
<el-input :value="value2" @input="$emit('update:value2',$event)" maxlength="30" :size="size"
placeholder="请输入内容,最长30位" style="width: 100px;margin-left: 10px;"
v-if="!variableType&&openValue2&&valueType!==3&&['is empty','not empty'].indexOf(data)==-1">
</el-input>
<el-select :value="value2" @input="$emit('update:value2',$event)" placeholder="请选择" :size="size"
style="width: 100px;margin-left: 10px;" v-if="!variableType&&openValue2&&valueType===3">
<el-option label="是" value="="></el-option>
<el-option label="否" value="!="></el-option>
</el-select>
<varialeSelect v-if="variableType" :valueType="valueType"
:disabled="variableDisList" :variableType="variableType"
@update:variableType="$emit('update:variableType',$event)" :value="value2"
@input="$emit('update:value2',$event)" v-bind="$attrs" @CustomCallback="$emit('CustomCallback',$event)" style="margin-left: 10px;"></varialeSelect>
</div>
</div>
</template>
<script>
import varialeSelect from '@/components/models/varialeSelect.vue'
export default {
components: {
varialeSelect
},
props: {
openValue2: { //是否打开后半截输入框
type: Boolean,
default: true
},
value2: { //后半截输入框的Key
type: String,
default: ''
},
type: { //是否打开搜索
type: Number,
default: 1
},
openSelect: { //是否自动打开下拉选择框
type: Boolean,
default: false
},
value: { //大于小于等信息
type: String,
default: ''
},
valueType: { //数字 或者字符串 或者 JSON
type: Number,
default: 1
},
size: { //大小
type: String,
default: ''
},
variableType: { //是否打开 常量变量自定义 以及默认为哪个 0为不打开
type: Number,
default: 0
},
variableDis: { //禁用常量变量自定义
type: Array || null,
default: null
}
},
data() {
return {
data: ''
}
},
created() {
this.data = this.value
// console.log(this.$listeners)
},
methods: {
change() {
this.$emit('change')
if (['is empty', 'not empty'].indexOf(this.data) == -1) {
if (this.data == 'regex') {
this.$emit('update:value2', '')
} else {
this.$emit('update:value2', '0')
}
}
if (this.data == 'regex') { //如果选择正则匹配 则只能为变量
this.$emit('update:variableType', 1)
}
this.$emit('input', this.data)
}
},
computed: {
variableDisList() {
let arr = []
if (this.variableDis) {
arr.push(...this.variableDis)
}
if (this.data == 'regex') {
arr.push(...[2, 3])
}
arr = Array.from(new Set(arr))
return arr
}
},
watch: {
value() {
this.data = this.value
},
openSelect() {
if (this.openSelect) {
this.$nextTick(() => {
this.$refs.select.focus()
})
}
}
}
}
</script>
<style>
</style>

View File

@@ -1,572 +0,0 @@
<style>
.te_top{
width: 100%;
height: 30px;
background-color: #aaa;
display: flex;
justify-content: space-around;
user-select: none;
}
.te_top>p{
color: #eee;
font-weight: bold;
font-size: 16px;
line-height: 30px;
}
.te_top>p:hover{
color: #fff;
cursor:pointer
}
</style>
<template>
<div style="width: 100%;">
<p style="font-size:14px;margin-bottom: 5px;color: #aaa;">
@字符选择变量
</p>
<div class="te_top">
<p @click="textareaAdd('+')">+</p>
<p @click="textareaAdd('-')">-</p>
<p @click="textareaAdd('*')">*</p>
<p @click="textareaAdd('/')">/</p>
<p @click="textareaAdd('sqrt(,)')">sqrt</p>
<p @click="textareaAdd('In(,)')">In</p>
<p @click="textareaAdd('avg(,)')">avg()</p>
<p @click="textareaAdd('(,)')">()</p>
<p @click="textareaAdd('abs(,)')">abs</p>
<p @click="textareaAdd('max(,)')">max</p>
<p @click="textareaAdd('min(,)')">min</p>
<p @click="textareaAdd('lg(,)')">lg</p>
<p @click="textareaAdd('exp(,)')">exp</p>
<p @click="textareaAdd('ceil(,)')">ceil</p>
<p @click="textareaAdd('floor(,)')">floor</p>
</div>
<el-input type="textarea" rows="9" placeholder="请输入内容" v-model="formula_show" ref="textarea" @input="$emit('input',formula_show)">
</el-input>
<fieldUserTable :text="text" :fieldUser="FieldUser" refs="t" @dbc="dbclick" :show="isshow" @close="isshow=false"></fieldUserTable>
<el-dialog :title="'当前编辑'+nowCurr" :visible.sync="dialogVisible" width="30%" append-to-body>
<el-button @click="delect">删除字段</el-button>
</el-dialog>
</div>
</template>
<script>
import fieldUserTable from '@/components/common/fieldUserTable.vue'
import {
validateSection
} from '@/api/index.js'
export default {
components: {
fieldUserTable
},
props: {
data: {
type: Object,
default () {
return {}
}
},
value: {
type: String,
default: ''
}
},
data() {
return {
loading: false,
tempsection: [],
sectionVisible: false, //区间编辑弹窗
nowCurr: '',
dialogVisible: false,
isshow: false,
text: '',
tempIndex: '',
lest: '',
islest: false,
tempFormula: '',
formula_show: '',
cursorfront: '',
cursorlest: '',
lastKeyDown: '',
fields: []
}
},
mounted() {
this.$refs.textarea.$refs.textarea.onkeydown = (e) => {
if (e.key == 'a') {
if (e.ctrlKey) {
e.preventDefault()
}
}
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if (e.key == "Backspace" || e.key == "Delete") {
this.lastKeyDown = e.key
if (e.key == "Backspace" && this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart - 1,
this.$refs.textarea.$refs.textarea.selectionStart) == '@' && (this.isodd(this.formula_show, '@') == false)) {
e.preventDefault()
this.openDialog()
}
if (e.key == "Delete" && this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart, this.$refs
.textarea.$refs.textarea.selectionStart + 1) == '@') {
e.preventDefault()
this.openDialog()
}
}
if (((this.isodd(this.cursorfront, '@') == true) && (this.isodd(this.cursorlest, '@') == true)) || (this.dialogVisible ==
true)) {
e.preventDefault()
this.openDialog()
}
}
this.$refs.textarea.$refs.textarea.onclick = (e) => {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if ((this.isodd(this.cursorfront, '@') == true) && (this.isodd(this.cursorlest, '@') == true) && this.formula_show
.indexOf(
'@') != -1) {
this.openDialog()
}
}
this.$refs.textarea.$refs.textarea.onfocus = () => {
document.body.onmousemove = (e) => {
e.preventDefault()
}
}
this.$refs.textarea.$refs.textarea.onblur = () => {
document.body.onmousemove = (e) => {
}
}
},
computed: {
FieldUser() {
return this.$store.state.FieldUser
},
},
created() {
this.formula_show = this.value
console.log(this.formula_show,this.value)
},
methods: {
setCaretPosition(ctrl, pos) { //设置光标位置函数
if (ctrl.setSelectionRange) {
ctrl.focus();
this.$nextTick(()=>{
ctrl.setSelectionRange(pos, pos);
})
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
},
textareaAdd(e) {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if(e.split(',')[1]){
this.formula_show = this.cursorfront + e.split(',')[0] + e.split(',')[1] + this.cursorlest
}else{
this.formula_show = this.cursorfront + e.split(',')[0] + this.cursorlest
}
this.setCaretPosition(this.$refs.textarea.$refs.textarea,(this.cursorfront + e.split(',')[0]).length)
// console.log(e, this.formula_show)
},
sectionSure() {
this.loading = true
let isNot = false
let Z = /^(\[|\()\d*,\d*(\]|\))$/
this.tempsection.forEach(value => {
if (!Z.test(value.segment)) {
isNot = true
}
})
if (isNot) {
this.$message.error('请检查区间格式');
this.loading = false
return
}
let arr = this.tempsection.map(value => {
return value.segment
})
validateSection(arr).then(res => {
if (res.status == "1") {
if (res.data.result == "1") {
this.$message({
message: res.data.msg,
type: 'success'
});
let isNotValue = false
this.tempsection.forEach(value => {
if (value.value == "") {
isNotValue = true
}
})
if (isNotValue) {
setTimeout(() => {
this.$message.error('值不能为空');
}, 10)
this.loading = false
return
}
let ind = this.cursorfront.match(/@.*?@/g) === null ? [] : this.cursorfront.match(/@.*?@/g);
this.fields[ind.length].segments = this.deepClone(this.tempsection)
this.sectionVisible = false
this.tempsection = []
} else {
this.$message.error(res.data.msg);
}
}
this.loading = false
}).catch(err => {
this.loading = false
})
},
delectSegment(index) {
this.tempsection.splice(index, 1)
},
addSegment(index) {
this.tempsection.splice(index, 0, {
"segment": "",
"value": ''
})
},
// 打开区间编辑
openSection() {
let ind = this.cursorfront.match(/@.*?@/g) === null ? [] : this.cursorfront.match(/@.*?@/g);
this.tempsection = this.deepClone(this.fields[ind.length].segments)
// this.sectionVisible = true
},
// 获取 字符串中 有 多少个指定字符
getTempIndex(string, str) {
let temp = 0
for (let num = 0;;) {
if (string.indexOf(str, temp) != -1) {
temp = string.indexOf(str, temp)
temp++
num++
} else {
return num
}
}
// console.log(string, str)
},
getTempArreyIndex(array, str) {
let num = 0
array.forEach((value) => {
if (value.field_name == "str") {
num++
}
})
return num
},
countCurr() {
if ((this.isodd(this.cursorfront, '@') == true) && (this.isodd(this.cursorlest, '@') == true)) {
// console.log(this.cursorfront.substring(this.cursorfront.lastIndexOf('@')))
// console.log(this.cursorlest.substring(0,this.cursorlest.indexOf('@')+1))
// console.log(this.cursorfront.lastIndexOf('@'),'上半句最后一个@')
} else if (this.lastKeyDown == "Backspace") {
this.cursorfront = this.cursorfront.substring(0, this.cursorfront.length - 1)
this.cursorlest = '@' + this.cursorlest
} else if (this.lastKeyDown == "Delete") {
this.cursorfront = this.cursorfront + '@'
this.cursorlest = this.cursorlest.substr(1);
}
let str = this.cursorfront.substring(this.cursorfront.lastIndexOf('@')) + this.cursorlest.substring(0, this.cursorlest
.indexOf('@') + 1)
// console.log(this.cursorfront, str)
// console.log(this.formula_show.indexOf(str,1),'整句中str的位置1')
this.nowCurr = str + '|' + this.getTempIndex(this.cursorfront, str)
},
openDialog() {
this.countCurr()
this.dialogVisible = true
this.$refs.textarea.$refs.textarea.blur()
// 数组添加
if (this.getTempIndex(this.formula_show, this.nowCurr.split('|')[0]) > this.getTempArreyIndex(this.fields, this.nowCurr
.split('|')[0].substring(1, this.nowCurr.split('|')[0].Length - 1))) {
let ind = this.cursorfront.match(/@.*?@/g) === null ? [] : this.cursorfront.match(/@.*?@/g);
let ind2 = this.formula_show.match(/@.*?@/g) === null ? [] : this.formula_show.match(/@.*?@/g);
// console.log(this.fields, ind2, ind, ind2)
let name = this.nowCurr.split('|')[0].substring(1, this.nowCurr.split('|')[0].length - 1)
let obj = {}
this.FieldUser.data.fieldList.forEach(value => {
if (value.fieldCn === name) {
obj = value
}
})
if (typeof this.fields[ind.length] === 'object' && this.fields[ind.length].field_type != 0) {
// console.log(this.fields[ind.length].length)
if (this.fields.length < ind2.length) {
// console.log(ind)
this.fields.splice(ind.length, 0, {
"field_id": obj.id,
"field_code": obj.fieldEn,
"field_name": name,
"field_type": 1,
"segments": [{
"segment": "",
"value": ''
}]
})
} else {
// this.fields[ind.length] = {
// n: Math.random()
// }
// 开启数据回显
}
} else {
// this.fields[ind.length] = {
// "field_id": obj.id,
// "field_code": obj.fieldEn,
// "field_name": name,
// "field_type": 1,
// "segments": [{
// "segment": "",
// "value": ''
// }]
// }
this.$set(this.fields, ind.length, {
"field_id": obj.id,
"field_code": obj.fieldEn,
"field_name": name,
"field_type": 1,
"segments": [{
"segment": "",
"value": ''
}]
})
for (let i = 0; i < ind.length; i++) {
if (typeof this.fields[i] !== 'object') {
// this.fields[i] = {
// "field_id": 0,
// "field_code": "",
// "field_name": "",
// "field_type": 0,
// "segments": [{
// "segment": "",
// "value": ''
// }]
// }
this.$set(this.fields, i, {
"field_id": 0,
"field_code": "",
"field_name": "",
"field_type": 0,
"segments": [{
"segment": "",
"value": ''
}]
})
}
}
}
// console.log(this.fields)
} else { //数组更新
}
},
delect() {
let str = this.nowCurr.split('|')[0]
let index = this.nowCurr.split('|')[1]
this.delectShow(str, parseInt(index))
this.delectArray(str, parseInt(index))
this.dialogVisible = false
this.cursorfront = ""
this.cursorlest = ""
this.nowCurr = ""
this.lastKeyDown = ""
},
delectShow(str, index) { // 回显删除
// console.log(this.cursorfront.lastIndexOf('@'))
this.formula_show = this.formula_show.substring(0, this.cursorfront.lastIndexOf('@')) + this.formula_show.substring(
this.cursorfront.lastIndexOf('@') + str.length, )
this.tempFormula = this.formula_show
},
delectArray(str, index) { // 数组删除
let ind = this.cursorfront.match(/@.*?@/g) === null ? [] : this.cursorfront.match(/@.*?@/g);
// console.log(ind)
this.fields.splice(ind.length, 1)
// console.log(this.fields)
},
isodd(text, str) { // 判断某个字符串中 某个字符是否是奇数
let num = 0
for (let i of text) {
if (i === str) {
num++
}
}
if (num % 2 === 1) {
return true
} else {
return false
}
},
dbclick(e) {
let T = ""
T = this.formula_show.split("")
T.splice(this.tempIndex, this.text.length + 1, '@' + e + '@')
this.formula_show = T.join("")
this.isshow = false
// console.log(1)
},
deepClone(obj) {
if (this.getType(obj) === 'Array') {
var res = []
} else if (this.getType(obj) === 'Object') {
var res = {}
} else {
return obj
}
for (var i in obj) {
res[i] = this.deepClone(obj[i])
}
return res
},
getType(obj) {
var res = Object.prototype.toString.call(obj)
//截取注意[] 符号,和空格
return res.slice(8, -1) // 也可以res.length-1
}
},
watch: {
formula_show() {
let num = 0
for (let i of this.formula_show) {
if (i === "@") {
num++
}
}
if (num % 2 === 1) {
this.isshow = true
for (let i in this.formula_show) {
if (this.formula_show[i] !== this.tempFormula[i] && this.formula_show[i] == "@") {
if (this.islest) {
this.tempIndex = i
this.lest = this.formula_show.substring(parseInt(this.tempIndex) + 1, this.formula_show.length)
this.islest = false
}
break
}
}
let T = this.formula_show.substring(parseInt(this.tempIndex) + 1, this.formula_show.length)
if (this.lest !== "") {
// console.log(T)
T = T.substring(0, T.indexOf(this.lest))
} else {
T = T.substring(0, T.length)
}
this.text = T
if (this.text === "@") {
this.text = ""
}
// console.log('lest:' + this.lest, 'index:' + this.tempIndex, "T:" + T)
} else {
this.islest = true
this.text = ""
this.tempIndex = null
this.isshow = false
// console.log(1)
}
this.tempFormula = this.formula_show
this.data.formula_show = this.formula_show
this.$emit('input', this.formula_show)
},
fields: {
handler: function() {
this.data.fields = this.fields
},
deep: true,
}
}
}
</script>

View File

@@ -1,463 +0,0 @@
<style>
.te_top {
width: 100%;
height: 30px;
background-color: #aaa;
display: flex;
justify-content: space-around;
}
.te_top>p {
color: #eee;
font-weight: bold;
font-size: 16px;
line-height: 30px;
}
.te_top>p:hover {
color: #fff;
cursor: pointer
}
.teParamParamList {
display: flex;
align-items: center;
margin-top: 10px;
margin-left: 10px;
}
</style>
<template>
<div style="width: 100%;">
<p>
入参
</p>
<div>
<div v-for="(value,index) in paramList"
style="margin-top: 10px;border-bottom: 1px #ddd dotted;padding-bottom: 5px;">
<el-select v-model="value.id" filterable placeholder="请选择" @change="paramChange(index,$event)">
<el-option v-for="item in FieldUser" :label="item.fieldCn" :value="item.id">
</el-option>
</el-select>
<i class="el-icon-circle-close" style="color: red;font-size: 20px;margin-left: 10px;"
@click="deleteparam(index)"></i>
<div v-if="value.paramList" v-for="item in value.paramList" class="teParamParamList">
{{item.en}} : <varialeSelect :disabled="[3]" :variableCascader="true" v-bind="$attrs"
:variableType.sync="item.type" v-model="item.value" style="margin-left: 10px;"></varialeSelect>
</div>
</div>
<el-button @click="addParam" style="margin-top: 10px;">+</el-button>
</div>
<p style="font-size:14px;margin-bottom: 5px;color: #aaa;margin-top: 30px;">
@字符选择变量
</p>
<slot></slot>
<div class="te_top" v-if="hint==true">
<p @click="textareaAdd('+')">+</p>
<p @click="textareaAdd('-')">-</p>
<p @click="textareaAdd('*')">*</p>
<p @click="textareaAdd('/')">/</p>
<p @click="textareaAdd('sqrt(,)')">sqrt</p>
<p @click="textareaAdd('In(,)')">In</p>
<p @click="textareaAdd('avg(,)')">avg()</p>
<p @click="textareaAdd('(,)')">()</p>
<p @click="textareaAdd('abs(,)')">abs</p>
<p @click="textareaAdd('max(,)')">max</p>
<p @click="textareaAdd('min(,)')">min</p>
<p @click="textareaAdd('lg(,)')">lg</p>
<p @click="textareaAdd('exp(,)')">exp</p>
<p @click="textareaAdd('ceil(,)')">ceil</p>
<p @click="textareaAdd('floor(,)')">floor</p>
</div>
<el-input type="textarea" rows="9" placeholder="请输入内容" v-model="formula_show" ref="textarea"
@input="$emit('input',formula_show)">
</el-input>
<fieldUserTable :text="text" :fieldUser="[...paramList,...tempAddOpkey]" refs="t" @dbc="dbclick" :show="isshow"
@close="isshow=false"></fieldUserTable>
<!-- <el-dialog :title="'当前编辑'+nowCurr" :visible.sync="dialogVisible" width="30%" append-to-body>
<el-button @click="delect">删除字段</el-button>
</el-dialog> -->
</div>
</template>
<script>
import fieldUserTable from '@/components/common/fieldUserTable.vue'
import varialeSelect from '@/components/models/varialeSelect.vue'
export default {
components: {
fieldUserTable,
varialeSelect
},
props: {
data: {
type: Object,
default () {
return {}
}
},
value: {
type: String,
default: ''
},
hint: {
type: Boolean,
default: false
},
paramList: {
type: Array,
default () {
return []
}
},
tempAddOpkey:{
type: Array,
default () {
return []
}
}
},
data() {
return {
loading: false,
tempsection: [],
sectionVisible: false, //区间编辑弹窗
nowCurr: '',
dialogVisible: false,
isshow: false,
text: '',
tempIndex: '',
lest: '',
islest: false,
tempFormula: '',
formula_show: '',
cursorfront: '',
cursorlest: '',
lastKeyDown: '',
// fields: []
}
},
mounted() {
this.$refs.textarea.$refs.textarea.onkeydown = (e) => {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if (e.key == "Backspace" || e.key == "Delete") {
this.lastKeyDown = e.key
if (e.key == "Backspace" && this.formula_show.substring(this.$refs.textarea.$refs.textarea
.selectionStart - 1,
this.$refs.textarea.$refs.textarea.selectionStart) == '@' && (this.isodd(this.formula_show,
'@') == false)) {
e.preventDefault()
this.countCurr()
this.delect("Backspace")
}
if (e.key == "Delete" && this.formula_show.substring(this.$refs.textarea.$refs.textarea
.selectionStart, this.$refs
.textarea.$refs.textarea.selectionStart + 1) == '@') {
e.preventDefault()
this.countCurr()
this.delect("Delete")
}
}
}
},
computed: {
FieldUser() {
return this.$store.state.FieldUser.data.fieldList
},
},
created() {
this.formula_show = this.value
// console.log(this.formula_show, this.value)
},
methods: {
deleteparam(index) {
this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.paramList.splice(index, 1)
this.$message({
type: 'success',
message: '删除成功!'
});
})
},
paramChange(index, id) {
let value = this.FieldUser.find(x => x.id == id)
if (value.sqlStatement) {
let arr = JSON.parse(value.sqlVariable)
if (arr) {
this.$set(value, 'paramList', arr.map(value => {
return {
en: value.key,
value: "",
type: 1
}
}))
}
}
this.$set(this.paramList, index, JSON.parse(JSON.stringify(value)))
},
addParam() {
// let arr = JSON.parse(JSON.stringify())
this.paramList.push({
id: ''
})
// console.log(arr)
// this.$emit('update:paramList', arr)
console.log(this.paramList)
},
setCaretPosition(ctrl, pos) { //设置光标位置函数
if (ctrl.setSelectionRange) {
ctrl.focus();
this.$nextTick(() => {
ctrl.setSelectionRange(pos, pos);
})
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
},
textareaAdd(e) {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea
.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if (e.split(',')[1]) {
this.formula_show = this.cursorfront + e.split(',')[0] + e.split(',')[1] + this.cursorlest
} else {
this.formula_show = this.cursorfront + e.split(',')[0] + this.cursorlest
}
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront + e.split(',')[0])
.length)
},
// 获取 字符串中 有 多少个指定字符
getTempIndex(string, str) {
let temp = 0
for (let num = 0;;) {
if (string.indexOf(str, temp) != -1) {
temp = string.indexOf(str, temp)
temp++
num++
} else {
return num
}
}
// console.log(string, str)
},
getTempArreyIndex(array, str) {
let num = 0
array.forEach((value) => {
if (value.field_name == "str") {
num++
}
})
return num
},
countCurr() {
if ((this.isodd(this.cursorfront, '@') == true) && (this.isodd(this.cursorlest, '@') == true)) {} else if (
this.lastKeyDown == "Backspace") {
this.cursorfront = this.cursorfront.substring(0, this.cursorfront.length - 1)
this.cursorlest = '@' + this.cursorlest
} else if (this.lastKeyDown == "Delete") {
this.cursorfront = this.cursorfront + '@'
this.cursorlest = this.cursorlest.substr(1);
}
let str = this.cursorfront.substring(this.cursorfront.lastIndexOf('@')) + this.cursorlest
.substring(0, this.cursorlest
.indexOf('@') + 1)
this.nowCurr = str + '|' + this.getTempIndex(this.cursorfront, str)
// console.log(this.nowCurr)
},
delect(type) {
let str = this.nowCurr.split('|')[0]
let index = this.nowCurr.split('|')[1]
// this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
// this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
this.delectShow(str, parseInt(index))
if (type == 'Backspace') {
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length - str.length + 1))
} else if (type == 'Delete') {
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length - 1))
}
this.cursorfront = ""
this.cursorlest = ""
this.nowCurr = ""
this.lastKeyDown = ""
},
delectShow(str, index) { // 回显删除
this.formula_show = this.formula_show.substring(0, this.cursorfront.lastIndexOf('@')) + this
.formula_show.substring(
this.cursorfront.lastIndexOf('@') + str.length, )
this.tempFormula = this.formula_show
},
isodd(text, str) { // 判断某个字符串中 某个字符是否是奇数
let num = 0
for (let i of text) {
if (i === str) {
num++
}
}
if (num % 2 === 1) {
return true
} else {
return false
}
},
dbclick(e) {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
// console.log(this.cursorfront)
let T = ""
T = this.formula_show.split("")
T.splice(this.tempIndex, this.text.length + 1, '@' + e + '@')
this.formula_show = T.join("")
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length + e.length + 1 - this
.text.length))
this.isshow = false
// console.log(1)
},
deepClone(obj) {
if (this.getType(obj) === 'Array') {
var res = []
} else if (this.getType(obj) === 'Object') {
var res = {}
} else {
return obj
}
for (var i in obj) {
res[i] = this.deepClone(obj[i])
}
return res
},
getType(obj) {
var res = Object.prototype.toString.call(obj)
//截取注意[] 符号,和空格
return res.slice(8, -1) // 也可以res.length-1
}
},
watch: {
formula_show() {
let num = 0
for (let i of this.formula_show) {
if (i === "@") {
num++
}
}
if (num % 2 === 1) {
this.isshow = true
for (let i in this.formula_show) {
if (this.formula_show[i] !== this.tempFormula[i] && this.formula_show[i] == "@") {
if (this.islest) {
this.tempIndex = i
this.lest = this.formula_show.substring(parseInt(this.tempIndex) + 1, this
.formula_show.length)
this.islest = false
}
break
}
}
let T = this.formula_show.substring(parseInt(this.tempIndex) + 1, this.formula_show.length)
if (this.lest !== "") {
// console.log(T)
T = T.substring(0, T.indexOf(this.lest))
} else {
T = T.substring(0, T.length)
}
this.text = T
if (this.text === "@") {
this.text = ""
}
// console.log('lest:' + this.lest, 'index:' + this.tempIndex, "T:" + T)
} else {
this.islest = true
this.text = ""
this.tempIndex = null
this.isshow = false
// console.log(1)
}
this.tempFormula = this.formula_show
this.data.formula_show = this.formula_show
this.$emit('input', this.formula_show)
},
fields: {
handler: function() {
this.data.fields = this.fields
},
deep: true,
},
value(value) {
console.log(value)
this.formula_show = this.value
}
}
}
</script>

View File

@@ -1,367 +0,0 @@
<style>
.te_top {
width: 100%;
height: 30px;
background-color: #aaa;
display: flex;
justify-content: space-around;
}
.te_top>p {
color: #eee;
font-weight: bold;
font-size: 16px;
line-height: 30px;
}
.te_top>p:hover {
color: #fff;
cursor: pointer
}
</style>
<template>
<div style="width: 100%;">
<p style="font-size:14px;margin-bottom: 5px;color: #aaa;">
@字符选择变量
</p>
<slot></slot>
<div class="te_top" v-if="hint==true">
<p @click="textareaAdd('+')">+</p>
<p @click="textareaAdd('-')">-</p>
<p @click="textareaAdd('*')">*</p>
<p @click="textareaAdd('/')">/</p>
<p @click="textareaAdd('sqrt(,)')">sqrt</p>
<p @click="textareaAdd('In(,)')">In</p>
<p @click="textareaAdd('avg(,)')">avg()</p>
<p @click="textareaAdd('(,)')">()</p>
<p @click="textareaAdd('abs(,)')">abs</p>
<p @click="textareaAdd('max(,)')">max</p>
<p @click="textareaAdd('min(,)')">min</p>
<p @click="textareaAdd('lg(,)')">lg</p>
<p @click="textareaAdd('exp(,)')">exp</p>
<p @click="textareaAdd('ceil(,)')">ceil</p>
<p @click="textareaAdd('floor(,)')">floor</p>
</div>
<el-input type="textarea" rows="9" placeholder="请输入内容" v-model="formula_show" ref="textarea"
@input="$emit('input',formula_show)">
</el-input>
<fieldUserTable :text="text" :fieldUser="FieldUser" refs="t" @dbc="dbclick" :show="isshow"
@close="isshow=false"></fieldUserTable>
<!-- <el-dialog :title="'当前编辑'+nowCurr" :visible.sync="dialogVisible" width="30%" append-to-body>
<el-button @click="delect">删除字段</el-button>
</el-dialog> -->
</div>
</template>
<script>
import fieldUserTable from '@/components/common/fieldUserTable.vue'
export default {
components: {
fieldUserTable
},
props: {
data: {
type: Object,
default () {
return {}
}
},
value: {
type: String,
default: ''
},
hint:{
type:Boolean,
default:false
}
},
data() {
return {
loading: false,
tempsection: [],
sectionVisible: false, //区间编辑弹窗
nowCurr: '',
dialogVisible: false,
isshow: false,
text: '',
tempIndex: '',
lest: '',
islest: false,
tempFormula: '',
formula_show: '',
cursorfront: '',
cursorlest: '',
lastKeyDown: '',
// fields: []
}
},
mounted() {
this.$refs.textarea.$refs.textarea.onkeydown = (e) => {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if (e.key == "Backspace" || e.key == "Delete") {
this.lastKeyDown = e.key
if (e.key == "Backspace" && this.formula_show.substring(this.$refs.textarea.$refs.textarea
.selectionStart - 1,
this.$refs.textarea.$refs.textarea.selectionStart) == '@' && (this.isodd(this.formula_show,
'@') == false)) {
e.preventDefault()
this.countCurr()
this.delect("Backspace")
}
if (e.key == "Delete" && this.formula_show.substring(this.$refs.textarea.$refs.textarea
.selectionStart, this.$refs
.textarea.$refs.textarea.selectionStart + 1) == '@') {
e.preventDefault()
this.countCurr()
this.delect("Delete")
}
}
}
},
computed: {
FieldUser() {
return this.$store.state.FieldUser.data.fieldList
},
},
created() {
this.formula_show = this.value
// console.log(this.formula_show, this.value)
},
methods: {
setCaretPosition(ctrl, pos) { //设置光标位置函数
if (ctrl.setSelectionRange) {
ctrl.focus();
this.$nextTick(() => {
ctrl.setSelectionRange(pos, pos);
})
} else if (ctrl.createTextRange) {
var range = ctrl.createTextRange();
range.collapse(true);
range.moveEnd('character', pos);
range.moveStart('character', pos);
range.select();
}
},
textareaAdd(e) {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea
.selectionStart)
this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
if (e.split(',')[1]) {
this.formula_show = this.cursorfront + e.split(',')[0] + e.split(',')[1] + this.cursorlest
} else {
this.formula_show = this.cursorfront + e.split(',')[0] + this.cursorlest
}
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront + e.split(',')[0])
.length)
},
// 获取 字符串中 有 多少个指定字符
getTempIndex(string, str) {
let temp = 0
for (let num = 0;;) {
if (string.indexOf(str, temp) != -1) {
temp = string.indexOf(str, temp)
temp++
num++
} else {
return num
}
}
// console.log(string, str)
},
getTempArreyIndex(array, str) {
let num = 0
array.forEach((value) => {
if (value.field_name == "str") {
num++
}
})
return num
},
countCurr() {
if ((this.isodd(this.cursorfront, '@') == true) && (this.isodd(this.cursorlest, '@') == true)) {} else if (
this.lastKeyDown == "Backspace") {
this.cursorfront = this.cursorfront.substring(0, this.cursorfront.length - 1)
this.cursorlest = '@' + this.cursorlest
} else if (this.lastKeyDown == "Delete") {
this.cursorfront = this.cursorfront + '@'
this.cursorlest = this.cursorlest.substr(1);
}
let str = this.cursorfront.substring(this.cursorfront.lastIndexOf('@')) + this.cursorlest
.substring(0, this.cursorlest
.indexOf('@') + 1)
this.nowCurr = str + '|' + this.getTempIndex(this.cursorfront, str)
// console.log(this.nowCurr)
},
delect(type) {
let str = this.nowCurr.split('|')[0]
let index = this.nowCurr.split('|')[1]
// this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
// this.cursorlest = this.formula_show.substring(this.$refs.textarea.$refs.textarea.selectionStart)
this.delectShow(str, parseInt(index))
if(type=='Backspace'){
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length-str.length+1))
}else if(type=='Delete'){
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length-1))
}
this.cursorfront = ""
this.cursorlest = ""
this.nowCurr = ""
this.lastKeyDown = ""
},
delectShow(str, index) { // 回显删除
this.formula_show = this.formula_show.substring(0, this.cursorfront.lastIndexOf('@')) + this
.formula_show.substring(
this.cursorfront.lastIndexOf('@') + str.length, )
this.tempFormula = this.formula_show
},
isodd(text, str) { // 判断某个字符串中 某个字符是否是奇数
let num = 0
for (let i of text) {
if (i === str) {
num++
}
}
if (num % 2 === 1) {
return true
} else {
return false
}
},
dbclick(e) {
this.cursorfront = this.formula_show.substring(0, this.$refs.textarea.$refs.textarea.selectionStart)
// console.log(this.cursorfront)
let T = ""
T = this.formula_show.split("")
T.splice(this.tempIndex, this.text.length + 1, '@' + e + '@')
this.formula_show = T.join("")
this.setCaretPosition(this.$refs.textarea.$refs.textarea, (this.cursorfront.length+e.length+1-this.text.length))
this.isshow = false
// console.log(1)
},
deepClone(obj) {
if (this.getType(obj) === 'Array') {
var res = []
} else if (this.getType(obj) === 'Object') {
var res = {}
} else {
return obj
}
for (var i in obj) {
res[i] = this.deepClone(obj[i])
}
return res
},
getType(obj) {
var res = Object.prototype.toString.call(obj)
//截取注意[] 符号,和空格
return res.slice(8, -1) // 也可以res.length-1
}
},
watch: {
formula_show() {
let num = 0
for (let i of this.formula_show) {
if (i === "@") {
num++
}
}
if (num % 2 === 1) {
this.isshow = true
for (let i in this.formula_show) {
if (this.formula_show[i] !== this.tempFormula[i] && this.formula_show[i] == "@") {
if (this.islest) {
this.tempIndex = i
this.lest = this.formula_show.substring(parseInt(this.tempIndex) + 1, this
.formula_show.length)
this.islest = false
}
break
}
}
let T = this.formula_show.substring(parseInt(this.tempIndex) + 1, this.formula_show.length)
if (this.lest !== "") {
// console.log(T)
T = T.substring(0, T.indexOf(this.lest))
} else {
T = T.substring(0, T.length)
}
this.text = T
if (this.text === "@") {
this.text = ""
}
// console.log('lest:' + this.lest, 'index:' + this.tempIndex, "T:" + T)
} else {
this.islest = true
this.text = ""
this.tempIndex = null
this.isshow = false
// console.log(1)
}
this.tempFormula = this.formula_show
this.data.formula_show = this.formula_show
this.$emit('input', this.formula_show)
},
fields: {
handler: function() {
this.data.fields = this.fields
},
deep: true,
},
value(value){
console.log(value)
this.formula_show = this.value
}
}
}
</script>

View File

@@ -1,136 +0,0 @@
<template>
<div style="width: 100%;margin-left: 5px;">
<div class="textInput" v-if="click=='dbl'" @dblclick="dialogVisibleOpen" :style="{'color':color,textAlign:center?'center':'left'}">{{value.trim()===""||JSON.parse(value).formula.trim()==""?'-':JSON.parse(value).formula}}</div>
<el-dialog title="自定义" v-if="dialogVisible" :visible.sync="dialogVisible" width="30%" append-to-body>
<teV2 v-model="tempValue"></teV2>
<span slot="footer" class="dialog-footer">
<el-button @click="dialogVisible=false;tempValue=''"> </el-button>
<el-button type="primary" @click="sectionSure" :disabled="type3Sure"> </el-button>
</span>
</el-dialog>
</div>
</template>
<script>
import teV2 from '@/components/common/teV2.vue'
export default {
components: {
teV2
},
props: {
center: {
type: Boolean,
default: false
},
value: {
type: String,
default: ''
},
click: {
type: String,
default: 'dbl'
}
},
data() {
return {
color: '#000',
dialogVisible: false,
tempValue: ''
}
},
created() {
},
mounted() {
},
methods: {
isodd(text, str) { // 判断某个字符串中 某个字符是否是奇数
let num = 0
for (let i of text) {
if (i === str) {
num++
}
}
if (num % 2 === 1) {
return true
} else {
return false
}
},
dialogVisibleOpen() {
// console.log('this.value',this.value)
this.tempValue = this.value==""?this.value:JSON.parse(this.value).formula
this.dialogVisible = true
},
sectionSure(e) {
// console.log(this.tempValue)
let arr = String(this.tempValue).match(/@(.|\n)*?@/g) === null ? [] : this.tempValue.match(/@(.|\n)*?@/g);
let is = false
arr = Array.from(new Set(arr))
// console.log(arr)
arr = arr.map(value => {
// console.log(value)
value = value.split('')
value.pop()
value.shift()
value = value.join('')
if (this.mixinGetValueByCn(value)) {
return this.mixinGetValueByCn(value)
} else {
is = true
this.$message.error(`没有找到指标:${value}`);
return this.mixinGetValueByCn(value)
}
})
if (is) {
return
}
let obj = {
farr: arr,
formula: this.tempValue.trim()
}
if(this.tempValue.trim()===""){
this.color = '#ee0000'
}else{
this.color = '#009500'
}
this.$emit('input', JSON.stringify(obj))
this.dialogVisible = false
},
},
watch: {
},
computed: {
type3Sure() {
return this.isodd(this.tempValue, '@')
}
}
}
</script>
<style>
.textInput {
width: 100% !important;
table-layout: fixed !important;
word-wrap: break-all !important;
word-break: normal !important;
overflow: hidden !important;
text-align: left;
font-size: 14px;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>

View File

@@ -1,137 +0,0 @@
<template>
<div style="width: 100%;margin-left: 5px;">
<div class="textInput" v-if="click=='dbl'" @dblclick="openinput=true" :style="{'color':color,textAlign:center?'center':'left'}"
v-show="!openinput">{{mytext.trim()==""?'-':mytext}}</div>
<div class="textInput" v-if="click=='click'" @click="openinput=true" :style="{'color':color,textAlign:center?'center':'left'}"
v-show="!openinput">{{mytext.trim()==""?'-':mytext}}</div>
<el-input v-show="openinput" ref='input' maxlength="30" v-model="mytext" placeholder="请输入内容" size="mini" @input="input" @blur="openinput=false"></el-input>
</div>
</template>
<script>
export default {
props: {
center: {
type: Boolean,
default: false
},
text: {
type: String,
default: ''
},
type: {
type: Number,
default: 1
},
examine: {
type: Number,
default: 1 // 1为范围检查 2为数字检查
},
click: {
type: String,
default: 'dbl'
}
},
data() {
return {
color: '#000',
openinput: false,
mytext: ''
}
},
created() {
this.mytext = this.text ? this.text : this.text === 0 ? this.text : '-'
if (this.text == null) {
this.mytext = "-"
}
},
mounted() {
this.$refs.input.$refs.input.onkeydown = (e) => {
if (e.key == 'Enter') {
this.$refs.input.$refs.input.blur()
}
}
},
methods: {
input(e) {
this.$emit('input', e)
},
verify(type = 1) {
if (!this.mytext && this.mytext != 0) {
this.mytext = '-'
this.color = '#f00'
} else {
if (this.examine == 1) {
if (this.type == 1) {
// let Z = /^(\[|\()(\d|\.)*,(\d|\.)*(\]|\))$/
let Z = /^((\[|\()(\d(\d)*(\.(\d)+)?)|\(),((\d(\d)*(\.(\d)+)?(\]|\)))|\))$/
if (!Z.test(this.mytext)) {
if (type == 1) {
this.$message.error('该字段为数值型 请填写范围区间 如:[123,456) 留空请使用 "(" ');
}
this.color = "#ee0000"
} else {
this.color = "#009500"
}
}
} else if (this.examine == 2) {
if (typeof Number(this.mytext) == 'number' && !isNaN(Number(this.mytext))) {
this.color = "#009500"
} else {
if (type == 1) {
this.$message.error('请填写数字');
}
this.color = "#ee0000"
}
} else if (this.examine == 3) {
if (String(this.mytext).trim() === "") {
this.color = "#ee0000"
} else {
this.color = "#009500"
}
}
}
}
},
watch: {
text() {
this.mytext = this.text
},
openinput() {
if (this.openinput) {
if (this.mytext == "-") {
this.mytext = ""
}
this.$nextTick(() => {
this.$refs.input.$refs.input.focus()
})
} else {
this.verify()
}
}
}
}
</script>
<style>
.textInput {
width: 100% !important;
table-layout: fixed !important;
word-wrap: break-all !important;
word-break: normal !important;
overflow: hidden !important;
text-align: left;
font-size: 14px;
text-overflow: ellipsis;
white-space: nowrap;
}
</style>

View File

@@ -1,158 +0,0 @@
<style>
.textSelectSpan {
font-size: 14px;
width: 120px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.textSelectSpan:hover {
overflow: unset;
}
</style>
<template>
<div style="display: flex;" v-if="type==1">
<p v-show="!openSelect" @dblclick="openSelect=true;" class="textSelectSpan" :style="{'color':color}">{{data.fieldName?data.fieldName:'请选择指标'}}</p>
<el-select v-model="data.fieldId" v-show="openSelect" filterable remote placeholder="请选择" size="mini" @change="change"
ref="select" @blur="blur" @visible-change="visibleChange">
<el-option v-for="item in FieldUser" :key="item.id" :label="item.fieldCn" :value="item.id">
</el-option>
</el-select>
</div>
<div style="display: flex;width: 80px;margin-left: 5px;" v-else-if="type==2">
<p v-show="!openSelect" @dblclick="openSelect=true;" class="textSelectSpan" :style="{'color':color}">{{data.calculateType==1?'分值':data.calculateType==2?'系数':'自定义'}}</p>
<el-select v-model="data.calculateType" v-show="openSelect" filterable placeholder="请选择" size="mini" @change="change"
ref="select" @blur="blur" @visible-change="visibleChange">
<el-option :key="1" label="分值" :value="1"></el-option>
<el-option :key="2" label="系数" :value="2"></el-option>
<el-option :key="3" label="自定义" :value="3"></el-option>
</el-select>
:
</div>
<div style="display: flex;width: 30px;margin-left: 5px;" v-else-if="type==3">
<p v-show="!openSelect" @dblclick="openSelect=true;" class="textSelectSpan" :style="{'color':color}">{{data.operator?data.operator=='contains'?'包含':data.operator=='not contains'?'不包含':data.operator:'-'}}</p>
<ruleRelation v-model="data.operator" :openValue2="false" :valueType="valueType" :openSelect="openSelect" :type="2" v-show="openSelect"
size="mini" @change="change" ref="select" @blur="blur" @visible-change="visibleChange" :andTextInput="true"></ruleRelation>
:
</div>
<div style="display: flex;width: 40px;margin-left: 5px;" v-else-if="type==4">
<p v-show="!openSelect" @dblclick="openSelect=true;" class="textSelectSpan" :style="{'color':color}">{{data.logical=='||'?'OR':'AND'}}</p>
<el-select v-model="data.logical" v-show="openSelect" filterable placeholder="请选择" size="mini" @change="change" ref="select" @blur="blur" @visible-change="visibleChange">
<el-option :key="1" label="AND" value="&&"></el-option>
<el-option :key="2" label="OR" value="||"></el-option>
</el-select>
</div>
</template>
<script>
import ruleRelation from '@/components/common/ruleRelation.vue'
export default {
components: {
ruleRelation
},
props: {
valueType: {
type: Number,
default: 1
},
type: {
type: Number,
default: 1
},
data: {
type: Object,
default () {
return {}
}
},
Number:{
type:Boolean,
default:false
}
},
data() {
return {
color: '#000',
openSelect: false
}
},
created() {
// this.$store.dispatch('getfielduser')
if (this.type == 1) {
if (!this.data.fieldId) {
this.data.fieldName = '请选择指标'
} else {
this.data.fieldName = this.mixinGetvalueCn(this.data.fieldId)
}
}
},
mounted() {
},
watch: {
openSelect() {
if (this.openSelect && this.type != 3) {
this.$nextTick(() => {
this.$refs.select.focus()
})
}
},
'data.operator'() {
if (this.data.operator == "" || this.data.operator == "-") {
this.color = '#F56C6C'
}
}
},
methods: {
visibleChange(e) {
if (!e) {
this.openSelect = false
}
},
blur() {
setTimeout(() => {
this.openSelect = false
}, 200)
},
change(e) {
// this.type==3?return : ''
if(this.type==1){
this.FieldUser.forEach(value => {
if (value.id == e) {
this.data.fieldName = value.fieldCn
}
})
}
setTimeout(() => {
this.openSelect = false
}, 200)
this.color = '#409EFF'
this.$emit('change')
}
},
computed: {
FieldUser() {
if (this.$store.state.FieldUser == null) {
return []
} else {
if(this.Number){
return this.$store.state.FieldUser.data.fieldList.filter(value=>value.valueType==1)
}else{
return this.$store.state.FieldUser.data.fieldList
}
}
},
}
}
</script>