|
@@ -1,5 +1,5 @@
|
|
|
-<script setup lang="ts">
|
|
|
-import {h, nextTick, ref, getCurrentInstance, onActivated, watch, onUnmounted} from "vue";
|
|
|
+<script setup lang="tsx">
|
|
|
+import {h, ref, onActivated, watch, onUnmounted} from "vue";
|
|
|
import * as vue from 'vue'
|
|
|
import {PageHeader, PageJsonObject} from "@/api/reports/report-query-center";
|
|
|
import {useCompRef} from "@/utils/useCompRef";
|
|
@@ -12,20 +12,14 @@ 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 PageHelpOtherConfigurations
|
|
|
- from "@/views/data-base/page-editor-help-v2/components/page-editor-v2/PageHelpOtherConfigurations.vue";
|
|
|
+
|
|
|
import {getWindowSize} from "@/utils/window-size";
|
|
|
import {ExcelName, Export} from '@/utils/ExportExcel'
|
|
|
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";
|
|
|
-
|
|
|
-interface Props {
|
|
|
- componentAttribute?: any
|
|
|
- addComponent?: any
|
|
|
- otherConfigurations?: string | any,
|
|
|
- doTest?: (data: any) => void
|
|
|
-}
|
|
|
+import CyFlex from "@/components/cy/flex/src/CyFlex.vue";
|
|
|
+import PageHelpTable from "@/views/data-base/page-editor-help-v2/components/PageHelpTable.vue";
|
|
|
|
|
|
interface Columns {
|
|
|
title: string,
|
|
@@ -36,23 +30,38 @@ interface Columns {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// @ts-ignore
|
|
|
-const props = withDefaults(defineProps<Props>(), {
|
|
|
- componentAttribute: null,
|
|
|
- addComponent: null,
|
|
|
- doTest: null
|
|
|
+const props = defineProps({
|
|
|
+ componentAttribute: {
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
+ addComponent: {
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
+ otherConfigurations: {
|
|
|
+ default: null,
|
|
|
+ },
|
|
|
+ doTest: {
|
|
|
+ default: null
|
|
|
+ },
|
|
|
+ isEditor: {
|
|
|
+ type: Boolean,
|
|
|
+ default: false
|
|
|
+ }
|
|
|
})
|
|
|
|
|
|
-const pageHelp = getCurrentInstance();
|
|
|
-const store = usePageStore()
|
|
|
-//@ts-ignore
|
|
|
-pageHelp.store = store
|
|
|
|
|
|
-const {currentClickIndex, pageData, clearOnAndFunc, tableBind, handleSavaData} = store
|
|
|
+const store = usePageStore(props)
|
|
|
|
|
|
+const {
|
|
|
+ currentClickIndex,
|
|
|
+ pageData,
|
|
|
+ clearOnAndFunc,
|
|
|
+ tableBind,
|
|
|
+ handleSavaData,
|
|
|
+ bindData
|
|
|
+} = store
|
|
|
|
|
|
const formRef = useCompRef(ElForm)
|
|
|
-const bindRef = ref(null)
|
|
|
const headerRef = ref<HTMLDivElement>()
|
|
|
const {height: headerHeight} = useElementSize(headerRef)
|
|
|
const emits = defineEmits(['changeTabs'])
|
|
@@ -66,7 +75,6 @@ const render = (item: PageHeader) => {
|
|
|
},
|
|
|
...item.bind
|
|
|
}
|
|
|
-
|
|
|
if (item.on) {
|
|
|
for (const onKey in item.on) {
|
|
|
const key = capitalizeFirstLetter(onKey, 'on')
|
|
@@ -104,7 +112,7 @@ function formItemClick(item: PageHeader, index) {
|
|
|
return
|
|
|
}
|
|
|
currentClickIndex.value = index
|
|
|
- bindRef.value?.changeCurrentBind(item)
|
|
|
+ store.changeCurrentBind(item)
|
|
|
}
|
|
|
|
|
|
function upClick(index) {
|
|
@@ -128,7 +136,7 @@ function swapItems(arr, currentClickIndex, newIndex) {
|
|
|
|
|
|
function delClick(index) {
|
|
|
currentClickIndex.value = -1
|
|
|
- bindRef.value.changeCurrentBind(null)
|
|
|
+ store.changeCurrentBind(null)
|
|
|
pageData.value.header.splice(index, 1)
|
|
|
}
|
|
|
|
|
@@ -166,6 +174,7 @@ const dialogTableData = ref({
|
|
|
data: [],
|
|
|
columns: []
|
|
|
})
|
|
|
+
|
|
|
const showDialog = ref(false)
|
|
|
const dialogTitle = ref('详情')
|
|
|
const tableData = ref([])
|
|
@@ -177,7 +186,7 @@ function requiredInit(setDefaultValue = false) {
|
|
|
rules.value = []
|
|
|
pageData.value.header.forEach(item => {
|
|
|
if (setDefaultValue) {
|
|
|
- pageData.value.params[item.key] = item.defaultValue
|
|
|
+ pageData.value.params = XEUtils.clone(pageData.value.defaultValue, true)
|
|
|
}
|
|
|
if (item.required) {
|
|
|
rules.value[item.key] = [{required: true, message: '必填', trigger: 'blur'}]
|
|
@@ -208,9 +217,9 @@ async function setPageData(data: PageJsonObject, currentIndex = -1) {
|
|
|
await handleOnAndFuncEvent(temp)
|
|
|
pageData.value = temp
|
|
|
if (currentIndex > 0) {
|
|
|
- bindRef.value?.changeCurrentBind(pageData.value.header[currentClickIndex.value])
|
|
|
+ await store.changeCurrentBind(pageData.value.header[currentClickIndex.value])
|
|
|
} else {
|
|
|
- bindRef.value?.changeCurrentBind(null)
|
|
|
+ await store.changeCurrentBind(null)
|
|
|
}
|
|
|
currentClickIndex.value = currentIndex
|
|
|
initTable()
|
|
@@ -251,15 +260,6 @@ async function addComponent(data) {
|
|
|
}
|
|
|
|
|
|
const compData = ref()
|
|
|
-const bindData = ref()
|
|
|
-
|
|
|
-async function bindRefresh() {
|
|
|
- bindData.value = await reportQueryCenterApi('/reportCenterOption/components/componentBind')
|
|
|
- await nextTick()
|
|
|
- if (currentClickIndex.value > -1) {
|
|
|
- bindRef.value?.changeCurrentBind(pageData.value.header[currentClickIndex.value])
|
|
|
- }
|
|
|
-}
|
|
|
|
|
|
async function addComponentRefresh() {
|
|
|
compData.value = await reportQueryCenterApi('/reportCenterOption/components/addComponents')
|
|
@@ -278,32 +278,26 @@ function openDialogAndSetData(data, title: string = '详情') {
|
|
|
dialogTitle.value = title
|
|
|
showDialog.value = true
|
|
|
dialogTableData.value = data
|
|
|
- handelColumnFunc(dialogTableData.value.columns)
|
|
|
}
|
|
|
|
|
|
-function handelColumnFunc(data) {
|
|
|
- XEUtils.arrayEach(data, (item: Columns) => {
|
|
|
- if (!item.func) {
|
|
|
- return
|
|
|
- }
|
|
|
- for (let key in item.func) {
|
|
|
- const newFunc = new Function("row", "pageData", "apiFunc", "el", "vue", "openDialogAndSetData", item.func[key])
|
|
|
- item[key] = (row) => newFunc(row, pageData.value, reportQueryCenterApi, ElAndXc, vue, openDialogAndSetData)
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
|
|
|
function setTableData(res) {
|
|
|
- tableBind.value = res
|
|
|
+ if (res === null) {
|
|
|
+ res = {
|
|
|
+ columns: [],
|
|
|
+ data: []
|
|
|
+ }
|
|
|
+ }
|
|
|
+ tableBind.value = res;
|
|
|
if (res.details) {
|
|
|
tableBind.value.columns.push({
|
|
|
- key: 'operations',
|
|
|
+ field: 'operations',
|
|
|
title: '详情',
|
|
|
width: 70,
|
|
|
align: 'center',
|
|
|
fixed: 'right',
|
|
|
func: {
|
|
|
- cellRenderer: `
|
|
|
+ default: `
|
|
|
const {h} = vue
|
|
|
const {ElButton} = el
|
|
|
return h(ElButton, {
|
|
@@ -324,10 +318,17 @@ function setTableData(res) {
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
- handelColumnFunc(tableBind.value.columns)
|
|
|
}
|
|
|
|
|
|
|
|
|
+const handleTableColumnDefault = (row, index, item) => {
|
|
|
+ if (!XEUtils.has(item, 'func.defaultFunc')) {
|
|
|
+ item.func.defaultFunc = new Function("row", 'rowIndex', "pageData", "apiFunc", "el", "vue", "openDialogAndSetData",
|
|
|
+ item.func.default)
|
|
|
+ }
|
|
|
+ return item.func.defaultFunc(row, index, pageData.value, reportQueryCenterApi, ElAndXc, vue, openDialogAndSetData)
|
|
|
+}
|
|
|
+
|
|
|
function exportExcel(data: {
|
|
|
data: any[],
|
|
|
columns: Columns[],
|
|
@@ -381,8 +382,8 @@ defineExpose({
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
|
- <cy-auto-size>
|
|
|
- <template #default="{height,width}">
|
|
|
+ <CyFlex content-size>
|
|
|
+ <template #header>
|
|
|
<div class="cy-page_help_v2-header" ref="headerRef">
|
|
|
<el-form v-bind="pageData.fromConfig"
|
|
|
:rules="rules"
|
|
@@ -423,24 +424,30 @@ defineExpose({
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
</div>
|
|
|
- <div class="cy-page_help_v2-main" v-loading="loading">
|
|
|
- <el-table-v2 v-bind="tableBind"
|
|
|
- :h-scrollbar-size="10"
|
|
|
- :v-scrollbar-size="10"
|
|
|
- :height="height - headerHeight"
|
|
|
- :width="width"/>
|
|
|
+ </template>
|
|
|
+ <template #content="{height, width}">
|
|
|
+ <div class="cy-page_help_v2-main"
|
|
|
+ :style="{width: width +'px'}"
|
|
|
+ v-loading="loading">
|
|
|
+ <PageHelpTable :data="tableBind.data"
|
|
|
+ :store="store"
|
|
|
+ :columns="tableBind.columns"
|
|
|
+ :handle-table-column-default="handleTableColumnDefault"
|
|
|
+ :height="height == 0 ? 500 : height "
|
|
|
+ />
|
|
|
</div>
|
|
|
</template>
|
|
|
- </cy-auto-size>
|
|
|
+ </CyFlex>
|
|
|
|
|
|
<el-dialog v-model="showDialog" :title="dialogTitle" width="90%" class="page_help-dialog">
|
|
|
<cy-auto-size>
|
|
|
<template #default="{width}">
|
|
|
- <el-table-v2 v-bind="dialogTableData"
|
|
|
- :h-scrollbar-size="12"
|
|
|
- :v-scrollbar-size="12"
|
|
|
- :height="getWindowSize.h - 500"
|
|
|
- :width="width - 10"/>
|
|
|
+ <PageHelpTable
|
|
|
+ :data="dialogTableData.data"
|
|
|
+ :columns="dialogTableData.columns"
|
|
|
+ :handle-table-column-default="handleTableColumnDefault"
|
|
|
+ :height="getWindowSize.h - 500 "
|
|
|
+ />
|
|
|
</template>
|
|
|
</cy-auto-size>
|
|
|
<template #footer>
|
|
@@ -448,14 +455,11 @@ defineExpose({
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <PageFormBind ref="bindRef"
|
|
|
- :store="store"
|
|
|
- @refresh="bindRefresh"
|
|
|
- :data="pageData"
|
|
|
- @requiredChange="requiredInit"
|
|
|
- :comp-bind="bindData"
|
|
|
- :teleport-div="props.componentAttribute"
|
|
|
- v-if="props.componentAttribute"/>
|
|
|
+ <PageFormBind
|
|
|
+ :store="store"
|
|
|
+ @requiredChange="requiredInit"
|
|
|
+ :teleport-div="props.componentAttribute"
|
|
|
+ v-if="props.componentAttribute"/>
|
|
|
|
|
|
<PageAddComponent :teleportDiv="props.addComponent"
|
|
|
@refresh="addComponentRefresh"
|
|
@@ -463,9 +467,6 @@ defineExpose({
|
|
|
:comp-data="compData"
|
|
|
v-if="props.addComponent"/>
|
|
|
|
|
|
- <PageHelpOtherConfigurations v-if="props.otherConfigurations"
|
|
|
- :store="store"
|
|
|
- :teleport-div="props.otherConfigurations"/>
|
|
|
|
|
|
</template>
|
|
|
|