|
@@ -7,12 +7,9 @@ import {ElButton, ElForm, ElOption} from "element-plus";
|
|
|
import PageFormBind from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageFormBind.vue";
|
|
|
import {ArrowLeft, ArrowRight, DeleteFilled} from "@element-plus/icons-vue";
|
|
|
import {reportQueryCenterApi} from "@/api/base-data/report-center";
|
|
|
-import CyAutoSize from "@/components/cy/auto-size/cy-auto-size.vue";
|
|
|
-import {useElementSize} from "@vueuse/core/index";
|
|
|
import XEUtils from "xe-utils";
|
|
|
import {xcMessage} from "@/utils/xiaochan-element-plus";
|
|
|
import PageAddComponent from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageAddComponent.vue";
|
|
|
-import {getWindowSize} from "@/utils/window-size";
|
|
|
import {userInfoStore} from "@/utils/store-public";
|
|
|
import {capitalizeFirstLetter, usePageStore, ElAndXc} from "@/views/data-base/page-editor-help-v2/page-help-v2";
|
|
|
import {shortcutTrigger, xcEvent} from "@/utils/xckeydown";
|
|
@@ -39,6 +36,7 @@ const props = defineProps({
|
|
|
default: null,
|
|
|
},
|
|
|
doTest: {
|
|
|
+ type: Function,
|
|
|
default: null
|
|
|
},
|
|
|
isEditor: {
|
|
@@ -56,17 +54,17 @@ const {
|
|
|
clearOnAndFunc,
|
|
|
tableBind,
|
|
|
handleSavaData,
|
|
|
- bindData
|
|
|
+ bindData,
|
|
|
+ mutation
|
|
|
} = store
|
|
|
|
|
|
const formRef = useCompRef(ElForm)
|
|
|
const headerRef = ref<HTMLDivElement>()
|
|
|
-const {height: headerHeight} = useElementSize(headerRef)
|
|
|
const emits = defineEmits(['changeTabs'])
|
|
|
const userInfo = XEUtils.clone(userInfoStore.value, true)
|
|
|
|
|
|
const render = (item: PageHeader) => {
|
|
|
- const modelValue = typeof pageData.value.params[item.key] === 'undefined' ? "" : pageData.value.params[item.key]
|
|
|
+ const modelValue = typeof pageData.value.params[item.key] === 'undefined' ? "" : pageData.value.params[item.key];
|
|
|
const tempProps = {
|
|
|
modelValue: modelValue,
|
|
|
"onUpdate:modelValue": (val) => {
|
|
@@ -180,18 +178,10 @@ const tableData = ref([])
|
|
|
const columns = ref([])
|
|
|
const loading = ref(false)
|
|
|
|
|
|
-function requiredInit(setDefaultValue = false) {
|
|
|
+function requiredInit() {
|
|
|
formRef.value!.resetFields()
|
|
|
rules.value = []
|
|
|
- const isEmpty = typeof pageData.value.paramsDefaultValue !== 'undefined' && !XEUtils.isEmpty(pageData.value.paramsDefaultValue)
|
|
|
pageData.value.header.forEach(item => {
|
|
|
- if (setDefaultValue) {
|
|
|
- if (isEmpty) {
|
|
|
- pageData.value.params = XEUtils.clone(pageData.value.paramsDefaultValue, true)
|
|
|
- } else {
|
|
|
- pageData.value.params[item.key] = item.defaultValue
|
|
|
- }
|
|
|
- }
|
|
|
if (item.required) {
|
|
|
rules.value[item.key] = [{required: true, message: '必填', trigger: 'blur'}]
|
|
|
}
|
|
@@ -218,8 +208,14 @@ async function refresh() {
|
|
|
|
|
|
async function setPageData(data: PageJsonObject, currentIndex = -1) {
|
|
|
const temp: PageJsonObject = XEUtils.clone(data, true);
|
|
|
+ queryKey.value = {}
|
|
|
+ temp.header.forEach((item, index) => {
|
|
|
+ queryKey.value[item.key] = index
|
|
|
+ })
|
|
|
+ if (!XEUtils.isEmpty(temp.paramsDefaultValue)) {
|
|
|
+ temp.params = XEUtils.clone(temp.paramsDefaultValue, true)
|
|
|
+ }
|
|
|
await handleOnAndFuncEvent(temp)
|
|
|
-
|
|
|
pageData.value = temp
|
|
|
if (currentIndex > 0) {
|
|
|
await store.changeCurrentBind(pageData.value.header[currentClickIndex.value])
|
|
@@ -228,9 +224,11 @@ async function setPageData(data: PageJsonObject, currentIndex = -1) {
|
|
|
}
|
|
|
currentClickIndex.value = currentIndex
|
|
|
initTable()
|
|
|
- requiredInit(true)
|
|
|
+ requiredInit()
|
|
|
}
|
|
|
|
|
|
+mutation.setPageData = setPageData
|
|
|
+
|
|
|
function getBindDefaultValue(name: string) {
|
|
|
const res = {}
|
|
|
if (XEUtils.has(bindData.value, name)) {
|
|
@@ -242,10 +240,19 @@ function getBindDefaultValue(name: string) {
|
|
|
return res
|
|
|
}
|
|
|
|
|
|
+const AsyncFunction = Object.getPrototypeOf(async function () {
|
|
|
+}).constructor;
|
|
|
+
|
|
|
+const queryKey = ref({})
|
|
|
+
|
|
|
function newFunc(currentBind, value, funcStr) {
|
|
|
- const func = new Function('pageJson', 'currentBind', 'apiFunc', 'val', 'userInfo', funcStr)
|
|
|
+ function updateView() {
|
|
|
+ queryKey.value[currentBind.key] += pageData.value.header.length + queryKey.value[currentBind.key]
|
|
|
+ }
|
|
|
+
|
|
|
+ const func = new AsyncFunction('pageJson', 'currentBind', 'apiFunc', 'updateView', 'val', 'userInfo', funcStr)
|
|
|
try {
|
|
|
- return func(pageData.value, currentBind, reportQueryCenterApi, value, userInfo)
|
|
|
+ return func(pageData.value, currentBind, reportQueryCenterApi, updateView, value, userInfo)
|
|
|
} catch (e) {
|
|
|
console.error('脚本错误', e)
|
|
|
}
|
|
@@ -254,6 +261,7 @@ function newFunc(currentBind, value, funcStr) {
|
|
|
async function addComponent(data) {
|
|
|
const temp = XEUtils.clone(data, true)
|
|
|
Object.assign(temp.bind, getBindDefaultValue(data.name))
|
|
|
+ queryKey.value[temp.key] = pageData.value.header.length
|
|
|
if (temp.on && temp.on.mounted) {
|
|
|
try {
|
|
|
await newFunc(temp, '', temp.on.mounted)
|
|
@@ -270,7 +278,7 @@ async function testClick() {
|
|
|
pageData.value.header.forEach(item => {
|
|
|
data[item.key] = pageData.value.params[item.key]
|
|
|
})
|
|
|
- props.doTest(data)
|
|
|
+ props?.doTest(data)
|
|
|
}
|
|
|
|
|
|
function openDialogAndSetData(data, title: string = '详情') {
|
|
@@ -376,7 +384,7 @@ defineExpose({
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <CyFlex content-size>
|
|
|
+ <CyFlex>
|
|
|
<template #header>
|
|
|
<div class="cy-page_help_v2-header" ref="headerRef">
|
|
|
<el-form v-bind="pageData.fromConfig"
|
|
@@ -385,6 +393,7 @@ defineExpose({
|
|
|
:model="pageData.params">
|
|
|
<div v-for="(item, index) in pageData.header"
|
|
|
v-if="pageData.header.length > 0"
|
|
|
+ :key="queryKey[item.key]"
|
|
|
class="page-item_div"
|
|
|
:class="isActive(index) ? 'page-item_active': ''">
|
|
|
<div v-if="currentClickIndex === index" class="tool">
|
|
@@ -424,16 +433,15 @@ defineExpose({
|
|
|
</el-form>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <template #content="{height, width}">
|
|
|
+ <template>
|
|
|
<div class="cy-page_help_v2-main"
|
|
|
- :style="{width: width +'px'}"
|
|
|
+ style="width: 100%"
|
|
|
v-loading="loading">
|
|
|
<PageHelpTable :data="tableBind.data"
|
|
|
:store="store"
|
|
|
tableRefName="mainTableRef"
|
|
|
:columns="tableBind.columns"
|
|
|
:handle-table-column-default="handleTableColumnDefault"
|
|
|
- :height="height == 0 ? 500 : height "
|
|
|
/>
|
|
|
</div>
|
|
|
</template>
|
|
@@ -443,18 +451,15 @@ defineExpose({
|
|
|
:title="dialogTitle"
|
|
|
width="90%"
|
|
|
class="page_help-dialog">
|
|
|
- <cy-auto-size>
|
|
|
- <template #default="{width}">
|
|
|
- <PageHelpTable
|
|
|
- :store="store"
|
|
|
- table-ref-name="dialogTableRef"
|
|
|
- :data="dialogTableData.data"
|
|
|
- :columns="dialogTableData.columns"
|
|
|
- :handle-table-column-default="handleTableColumnDefault"
|
|
|
- :height="getWindowSize.h - 500 "
|
|
|
- />
|
|
|
- </template>
|
|
|
- </cy-auto-size>
|
|
|
+ <template>
|
|
|
+ <PageHelpTable
|
|
|
+ :store="store"
|
|
|
+ table-ref-name="dialogTableRef"
|
|
|
+ :data="dialogTableData.data"
|
|
|
+ :columns="dialogTableData.columns"
|
|
|
+ :handle-table-column-default="handleTableColumnDefault"
|
|
|
+ />
|
|
|
+ </template>
|
|
|
<template #footer>
|
|
|
<el-button v-if="props.isEditor" @click="dialogTableColumns">生成表格列</el-button>
|
|
|
<el-button @click="exportExcel(dialogTableData ,store.dialogTableRef)" type="primary">导出Excel</el-button>
|