|
|
@@ -102,7 +102,7 @@
|
|
|
class="copy-btn">
|
|
|
复制代码
|
|
|
</a-button>
|
|
|
- <a-button @click="saveCode" @keydown="keyDownHandleSaveCode" type="primary" :loading="submitLoading"> 保存(Ctrl
|
|
|
+ <a-button @click="saveCode" type="primary" :loading="submitLoading"> 保存(Ctrl
|
|
|
+ S)
|
|
|
</a-button>
|
|
|
<a-button @click="viewCode" type="dashed" class="copy-btn"> 查看历史</a-button>
|
|
|
@@ -143,7 +143,7 @@ export default {
|
|
|
title: '代码',
|
|
|
objectId: undefined,
|
|
|
submitLoading: false,
|
|
|
- activeKey: 'initVar',
|
|
|
+ activeKey: 'loadAfter',
|
|
|
size: 'small',
|
|
|
customEvents: [
|
|
|
{
|
|
|
@@ -290,7 +290,7 @@ export default {
|
|
|
this.editorJsCode = '';
|
|
|
|
|
|
if (type == '0') {
|
|
|
- this.activeKey = 'initVar';
|
|
|
+ this.activeKey = 'loadAfter';
|
|
|
this.objectId = this.config.event[this.activeKey];
|
|
|
this.eventObj = this.customEvents.find((v) => v.key == this.activeKey);
|
|
|
} else if (type == '1') {
|
|
|
@@ -310,6 +310,7 @@ export default {
|
|
|
},
|
|
|
|
|
|
async getCode(objectId, type) {
|
|
|
+
|
|
|
this.loading = true;
|
|
|
const {success, data} = await getJsStr({objectid: objectId});
|
|
|
this.loading = false;
|
|
|
@@ -317,10 +318,12 @@ export default {
|
|
|
this.$nextTick(() => {
|
|
|
if (!isString(data)) {
|
|
|
if (type == '0') {
|
|
|
- this.editorJsCode = `
|
|
|
-//固定写法
|
|
|
+ const selectedItem = this.customEvents.find(item => item.key == this.activeKey)
|
|
|
+ this.editorJsCode = `/**
|
|
|
+ * ${selectedItem.name}
|
|
|
+ */
|
|
|
(() => {
|
|
|
- console.log("this", this)
|
|
|
+ console.log("this", this)
|
|
|
|
|
|
|
|
|
|
|
|
@@ -328,20 +331,30 @@ export default {
|
|
|
})()
|
|
|
`;
|
|
|
} else if (type == '1') {
|
|
|
- this.editorJsCode = `
|
|
|
-//固定写法
|
|
|
+ this.editorJsCode = `/**
|
|
|
+ * 值改变事件
|
|
|
+ */
|
|
|
((bizObj) => {
|
|
|
- const { value, key, record, tableInfo } = bizObj;
|
|
|
+ // value 修改后的值
|
|
|
+ // key 字段的编码
|
|
|
+ // record 字段的属性
|
|
|
+ // tableInfo 仅在子表的值改变事件中有效
|
|
|
+ // tableInfo.rowIndex 修改的行的索引
|
|
|
+ // tableInfo.column.dataIndex 修改的列的编码
|
|
|
+ const { value, key, record, tableInfo } = bizObj;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-})(bizObj)
|
|
|
-`;
|
|
|
+
|
|
|
+
|
|
|
+})(bizObj)`;
|
|
|
} else if (type == '2') {
|
|
|
- this.editorJsCode = `
|
|
|
-//固定写法
|
|
|
+ this.editorJsCode = `// 自定义校验
|
|
|
+// rule.message 设置校验提示信息
|
|
|
+// return true 校验通过
|
|
|
+// return false 校验不通过
|
|
|
const { rule, value } = bizObj;
|
|
|
rule.message = '错误信息'
|
|
|
if (value == '1') {
|
|
|
@@ -349,7 +362,6 @@ if (value == '1') {
|
|
|
} else {
|
|
|
return false//没有通过校验
|
|
|
}
|
|
|
-
|
|
|
`
|
|
|
}
|
|
|
} else {
|