|
@@ -6,7 +6,7 @@ import {
|
|
|
PageStore
|
|
|
} from "@/views/data-base/page-editor-help-v2/page-help-v2";
|
|
|
import * as vue from "vue";
|
|
|
-import {h, nextTick, onMounted, ref} from "vue";
|
|
|
+import {h, nextTick, onMounted, ref, computed, Ref} from "vue";
|
|
|
import {ElButton, ElDivider, ElInput, ElInputNumber, ElOption, ElSelect, ElSwitch} from "element-plus";
|
|
|
import {PageHeader} from "@/api/reports/report-query-center";
|
|
|
import {xcMessage} from "@/utils/xiaochan-element-plus";
|
|
@@ -15,7 +15,7 @@ import {copyStrFunc} from "@/utils/public";
|
|
|
import {reportQueryCenterApi} from "@/api/base-data/report-center";
|
|
|
import PageHelpOtherConfigurations
|
|
|
from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageHelpOtherConfigurations.vue";
|
|
|
-import {cyCodeEditorDialog, CyJsonEditorDialog} from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
|
|
|
+import {CyCodeEditorDialog, CyJsonEditorDialog} from "@/components/cy/cy-monaco-editor/CyMonacoEditor";
|
|
|
import {useUserStore} from "@/pinia/user-store";
|
|
|
|
|
|
const showDiv = ref(false)
|
|
@@ -29,6 +29,41 @@ const props = defineProps<{
|
|
|
const userStore = useUserStore()
|
|
|
const emits = defineEmits(['refresh', 'requiredChange'])
|
|
|
|
|
|
+const tmpKey = ref('')
|
|
|
+
|
|
|
+function handelKeyBlur() {
|
|
|
+ const {pageData} = props.store
|
|
|
+
|
|
|
+ pageData.value.params[tmpKey.value] = pageData.value.params[currentItem.value.key]
|
|
|
+ pageData.value.paramsDefaultValue[tmpKey.value] = pageData.value.paramsDefaultValue[currentItem.value.key]
|
|
|
+ currentItem.value.key = tmpKey.value
|
|
|
+
|
|
|
+ const keys = XEUtils.eachAndReturnList(pageData.value.header, (item) => {
|
|
|
+ return item.key
|
|
|
+ })
|
|
|
+
|
|
|
+ clearOtherKeys(keys, pageData.value.params)
|
|
|
+ clearOtherKeys(keys, pageData.value.paramsDefaultValue)
|
|
|
+}
|
|
|
+
|
|
|
+function clearOtherKeys(keys: string[], params: {}) {
|
|
|
+
|
|
|
+ const tmp = Object.keys(params)
|
|
|
+
|
|
|
+ const clearKey: string[] = [];
|
|
|
+ tmp.forEach(item => {
|
|
|
+ if (!keys.includes(item)) {
|
|
|
+ clearKey.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+
|
|
|
+ clearKey.forEach(item => {
|
|
|
+ //@ts-ignore
|
|
|
+ delete params[item]
|
|
|
+ })
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
const currentItem = ref<PageHeader>({
|
|
|
key: "",
|
|
|
compKey: "",
|
|
@@ -77,6 +112,7 @@ async function changeCurrentBind(item) {
|
|
|
formFunc.value = bindData.value[item.name].func
|
|
|
}
|
|
|
onFuncHelp()
|
|
|
+ tmpKey.value = currentItem.value.key
|
|
|
await nextTick()
|
|
|
showDiv.value = true
|
|
|
}
|
|
@@ -124,14 +160,14 @@ function render(key: string, item: ComponentBind) {
|
|
|
|
|
|
const vModel = {
|
|
|
modelValue: currentItem.value.bind[key],
|
|
|
- "onUpdate:modelValue": (value) => {
|
|
|
+ "onUpdate:modelValue": (value: any) => {
|
|
|
currentItem.value.bind[key] = value
|
|
|
},
|
|
|
...getFunc()
|
|
|
}
|
|
|
|
|
|
function selectRender() {
|
|
|
- const child = []
|
|
|
+ const child: any[] = []
|
|
|
item.selectData?.forEach(value => {
|
|
|
//@ts-ignore
|
|
|
child.push(h(ElOption, {label: value, value: value}, () => null))
|
|
@@ -144,13 +180,13 @@ function render(key: string, item: ComponentBind) {
|
|
|
activeValue: true,
|
|
|
inactiveValue: false,
|
|
|
...vModel
|
|
|
- }, null)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function inputRender() {
|
|
|
return h(ElInput, {
|
|
|
...vModel
|
|
|
- }, null)
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
function numberRender() {
|
|
@@ -163,7 +199,7 @@ function render(key: string, item: ComponentBind) {
|
|
|
text: true,
|
|
|
icon: 'Edit',
|
|
|
onClick: () => {
|
|
|
- CyJsonEditorDialog(currentItem.value?.bind[key]).then(res => {
|
|
|
+ CyJsonEditorDialog(currentItem.value?.bind[key], null).then(res => {
|
|
|
currentItem.value!.bind[key] = res.json
|
|
|
})
|
|
|
}
|
|
@@ -193,13 +229,17 @@ function handleClickEdit(key: string, value: any, name: 'on' | 'func') {
|
|
|
currentItem.value = pageData.value.header[currentClickIndex.value]
|
|
|
|
|
|
if (!currentItem.value[name]) {
|
|
|
+ // @ts-ignore
|
|
|
currentItem.value[name] = {}
|
|
|
}
|
|
|
+ // @ts-ignore
|
|
|
if (!currentItem.value[name][key]) {
|
|
|
+ // @ts-ignore
|
|
|
currentItem.value[name][key] = ''
|
|
|
}
|
|
|
|
|
|
- cyCodeEditorDialog({
|
|
|
+ CyCodeEditorDialog({
|
|
|
+ // @ts-ignore
|
|
|
code: currentItem.value[name][key],
|
|
|
testClick: (value, code) => {
|
|
|
const data = {
|
|
@@ -224,12 +264,14 @@ function handleClickEdit(key: string, value: any, name: 'on' | 'func') {
|
|
|
{
|
|
|
title: value.name
|
|
|
}
|
|
|
- ).then(res => {
|
|
|
+ ).then((res: string) => {
|
|
|
+ // @ts-ignore
|
|
|
currentItem.value[name][key] = res
|
|
|
})
|
|
|
}
|
|
|
|
|
|
function editStyleClick() {
|
|
|
+ // @ts-ignore
|
|
|
CyJsonEditorDialog(currentItem.value.bind.style).then(res => {
|
|
|
currentItem.value.bind.style = res.json
|
|
|
})
|
|
@@ -238,6 +280,7 @@ function editStyleClick() {
|
|
|
function exportJSON() {
|
|
|
const temp = XEUtils.clone(currentItem.value)
|
|
|
const bind = temp.bind
|
|
|
+ // @ts-ignore
|
|
|
delete temp.bind
|
|
|
const tempData = {
|
|
|
bind: bind,
|
|
@@ -272,7 +315,10 @@ onMounted(() => {
|
|
|
<el-form label-width="120px">
|
|
|
<el-divider>主要</el-divider>
|
|
|
<el-form-item label="key:">
|
|
|
- <el-input v-model="currentItem.key" style="width: 80px"/>
|
|
|
+ <el-input
|
|
|
+ v-model="tmpKey"
|
|
|
+ @blur="handelKeyBlur"
|
|
|
+ style="width: 80px"/>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="必填:">
|
|
|
<el-switch v-model="currentItem.required" @change="emits('requiredChange')"/>
|