|
@@ -12,8 +12,8 @@
|
|
<el-form-item
|
|
<el-form-item
|
|
v-if="
|
|
v-if="
|
|
inputShow[item.name] &&
|
|
inputShow[item.name] &&
|
|
- item.type != 'dycustComponents' &&
|
|
|
|
- item.type != 'dynamic-add-table'
|
|
|
|
|
|
+ item.type != 'dycustComponents' &&
|
|
|
|
+ item.type != 'dynamic-add-table'
|
|
"
|
|
"
|
|
:label="item.label"
|
|
:label="item.label"
|
|
:prop="item.name"
|
|
:prop="item.name"
|
|
@@ -22,7 +22,7 @@
|
|
<el-input-number
|
|
<el-input-number
|
|
v-if="item.type == 'el-input-number'"
|
|
v-if="item.type == 'el-input-number'"
|
|
size="mini"
|
|
size="mini"
|
|
- style="width:100%"
|
|
|
|
|
|
+ style="width: 100%"
|
|
v-model.trim="formData[item.name]"
|
|
v-model.trim="formData[item.name]"
|
|
controls-position="right"
|
|
controls-position="right"
|
|
@change="changed($event, item.name)"
|
|
@change="changed($event, item.name)"
|
|
@@ -58,7 +58,7 @@
|
|
<ColorPicker
|
|
<ColorPicker
|
|
v-if="item.type == 'vue-color'"
|
|
v-if="item.type == 'vue-color'"
|
|
v-model="formData[item.name]"
|
|
v-model="formData[item.name]"
|
|
- @change="val => changed(val, item.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, item.name)"
|
|
/>
|
|
/>
|
|
<customUpload
|
|
<customUpload
|
|
v-if="item.type == 'custom-upload'"
|
|
v-if="item.type == 'custom-upload'"
|
|
@@ -69,7 +69,7 @@
|
|
<el-radio-group
|
|
<el-radio-group
|
|
v-if="item.type == 'el-radio-group'"
|
|
v-if="item.type == 'el-radio-group'"
|
|
v-model="formData[item.name]"
|
|
v-model="formData[item.name]"
|
|
- @change="val => changed(val, item.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, item.name)"
|
|
>
|
|
>
|
|
<el-radio
|
|
<el-radio
|
|
v-for="itemChild in item.selectOptions"
|
|
v-for="itemChild in item.selectOptions"
|
|
@@ -85,7 +85,7 @@
|
|
v-model="formData[item.name]"
|
|
v-model="formData[item.name]"
|
|
clearable
|
|
clearable
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
- @change="val => changed(val, item.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, item.name)"
|
|
>
|
|
>
|
|
<el-option
|
|
<el-option
|
|
v-for="itemChild in item.selectOptions"
|
|
v-for="itemChild in item.selectOptions"
|
|
@@ -98,7 +98,7 @@
|
|
<el-slider
|
|
<el-slider
|
|
v-if="item.type == 'el-slider'"
|
|
v-if="item.type == 'el-slider'"
|
|
v-model="formData[item.name]"
|
|
v-model="formData[item.name]"
|
|
- @change="val => changed(val, item.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, item.name)"
|
|
/>
|
|
/>
|
|
|
|
|
|
<el-button
|
|
<el-button
|
|
@@ -110,6 +110,14 @@
|
|
>编辑</el-button
|
|
>编辑</el-button
|
|
>
|
|
>
|
|
|
|
|
|
|
|
+ <el-button
|
|
|
|
+ v-if="item.type == 'methods'"
|
|
|
|
+ type="primary"
|
|
|
|
+ size="mini"
|
|
|
|
+ @click="methodsVisible = true"
|
|
|
|
+ >添加事件</el-button
|
|
|
|
+ >
|
|
|
|
+
|
|
<!-- 弹窗 -->
|
|
<!-- 弹窗 -->
|
|
<el-dialog
|
|
<el-dialog
|
|
title="代码编辑"
|
|
title="代码编辑"
|
|
@@ -131,6 +139,23 @@
|
|
<el-button type="primary" @click="saveData">确 定</el-button>
|
|
<el-button type="primary" @click="saveData">确 定</el-button>
|
|
</span>
|
|
</span>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
+
|
|
|
|
+ <el-dialog
|
|
|
|
+ title="代码编辑"
|
|
|
|
+ :visible.sync="methodsVisible"
|
|
|
|
+ width="50%"
|
|
|
|
+ :before-close="handleClose"
|
|
|
|
+ >
|
|
|
|
+ <monaco-editor
|
|
|
|
+ v-model.trim="formData[item.name]"
|
|
|
|
+ language="javascript"
|
|
|
|
+ style="height: 500px"
|
|
|
|
+ />
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="methodsVisible = false">取 消</el-button>
|
|
|
|
+ <el-button type="primary" @click="saveData">确 定</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<dynamicComponents
|
|
<dynamicComponents
|
|
v-if="item.type == 'dycustComponents' && inputShow[item.name]"
|
|
v-if="item.type == 'dycustComponents' && inputShow[item.name]"
|
|
@@ -149,7 +174,8 @@
|
|
v-if="item.type == 'dynamic-add-radar' && inputShow[item.name]"
|
|
v-if="item.type == 'dynamic-add-radar' && inputShow[item.name]"
|
|
v-model="formData[item.name]"
|
|
v-model="formData[item.name]"
|
|
:chart-type="item.chartType"
|
|
:chart-type="item.chartType"
|
|
- @change="changed($event, item.name)"/>
|
|
|
|
|
|
+ @change="changed($event, item.name)"
|
|
|
|
+ />
|
|
</div>
|
|
</div>
|
|
<div v-else-if="isShowForm(item, '[object Array]')" :key="'a-' + index">
|
|
<div v-else-if="isShowForm(item, '[object Array]')" :key="'a-' + index">
|
|
<el-collapse accordion>
|
|
<el-collapse accordion>
|
|
@@ -169,7 +195,7 @@
|
|
<el-input-number
|
|
<el-input-number
|
|
v-if="itemChildList.type == 'el-input-number'"
|
|
v-if="itemChildList.type == 'el-input-number'"
|
|
size="mini"
|
|
size="mini"
|
|
- style="width:100%"
|
|
|
|
|
|
+ style="width: 100%"
|
|
v-model="formData[itemChildList.name]"
|
|
v-model="formData[itemChildList.name]"
|
|
controls-position="right"
|
|
controls-position="right"
|
|
:placeholder="itemChildList.placeholder"
|
|
:placeholder="itemChildList.placeholder"
|
|
@@ -207,7 +233,7 @@
|
|
<ColorPicker
|
|
<ColorPicker
|
|
v-if="itemChildList.type == 'vue-color'"
|
|
v-if="itemChildList.type == 'vue-color'"
|
|
v-model="formData[itemChildList.name]"
|
|
v-model="formData[itemChildList.name]"
|
|
- @change="val => changed(val, itemChildList.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, itemChildList.name)"
|
|
/>
|
|
/>
|
|
|
|
|
|
<el-upload
|
|
<el-upload
|
|
@@ -220,7 +246,7 @@
|
|
<el-radio-group
|
|
<el-radio-group
|
|
v-if="itemChildList.type == 'el-radio-group'"
|
|
v-if="itemChildList.type == 'el-radio-group'"
|
|
v-model="formData[itemChildList.name]"
|
|
v-model="formData[itemChildList.name]"
|
|
- @change="val => changed(val, itemChildList.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, itemChildList.name)"
|
|
>
|
|
>
|
|
<el-radio
|
|
<el-radio
|
|
v-for="it in itemChildList.selectOptions"
|
|
v-for="it in itemChildList.selectOptions"
|
|
@@ -236,7 +262,7 @@
|
|
v-model="formData[itemChildList.name]"
|
|
v-model="formData[itemChildList.name]"
|
|
clearable
|
|
clearable
|
|
placeholder="请选择"
|
|
placeholder="请选择"
|
|
- @change="val => changed(val, itemChildList.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, itemChildList.name)"
|
|
>
|
|
>
|
|
<el-option
|
|
<el-option
|
|
v-for="it in itemChildList.selectOptions"
|
|
v-for="it in itemChildList.selectOptions"
|
|
@@ -249,7 +275,7 @@
|
|
<el-slider
|
|
<el-slider
|
|
v-if="itemChildList.type == 'el-slider'"
|
|
v-if="itemChildList.type == 'el-slider'"
|
|
v-model="formData[itemChildList.name]"
|
|
v-model="formData[itemChildList.name]"
|
|
- @change="val => changed(val, itemChildList.name)"
|
|
|
|
|
|
+ @change="(val) => changed(val, itemChildList.name)"
|
|
/>
|
|
/>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
<customColorComponents
|
|
<customColorComponents
|
|
@@ -282,6 +308,7 @@ import customColorComponents from "./customColorComponents";
|
|
import dynamicAddTable from "./dynamicAddTable.vue";
|
|
import dynamicAddTable from "./dynamicAddTable.vue";
|
|
import customUpload from "./customUpload.vue";
|
|
import customUpload from "./customUpload.vue";
|
|
import dynamicAddRadar from "./dynamicAddRadar";
|
|
import dynamicAddRadar from "./dynamicAddRadar";
|
|
|
|
+import MonacoEditor from "@/components/MonacoEditor/index";
|
|
export default {
|
|
export default {
|
|
name: "DynamicForm",
|
|
name: "DynamicForm",
|
|
components: {
|
|
components: {
|
|
@@ -291,24 +318,26 @@ export default {
|
|
customColorComponents,
|
|
customColorComponents,
|
|
dynamicAddTable,
|
|
dynamicAddTable,
|
|
customUpload,
|
|
customUpload,
|
|
- dynamicAddRadar
|
|
|
|
|
|
+ dynamicAddRadar,
|
|
|
|
+ MonacoEditor,
|
|
},
|
|
},
|
|
model: {
|
|
model: {
|
|
prop: "value",
|
|
prop: "value",
|
|
- event: "input"
|
|
|
|
|
|
+ event: "input",
|
|
},
|
|
},
|
|
props: {
|
|
props: {
|
|
options: Array,
|
|
options: Array,
|
|
value: {
|
|
value: {
|
|
type: [Object],
|
|
type: [Object],
|
|
- default: () => {}
|
|
|
|
- }
|
|
|
|
|
|
+ default: () => {},
|
|
|
|
+ },
|
|
},
|
|
},
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
formData: {},
|
|
formData: {},
|
|
inputShow: {}, // 控制表单是否显示
|
|
inputShow: {}, // 控制表单是否显示
|
|
dialogVisibleStaticData: false,
|
|
dialogVisibleStaticData: false,
|
|
|
|
+ methodsVisible: false,
|
|
validationRules: "",
|
|
validationRules: "",
|
|
optionsJavascript: {
|
|
optionsJavascript: {
|
|
mode: "text/javascript",
|
|
mode: "text/javascript",
|
|
@@ -318,9 +347,9 @@ export default {
|
|
styleActiveLine: true, // 高亮选中行
|
|
styleActiveLine: true, // 高亮选中行
|
|
|
|
|
|
hintOptions: {
|
|
hintOptions: {
|
|
- completeSingle: true // 当匹配只有一项的时候是否自动补全
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ completeSingle: true, // 当匹配只有一项的时候是否自动补全
|
|
|
|
+ },
|
|
|
|
+ },
|
|
};
|
|
};
|
|
},
|
|
},
|
|
watch: {
|
|
watch: {
|
|
@@ -330,7 +359,7 @@ export default {
|
|
options(val) {
|
|
options(val) {
|
|
this.setDefaultValue();
|
|
this.setDefaultValue();
|
|
this.isShowData();
|
|
this.isShowData();
|
|
- }
|
|
|
|
|
|
+ },
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
this.isShowData();
|
|
this.isShowData();
|
|
@@ -365,6 +394,7 @@ export default {
|
|
saveData() {
|
|
saveData() {
|
|
this.$emit("onChanged", this.formData);
|
|
this.$emit("onChanged", this.formData);
|
|
this.dialogVisibleStaticData = false;
|
|
this.dialogVisibleStaticData = false;
|
|
|
|
+ this.methodsVisible = false;
|
|
},
|
|
},
|
|
// 静态数据
|
|
// 静态数据
|
|
addStaticData() {
|
|
addStaticData() {
|
|
@@ -372,6 +402,7 @@ export default {
|
|
},
|
|
},
|
|
handleClose() {
|
|
handleClose() {
|
|
this.dialogVisibleStaticData = false;
|
|
this.dialogVisibleStaticData = false;
|
|
|
|
+ this.methodsVisible = false;
|
|
},
|
|
},
|
|
// 组件属性 数据是否展示动态还是静态数据
|
|
// 组件属性 数据是否展示动态还是静态数据
|
|
isShowData() {
|
|
isShowData() {
|
|
@@ -386,7 +417,7 @@ export default {
|
|
data.push(this.options[i]);
|
|
data.push(this.options[i]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- data.forEach(el => {
|
|
|
|
|
|
+ data.forEach((el) => {
|
|
if (el.relactiveDomValue != currentData.value) {
|
|
if (el.relactiveDomValue != currentData.value) {
|
|
this.inputShow[el.name] = false;
|
|
this.inputShow[el.name] = false;
|
|
}
|
|
}
|
|
@@ -404,7 +435,7 @@ export default {
|
|
} else if (Object.prototype.toString.call(obj) == "[object Array]") {
|
|
} else if (Object.prototype.toString.call(obj) == "[object Array]") {
|
|
for (let j = 0; j < obj.length; j++) {
|
|
for (let j = 0; j < obj.length; j++) {
|
|
const list = obj[j].list;
|
|
const list = obj[j].list;
|
|
- list.forEach(el => {
|
|
|
|
|
|
+ list.forEach((el) => {
|
|
this.formData[el.name] = el.value;
|
|
this.formData[el.name] = el.value;
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -416,8 +447,8 @@ export default {
|
|
// 是否显示 那种格式
|
|
// 是否显示 那种格式
|
|
isShowForm(val, type) {
|
|
isShowForm(val, type) {
|
|
return Object.prototype.toString.call(val) == type;
|
|
return Object.prototype.toString.call(val) == type;
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+ },
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
|
|
|