Commit 334830ae authored by 董国亮's avatar 董国亮

增加web组件开发、业务组件仓库等模块

parent e285e833
......@@ -13,7 +13,8 @@
"compression-webpack-plugin": "^3.1.0",
"core-js": "^3.6.5",
"vue-cron": "^1.0.9",
"vue-drag-resize": "^1.4.1"
"vue-drag-resize": "^1.4.1",
"yaml": "^1.10.2"
},
"devDependencies": {
"@unistrong/st-cli-service": "^0.1.0"
......
......@@ -111,18 +111,46 @@ export default [
component: (resolve) =>
require(["@/views/app/portalEditor/index"], resolve),
},
{
path: URL.SEARCH,
redirect: URL.SEARCH_DATA,
path: URL.WEB_COMPONENT,
redirect: URL.WEB_COMPONENT_COMPONENT,
},
{
path: URL.WEB_COMPONENT,
component: (resolve) => require(["@/views/web-component/index"], resolve),
children: [
{
path: URL.WEB_COMPONENT_COMPONENT,
component: (resolve) =>
require(["@/views/web-component/component/index"], resolve),
},
{
path: URL.WEB_COMPONENT_TEMPLATE,
component: (resolve) =>
require(["@/views/web-component/template/index"], resolve),
},
{
path: URL.WEB_COMPONENT_PREVIEW,
component: (resolve) =>
require(["@/views/web-component/preview/index"], resolve),
},
],
},
{
path: URL.JAVA,
redirect: URL.JAVA_PUBLIC
},
{
path: URL.JAVA_PUBLIC,
component: resolve => require(["@/views/java/public/index"], resolve)
},
{
path: URL.SEARCH_DATA,
component: (resolve) => require(["@/views/search/data/index"], resolve),
path: URL.JAVA_APP,
component: resolve => require(["@/views/java/app/index"], resolve)
},
{
path: URL.SEARCH_APP,
component: (resolve) => require(["@/views/search/app/index"], resolve),
path: URL.JAVA_RULE,
component: resolve => require(["@/views/java/rule/index"], resolve)
},
{
path: URL.SCHEDULE,
......@@ -136,15 +164,16 @@ export default [
path: URL.SCHEDULE_TASK_DEVELOP,
component: (resolve) =>
require(["@/views/schedule/task/develop/index"], resolve),
},
{
path: URL.SCHEDULE_TASK_PIPELINE,
component: (resolve) =>
require(["@/views/schedule/task/pipeline/index"], resolve),
},
{
path: URL.SCHEDULE_TASK_ACCESS,
component: (resolve) =>
require(["@/views/schedule/task/access/index"], resolve),
},
},
{
path: URL.SCHEDULE_TASK_PIPELINE,
component: (resolve) =>
require(["@/views/schedule/task/pipeline/index"], resolve),
},
{
path: URL.SCHEDULE_TASK_ACCESS,
component: (resolve) =>
require(["@/views/schedule/task/access/index"], resolve),
},
];
......@@ -27,13 +27,15 @@ export const PORTAL_BPMSIMULATION = "/portal/:appId/bpmsimulation";
export const PORTAL_MAP = "/portal/:appId/map";
export const PORTAL_CONTENT = "/portal/:appId/content";
export const WEB_COMPONENT = "/web-component";
export const WEB_COMPONENT_COMPONENT = "/web-component/component";
export const WEB_COMPONENT_TEMPLATE = "/web-component/template";
export const WEB_COMPONENT_PREVIEW = "/web-component/preview";
export const RESOURCE = "/resource";
export const JAVA = "/java";
export const JAVA_PUBLIC = "/java/public";
export const JAVA_APP = "/java/app";
export const JAVA_RULE = "/java/rule";
export const SEARCH = "/search";
export const SEARCH_DATA = "/search/data";
export const SEARCH_APP = "/search/app";
export const SCHEDULE = "/schedule";
export const SCHEDULE_TASK = "/schedule/task";
export const SCHEDULE_TASK_DEVELOP = "/schedule/task/develop";
......
import dao from "./index";
export default dao.create({
findByAll: {
url: "/design/component/componentGroup/byAll"
},
findByCondition: {
url: "/design/component/componentGroup/byCondition",
method: "POST"
},
findDetailAll: {
url: "/design/component/componentGroup/findDetailAll"
},
create: {
url: "/design/component/componentGroup/creating",
method: "POST",
notify: "组件组创建",
},
edit: {
url: "/design/component/componentGroup/updating",
method: "POST",
notify: "组件组修改",
},
delete: {
url: "/design/component/componentGroup/deleting",
notify: "组件组删除",
},
queryComponentTree: {
url: "/design/component/componentGroup/queryComponentTree",
},
componentExport: {
url: "/design/component/componentGroup/componentExport",
method: "POST",
notify: "组件导出",
},
componentImport: {
url: "/design/component/componentGroup/componentImport",
method: "POST",
notify: "组件导入",
}
});
import dao from "./index";
export default dao.create({
findByCondition: {
url: "/design/component/component/byCondition",
method: "POST"
},
create: {
url: "/design/component/component/creating",
method: "POST",
notify: "组件创建"
},
edit: {
url: "/design/component/component/updating",
method: "POST",
notify: "组件编辑"
},
delete: {
url: "/design/component/component/deleting",
notify: "组件删除"
},
});
import dao from "../index";
export default dao.create({
findByPage: {
url: "/design/console/repomoduleparmsrestserver/byPage",
method: "POST"
}
});
import dao from "../index";
export default dao.create({
findByAll: {
url: "/design/console/repomodulerestserver/byCondition",
method: "POST"
},
create: {
url: "/design/console/repomodulerestserver/uploadJar",
method: "POST",
notify: "动作分类创建"
},
findByCondition: {
url: "/design/console/repomodulerestserver/byCondition",
method: "POST"
},
edit: {
url: "/design/console/repomodulerestserver/updating",
method: "POST",
notify: "动作分类编辑"
},
delete: {
url: "/design/console/repomodulerestserver/deleteJar",
notify: "动作分类删除"
},
getActions: {
url: "/design/console/repomodulerestserver/getActions",
method: "POST",
notify: "同步action"
},
online: {
url: "/design/console/repomodulerestserver/online",
notify: "上线"
},
offline: {
url: "/design/console/repomodulerestserver/offline",
notify: "下线"
}
});
import dao from "../index";
export default dao.create({
findByAll: {
url: "/design/console/repomoduletyperestserver/byCondition",
method: "POST"
},
findByCondition: {
url: "/design/console/repomoduletyperestserver/byCondition",
method: "POST"
},
create: {
url: "/design/console/repomoduletyperestserver/creating",
method: "POST",
notify: "规则分类创建"
},
edit: {
url: "/design/console/repomoduletyperestserver/updating",
method: "POST",
notify: "规则分类修改"
},
delete: {
url: "/design/console/repomoduletyperestserver/deleting",
notify: "规则分类删除"
},
getMethod: {
url: "/design/console/repomoduletyperestserver/actionTree"
}
});
import dao from "../index";
export default dao.create({
findByPage: {
url: "/design/rule/constantLibraryParam/byPage",
method: "POST"
},
findByCondition: {
url: "/design/rule/constantLibraryParam/byCondition",
method: "POST"
},
create: {
url: "/design/rule/constantLibraryParam/creating",
method: "POST",
notify: "常量创建"
},
edit: {
url: "/design/rule/constantLibraryParam/updating",
method: "POST",
notify: "常量编辑"
},
delete: {
url: "/design/rule/constantLibraryParam/deleting",
notify: "常量删除"
}
});
import dao from "../index";
export default dao.create({
findByAll: {
url: "/design/rule/constantLibrary/byCondition",
method: "POST"
},
findByCondition: {
url: "/design/rule/constantLibrary/byCondition",
method: "POST"
},
create: {
url: "/design/rule/constantLibrary/creating",
method: "POST",
notify: "常量分类创建"
},
edit: {
url: "/design/rule/constantLibrary/updating",
method: "POST",
notify: "常量分类编辑"
},
delete: {
url: "/design/rule/constantLibrary/deleting",
notify: "常量分类删除"
},
getConstant: {
url: "/design/rule/constantLibrary/constantTree"
}
});
import dao from "../index";
export default dao.create({
finByPage: {
url: "/design/rule/parameterLibraryParam/byPage",
method: "POST"
},
create: {
url: "/design/rule/parameterLibraryParam/creating",
method: "POST",
notify: "参数创建"
},
edit: {
url: "/design/rule/parameterLibraryParam/updating",
method: "POST",
notify: "参数编辑"
},
findByCondition: {
url: "/design/rule/parameterLibraryParam/byCondition",
method: "POST"
},
delete: {
url: "/design/rule/parameterLibraryParam/deleting",
notify: "参数删除"
}
});
import dao from "../index";
export default dao.create({
findByAll: {
url: "/design/rule/parameterLibrary/byCondition",
method: "POST"
},
findByCondition: {
url: "/design/rule/parameterLibrary/byCondition",
method: "POST"
},
create: {
url: "/design/rule/parameterLibrary/creating",
method: "POST",
notify: "参数分类创建"
},
edit: {
url: "/design/rule/parameterLibrary/updating",
method: "POST",
notify: "参数分类编辑"
},
delete: {
url: "/design/rule/parameterLibrary/deleting",
notify: "参数分类删除"
},
getVariable: {
url: "/design/rule/parameterLibrary/parameterTree"
}
});
import dao from "../index";
export default dao.create({
findByPage: {
url: "/design/rule/ruleScript/byPage",
method: "POST"
},
findByCondition: {
url: "/design/rule/ruleScript/byCondition",
method: "POST"
},
create: {
url: "/design/rule/ruleScript/creating",
method: "POST",
notify: "规则创建"
},
edit: {
url: "/design/rule/ruleScript/updating",
method: "POST",
notify: "规则编辑"
},
delete: {
url: "/design/rule/ruleScript/deleting",
notify: "规则删除"
},
releaseScript: {
url: "/design/rule/ruleScript/releaseScript",
method: "POST",
notify: "脚本保存"
},
publish: {
url: "/design/rule/ruleScript/buildAndRelease",
notify: "发布"
}
});
import dao from "./index";
export default dao.create({
online: {
url: "/design/console/repomodulerestserver/online/:id"
},
offline: {
url: "/design/console/repomodulerestserver/offline/:id"
}
});
import dao from "./index";
export default dao.create({
findByAll: {
url: "/design/component/resourceGroup/byAll"
},
findByCondition: {
url: "/design/component/resourceGroup/byCondition",
method: "POST"
},
create: {
url: "/design/component/resourceGroup/creating",
method: "POST",
notify: "资源分类创建",
},
edit: {
url: "/design/component/resourceGroup/updating",
method: "POST",
notify: "资源分类编辑",
},
delete: {
url: "/design/component/resourceGroup/deleting",
notify: "资源分类删除",
}
});
import dao from "./index";
export default dao.create({
findByPage: {
url: "/design/component/resource/byPage",
method: "POST"
},
findByCondition: {
url: "/design/component/resource/byCondition",
method: "POST"
},
edit: {
url: "/design/component/component/updating",
method: "POST"
},
delete: {
url: "/design/component/resource/deleting",
method: "GET"
},
});
import dao from "./index";
export default dao.create({
findByAll: {
url: "/design/component/templateGroup/byAll"
},
findByCondition: {
url: "/design/component/templateGroup/byCondition",
method: "POST"
},
findDetailAll: {
url: "/design/component/templateGroup/findDetailAll"
},
create: {
url: "/design/component/templateGroup/creating",
method: "POST",
notify: "模板组创建",
},
edit: {
url: "/design/component/templateGroup/updating",
method: "POST",
notify: "模板组修改",
},
delete: {
url: "/design/component/templateGroup/deleting",
notify: "模板组删除",
},
queryTemplateTree: {
url: "/design/component/templateGroup/queryTemplateTree",
},
templateExport: {
url: "/design/component/templateGroup/templateExport",
method: "POST",
notify: "模板导出",
},
templateImport: {
url: "/design/component/templateGroup/templateImport",
method: "POST",
notify: "模板导入",
}
});
import dao from "./index";
export default dao.create({
findByPage: {
url: "/design/component/templateVersion/byPage",
method: "POST"
},
findJson: {
url: "/design/component/templateVersion/findJson"
},
create: {
url: "/design/component/templateVersion/creating",
method: "POST",
notify: "模板版本创建"
},
edit: {
url: "/design/component/templateVersion/updating",
method: "POST",
notify: "模板版本编辑"
},
delete: {
url: "/design/component/templateVersion/deleting",
notify: "模板版本删除"
}
});
import dao from "./index";
export default dao.create({
findByCondition: {
url: "/design/component/template/byCondition",
method: "POST"
},
create: {
url: "/design/component/template/creating",
method: "POST",
notify: "模板创建"
},
edit: {
url: "/design/component/template/updating",
method: "POST",
notify: "模板编辑"
},
delete: {
url: "/design/component/template/deleting",
notify: "模板删除"
},
});
<template>
<el-dialog title="查看" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form :model="form" ref="form" class="automargin" label-width="80px" status-icon>
<el-form-item label="名称" prop="name">
<el-input
show-word-limit
v-model="form.name"
placeholder="名称"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
disabled
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="100"
disabled
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.fileName"
placeholder="文件名称"
disabled
class="fileStyle"
disabled
>
</el-input>
<!-- <el-upload
:before-upload="beforeUpload"
ref="upload"
:action="uploadUrl"
:on-success="create_upload"
:on-change="changeFile"
:auto-upload="false"
:data="form"
:show-file-list="false"
>
<el-button size="small" class="upload" icon="el-icon-upload" @click="clear"></el-button>
</el-upload> -->
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="submit()">上传</el-button> -->
</span>
</el-dialog>
</template>
<script>
class Form {
constructor(data = {}) {
this.fileName = data.fileName;
this.name = data.name;
this.version = data.version;
this.spackage = data.spackage;
this.description = data.description;
}
}
export default {
data() {
return {
show: false,
form: {}
};
},
methods: {
getPage(data) {
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
}
}
};
</script>
<style lang="less"></style>
<template>
<el-dialog
width="52%"
id="cardCreate"
title="配置说明"
:visible.sync="show"
v-drag
append-to-body
>
<div class="configDescription">
<div class="cronHeaderTab">
<ul>
<li>
配置说明
</li>
<li>
示例
</li>
</ul>
</div>
<div class="cronMiddleWarp">
<ul>
<li class="cronMiddleWarpLi">
名称 : 可随意填写<br />
版本 : 可随意填写<br />
类路径 : 是所开发的组件的项目的包路径<br />
描述 : 这个组件的描述<br />
文件名称 : 组件开发后所install的jar包
</li>
<li class="cronMiddleWarpLi">
名称 : actionB<br />
版本 : 1.1<br />
类路径 : com.jonbore.actionb<br />
描述 : 这是一个例子<br />
文件名称 : 相应的jar包在页面下载附件中下载。
</li>
</ul>
</div>
</div>
<span slot="footer" class="dialog-footer"> </span>
</el-dialog>
</template>
<script>
// 构造函数
class Form {
constructor() {}
}
export default {
data() {
return {
show: false,
form: [],
rules: {}
};
},
methods: {
getPage() {
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
}
}
};
</script>
<style lang="less">
.configDescription {
position: relative;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border-radius: 6px;
outline: 0;
padding: 0 15px 15px 15px;
.cronHeaderTab {
margin-bottom: 25px;
ul {
width: 100%;
justify-content: space-between;
display: flex;
li {
text-align: center;
width: 50%;
font-weight: bold;
font-size: 16px;
}
}
}
.cronMiddleWarp ul {
width: 100%;
justify-content: space-between;
display: flex;
.cronMiddleWarpLi {
text-align: left;
width: 48%;
border: 1px solid #666666;
padding: 10px;
height: 200px;
overflow: auto;
}
}
}
</style>
<template>
<el-dialog
v-drag
title="编辑"
:visible.sync="show"
id="warehouse"
size="tiny"
width="70%"
:close-on-click-modal="false"
>
<el-collapse v-model="activeName" accordion>
<el-collapse-item name="1">
<template slot="title">
<div class="title">
<div></div>
<div>基本设置</div>
</div>
</template>
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="60px"
status-icon
id="warehouseForm"
>
<el-form-item label="名称" prop="name">
<el-input
show-word-limit
v-model="form.name"
placeholder="名称"
maxlength="50"
></el-input>
</el-form-item>
<el-form-item label="描述" prop="desctrption">
<el-input
show-word-limit
type="textarea"
v-model="form.desctrption"
placeholder="描述"
resize="none"
maxlength="50"
></el-input>
</el-form-item>
</el-form>
</el-collapse-item>
<el-collapse-item name="2">
<template slot="title">
<div class="title">
<div></div>
<div>请求参数设置</div>
</div>
</template>
<div class="template-tab" style="background:rgba(236,238,241,.67);padding:20px;">
<paticipation ref="paticipation" id="paticipation"></paticipation>
</div>
</el-collapse-item>
<el-collapse-item name="3">
<template slot="title">
<div class="title">
<div></div>
<div>返回参数设置</div>
</div>
</template>
<div class="template-tab" style="background:rgba(236,238,241,.67);padding:20px;">
<returnValue ref="returnValue" id="returnValue"></returnValue>
</div>
</el-collapse-item>
</el-collapse>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</el-dialog>
</template>
<script>
import {
create, // 新建
repeatTabName, // 查重
edit, // 编辑
} from './service';
import paticipation from './paticipation';
import returnValue from './returnValue';
class Form {
constructor() {
this.name = '';
this.paticipation = '';
this.returnValue = '';
this.desctrption = '';
this.moduleId = '';
}
}
export default {
components: {
paticipation,
returnValue,
},
data() {
return {
show: false,
form: [],
activeName: '1',
rules: {
name: [
{
required: true,
message: '请输入名称',
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message,
},
],
},
datas: [],
};
},
methods: {
getPage(data) {
this.datas = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
this.echoDisplay();
this.activeName = '1';
},
echoDisplay() {
this.form.name = this.datas.name;
this.form.desctrption = this.datas.desctrption;
const item = [
{
name: 'root',
dataType: 'object',
des: '',
treeId: '-1',
required: '1',
type: '1',
defaultValue: '',
children: [],
},
];
if (this.datas.paticipation != '') {
const body = item.concat(treeToList(JSON.parse(this.datas.paticipation)));
this.$nextTick(() => {
this.$refs.paticipation.paticipation = listToTree(body);
});
}
const data = [
{
name: 'root',
dataType: 'object',
des: '',
treeId: '-1',
required: '1',
type: '1',
defaultValue: '',
children: [],
},
];
if (this.datas.returnValue != '') {
const returnData = data.concat(treeToList(JSON.parse(this.datas.returnValue)));
this.$nextTick(() => {
this.$refs.returnValue.returnValue = listToTree(returnData);
});
}
},
submit() {
this.$refs.form.validate((valid) => {
if (valid) {
const paticipation = treeToList(this.$refs.paticipation.paticipation).splice(1);
const returnValue = treeToList(this.$refs.returnValue.returnValue).splice(1);
this.show = false;
const obj = {
moduleId: this.$parent.jarNode.id,
paticipation: JSON.stringify(paticipation),
returnValue: JSON.stringify(returnValue),
desctrption: this.form.desctrption,
name: this.form.name,
id: this.datas.id,
};
edit(obj).then((res) => {
if (res.status == 'success') {
this.$message({
message: '编辑成功',
type: 'success',
});
} else {
this.$message({
message: res.message,
type: 'error',
});
}
this.$parent.queryData();
});
} else {
return false;
}
});
},
},
};
// tree型数据转一维数组
function treeToList(tree) {
let queen = [];
const out = [];
queen = queen.concat(tree);
while (queen.length) {
const first = queen.shift();
if (first.children) {
queen = queen.concat(first.children);
delete first.children;
}
out.push(first);
}
return out;
}
// 一维数组转tree型数据
function listToTree(list) {
const map = {};
let node;
const tree = [];
let i;
for (i = 0; i < list.length; i++) {
list[i].required = list[i].required == true ? '1' : '0';
map[list[i].treeId] = list[i];
list[i].children = [];
}
for (i = 0; i < list.length; i += 1) {
node = list[i];
if (node.treeId !== '-1') {
map[node.treeParentId].children.push(node);
} else {
tree.push(node);
}
}
return tree;
}
</script>
<style lang="less">
#warehouse .el-collapse {
border-top: 1px solid #fff !important;
border-bottom: 1px solid #fff !important;
}
#warehouse .title {
height: 60px;
display: flex;
align-items: center;
div:nth-of-type(1) {
width: 3px;
height: 30px;
background-color: #2395f1;
}
div:nth-of-type(2) {
font-size: 18px;
margin-left: 10px;
}
}
#warehouse .el-dialog__body {
padding: 10px 41px 0 35px !important;
#warehouseForm {
background: rgba(236, 238, 241, 0.67);
padding: 20px;
}
}
#warehouse .el-collapse-item__header {
border-bottom: 1px solid #fff !important;
border-top-color: #ffffff;
}
#warehouse .el-collapse-item__wrap {
border-bottom: 1px solid #ffff !important;
}
#warehouse .el-collapse-item__content {
padding-bottom: 0px !important;
}</style>
<template>
<div id="componentRepository-li">
<!-- 左侧树 -->
<iov-table-layout
:tree-data="applicationList"
@tree-click="listTreeClick"
tree-title="应用类别"
:tree-value="listselectNode"
v-if="applicationList"
ref="layoutList"
:treeStyle="'list'"
>
<!-- 右侧表格 -->
<div class="iov-content" slot="container">
<!-- 左侧树 -->
<iov-table-layout
tree-title="组件类别"
:tree-data="treeData"
@tree-click="treeClick"
v-if="treeData"
:tree-value="selectNode"
ref="layout"
:treeStyle="'list'"
:hide-crumb="true"
class="remove-crumbs"
>
<template slot="tool">
<el-button
title="新建"
type="primary"
icon="el-icon-plus"
:disabled="!applicationList || applicationList.length <= 0"
@click="treeCreate_getPage"
></el-button>
<el-button
title="编辑"
type="primary"
icon="el-icon-edit"
@click="treeEdit_getPage"
:disabled="
!selectNode ||
(selectNode && selectNode.isRoot) ||
selectNode.level == 2 ||
treeData.length <= 0
"
></el-button>
<el-button
type="primary"
icon="el-icon-delete"
@click="treeDelete_getPage"
title="删除"
:disabled="
!selectNode ||
(selectNode && selectNode.isRoot) ||
treeData.length <= 0
"
></el-button>
</template>
<!-- 右侧表格 -->
<div class="iov-content" slot="container">
<div class="center">
<div class="fileTop">
<div class="title">组件列表</div>
<div>
<el-button
type="success"
size="small"
@click="jarCreate_getPage"
:disabled="!selectNode || (selectNode && selectNode.isRoot)"
>上传</el-button
>
<el-button
size="small"
@click="deletJar"
:disabled="
this.jarList.length == 0 || jarNode.enable == '1'
"
>删除</el-button
>
</div>
</div>
<div class="photoStyle">
<img
src="@/assets/images/img/unData.png"
v-if="this.jarList.length == 0"
/>
</div>
<div class="fileBottom" v-if="this.jarList.length > 0">
<div
class="fileContent"
v-for="item in jarList"
:key="item.id"
:class="{ active: jarNode.id == item.id }"
@click="jarClick(item)"
>
<div class="img"></div>
<div class="titleContent">
<div :title="item.name">
{{ item.name }}/{{ item.version }}
</div>
<div :title="item.path">{{ item.path }}</div>
<div :title="item.desctrption">{{ item.desctrption }}</div>
</div>
<div class="line">
<el-tooltip content="查看" placement="top">
<i class="el-icon-view" @click="check(item)"></i>
</el-tooltip>
<el-tooltip content="上线" placement="top">
<img
src="@/assets/images/img/offline.png"
@click="online(item)"
v-if="item.enable == '2'"
style="margin-left:10px;"
/>
</el-tooltip>
<el-tooltip content="下线" placement="top">
<img
src="@/assets/images/img/online.png"
@click="offline(item)"
v-if="item.enable == '1'"
style="margin-left:10px;"
/>
</el-tooltip>
</div>
</div>
</div>
</div>
<div class="iov-table right" v-if="table.tableData">
<div class="topTool">
<el-button
type="primary"
size="small"
@click="asyncAction"
:disabled="
!jarNode || jarNode.enable == '2' || jarList.length == 0
"
>读取组件</el-button
>
<el-button type="success" size="small" @click="download"
>下载基础框架</el-button
>
<el-input
show-word-limit
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
maxlength="50"
class="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
<div class="iov-table" v-if="table.tableData">
<iov-table
:table-data="table.tableData"
:table-option="table.option"
:table-loading="table.loading"
:total="table.pageTotal"
:pageSize="table.pageSize"
:pageChange="pageChange"
:sizeChange="sizeChange"
:pageNum="table.pageNum"
@selectChange="selectChange"
>
<el-table-column
fixed="right"
label="操作"
width="120"
v-if="table.tableData.length > 0"
slot="operationTool"
>
<template slot-scope="scope">
<el-button
@click.native.prevent="edit_getPage(scope.row)"
type="text"
size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="test_getPage(scope.row)"
type="text"
size="small"
:disabled="jarNode.enable == '2'"
>测试</el-button
>
</template>
</el-table-column>
</iov-table>
</div>
</div>
</div>
</iov-table-layout>
</div>
</iov-table-layout>
<!-- 左侧树新建 -->
<treeCreateForm ref="treeCreate_form"></treeCreateForm>
<!-- jar包新建 -->
<jarCreateForm ref="jarCreate_form"></jarCreateForm>
<!-- 左侧树编辑 -->
<treeEditForm ref="treeEdit_form"></treeEditForm>
<!-- 右侧编辑 -->
<editForm ref="edit_form" mode="edit"></editForm>
<!-- 测试 -->
<stms-api-design
ref="test_form"
:requestTool="requestTool"
></stms-api-design>
<check ref="check_form"></check>
</div>
</template>
<script>
// 引入Api
import {
queryData, // 表格
getTreeList, //应用列表树
getTree, // 树
treeDelete, // 树删除
deleting, // 表格删除
jarDelete, // jar包删除
repeatJarName, // 获取Jar数据
online, // 上线
offline, // 下线
asyncActions, // 同步方法
download, //下载
} from "./service";
// 引入相关文件
import editForm from "./edit";
import treeCreateForm from "./treeCreate";
import treeEditForm from "./treeEdit";
import jarCreateForm from "./jarCreate";
import check from "./check";
export default {
// 组件注册
components: {
editForm,
treeCreateForm,
treeEditForm,
jarCreateForm,
check,
},
mounted() {
this.getListTree();
},
data() {
return {
//李永健
applicationList: [],
requestTool: [],
listselectNode: "",
//其他
jarList: [],
jarNode: null,
table: {
option: [
{
prop: "name",
label: "名称",
},
{
prop: "desctrption",
label: "描述",
},
{
prop: "createDate",
label: "创建时间",
},
],
tableData: [],
loading: false,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
selectNode: "",
treeData: [],
jarPath: "",
disable: [],
};
},
methods: {
// 应用列表树查询
async getListTree() {
const typeList = {
internal: "Web应用",
mobile: "移动应用",
webPortal: "web门户",
mobliePortal: "移动门户",
webPortalResources: "web门户资源",
mobilePortalResources: "移动门户资源",
orchestration: "服务编排",
};
const res = await getTreeList();
if (res.status == "success") {
if (res.content.length > 0) {
let list = res.content;
for (let i = 0; i < list.length; i++) {
if (list[i].type && typeList[list[i].type]) {
list[i].name =
list[i].nameCn + " (" + typeList[list[i].type] + ")";
} else {
list[i].name = list[i].nameCn;
}
}
this.applicationList = list;
this.listTreeClick(res.content[0]);
} else {
this.applicationList = [];
}
} else {
this.applicationList = [];
}
},
// 树查询
async getTree() {
let data = {
appId: this.listselectNode.id,
type: "application",
};
const res = await getTree(data);
if (res.status == "success") {
if (res.content.length > 0) {
this.treeData = res.content;
this.treeClick(res.content[0]);
} else {
//清空后面的数据
this.treeData = [];
this.jarList = [];
this.table.tableData = [];
this.table.pageTotal = 0;
}
} else {
this.treeData = [];
}
},
//应用列表点击
listTreeClick(item) {
this.listselectNode = item;
this.getTree();
},
// 点击分类
treeClick(item) {
this.selectNode = item;
if (this.selectNode.data) {
this.jarPath = this.selectNode.data.jarPath;
}
this.repeatJarName();
},
// 获取jar数据
async repeatJarName() {
const res = await repeatJarName({ typeId: this.selectNode.id });
if (res.status == "success") {
this.jarList = res.content;
if (this.jarList.length > 0) {
this.jarNode = this.jarList[0];
this.jarNode.id = this.jarList[0].id;
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
} else {
this.jarList = [];
}
if (this.jarNode) {
this.jarClick(this.jarNode);
}
},
jarClick(data) {
this.jarNode = data;
this.queryData();
},
// 删除jar
deletJar() {
__.ui.messageBox("此操作将永久删除该jar包, 是否继续?", () => {
jarDelete({
id: this.jarNode.id,
}).then((res) => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
}
this.repeatJarName();
});
});
},
// 表格查寻
async queryData() {
this.table.loading = false;
if (this.jarList != null && this.jarList.length > 0) {
const data = {
condition: {
keyword: this.searchData,
moduleId: this.jarNode.id,
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum,
};
const res = await queryData(data);
if (res.status == "success") {
this.table.tableData = res.content.rows || [];
this.table.pageTotal = res.content.total;
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
}
this.table.loading = false;
},
// 树新建
treeCreate_getPage() {
this.$refs.treeCreate_form.getPage(this.listselectNode);
},
// jar包新建
jarCreate_getPage() {
this.$refs.jarCreate_form.getPage();
},
// 上线
online(data) {
__.ui.messageBox("此操作将此jar包上线, 是否继续?", () => {
const params = { id: data.id };
online(params).then((res) => {
if (res.status == "success") {
this.$message({
message: "上线成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "success",
});
}
this.getTree();
});
});
},
// 下线
offline(data) {
__.ui.messageBox("此操作将此jar包下线, 是否继续?", () => {
const params = { id: data.id };
offline(params).then((res) => {
if (res.status == "success") {
this.$message({
message: "下线成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "success",
});
}
this.getTree();
});
});
},
// 树编辑
treeEdit_getPage() {
this.$refs.treeEdit_form.getPage(this.selectNode);
},
test_getPage(data) {
var obj;
this.requestTool = ["body"];
obj = {
root: `http://${window.location.host}/design`,
requestBody: {
query: [],
headers: [],
body: {
type:
(data.paticipation && JSON.parse(data.paticipation).type) || "0",
param:
(data.paticipation && JSON.parse(data.paticipation).param) || [],
},
},
};
data.method = "POST"; //仅支持post
data.url = `/console/repomodulerestserver/executeAction/${this.jarNode.name}/${this.jarNode.version}/${data.name}`;
this.$refs.test_form.getPage(Object.assign(obj, data));
},
getReqData(req) {
if (req.requestBody.body.type === "4") {
var formdata = new FormData();
(req.requestBody.body.param || []).forEach((val) => {
formdata.append("file", val.file.raw);
});
}
return req.requestBody.body.type === "3"
? JSON.parse(req.requestBody.body.param)
: req.requestBody.body.type === "4"
? formdata
: (req.requestBody.body.param[0] &&
__.request.getBody(req.requestBody.body.param[0].children)) ||
{};
},
// 树删除(jar包删除)
treeDelete_getPage() {
__.ui.messageBox("此操作将永久删除该函数列表, 是否继续?", () => {
treeDelete({
ids: this.selectNode.id,
}).then((res) => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
}
this.getTree();
});
});
},
// 搜索
search() {
this.queryData();
},
// 新建
asyncAction() {
this.asyncActions();
},
async asyncActions() {
const data = {
id: this.jarNode.id,
name: this.jarNode.name,
};
const res = await asyncActions(data);
if (res.status == "success") {
this.$message({
message: res.message,
type: "success",
});
this.queryData();
} else {
this.$message({
message: res.message,
type: "error",
});
}
},
// 下载
download() {
window.location.href =
window.location.origin +
"/design/console/repomodulerestserver/downloadFile";
},
// 编辑
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
pageChange(currentPage) {
this.table.pageNum = currentPage;
this.queryData();
},
sizeChange(size) {
this.table.pageSize = size;
this.queryData();
},
selectChange(data) {
this.mutiDeleteData = data;
},
// 删除
multiDelete(data) {
__.ui.messageBox("此操作将永久删除该函数, 是否继续?", () => {
deleting({
ids: data.id,
}).then((res) => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.queryData();
});
});
},
//查看
check(data) {
this.$refs.check_form.getPage(data);
},
},
};
</script>
<style lang="less">
#componentRepository-li {
.undata {
margin: 10% 30%;
}
.photoStyle {
text-align: center;
margin-top: 20px;
}
.topTool {
height: 56px;
padding: 10px 20px 0;
position: relative;
.search {
width: 250px;
position: absolute;
right: 10px;
}
}
.iov-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: inherit;
.center {
width: 320px;
height: 100%;
border-right: 1px solid #d7e3f1;
.fileTop {
width: 100%;
display: flex;
height: 56px;
align-items: center;
padding: 0 15px;
justify-content: space-between;
}
.fileBottom {
width: 100%;
height: calc(100% - 56px);
overflow-y: auto;
.fileContent.active {
background: #5a6ce6;
color: #fff;
.titleContent {
div:nth-of-type(1) {
color: #fff;
}
div:nth-of-type(2) {
color: #fff;
}
div:nth-of-type(3) {
color: #fff;
}
}
}
.fileContent {
height: 90px;
width: 100%;
display: flex;
align-items: center;
background: rgba(255, 255, 255, 1);
border-top: 1px solid rgba(238, 238, 238, 1);
border-bottom: 1px solid rgba(238, 238, 238, 1);
position: relative;
.line {
position: absolute;
right: 10px;
top: 5px;
display: flex;
height: 15px;
img {
cursor: pointer;
}
}
.img {
width: 45px;
height: 51px;
line-height: 80px;
text-align: center;
background-image: url("~@/assets/images/img/activeJar.png");
margin: 0 18px;
}
.titleContent {
width: calc(100% - 100px);
div:nth-of-type(1) {
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(74, 74, 74, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
div:nth-of-type(2) {
font-size: 10px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(102, 102, 102, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
div:nth-of-type(3) {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(153, 153, 153, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
}
.right {
padding: 0 0;
width: 0;
height: auto;
display: flex;
flex-direction: column;
.fileName {
width: 100%;
height: 56px;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(238, 238, 238, 1);
padding: 0 15px;
img {
margin-right: 10px;
}
}
.fileUrl {
width: 100%;
height: 35px;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(238, 238, 238, 1);
padding: 0 15px;
margin-bottom: 5px;
img {
margin-right: 10px;
}
}
}
}
.item_simple {
margin: 10px 0 10px 10px;
width: 95%;
height: 100px;
border: 1px solid #dcdcdc;
border-left-width: 20px;
border-radius: 10px;
position: relative;
.item_list {
margin: 12px 34px;
width: 86%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.edit {
position: absolute;
right: 40px;
top: 5px;
font-size: 18px;
cursor: pointer;
}
.closeDelete {
position: absolute;
right: 8px;
top: 5px;
font-size: 18px;
cursor: pointer;
}
}
.item_simple:hover {
border-color: #d5e8f6;
box-shadow: 0 0 7px #d5e8f6;
}
/* lyj*/
.remove-crumbs {
.layoutContainer {
top: 0;
}
}
}
</style>
<template>
<el-dialog title="上传" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="80px"
status-icon
>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
></el-input>
</el-form-item>
<el-form-item label="描述" prop="desctrption">
<el-input
show-word-limit
type="textarea"
v-model="form.desctrption"
placeholder="描述"
resize="none"
maxlength="100"
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.file"
placeholder="文件名称"
disabled
class="fileStyle"
>
</el-input>
<el-upload
:before-upload="beforeUpload"
ref="upload"
:action="uploadUrl"
:on-success="create_upload"
:on-change="changeFile"
:auto-upload="false"
:data="form"
:show-file-list="false"
>
<el-button size="small" class="upload" icon="el-icon-upload" @click="clear"></el-button>
</el-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">上传</el-button>
</span>
</el-dialog>
</template>
<script>
import { repeatJarName, repeatNameLi } from "./service";
class Form {
constructor() {
this.file = "";
this.name = "";
this.version = "";
this.url = "";
this.spackage = "";
this.desctrption = "";
this.typeId = "";
this.fileName = "";
}
}
export default {
data() {
//名称查重
let nameVal = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入"));
} else if (this.form.version === "") {
callback();
} else {
repeatNameLi({
name: this.form.name,
version: this.form.version
}).then(res => {
if (res.content.length > 0) {
callback(new Error("该名称和版本已被使用"));
} else {
callback();
}
});
}
};
//版本查重
let versionVal = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入"));
} else if (this.form.name === "") {
callback();
} else {
repeatNameLi({
name: this.form.name,
version: this.form.version
}).then(res => {
if (res.content.length > 0) {
callback(new Error("该名称和版本已被使用"));
} else {
callback();
}
});
}
};
return {
show: false,
form: {},
rules: {
name: [
{
required: true,
message: "请输入"
},
{
validator: nameVal,
trigger: "blur"
}
// {
// pattern: __.validate.regular.commonCn.pattern,
// message: __.validate.regular.commonCn.message
// },
],
url: [
{
required: true,
message: "请输入路径"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
}
],
spackage: [
{
required: true,
message: "请输入类路径"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
}
],
version: [
{
required: true,
message: "请输入"
},
{
validator: versionVal,
trigger: "blur"
}
],
file: [
{
required: true,
message: "请选择文件"
},
{
validator: __.validate.unique(repeatJarName)
}
]
},
uploadUrl: "/design/console/repomodulerestserver/uploadJar"
};
},
methods: {
getPage() {
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
beforeUpload(file) {
const Jar = file.name.toLowerCase().split(".");
if (Jar[Jar.length - 1] === "jar") {
return file;
}
this.$message.error("上传文件只能是 jar 格式!");
return false;
},
create_upload(response) {
if (response.status == "success") {
this.headerList = response.content;
this.$notify({
title: "成功",
message: response.message || "上传成功",
type: "success"
});
} else {
this.headerList = [];
this.$notify.error({
title: "失败",
message: response.message || "上传失败"
});
}
this.$parent.queryData();
},
clear() {
this.$refs.upload.clearFiles();
},
changeFile(file, fileList) {
this.form.file = file.name;
this.form.fileName = file.name;
this.beforeUpload(file);
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
const jar = this.form.file.toLowerCase().split(".");
if (jar[jar.length - 1] === "jar") {
this.form.typeId = this.$parent.selectNode.id;
this.$refs.upload.submit();
this.show = false;
this.$parent.repeatJarName();
} else {
this.$message.error("上传文件只能是 jar 格式!");
}
} else {
return false;
}
});
}
}
};
</script>
<style lang="less">
.uploadParent {
position: relative;
.upload {
position: absolute;
top: 0;
right: 0;
}
.el-form-item__content {
div:nth-of-type(2) {
height: 3px;
}
}
}
</style>
<template>
<div>
<div class="treeScroll">
<el-tree
id="returns"
:data="paticipation"
node-key="treeId"
:default-expand-all="true"
:expand-on-click-node="false"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<el-input v-model="data.name" class="width" :disabled="data.treeId == '-1'"></el-input>
<el-select
v-model="data.dataType"
class="selectWidth"
@change="typeChange(data)"
:disabled="data.treeId == '-1'"
>
<el-option
v-for="item in typeList"
:key="item"
:label="item"
:value="item"
></el-option>
</el-select>
<el-select
v-model="data.required"
filterable
placeholder="必填"
class="selectWidth"
:disabled="data.treeId == '-1'"
>
<el-option value="1" label="是"></el-option>
<el-option value="0" label="否"></el-option>
</el-select>
<el-input
show-word-limit
type="text"
placeholder="说明"
v-model="data.des"
maxlength="100"
class="width"
:disabled="data.treeId == '-1'"
></el-input>
<!-- 默认input -->
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des != 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<!-- 两个input -->
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des == 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des == 'between'
"
v-model="data.defaultValues"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<!-- 默认日历插件 -->
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des != 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
></el-date-picker>
<!-- 两个日历框 -->
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des == 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
></el-date-picker>
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des == 'between'
"
v-model="data.defaultValues"
:disabled="data.treeId == '-1'"
></el-date-picker>
</span>
<span class="tools">
<i
class="el-icon-plus"
v-if="data.dataType == 'object'"
@click="append(data, paticipation)"
></i>
<i
class="el-icon-close"
@click="() => remove(node, data)"
v-if="data.treeId != '-1'"
></i>
</span>
</span>
</el-tree>
</div>
</div>
</template>
<script>
export default {
mounted() {},
data() {
return {
dataIn: "",
// 数据类型
typeList: [
"string",
"int",
"object",
"char",
"short",
"long",
"float",
"double",
"boolean",
"byte",
"json",
"array",
"file",
"timestamp",
"time",
"date"
],
paramTypeCode: "04", // 默认选中json
show: false,
treeId: "",
radio: "0", // 默认json标签
// json数据
paticipation: [
{
name: "root",
dataType: "object",
des: "",
children: [],
paramTypeCode: "04",
treeId: "-1",
required: "1",
type: "0",
defaultValue: ""
}
]
};
},
methods: {
// 计算请求参数节点最大id
getMaxId(nodes, id = 0) {
return nodes.reduce(
(result, item) =>
item.children && item.children.length > 0
? this.getMaxId(item.children, result)
: result > item.id
? result
: item.treeId + 1,
id
);
},
// 添加json
append(data, all) {
if (!data.children) {
this.$set(data, "children", []);
}
this.funcDisable(this.paticipation);
// 变量接requireName为false则为空
if (this.requireName == false) {
this.$message({
type: "error",
message: "名称必填"
});
} else {
data.children.push({
name: "",
dataType: "object",
treeId: this.getMaxId(all),
treeParentId: data.treeId,
des: "",
serviceId: "",
type: "0",
required: "",
defaultValue: ""
});
}
Vue.set(data, "children", data.children); // 保证修改数组视图渲染
},
// 递归取数据中的name是否为空
funcDisable(data) {
for (let i = 0; i < data.length; i++) {
if (data[i].children) {
if (data[i].name == "") {
this.requireName = false;
} else {
this.requireName = true;
}
}
const { children } = data[i];
if (children) {
this.funcDisable(children);
}
}
},
// 删除json节点
remove(node, data) {
const index = node.parent.data.children.findIndex(d => d.id === data.id);
node.parent.data.children.splice(index, 1);
node.parent.childNodes.splice(index, 1);
},
// 改变数据类型
typeChange(data) {
if (data.dataType != "object") {
Vue.set(data, "children", []); // 保证修改数组视图渲染
}
}
}
};
</script>
<style lang="less">
#paticipation {
height: 390px;
// padding: 20px;
.treeScroll {
overflow-y: auto;
overflow-x: scroll;
height: 370px;
background: #fff;
#returns {
padding-top: 3px;
display: inline-block;
.selectWidth {
width: 100px;
margin-left: 10px;
}
.width {
width: 160px;
margin-left: 10px;
}
.tools {
margin-left: 10px;
width: 40px;
display: inline-flex;
justify-content: space-between;
}
.el-tree-node__content {
height: 32px;
margin: 8px 0;
background: #fff;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
}
}
}
</style>
<template>
<div>
<el-tree
id="returns"
:data="returnValue"
node-key="treeId"
:default-expand-all="true"
:expand-on-click-node="false"
>
<span class="custom-tree-node" slot-scope="{ node, data }">
<span>
<el-input v-model="data.name" class="width" :disabled="data.treeId == '-1'"></el-input>
<el-select
v-model="data.dataType"
class="selectWidth"
@change="typeChange(data)"
:disabled="data.treeId == '-1'"
>
<el-option v-for="item in typeList" :key="item" :label="item" :value="item"></el-option>
</el-select>
<el-select
v-model="data.required"
filterable
placeholder="必填"
class="selectWidth"
:disabled="data.treeId == '-1'"
>
<el-option value="1" label="是"></el-option>
<el-option value="0" label="否"></el-option>
</el-select>
<el-input
show-word-limit
type="text"
placeholder="说明"
v-model="data.des"
maxlength="100"
class="width"
:disabled="data.treeId == '-1'"
></el-input>
<!-- 默认input -->
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des != 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<!-- 两个input -->
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des == 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<el-input
show-word-limit
type="text"
maxlength="50"
placeholder="默认值"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) == -1 && data.des == 'between'
"
v-model="data.defaultValues"
:disabled="data.treeId == '-1'"
class="width"
></el-input>
<!-- 默认日历插件 -->
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des != 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
></el-date-picker>
<!-- 两个日历框 -->
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des == 'between'
"
v-model="data.defaultValue"
:disabled="data.treeId == '-1'"
></el-date-picker>
<el-date-picker
type="date"
value-format="yyyy-MM-dd"
class="el-date width"
v-if="
['timestamp', 'time', 'date'].indexOf(data.dataType) != -1 && data.des == 'between'
"
v-model="data.defaultValues"
:disabled="data.treeId == '-1'"
></el-date-picker>
</span>
<span class="tools">
<i
class="el-icon-plus"
v-if="data.dataType == 'object'"
@click="append(data, returnValue)"
></i>
<i class="el-icon-close" @click="() => remove(node, data)" v-if="data.treeId != '-1'"></i>
</span>
</span>
</el-tree>
</div>
</template>
<script>
export default {
mounted() {},
data() {
return {
dataIn: '',
// 数据类型
typeList: [
'string',
'int',
'object',
'char',
'short',
'long',
'float',
'double',
'boolean',
'byte',
'json',
'array',
'file',
'timestamp',
'time',
'date',
],
paramTypeCode: '04', // 默认选中json
show: false,
treeId: '',
radio: '0', // 默认json标签
// json数据
returnValue: [
{
name: 'root',
dataType: 'object',
des: '',
children: [],
paramTypeCode: '04',
treeId: '-1',
required: '1',
type: '0',
defaultValue: '',
},
],
};
},
methods: {
// 计算请求参数节点最大id
getMaxId(nodes, id = 0) {
return nodes.reduce(
(result, item) => (item.children && item.children.length > 0
? this.getMaxId(item.children, result)
: result > item.id
? result
: item.treeId + 1),
id,
);
},
// 添加json
append(data, all) {
if (!data.children) {
this.$set(data, 'children', []);
}
this.funcDisable(this.returnValue);
// 变量接requireName为false则为空
if (this.requireName == false) {
this.$message({
type: 'error',
message: '名称必填',
});
} else {
data.children.push({
name: '',
dataType: 'object',
treeId: this.getMaxId(all),
treeParentId: data.treeId,
des: '',
serviceId: '',
type: '0',
required: '',
defaultValue: '',
});
}
Vue.set(data, 'children', data.children); // 保证修改数组视图渲染
},
// 递归取数据中的name是否为空
funcDisable(data) {
for (let i = 0; i < data.length; i++) {
if (data[i].children) {
if (data[i].name == "") {
this.requireName = false;
} else {
this.requireName = true;
}
}
const { children } = data[i];
if (children) {
this.funcDisable(children);
}
}
},
// 删除json节点
remove(node, data) {
const index = node.parent.data.children.findIndex(d => d.id === data.id);
node.parent.data.children.splice(index, 1);
node.parent.childNodes.splice(index, 1);
},
// 改变数据类型
typeChange(data) {
if (data.dataType != 'object') {
Vue.set(data, 'children', []); // 保证修改数组视图渲染
}
},
},
};
</script>
<style lang="less">
#returnValue {
height: 390px;
// padding: 20px;
#returns {
width: 100%;
height: 390px;
padding-top: 3px;
overflow: auto;
.selectWidth {
width: 100px;
margin-left: 10px;
}
.width {
width: 160px;
margin-left: 10px;
}
.tools {
margin-left: 10px;
width: 40px;
display: inline-flex;
justify-content: space-between;
}
.el-tree-node__content {
height: 32px;
margin: 8px 0;
background: #fff;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
}
}
</style>
import fetch from "@/utils/fetch";
// 应用列表树
export const getTreeList = () =>
fetch("/design/appmanage/application/findSpecificApplication", {}, "GET");
// 左侧树
export const getTree = (data) =>
fetch("/design/console/repomoduletyperestserver/byCondition", data, "POST");
// 左侧列表新建
export const treeCreate = (data) =>
fetch("/design/console/repomoduletyperestserver/creating", data, "POST");
// 编辑
export const treeEdit = (data) =>
fetch("/design/console/repomoduletyperestserver/updating", data, "POST");
// 删除
export const treeDelete = (data) =>
fetch("/design/console/repomoduletyperestserver/deleting", data, "GET");
// 左侧列表查重
export const repeatName = (data) =>
fetch("/design/console/repomoduletyperestserver/byCondition", data, "POST");
// 表格查询
export const queryData = (data) =>
fetch("/design/console/repomoduleparmsrestserver/byPage", data, "POST");
export const create = (data) =>
fetch("/design/console/repomoduleparmsrestserver/creating", data, "POST");
export const edit = (data) =>
fetch("/design/console/repomoduleparmsrestserver/updating", data, "POST");
export const deleting = (data) =>
fetch("/design/console/repomoduleparmsrestserver/deleting", data, "GET");
export const repeatTabName = (data) =>
fetch("/design/console/repomoduleparmsrestserver/byCondition", data, "POST");
// jar包上传
export const uploadUrl = (data) =>
fetch("/design/console/repomodulerestserver/uploadJar", data, "POST");
// jar包查重
export const repeatJarName = (data) =>
fetch("/design/console/repomodulerestserver/byCondition", data, "POST");
//名称和版本查重
export const repeatNameLi = (data) =>
fetch("/design/console/repomodulerestserver/byCondition", data, "POST");
// jar包删除
export const jarDelete = (data) =>
fetch("/design/console/repomodulerestserver/deleteJar", data, "GET");
// jar上线
export const online = (data) =>
fetch("/design/console/repomodulerestserver/online", data, "GET");
// jar下线
export const offline = (data) =>
fetch("/design/console/repomodulerestserver/offline", data, "GET");
// 同步方法
export const asyncActions = (data) =>
fetch("/design/console/repomodulerestserver/getActions", data, "POST");
<template>
<el-dialog title="新建" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="80px"
status-icon
>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="编码" prop="code">
<el-input show-word-limit v-model="form.code" placeholder="编码" maxlength="50"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import {
treeCreate, // 新建
repeatName // 查重
} from "./service";
class Form {
constructor() {
this.name = "";
this.code = "";
this.appId = "";
this.type = "application";
}
}
export default {
data() {
return {
show: false,
form: {},
rules: {
name: [
{
required: true,
message: "请输入名称"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName),
trigger: "change"
}
],
code: [
{
required: true,
message: "请输入编码"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName),
trigger: "change"
}
]
}
};
},
methods: {
getPage(data) {
this.form = new Form();
this.form.appId = data.id;
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.show = false;
treeCreate(this.form).then(res => {
if (res.status == "success") {
this.$message({
message: "新建成功",
type: "success"
});
} else {
this.$message({
message: res.message,
type: "error"
});
}
this.$parent.getTree();
});
} else {
return false;
}
});
}
}
};
</script>
<style scoped></style>
<template>
<el-dialog v-drag title="编辑" :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-dialog title="编辑" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
......@@ -8,21 +8,11 @@
label-width="80px"
status-icon
>
<el-form-item label="中文名称" prop="nameCn">
<el-input
show-word-limit
v-model="form.nameCn"
placeholder="请输入中文名称"
maxlength="50"
></el-input>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="英文名称" prop="nameEn">
<el-input
show-word-limit
v-model="form.nameEn"
placeholder="请输入英文名称"
maxlength="50"
></el-input>
<el-form-item label="编码" prop="code">
<el-input show-word-limit v-model="form.code" placeholder="编码" maxlength="50"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
......@@ -30,68 +20,58 @@
</span>
</el-dialog>
</template>
<script>
import { edit, repeatTabName } from "./service";
import {
treeEdit, // 编辑
repeatName // 查重
} from "./service";
class Form {
constructor(data = {}) {
this.id = data.id;
this.nameCn = data.nameCn;
this.nameEn = data.nameEn;
this.name = data.name;
this.code = data.code;
}
}
export default {
data() {
return {
show: false,
form: [],
rules: {},
sataus: ""
form: {},
rules: {}
};
},
methods: {
getPage(data) {
this.form = new Form(data);
this.sataus = data.status;
const nameCn = (rule, value, callback) => {
if (value) {
repeatTabName({
// 调用接口
nameCn: value
}).then(res => {
if (res.content.length > 0 && this.form.id != res.content[0].id) {
callback(new Error("该中文名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
nameEn: [
name: [
{
required: true,
message: "填写英文名称"
message: "输入名称"
},
{
pattern: /^[a-zA-Z]{1,50}$/,
message: "请输入纯英文"
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName, this.form.id),
trigger: "change"
}
],
nameCn: [
code: [
{
required: true,
message: "请输入中文名称"
message: "请输入编码"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: nameCn
validator: __.validate.unique(repeatName, this.form.id),
trigger: "change"
}
]
};
......@@ -100,12 +80,11 @@ export default {
}
this.show = true;
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.show = false;
edit(this.form).then(res => {
treeEdit(this.form).then(res => {
if (res.status == "success") {
this.$message({
message: "编辑成功",
......@@ -117,7 +96,7 @@ export default {
type: "error"
});
}
this.$parent.queryData();
this.$parent.getTree();
});
} else {
return false;
......@@ -127,3 +106,5 @@ export default {
}
};
</script>
<style scoped></style>
<template>
<el-dialog title="查看" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form :model="form" ref="form" class="automargin" label-width="80px" status-icon>
<el-form-item label="名称" prop="name">
<el-input
show-word-limit
v-model="form.name"
placeholder="名称"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
disabled
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="100"
disabled
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.fileName"
placeholder="文件名称"
disabled
class="fileStyle"
disabled
>
</el-input>
<!-- <el-upload
:before-upload="beforeUpload"
ref="upload"
:action="uploadUrl"
:on-success="create_upload"
:on-change="changeFile"
:auto-upload="false"
:data="form"
:show-file-list="false"
>
<el-button size="small" class="upload" icon="el-icon-upload" @click="clear"></el-button>
</el-upload> -->
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="submit()">上传</el-button> -->
</span>
</el-dialog>
</template>
<script>
class Form {
constructor(data = {}) {
this.fileName = data.fileName;
this.name = data.name;
this.version = data.version;
this.spackage = data.spackage;
this.description = data.description;
}
}
export default {
data() {
return {
show: false,
form: {}
};
},
methods: {
getPage(data) {
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
}
}
};
</script>
<style lang="less"></style>
<template>
<el-dialog
width="52%"
id="cardCreate"
title="配置说明"
:visible.sync="show"
v-drag
append-to-body
>
<div class="configDescription">
<div class="cronHeaderTab">
<ul>
<li>
配置说明
</li>
<li>
示例
</li>
</ul>
</div>
<div class="cronMiddleWarp">
<ul>
<li class="cronMiddleWarpLi">
名称 : 可随意填写<br />
版本 : 可随意填写<br />
类路径 : 是所开发的组件的项目的包路径<br />
描述 : 这个组件的描述<br />
文件名称 : 组件开发后所install的jar包
</li>
<li class="cronMiddleWarpLi">
名称 : actionB<br />
版本 : 1.1<br />
类路径 : com.jonbore.actionb<br />
描述 : 这是一个例子<br />
文件名称 : 相应的jar包在页面下载附件中下载。
</li>
</ul>
</div>
</div>
<span slot="footer" class="dialog-footer"> </span>
</el-dialog>
</template>
<script>
// 构造函数
class Form {
constructor() {}
}
export default {
data() {
return {
show: false,
form: [],
rules: {}
};
},
methods: {
getPage() {
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
}
}
};
</script>
<style lang="less">
.configDescription {
position: relative;
background-color: #fff;
-webkit-background-clip: padding-box;
background-clip: padding-box;
border-radius: 6px;
outline: 0;
padding: 0 15px 15px 15px;
.cronHeaderTab {
margin-bottom: 25px;
ul {
width: 100%;
justify-content: space-between;
display: flex;
li {
text-align: center;
width: 50%;
font-weight: bold;
font-size: 16px;
}
}
}
.cronMiddleWarp ul {
width: 100%;
justify-content: space-between;
display: flex;
.cronMiddleWarpLi {
text-align: left;
width: 48%;
border: 1px solid #666666;
padding: 10px;
height: 200px;
overflow: auto;
}
}
}
</style>
<template>
<el-dialog
v-drag
title="编辑"
:visible.sync="show"
id="warehouse"
size="tiny"
width="70%"
:close-on-click-modal="false"
>
<el-collapse v-model="activeName" accordion>
<el-collapse-item name="1">
<template slot="title">
<div class="title">
<div></div>
<div>基本设置</div>
</div>
</template>
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="60px"
status-icon
id="warehouseForm"
>
<el-form-item label="名称" prop="name">
<el-input
show-word-limit
v-model="form.name"
placeholder="名称"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="50"
></el-input>
</el-form-item>
</el-form>
</el-collapse-item>
<el-collapse-item name="2">
<template slot="title">
<div class="title">
<div></div>
<div>请求参数设置</div>
</div>
</template>
<div class="template-tab" style="background:rgba(236,238,241,.67);padding:20px;">
<stms-api-design-bodys v-model="request.body"></stms-api-design-bodys>
</div>
</el-collapse-item>
<el-collapse-item name="3">
<template slot="title">
<div class="title">
<div></div>
<div>返回参数设置</div>
</div>
</template>
<div class="template-tab" style="background:rgba(236,238,241,.67);padding:20px;">
<stms-api-design-bodys v-model="response.body"></stms-api-design-bodys>
</div>
</el-collapse-item>
</el-collapse>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</el-dialog>
</template>
<script>
import {
create, // 新建
repeatTabName, // 查重
edit, // 编辑
} from './service';
class Form {
constructor(data={}) {
this.name = data.name;
this.paticipation = '';
this.returnValue = '';
this.description = data.description;
this.moduleId = '';
}
}
export default {
data() {
return {
show: false,
form: [],
activeName: '1',
rules: {
name: [
{
required: true,
message: '请输入名称',
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message,
},
],
},
datas: [],
request: {
body: {
type: "0",
param: []
}
},
response: {
body: {
type: "0",
param: []
},
},
};
},
methods: {
getPage(data) {
this.datas = data;
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
this.activeName = '1';
this.requestBackfill(); // 回填请求参数
this.responseBackfill(); // 返回参数回填
},
// 获取编辑请求参数
requestBackfill() {
if(JSON.parse(this.datas.paticipation)&&JSON.parse(this.datas.paticipation).type){
const {type,param} = JSON.parse(this.datas.paticipation)
this.request = {
body: {
type,
param
}
};
}
},
// 获取编辑请求参数
responseBackfill() {
if(JSON.parse(this.datas.returnValue)&&JSON.parse(this.datas.returnValue).type){
const {type,param} = JSON.parse(this.datas.returnValue)
this.response = {
body: {
type,
param
},
};
}
},
submit() {
this.$refs.form.validate((valid) => {
if (valid) {
this.show = false;
const obj = {
moduleId: this.$parent.jarNode.id,
paticipation: JSON.stringify(this.request.body),
returnValue:JSON.stringify(this.response.body),
description: this.form.description,
name: this.form.name,
id: this.datas.id,
};
edit(obj).then((res) => {
if (res.status == 'success') {
this.$message({
message: '编辑成功',
type: 'success',
});
} else {
this.$message({
message: res.message,
type: 'error',
});
}
this.$parent.queryData();
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less">
#warehouse .el-collapse {
border-top: 1px solid #fff !important;
border-bottom: 1px solid #fff !important;
}
#warehouse .title {
height: 60px;
display: flex;
align-items: center;
div:nth-of-type(1) {
width: 3px;
height: 30px;
background-color: #2395f1;
}
div:nth-of-type(2) {
font-size: 18px;
margin-left: 10px;
}
}
#warehouse .el-dialog__body {
padding: 10px 41px 0 35px !important;
#warehouseForm {
background: rgba(236, 238, 241, 0.67);
padding: 20px;
}
}
#warehouse .el-collapse-item__header {
border-bottom: 1px solid #fff !important;
border-top-color: #ffffff;
}
#warehouse .el-collapse-item__wrap {
border-bottom: 1px solid #ffff !important;
}
#warehouse .el-collapse-item__content {
padding-bottom: 0px !important;
}</style>
<template>
<div id="componentRepository">
<!-- 左侧树 -->
<iov-table-layout
:tree-data="treeData"
@tree-click="treeClick"
tree-title="组件分类"
:tree-value="selectNode"
v-if="treeData"
ref="layout"
:treeStyle="'list'"
>
<template slot="tool">
<el-button
type="primary"
title="新建"
icon="el-icon-plus"
@click="treeCreate_getPage"
></el-button>
<el-button
type="primary"
icon="el-icon-edit"
title="编辑"
@click="treeEdit_getPage"
:disabled="
!selectNode ||
(selectNode && selectNode.isRoot) ||
selectNode.level == 2
"
></el-button>
<el-button
type="primary"
icon="el-icon-delete"
@click="treeDelete_getPage"
title="删除"
:disabled="!selectNode || (selectNode && selectNode.isRoot)"
></el-button>
</template>
<!-- 右侧表格 -->
<div class="iov-content" slot="container">
<div class="center">
<div class="fileTop">
<div class="title">组件列表</div>
<div>
<el-button type="primary" size="small" @click="configDescription">
配置说明
</el-button>
<el-button
type="success"
size="small"
@click="jarCreate_getPage"
:disabled="!selectNode || (selectNode && selectNode.isRoot)"
>
上传
</el-button>
<el-button
size="small"
@click="deletJar"
:disabled="this.jarList.length == 0 || jarNode.enable == '1'"
>
删除
</el-button>
</div>
</div>
<div class="photoStyle">
<img
src="@/assets/images/img/unData.png"
v-if="this.jarList.length == 0"
/>
</div>
<div class="fileBottom" v-if="this.jarList.length > 0">
<div
class="fileContent"
v-for="item in jarList"
:key="item.id"
:class="{ active: jarNode.id == item.id }"
@click="jarClick(item)"
>
<div class="img"></div>
<div class="titleContent">
<div :title="item.name">{{ item.name }}/{{ item.version }}</div>
<div :title="item.path">{{ item.path }}</div>
<div :title="item.description">{{ item.description }}</div>
</div>
<div class="line">
<el-tooltip content="查看" placement="top">
<i class="el-icon-view" @click="check(item)"></i>
</el-tooltip>
<el-tooltip content="上线" placement="top">
<img
src="@/assets/images/img/offline.png"
@click="online"
v-if="item.enable == '2'"
style="margin-left:10px;"
/>
</el-tooltip>
<el-tooltip content="下线" placement="top">
<img
src="@/assets/images/img/online.png"
@click="offline"
v-if="item.enable == '1'"
style="margin-left:10px;"
/>
</el-tooltip>
</div>
</div>
</div>
</div>
<div class="iov-table right" v-if="table.tableData">
<div class="topTool">
<el-button
type="primary"
size="small"
@click="asyncAction"
:disabled="
!jarNode || jarNode.enable == '2' || jarList.length == 0
"
>
读取组件
</el-button>
<el-button type="success" size="small" @click="download">
下载基础框架
</el-button>
<el-input
show-word-limit
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
maxlength="50"
class="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
<div class="iov-table" v-if="table.tableData">
<iov-table
:table-data="table.tableData"
:table-option="table.option"
:table-loading="table.loading"
:total="table.pageTotal"
:pageSize="table.pageSize"
:pageChange="pageChange"
:sizeChange="sizeChange"
:pageNum="table.pageNum"
@selectChange="selectChange"
>
<el-table-column
fixed="right"
label="操作"
width="120"
v-if="table.tableData.length > 0"
slot="operationTool"
>
<template slot-scope="scope">
<el-button
@click.native.prevent="edit_getPage(scope.row)"
type="text"
size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="test_getPage(scope.row)"
type="text"
size="small"
:disabled="jarNode.enable == '2'"
>测试</el-button
>
</template>
</el-table-column>
</iov-table>
</div>
</div>
</div>
</iov-table-layout>
<!-- 左侧树新建 -->
<treeCreateForm ref="treeCreate_form"></treeCreateForm>
<!-- jar包新建 -->
<jarCreateForm ref="jarCreate_form"></jarCreateForm>
<!-- 左侧树编辑 -->
<treeEditForm ref="treeEdit_form"></treeEditForm>
<!-- 右侧编辑 -->
<editForm ref="edit_form" mode="edit"></editForm>
<!-- 测试 -->
<stms-api-design
ref="test_form"
:requestTool="requestTool"
></stms-api-design>
<!-- 组件仓库配置说明 -->
<configDescriptionFrom ref="configDescription_form"></configDescriptionFrom>
<check ref="check_form"></check>
</div>
</template>
<script>
// 引入Api
import {
queryData, // 表格
getTree, // 树
treeDelete, // 树删除
deleting, // 表格删除
jarDelete, // jar包删除
repeatJarName, // 获取Jar数据
online, // 上线
offline, // 下线
asyncActions, // 同步方法
download, //下载
} from "./service";
// 引入相关文件
import editForm from "./edit";
import treeCreateForm from "./treeCreate";
import treeEditForm from "./treeEdit";
import jarCreateForm from "./jarCreate";
import configDescriptionFrom from "./configDescription";
import check from "./check";
import data from "../../web-component/component/component-test/data";
export default {
// 组件注册
components: {
editForm,
treeCreateForm,
treeEditForm,
jarCreateForm,
configDescriptionFrom,
check,
},
mounted() {
this.getTree();
},
data() {
return {
jarList: [],
requestTool: [],
jarNode: null,
table: {
option: [
{
prop: "name",
label: "名称",
},
{
prop: "description",
label: "描述",
},
{
prop: "createDate",
label: "创建时间",
},
],
tableData: [],
loading: false,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
selectNode: "",
treeData: [],
jarPath: "",
disable: [],
};
},
methods: {
// 树查询
async getTree() {
let data = {
type: "common",
};
const res = await getTree(data);
if (res.status == "success") {
if (res.content.length > 0) {
this.treeData = res.content;
} else {
this.treeData = [];
}
} else {
this.treeData = [];
}
this.treeClick(res.content[0]);
},
// 点击分类
treeClick(item) {
this.selectNode = item;
if (this.selectNode.data) {
this.jarPath = this.selectNode.data.jarPath;
}
this.repeatJarName();
},
// 获取jar数据
async repeatJarName() {
const res = await repeatJarName({ typeId: this.selectNode.id });
if (res.status == "success") {
this.jarList = res.content;
if (this.jarList.length > 0) {
this.jarNode = this.jarList[0];
this.jarNode.id = this.jarList[0].id;
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
} else {
this.jarList = [];
}
if (this.jarNode) {
this.jarClick(this.jarNode);
}
},
jarClick(data) {
this.jarNode = data;
this.queryData();
},
// 删除jar
deletJar() {
__.ui.messageBox("此操作将永久删除该jar包, 是否继续?", () => {
jarDelete({
id: this.jarNode.id,
}).then((res) => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
}
this.repeatJarName();
});
});
},
// 表格查寻
async queryData() {
this.table.loading = false;
if (this.jarList != null && this.jarList.length > 0) {
const data = {
condition: {
keyword: this.searchData,
moduleId: this.jarNode.id,
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum,
};
const res = await queryData(data);
if (res.status == "success") {
this.table.tableData = res.content.rows || [];
this.table.pageTotal = res.content.total;
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
}
this.table.loading = false;
},
// 树新建
treeCreate_getPage() {
this.$refs.treeCreate_form.getPage();
},
// jar包新建
jarCreate_getPage() {
this.$refs.jarCreate_form.getPage();
},
//查看
check(data) {
this.$refs.check_form.getPage(data);
},
// 上线
online() {
__.ui.messageBox("此操作将此jar包上线, 是否继续?", () => {
const params = { id: this.jarNode.id };
online(params).then((res) => {
if (res.status == "success") {
this.$message({
message: "上线成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.repeatJarName();
});
});
},
// 下线
offline() {
__.ui.messageBox("此操作将此jar包下线, 是否继续?", () => {
const params = { id: this.jarNode.id };
offline(params).then((res) => {
if (res.status == "success") {
this.$message({
message: "下线成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.repeatJarName();
});
});
},
// 树编辑
treeEdit_getPage() {
this.$refs.treeEdit_form.getPage(this.selectNode);
},
test_getPage(data) {
var obj = {};
this.requestTool = ["body"];
obj = {
root: `http://${window.location.host}/design`,
requestBody: {
query: [],
headers: [],
body: {
type:
(data.paticipation && JSON.parse(data.paticipation).type) || "0",
param:
(data.paticipation && JSON.parse(data.paticipation).param) || [],
},
},
};
data.method = "POST"; //仅支持post
data.url = `/console/repomodulerestserver/executeAction/${this.jarNode.name}/${this.jarNode.version}/${data.name}`;
this.$refs.test_form.getPage(Object.assign(obj, data));
},
getReqData(req) {
if (req.requestBody.body.type === "4") {
var formdata = new FormData();
(req.requestBody.body.param || []).forEach((val) => {
formdata.append("file", val.file.raw);
});
}
return req.requestBody.body.type === "3"
? JSON.parse(req.requestBody.body.param)
: req.requestBody.body.type === "4"
? formdata
: (req.requestBody.body.param[0] &&
__.request.getBody(req.requestBody.body.param[0].children)) ||
{};
},
// 树删除(jar包删除)
treeDelete_getPage() {
__.ui.messageBox("此操作将永久删除该函数列表, 是否继续?", () => {
treeDelete({
ids: this.selectNode.id,
}).then((res) => {
console.log("删除组件111", res.message);
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "warning",
});
}
this.getTree();
});
});
},
// 搜索
search() {
this.queryData();
},
// 新建
asyncAction() {
this.asyncActions();
},
async asyncActions() {
const data = {
id: this.jarNode.id,
name: this.jarNode.name,
version: this.jarNode.version,
enable: this.jarNode.enable,
spackage: this.jarNode.spackage,
};
const res = await asyncActions(data);
if (res.status == "success") {
this.$message({
message: res.message,
type: "success",
});
this.queryData();
} else {
this.$message({
message: res.message,
type: "error",
});
}
},
// 下载
download() {
window.location.href =
window.location.origin +
"/design/console/repomodulerestserver/downloadFile";
},
// 编辑
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
//组件仓库配置
configDescription() {
this.$refs.configDescription_form.getPage();
},
pageChange(currentPage) {
this.table.pageNum = currentPage;
this.queryData();
},
sizeChange(size) {
this.table.pageSize = size;
this.queryData();
},
selectChange(data) {
this.mutiDeleteData = data;
},
// 删除
multiDelete(data) {
__.ui.messageBox("此操作将永久删除该函数, 是否继续?", () => {
deleting({
ids: data.id,
}).then((res) => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success",
});
} else {
this.$message({
message: res.message,
type: "error",
});
}
this.queryData();
});
});
},
},
};
</script>
<style lang="less">
#componentRepository {
.tapContainer {
display: none;
}
.undata {
margin: 10% 30%;
}
.photoStyle {
text-align: center;
margin-top: 20px;
}
.topTool {
height: 56px;
padding: 10px 20px 0;
position: relative;
.search {
width: 250px;
position: absolute;
right: 10px;
}
}
.iov-content {
width: 100%;
height: 100%;
display: flex;
flex-direction: inherit;
overflow: hidden;
.center {
width: 400px;
height: 100%;
border-right: 1px solid #d7e3f1;
.fileTop {
width: 100%;
display: flex;
height: 56px;
align-items: center;
padding: 0 15px;
justify-content: space-between;
}
.fileBottom {
width: 100%;
height: calc(100% - 56px);
overflow-y: auto;
.fileContent.active {
background: #5a6ce6;
color: #fff;
.titleContent {
div:nth-of-type(1) {
color: #fff;
}
div:nth-of-type(2) {
color: #fff;
}
div:nth-of-type(3) {
color: #fff;
}
}
.img {
width: 45px;
height: 51px;
line-height: 80px;
text-align: center;
background-image: url("~@/assets/images/img/activeJar.png");
margin: 0 18px;
}
}
.fileContent {
height: 90px;
width: 100%;
display: flex;
align-items: center;
background: rgba(255, 255, 255, 1);
border-top: 1px solid rgba(238, 238, 238, 1);
border-bottom: 1px solid rgba(238, 238, 238, 1);
position: relative;
.line {
position: absolute;
right: 10px;
top: 5px;
display: flex;
height: 15px;
img {
cursor: pointer;
}
}
.img {
width: 45px;
height: 51px;
line-height: 80px;
text-align: center;
background-image: url("~@/assets/images/img/jar.png");
margin: 0 18px;
}
.titleContent {
width: calc(100% - 100px);
div:nth-of-type(1) {
font-size: 14px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(74, 74, 74, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
div:nth-of-type(2) {
font-size: 10px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(102, 102, 102, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
div:nth-of-type(3) {
font-size: 12px;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: rgba(153, 153, 153, 1);
width: 100%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
}
}
}
}
.right {
padding: 0 0;
width: 0;
height: auto;
display: flex;
flex-direction: column;
.fileName {
width: 100%;
height: 56px;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(238, 238, 238, 1);
padding: 0 15px;
img {
margin-right: 10px;
}
}
.fileUrl {
width: 100%;
height: 35px;
display: flex;
align-items: center;
border-bottom: 1px solid rgba(238, 238, 238, 1);
padding: 0 15px;
margin-bottom: 5px;
img {
margin-right: 10px;
}
}
}
}
.item_simple {
margin: 10px 0 10px 10px;
width: 95%;
height: 100px;
border: 1px solid #dcdcdc;
border-left-width: 20px;
border-radius: 10px;
position: relative;
.item_list {
margin: 12px 34px;
width: 86%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.edit {
position: absolute;
right: 40px;
top: 5px;
font-size: 18px;
cursor: pointer;
}
.closeDelete {
position: absolute;
right: 8px;
top: 5px;
font-size: 18px;
cursor: pointer;
}
}
.item_simple:hover {
border-color: #d5e8f6;
box-shadow: 0 0 7px #d5e8f6;
}
}
</style>
<template>
<el-dialog title="上传" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="80px"
status-icon
>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="100"
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.file"
placeholder="文件名称"
disabled
class="fileStyle"
>
</el-input>
<el-upload
:before-upload="beforeUpload"
ref="upload"
:action="uploadUrl"
:on-success="create_upload"
:on-change="changeFile"
:auto-upload="false"
:data="form"
:show-file-list="false"
>
<el-button size="small" class="upload" icon="el-icon-upload" @click="clear"></el-button>
</el-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">上传</el-button>
</span>
</el-dialog>
</template>
<script>
import {repeatJarName, repeatNameLi} from "./service";
class Form {
constructor() {
this.file = "";
this.name = "";
this.version = "";
this.spackage = "";
this.description = "";
this.typeId = "";
this.fileName = "";
}
}
export default {
data() {
//名称查重
let nameVal = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入"));
} else if (this.form.version === "") {
callback();
} else {
repeatNameLi({
name: this.form.name,
version: this.form.version
}).then(res => {
if (res.content.length > 0) {
callback(new Error("该名称和版本已被使用"));
} else {
callback();
}
});
}
};
//版本查重
let versionVal = (rule, value, callback) => {
if (value === "") {
callback(new Error("请输入"));
} else if (this.form.name === "") {
callback();
} else {
repeatNameLi({
name: this.form.name,
version: this.form.version
}).then(res => {
if (res.content.length > 0) {
callback(new Error("该名称和版本已被使用"));
} else {
callback();
}
});
}
};
return {
show: false,
form: {},
rules: {
name: [
{
required: true,
message: "请输入"
},
{
validator: nameVal,
trigger: "blur"
},
{
pattern: __.validate.regular.nameEn.pattern,
message: __.validate.regular.nameEn.message
},
],
spackage: [
{
required: true,
message: "请输入类路径"
},
{
pattern: __.validate.regular.commonEn.pattern,
message: __.validate.regular.commonEn.message
}
],
version: [
{
required: true,
message: "请输入"
},
{
validator: versionVal,
trigger: "blur"
},
{
pattern: __.validate.regular.commonEn.pattern,
message: __.validate.regular.commonEn.message
}
],
file: [
{
required: true,
message: "请选择文件"
},
{
validator: __.validate.unique(repeatJarName)
}
]
},
uploadUrl: "/design/console/repomodulerestserver/uploadJar"
};
},
methods: {
getPage() {
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
beforeUpload(file) {
const Jar = file.name.toLowerCase().split(".");
if (Jar[Jar.length - 1] === "jar") {
return file;
}
this.$message.error("上传文件只能是 jar 格式!");
return false;
},
create_upload(response) {
if (response.status == "success") {
this.headerList = response.content;
this.$notify({
title: "成功",
message: response.message || "上传成功",
type: "success"
});
} else {
this.headerList = [];
this.$notify.error({
title: "失败",
message: response.message || "上传失败"
});
}
this.$parent.repeatJarName();
},
clear() {
this.$refs.upload.clearFiles();
},
changeFile(file, fileList) {
this.form.file = file.name;
this.form.fileName = file.name;
this.beforeUpload(file);
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
const jar = this.form.file.toLowerCase().split(".");
if (jar[jar.length - 1] === "jar") {
this.form.typeId = this.$parent.selectNode.id;
this.$refs.upload.submit();
this.show = false;
} else {
this.$message.error("上传文件只能是 jar 格式!");
}
} else {
return false;
}
});
}
}
};
</script>
<style lang="less">
.uploadParent {
position: relative;
.upload {
position: absolute;
top: 0;
right: 0;
}
.el-form-item__content {
div:nth-of-type(2) {
height: 3px;
}
}
}
</style>
import fetch from "@/utils/fetch";
// 左侧树
export const getTree = (data) =>
fetch("/design/console/repomoduletyperestserver/byCondition", data, "POST");
// 左侧列表新建
export const treeCreate = (data) =>
fetch("/design/console/repomoduletyperestserver/creating", data, "POST");
// 编辑
export const treeEdit = (data) =>
fetch("/design/console/repomoduletyperestserver/updating", data, "POST");
// 删除
export const treeDelete = (data) =>
fetch("/design/console/repomoduletyperestserver/deleting", data, "GET");
// 左侧列表查重
export const repeatName = (data) =>
fetch("/design/console/repomoduletyperestserver/byCondition", data, "POST");
// 表格查询
export const queryData = (data) =>
fetch("/design/console/repomoduleparmsrestserver/byPage", data, "POST");
export const create = (data) =>
fetch("/design/console/repomoduleparmsrestserver/creating", data, "POST");
export const edit = (data) =>
fetch("/design/console/repomoduleparmsrestserver/updating", data, "POST");
export const deleting = (data) =>
fetch("/design/console/repomoduleparmsrestserver/deleting", data, "GET");
export const repeatTabName = (data) =>
fetch("/design/console/repomoduleparmsrestserver/byCondition", data, "POST");
// jar包上传
export const uploadUrl = (data) =>
fetch("/design/console/repomodulerestserver/uploadJar", data, "POST");
// jar包查重
export const repeatJarName = (data) =>
fetch("/design/console/repomodulerestserver/byCondition", data, "POST");
//名称和版本查重
export const repeatNameLi = (data) =>
fetch("/design/console/repomodulerestserver/byCondition", data, "POST");
// jar包删除
export const jarDelete = (data) =>
fetch("/design/console/repomodulerestserver/deleteJar", data, "GET");
// jar上线
export const online = (data) =>
fetch("/design/console/repomodulerestserver/online", data, "GET");
// jar下线
export const offline = (data) =>
fetch("/design/console/repomodulerestserver/offline", data, "GET");
// 同步方法
export const asyncActions = (data) =>
fetch("/design/console/repomodulerestserver/getActions", data, "POST");
<template>
<!-- 新建表单 -->
<el-dialog v-drag title="新建" :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-dialog title="新建" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
......@@ -9,21 +8,11 @@
label-width="80px"
status-icon
>
<el-form-item label="中文名称" prop="nameCn">
<el-input
show-word-limit
v-model="form.nameCn"
placeholder="请输入中文名称"
maxlength="50"
></el-input>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="英文名称" prop="nameEn">
<el-input
show-word-limit
v-model="form.nameEn"
placeholder="请输入英文名称"
maxlength="50"
></el-input>
<el-form-item label="编码" prop="code">
<el-input show-word-limit v-model="form.code" placeholder="编码" maxlength="50"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
......@@ -31,62 +20,51 @@
</span>
</el-dialog>
</template>
<script>
// 引入接口
import { create, repeatTabName } from "./service";
import {
treeCreate, // 新建
repeatName // 查重
} from "./service";
// 构造函数
class Form {
constructor() {
this.nameCn = "";
this.nameEn = "";
this.aapId = "";
this.name = "";
this.code = "";
this.type = "common";
}
}
export default {
data() {
const nameCn = (rule, value, callback) => {
if (value) {
repeatTabName({
// 调用接口
nameCn: value
}).then(res => {
if (res.content.length > 0) {
callback(new Error("该中文名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false,
form: [],
form: {},
rules: {
nameEn: [
name: [
{
required: true,
message: "填写英文名称"
message: "输入名称"
},
{
pattern: /^[a-zA-Z]{1,50}$/,
message: "请输入纯英文"
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName),
trigger: "change"
}
],
nameCn: [
code: [
{
required: true,
message: "请输入中文名称"
message: "请输入编码"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: nameCn
validator: __.validate.unique(repeatName),
trigger: "change"
}
]
}
......@@ -100,13 +78,11 @@ export default {
}
this.show = true;
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.show = false;
this.form.appId = this.$parent.selectNode.id;
create(this.form).then(res => {
treeCreate(this.form).then(res => {
if (res.status == "success") {
this.$message({
message: "新建成功",
......@@ -118,7 +94,7 @@ export default {
type: "error"
});
}
this.$parent.queryData();
this.$parent.getTree();
});
} else {
return false;
......@@ -128,3 +104,5 @@ export default {
}
};
</script>
<style scoped></style>
<template>
<el-dialog title="编辑" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="80px"
status-icon
>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="编码" prop="code">
<el-input show-word-limit v-model="form.code" placeholder="编码" maxlength="50"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import {
treeEdit, // 编辑
repeatName // 查重
} from "./service";
class Form {
constructor(data = {}) {
this.id = data.id;
this.name = data.name;
this.code = data.code;
}
}
export default {
data() {
return {
show: false,
form: {},
rules: {}
};
},
methods: {
getPage(data) {
this.form = new Form(data);
this.rules = {
name: [
{
required: true,
message: "请输入名称"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName, this.form.id),
trigger: "change"
}
],
code: [
{
required: true,
message: "请输入编码"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
},
{
validator: __.validate.unique(repeatName, this.form.id),
trigger: "change"
}
]
};
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
submit() {
this.$refs.form.validate(valid => {
if (valid) {
this.show = false;
treeEdit(this.form).then(res => {
if (res.status == "success") {
this.$message({
message: "编辑成功",
type: "success"
});
} else {
this.$message({
message: res.message,
type: "error"
});
}
this.$parent.getTree();
});
} else {
return false;
}
});
}
}
};
</script>
<style scoped></style>
<template>
<stms-layout :options="options">
<div slot="content" class="rule">
<div class="tool">
<div class="template-tab">
<el-tabs class="elTabs" v-model="tableName">
<el-tab-pane label="预警规则" name="0"> </el-tab-pane>
<el-tab-pane label="参数定义" name="1"> </el-tab-pane>
</el-tabs>
</div>
</div>
<waring
v-if="tableName === '0'"
:selectNode="options.list.config.active"
:events="options.list.events"
/>
<params
v-if="tableName === '1'"
:selectNode="options.list.config.active"
:events="options.list.events"
/>
</div>
</stms-layout>
</template>
<script>
import options from "./options";
import params from "./param"; //参数定义
import waring from "./warning"; //规则预警
export default {
components: { params, waring },
data() {
return {
options,
tableName: "0"
};
}
};
</script>
<style lang="less" scoped>
.rule {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
}
</style>
import RepomoduletyperestserverDao from "@/dao/console/repomoduletyperestserver";
export default {
async queryRuleGroup({ component }) {
let list = [];
const resp = await RepomoduletyperestserverDao.findByAll({
data: {
type: "rule"
}
});
const {
data: { status, content }
} = resp;
if (status == "success") {
list = content;
}
console.log(component("list"))
component("list").action("setData", list);
component("list").action("setActive");
},
async createRuleGroup({ dispatch }, payload) {
await RepomoduletyperestserverDao.create({
data: {
type: "rule",
...payload
}
});
await dispatch("queryRuleGroup");
},
async editRuleGroup({ dispatch }, payload) {
await RepomoduletyperestserverDao.edit({
data: payload
});
await dispatch("queryRuleGroup");
},
async deleteRuleGroup({ dispatch }, payload) {
await RepomoduletyperestserverDao.delete({
params: payload
});
await dispatch("queryRuleGroup");
}
};
import * as URL from "@/config/url";
export default {
"config.data": [
{
name: "Java仓库",
path: URL.JAVA
},
{
name: "规则定义",
path: URL.JAVA_RULE
}
]
};
import breadcrumb from "./breadcrumb";
import list from "./list";
import action from "./action";
const solution = STUI.default.LayoutSolution.use("SingleCategoryTable");
solution.uninstall("table");
solution.bindAction(action);
solution.extends("breadcrumb", breadcrumb);
solution.extends("list", list);
console.log(solution.export());
export default solution.export();
import RepomoduletyperestserverDao from "@/dao/console/repomoduletyperestserver";
export default {
"config.title": "规则分类",
"config.toolbar.edit.disabled": ({ component }) => {
return !component("list").action("getActive");
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("list").action("getActive");
},
"events.init": async ({ dispatch }) => {
await dispatch("queryRuleGroup");
},
"events.toolbarClick/create": async ({ dispatch, modal }) => {
modal({
data: {},
title: "新建",
schema: [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写名称"
},
{
validator: (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
type: "rule"
};
RepomoduletyperestserverDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
},
trigger: "change"
}
]
},
{
prop: "code",
label: "编码",
type: "input",
props: {
placeholder: "请填写编码",
showWordLimit: true,
maxlength: 20
}
}
],
onConfirm: async ({ data, close }) => {
await dispatch("createRuleGroup", data);
await dispatch("queryRuleGroup");
close();
}
});
},
"events.toolbarClick/edit": async ({ dispatch, component, modal }) => {
const active = component("list").action("getActive");
modal({
data: active,
title: "编辑",
schema: [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写名称"
},
{
validator: (rule, value, callback) => {
if (value) {
const data = {
name: value,
type: "rule",
id: active.id
};
RepomoduletyperestserverDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && active.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
},
trigger: "change"
}
]
},
{
prop: "code",
label: "编码",
type: "input",
props: {
placeholder: "请填写编码",
showWordLimit: true,
maxlength: 20
}
}
],
onConfirm: async ({ data, close }) => {
await dispatch("editRuleGroup", data);
await dispatch("queryRuletGroup");
close();
}
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const active = component("list").action("getActive");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
onConfirm: async () => {
await dispatch("deleteRuleGroup", {
ids: active.id
});
await dispatch("queryRuleGroup");
}
});
}
};
<template>
<el-dialog title="上传" v-drag :visible.sync="show" size="tiny" :close-on-click-modal="false">
<el-form :model="form" :rules="rules" ref="form" label-width="80px" status-icon>
<el-form-item label="名称" prop="name">
<el-input show-word-limit v-model="form.name" placeholder="名称" maxlength="50"></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="100"
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.file"
placeholder="文件名称"
disabled
class="fileStyle"
>
</el-input>
<el-upload
:before-upload="beforeUpload"
ref="upload"
:action="uploadUrl"
:on-success="create_upload"
:on-change="changeFile"
:auto-upload="false"
:data="form"
:show-file-list="false"
>
<el-button size="small" class="upload" icon="el-icon-upload" @click="clear"></el-button>
</el-upload>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">上传</el-button>
</span>
</el-dialog>
</template>
<script>
import RepomodulerestserverDao from "@/dao/console/repomodulerestserver";
//构造表单
class Form {
constructor() {
this.file = "";
this.name = "";
this.version = "";
this.url = "";
this.spackage = "";
this.description = "";
this.typeId = "";
this.fileName = "";
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
typeId: this.$parent.selectNode.id
};
RepomodulerestserverDao.findByCondition({
data
}).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
rules: {
name: [
{
required: true,
message: "请输入"
},
{
validator: name,
trigger: "change"
}
],
url: [
{
required: true,
message: "请输入路径"
}
],
spackage: [
{
required: true,
message: "请输入类路径"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
}
],
version: [
{
required: true,
message: "请输入"
}
],
file: [
{
required: true,
message: "请选择文件"
}
]
},
uploadUrl: "/design/console/repomodulerestserver/uploadJar"
};
},
methods: {
//页面获取时
getPage(data) {
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
beforeUpload(file) {
const Jar = file.name.toLowerCase().split(".");
if (Jar[Jar.length - 1] === "jar") {
return file;
}
this.$message.error("上传文件只能是 jar 格式!");
return false;
},
create_upload(response) {
if (response.status == "success") {
this.headerList = response.content;
this.$notify({
title: "成功",
message: response.message || "上传成功",
type: "success"
});
} else {
this.headerList = [];
this.$notify.error({
title: "失败",
message: response.message || "上传失败"
});
}
this.$parent.getActionType();
},
clear() {
this.$refs.upload.clearFiles();
},
changeFile(file, fileList) {
this.form.file = file.name;
this.form.fileName = file.name;
this.beforeUpload(file);
},
//页面提交
submit() {
this.$refs.form.validate(valid => {
if (valid) {
const jar = this.form.file.toLowerCase().split(".");
if (jar[jar.length - 1] === "jar") {
this.form.typeId = this.$parent.selectNode.id;
this.$refs.upload.submit();
this.show = false;
} else {
this.$message.error("上传文件只能是 jar 格式!");
}
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="查看"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form
:model="form"
:rules="rules"
ref="form"
class="automargin"
label-width="80px"
status-icon
>
<el-form-item label="名称" prop="name">
<el-input
show-word-limit
v-model="form.name"
placeholder="名称"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="版本" prop="version">
<el-input
show-word-limit
v-model="form.version"
placeholder="版本"
maxlength="10"
disabled
></el-input>
</el-form-item>
<el-form-item label="类路径" prop="spackage">
<el-input
show-word-limit
v-model="form.spackage"
placeholder="类路径"
maxlength="50"
disabled
></el-input>
</el-form-item>
<el-form-item label="描述" prop="description">
<el-input
show-word-limit
type="textarea"
v-model="form.description"
placeholder="描述"
resize="none"
maxlength="100"
disabled
></el-input>
</el-form-item>
<el-form-item label="文件名称" prop="file" class="uploadParent">
<el-input
show-word-limit
v-model="form.fileName"
placeholder="文件名称"
disabled
class="fileStyle"
disabled
>
</el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<!-- <el-button type="primary" @click="submit()" disabled>确 定</el-button> -->
</span>
</el-dialog>
</template>
<script>
import RepomodulerestserverDao from "@/dao/console/repomodulerestserver";
//构造表单
class Form {
constructor(data = {}) {
this.id = data.id;
this.fileName = data.fileName;
this.name = data.name;
this.version = data.version;
this.spackage = data.spackage;
this.description = data.description;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
rules: {}
};
},
methods: {
//页面获取时
getPage(data) {
const { typeId } = data;
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
typeId: typeId
};
RepomodulerestserverDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && data.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
name: [
{
required: true,
message: "请输入"
},
{
validator: name,
trigger: "change"
}
],
url: [
{
required: true,
message: "请输入路径"
}
],
spackage: [
{
required: true,
message: "请输入类路径"
},
{
pattern: __.validate.regular.commonCn.pattern,
message: __.validate.regular.commonCn.message
}
],
version: [
{
required: true,
message: "请输入"
}
]
};
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
const data = this.form;
RepomodulerestserverDao.edit({ data }).then(res => {
this.$parent.getActionType();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<div class="rule-action">
<div class="rule-action-flex">
<iov-table-layout
:tree-data="actionList"
@tree-click="actionClick"
tree-title="组件列表"
:tree-value="selectAction"
:hideCrumb="true"
v-if="actionList"
ref="layout"
:treeStyle="'list'"
>
<template slot="tool">
<el-button
type="primary"
icon="el-icon-plus"
title="新建"
@click="actionCreate_getPage"
:disabled="!selectNode"
></el-button>
<el-button
type="primary"
icon="el-icon-delete"
@click="actionDelete_getPage"
:disabled="!selectAction"
></el-button>
<el-button
type="primary"
icon="el-icon-view"
@click="actionEdit_getPage"
:disabled="!selectAction"
></el-button>
<el-tooltip content="上线" placement="bottom">
<img
src="@/assets/images/img/offline.png"
@click="online"
v-show="selectAction && selectAction.enable === '2'"
class="line"
/>
</el-tooltip>
<el-tooltip content="下线" placement="bottom">
<img
src="@/assets/images/img/online.png"
@click="offline"
class="line"
v-show="selectAction && selectAction.enable === '1'"
/>
</el-tooltip>
</template>
<div class="iov-content" slot="container">
<div class="iov-tool">
<el-button
type="primary"
size="small"
@click="createAction"
:disabled="
!selectAction ||
selectAction.enable == '2' ||
actionList.length == 0
"
>
读取组件
</el-button>
<el-input
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
<div class="iov-table">
<stms-table
slot="content-flex"
full
:data="table.data"
:schema="table.option"
:loading="table.loading"
@selection-change="selectChange"
:pagination="{
pageNum: table.pageNum,
pageSize: table.pageSize,
total: table.pageTotal,
onChange: pageChange,
}"
>
<el-table-column label="操作" width="120" slot="end">
<template slot-scope="scope">
<el-button
@click.native.prevent="edit_getPage(scope.row)"
type="text"
size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="test(scope.row)"
type="text"
size="small"
:disabled="selectAction.enable == '2'"
>测试</el-button
>
</template>
</el-table-column>
</stms-table>
</div>
</div>
</iov-table-layout>
<createParentForm ref="createParent_form"></createParentForm>
<editParentForm ref="editParent_form"></editParentForm>
<!-- 右侧编辑 -->
<editForm ref="edit_form" mode="edit"></editForm>
<!-- 测试 -->
<stms-api-design
ref="test_form"
:requestTool="requestTool"
></stms-api-design>
</div>
</div>
</template>
<script>
import RepomodulerestserverDao from "@/dao/console/repomodulerestserver";
import RepomoduleparmsrestserverDao from "@/dao/console/repomoduleparmsrestserver";
import createParentForm from "./createParent";
import editParentForm from "./editParent";
import editForm from "../../../public/edit";
// import testForm from "../../../public/test";
export default {
props: ["selectNode", "events"],
//注册子组件
components: {
createParentForm,
editParentForm,
editForm,
// testForm,
},
mounted() {
this.$set(this.events, "change", ({}, data) => {
this.selectNode = data;
this.getActionType();
});
this.getActionType();
},
data() {
return {
actionList: [],
requestTool: [],
selectAction: null,
table: {
//表格数据
data: [],
option: [
{
prop: "name",
label: "名称",
},
{
prop: "description",
label: "描述",
},
{
prop: "createDate",
label: "创建时间",
},
],
loading: false,
pageTotal: null,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
};
},
methods: {
// 动作分类
async getActionType() {
let res = await RepomodulerestserverDao.findByAll({
data: { typeId: this.selectNode.id },
});
if (res.data.status == "success") {
this.actionList = res.data.content;
}
this.actionClick(res.data.content[0]);
},
actionClick(item) {
this.selectAction = item;
this.table.pageNum = 1;
this.table.pageSize = 10;
this.getAction();
},
actionCreate_getPage() {
this.$refs.createParent_form.getPage(this.selectNode);
},
actionEdit_getPage() {
this.$refs.editParent_form.getPage(this.selectAction);
},
actionDelete_getPage() {
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const params = { id: this.selectAction.id };
RepomodulerestserverDao.delete({ params }).then((res) => {
this.getActionType();
});
});
},
// 动作库表格数据
async getAction() {
try {
this.table.loading = true;
let res = await RepomoduleparmsrestserverDao.findByPage({
data: {
condition: {
moduleId: this.selectAction.id,
keyword: this.searchData,
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum,
},
});
const {
data: { status, content },
} = res;
if (status === "success") {
this.table.data = content.rows;
this.table.pageTotal = content.total;
}
this.table.loading = false;
} catch (error) {
this.table.data = [];
this.table.loading = false;
}
},
async createAction() {
const data = {
id: this.selectAction.id,
name: this.selectAction.name,
version: this.selectAction.version,
enable: this.selectAction.enable,
spackage: this.selectAction.spackage,
};
let res = await RepomodulerestserverDao.getActions({ data });
const {
data: { status, content },
} = res;
if (status === "success") {
this.getAction();
}
},
pageChange(pageNum, pageSize) {
this.table.pageNum = pageNum;
this.table.pageSize = pageSize;
this.getAction();
},
selectChange(data) {
this.mutiDeleteData = data.map((val) => val.id).join(",");
},
//搜索
search() {
this.table.pageNum = 1;
this.getAction();
},
// 上线
online() {
__.ui.messageBox("此操作将此jar包上线, 是否继续?", () => {
const params = { id: this.selectAction.id };
RepomodulerestserverDao.online({ params }).then((res) => {
this.getActionType();
});
});
},
// 下线
offline() {
__.ui.messageBox("此操作将此jar包下线, 是否继续?", () => {
const params = { id: this.selectAction.id };
RepomodulerestserverDao.offline({ params }).then((res) => {
this.getActionType();
});
});
},
// 编辑
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
// 测试
test(data) {
console.log(data);
var obj;
this.requestTool = ["body"];
obj = {
root: `http://${window.location.host}/design`,
requestBody: {
query: [],
headers: [],
body: {
type:
(data.paticipation && JSON.parse(data.paticipation).type) || "0",
param:
(data.paticipation && JSON.parse(data.paticipation).param) || [],
},
},
};
data.method = "POST"; //仅支持post
data.url = `/console/repomodulerestserver/executeAction/${this.selectAction.name}/${this.selectAction.version}/${data.name}`;
this.$refs.test_form.getPage(Object.assign(obj, data));
},
getReqData(req) {
if (req.requestBody.body.type === "4") {
var formdata = new FormData();
(req.requestBody.body.param || []).forEach((val) => {
formdata.append("file", val.file.raw);
});
}
return req.requestBody.body.type === "3"
? JSON.parse(req.requestBody.body.param)
: req.requestBody.body.type === "4"
? formdata
: (req.requestBody.body.param[0] &&
__.request.getBody(req.requestBody.body.param[0].children)) ||
{};
},
},
};
</script>
<style lang="less" scoped>
.rule-action {
height: 0;
flex: auto;
position: relative;
.rule-action-flex {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.line {
margin-left: 10px;
cursor: pointer;
}
.iov-tool {
padding: 10px 20px 6px;
}
.iov-table {
position: relative;
.full {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
}
}
}
</style>
<template>
<el-dialog
title="新建"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="标题" prop="name">
<el-input v-model="form.name" placeholder="请输入标题" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="值" prop="value">
<el-input v-model="form.value" placeholder="请输入值" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
<el-option
v-for="item in dataTypeList"
:label="item"
:value="item"
:key="item"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ConstantLibraryParamDao from "@/dao/develop/constant-library-param";
//构造表单
class Form {
constructor() {
this.name = ""; //名称为空
this.value = "";
this.type = "";
this.constantLibraryId = "";
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
constantLibraryId: this.constantLibrary.id
};
ConstantLibraryParamDao.findByCondition({
data
}).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
dataTypeList: [
"String",
"Integer",
"Date",
"Double",
// "Char",
// "Object",
// "Long",
// "Float",
"Boolean"
// "List",
// "Set",
// "Map",
// "Enum"
],
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
],
value: [
{
required: true,
message: "请输入值"
}
],
type: [
{
required: true,
message: "请选择类型"
}
]
},
constantLibrary: ""
};
},
methods: {
//页面获取时
getPage(data) {
this.constantLibrary = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
this.form.constantLibraryId = this.constantLibrary.id;
const data = this.form;
ConstantLibraryParamDao.create({ data }).then(res => {
this.$parent.getConstant();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="新建"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" maxlength="20"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ConstantLibraryDao from "@/dao/develop/constant-library";
//构造表单
class Form {
constructor() {
this.name = ""; //名称为空
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
ruleCategoryId: this.node.id
};
ConstantLibraryDao.findByCondition({
data
}).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
]
},
node: null
};
},
methods: {
//页面获取时
getPage(data) {
this.node = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
this.form.ruleCategoryId = this.node.id;
const data = this.form;
ConstantLibraryDao.create({ data }).then(res => {
this.$parent.getConstantType();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="编辑"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="标题" prop="name">
<el-input v-model="form.name" placeholder="请输入标题" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="值" prop="value">
<el-input v-model="form.value" placeholder="请输入值" maxlength="20"></el-input>
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
<el-option
v-for="item in dataTypeList"
:label="item"
:value="item"
:key="item"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ConstantLibraryParamDao from "@/dao/develop/constant-library-param";
//构造表单
class Form {
constructor(data) {
this.id = data.id;
this.name = data.name; //名称为空
this.value = data.value;
this.type = data.type;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
dataTypeList: [
"String",
"Integer",
"Date",
"Double",
// "Char",
// "Object",
// "Long",
// "Float",
"Boolean"
// "List",
// "Set",
// "Map",
// "Enum"
],
rules: {}
};
},
methods: {
//页面获取时
getPage(data) {
const { constantLibraryId } = data;
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
constantLibraryId: constantLibraryId
};
ConstantLibraryParamDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && data.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
],
value: [
{
required: true,
message: "请输入值"
}
],
type: [
{
required: true,
message: "请选择类型"
}
]
};
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
const data = this.form;
ConstantLibraryParamDao.edit({ data }).then(res => {
this.$parent.getConstant();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="编辑"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" maxlength="20"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ConstantLibraryDao from "@/dao/develop/constant-library";
//构造表单
class Form {
constructor(data = {}) {
this.id = data.id;
this.name = data.name; //名称为空
this.ruleCategoryId = data.ruleCategoryId;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
rules: {},
node: null
};
},
methods: {
//页面获取时
getPage(data) {
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
ruleCategoryId: this.form.ruleCategoryId
};
ConstantLibraryDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && data.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
]
};
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
const data = this.form;
ConstantLibraryDao.edit({ data }).then(res => {
this.$parent.getConstantType();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<div class="rule-constant">
<div class="rule-constant-flex">
<iov-table-layout
:tree-data="constantList"
@tree-click="constantClick"
tree-title="常量分类"
:tree-value="selectConstant"
:hideCrumb="true"
v-if="constantList"
ref="layout"
:treeStyle="'list'"
>
<template slot="tool">
<el-button
type="primary"
icon="el-icon-plus"
title="新建"
@click="constantCreate_getPage"
:disabled="!selectNode"
></el-button>
<el-button
type="primary"
icon="el-icon-edit"
@click="constantEdit_getPage"
:disabled="!selectConstant"
></el-button>
<el-button
type="primary"
icon="el-icon-delete"
@click="constantDelete_getPage"
:disabled="!selectConstant"
></el-button>
</template>
<div class="iov-content" slot="container">
<div class="iov-tool">
<el-button
type="primary"
size="small"
@click="create_getPage"
:disabled="!selectConstant"
>
新建
<i class="el-icon-circle-plus-outline el-icon--right"></i>
</el-button>
<el-input
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
<div class="iov-table">
<stms-table
slot="content-flex"
full
:data="table.data"
:schema="table.option"
:loading="table.loading"
@selection-change="selectChange"
:pagination="{
pageNum: table.pageNum,
pageSize: table.pageSize,
total: table.pageTotal,
onChange: pageChange,
}"
>
<el-table-column label="操作" width="120" slot="end">
<template slot-scope="scope">
<el-button
@click.native.prevent="edit_getPage(scope.row)"
type="text"
size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="multiDelete(scope.row)"
type="text"
size="small"
>删除</el-button
>
</template>
</el-table-column>
</stms-table>
</div>
</div>
</iov-table-layout>
<createParentForm ref="createParent_form"></createParentForm>
<editParentForm ref="editParent_form"></editParentForm>
<createForm ref="create_form"></createForm>
<editForm ref="edit_form"></editForm>
</div>
</div>
</template>
<script>
import ConstantLibraryDao from "@/dao/develop/constant-library";
import ConstantLibraryParamDao from "@/dao/develop/constant-library-param";
import createParentForm from "./createParent";
import editParentForm from "./editParent";
import createForm from "./create";
import editForm from "./edit";
export default {
props: ["selectNode", "events"],
//注册子组件
components: {
createParentForm,
editParentForm,
createForm,
editForm,
},
mounted() {
this.$set(this.events, "change", ({}, data) => {
this.selectNode = data;
this.getConstantType();
});
this.getConstantType();
},
data() {
return {
constantList: [],
selectConstant: null,
table: {
//表格数据
data: [],
option: [
{
prop: "name",
label: "常量标题",
},
{
prop: "value",
label: "常量值",
},
{
prop: "type",
label: "常量类型",
},
],
loading: false,
pageTotal: null,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
};
},
methods: {
// 参数库分类
async getConstantType() {
let res = await ConstantLibraryDao.findByAll({
data: { ruleCategoryId: this.selectNode.id },
});
if (res.data.status == "success") {
this.constantList = res.data.content;
}
this.constantClick(res.data.content[0]);
},
constantClick(item) {
this.selectConstant = item;
this.table.pageNum = 1;
this.table.pageSize = 10;
this.getConstant();
},
constantCreate_getPage() {
this.$refs.createParent_form.getPage(this.selectNode);
},
constantEdit_getPage() {
this.$refs.editParent_form.getPage(this.selectConstant);
},
constantDelete_getPage() {
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const params = { ids: this.selectConstant.id };
ConstantLibraryDao.delete({ params }).then((res) => {
this.getConstantType();
});
});
},
// 参数库表格数据
async getConstant() {
try {
this.table.loading = true;
let res = await ConstantLibraryParamDao.findByPage({
data: {
condition: {
constantLibraryId: this.selectConstant.id,
keyword: this.searchData,
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum,
},
});
const {
data: { status, content },
} = res;
if (status === "success") {
this.table.data = content.rows;
this.table.pageTotal = content.total;
}
this.table.loading = false;
} catch (error) {
this.table.data = [];
this.table.loading = false;
}
},
create_getPage() {
this.$refs.create_form.getPage(this.selectConstant);
},
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
multiDelete(data) {
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const params = { ids: data.id };
ConstantLibraryParamDao.delete({ params }).then((res) => {
this.getConstant();
});
});
},
pageChange(pageNum, pageSize) {
this.table.pageNum = pageNum;
this.table.pageSize = pageSize;
this.getConstant();
},
selectChange(data) {
this.mutiDeleteData = data.map((val) => val.id).join(",");
},
//搜索
search() {
this.table.pageNum = 1;
this.getConstant();
},
},
};
</script>
<style lang="less" scoped>
.rule-constant {
height: 0;
flex: auto;
position: relative;
.rule-constant-flex {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
height: 100%;
.iov-tool {
padding: 10px 20px 6px;
}
.iov-table {
position: relative;
.full {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
}
}
}
</style>
<template>
<div class="rule-param">
<div class="rule-param-flex">
<div slot="content" v-if="selectNode">
<div class="tool">
<div class="template-tab">
<el-tabs v-model="activeName">
<el-tab-pane label="参数库" name="0"> </el-tab-pane>
<el-tab-pane label="常量库" name="1"> </el-tab-pane>
<el-tab-pane label="动作库" name="2"> </el-tab-pane>
</el-tabs>
</div>
</div>
</div>
<variable
v-if="activeName === '0'"
:selectNode="selectNode"
:events="events"
/>
<constant
v-if="activeName === '1'"
:selectNode="selectNode"
:events="events"
/>
<action
v-if="activeName === '2'"
:selectNode="selectNode"
:events="events"
/>
</div>
</div>
</template>
<script>
import constant from "./constant"; //常量库
import variable from "./variable"; //参数库
import action from "./action"; //动作库
export default {
props: ["selectNode", "events"],
components: { constant, variable, action },
mounted() {},
data() {
return {
activeName: "0",
};
},
methods: {},
};
</script>
<style lang="less">
.rule-param {
overflow: hidden;
height: 0;
flex: auto;
position: relative;
.rule-param-flex {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
display: flex;
flex-direction: column;
}
.el-tabs__header {
margin: 0;
}
}
</style>
<template>
<el-dialog
title="新建"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="参数名称" prop="name">
<el-input v-model="form.name" placeholder="请输入参数名称" maxlength="20"></el-input>
</el-form-item>
<!-- <el-form-item label="中文名称" prop="value">
<el-input v-model="form.value" placeholder="请输入中文名称" maxlength="20"></el-input>
</el-form-item> -->
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
<el-option
v-for="item in dataTypeList"
:label="item"
:value="item"
:key="item"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ParameterLibraryParamDao from "@/dao/develop/parameter-library-param";
//构造表单
class Form {
constructor(data) {
this.name = "";
// this.value = "";
this.type = "";
this.parameterLibraryId = "";
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
parameterLibraryId: this.parameterLibrary.id
};
ParameterLibraryParamDao.findByCondition({
data
}).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
dataTypeList: [
"String",
"Integer",
"Date",
"Double",
// "Char",
// "Object",
// "Long",
// "Float",
"Boolean"
// "List",
// "Set",
// "Map",
// "Enum"
],
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
],
label: [
{
required: true,
message: "请输入中文名称"
}
],
type: [
{
required: true,
message: "请选择类型"
}
]
},
parameterLibrary: ""
};
},
methods: {
//页面获取时
getPage(data) {
this.parameterLibrary = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
this.form.parameterLibraryId = this.parameterLibrary.id;
const data = this.form;
ParameterLibraryParamDao.create({ data }).then(res => {
this.$parent.getVariable();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="新建"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" maxlength="20"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
//构造表单
class Form {
constructor() {
this.name = ""; //名称为空
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
ruleCategoryId: this.node.id
};
ParameterLibraryDao.findByCondition({
data
}).then(res => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
]
},
node: null
};
},
methods: {
//页面获取时
getPage(data) {
this.node = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
this.form.ruleCategoryId = this.node.id;
const data = this.form;
ParameterLibraryDao.create({ data }).then(res => {
this.$parent.getVariableType();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="编辑"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="参数名称" prop="name">
<el-input v-model="form.name" placeholder="请输入参数名称" maxlength="20"></el-input>
</el-form-item>
<!-- <el-form-item label="中文名称" prop="label">
<el-input v-model="form.label" placeholder="请输入中文名称" maxlength="20"></el-input>
</el-form-item> -->
<el-form-item label="类型" prop="type">
<el-select v-model="form.type" placeholder="请选择类型" style="width:100%">
<el-option
v-for="item in dataTypeList"
:label="item"
:value="item"
:key="item"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ParameterLibraryParamDao from "@/dao/develop/parameter-library-param";
//构造表单
class Form {
constructor(data) {
this.id = data.id;
// this.label = data.label;
this.name = data.name;
this.type = data.type;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
dataTypeList: [
"String",
"Integer",
"Date",
"Double",
// "Char",
// "Object",
// "Long",
// "Float",
"Boolean"
// "List",
// "Set",
// "Map",
// "Enum"
],
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
}
// {
// validator: name
// }
],
label: [
{
required: true,
message: "请输入中文名称"
}
],
type: [
{
required: true,
message: "请选择类型"
}
]
},
parameterLibrary: ""
};
},
methods: {
//页面获取时
getPage(data) {
const { parameterLibraryId } = data;
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
parameterLibraryId: parameterLibraryId
};
ParameterLibraryParamDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && data.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
//表单校验规则
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
],
label: [
{
required: true,
message: "请输入中文名称"
}
],
type: [
{
required: true,
message: "请选择类型"
}
]
};
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
const data = this.form;
ParameterLibraryParamDao.edit({ data }).then(res => {
this.$parent.getVariable();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="编辑"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
id="formStyle"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input v-model="form.name" placeholder="请输入名称" maxlength="20"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
//构造表单
class Form {
constructor(data = {}) {
this.id = data.id;
this.name = data.name; //名称为空
this.ruleCategoryId = data.ruleCategoryId;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
rules: {},
node: null
};
},
methods: {
//页面获取时
getPage(data) {
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
console.log(data.id);
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
ruleCategoryId: this.form.ruleCategoryId
};
ParameterLibraryDao.findByCondition({ data }).then(res => {
if (res.data.content.length > 0 && data.id != res.data.content[0].id) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
name: [
{
required: true,
message: "请输入名称"
},
{
validator: name,
trigger: "change"
}
]
};
},
//页面提交
submit() {
this.$refs["form"].validate(valid => {
if (valid) {
this.show = false;
const data = this.form;
ParameterLibraryDao.edit({ data }).then(res => {
this.$parent.getVariableType();
});
} else {
return false;
}
});
}
}
};
</script>
<style lang="less" scoped></style>
<template>
<div class="rule-variable">
<div class="rule-variable-flex">
<iov-table-layout
:tree-data="variableList"
@tree-click="variableClick"
tree-title="参数分类"
:tree-value="selectVariable"
:hideCrumb="true"
v-if="variableList"
ref="layout"
:treeStyle="'list'"
>
<template slot="tool">
<el-button
type="primary"
icon="el-icon-plus"
title="新建"
@click="variableCreate_getPage"
:disabled="!selectNode"
></el-button>
<el-button
type="primary"
icon="el-icon-edit"
@click="variableEdit_getPage"
:disabled="!selectVariable"
></el-button>
<el-button
type="primary"
icon="el-icon-delete"
@click="variableDelete_getPage"
:disabled="!selectVariable"
></el-button>
</template>
<div class="iov-content" slot="container">
<div class="iov-tool">
<el-button
type="primary"
size="small"
@click="create_getPage"
:disabled="!selectVariable"
>
新建条件
<i class="el-icon-circle-plus-outline el-icon--right"></i>
</el-button>
<el-input
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
<div class="iov-table">
<stms-table
slot="content-flex"
full
:data="table.data"
:schema="table.option"
:loading="table.loading"
@selection-change="selectChange"
:pagination="{
pageNum: table.pageNum,
pageSize: table.pageSize,
total: table.pageTotal,
onChange: pageChange,
}"
>
<el-table-column label="操作" width="120" slot="end">
<template slot-scope="scope">
<el-button
@click.native.prevent="edit_getPage(scope.row)"
type="text"
size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="multiDelete(scope.row)"
type="text"
size="small"
>删除</el-button
>
</template>
</el-table-column>
</stms-table>
</div>
</div>
</iov-table-layout>
<createParentForm ref="createParent_form"></createParentForm>
<editParentForm ref="editParent_form"></editParentForm>
<createForm ref="create_form"></createForm>
<editForm ref="edit_form"></editForm>
</div>
</div>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import ParameterLibraryParamDao from "@/dao/develop/parameter-library-param";
import createParentForm from "./createParent";
import editParentForm from "./editParent";
import createForm from "./create";
import editForm from "./edit";
export default {
props: ["selectNode", "events"],
//注册子组件
components: {
createParentForm,
editParentForm,
createForm,
editForm,
},
mounted() {
this.$set(this.events, "change", ({}, data) => {
this.selectNode = data;
this.getVariableType();
});
this.getVariableType();
},
data() {
return {
variableList: [],
selectVariable: null,
table: {
//表格数据
data: [],
option: [
{
prop: "name",
label: "参数名称",
},
// {
// prop: "label",
// label: "参数标题"
// },
{
prop: "type",
label: "参数类型",
},
],
loading: false,
pageTotal: null,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
};
},
methods: {
// 参数库分类
async getVariableType() {
let res = await ParameterLibraryDao.findByAll({
data: {
ruleCategoryId: this.selectNode.id,
},
});
if (res.data.status == "success") {
this.variableList = res.data.content;
}
this.variableClick(res.data.content[0]);
},
variableClick(item) {
this.selectVariable = item;
this.table.pageNum = 1;
this.table.pageSize = 10;
this.getVariable();
},
variableCreate_getPage() {
this.$refs.createParent_form.getPage(this.selectNode);
},
variableEdit_getPage() {
this.$refs.editParent_form.getPage(this.selectVariable);
},
variableDelete_getPage() {
console.log(this.selectVariable);
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const params = { ids: this.selectVariable.id };
ParameterLibraryDao.delete({ params }).then((res) => {
this.getVariableType();
});
});
},
// 参数库表格数据
async getVariable() {
try {
this.table.loading = true;
let res = await ParameterLibraryParamDao.finByPage({
data: {
condition: {
parameterLibraryId: this.selectVariable.id,
keyword: this.searchData,
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum,
},
});
const {
data: { status, content },
} = res;
if (status === "success") {
this.table.data = content.rows;
this.table.pageTotal = content.total;
}
this.table.loading = false;
} catch (error) {
this.table.data = [];
this.table.loading = false;
}
},
create_getPage() {
this.$refs.create_form.getPage(this.selectVariable);
},
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
multiDelete(data) {
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const params = { ids: data.id };
ParameterLibraryParamDao.delete({ params }).then((res) => {
this.getVariable();
});
});
},
pageChange(pageNum, pageSize) {
this.table.pageNum = pageNum;
this.table.pageSize = pageSize;
this.getVariable();
},
selectChange(data) {
this.mutiDeleteData = data.map((val) => val.id).join(",");
},
//搜索
search() {
this.table.pageNum = 1;
this.getVariable();
},
},
};
</script>
<style lang="less" scoped>
.rule-variable {
height: 0;
flex: auto;
position: relative;
.rule-variable-flex {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.iov-tool {
padding: 10px 20px 6px;
}
.iov-table {
position: relative;
.full {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
padding: 10px;
}
}
}
</style>
<template>
<el-dialog
title="新建"
:visible.sync="show"
v-drag
:close-on-click-modal="false"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input
v-model="form.name"
placeholder="名称"
maxlength="20"
></el-input>
</el-form-item>
<el-form-item label="类型" prop="ruleType">
<el-select
v-model="form.ruleType"
placeholder="请选择类型"
style="width:100%"
>
<el-option
v-for="item in ruleTypeList"
:label="item.name"
:value="item.id"
:key="item.id"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import RuleScriptDao from "@/dao/develop/rule-script";
//构造表单
class Form {
constructor() {
this.name = ""; //名称为空
this.published = "2";
}
}
export default {
data() {
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
ruleCategoryId: this.ruleCategory.id,
};
RuleScriptDao.findByCondition({
data,
}).then((res) => {
if (res.data.content.length > 0) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
return {
show: false, //显示外层对话框
form: {},
ruleTypeList: [
{
name: "决策集",
id: "RuleSet",
},
{
name: "决策表",
id: "Table",
},
],
rules: {
//表单校验规则
name: [
{
required: true,
message: "请输入名称",
},
{
validator: name,
trigger: "change",
},
],
ruleType: [
{
required: true,
message: "请选择类型",
},
],
},
ruleCategory: null,
};
},
methods: {
//页面获取时
getPage(data) {
this.ruleCategory = data;
this.form = new Form();
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
this.show = false;
this.form.ruleCategoryId = this.ruleCategory.id;
const data = this.form;
RuleScriptDao.create({ data }).then((res) => {
this.$parent.queryData();
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less" scoped></style>
<template>
<el-dialog
title="变量赋值配置"
:visible.sync="innerVisible"
:close-on-click-modal="false"
v-if="innerVisible"
:destroy-on-close="true"
width="80%"
height="100"
id="assignment"
append-to-body
>
<div class="config-page" style="display:flex;">
<div id="selectStyle" class="placeholderValue">
<el-select
style="width: 120px;"
v-model="data.valueType"
placeholder="请选择值类型"
@change="valueParameterChange(...arguments, data)"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
ref="method"
v-if="data.valueType == 'Method'"
:data="data"
:ruleCategoryId="ruleCategoryId"
></method>
<!-- 参数数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Parameter'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
@change="paramChange(...arguments, 'Parameter', data)"
></el-cascader>
</div>
<!-- 常量数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Constant'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="constantList"
@change="paramChange(...arguments, 'Constant', data)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
></el-cascader>
</div>
<!-- 输入框数据 -->
<el-input
style="width: 120px;"
v-if="data.valueType == 'Input'"
v-model="data.content"
class="contentInput"
></el-input>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import ConstantLibraryDao from "@/dao/develop/constant-library";
import method from "./method";
import params from "./params";
import { param, constant } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
props: ["data", "ruleCategoryId"],
components: { params, method },
data() {
return {
//值类型
dataTypeList,
innerVisible: false, //显示外层对话框
constantList: [],
keyList: []
};
},
computed: {},
mounted() {
this.getVariable();
this.getConstant();
},
methods: {
//页面获取时
getPage() {
this.innerVisible = true;
},
//参数赋值下拉选值
valueParameterChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
//右侧选择参数数据传值
paramChange(value, type, node) {
if (type == "Parameter") {
param(value, node, this.keyList);
} else if (type == "Constant") {
constant(value, node, this.constantList);
}
},
submit() {
this.innerVisible = false;
this.$emit("changeTableData", this.data, "Assignment");
}
}
};
</script>
<style lang="less" scoped>
.config-page {
width: 100%;
height: 100px;
background: #fff;
overflow: scroll;
white-space: nowrap;
align-items: center;
padding: 0 10px;
}
</style>
<template>
<el-dialog
title="条件配置"
:visible.sync="innerVisible"
:close-on-click-modal="false"
v-if="innerVisible"
:destroy-on-close="true"
width="80%"
height="500"
id="conditionConfig"
append-to-body
>
<div class="treeScroll">
<div class="banner">
<el-tree
id="ruleTree"
:data="list"
node-key="treeId"
:default-expand-all="true"
:expand-on-click-node="false"
:props="defaultProps"
>
<div slot-scope="{ node, data }">
<!-- 或者,并且,添加条件 -->
<el-select
v-if="data.treeType == 'parent'"
v-model="data.junctionType"
class="parentBtn"
@change="conditionChangeTree(data, list, node)"
>
<el-option
v-for="item in typeList"
:key="item.id"
:label="item.name"
:value="item.type"
></el-option>
</el-select>
<div class="childrenContent" v-if="data.treeType == 'children'">
<!-- 中间 比较符 -->
<div class="placeholder">
<el-select v-model="data.op" placeholder="请选择比较操作符">
<el-option
v-for="item in conditionList"
:key="item.id"
:label="item.name"
:value="item.type"
></el-option>
</el-select>
</div>
<!-- 选择参数 -->
<params
ref="method"
v-if="data.op != ''"
:data="data.value"
:ruleCategoryId="ruleCategoryId"
></params>
<!-- 当行的删除按钮 -->
<el-button
v-if="data.treeType == 'children'"
@click="() => remove(node, data)"
type="text"
icon="el-icon-delete"
></el-button>
</div>
</div>
</el-tree>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import method from "./method";
import params from "./params";
import { typeList, conditionList } from "../util/data";
export default {
props: ["jointdata", "ruleCategoryId"],
components: { params, method },
data() {
return {
//比较符
conditionList,
//下拉条件选择
typeList: typeList.filter(val => {
return val.id !== "4";
}),
innerVisible: false, //显示外层对话框
defaultProps: {
//树转换数据
label: "name",
children: "conditions"
},
arr: [] //下拉框选择
};
},
computed: {
list() {
// 单元格条件配置传递过来的数据
return [this.jointdata];
}
},
methods: {
//页面获取时
getPage() {
this.innerVisible = true;
},
// 添加条件
conditionChangeTree(data, all, node) {
if (!data.conditions) {
this.$set(data, "conditions", []);
}
this.arr.push(data.junctionType);
this.arr = this.arr.filter(val => val != "Criteria"); //过滤添加条件
this.filterFile = this.arr;
// 添加条件
if (data.junctionType == "Criteria") {
let obj = {
op: "",
opName: "",
value: {
arithmetic: "",
valueType: "",
paramName: "",
paramLabel: "",
paramLibName: "",
paramLibLabel: "",
paramLibId: "",
paramId: "",
datatype: "",
parameters: []
},
// 自用
treeType: "children",
treeId: this.getMaxId(all),
treeParentId: data.treeId,
criterionType: "Or",
junctionType: null
};
data.conditions.push(obj);
if (this.filterFile.length == 0) {
data.junctionType = "Or";
} else {
data.junctionType = this.filterFile.pop();
}
}
Vue.set(data, "conditions", data.conditions); // 保证修改数组视图渲染
},
// 删除条件
remove(node, data) {
const parent = node.parent;
const children = parent.data.conditions || parent.data;
const index = children.findIndex(d => d.treeId === data.treeId);
children.splice(index, 1);
},
// 计算请求参数节点最大id
getMaxId(nodes, id = 1) {
return nodes.reduce(
(result, item) =>
item.conditions && item.conditions.length > 0
? this.getMaxId(item.conditions, result)
: result > item.id
? result
: item.treeId + 1,
id
);
},
submit() {
this.innerVisible = false;
this.list[0].conditions.forEach(element => {
this.conditionList.forEach(item => {
if (element.op == item.type) {
element.opName = item.name;
}
});
});
this.$emit("changeTableData", this.list, "Criteria");
}
}
};
</script>
<style lang="less" scoped>
#conditionConfig {
/deep/.el-input--suffix .el-input__inner {
padding-left: 2px;
padding-right: 28px;
}
.treeScroll {
width: 100%;
height: 500px;
background: #fff;
overflow: scroll;
white-space: nowrap;
.banner {
display: inline-block;
}
#ruleTree {
width: 100%;
padding-top: 3px;
.parentBtn {
width: 80px;
}
.placeholder {
width: 120px;
}
.contentInput {
width: 250px;
}
.el-select {
// width: 100px;
}
.el-cascader {
width: 200px;
}
.childrenContent {
display: flex;
.methodContent {
display: flex;
}
}
/deep/.el-tree-node__content {
height: 40px;
margin: 5px 0;
background: #fff;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
.el-tree__empty-block {
display: none;
}
}
}
}
</style>
<template>
<el-dialog
title="执行方法配置"
:visible.sync="innerVisible"
:close-on-click-modal="false"
v-if="innerVisible"
:destroy-on-close="true"
width="80%"
height="500"
id="executeMethod"
append-to-body
>
<div class="config-page" style="display:flex;">
<!-- 左侧选择方法 -->
<div id="selectStyle" class="actionValueStyle">
<el-cascader
style="width: 120px;"
placeholder="请选择方法"
:options="methodList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
:show-all-levels="false"
@change="methodChange(...arguments, data)"
v-model="data.beanNames"
></el-cascader>
</div>
<!-- 选择方法 右侧选择方法 -->
<div class="methodData" v-for="val in data.parameters" :key="val.id">
<div>{{ val.label }}</div>
<div>:</div>
<div id="selectStyle" v-if="val.value" class="placeholderValue">
<el-select
style="width: 120px;"
v-model="val.value.valueType"
@change="valueChange(...arguments, data, val)"
placeholder="请选择值类型"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
:ruleCategoryId="ruleCategoryId"
v-if="val.value.valueType == 'Method'"
:data="val.value"
></method>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Parameter'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
@change="paramChangeMehod(...arguments, data, val.value)"
></el-cascader>
</div>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Constant'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="constantList"
@change="paramChangeMehod(...arguments, data, val.value)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
></el-cascader>
</div>
<el-input
style="width: 120px;"
v-if="val.value.valueType == 'Input'"
v-model="val.value.content"
class="contentInput"
></el-input>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import RepomoduletyperestserverDao from "@/dao/console/repomoduletyperestserver";
import ConstantLibraryDao from "@/dao/develop/constant-library";
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import method from "./method";
import params from "./params";
import { param, constant, methods } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
props: ["data", "ruleCategoryId"],
components: { params, method },
data() {
return {
//值类型
dataTypeList,
innerVisible: false, //显示外层对话框
methodList: [],
constantList: [],
keyList: []
};
},
computed: {},
mounted() {
this.getMethod();
this.getVariable();
this.getConstant();
},
methods: {
//页面获取时
getPage() {
this.innerVisible = true;
},
async getMethod() {
let res = await RepomoduletyperestserverDao.getMethod({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.methodList = content;
}
},
//方法下拉选值
valueChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
} else {
this.getMethod();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 方法传参
methodChange(value, data) {
methods(value, data, this.methodList);
},
//右侧方法传参
paramChangeMehod(value, data, node) {
if (node.valueType == "Parameter") {
param(value, node, this.keyList);
}
if (node.valueType == "Constant") {
constant(value, node, this.constantList);
}
},
submit() {
this.innerVisible = false;
this.$emit("changeTableData", this.data, "ExecuteMethod");
}
}
};
</script>
<style lang="less" scoped>
.config-page {
width: 100%;
height: 100px;
background: #fff;
overflow: scroll;
white-space: nowrap;
align-items: center;
padding: 0 10px;
}
</style>
<template>
<el-dialog
title="决策表"
:visible.sync="show"
:close-on-click-modal="false"
v-if="show"
:destroy-on-close="true"
:fullscreen="true"
id="ruleDefine"
>
<!-- 顶部操作列 -->
<div class="operation">
<el-button type="primary" icon="el-icon-plus" @click="addItemDataRow()">添加条件行</el-button>
<el-button type="danger" icon="el-icon-delete" @click="deleteItemDataRow()"
>删除条件行</el-button
>
</div>
<div class="operation">
<el-popover placement="bottom" width="240" trigger="click">
<el-button type="primary" icon="el-icon-plus" slot="reference">添加属性</el-button>
<el-select v-model="propType" @change="selectPropType" placeholder="请选择">
<el-option
v-for="item in propOptions"
:key="item.value"
:label="item.label"
:value="item.value"
></el-option>
</el-select>
</el-popover>
<!-- 添加的属性 -->
<div class="prop-list" v-if="showSalience || form.salience">
<span>优先级:</span>
<el-input
style="width:220px; height:28px;"
placeholder="请输入优先级"
v-model="form.salience"
></el-input>
<i class="el-icon-delete" @click.stop="hideSalience"></i>
</div>
<div class="prop-list" v-if="showEffectiveDate || form.effectiveDate">
<span>生效日期:</span>
<el-date-picker
style="width:220px; height:28px;"
v-model="form.effectiveDate"
type="datetime"
placeholder="请选择生效日期"
></el-date-picker>
<i class="el-icon-delete" @click.stop="hideEffectiveDate"></i>
</div>
<div class="prop-list" v-if="showExpiresDate || form.expiresDate">
<span>失效日期:</span>
<el-date-picker
style="width:220px; height:28px;"
v-model="form.expiresDate"
type="datetime"
placeholder="请选择失效日期"
></el-date-picker>
<i class="el-icon-delete" @click.stop="hideExpiresDate"></i>
</div>
</div>
<div class="main-table">
<table>
<thead>
<tr>
<th v-for="(item, index) in table.columns" :key="index">
<span class="border-icon">&nbsp;</span>
<el-popover placement="bottom" width="240" trigger="click">
<div slot="reference" @contextmenu.prevent="showConditionOperation(item)">
<i v-if="item.columnType == 'Criteria'" class="el-icon-s-tools"></i>
<i v-if="item.columnType == 'ExecuteMethod'" class="el-icon-s-flag"></i>
<i v-if="item.columnType == 'Assignment'" class="el-icon-s-operation"></i>
<span>{{ item.paramLibLabel }}/{{ item.paramLabel }}</span>
</div>
<!-- 条件的事件 -->
<el-cascader
ref="cascadercondition"
v-if="item.columnType == 'Criteria'"
v-model="item.cascaderValue"
:options="conditionOperationShow"
@change="selectCondition(item.cascaderValue, item, index)"
clearable
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
></el-cascader>
<!-- 动作和方法的事件 -->
<el-cascader
v-else
clearable
ref="cascadercondition"
v-model="item.cascaderValue"
:options="actionOperationShow"
@change="selectCondition(item.cascaderValue, item, index)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
></el-cascader>
</el-popover>
</th>
</tr>
</thead>
<tbody>
<tr
v-for="(item, index) in table.tableData"
:key="index"
:class="currentIndex == index ? 'showTr' : 'hideTr'"
>
<td v-for="(val, num) in item" :key="num">
<!-- 条件 -->
<div
class="table-item"
style="height:100%; width:100%; position: relative; paddingRight: 16px;"
@click.stop="selectItem(index, val)"
>
<div class="configIcon">
<el-popover placement="bottom" width="240" trigger="click">
<i @click.stop slot="reference" class="el-icon-setting"></i>
<el-select
v-if="val.columnType === 'Criteria'"
value-key="id"
v-model="val.cascaderValue"
clearable
@change="selectTableData(val.cascaderValue, index, num, val)"
>
<el-option
v-for="item in tableOperation"
:key="item.id"
:label="item.name"
:value="item"
></el-option>
</el-select>
<el-select
v-else
value-key="id"
v-model="val.cascaderValue"
clearable
@change="selectTableData(val.cascaderValue, index, num, val)"
>
<el-option
v-for="item in tableOperationResule"
:key="item.id"
:label="item.name"
:value="item"
></el-option>
</el-select>
</el-popover>
</div>
<!-- 条件 -->
<div v-if="val.columnType == 'Criteria' && val.joint">
<span v-for="(conditionsItem, i) in val.joint.conditions" :key="i">
<span
class="junction-type-red"
v-if="
i % 2 != 0 &&
val.joint &&
val.joint.junctionType &&
val.joint.junctionType == 'And'
"
>并且</span
>
<span
class="junction-type-green"
v-if="
i % 2 != 0 &&
val.joint &&
val.joint.junctionType &&
val.joint.junctionType == 'Or'
"
>或者</span
>
<!-- 占位符 -->
<span class="placeholder">{{ conditionsItem.opName }}</span>
<!-- 输入框 Input-->
<span v-if="conditionsItem.value.valueType == 'Input'">{{
conditionsItem.value.content
}}</span>
<!-- 常量 Constant -->
<span v-if="conditionsItem.value.valueType == 'Constant'">{{
conditionsItem.value.constantLabel
}}</span>
<!-- 参数 Parameter -->
<span v-if="conditionsItem.value.valueType == 'Parameter'">{{
conditionsItem.value.paramLabel
}}</span>
<!-- 方法 "Method" -->
<span v-if="conditionsItem.value.valueType == 'Method'">{{
conditionsItem.value.methodLabel
}}</span>
</span>
</div>
<!-- 变量赋值 -->
<div v-if="val.columnType == 'Assignment' && val.value">
<!-- 输入框 Input-->
<span v-if="val.value.valueType == 'Input'">{{ val.value.content }}</span>
<!-- 常量 Constant -->
<span v-if="val.value.valueType == 'Constant'">{{
val.value.constantLabel
}}</span>
<!-- 参数 Parameter -->
<span v-if="val.value.valueType == 'Parameter'">{{ val.value.paramLabel }}</span>
<!-- 方法 "Method" -->
<span v-if="val.value.valueType == 'Method'">{{ val.value.methodLabel }}</span>
</div>
<!-- 执行方法 -->
<div v-if="val.columnType == 'ExecuteMethod' && val.action">
<!-- 输入框 Input-->
<span v-if="val.action.valueType == 'Input'">{{ val.action.content }}</span>
<!-- 常量 Constant -->
<span v-if="val.action.valueType == 'Constant'">{{
val.action.constantLabel
}}</span>
<!-- 参数 Parameter -->
<span v-if="val.action.valueType == 'Parameter'">{{
val.action.paramLabel
}}</span>
<!-- 方法 "Method" -->
<span v-if="val.action.valueType == 'Method'">{{ val.action.methodLabel }}</span>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<!-- 相关动作出现的弹框 -->
<div class="other"></div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
<!-- 条件配置组件 -->
<conditionConfig
@changeTableData="changeTableData"
ref="conditionConfig_form"
:ruleCategoryId="form.id"
:jointdata="selectTableItemData"
></conditionConfig>
<!-- 变量赋值配置组件 -->
<assignment
@changeTableData="changeTableData"
ref="assignment_form"
:ruleCategoryId="form.id"
:data="selectTableItemData"
></assignment>
<!-- 执行方法配置组件 -->
<executeMethod
@changeTableData="changeTableData"
ref="executeMethod_form"
:ruleCategoryId="form.id"
:data="selectTableItemData"
></executeMethod>
</el-dialog>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import RuleScriptDao from "@/dao/develop/rule-script";
import conditionConfig from "./conditionConfig"; // 条件配置组件
import assignment from "./assignment"; // 变量赋值动作配置组件
import executeMethod from "./executeMethod"; // 执行方法配置组件
import {
propOptions,
conditionOperation,
actionOperation,
tableOperation,
tableOperationResule
} from "../util/data";
//构造表单
class Form {
constructor(data = {}, jsonData) {
this.id = data.ruleCategoryId; // 左侧树id
this.tableId = data.id; // 表的id
if (jsonData) {
this.expiresDate = jsonData.jsonData || null;
this.effectiveDate = jsonData.effectiveDate || null;
this.salience = jsonData.salience || null;
}
}
}
export default {
components: {
conditionConfig,
assignment,
executeMethod
},
watch: {
selectTableItemData(val) {}
},
data() {
return {
// 添加属性
propOptions,
// 头部的条件栏操作
conditionOperation,
// 头部动作栏的操作
actionOperation,
// 表格操作
tableOperation,
tableOperationResule,
show: false, //显示外层对话框
currentIndex: null, // 点击后获取的第几行高亮
// 添加属性选择的类型
propType: "",
conditionOperationShow: [],
actionOperationShow: [],
table: {
tableData: [
[
{
row: "0",
col: "0",
joint: null,
value: null,
action: null,
columnType: "Criteria"
},
{
row: "0",
col: "1",
joint: null,
value: null,
action: null,
columnType: "Assignment"
}
]
],
columns: [
{
num: "0",
paramLabel: "请选择参数",
columnType: "Criteria",
cascaderValue: ""
},
{
num: "1",
paramLabel: "请选择要赋值的参数",
columnType: "Assignment",
cascaderValue: ""
}
]
},
form: {
salience: "", // 优先级
effectiveDate: "", // 生效日期
expiresDate: "" // 失效日期
},
showSalience: false, // 显示优先级
showEffectiveDate: false, // 生效日期
showExpiresDate: false, // 失效日期
selectTableItemData: "", // 选中单元格数据
paramLibs: "" // 参数库
};
},
watch: {
show: {
handler(val) {
if (val) {
this.getVariable();
} else {
}
},
immediate: true
}
},
mounted() {},
methods: {
//页面获取时
getPage(data) {
this.reset();
this.show = true;
if (data.jsonData != null) {
this.displayData(data.jsonData);
}
this.form = new Form(data, data.jsonData ? JSON.parse(data.jsonData) : null);
},
// 数据回显
displayData(jsonData) {
let data = JSON.parse(jsonData);
// 表头
this.table.columns = data.columns;
let keyArr = [];
let map = new Map();
for (let key in data.cellMap) {
let o = {
id: key.split(",")[0],
value: data.cellMap[key]
};
keyArr.push(o);
}
let tableData = this.handlerDatas(keyArr);
this.$nextTick(() => {
this.table.tableData = tableData;
});
},
handlerDatas(arr) {
let obj = [];
arr.forEach((item, index) => {
let { id } = item;
if (!obj[id]) {
obj[id] = [];
}
obj[id].push(item.value);
});
return Object.values(obj); // 最终输出
},
// 添加属性选中添加的类型
selectPropType(value) {
switch (value) {
// 优先级
case "1":
this.showSalience = true;
break;
// 生效日期
case "2":
this.showEffectiveDate = true;
break;
// 失效日期
case "3":
this.showExpiresDate = true;
break;
}
},
// 删除属性
hideEffectiveDate() {
this.showEffectiveDate = false;
this.form.effectiveDate = "";
},
hideSalience() {
this.showSalience = false;
this.form.salience = "";
},
hideExpiresDate() {
this.showExpiresDate = false;
this.form.expiresDate = "";
},
// 条件头部的操作
selectCondition(value, data, index) {
if (value[0] == "addCriteria") {
// 添加条件
this.addItem(index, value[1], "addCriteria");
this.addItemData(index, value[1], "addCriteria");
} else if (value[0] == "addAction") {
// 添加方法
this.addItem(index, value[1], "addAction");
this.addItemData(index, value[1], "addAction");
} else if (value[0] == "addValue") {
// 添加赋值
this.addItem(index, value[1], "addValue");
this.addItemData(index, value[1], "addValue");
} else if (value[0] == "delete") {
let arr = this.table.columns.filter(val => {
return val.columnType == "Criteria";
});
let arr1 = this.table.columns.filter(val => {
return val.columnType == "Assignment" || val.columnType == "ExecuteMethod";
});
if (arr.length > 1 || arr1.length > 1) {
this.deleteItem(index);
this.deleteItemData(index);
} else {
this.$message({
message: "请保留一个",
type: "error"
});
}
} else {
// 选择配置参数
let nodesObj = this.$refs.cascadercondition[index].getCheckedNodes()[0];
if (nodesObj) {
console.log(data, index, value, nodesObj, "111111");
this.setItem(data, index, value, nodesObj);
}
}
this.clearSelectCum(index);
},
//tableHeader start
// 插入条件列
addItem(index, type, addType) {
let obj;
if (addType == "addAction") {
obj = {
paramLabel: "执行方法",
columnType: "ExecuteMethod",
cascaderValue: ""
};
} else if (addType == "addValue") {
obj = {
paramLabel: "请选择参数或变量",
columnType: "Assignment",
cascaderValue: ""
};
} else if (addType == "addCriteria") {
obj = {
paramLabel: "请选择参数",
columnType: "Criteria",
cascaderValue: ""
};
}
if (type === "leftAdd") {
this.table.columns.splice(index, 0, obj);
} else if (type === "rightAdd") {
this.table.columns.splice(index + 1, 0, obj);
}
},
// 删除条件列
deleteItem(index) {
this.table.columns.splice(index, 1);
},
//配置参数
setItem(data, index, value, nodesObj) {
let obj = {
num: index,
paramLibId: nodesObj.parent.data.data.id || null,
paramLibName: nodesObj.parent.data.data.name || null,
paramLibLabel: nodesObj.parent.data.data.name || null,
paramId: nodesObj.data.data.id || null,
paramLabel: nodesObj.data.data.name || null,
paramName: nodesObj.data.data.name || null,
datatype: nodesObj.data.data.type || null,
columnType: data.columnType || null,
cascaderValue: nodesObj.data.data.name || null
};
this.table.columns.splice(index, 1, obj);
},
// tableHeader end
// tableData start
// 添加一列
addItemData(index, type, addType) {
let columnType = "";
if (addType == "addAction") {
columnType = "ExecuteMethod";
} else if (addType == "addValue") {
columnType = "Assignment";
} else if (addType == "addCriteria") {
columnType = "Criteria";
}
let _length = this.table.tableData.length;
this.table.tableData.forEach((val, i) => {
let obj = {
row: i.toString(),
col: index.toString(),
joint: null,
value: null,
action: null,
columnType: columnType
};
if (type === "leftAdd") {
val.splice(index, 0, obj);
} else if (type === "rightAdd") {
val.splice(index + 1, 0, obj);
}
});
},
// 删除条件列
deleteItemData(index) {
this.table.tableData.forEach(val => {
val.splice(index, 1);
});
},
// tbody 里单元格操作
selectTableData(value, index, num, val) {
if (value.id == "add") {
// 添加条件
this.addItemDataRow(index);
} else if (value.id == "delete") {
// 删除条件
this.deleteItemDataRow(index);
} else if (value.id == "empty") {
// 清空结果的
this.emptyItemData(index, num, val);
} else if (value.id == "set") {
// 配置条件
this.selectTableItemData = val;
if (!val.joint) {
this.selectTableItemData = {
row: index.toString(),
col: num.toString(),
junctionType: "And",
conditions: [],
treeId: "0",
treeParentId: "0",
treeType: "parent"
};
} else {
this.selectTableItemData = val.joint;
}
this.$nextTick(function() {
this.$refs.conditionConfig_form.getPage();
});
} else if (value.id == "setResult") {
if (val.columnType == "ExecuteMethod") {
// 结果配置(方法)
if (!val.action) {
this.selectTableItemData = {
row: index.toString(),
col: num.toString(),
actionType: "",
actionId: "",
beanName: "",
beanLabel: "",
methodName: "",
methodLabel: "",
path: null,
parameters: [],
valueType: "Method"
};
} else {
this.selectTableItemData = val.action;
}
this.$nextTick(function() {
this.$refs.executeMethod_form.getPage();
});
} else if (val.columnType == "Assignment") {
// 结果配置(变量赋值)
if (!val.value) {
this.selectTableItemData = {
row: index.toString(),
col: num.toString(),
arithmetic: null,
valueType: "",
paramName: "",
paramLabel: null,
paramLibName: null,
paramLibId: null,
paramId: null,
datatype: "",
parameters: []
};
} else {
this.selectTableItemData = val.value;
}
this.$nextTick(function() {
this.$refs.assignment_form.getPage();
});
}
} else if (value.id == "up") {
this.moveUp(index, num);
} else if (value.id == "down") {
this.moveDown(index, num);
}
this.clearSelect(index, num);
},
// 添加条件行
addItemDataRow(index) {
let arr = [];
this.table.tableData[0].forEach((val, num) => {
let obj = {
row: index,
col: num,
joint: null,
value: null,
action: null,
columnType: val.columnType
};
arr.push(obj);
});
if (index) {
this.table.tableData.splice(index, 0, arr);
} else {
// 顶部的添加
this.table.tableData.splice(this.table.tableData.length, 0, arr);
}
},
// 删除条件行
deleteItemDataRow(index) {
if (!index) {
index = this.currentIndex;
this.currentIndex = null;
}
if (this.table.tableData.length < 2) {
this.$message({
message: "请保留一个",
type: "error"
});
return false;
}
this.table.tableData.splice(index, 1);
},
// 清空结果单元格
emptyItemData(index, num, data) {
let obj = {
row: index,
col: num,
joint: null,
value: null,
action: null,
columnType: data.columnType
};
this.table.tableData[index].splice(num, 1);
this.table.tableData[index].splice(num, 0, obj);
},
// 清除选中状态
clearSelect(index, num) {
this.table.tableData.forEach((item, i) => {
if (i == index) {
item.forEach((val, j) => {
if (j == num) {
val.cascaderValue = null;
}
});
}
});
},
// 清除头不的选中
clearSelectCum(index) {
this.table.columns.forEach((item, i) => {
item.cascaderValue = null;
});
},
//上移
moveUp(index, num) {
let that = this;
if (index > 0) {
let upDate = that.table.tableData[index - 1];
that.table.tableData.splice(index - 1, 1);
that.table.tableData.splice(index, 0, upDate);
}
},
//下移
moveDown(index, num) {
let that = this;
if (index + 1 === that.table.tableData.length) {
return;
} else {
let downDate = that.table.tableData[index + 1];
that.table.tableData.splice(index + 1, 1);
that.table.tableData.splice(index, 0, downDate);
}
},
// tableData end
// 数据重置
reset() {
this.table = {
tableData: [
[
{
row: "0",
col: "0",
joint: null,
value: null,
action: null,
columnType: "Criteria"
},
{
row: "0",
col: "1",
joint: null,
value: null,
action: null,
columnType: "Assignment"
// columnType: "ExecuteMethod"
}
]
],
columns: [
{
num: "0",
paramLabel: "请选择参数",
columnType: "Criteria",
cascaderValue: ""
},
{
num: "1",
paramLabel: "请选择要赋值的参数",
columnType: "Assignment",
cascaderValue: ""
}
]
};
this.form = {
salience: "", // 优先级
effectiveDate: "", // 生效日期
expiresDate: "" // 失效日期
};
this.showSalience = false; // 显示优先级
this.showEffectiveDate = false; // 生效日期
this.showExpiresDate = false; // 失效日期
this.currentIndex = null;
this.conditionOperationShow = [];
this.actionOperationShow = [];
this.paramLibs = [];
},
// 选择参数(参数库)
async getVariable() {
let res = await ParameterLibraryDao.getVariable({ params: { ruleCategoryId: this.form.id } });
const {
data: { status, content }
} = res;
if (status == "success") {
this.conditionOperationShow = this.conditionOperation.concat(content);
this.actionOperationShow = this.actionOperation.concat(content);
let arr = [];
content.forEach(item => {
let obj = {
name: item.name,
id: item.id
};
arr.push(obj);
});
this.paramLibs = arr;
}
},
// 修改tabledata
changeTableData(data, type) {
if (type === "Criteria") {
let _data = data[0];
this.table.tableData.forEach((item, index) => {
item.forEach((val, i) => {
if (index == _data.row && i == _data.col) {
val.joint = _data;
}
});
});
} else if (type === "Assignment") {
this.table.tableData.forEach((item, index) => {
item.forEach((val, i) => {
if (index == data.row && i == data.col) {
val.value = data;
}
});
});
} else if (type === "ExecuteMethod") {
this.table.tableData.forEach((item, index) => {
item.forEach((val, i) => {
if (index == data.row && i == data.col) {
val.action = data;
}
});
});
}
},
//提交
submit() {
let _effectiveDate =
this.form.effectiveDate && this.showEffectiveDate
? __.date.format(new Date(this.form.effectiveDate))
: "";
let _expiresDate =
this.form.expiresDate && this.showExpiresDate
? __.date.format(new Date(this.form.expiresDate))
: "";
let _cellMap = {};
let _rows = [];
this.table.tableData.forEach((item, i) => {
let obj = {
num: i.toString()
};
_rows.push(obj);
item.forEach((val, j) => {
val.row = i.toString();
val.col = j.toString();
_cellMap[i + "," + j] = val;
});
});
this.table.columns.forEach((val, index) => {
val.num = index.toString();
});
let jsonData = {
ruleCategoryId: this.form.id,
ruleScriptId: this.form.tableId,
actions: null,
enabled: null,
salience: this.form.salience,
effectiveDate: _effectiveDate,
expiresDate: _expiresDate,
rows: _rows,
columns: this.table.columns,
cellMap: _cellMap,
paramLibs: this.paramLibs
};
RuleScriptDao.edit({
data: {
jsonData: JSON.stringify(jsonData),
ruleCategoryId: this.form.id, //左侧规则树
id: this.form.tableId,
published: "2"
}
}).then(res => {
this.show = false;
this.$parent.queryData();
});
},
selectItem(index, value) {
this.currentIndex = index;
}
}
};
</script>
<style lang="less" scoped>
.operation {
padding-bottom: 20px;
}
.prop-list {
display: inline-block;
border: 1px solid #dcdcdc;
padding: 4px 8px;
/deep/.el-input__inner {
height: 28px;
}
margin-left: 10px;
}
.main-table {
table {
td,
th {
width: 200px;
height: 32px;
line-height: 32px;
border: 1px solid #dcdcdc;
padding: 0 8px;
}
.showTr {
background: #eef1f6;
}
.hideTr {
background: #fff;
}
}
thead {
height: 30px;
background: rgb(241, 241, 241);
.border-icon {
cursor: col-resize;
width: 3px;
height: 20px;
float: right;
border: 2px solid transparent;
}
.border-icon:hover,
.border-icon:focus {
outline: -webkit-focus-ring-color auto 1px;
}
}
.other {
padding-top: 20px;
}
.configIcon {
position: absolute;
right: 0;
top: 0;
cursor: pointer;
}
.table-item {
.placeholder {
color: blue;
}
.junction-type-green {
color: green;
}
.junction-type-red {
color: red;
}
}
}
</style>
<template>
<div style="display:flex;">
<!-- 左侧选择方法 -->
<div id="selectStyle" class="actionValueStyle">
<el-cascader
style="width: 120px;"
placeholder="请选择方法"
:options="methodList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
:show-all-levels="false"
@change="methodChange(...arguments, data)"
v-model="data.beanNames"
></el-cascader>
</div>
<!-- 选择方法 右侧选择方法 -->
<div class="methodData" v-for="val in data.parameters" :key="val.id">
<div>{{ val.label }}</div>
<div>:</div>
<div id="selectStyle" v-if="val.value" class="placeholderValue">
<el-select
style="width: 120px;"
v-model="val.value.valueType"
@change="valueChange(...arguments, data, val)"
placeholder="请选择值类型"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
:ruleCategoryId="ruleCategoryId"
v-if="val.value.valueType == 'Method'"
:data="val.value"
></method>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Parameter'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
@change="paramChangeMehod(...arguments, data, val.value)"
></el-cascader>
</div>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Constant'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="constantList"
@change="paramChangeMehod(...arguments, data, val.value)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
></el-cascader>
</div>
<el-input
style="width: 120px;"
v-if="val.value.valueType == 'Input'"
v-model="val.value.content"
class="contentInput"
></el-input>
</div>
</div>
</template>
<script>
import RepomoduletyperestserverDao from "@/dao/console/repomoduletyperestserver";
import ConstantLibraryDao from "@/dao/develop/constant-library";
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import { param, constant, methods } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
name: "method",
components: {},
props: ["data", "ruleCategoryId"],
data() {
return {
//值类型
dataTypeList,
methodList: [],
constantList: [],
keyList: []
};
},
mounted() {
this.getMethod();
this.getVariable();
this.getConstant();
},
methods: {
async getMethod() {
let res = await RepomoduletyperestserverDao.getMethod({
ruleCategoryId: this.ruleCategoryId
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.methodList = content;
}
},
//方法下拉选值
valueChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
} else {
this.getMethod();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 方法传参
methodChange(value, data) {
methods(value, data, this.methodList);
},
//右侧方法传参
paramChangeMehod(value, data, node) {
if (node.valueType == "Parameter") {
param(value, node, this.keyList);
}
if (node.valueType == "Constant") {
constant(value, node, this.constantList);
}
},
removeAction(index) {
this.rhs.actions.splice(index, 1);
}
}
};
</script>
<style lang="less" scoped>
.methodData {
display: flex;
align-items: center;
}
</style>
<template>
<div style="display:flex;">
<div id="selectStyle" class="placeholderValue">
<el-select
style="width: 120px;"
v-model="data.valueType"
placeholder="请选择值类型"
@change="valueParameterChange(...arguments, data)"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
ref="method"
v-if="data.valueType == 'Method'"
:data="data"
:ruleCategoryId="ruleCategoryId"
></method>
<!-- 参数数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Parameter'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
@change="paramChange(...arguments, 'Parameter', data)"
></el-cascader>
</div>
<!-- 常量数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Constant'">
<el-cascader
style="width: 120px;"
placeholder="请选择数据"
:options="constantList"
@change="paramChange(...arguments, 'Constant', data)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
></el-cascader>
</div>
<!-- 输入框数据 -->
<el-input
style="width: 120px;"
v-if="data.valueType == 'Input'"
v-model="data.content"
class="contentInput"
></el-input>
</div>
</template>
<script>
import ConstantLibraryDao from "@/dao/develop/constant-library";
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import method from "./method";
import { param, constant } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
components: {
method
},
props: ["data", "ruleCategoryId"],
data() {
return {
//值类型
dataTypeList,
constantList: [],
keyList: []
};
},
mounted() {
this.getVariable();
this.getConstant();
},
methods: {
//参数赋值下拉选值
valueParameterChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
//右侧选择参数数据传值
paramChange(value, type, node) {
if (type == "Parameter") {
param(value, node, this.keyList);
} else if (type == "Constant") {
constant(value, node, this.constantList);
}
},
removeAction(index) {
this.rhs.actions.splice(index, 1);
}
}
};
</script>
<template>
<el-dialog
title="编辑"
:visible.sync="show"
v-drag
:close-on-click-modal="false"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="名称" prop="name">
<el-input
v-model="form.name"
placeholder="名称"
maxlength="20"
></el-input>
</el-form-item>
<el-form-item label="类型" prop="ruleType">
<el-select
v-model="form.ruleType"
disabled
placeholder="请选择类型"
style="width:100%"
>
<el-option
v-for="item in ruleTypeList"
:label="item.name"
:value="item.id"
:key="item.id"
></el-option>
</el-select>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import RuleScriptDao from "@/dao/develop/rule-script";
//构造表单
class Form {
constructor(data) {
this.id = data.id;
this.name = data.name; //名称为空
this.ruleType = data.ruleType;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
ruleTypeList: [
{
name: "决策集",
id: "RuleSet",
},
{
name: "决策表",
id: "Table",
},
],
rules: {},
datas: null,
};
},
methods: {
//页面获取时
getPage(data) {
this.datas = data;
this.form = new Form(data);
const name = (rule, value, callback) => {
// 用户查重
if (value) {
const data = {
name: value,
id: this.form.id,
ruleCategoryId: this.form.ruleCategoryId,
};
RuleScriptDao.findByCondition({ data }).then((res) => {
if (
res.data.content.length > 0 &&
data.id != res.data.content[0].id
) {
callback(new Error("该名称已被使用"));
} else {
callback();
}
});
}
};
this.rules = {
//表单校验规则
name: [
{
required: true,
message: "请输入名称",
},
{
validator: name,
trigger: "change",
},
],
ruleType: [
{
required: true,
message: "请选择类型",
},
],
};
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
this.show = false;
this.form.ruleCategoryId = this.datas.ruleCategoryId;
const data = this.form;
RuleScriptDao.edit({ data }).then((res) => {
this.$parent.queryData();
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less" scoped></style>
<template>
<div class="rule-warning">
<div class="rule-warning-flex">
<div class="table-content">
<div class="toolbar">
<div class="btn-group">
<el-button type="primary" size="small" @click="create_getPage">
新建
<i class="el-icon-circle-plus-outline el-icon--right"></i>
</el-button>
<el-button
type="warning"
size="small"
@click="multiDelete"
:disabled="mutiDeleteData.length == 0"
>
删除
<i class="el-icon-delete el-icon--right"></i>
</el-button>
</div>
<div class="search">
<el-input
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
>
<i
slot="suffix"
class="el-input__icon el-icon-search"
@click="search"
></i>
</el-input>
</div>
</div>
<div class="table" v-if="fieldTable.data">
<stms-table
slot="content-flex"
full
:data="fieldTable.data"
:schema="fieldTable.option"
:rowSelection="true"
:loading="fieldTable.loading"
@selection-change="selectChange"
:pagination="{
pageNum: fieldTable.pageNum,
pageSize: fieldTable.pageSize,
total: fieldTable.pageTotal,
onChange: pageChange,
}"
>
<el-table-column label="状态" slot="end">
<template slot-scope="scope">
<el-tag v-if="scope.row.published == '2'">未发布</el-tag>
<el-tag v-if="scope.row.published == '1'" type="success"
>已发布</el-tag
>
</template>
</el-table-column>
<el-table-column label="操作" width="120" slot="end">
<template slot-scope="scope">
<el-dropdown trigger="click" class="operationDropDown">
<el-button type="default" size="mini">
操作
<i class="el-icon-caret-bottom el-icon--right"></i>
</el-button>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item
icon="el-icon-edit"
@click.native.prevent="edit_getPage(scope.row)"
>编辑</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-document"
@click.native.prevent="editScript_getPage(scope.row)"
>编辑脚本</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-position"
@click.native.prevent="test_getPage(scope.row)"
>测试</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-s-promotion"
@click.native.prevent="publish(scope.row, '1')"
v-if="scope.row.published === '2'"
>发布</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-s-promotion"
@click.native.prevent="unpublish(scope.row, '2')"
v-if="scope.row.published === '1'"
>取消发布</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-circle-plus-outline"
v-if="scope.row.ruleType == 'RuleSet'"
@click.native.prevent="rule_getPage(scope.row)"
>规则定义</el-dropdown-item
>
<el-dropdown-item
icon="el-icon-circle-plus-outline"
v-if="scope.row.ruleType == 'Table'"
@click.native.prevent="decisionTable(scope.row)"
>规则定义</el-dropdown-item
>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</stms-table>
</div>
</div>
<!-- 新建 -->
<createForm ref="create_form"></createForm>
<!-- 编辑 -->
<editForm ref="edit_form"></editForm>
<!-- 编辑脚本 -->
<scriptForm ref="script_form"></scriptForm>
<!-- 规则定义 -->
<ruleDefine ref="ruleDefine"></ruleDefine>
<!-- 决策表 -->
<decisionTable ref="decisionTable"></decisionTable>
<!-- 测试 -->
<stms-api-design
ref="test_form"
:requestTool="requestTool"
></stms-api-design>
</div>
</div>
</template>
<script>
import RuleScriptDao from "@/dao/develop/rule-script";
import createForm from "./create";
import editForm from "./edit";
import scriptForm from "./script";
import ruleDefine from "./ruleDefine/index";
import decisionTable from "./decisionTable";
//引入组件文件
export default {
props: ["selectNode", "events"],
//注册子组件
components: {
createForm,
editForm,
scriptForm,
ruleDefine,
decisionTable,
},
mounted() {
this.$set(this.events, "change", ({}, data) => {
this.selectNode = data;
this.queryData();
});
this.queryData();
},
data() {
return {
activeName: "0",
requestTool: [],
fieldTable: {
//表格数据
data: [],
option: [
{
prop: "name",
label: "名称",
},
{
prop: "_ruleType",
label: "类型",
},
],
loading: false,
pageTotal: null,
pageSize: 10,
pageNum: 1,
},
searchData: "",
mutiDeleteData: [],
};
},
methods: {
async queryData() {
try {
this.fieldTable.loading = true;
let data = {
condition: {
ruleCategoryId: this.selectNode.id,
keyword: this.searchData,
},
pageSize: this.fieldTable.pageSize,
pageNum: this.fieldTable.pageNum,
};
let res = await RuleScriptDao.findByPage({ data });
const {
data: { status, content },
} = res;
if (status === "success") {
this.fieldTable.data = content.rows;
this.fieldTable.pageTotal = content.total;
this.fieldTable.data.forEach((val) => {
if (val.ruleType == "RuleSet") {
val._ruleType = "决策集";
} else if (val.ruleType == "Table") {
val._ruleType = "决策表";
}
});
}
this.fieldTable.loading = false;
} catch (error) {
this.fieldTable.data = [];
this.fieldTable.loading = false;
}
},
//页数改变时调用
pageChange(pageNum, pageSize) {
this.fieldTable.pageNum = pageNum;
this.fieldTable.pageSize = pageSize;
this.queryData();
},
sizeChange(size) {
this.fieldTable.pageSize = size;
},
selectChange(data) {
this.mutiDeleteData = data.map((val) => val.id).join(",");
},
//表格新建
create_getPage() {
this.$refs.create_form.getPage(this.selectNode);
},
// 表格编辑
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
// 编辑脚本
editScript_getPage(data) {
this.$refs.script_form.getPage(data);
},
test_getPage(data) {
var obj;
this.requestTool = ["query", "headers", "body"];
obj = {
root: `http://${window.location.host}/design`,
requestBody: {
query: [],
headers: [],
body: {
type: "0",
param: [],
},
},
};
data.method = "POST"; //仅支持post
data.url = `/rule/ruleScript/execute/${data.id}`;
this.$refs.test_form.getPage(Object.assign(obj, data));
},
getReqData(req) {
if (req.requestBody.body.type === "4") {
var formdata = new FormData();
(req.requestBody.body.param || []).forEach((val) => {
formdata.append("file", val.file.raw);
});
}
return req.requestBody.body.type === "3"
? JSON.parse(req.requestBody.body.param)
: req.requestBody.body.type === "4"
? formdata
: (req.requestBody.body.param[0] &&
__.request.getBody(req.requestBody.body.param[0].children)) ||
{};
},
// 决策表
decisionTable(data) {
this.$refs.decisionTable.getPage(data);
},
//决策集
rule_getPage(data) {
this.$refs.ruleDefine.getPage(data);
},
//发布
publish(data, type) {
__.ui.messageBox("此操作将发布此规则, 是否继续?", () => {
const params = {
id: data.id,
published: type,
};
RuleScriptDao.publish({ params }).then((res) => {
this.queryData();
});
});
},
//发布
unpublish(data, type) {
__.ui.messageBox("此操作将取消发布此规则, 是否继续?", () => {
RuleScriptDao.edit({
data: {
id: data.id,
published: type,
},
notify: "取消发布",
}).then((res) => {
this.queryData();
});
});
},
//表格删除
multiDelete() {
__.ui.messageBox("此操作将永久删除, 是否继续?", () => {
const data = {
ids: this.mutiDeleteData,
};
RuleScriptDao.delete({
params: data,
}).then((res) => {
if (res.data.status == "success") {
this.mutiDeleteData = [];
this.queryData();
}
});
});
},
//搜索
search() {
this.fieldTable.pageNum = 1;
this.queryData();
},
},
};
</script>
<style lang="less" scoped>
.rule-warning {
height: 0;
flex: auto;
position: relative;
.rule-warning-flex {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
.table-content {
height: 100%;
display: flex;
flex-direction: column;
.toolbar {
display: flex;
justify-content: space-between;
margin-bottom: 10px;
}
.table {
flex: auto;
position: relative;
.full {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
}
}
}
}
</style>
<template>
<div id="ifCondition">
<div class="titleStyle">如果</div>
<div class="treeScroll">
<div class="banner">
<el-tree
id="ruleTree"
:data="list"
node-key="treeId"
:default-expand-all="true"
:expand-on-click-node="false"
:props="defaultProps"
>
<div slot-scope="{ node, data }">
<!-- 下拉选择框 -->
<el-select
v-if="data.treeType == 'parent'"
v-model="data.junctionType"
class="parentBtn"
@change="conditionChangeTree(data, list, node)"
>
<el-option
v-for="item in typeList"
:key="item.id"
:label="item.name"
:value="item.type"
></el-option>
</el-select>
<el-button
v-if="data.treeType == 'parent' && data.treeId != '0'"
@click="() => remove(node, data)"
type="text"
icon="el-icon-delete"
></el-button>
<div class="childrenContent" v-if="data.treeType == 'children'">
<!-- 左侧数据类型 -->
<div id="selectStyle" class="actionStyle">
<el-select
v-if="data.left"
@change="dataChange(...arguments, data)"
v-model="data.left.leftType"
placeholder="请选择数据类型"
class="selectWidth"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<!--左侧 参数赋值 选择参数 -->
<div
id="selectStyle"
v-if="data.left && data.left.leftType == 'Parameter'"
class="keyPlaceholder"
>
<el-cascader
class="selectWidth"
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.left.leftPart.paramIds"
@change="paramChangeLeft(...arguments, data, data.left.leftPart)"
></el-cascader>
</div>
<!-- 选择方法 -->
<method
ref="method"
v-if="data.left && data.left.leftType == 'Method'"
:data="data.left.leftPart"
:ruleCategoryId="ruleCategoryId"
></method>
<!-- 中间 比较符 -->
<div id="selectStyle" class="placeholder" v-if="data.left.leftType">
<el-select v-model="data.op" placeholder="请选择比较操作符">
<el-option
v-for="item in conditionList"
:key="item.id"
:label="item.name"
:value="item.type"
></el-option>
</el-select>
</div>
<!-- 选择参数 -->
<params
ref="method"
v-if="data.op != ''"
:data="data.value"
:ruleCategoryId="ruleCategoryId"
></params>
<el-button
v-if="data.treeType == 'children'"
@click="() => remove(node, data)"
type="text"
icon="el-icon-delete"
></el-button>
</div>
</div>
</el-tree>
</div>
</div>
</div>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import method from "./method";
import params from "./params";
import { param } from "../util/transformData";
import { conditionList, typeList, dataTypeList } from "../util/data";
export default {
props: ["ruleCategoryId", "lhs"],
components: { method, params },
computed: {
list() {
return [this.lhs.junction];
}
},
data() {
return {
//比较符
conditionList,
//下拉条件选择
typeList,
dataTypeList: dataTypeList.filter(val => {
return val.id === "Parameter" || val.id === "Method";
}),
arr: [], //下拉框选择
defaultProps: {
//树转换数据
label: "name",
children: "childJunctionList"
},
keyList: [] //参数
};
},
mounted() {
this.getVariable(); //参数
},
methods: {
// 点击添加数据
conditionChangeTree(data, all, node) {
if (!data.childJunctionList) {
this.$set(data, "childJunctionList", []);
}
this.arr.push(data.junctionType);
this.arr = this.arr.filter(val => val != "Criteria"); //过滤添加条件
this.filterFile = this.arr;
this.filterFile = this.filterFile.filter(val => val != "Junction"); //过滤联合条件
if (data.junctionType == "Criteria") {
data.childJunctionList.push({
left: {
leftType: "",
leftPart: {
paramId: "",
parameters: []
}
},
op: "",
value: {
valueType: "",
parameters: []
},
treeType: "children",
childJunctionList: [],
treeId: this.getMaxId(all),
treeParentId: data.treeId,
criterionType: "Criteria",
junctionType: null
});
if (this.filterFile.length == 0) {
data.junctionType = "And";
} else {
data.junctionType = this.filterFile.pop();
}
} else if (data.junctionType == "Junction") {
data.childJunctionList.push({
treeType: "parent",
treeId: this.getMaxId(all),
treeParentId: data.treeId,
criterionType: "Junction",
junctionType: "And",
childJunctionList: []
});
if (this.filterFile.length == 0) {
data.junctionType = "And";
} else {
data.junctionType = this.filterFile.pop();
}
Vue.set(data, "childJunctionList", data.childJunctionList); // 保证修改数组视图渲染
}
Vue.set(data, "childJunctionList", data.childJunctionList); // 保证修改数组视图渲染
},
// 数据类型改变
dataChange(value, data) {
if (value == "Parameter") {
this.getVariable();
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: {
ruleCategoryId: this.ruleCategoryId
}
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 左侧选择参数
paramChangeLeft(value, data, node) {
if (data.left.leftType == "Parameter") {
param(value, node, this.keyList);
}
},
// 删除
remove(node, data) {
const parent = node.parent;
const children = parent.data.childJunctionList || parent.data;
const index = children.findIndex(d => d.treeId === data.treeId);
children.splice(index, 1);
},
// 计算请求参数节点最大id
getMaxId(nodes, id = 1) {
return nodes.reduce(
(result, item) =>
item.childJunctionList && item.childJunctionList.length > 0
? this.getMaxId(item.childJunctionList, result)
: result > item.id
? result
: item.treeId + 1,
id
);
}
}
};
</script>
<style lang="less">
#ifCondition {
.titleStyle {
font-weight: bold;
}
.headSelect {
width: 75px;
margin-top: 10px;
}
/*滚动条样式*/
.treeScroll::-webkit-scrollbar {
/*滚动条整体样式*/
width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
height: 5px;
}
.treeScroll::-webkit-scrollbar-track-piece {
background-color: #fff;
}
.treeScroll {
width: 100%;
height: 100%;
background: #fff;
overflow-x: scroll; /*添加横向滚动条*/
white-space: nowrap; /*不换行*/
overflow-y: hidden;
.banner {
display: inline-block;
}
#ruleTree {
width: 100%;
padding-top: 3px;
.parentBtn {
width: 80px;
}
.contentInput {
width: 250px;
}
.el-select {
width: 100px;
}
.el-cascader {
width: 200px;
}
.childrenContent {
display: flex;
.methodContent {
display: flex;
}
}
// .el-tree-node {
// min-width: 100%;
// display: inline-block;
// }
.el-tree-node__content {
height: 40px;
margin: 5px 0;
background: #fff;
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
justify-content: space-between;
font-size: 14px;
padding-right: 8px;
}
.el-tree__empty-block {
display: none;
}
}
}
}
</style>
<template>
<el-dialog
title="规则定义"
:visible.sync="show"
:close-on-click-modal="false"
v-if="show"
:destroy-on-close="true"
:fullscreen="true"
class="ruleDefine"
style="width:100%"
>
<div class="top">
<el-button type="primary" size="small" @click="createRule">
添加规则
<i class="el-icon-circle-plus-outline el-icon--right"></i>
</el-button>
</div>
<div class="bottom" v-for="(item, index) in ruleData" :key="item.id">
<div class="content">
<div class="ruleStyle">
<el-input
show-word-limit
style="margin: 0 10px;width:200px"
maxlength="50"
v-model="item.name"
placeholder="请输入名称"
></el-input>
<el-button
type="text"
icon="el-icon-close"
@click="ruleDelete(index)"
></el-button>
</div>
<div class="createAttr">
<span class="title" @click="createAttr(item)">添加属性</span>
<div v-if="item.ifCreateAttr == true" class="right">
<el-form ref="form" class="elForm">
<el-form-item label="优先级" prop="salience">
<el-input-number
v-model="item.salience"
:min="1"
:max="50"
></el-input-number>
</el-form-item>
<el-form-item label="日期选择" prop="effectiveDate">
<el-date-picker
:picker-options="pickerOptions"
:value="[item.effectiveDate, item.expiresDate]"
type="daterange"
range-separator="至"
start-placeholder="生效日期"
end-placeholder="失效日期"
value-format="yyyy-MM-dd"
@input="
(val) => {
item.effectiveDate = val[0];
item.expiresDate = val[1];
}
"
>
</el-date-picker>
</el-form-item>
<el-form-item>
<el-button
type="text"
icon="el-icon-delete"
@click="close(item)"
></el-button>
</el-form-item>
</el-form>
</div>
</div>
<!-- 如果-->
<ifCondition
:lhs="item.lhs"
:ruleCategoryId="ruleCategoryId"
></ifCondition>
<!-- 那么 -->
<thatCondition
:rhs="item.rhs"
:ruleCategoryId="ruleCategoryId"
></thatCondition>
<!-- 否则 -->
<otherCondition
:other="item.other"
:ruleCategoryId="ruleCategoryId"
></otherCondition>
</div>
</div>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import RuleScriptDao from "@/dao/develop/rule-script";
import ifCondition from "./if"; //如果
import thatCondition from "./that"; //那么
import otherCondition from "./other"; //否则
export default {
components: {
ifCondition,
thatCondition,
otherCondition,
},
data() {
return {
show: false,
ruleCategoryId: "",
dataNodeTable: null,
ruleData: [],
pickerOptions: {
disabledDate: (date) => {
return (
date.getTime() < new Date(new Date().toLocaleDateString()).getTime()
);
},
},
};
},
methods: {
//页面获取时
getPage(data) {
this.dataNodeTable = data;
this.ruleCategoryId = data.ruleCategoryId;
this.ruleData = [];
this.show = true;
this.ifCreateAttr = false;
if (data.jsonData != null) {
this.displayData();
}
},
// 回显数据
displayData() {
let data = JSON.parse(this.dataNodeTable.jsonData).rules;
this.$nextTick(() => {
this.ruleData = data;
});
},
createAttr(data) {
data.ifCreateAttr = true;
},
close(data) {
data.ifCreateAttr = false;
},
//添加多个规则
createRule() {
let obj = {
name: "",
salience: "",
effectiveDate: new Date(), //开始
expiresDate: new Date(), //结束
enabled: null,
loop: null,
ifCreateAttr: false,
rhs: {
actions: [],
},
other: {
actions: [],
},
lhs: {
junction: {
childJunctionList: [],
treeId: "0",
treeParentId: "0",
junctionType: "And",
criterionType: "Junction",
treeType: "parent",
},
},
};
this.ruleData.push(obj);
},
// 删除
ruleDelete(index) {
this.ruleData.splice(index, 1);
},
//提交
submit() {
let obj = {
ruleCategoryId: this.ruleCategoryId, //左侧规则树
ruleType: "RuleSet",
ruleScriptId: "1",
rules: this.ruleData,
};
this.show = false;
RuleScriptDao.edit({
data: {
jsonData: JSON.stringify(obj),
ruleCategoryId: this.ruleCategoryId, //左侧规则树
ruleType: "RuleSet",
id: this.dataNodeTable.id,
published: "2",
},
}).then((res) => {
this.$parent.queryData();
});
},
},
};
</script>
<style lang="less">
.ruleDefine {
.el-dialog.is-fullscreen {
width: 100% !important;
overflow: auto;
}
.bottom {
left: 260px;
margin-bottom: 10px;
// border-top: 1px solid #eee;
padding: 0px 20px;
.content {
width: 100%;
height: auto;
padding: 10px;
border-bottom: 1px solid #eee;
.title {
color: #7777;
margin: 5px;
}
.ruleStyle {
display: flex;
align-items: center;
width: 100%;
padding: 10px;
.titleInput {
display: inline-block;
margin: 0 10px;
max-width: 100px;
font-weight: bold;
}
.titleInput {
.el-input__inner {
border: none;
text-align: center;
}
}
}
.createAttr {
margin: 0 0 10px 10px;
display: flex;
height: 40px;
align-items: center;
.title {
height: 40px;
color: blue;
cursor: pointer;
line-height: 40px;
}
.right {
width: calc(100% - 70px);
height: 100%;
.elForm {
display: flex;
margin-top: 2.5px;
.el-form-item__label {
padding: 0px 17px 11px 10px;
}
.el-form-item__content {
display: flex;
align-items: center;
height: 32px;
}
.el-form-item {
.el-radio {
top: 0;
}
}
}
}
}
}
}
.bottom {
.placeholderValue {
.el-input__inner {
color: rgb(180, 95, 4);
}
input::-webkit-input-placeholder {
color: rgb(180, 95, 4);
}
}
.placeholder {
.el-input__inner {
color: red;
}
input::-webkit-input-placeholder {
color: red;
}
}
.keyPlaceholder {
.el-input__inner {
color: darkcyan;
}
}
.actionStyle {
.el-input__inner {
color: green;
}
}
.actionValueStyle {
.el-input__inner {
color: darkcyan;
}
}
}
}
</style>
<template>
<div style="display:flex;">
<!-- 左侧选择方法 -->
<div id="selectStyle" class="actionValueStyle">
<el-cascader
placeholder="请选择方法"
:options="methodList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
:show-all-levels="false"
@change="methodChange(...arguments, data)"
v-model="data.beanNames"
></el-cascader>
</div>
<!-- 选择方法 右侧选择方法 -->
<div class="methodData" v-for="val in data.parameters" :key="val.id">
<div>{{ val.label }}</div>
<div>:</div>
<div id="selectStyle" v-if="val.value" class="placeholderValue">
<el-select
v-model="val.value.valueType"
@change="valueChange(...arguments, data, val)"
placeholder="请选择值类型"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
:ruleCategoryId="ruleCategoryId"
v-if="val.value.valueType == 'Method'"
:data="val.value"
></method>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Parameter'">
<el-cascader
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
@change="paramChangeMehod(...arguments, data, val.value)"
></el-cascader>
</div>
<div id="selectStyle" class="actionValueStyle" v-if="val.value.valueType == 'Constant'">
<el-cascader
placeholder="请选择数据"
:options="constantList"
@change="paramChangeMehod(...arguments, data, val.value)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="val.value.paramIds"
></el-cascader>
</div>
<el-input
v-if="val.value.valueType == 'Input'"
v-model="val.value.content"
class="contentInput"
></el-input>
</div>
</div>
</template>
<script>
import RepomoduletyperestserverDao from "@/dao/console/repomoduletyperestserver";
import ConstantLibraryDao from "@/dao/develop/constant-library";
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import { param, constant, methods } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
name: "method",
components: {},
props: ["data", "ruleCategoryId"],
data() {
return {
//值类型
dataTypeList,
methodList: [],
ifMethod: false,
constantList: [],
keyList: []
};
},
mounted() {
this.getMethod();
this.getVariable();
this.getConstant();
},
methods: {
async getMethod() {
let res = await RepomoduletyperestserverDao.getMethod({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.methodList = content;
}
},
//方法下拉选值
valueChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
} else {
this.getMethod();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 方法传参
methodChange(value, data) {
methods(value, data, this.methodList);
},
//右侧方法传参
paramChangeMehod(value, data, node) {
if (node.valueType == "Parameter") {
param(value, node, this.keyList);
}
if (node.valueType == "Constant") {
constant(value, node, this.constantList);
}
}
}
};
</script>
<style lang="less">
.methodData {
display: flex;
align-items: center;
}
</style>
<template>
<div id="otherCondition">
<div>
<span class="titleStyle">否则</span>
<span class="addSo" @click="addSo">添加动作</span>
</div>
<div class="scrollWidth">
<div class="banner">
<div class="otherContent" v-for="(data, index) in other.actions" :key="data.id">
<!-- 删除每一行数据 -->
<el-button type="text" icon="el-icon-delete" @click="removeAction(index)"></el-button>
<!-- 动作类型 -->
<div id="selectStyle" class="actionStyle">
<el-select
v-model="data.actionType"
placeholder="请选择动作类型"
@change="changeAction(...arguments, data)"
>
<el-option
v-for="item in actionList"
:key="item.id"
:label="item.name"
:value="item.actionType"
></el-option>
</el-select>
</div>
<!-- 参数左侧赋值 -->
<div
id="selectStyle"
v-if="data.actionType == 'ParameterAssign'"
class="actionValueStyle"
>
<el-cascader
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
@change="paramChangeLeft(...arguments, 'ParameterAssign', data)"
></el-cascader>
</div>
<div id="selectStyle" v-if="data.actionType == 'DataCollection'" class="actionValueStyle">
<el-select
v-model="data.paramLibId"
@change="paramChangeLeft(...arguments, 'DataCollection', data)"
placeholder="请选择数据"
>
<el-option
v-for="item in keyList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<!-- 比较符 -->
<div v-if="data.actionType == 'ParameterAssign'">=</div>
<params
ref="method"
v-if="data.actionType == 'ParameterAssign'"
:data="data.value"
:ruleCategoryId="ruleCategoryId"
></params>
<method
ref="method"
v-if="data.actionType == 'ExecuteMethod'"
:data="data"
:ruleCategoryId="ruleCategoryId"
></method>
</div>
</div>
</div>
</div>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import method from "./method";
import params from "./params";
import { param, dataCollection } from "../util/transformData";
import { actionList } from "../util/data";
export default {
components: {
method,
params
},
props: ["ruleCategoryId", "other"],
data() {
return {
//请选择动作类型
actionList,
actions: [],
keyList: [] //选择参数
};
},
mounted() {
this.getVariable(); //参数
},
methods: {
// 添加数据
addSo() {
let obj = {
actionType: "",
value: {
valueType: "",
parameters: [],
paramIds: []
},
paramIds: [],
parameters: [] //选择方法参数回显
};
this.other.actions.push(obj);
},
//获取动作方法
changeAction(value, data) {
if (data.actionType == "ParameterAssign") {
this.getVariable();
}
},
// // 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 左侧选择参数数据传值
paramChangeLeft(value, type, node) {
if (type == "ParameterAssign") {
param(value, node, this.keyList);
} else {
dataCollection(node, this.keyList);
}
},
removeAction(index) {
this.other.actions.splice(index, 1);
}
}
};
</script>
<style lang="less">
#otherCondition {
margin: 15px 0;
.titleStyle {
font-weight: bold;
}
.addSo {
color: blue;
margin-right: 10px;
cursor: pointer;
}
.scrollWidth {
width: 100%;
height: 100%;
overflow-x: scroll; /*添加横向滚动条*/
white-space: nowrap; /*不换行*/
overflow-y: hidden;
.banner {
display: inline-block;
.otherContent {
width: 100%;
display: flex;
align-items: center;
margin: 5px 0;
.contentInput {
width: 200px;
}
.el-select {
width: 100px;
}
.el-cascader {
width: 200px;
}
.methodContent {
display: flex;
}
.methodData {
display: flex;
align-items: center;
}
}
}
}
/*滚动条样式*/
.scrollWidth::-webkit-scrollbar {
/*滚动条整体样式*/
width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
height: 5px;
}
.scrollWidth::-webkit-scrollbar-track-piece {
background-color: #fff;
}
}
</style>
<template>
<div style="display:flex;">
<div id="selectStyle" class="placeholderValue">
<el-select
v-model="data.valueType"
placeholder="请选择值类型"
@change="valueParameterChange(...arguments, data)"
>
<el-option
v-for="item in dataTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<method
ref="method"
v-if="data.valueType == 'Method'"
:data="data"
:ruleCategoryId="ruleCategoryId"
></method>
<!-- 参数数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Parameter'">
<el-cascader
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
@change="paramChange(...arguments, 'Parameter', data)"
></el-cascader>
</div>
<!-- 常量数据 -->
<div id="selectStyle" class="actionValueStyle" v-if="data.valueType == 'Constant'">
<el-cascader
placeholder="请选择数据"
:options="constantList"
@change="paramChange(...arguments, 'Constant', data)"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
></el-cascader>
</div>
<!-- 输入框数据 -->
<el-input
v-if="data.valueType == 'Input'"
v-model="data.content"
class="contentInput"
></el-input>
</div>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import ConstantLibraryDao from "@/dao/develop/constant-library";
import method from "./method";
import { param, constant } from "../util/transformData";
import { dataTypeList } from "../util/data";
export default {
components: {
method
},
props: ["data", "ruleCategoryId"],
data() {
return {
//值类型
dataTypeList,
constantList: [],
keyList: []
};
},
mounted() {
this.getVariable();
this.getConstant();
},
methods: {
//参数赋值下拉选值
valueParameterChange(value, data) {
if (value == "Constant") {
this.getConstant();
} else if (value == "Parameter") {
this.getVariable();
}
},
// 选择常量
async getConstant() {
let res = await ConstantLibraryDao.getConstant({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.constantList = content;
}
},
// 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
//右侧选择参数数据传值
paramChange(value, type, node) {
if (type == "Parameter") {
param(value, node, this.keyList);
} else if (type == "Constant") {
constant(value, node, this.constantList);
}
}
}
};
</script>
<style lang="less"></style>
<template>
<div id="thatCondition">
<div>
<span class="titleStyle">那么</span>
<span class="addSo" @click="addSo">添加动作</span>
</div>
<div class="scrollWidth">
<div class="banner">
<div class="otherContent" v-for="(data, index) in rhs.actions" :key="data.id">
<!-- 删除每一行数据 -->
<el-button type="text" icon="el-icon-delete" @click="removeAction(index)"></el-button>
<!-- 动作类型 -->
<div id="selectStyle" class="actionStyle">
<el-select
v-model="data.actionType"
placeholder="请选择动作类型"
@change="changeAction(...arguments, data)"
>
<el-option
v-for="item in actionList"
:key="item.id"
:label="item.name"
:value="item.actionType"
></el-option>
</el-select>
</div>
<!-- 参数左侧赋值 -->
<div
id="selectStyle"
v-if="data.actionType == 'ParameterAssign'"
class="actionValueStyle"
>
<el-cascader
placeholder="请选择数据"
:options="keyList"
:props="{
label: 'name',
children: 'children',
value: 'id'
}"
v-model="data.paramIds"
@change="paramChangeLeft(...arguments, 'ParameterAssign', data)"
></el-cascader>
</div>
<div id="selectStyle" v-if="data.actionType == 'DataCollection'" class="actionValueStyle">
<el-select
v-model="data.paramLibId"
@change="paramChangeLeft(...arguments, 'DataCollection', data)"
placeholder="请选择数据"
>
<el-option
v-for="item in keyList"
:key="item.id"
:label="item.name"
:value="item.id"
></el-option>
</el-select>
</div>
<!-- 比较符 -->
<div v-if="data.actionType == 'ParameterAssign'">=</div>
<params
ref="method"
v-if="data.actionType == 'ParameterAssign'"
:data="data.value"
:ruleCategoryId="ruleCategoryId"
></params>
<method
ref="method"
v-if="data.actionType == 'ExecuteMethod'"
:data="data"
:ruleCategoryId="ruleCategoryId"
></method>
</div>
</div>
</div>
</div>
</template>
<script>
import ParameterLibraryDao from "@/dao/develop/parameter-library";
import method from "./method";
import params from "./params";
import { param, dataCollection } from "../util/transformData";
import { actionList } from "../util/data";
export default {
components: {
method,
params
},
props: ["ruleCategoryId", "rhs"],
data() {
return {
//请选择动作类型
actionList,
actions: [],
keyList: [] //选择参数
};
},
mounted() {
this.getVariable(); //参数
},
methods: {
// 添加数据
addSo() {
let obj = {
actionType: "",
value: {
valueType: "",
parameters: [],
paramIds: []
},
paramIds: [],
// beanNames: [], //级联选中效果
parameters: [] //选择方法参数回显
};
this.rhs.actions.push(obj);
},
//获取动作方法
changeAction(value, data) {
if (data.actionType == "ParameterAssign") {
this.getVariable();
}
},
// // 选择参数
async getVariable() {
let res = await ParameterLibraryDao.getVariable({
params: { ruleCategoryId: this.ruleCategoryId }
});
const {
data: { status, content }
} = res;
if (status == "success") {
this.keyList = content;
}
},
// 左侧选择参数数据传值
paramChangeLeft(value, type, node) {
if (type == "ParameterAssign") {
param(value, node, this.keyList);
} else {
dataCollection(node, this.keyList);
}
},
removeAction(index) {
this.rhs.actions.splice(index, 1);
}
}
};
</script>
<style lang="less">
#thatCondition {
margin: 15px 0;
.titleStyle {
font-weight: bold;
}
.addSo {
color: blue;
margin-right: 10px;
cursor: pointer;
}
.scrollWidth {
width: 100%;
height: 100%;
overflow-x: scroll; /*添加横向滚动条*/
white-space: nowrap; /*不换行*/
overflow-y: hidden;
.banner {
display: inline-block;
.otherContent {
width: 100%;
display: flex;
align-items: center;
margin: 5px 0;
.contentInput {
width: 200px;
}
.el-select {
width: 100px;
}
.el-cascader {
width: 200px;
}
.methodContent {
display: flex;
}
.methodData {
display: flex;
align-items: center;
}
}
}
}
/*滚动条样式*/
.scrollWidth::-webkit-scrollbar {
/*滚动条整体样式*/
width: 5px; /*高宽分别对应横竖滚动条的尺寸*/
height: 5px;
}
.scrollWidth::-webkit-scrollbar-track-piece {
background-color: #fff;
}
}
</style>
<template>
<el-dialog
title="规则脚本"
:visible.sync="show"
width="650px"
v-drag
:close-on-click-modal="false"
v-if="show"
:destroy-on-close="true"
>
<el-form :model="form" :rules="rules" ref="form">
<el-form-item prop="ruleTxt">
<div class="scriptStyle">
<stms-ace-editor
v-model="form.script"
mode="mysql"
width="100%"
height="335px"
/>
</div>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">保存并发布</el-button>
</span>
</el-dialog>
</template>
<script>
import RuleScriptDao from "@/dao/develop/rule-script";
//构造表单
class Form {
constructor(data) {
this.id = data.id;
this.script = data.script;
this.ruleCategoryId = data.ruleCategoryId;
}
}
export default {
data() {
return {
show: false, //显示外层对话框
form: {},
rules: {},
};
},
methods: {
//页面获取时
getPage(data) {
this.form = new Form(data);
if (this.$refs.form) {
this.$refs.form.resetFields();
}
this.show = true;
},
//页面提交
submit() {
this.$refs["form"].validate((valid) => {
if (valid) {
this.show = false;
const data = this.form;
RuleScriptDao.releaseScript({ data }).then((res) => {
this.$parent.queryData();
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less" scoped>
.scriptStyle {
display: inline-block;
width: 100%;
}
</style>
export const conditionList = [
{
id: "1",
name: "等于",
type: "Equals"
},
{
id: "2",
name: "等于(不分大小写)",
type: "EqualsIgnoreCase"
},
{
id: "3",
name: "不等于",
type: "NotEquals"
},
{
id: "4",
name: "不等于(不分大小写)",
type: "NotEqualsIgnoreCase"
},
{
id: "5",
name: "小于",
type: "LessThen"
},
{
id: "6",
name: "小于等于",
type: "LessThenEquals"
},
{
id: "7",
name: "大于",
type: "GreaterThen"
},
{
id: "8",
name: "大于等于",
type: "GreaterThenEquals"
},
{
id: "9",
name: "开始于",
type: "StartWith"
},
{
id: "10",
name: "不开始于",
type: "NotStartWith"
},
{
id: "11",
name: "结束于",
type: "EndWith"
},
{
id: "12",
name: "不结束于",
type: "NotEndWith"
},
{
id: "13",
name: "为空",
type: "Null"
},
{
id: "14",
name: "不为空",
type: "NotNull"
},
{
id: "15",
name: "匹配",
type: "Match"
},
{
id: "16",
name: "不匹配",
type: "NotMatch"
},
{
id: "17",
name: "包含",
type: "Contain"
},
{
id: "18",
name: "不包含",
type: "NotContain"
}
];
export const typeList = [
{
id: "1",
name: "并且",
type: "And"
},
{
id: "2",
name: "或者",
type: "Or"
},
{
id: "3",
name: "添加条件",
type: "Criteria"
},
{
id: "4",
name: "添加联合条件",
type: "Junction"
}
];
export const actionList = [
{
id: "1",
name: "参数赋值",
actionType: "ParameterAssign"
},
{
id: "2",
name: "执行方法",
actionType: "ExecuteMethod"
},
{
id: "3",
name: "数据搜集",
actionType: "DataCollection"
}
];
export const dataTypeList = [
{
id: "Input",
name: "输入值"
},
{
id: "Constant",
name: "选择常量"
},
{
id: "Parameter",
name: "选择参数"
},
{
id: "Method",
name: "选择方法"
}
];
export const propOptions = [
{ label: "优先级", value: "1" },
{ label: "生效日期", value: "2" },
{ label: "失效日期", value: "3" }
];
export const conditionOperation = [
{
name: "插入条件列",
id: "addCriteria",
children: [
{
id: "leftAdd",
name: "< 前"
},
{
id: "rightAdd",
name: "> 后"
}
]
},
{
name: "删除当前条件列",
id: "delete"
}
];
export const actionOperation = [
{
name: "插入执行方法动作列",
id: "addAction",
children: [
{
id: "leftAdd",
name: "< 前"
},
{
id: "rightAdd",
name: "> 后"
}
]
},
{
name: "删除当前动作列",
id: "delete"
},
{
name: "插入变量赋值动作列",
id: "addValue",
children: [
{
id: "leftAdd",
name: "< 前"
},
{
id: "rightAdd",
name: "> 后"
}
]
}
];
export const tableOperation = [
{
name: "配置条件",
id: "set"
},
{
name: "添加条件行",
id: "add"
},
{
name: "删除条件行",
id: "delete"
},
{
name: "上移",
id: "up"
},
{
name: "下移",
id: "down"
},
{
name: "清空",
id: "empty"
}
];
export const tableOperationResule = [
{
name: "结果配置",
id: "setResult"
},
{
name: "清空",
id: "empty"
}
];
//参数库
const param = (value, node, keyList) => {
const [paramLibId, paramId] = value;
const { name: paramLibName, children, data: libData } = keyList.find(v => v.id === paramLibId);
const { description: paramLibLabel } = libData;
const { name: paramName, data: paramData } = children.find(v => v.id === paramId);
const { description: paramLabel, type: type } = paramData;
node.paramLibName = paramLibName;
node.paramLibLabel = paramLibLabel;
node.paramName = paramName;
node.paramLabel = paramLabel;
node.paramLibId = paramLibId;
node.datatype = type;
node.paramId = paramId;
};
//常量库
const constant = (value, node, constantList) => {
const [constantLibId, constantId] = value;
const { name: constantLibName, children } = constantList.find(v => v.id === constantLibId);
const { data: constantData } = children.find(v => v.id === constantId);
const { name: constantLabel, value: constantValue, type: datatype } = constantData;
node.constantLibName = constantLibName;
node.constantValue = constantValue;
node.constantLabel = constantLabel;
node.constantLibId = constantLibId;
node.datatype = datatype;
node.constantId = constantId;
};
//方法库
const methods = (value, data, methodList) => {
const [beanId, methodId] = value;
const { name: beanName, children, data: libData } = methodList.find(v => v.id === beanId);
const { description: beanLabel, version: beanVersion } = libData;
data.actionId = beanId;
data.beanVersion = beanVersion;
data.beanName = beanName;
data.beanLabel = beanLabel;
const { name: methodName, data: paramData } = children.find(v => v.id === methodId);
const { description: methodLabel } = paramData;
data.methodName = methodName;
data.methodLabel = methodLabel;
};
//数据搜集
const dataCollection = (node, keyList) => {
const { name: paramLibName, data: libData } = keyList.find(v => v.id === node.paramLibId);
const { description: paramLibLabel } = libData;
node.paramLibName = paramLibName;
node.paramLibLabel = paramLibLabel;
};
export { param, constant, methods, dataCollection };
<template>
<!-- 搜索页面 -->
<div id="search">
<iov-table-layout>
<div class="iov-content system" slot="container">
<div class="searchContent">
<el-input
show-word-limit
placeholder="请输入内容"
v-model="searchWords"
class="input-with-select"
>
<el-button slot="append" @click="search">查找</el-button>
</el-input>
<div class="tab">
<el-tabs v-model="type" @tab-click="typeClick" class="tabStyle">
<el-tab-pane
v-for="item in typeList"
:key="item.id"
:label="item.nameCn"
:name="item.id + ',' + item.nameEn"
>
</el-tab-pane>
</el-tabs>
</div>
</div>
<div class="iov-table">
<div class="unData" v-if="typeList.length == 0">
<img src="@/assets/images/img/unDataSearch.png" />
<div class="title">暂无数据</div>
</div>
<iov-table
v-if="typeList.length > 0"
:table-data="table.tableData"
:pageSizes="table.pageSizes"
:table-option="table.option"
:table-loading="table.loading"
:total="table.pageTotal"
:pageSize="table.pageSize"
:pageChange="pageChange"
:sizeChange="sizeChange"
:pageNum="table.pageNum"
:maxHeight="640"
>
</iov-table>
</div>
</div>
</iov-table-layout>
</div>
</template>
<script>
import {
searchType,
searchData,
// 获取字段
getAllFiledsByTableId
} from "./service";
export default {
data() {
return {
searchWords: "",
typeList: [],
table: {
option: [],
tableData: [],
loading: false,
pageNum: 1,
pageSize: 10,
pageSizes: []
},
type: ""
};
},
mounted() {
this.getType();
},
methods: {
async getType() {
const res = await searchType();
if (res.status == "success") {
if (res.content != undefined && res.content != null && res.content.length > 0) {
res.content.map(item => {
// if (item.type == 3) {
this.typeList.push(item);
// }
});
this.type = `${this.typeList[0].id},${this.typeList[0].nameEn}`;
if (this.typeList.length > 0) {
this.getFields();
}
this.getFields();
} else {
this.typeList = [];
this.type = "";
}
} else {
this.typeList = [];
}
},
typeClick(tab) {
this.type = tab.name;
this.getFields();
this.search();
},
async search() {
const reqData = {
userId: localStorage.getItem("userId"),
indexName: this.type.split(",")[1],
keyword: this.searchWords,
pageNum: this.table.pageNum.toString(),
pageSize: this.table.pageSize.toString()
};
const res = await searchData(reqData);
if (res.status == "success") {
if (
res.content.rows != undefined &&
res.content.rows != null &&
res.content.rows.length > 0
) {
this.table.tableData = res.content.rows;
this.table.pageTotal = res.content.total;
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
this.table.loading = false;
},
// 页数改变时调用
pageChange(currentPage) {
this.table.pageNum = currentPage;
this.search();
},
// 一页展示数量改变时调用
sizeChange(size) {
this.table.pageSize = size;
this.table.pageNum = "1";
this.search();
},
async getFields() {
this.table.loading = true;
const reqData = {
tableId: this.type.split(",")[0]
};
const res = await getAllFiledsByTableId(reqData);
this.table.option = [];
const arr = [];
if (res.status == "success") {
if (res.content != undefined && res.content != null && res.content.length > 0) {
this.tableHeadList = res.content;
this.tableHeadList.forEach(item => {
arr.unshift({
prop: item.fieldName,
label: item.fieldNameCn
});
});
} else {
this.tableHeadList = [];
}
} else {
this.tableHeadList = [];
}
if (arr.length > 0) {
this.table.option = arr;
} else {
this.table.option = [
{
prop: "title",
label: "标题"
}
];
}
this.search();
}
}
};
</script>
<style lang="less">
#search .unData {
width: 100%;
height: 76%;
text-align: center;
padding: 8% 0;
.title {
color: #4a4a4a;
}
}
#search .searchContent {
margin: 60px auto 0;
width: 600px;
}
#search .searchContent .el-input {
font-size: 16px;
width: 600px;
height: 45px;
}
#search .searchContent .el-input .el-input__inner {
height: 45px;
width: 470px;
}
#search .searchContent .el-input .el-input-group__append {
text-align: center;
font-size: 16px;
background-color: #3a84ff;
border: 1px solid #3a84ff;
color: #fff;
width: 130px;
}
#search .tableContainer {
background-color: #fff;
}
/*#search .iov-table {*/
/* top: 150px;*/
/*}*/
#search .tab {
padding: 0 82px;
margin-top: 18px;
}
</style>
import fetch from '@/utils/fetch';
// 获取搜索类型
export const searchType = () => fetch('/design/console/mansearchtablerestserver/byAll', {}, 'GET');
// 搜索
export const searchData = data => fetch('/design/displaycenter/displaycenter/fuzzySearch', data, 'POST');
// 根据表id,获取所有字段
export const getAllFiledsByTableId = data => fetch('/design/console/mansearchfieldsrestserver/byCondition', data, 'POST');
<template>
<el-dialog
v-drag
title=" 字段配置"
:visible.sync="show"
id="sitingService"
width="1000px"
:close-on-click-modal="false"
>
<div class="content">
<div id="main">
<div class="btn">
<span>中文名称:</span>
<el-input
show-word-limit
v-model="tableNameCn"
:title="tableNameCn"
placeholder="请输入中文表名"
disabled
style="width:20%;margin:0 10px;"
></el-input>
<el-button type="primary" icon="plus" @click="addField" :disabled="status == '已创建'"
>添加字段</el-button
>
</div>
<el-form :model="{ tableData }" ref="form">
<el-table :data="tableData" height="450px">
<el-table-column type="index" label="序号" width="70"></el-table-column>
<el-table-column label="字段中文名">
<template slot-scope="scope">
<el-form-item
:prop="'tableData.' + scope.$index + '.fieldNameCn'"
:rules="[
{ required: true, message: '请输入中文名' },
{ pattern: /^[\u4E00-\u9FA50-9a-zA-Z_\-.]+$/, message: '请勿输入特殊字符' }
]"
>
<el-input
show-word-limit
type="text"
placeholder="请输入字段中文名"
v-model="scope.row.fieldNameCn"
maxlength="50"
></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="字段英文名">
<template slot-scope="scope">
<el-form-item
:prop="'tableData.' + scope.$index + '.fieldName'"
:rules="[
{ required: true, message: '请输入字段英文名' },
{ pattern: /^[a-zA-Z]{1,50}$/, message: '请输入1~50位纯英文' }
]"
>
<el-input
show-word-limit
type="text"
placeholder="请输入字段英文名"
v-model="scope.row.fieldName"
maxlength="50"
></el-input>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="字段类型">
<template slot-scope="scope">
<el-select
v-model="scope.row.type"
placeholder="请选择字段类型"
filterable
:disabled="status == '已创建'"
>
<el-option v-for="item in typeList" :key="item.id" :value="item"> </el-option>
</el-select>
</template>
</el-table-column>
<el-table-column label="删除" width="80">
<template slot-scope="scope">
<el-button
@click.native.prevent="deleteField(scope.$index)"
type="text"
size="small"
:disabled="status == '已创建'"
>
<i class="el-icon-delete"></i>&nbsp;&nbsp;删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
</div>
</div>
<div class="footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</div>
</el-dialog>
</template>
<script>
import { queryFiled, saveField } from "./service";
class Field {
constructor() {
this.fieldName = "";
this.fieldNameCn = "";
this.type = "text";
this.length = "";
this.isPk = "false";
this.isBusinessPk = "false";
this.isNull = "false";
this.defaultValue = "";
}
}
export default {
data() {
return {
show: false,
tableData: [],
tableNameCn: "",
tableId: "",
status: "",
typeList: [
"text",
"keyword",
"date",
"boolean",
"binary",
"range",
"array",
"object",
"nested",
"byte",
"short",
"integer",
"long",
"float",
"double",
"half_float",
"scaled_float"
],
isShow: false,
form: {}
};
},
methods: {
// 弹框
getPage(data) {
this.show = true;
this.tableId = data.id;
this.status = data.status;
this.tableNameCn = data.nameCn;
this.queryFiled();
},
// 字段回填
async queryFiled() {
const data = {
tableId: this.tableId
};
const res = await queryFiled(data);
this.tableData = res.content;
},
// 添加新的一行空的字段
addField() {
if (!this.checkRepeatCn()) {
this.$message({
type: "info",
message: "中文名不允许重复"
});
} else if (!this.checkRepeat()) {
this.$message({
type: "info",
message: "英文名不允许重复"
});
} else {
this.$refs.form.validate(valid => {
if (valid) {
this.tableData.push(new Field());
}
});
}
},
// 删除一行字段
deleteField(index) {
this.tableData.splice(index, 1);
},
// 中文名查重
checkRepeatCn() {
return (
__.common.unique(this.tableData.map(val => val.fieldNameCn)).length == this.tableData.length
);
},
// 英文查重
checkRepeat() {
return (
__.common.unique(this.tableData.map(val => val.fieldName)).length == this.tableData.length
);
},
// 英文校验
myInput(val) {
const pattern = /^[a-zA-Z0-9_]*$/;
this.isShow = false;
if (pattern.test(val) == false) {
this.$message({
type: "info",
message: "请输入英文"
});
this.isShow = true;
}
},
// 数字校验
lenInput(val) {
const pattern = /^[1-9]\d*$/;
this.isShow = false;
if (pattern.test(val) == false) {
this.$message({
type: "info",
message: "请输入数字"
});
this.isShow = true;
}
},
// 校验联动
checkNull(data) {
if (data.isNull == "true") {
data.isPk = "false";
}
},
checkPk(data) {
if (data.isPk == "true") {
data.isNull = "false";
data.defaultValue = "";
}
},
// 保存
submit() {
let i = 0;
this.tableData.map(val => {
if (val.isPk == "true") {
i++;
}
});
let j = 0;
this.tableData.map(val => {
if (val.isBusinessPk == "true") {
j++;
}
});
if (!this.checkRepeatCn()) {
this.$message({
type: "info",
message: "中文名不允许重复"
});
} else if (!this.checkRepeat()) {
this.$message({
type: "info",
message: "英文名不允许重复"
});
} else {
this.$refs.form.validate(valid => {
if (valid) {
saveField({
tableId: this.tableId,
fields: this.tableData
}).then(res => {
if (res.status == "success") {
this.$message({
message: "保存字段成功",
type: "success"
});
}
this.show = false;
this.$parent.queryData();
});
}
});
}
}
}
};
</script>
<style lang="less">
#sitingService {
.el-dialog__body {
padding: 20px 40px 20px 35px;
.el-form {
margin-top: 20px;
.el-form-item {
margin-bottom: 0;
}
}
.footer {
width: 100%;
margin-top: 10px;
display: flex;
justify-content: flex-end;
}
}
}
</style>
<template>
<div id="serviceDb">
<iov-table-layout
:tree-data="treeData"
:tree-value="selectNode"
tree-title="应用列表"
@tree-click="treeClick"
v-if="treeData"
ref="layout"
:treeStyle="'list'"
>
<div class="iov-content" slot="container">
<div class="iov-tool">
<el-button
type="primary"
@click="create_getPage"
:disabled="!selectNode || selectNode.level == 0 || selectNode == ''"
>新建</el-button
>
<el-button @click="multiDelete" :disabled="mutiDeleteData.length == 0">删除</el-button>
<el-input
show-word-limit
placeholder="请输入搜索信息"
v-model="searchData"
@keyup.enter.native="search"
>
<i slot="suffix" class="el-input__icon el-icon-search" @click="search"></i>
</el-input>
</div>
<!-- 表格数据 -->
<div class="iov-table" v-if="table.tableData">
<iov-table
:table-data="table.tableData"
:table-option="table.option"
:table-loading="table.loading"
:total="table.pageTotal"
:pageSize="table.pageSize"
:pageChange="pageChange"
:sizeChange="sizeChange"
:pageNum="table.pageNum"
:showCheckBox="true"
@selectChange="selectChange"
>
<!-- 右侧操作 -->
<el-table-column
fixed="right"
label="操作"
v-if="table.tableData.length > 0"
slot="operationTool"
width="250px"
>
<template slot-scope="scope">
<el-button @click.native.prevent="edit_getPage(scope.row)" type="text" size="small"
>编辑</el-button
>
<el-button
@click.native.prevent="config_getPage(scope.row)"
type="text"
size="small"
>字段配置</el-button
>
<el-button @click.native.prevent="deleteFields(scope.row)" type="text" size="small"
>删除表结构</el-button
>
</template>
</el-table-column>
</iov-table>
</div>
</div>
</iov-table-layout>
<!-- 新建页面 -->
<createForm ref="create_form"></createForm>
<editForm ref="edit_form"></editForm>
<configForm ref="config_form"></configForm>
</div>
</template>
<script>
import { constants } from "crypto";
import { getTree, queryData, deleteFields, deleting } from "./service";
// 引入相关页面
import createForm from "./create";
import editForm from "./edit";
import configForm from "./config";
export default {
// 注册组件
components: {
createForm,
editForm,
configForm
},
mounted() {
this.getTree();
},
data() {
return {
table: {
option: [
{
prop: "nameCn",
label: "中文名称"
},
{
prop: "nameEn",
label: "英文名称"
},
{
prop: "createDate",
label: "更新时间"
}
],
tableData: [],
loading: false,
pageSize: 10,
pageNum: 1
},
searchData: null,
mutiDeleteData: [],
selectNode: "",
treeData: []
};
},
methods: {
// 获取列表
async getTree() {
const res = await getTree();
if (res.status == "success") {
if (res.content != null && res.content != undefined && res.content.length > 0) {
res.content.map(appList => {
appList.url = "";
appList.name = appList.nameCn + "(" + appList.typeNameCn + ")";
});
this.treeData = res.content;
this.treeClick(this.selectNode || res.content[0]);
} else {
this.treeData = [];
}
} else {
this.treeData = [];
}
},
// 点击分类
treeClick(item) {
this.selectNode = item;
this.queryData();
},
// 表格查询
async queryData() {
this.table.loading = true;
const data = {
condition: {
appId: this.selectNode.id,
keyword: this.searchData
},
pageSize: this.table.pageSize,
pageNum: this.table.pageNum
};
const res = await queryData(data);
if (res.status == "success") {
this.table.tableData = res.content.rows || [];
this.table.pageTotal = res.content.total;
this.table.tableData = this.table.tableData.map(val => {
// 判断创建状态
if (val.status == "1") {
val.status = "已创建";
} else {
val.status = "未创建";
}
return val;
});
} else {
this.table.tableData = [];
this.table.pageTotal = 0;
}
this.table.loading = false;
},
// 搜索
search() {
this.queryData();
},
// 新建
create_getPage() {
this.$refs.create_form.getPage();
},
// 编辑
edit_getPage(data) {
this.$refs.edit_form.getPage(data);
},
pageChange(currentPage) {
this.table.pageNum = currentPage;
this.queryData();
},
sizeChange(size) {
this.table.pageSize = size;
this.queryData();
},
selectChange(data) {
this.mutiDeleteData = data;
},
// 删除
multiDelete() {
__.ui.messageBox("此操作将永久删除该表并且会级联删除该表的所有字段, 是否继续?", () => {
deleting({
ids: this.mutiDeleteData
}).then(res => {
if (res.status == "success") {
this.$message({
message: "删除成功",
type: "success"
});
} else {
this.$message({
message: res.message,
type: "error"
});
}
this.queryData();
});
});
},
// 属性配置
config_getPage(data) {
this.$refs.config_form.getPage(data);
},
baseApiConfig_getPage(data) {
this.$refs.baseApiConfig_form.getPage(data);
},
// 创建表
// async createTmpTable(data) {
// const res = await createTmpTable({
// id: data.id
// });
// if (res.status == "success") {
// this.$message({
// message: "创建表成功",
// type: "success"
// });
// }
// setTimeout(() => {
// this.queryData();
// }, 1000);
// },
// 删除表
// async deleteTable(data) {
// const res = await deleteTable({
// id: data.id
// });
// if (res.status == "success") {
// this.$message({
// message: "删除物理表成功",
// type: "success"
// });
// }
// setTimeout(() => {
// this.queryData();
// }, 1000);
// },
// 删除表字段
deleteFields(data) {
__.ui.messageBox("此操作将永久删除该表结构, 是否继续?", async () => {
const res = await deleteFields({
id: data.id
});
if (res.status == "success") {
this.$message({
message: "删除表结构成功",
type: "success"
});
}
setTimeout(() => {
this.queryData();
}, 1000);
});
}
}
};
</script>
<style>
#serviceDb .serviceDbTable {
top: 90px;
}
</style>
import fetch from '@/utils/fetch';
// 左侧树
export const getTree = () => fetch('/design/appmanage/application/byAll', {}, 'GET');
// 表格查寻
export const queryData = data => fetch('/design/console/mansearchtablerestserver/byPage', data, 'POST');
// 表格新建
export const create = data => fetch('/design/console/mansearchtablerestserver/creating', data, 'POST');
// 表格新建名称查重
export const repeatTabName = data => fetch('/design/console/mansearchtablerestserver/byCondition', data, 'POST');
// 表格编辑
export const edit = data => fetch('/design/console/mansearchtablerestserver/updating', data, 'POST');
// 表格删除
export const deleting = data => fetch('/design/console/mansearchtablerestserver/deleting', data, 'GET');
// 字段新建
export const saveField = data => fetch('/design/console/mansearchfieldsrestserver/saveTableFields', data, 'POST');
// 字段回填查寻
export const queryFiled = data => fetch('/design/console/mansearchfieldsrestserver/byCondition', data, 'POST');
// 删除表字段
export const deleteFields = data => fetch('/design/console/mansearchfieldsrestserver/deleteFields', data, 'GET');
export default function(lib) {
const {
group,
key,
version,
config,
component: {
render: {
layout: { width, height },
},
},
} = lib;
return {
version: "v4",
pages: {
"test-page": {
id: "test-page",
name: "测试",
type: "page",
config: {
width: "100%",
height: "100%",
backgroundColor: "#FFFFFF",
},
events: [],
components: {
"test-component": {
id: "test-component",
alias: "",
type: "online",
group,
key,
version,
layout: {
style: {
width: width + "px",
height: height + "px",
left: 0,
top: 0,
},
cssText: "",
},
event: [],
config,
},
},
},
},
masters: {},
settings: {
initUrl: "test-page",
},
};
}
<template>
<el-dialog
title="组件测试"
v-drag
:visible.sync="visible"
width="1200px"
:close-on-click-modal="false"
id="componentTest"
@close="show = false"
>
<div class="preview">
<stms-designer v-if="show" ref="designer" />
</div>
</el-dialog>
</template>
<script>
import ComponentVersionDao from "@/dao/component-version";
import pageData from "./data";
export default {
data() {
return {
visible: false,
show: false
};
},
methods: {
async init(data) {
const { groupKey: group, componentKey: key, version } = data.row;
this.visible = true;
const component = await this.findYaml({
group,
key,
version
});
this.show = true;
setTimeout(() => {
this.$refs.designer.init({
tools: {
headTitle: {
show: false
},
headMenu: {
show: false
},
headTool: {
show: false
},
controlsLayout: {
show: false
},
workArea: {
pageTab: {
show: false
}
}
},
callback: {
onAppQuery() {
return {
name: "",
data: pageData(component)
};
},
onApiDocQuery() {
return [];
},
onComponentQuery() {
return [];
},
onTemplateQuery() {
return [];
},
onPageQuery() {
return null;
},
onPageQueryDetail() {
return null;
},
onPageSave() {
return null;
},
onAppMenuQuery() {
return [];
},
},
systemInfo: {}
});
});
},
async findYaml(lib) {
const { group, key, version } = lib;
const resp = await ComponentVersionDao.findYaml({
params: {
group,
key,
version
}
});
return resp.data.content;
}
}
};
</script>
<style lang="less">
#componentTest {
.el-dialog__body {
padding-bottom: 20px;
}
.preview {
height: 630px;
}
}
</style>
<template>
<el-dialog
title="导出组件"
v-drag
:visible.sync="show"
:close-on-click-modal="false"
>
<el-form :model="form" :rules="rules" ref="form" label-width="80px">
<el-form-item label="组件" prop="componentList">
<stms-dropdown-tree :data="componentData" v-model="form.componentList">
</stms-dropdown-tree>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import ComponentVersionDao from "@/dao/component-group";
export default {
data() {
return {
show: false,
componentData: [],
form: {
componentList: [],
},
rules: {
componentList: [
{
required: true,
message: "请选择组件",
},
],
},
};
},
methods: {
async init() {
this.show = true;
this.form.componentList = [];
this.queryComponentTree();
},
async queryComponentTree() {
const res = await ComponentVersionDao.queryComponentTree();
if (res.data.status === "success") {
this.componentData = res.data.content;
}
},
submit() {
this.$refs.form.validate((valid) => {
if (valid) {
this.show = false;
ComponentVersionDao.componentExport({
data: this.form.componentList,
}).then((res) => {
const { status, content } = res.data;
if (status === "success") {
window.open(content + "?attname=组件仓库.zip");
}
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less"></style>
<template>
<el-dialog title="导入组件" v-drag :visible.sync="show" ref="dialog">
<el-form :model="form" ref="form">
<el-upload
class="upload-demo"
ref="uploadXml"
drag
:before-upload="beforeUpload"
:on-change="handleChage"
:on-success="handleSuccess"
:on-error="handleError"
action="/design/component/componentGroup/componentImport"
multiple
:data="uploadData"
:auto-upload="false"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
只能上传zip文件,且不超过50M
</div>
</el-upload>
<el-form-item label="导入类型" prop="" style="margin-top: 20px;">
<el-radio-group v-model="uploadData.importType">
<el-radio label="skip">跳过重复数据</el-radio>
<el-radio label="update">覆盖重复数据</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="uploadFile()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
show: false,
uploadData: {
importType: "skip",
},
list: [],
};
},
mounted() {
this.list = [];
},
methods: {
async init() {
this.show = true;
uploadData: {
importType: "skip";
}
},
handleChage(file, fileList) {
this.list = fileList;
},
beforeUpload(file) {
var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
const extension = testmsg === "zip";
const isLt2M = file.size / 1024 / 1024 < 50;
if (!extension) {
this.$message({
message: "上传文件只能是zip格式!",
type: "warning",
});
}
if (!isLt2M) {
this.$message({
message: "上传文件大小不能超过 50MB!",
type: "warning",
});
}
return extension && isLt2M;
},
// 文件上传成功时的钩子
handleSuccess(res, file, fileList) {
this.$message.success({
title: "成功",
message: res.message,
});
},
// 文件上传失败时的钩子
handleError(err, file, fileList) {
this.$message.error({
title: "错误",
message: `文件上传失败`,
});
this.show = true;
},
// 点击【导入】按钮时上传文件
uploadFile() {
if (this.list.length === 0) {
this.$message({
type: "warning",
message: `请上传文件`,
});
return;
}
this.show = false;
this.$refs.uploadXml.submit();
setTimeout(() => {
this.$parent.$parent.dispatch("queryComponentGroup");
}, 300);
},
},
};
</script>
<style lang="less"></style>
<template>
<stms-layout :options="options">
<component-test ref="component_test"></component-test>
<import-form ref="import_form"></import-form>
<export-form ref="export_form"></export-form>
</stms-layout>
</template>
<script>
import options from "./options";
import ComponentTest from "./component-test";
import importForm from "./import";
import exportForm from "./export";
export default {
components: {
ComponentTest,
importForm,
exportForm,
},
data() {
return {
options,
dispatch: null,
};
},
mounted() {
this.$set(
this.options.table.events,
"actionbarClick/preview",
async ({ dispatch, modal }, payload) => {
this.$refs.component_test.init(payload);
}
);
this.$set(
this.options.table.events,
"toolbarClick/import",
async ({ dispatch, modal }, payload) => {
this.dispatch = dispatch;
this.$refs.import_form.init(payload);
}
);
this.$set(
this.options.table.events,
"toolbarClick/export",
async ({ dispatch, modal }, payload) => {
this.$refs.export_form.init(payload);
}
);
},
};
</script>
import ComponentGroupDao from "@/dao/component-group";
import ComponentDao from "@/dao/component";
import ComponentVersionDao from "@/dao/component-version";
export default {
async queryComponentGroup({ component }) {
let list = [];
const resp = await ComponentGroupDao.findByAll();
const {
data: { status, content }
} = resp;
if (status == "success") {
list = content;
}
component("list1").action("setData", list);
component("list1").action("setActive");
},
async createComponentGroup({ dispatch }, payload) {
await ComponentGroupDao.create({
data: {
parentId: 0,
...payload
}
});
await dispatch("queryComponentGroup");
},
async editComponentGroup({ dispatch }, payload) {
await ComponentGroupDao.edit({
data: payload
});
await dispatch("queryComponentGroup");
},
async deleteComponentGroup({ dispatch }, payload) {
await ComponentGroupDao.delete({
params: payload
});
await dispatch("queryComponentGroup");
},
async queryComponent({ component }) {
const active = component("list1").action("getActive");
let list = [];
const resp = await ComponentDao.findByCondition({
data: { groupId: active.id }
});
const {
data: { status, content }
} = resp;
if (status == "success") {
list = content;
}
component("list2").action("setData", list);
component("list2").action("setActive");
},
async createComponent({ component, dispatch }, payload) {
const active = component("list1").action("getActive");
await ComponentDao.create({
data: { ...payload, groupKey: active.key, groupId: active.id }
});
await dispatch("queryComponent");
},
async editComponent({ dispatch }, payload) {
await ComponentDao.edit({
data: payload
});
await dispatch("queryComponent");
},
async deleteComponent({ dispatch }, payload) {
await ComponentDao.delete({
params: payload
});
await dispatch("queryComponent");
},
async queryComponentVersion({ component }, payload) {
const active = component("list2").action("getActive");
if (!active) {
return;
}
const data = component("table").action("getQueryData");
data.condition.componentId = active.id;
component("table").action("setLoading", true);
try {
const resp = await ComponentVersionDao.findByPage({
data
});
const { content, status } = resp.data;
if (status == "success") {
component("table").action("setData", {
data: content.rows,
total: content.total
});
}
component("table").action("setLoading", false);
} catch (error) {
component("table").action("setLoading", false);
}
},
async createComponentVersion({ dispatch }, payload) {
await ComponentVersionDao.create({
data: payload
});
await dispatch("queryComponentVersion");
},
async editComponentVersion({ dispatch }, payload) {
await ComponentVersionDao.edit({
data: payload
});
await dispatch("queryComponentVersion");
},
async deleteComponentVersion({ dispatch }, payload) {
await ComponentVersionDao.delete({
params: payload
});
await dispatch("queryComponentVersion");
}
};
import list1 from "./list1";
import list2 from "./list2";
import table from "./table";
import action from "./action";
const solution = STUI.default.LayoutSolution.use("DoubleCategoryTable");
solution.bindAction(action);
solution.uninstall("breadcrumb");
solution.extends("list1", list1);
solution.extends("list2", list2);
solution.extends("table", table);
export default solution.export();
const schema = [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写名称"
}
]
},
{
prop: "key",
label: "key",
type: "input",
props: {
placeholder: "请填写组名",
showWordLimit: true,
maxlength: 100
},
rules: [
{
required: true,
message: "请填写组名"
},
{
pattern: /^([a-z0-9]+)(\.([a-z0-9]+))+$/,
message: "组名格式为xxx.xxx.xxx,至少一个点分隔,由小写字母、数字组成"
}
]
},
{
prop: "nameEn",
label: "英文名称",
type: "input",
props: {
placeholder: "请填写英文名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写英文名称"
}
]
},
{
prop: "tag",
label: "标签",
type: "input",
props: {
placeholder: "请填写标签名称",
showWordLimit: true,
maxlength: 10
},
rules: [
{
required: true,
message: "请填写标签名称"
}
]
}
];
export default {
"config.title": "组件分类",
"config.toolbar.edit.disabled": ({ component }) => {
return !component("list1").action("getActive");
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("list1").action("getActive");
},
"events.init": async ({ dispatch }) => {
await dispatch("queryComponentGroup");
},
"events.change": async ({ dispatch }) => {
await dispatch("queryComponent");
},
"events.toolbarClick/create": async ({ dispatch, modal }) => {
modal({
data: {},
title: "新建组件组",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("createComponentGroup", data);
await dispatch("queryComponentGroup");
close();
}
});
},
"events.toolbarClick/edit": async ({ dispatch, component, modal }) => {
const active = component("list1").action("getActive");
modal({
data: active,
title: "编辑组件组",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("editComponentGroup", data);
await dispatch("queryComponentGroup");
close();
}
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const active = component("list1").action("getActive");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteComponentGroup", {
ids: active.id
});
await dispatch("queryComponentGroup");
}
});
}
};
const schema = [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit:true,
maxlength:20
},
rules: [
{
required: true,
message: "请填写名称"
}
]
},
{
prop: "key",
label: "key",
type: "input",
props: {
placeholder: "请填写key",
showWordLimit:true,
maxlength:100
},
rules: [
{
required: true,
message: "请填写key"
}
]
},
{
prop: "iconUrl",
label: "图标",
type: "upload-file",
props: {
placeholder: "请上传图标",
type: "image",
data: {
groupId: "B1855275E53E4568B3FCBA2C6111BDB8"
}
}
},
{
prop: "desc",
label: "描述",
type: "input",
props: {
type: "textarea",
placeholder: "请填写描述",
showWordLimit:true,
maxlength:100
}
}
];
export default {
"config.title": "组件列表",
"config.toolbar.edit.disabled": ({ component }) => {
return !component("list2").action("getActive");
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("list2").action("getActive");
},
"events.change": async ({ dispatch }) => {
await dispatch("queryComponentVersion", {
init: true
});
},
"events.toolbarClick/create": async ({ dispatch, modal }) => {
modal({
data: {},
title: "新建组件",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("createComponent", data);
await dispatch("queryComponent");
close();
}
});
},
"events.toolbarClick/edit": async ({ dispatch, component, modal }) => {
const active = component("list2").action("getActive");
modal({
data: active,
title: "编辑组件",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("editComponent", data);
await dispatch("queryComponent");
close();
}
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const active = component("list2").action("getActive");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteComponent", {
ids: active.id
});
await dispatch("queryComponent");
}
});
}
};
import YAML from "yaml";
// 查重
import fetch from "@/utils/fetch";
export const repeatNamess = data => fetch("/design/component/componentVersion/byCondition", { componentId: repeatNameKey, version: replaceData(data) }, "POST");
let repeatNameKey = "";
let oldVersion = "";
function replaceData(data) {
console.log("reloacedata", data)
if (data == oldVersion) {
return " "
} else {
return data
}
}
const tableSchema = [
{
prop: "componentKey",
label: "名称",
},
{
prop: "version",
label: "版本",
},
{
prop: "status",
label: "状态",
render(data) {
const map = {
online: "上线",
offline: "下线",
};
return map[data];
},
},
];
const schema = ({ component, modal }) => {
const activeComponentGroup = component("list1").action("getActive");
const activeComponent = component("list2").action("getActive");
return [
{
prop: "version",
label: "版本",
type: "input",
props: {
placeholder: "请填写版本",
showWordLimit: true,
maxlength: 50,
},
rules: [
{
required: true,
message: "请填写版本",
},
{
pattern: /^([0-9]\d|[0-9])(\.([0-9]\d|\d)){2}$/,
message: "版本号格式为x.x.x三位数字格式",
}, {
validator: async function (rule, value, callback) {
if (oldVersion == value) {
return callback()
} else {
const a = await repeatNamess(value)
if (a.content.length > 0) {
return callback(new Error("版本号已使用,请重试"))
} else {
return callback()
}
}
}
}
],
},
{
prop: "yaml",
label: "Yaml",
type: "ace-editor",
props: {
mode: "yaml",
height: "300px",
placeholder: "请填写Yaml",
},
rules: [
{
required: true,
message: "请填写Yaml",
},
{
validator: (rule, value, callback) => {
if (value) {
const json = YAML.parse(value);
if (typeof json !== "object") {
return callback(new Error("yaml格式错误"));
}
const { name, group, key, version } = json;
if (!name) return callback(new Error("yaml中name为必填"));
if (!group) return callback(new Error("yaml中group为必填"));
if (!key) return callback(new Error("yaml中key为必填"));
if (!version) return callback(new Error("yaml中version为必填"));
if (group !== activeComponentGroup.key)
return callback(new Error("yaml中group值与所选组不匹配"));
if (name !== activeComponent.name)
return callback(new Error("yaml中name值与所选组件不匹配"));
if (key !== activeComponent.key)
return callback(new Error("yaml中key值与所选组件不匹配"));
return callback();
}
},
},
],
},
{
prop: "desc",
label: "描述",
type: "rich-text-editor",
props: {
type: "textarea",
placeholder: "请填写描述",
},
},
];
};
export default {
"config.schema": tableSchema,
"events.pageChange": async ({ dispatch }) => {
await dispatch("queryComponentVersion");
},
"config.actionbar.delete.show": false,
"config.actionbar.preview": {
order: 2,
show: true,
disabled: false,
type: "text",
size: "small",
text: "预览",
},
"config.actionbar.online": {
order: 3,
show: (options, item, data) => data.status === "offline",
disabled: false,
type: "text",
size: "small",
text: "上线",
},
"config.actionbar.offline": {
order: 4,
show: (options, item, data) => data.status === "online",
disabled: false,
type: "text",
size: "small",
text: "下线",
},
"config.toolbar.import": {
order: 5,
show: true,
disabled: false,
type: "success",
size: "small",
text: "导入",
},
"config.toolbar.export": {
order: 6,
show: true,
disabled: false,
type: "info",
size: "small",
text: "导出",
},
"config.toolbar.create.text": "新建版本",
"config.toolbar.create.disabled": ({ component }) => {
return (
!component("list1").action("getActive") ||
!component("list2").action("getActive")
);
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("table").action("getSelection").length;
},
"events.search": async ({ dispatch }) => {
dispatch("queryComponentVersion");
},
"events.toolbarClick/create": async ({ dispatch, component, modal }, payload) => {
const createListData = component(
"list2"
).action("getActive");
repeatNameKey = createListData.id;
console.log("repeatNameKey: ", repeatNameKey)
modal({
data: {},
title: "新建组件版本",
width: "907px",
confirmText: "确定",
showCancel: false,
schema: schema({ component, modal }),
onConfirm: async ({ data, close }) => {
const { id: groupId, key: groupKey } = component("list1").action(
"getActive"
);
const { id: componentId, key: componentKey } = component(
"list2"
).action("getActive");
await dispatch("createComponentVersion", {
...data,
groupId,
groupKey,
componentId,
componentKey,
});
close();
},
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const selection = component("table").action("getSelection");
const ids = selection.map((v) => v.id).join(",");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteComponentVersion", {
ids,
});
},
});
},
"events.actionbarClick/edit": async (
{ dispatch, modal, component },
payload
) => {
const { row } = payload;
repeatNameKey = payload.row.componentId;
oldVersion = payload.row.version
console.log("repeatNameKey:", repeatNameKey, payload)
modal({
data: row,
title: "编辑组件版本",
width: "907px",
confirmText: "确定",
showCancel: false,
schema: schema({ component }),
onConfirm: async ({ data, close }) => {
await dispatch("editComponentVersion", data);
close();
},
});
},
"events.actionbarClick/online": async ({ dispatch, confirm }, payload) => {
const { row } = payload;
confirm({
title: "是否上线",
content: "即将上线所选数据,是否继续",
confirmButtonText: "上线",
cancelButtonText: "关闭",
onConfirm: async () => {
await dispatch("editComponentVersion", {
id: row.id,
status: "online",
});
},
});
},
"events.actionbarClick/offline": async ({ dispatch, confirm }, payload) => {
const { row } = payload;
confirm({
title: "是否下线",
content: "即将下线所选数据,是否继续",
confirmButtonText: "下线",
cancelButtonText: "关闭",
onConfirm: async () => {
await dispatch("editComponentVersion", {
id: row.id,
status: "offline",
});
},
});
},
};
<template>
<div class="web-component">
<el-menu mode="horizontal" router :default-active="defaultActive">
<el-menu-item
v-for="(item, index) in menu"
:key="index"
:route="item.path"
:index="index"
>{{ item.name }}</el-menu-item
>
</el-menu>
<div class="web-component-view">
<router-view />
</div>
</div>
</template>
<script>
import * as URL from "@/config/url";
export default {
components: {},
data() {
return {
defaultActive: null,
menu: [
{
path: URL.WEB_COMPONENT_COMPONENT,
name: "组件开发",
},
{
path: URL.WEB_COMPONENT_TEMPLATE,
name: "模板开发",
},
],
};
},
mounted() {
this.defaultActive = this.menu.findIndex(
(v) => v.path === this.$route.path
);
},
};
</script>
<style lang="less" scoped>
.web-component {
height: 100%;
width: 100%;
.el-menu {
display: flex;
justify-content: left;
.el-menu-item {
height: 50px;
line-height: 50px;
}
}
.web-component-view {
height: calc(100% - 51px);
width: 100%;
}
}
</style>
<template>
<div class="preview">
<stms-viewer ref="viewer" />
</div>
</template>
<script>
import TemplateVersionDao from "@/dao/template-version";
export default {
data() {
return {
visible: false,
};
},
mounted() {
this.init();
},
methods: {
async init(data) {
const { group, key, version } = __.url.getUrlParams();
if (group && key && version) {
this.$refs.viewer.init({
callback: {
onAppQuery: async () => {
const page = await this.findJson({
group,
key,
version,
});
return {
name: "模板开发",
data: __.json.jsonParse(page),
};
},
},
systemInfo: {},
});
}
},
async findJson(lib) {
const { group, key, version } = lib;
const resp = await TemplateVersionDao.findJson({
params: {
group,
key,
version,
},
});
return resp.data.content;
},
},
};
</script>
<style lang="less" scoped>
.preview {
position: fixed;
z-index: 999;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
}
</style>
export default function() {
return {
version: "v3",
pages: {
"template-page": {
id: "template-page",
name: "模板页面",
config: {
width: "100%",
height: "100%",
backgroundColor: "#FFFFFF"
},
events: [],
components: {}
}
},
masters: {},
settings: {
initUrl: "template-page"
}
};
}
<template>
<el-dialog
title="导出模板"
v-drag
:visible.sync="show"
:close-on-click-modal="false"
>
<el-form :model="form" ref="form" :rules="rules" label-width="80px">
<el-form-item label="模板" prop="templateList">
<stms-dropdown-tree :data="templateData" v-model="form.templateList">
</stms-dropdown-tree>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="submit()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
import TemplateGroupDao from "@/dao/template-group";
export default {
data() {
return {
show: false,
templateData: [],
form: {
templateList: [],
},
rules: {
templateList: [
{
required: true,
message: "请选择组件",
},
],
},
};
},
methods: {
async init() {
this.show = true;
this.form.templateList = [];
this.queryTemplateTree();
},
async queryTemplateTree() {
const res = await TemplateGroupDao.queryTemplateTree();
if (res.data.status === "success") {
this.templateData = res.data.content;
}
},
submit() {
this.$refs.form.validate((valid) => {
if (valid) {
this.show = false;
TemplateGroupDao.templateExport({
data: this.form.templateList,
}).then((res) => {
const { status, content } = res.data;
if (status === "success") {
window.open(content + "?attname=模板管理.zip");
}
});
} else {
return false;
}
});
},
},
};
</script>
<style lang="less"></style>
<template>
<el-dialog title="导入模板" v-drag :visible.sync="show" ref="dialog">
<el-form :model="form" ref="form" class="config-test-form">
<el-upload
class="upload-demo"
ref="uploadXml"
drag
:before-upload="beforeUpload"
:on-change="handleChage"
:on-success="handleSuccess"
:on-error="handleError"
action="/design/component/templateGroup/templateImport"
multiple
:data="uploadData"
:auto-upload="false"
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">
将文件拖到此处,或
<em>点击上传</em>
</div>
<div class="el-upload__tip" slot="tip">
只能上传zip文件,且不超过50M
</div>
</el-upload>
<el-form-item label="导入类型" prop="" style="margin-top: 20px;">
<el-radio-group v-model="uploadData.importType">
<el-radio label="skip">跳过重复数据</el-radio>
<el-radio label="update">覆盖重复数据</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button type="primary" @click="uploadFile()">确 定</el-button>
</span>
</el-dialog>
</template>
<script>
export default {
data() {
return {
show: false,
uploadData: {
importType: "skip",
},
list: [],
};
},
mounted() {
this.list = [];
},
methods: {
async init() {
this.show = true;
uploadData: {
importType: "skip";
}
},
handleChage(file, fileList) {
this.list = fileList;
},
beforeUpload(file) {
var testmsg = file.name.substring(file.name.lastIndexOf(".") + 1);
const extension = testmsg === "zip";
const isLt2M = file.size / 1024 / 1024 < 50;
if (!extension) {
this.$message({
message: "上传文件只能是zip格式!",
type: "warning",
});
}
if (!isLt2M) {
this.$message({
message: "上传文件大小不能超过 50MB!",
type: "warning",
});
}
return extension && isLt2M;
},
// 文件上传成功时的钩子
handleSuccess(res, file, fileList) {
this.$message.success({
title: "成功",
message: res.message,
});
},
// 文件上传失败时的钩子
handleError(err, file, fileList) {
this.$message.error({
title: "错误",
message: `文件上传失败`,
});
this.show = true;
},
// 点击【导入】按钮时上传文件
uploadFile() {
if (this.list.length === 0) {
this.$message({
type: "warning",
message: `请上传文件`,
});
return;
}
this.show = false;
this.$refs.uploadXml.submit();
setTimeout(() => {
this.$parent.$parent.dispatch("queryTemplateGroup");
}, 300);
},
},
};
</script>
<style lang="less"></style>
<template>
<stms-layout :options="options">
<template-develop ref="template_develop"></template-develop>
<import-form ref="import_form"></import-form>
<export-form ref="export_form"></export-form>
</stms-layout>
</template>
<script>
import options from "./options";
import TemplateDevelop from "./template-develop";
import importForm from "./import";
import exportForm from "./export";
export default {
components: {
TemplateDevelop,
importForm,
exportForm,
},
data() {
return {
options,
dispatch: null,
};
},
mounted() {
this.$set(
this.options.table.events,
"actionbarClick/design",
async ({ dispatch, modal }, payload) => {
this.$refs.template_develop.init(payload);
}
);
this.$set(
this.options.table.events,
"toolbarClick/import",
async ({ dispatch, modal }, payload) => {
this.dispatch = dispatch;
this.$refs.import_form.init(payload);
}
);
this.$set(
this.options.table.events,
"toolbarClick/export",
async ({ dispatch, modal }, payload) => {
this.$refs.export_form.init(payload);
}
);
},
};
</script>
import TemplateGroupDao from "@/dao/template-group";
import TemplateDao from "@/dao/template";
import TemplateVersionDao from "@/dao/template-version";
export default {
async queryTemplateGroup({ component }) {
let list = [];
const resp = await TemplateGroupDao.findByAll();
const {
data: { status, content }
} = resp;
if (status == "success") {
list = content;
}
component("list1").action("setData", list);
component("list1").action("setActive");
},
async createTemplateGroup({ dispatch }, payload) {
await TemplateGroupDao.create({
data: {
parentId: 0,
...payload
}
});
await dispatch("queryTemplateGroup");
},
async editTemplateGroup({ dispatch }, payload) {
await TemplateGroupDao.edit({
data: payload
});
await dispatch("queryTemplateGroup");
},
async deleteTemplateGroup({ dispatch }, payload) {
await TemplateGroupDao.delete({
params: payload
});
await dispatch("queryTemplateGroup");
},
async queryTemplate({ component }) {
const active = component("list1").action("getActive");
let list = [];
const resp = await TemplateDao.findByCondition({
data: { groupId: active.id }
});
const {
data: { status, content }
} = resp;
if (status == "success") {
list = content;
}
component("list2").action("setData", list);
component("list2").action("setActive");
},
async createTemplate({ component, dispatch }, payload) {
const active = component("list1").action("getActive");
await TemplateDao.create({
data: { ...payload, groupKey: active.key, groupId: active.id }
});
await dispatch("queryTemplate");
},
async editTemplate({ dispatch }, payload) {
await TemplateDao.edit({
data: payload
});
await dispatch("queryTemplate");
},
async deleteTemplate({ dispatch }, payload) {
await TemplateDao.delete({
params: payload
});
await dispatch("queryTemplate");
},
async queryTemplateVersion({ component }, payload) {
const active = component("list2").action("getActive");
if (!active) {
return;
}
const data = component("table").action("getQueryData");
data.condition.templateId = active.id;
component("table").action("setLoading", true);
try {
const resp = await TemplateVersionDao.findByPage({
data
});
const { content, status } = resp.data;
if (status == "success") {
component("table").action("setData", {
data: content.rows,
total: content.total
});
}
component("table").action("setLoading", false);
} catch (error) {
component("table").action("setLoading", false);
}
},
async createTemplateVersion({ dispatch }, payload) {
await TemplateVersionDao.create({
data: payload
});
await dispatch("queryTemplateVersion");
},
async editTemplateVersion({ dispatch }, payload) {
await TemplateVersionDao.edit({
data: payload
});
await dispatch("queryTemplateVersion");
},
async deleteTemplateVersion({ dispatch }, payload) {
await TemplateVersionDao.delete({
params: payload
});
await dispatch("queryTemplateVersion");
}
};
import list1 from "./list1";
import list2 from "./list2";
import table from "./table";
import action from "./action";
const solution = STUI.default.LayoutSolution.use("DoubleCategoryTable");
solution.bindAction(action);
solution.uninstall("breadcrumb");
solution.extends("list1", list1);
solution.extends("list2", list2);
solution.extends("table", table);
export default solution.export();
const schema = [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写名称"
}
]
},
{
prop: "key",
label: "key",
type: "input",
props: {
placeholder: "请填写组名",
showWordLimit: true,
maxlength: 100
},
rules: [
{
required: true,
message: "请填写组名"
},
{
pattern: /^([a-z0-9]+)(\.([a-z0-9]+))+$/,
message: "组名格式为xxx.xxx.xxx,至少一个点分隔,由小写字母、数字组成"
}
]
},
{
prop: "nameEn",
label: "英文名称",
type: "input",
props: {
placeholder: "请填写英文名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写英文名称"
}
]
},
{
prop: "tag",
label: "标签",
type: "input",
props: {
placeholder: "请填写标签名称",
showWordLimit: true,
maxlength: 10
},
rules: [
{
required: true,
message: "请填写标签名称"
}
]
}
];
export default {
"config.title": "模板分类",
"config.toolbar.edit.disabled": ({ component }) => {
return !component("list1").action("getActive");
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("list1").action("getActive");
},
"events.init": async ({ dispatch }) => {
await dispatch("queryTemplateGroup");
},
"events.change": async ({ dispatch }) => {
await dispatch("queryTemplate");
},
"events.toolbarClick/create": async ({ dispatch, modal }) => {
modal({
data: {},
title: "新建模板组",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("createTemplateGroup", data);
await dispatch("queryTemplateGroup");
close();
}
});
},
"events.toolbarClick/edit": async ({ dispatch, component, modal }) => {
const active = component("list1").action("getActive");
modal({
data: active,
title: "编辑模板组",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("editTemplateGroup", data);
await dispatch("queryTemplateGroup");
close();
}
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const active = component("list1").action("getActive");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteTemplateGroup", {
ids: active.id
});
await dispatch("queryTemplateGroup");
}
});
}
};
const schema = [
{
prop: "name",
label: "名称",
type: "input",
props: {
placeholder: "请填写名称",
showWordLimit: true,
maxlength: 20
},
rules: [
{
required: true,
message: "请填写名称"
}
]
},
{
prop: "key",
label: "key",
type: "input",
props: {
placeholder: "请填写key",
showWordLimit: true,
maxlength: 100
},
rules: [
{
required: true,
message: "请填写key"
}
]
},
{
prop: "iconUrl",
label: "图标",
type: "upload-file",
props: {
placeholder: "请上传图标",
type: "image",
data: {
groupId: "B1855275E53E4568B3FCBA2C6111BDB8"
}
}
},
{
prop: "desc",
label: "描述",
type: "input",
props: {
type: "textarea",
placeholder: "请填写描述",
showWordLimit: true,
maxlength: 100
}
}
];
export default {
"config.title": "模板列表",
"config.toolbar.edit.disabled": ({ component }) => {
return !component("list2").action("getActive");
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("list2").action("getActive");
},
"events.change": async ({ dispatch }) => {
await dispatch("queryTemplateVersion", {
init: true
});
},
"events.toolbarClick/create": async ({ dispatch, modal }) => {
modal({
data: {},
title: "新建模板",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("createTemplate", data);
await dispatch("queryTemplate");
close();
}
});
},
"events.toolbarClick/edit": async ({ dispatch, component, modal }) => {
const active = component("list2").action("getActive");
modal({
data: active,
title: "编辑模板",
schema,
onConfirm: async ({ data, close }) => {
await dispatch("editTemplate", data);
await dispatch("queryTemplate");
close();
}
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const active = component("list2").action("getActive");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteTemplate", {
ids: active.id
});
await dispatch("queryTemplate");
}
});
}
};
import pageData from "../data";
// 查重
import fetch from "@/utils/fetch";
export const repeatNamess = data => fetch("/design/component/templateVersion/byCondition", { templateId: repeatNameKey, version: replaceData(data) }, "POST");
let repeatNameKey = "";
let oldVersion = "";
function replaceData(data) {
console.log("reloacedata", data)
if (data == oldVersion) {
return " "
} else {
return data
}
}
const tableSchema = [
{
prop: "templateKey",
label: "名称",
},
{
prop: "version",
label: "版本",
},
{
prop: "desc",
label: "描述",
},
{
prop: "status",
label: "状态",
render(data) {
const map = {
online: "上线",
offline: "下线",
};
return map[data];
},
},
];
const schema = () => {
return [
{
prop: "version",
label: "版本",
type: "input",
props: {
placeholder: "请填写版本",
showWordLimit: true,
maxlength: 50,
},
rules: [
{
required: true,
message: "请填写版本",
},
{
pattern: /^([0-9]\d|[0-9])(\.([0-9]\d|\d)){2}$/,
message: "版本号格式为x.x.x三位数字格式",
},
{
validator: async function (rule, value, callback) {
if (oldVersion == value) {
return callback()
} else {
const a = await repeatNamess(value)
if (a.content.length > 0) {
return callback(new Error("版本号已使用,请重试"))
} else {
return callback()
}
}
}
}
],
},
{
prop: "desc",
label: "描述",
type: "input",
props: {
type: "textarea",
placeholder: "请填写描述",
showWordLimit:true,
maxlength:100
},
},
];
};
export default {
"config.schema": tableSchema,
"events.pageChange": async ({ dispatch }) => {
await dispatch("queryTemplateVersion");
},
"config.actionbar.delete.show": false,
"config.actionbar.design": {
order: 2,
show: true,
disabled: false,
type: "text",
size: "small",
text: "设计",
},
"config.actionbar.online": {
order: 3,
show: (options, item, data) => data.status === "offline",
disabled: false,
type: "text",
size: "small",
text: "上线",
},
"config.actionbar.offline": {
order: 4,
show: (options, item, data) => data.status === "online",
disabled: false,
type: "text",
size: "small",
text: "下线",
},
"config.toolbar.import": {
order: 5,
show: true,
disabled: false,
type: "success",
size: "small",
text: "导入",
},
"config.toolbar.export": {
order: 6,
show: true,
disabled: false,
type: "info",
size: "small",
text: "导出",
},
"config.toolbar.create.text": "新建版本",
"config.toolbar.create.disabled": ({ component }) => {
return (
!component("list1").action("getActive") ||
!component("list2").action("getActive")
);
},
"config.toolbar.delete.disabled": ({ component }) => {
return !component("table").action("getSelection").length;
},
"events.search": async ({ dispatch }) => {
dispatch("queryTemplateVersion");
},
"events.toolbarClick/create": async ({ dispatch, component, modal }) => {
const createListData = component(
"list2"
).action("getActive");
repeatNameKey = createListData.id;
console.log("repeatNameKey: ", repeatNameKey)
modal({
data: {},
title: "新建模板版本",
width: "800px",
confirmText: "确定",
showCancel: false,
schema: schema({ component }),
onConfirm: async ({ data, close }) => {
const { id: groupId, key: groupKey } = component("list1").action(
"getActive"
);
const { id: templateId, key: templateKey } = component("list2").action(
"getActive"
);
await dispatch("createTemplateVersion", {
...data,
groupId,
groupKey,
templateId,
templateKey,
templateJson: JSON.stringify(pageData()),
});
close();
},
});
},
"events.toolbarClick/delete": async ({ dispatch, component, confirm }) => {
const selection = component("table").action("getSelection");
const ids = selection.map((v) => v.id).join(",");
confirm({
title: "是否删除",
content: "即将删除所选数据,是否继续",
confirmButtonText: "删除",
cancelButtonText: "关闭",
closeOnClickModal: false,
onConfirm: async () => {
await dispatch("deleteTemplateVersion", {
ids,
});
},
});
},
"events.actionbarClick/edit": async (
{ dispatch, modal, component },
payload
) => {
const { row } = payload;
repeatNameKey = payload.row.componentId;
oldVersion = payload.row.version
console.log("repeatNameKey:", repeatNameKey, payload)
modal({
data: row,
title: "编辑模板版本",
width: "800px",
confirmText: "确定",
showCancel: false,
schema: schema({ component }),
onConfirm: async ({ data, close }) => {
await dispatch("editTemplateVersion", data);
close();
},
});
},
"events.actionbarClick/online": async ({ dispatch, confirm }, payload) => {
const { row } = payload;
confirm({
title: "是否上线",
content: "即将上线所选数据,是否继续",
confirmButtonText: "上线",
cancelButtonText: "关闭",
onConfirm: async () => {
await dispatch("editTemplateVersion", { id: row.id, status: "online" });
},
});
},
"events.actionbarClick/offline": async ({ dispatch, confirm }, payload) => {
const { row } = payload;
confirm({
title: "是否下线",
content: "即将下线所选数据,是否继续",
confirmButtonText: "下线",
cancelButtonText: "关闭",
onConfirm: async () => {
await dispatch("editTemplateVersion", {
id: row.id,
status: "offline",
});
},
});
},
};
<template>
<div class="templateDevelop" v-if="visible">
<stms-designer ref="designer" />
</div>
</template>
<script>
import TemplateVersionDao from "@/dao/template-version";
export default {
data() {
return {
visible: false,
};
},
methods: {
async init(data) {
const { id, groupKey: group, templateKey: key, version } = data.row;
this.visible = true;
this.$nextTick(() => {
this.$refs.designer.init({
tools: {
headMenu: {
menu: {
publish: {
item: {
tag: {
show: false,
},
menu: {
show: false,
},
},
},
view: {
item: {
panel: {
subItem: {
master: {
show: false,
},
page: {
show: false,
},
},
},
},
},
publish: {
item: {
preview: {
click() {
window.open(
`/component/#/web-component/preview?group=${group}&key=${key}&version=${version}`
);
},
},
previewCurrent: {
show: false,
},
},
},
help: {
show: false,
},
},
},
headTool: {
custom: {
tools: {
preview: {
click() {
window.open(
`/component/#/web-component/preview?group=${group}&key=${key}&version=${version}`
);
},
},
previewCurrent: {
show: false,
},
apiDoc: {
show: false,
},
},
},
appSettings: {
show: false,
},
},
controlsLayout: {
item: {
master: {
show: false,
},
page: {
show: false,
},
},
},
workArea: {
pageTab: {
show: false,
},
},
},
callback: {
onAppQuery: async () => {
const page = await this.findJson({
group,
key,
version,
});
return {
name: "模板开发",
data: __.json.jsonParse(page),
};
},
onAppSave: async (params) => {
const { data } = params;
TemplateVersionDao.edit({
data: {
id,
templateJson: __.json.jsonStringify(data),
},
});
},
onApiDocQuery: () => {
return [];
},
onAppBack: () => {
this.visible = false;
},
onPageQuery() {
return null;
},
onPageQueryDetail() {
return null;
},
onPageSave() {
return null;
},
},
systemInfo: {},
});
});
},
async findJson(lib) {
const { group, key, version } = lib;
const resp = await TemplateVersionDao.findJson({
params: {
group,
key,
version,
},
});
return resp.data.content;
},
},
};
</script>
<style lang="less" scoped>
.templateDevelop {
position: fixed;
z-index: 999;
height: 100%;
width: 100%;
top: 0;
left: 0;
background: #fff;
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment