|
@@ -5,13 +5,15 @@ import {
|
|
|
ElAndXc,
|
|
|
PageStore
|
|
|
} from "@/views/data-base/page-editor-help-v2/page-help-v2";
|
|
|
-import {ref, h, nextTick, onMounted, reactive} from "vue";
|
|
|
-import {ElOption, ElSelect, ElSwitch, ElInput, ElInputNumber, ElDivider, ElButton} from "element-plus";
|
|
|
-import {PageHeader, PageJsonObject} from "@/api/reports/report-query-center";
|
|
|
import * as vue from "vue";
|
|
|
+import {h, nextTick, onMounted, reactive, ref} from "vue";
|
|
|
+import {ElButton, ElDivider, ElInput, ElInputNumber, ElOption, ElSelect, ElSwitch} from "element-plus";
|
|
|
+import {PageHeader, PageJsonObject} from "@/api/reports/report-query-center";
|
|
|
import CodeEditor from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/CodeEditor.vue";
|
|
|
import JsonEditor from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/JsonEditor.vue";
|
|
|
import {xcMessage} from "@/utils/xiaochan-element-plus";
|
|
|
+import XEUtils from "xe-utils";
|
|
|
+import {copyStrFunc} from "@/utils/public";
|
|
|
|
|
|
const showDiv = ref(false)
|
|
|
const componentBinds = ref<{ [key: string]: ComponentBind } | null>()
|
|
@@ -77,14 +79,17 @@ async function changeCurrentBind(item) {
|
|
|
* 组件属性的额外配置
|
|
|
*/
|
|
|
function renderHelp() {
|
|
|
+ const {currentClickIndex, pageData} = props.store
|
|
|
const func = new Function("pageJson", "currentBind", "el", "vue", 'xcMessage', renderRef.value)
|
|
|
- return func(props.store.pageData.value, currentItem.value, ElAndXc, vue, xcMessage)
|
|
|
+ return func(props.store.pageData.value, pageData.value.header[currentClickIndex.value], ElAndXc, vue, xcMessage)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 绑定组件属性的 事件
|
|
|
*/
|
|
|
function onFuncHelp() {
|
|
|
+ const {currentClickIndex, pageData} = props.store
|
|
|
+
|
|
|
for (let key in componentBinds.value) {
|
|
|
const item = componentBinds.value[key]
|
|
|
const func = {}
|
|
@@ -93,7 +98,7 @@ function onFuncHelp() {
|
|
|
func[capitalizeFirstLetter(itemKey, 'on')] = (val) => {
|
|
|
const func = new Function("pageJson", "currentBind", "val", item.on[itemKey])
|
|
|
try {
|
|
|
- func(props.store.pageData.value, currentItem.value, val)
|
|
|
+ func(props.store.pageData.value, pageData.value.header[currentClickIndex.value], val)
|
|
|
} catch (e) {
|
|
|
console.error(e)
|
|
|
}
|
|
@@ -174,12 +179,15 @@ function render(key: string, item: ComponentBind) {
|
|
|
}
|
|
|
|
|
|
function handleClickEdit(key: string, value: any, name: 'on' | 'func') {
|
|
|
+ const {currentClickIndex, pageData} = props.store
|
|
|
+ currentItem.value = pageData.value.header[currentClickIndex.value]
|
|
|
if (!currentItem.value[name]) {
|
|
|
currentItem.value[name] = {}
|
|
|
}
|
|
|
if (!currentItem.value[name][key]) {
|
|
|
currentItem.value[name][key] = ''
|
|
|
}
|
|
|
+
|
|
|
codeEditorOption.code = currentItem.value[name][key]
|
|
|
codeEditorOption.dialog = true
|
|
|
codeEditorOption.prompt = value
|
|
@@ -209,6 +217,18 @@ function editStyleClick() {
|
|
|
jsonEditOrOption.key = 'style'
|
|
|
}
|
|
|
|
|
|
+function exportJSON() {
|
|
|
+ const temp = XEUtils.clone(currentItem.value)
|
|
|
+ const bind = temp.bind
|
|
|
+ delete temp.bind
|
|
|
+ const tempData = {
|
|
|
+ bind: bind,
|
|
|
+ data: temp
|
|
|
+ }
|
|
|
+
|
|
|
+ copyStrFunc(JSON.stringify(tempData))
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
emits('refresh')
|
|
|
})
|
|
@@ -232,6 +252,7 @@ defineExpose({
|
|
|
|
|
|
<teleport :to="props.teleportDiv">
|
|
|
<div style="text-align: left; padding: 0 15px">
|
|
|
+ <el-button @click="exportJSON" icon="RefreshLeft" type="primary" text>导出JSON</el-button>
|
|
|
<el-button @click="emits('refresh')" icon="RefreshLeft" type="primary" text>刷新</el-button>
|
|
|
</div>
|
|
|
<div v-if="componentBinds && showDiv" class="page_help-bind-container">
|