FlowFormRightSubSetting.vue
8.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<template>
<el-dialog
top="8vh"
width="70%"
title="设置子表数据授权"
:visible.sync="dialogVisibleSetting"
append-to-body
class="urgent-text"
:close-on-click-modal="false"
>
<div style="width:100%;height: 550px;">
<div style="float: left;width:25%;height: 100%;">
<ht-tree
style="overflow: auto;height: 100%;"
:data="treeData"
:props="defaultProps"
default-expand-all
@node-click="handleNodeClick"
:expand-on-click-node="false"
ref="htTypeTree"
></ht-tree>
</div>
<div style="width:73%;float: left;margin-left: 10px;height: 100%;">
<table class="form-table" cellspacing="0" cellpadding="0" border="0">
<tbody>
<tr>
<th width="130px">操作子表:</th>
<td>{{editingRight.tableName?editingRight.tableName:"请先选择需要编辑的子表"}}</td>
</tr>
<tr>
<th width="130px">操作提示:</th>
<td style="color: red; ">保存的结果为SQL语句,如:return "a.F_wb1 in('1','2')";<br/>return "a.F_wb1 in('1','2',\'"+scriptImpl.getCurrentUserName()+"\')";</td>
</tr>
<tr>
<th width="130px">SQL:</th>
<td>
<div>
<!-- 常用脚本选择对话框 -->
<eip-script-dialog
ref="whenSaveDialog"
v-model="editingRight.script"
append-to-body
/>
<el-button @click="showScriptDialog()">常用脚本</el-button>
</div>
<el-row style="height:100%;padding-top: 10px;">
<codemirror
v-model="editingRight.script"
:options="cmStyle"
style="width: 99%;height:100%;"
></codemirror>
</el-row>
</td>
</tr>
</tbody>
</table>
<div slot="footer" class="dialog-footer" style="float: right;padding-top: 40px;">
<el-button type="danger" size="small" @click="close">取 消</el-button>
<el-button type="danger" size="small" @click="clean">清除权限</el-button>
<el-button type="primary" size="small" @click="saveDataDialog">保 存</el-button>
</div>
</div>
</div>
</el-dialog>
</template>
<script>
const eipScriptDialog = () => import("@/components/dialog/EipScriptDialog.vue");
import { Message } from "element-ui";
import req from "@/request.js";
export default {
name: "FlowFormRightSubSetting",
components: { eipScriptDialog},
props: {
defId: String,
nodeId: String,
defkey: String,
parentDefKey:String
},
data() {
return {
treeData: [], //树数据
defaultProps: {
children: "children",
label: "desc"
},
sql:"",
cmStyle: {
value: "",
mode: "groovy",
readOnly: false,
smartIndent: true,
tabSize: 2,
theme: "base16-light",
lineNumbers: true,
line: true
},
dialogVisibleSetting:false,
editingRight:{tableName:"",script:"",nodeId:"",parentDefKey:this.parentDefKey},//子表配置
data:{}
};
},
methods: {
//显示常用脚本
showScriptDialog() {
if(this.editingRight.script == ''){
this.$message.warning("请先选择需要编辑的子表");
return;
}
this.$refs.whenSaveDialog.showDialog();
},
//设置子表数据授权对话框保存事件
saveDataDialog() {
const this_ = this;
if(this_.editingRight.tableName == ''){
this_.$message.warning("请先选择需要编辑的子表");
return;
}
if(this_.editingRight.script == ''){
this_.$message.warning("请编写SQL语句");
return;
}
req.post(window.context.bpmModel +"/flow/node/v1/saveSub?defId="+this_.defId+"&nodeId="+this_.nodeId+"&parentDefKey="+this_.parentDefKey,this_.data).then(function(res){
if(res.data.state){
this_.$confirm(res.data.message+",是否继续操作?", "提示", {cancelButtonText: "取消",confirmButtonText: "确定",type: "warning"}) .then(() => {
}).catch(() => {
this_.dialogVisibleSetting = false;
});
}
});
},
//显示设置子表数据授权对话框
showDialog(){
const this_ = this;
this_.editingRight = {tableName:"",script:"",nodeId:"",parentDefKey:this.parentDefKey};
this_.data = {};
this_.dialogVisibleSetting = true;
//获取子表表单字段变量
req.post(window.context.bpmModel + "/flow/node/v1/varTree", {
defId: this_.defId,
nodeId: this_.nodeId,
includeBpmConstants : false,
removeMain : true
})
.then(function(respose) {
this_.treeData = respose.data;
//获取已编辑的子表权限设置
req.get(window.context.bpmModel +"/flow/node/v1/initSub?defId="+this_.defId+"&nodeId="+this_.nodeId+"&parentDefKey="+this_.parentDefKey).then(function(data){
if(JSON.stringify(data.data) != "{}"){
this_.data = data.data;
}
});
});
},
//树鼠标左击事件(treeNode:当前节点对象,node:可以拿到父节点对象)
handleNodeClick(treeNode, node, nodeCompent) {
//先处理tableName的赋值
let preTableName = this.editingRight.tableName;
if (treeNode.nodeType == "sub") {
this.editingChange(treeNode.name);
}
if (treeNode.nodeType == "field") {
this.editingChange(node.parent.data.name);
}
if (preTableName != this.editingRight.tableName) {
return;
}
let prefix;
if (treeNode.nodeType == "bfield") {
prefix = "b";
} else {
prefix = "a";
}
if(treeNode.fieldName!=undefined){
let str = prefix + "." + treeNode.fieldName;
this.editingRight.script = this.editingRight.script+str;
}
},
editingChange(tableName){
if(this.data[tableName]==undefined){
let json = {};
json.nodeId=this.nodeId;
json.parentDefKey=this.parentDefKey;
json.tableName=tableName;
json.script="return sql;";
this.data[tableName]=json;
}
this.editingRight = this.data[tableName];
},
//清除权限
clean(){
const this_ = this;
this.$confirm("确定清除所有子表授权?","提示",
{
cancelButtonText: "取消",
confirmButtonText: "确定",
type: "warning",
closeOnClickModal: false
}
).then(() => {
req.post(window.context.bpmModel +"/flow/node/v1/saveSub?defId="+this_.defId+"&nodeId="+this_.nodeId+"&parentDefKey="+this_.parentDefKey,{}).then(function(data){
data = data.data;
if (data.state) {
this_.$message.success({
duration: 1000, message: "清除成功", onClose: function () {
this_.dialogVisibleSetting = false;
}
});
} else {
this_.$message.error(data.message);
}
});
});
},
//关闭侧边栏
close() {
this.dialogVisibleSetting = false;
},
},
};
</script>
<style lang="scss" scoped>
@import "@/assets/css/form-editor.scss";
div >>> .el-dialog__body {
padding: 10px 20px;
color: #606266;
font-size: 14px;
word-break: break-all;
}
.el-main {
padding-top: 0px;
}
.urgent-text {
width: 100%;
}
.ht {
width: 100%;
}
.bo-set__card {
height: calc(100% - 5px);
}
.bo-set__card /deep/ > div.el-card__header {
padding: 8px 20px;
}
.bo-set__card /deep/ > div.el-card__body {
height: calc(100% - 65px);
padding: 10px 0 10px 10px;
}
.bo-set__table th,
.bo-set__card /deep/ > div.el-card__header,
.bo-set__detail /deep/ > .el-table__header-wrapper > table > thead th {
background: #f9f9f9;
}
.bo-set__table th,
.bo-set__table td {
padding: 5px 15px !important;
}
</style>