Browse Source

表格优化提交

main
likunming 1 year ago
parent
commit
43961f5f70
  1. 58
      io.sc.platform.core.frontend/src/platform/components/dialog/WDialog.vue
  2. 39
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

58
io.sc.platform.core.frontend/src/platform/components/dialog/WDialog.vue

@ -5,7 +5,16 @@
no-backdrop-dismiss: 用户不能通过单击对话框外部来关闭对话框如果还设置了 'persistent' 属性则无需设置它 no-backdrop-dismiss: 用户不能通过单击对话框外部来关闭对话框如果还设置了 'persistent' 属性则无需设置它
no-refocus: 当对话框被隐藏时不要重新聚焦以前有聚焦过的 DOM 元素 no-refocus: 当对话框被隐藏时不要重新聚焦以前有聚焦过的 DOM 元素
--> -->
<q-dialog v-model="dialog.show" :maximized="dialog.maximized" allow-focus-outside no-esc-dismiss no-backdrop-dismiss no-refocus v-bind="attrs"> <q-dialog
ref="dialogRef"
v-model="dialog.show"
:maximized="dialog.maximized"
allow-focus-outside
no-esc-dismiss
no-backdrop-dismiss
no-refocus
v-bind="attrs"
>
<q-card <q-card
:style="{ :style="{
width: dialog.maximized ? '100vw' : props.width, width: dialog.maximized ? '100vw' : props.width,
@ -38,7 +47,7 @@
</q-card-section> </q-card-section>
<q-separator /> <q-separator />
</div> </div>
<div style="height: calc(100% - 69px)"> <div ref="dialogContentDivRef" class="dialog_content_div" style="height: calc(100% - 69px)">
<q-card-section style="height: 100%; padding: 0px" class="scroll"> <q-card-section style="height: 100%; padding: 0px" class="scroll">
<slot></slot> <slot></slot>
</q-card-section> </q-card-section>
@ -49,7 +58,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { reactive, useAttrs } from 'vue'; import { ref, reactive, useAttrs } from 'vue';
import { IconEnum } from '@/platform/enums'; import { IconEnum } from '@/platform/enums';
const attrs = useAttrs(); const attrs = useAttrs();
@ -67,6 +76,7 @@ const emit = defineEmits<{
): void; ): void;
}>(); }>();
const dialogContentDivRef = ref();
const dialog = reactive({ const dialog = reactive({
show: false, show: false,
maximized: attrs.maximized || false, maximized: attrs.maximized || false,
@ -84,8 +94,50 @@ const hide = () => {
dialog.show = false; dialog.show = false;
}; };
//
const getElementViewPosition = (element) => {
//x
let actualLeft = element.offsetLeft;
let xcurrent = element.offsetParent;
while (xcurrent !== null) {
actualLeft += xcurrent.offsetLeft + xcurrent.clientLeft;
xcurrent = xcurrent.offsetParent;
}
let elementScrollLeft = document.documentElement.scrollLeft;
if (document.compatMode == 'BackCompat') {
elementScrollLeft = document.body.scrollLeft;
}
const left = actualLeft - elementScrollLeft;
//y
let actualTop = element.offsetTop;
let ycurrent = element.offsetParent;
while (ycurrent !== null) {
actualTop += ycurrent.offsetTop + ycurrent.clientTop;
ycurrent = ycurrent.offsetParent;
}
let elementScrollTop = document.documentElement.scrollTop;
if (document.compatMode == 'BackCompat') {
elementScrollTop = document.body.scrollTop;
}
var right = actualTop - elementScrollTop;
//
return { x: left, y: right };
};
const getContentHeight = () => {
if (dialogContentDivRef?.value) {
console.info('dialogContentDivRef.value', dialogContentDivRef.value.getBoundingClientRect().height);
return {
height: dialogContentDivRef.value.offsetHeight,
y: getElementViewPosition(dialogContentDivRef.value).y,
};
}
return null;
};
defineExpose({ defineExpose({
show, show,
hide, hide,
getContentHeight,
}); });
</script> </script>

39
io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue

@ -348,41 +348,37 @@ const emit = defineEmits<{
// checkbox // checkbox
(e: 'updateTicked', evt: Event, row: any): void; (e: 'updateTicked', evt: Event, row: any): void;
( (
e: 'requestDataBefore', // e: 'beforeRequestData', //
requestParams: URLSearchParams | any, // requestParams: URLSearchParams | any, //
callback: any, // callback: any, //
): void; ): void;
( (
e: 'requestDataAfter', // e: 'afterRequestData', //
responseResult: any, //
): void; ): void;
( (
e: 'addEditDataSubmitBefore', // e: 'beforeEditorDataSubmit', //
data: any, // data: any, //
callback: any, callback: any,
): void; // ): void; //
( (
e: 'addEditDataSubmitAfter', // e: 'afterEditorDataSubmit', //
responseResult: any, // responseResult: any, //
): void; ): void;
( (
e: 'deleteDataBefore', // e: 'beforeRemove', //
data: Array<any | string>, // data: Array<any | string>, //
callback: any, callback: any,
): void; // ): void; //
( (
e: 'deleteDataAfter', // e: 'afterRemove', //
responseResult: any, // responseResult: any, //
): void; ): void;
( (
e: 'addDialogOpenAfter', // e: 'afterEditorOpen', //
): void; editData: any,
(
e: 'editDialogOpenAfter', //
editData: any, //
): void; ): void;
( (
e: 'rowDragDropAfter', // e: 'afterRowDraggable', //
): void; ): void;
}>(); }>();
@ -518,7 +514,7 @@ const buttonObj = {
dialogRef.value.show(); dialogRef.value.show();
nextTick(() => { nextTick(() => {
dialogFormRef.value.setStatus(PageStatusEnum.新增); dialogFormRef.value.setStatus(PageStatusEnum.新增);
emit('addDialogOpenAfter'); emit('afterEditorOpen', null);
}); });
}, },
}, },
@ -541,7 +537,7 @@ const buttonObj = {
nextTick(() => { nextTick(() => {
dialogFormRef.value.setStatus(PageStatusEnum.编辑); dialogFormRef.value.setStatus(PageStatusEnum.编辑);
dialogFormRef.value.setData(selected[0]); dialogFormRef.value.setData(selected[0]);
emit('editDialogOpenAfter', selected[0]); emit('afterEditorOpen', selected[0]);
}); });
} }
}, },
@ -657,7 +653,7 @@ const buttonObj = {
dialogRef.value.show(); dialogRef.value.show();
nextTick(() => { nextTick(() => {
dialogFormRef.value.setStatus('addTop'); dialogFormRef.value.setStatus('addTop');
emit('addDialogOpenAfter'); emit('afterEditorOpen', null);
}); });
}, },
}, },
@ -676,7 +672,7 @@ const buttonObj = {
dialogRef.value.show(); dialogRef.value.show();
nextTick(() => { nextTick(() => {
dialogFormRef.value.setStatus('addChild'); dialogFormRef.value.setStatus('addChild');
emit('addDialogOpenAfter'); emit('afterEditorOpen', null);
}); });
}, },
}, },
@ -1169,7 +1165,7 @@ const requestHandler = async (ops) => {
// RestCrudController // RestCrudController
let urlSearchParams = buildQueryCriterias(reqParams); let urlSearchParams = buildQueryCriterias(reqParams);
// const urlSearchParams = buildQueryEntity(reqParams); // const urlSearchParams = buildQueryEntity(reqParams);
emit('requestDataBefore', urlSearchParams, (handlerRequestParams: URLSearchParams | any) => { emit('beforeRequestData', urlSearchParams, (handlerRequestParams: URLSearchParams | any) => {
urlSearchParams = handlerRequestParams; urlSearchParams = handlerRequestParams;
}); });
const resp = await axios.get(url.fetchDataUrl || url.dataUrl, { params: urlSearchParams }).catch((error) => { const resp = await axios.get(url.fetchDataUrl || url.dataUrl, { params: urlSearchParams }).catch((error) => {
@ -1221,6 +1217,7 @@ const onRequest = async (ops: any) => {
state.pagination.descending = ops.pagination.descending; state.pagination.descending = ops.pagination.descending;
addRowKey(table.rows); addRowKey(table.rows);
stickyHeaderColumn(); stickyHeaderColumn();
emit('afterRequestData');
}; };
const addRowKey = (rows: []) => { const addRowKey = (rows: []) => {
@ -1249,7 +1246,7 @@ const save = async () => {
dialogFormData[props.primaryKey] = getSelectedRowsComputed.value[0][props.primaryKey]; dialogFormData[props.primaryKey] = getSelectedRowsComputed.value[0][props.primaryKey];
} }
let submitFlag = true; let submitFlag = true;
emit('addEditDataSubmitBefore', dialogFormData, (handlerRequestParams: any | boolean) => { emit('beforeEditorDataSubmit', dialogFormData, (handlerRequestParams: any | boolean) => {
if (typeof handlerRequestParams === 'boolean' && handlerRequestParams === false) { if (typeof handlerRequestParams === 'boolean' && handlerRequestParams === false) {
submitFlag = false; submitFlag = false;
} else { } else {
@ -1279,7 +1276,7 @@ const save = async () => {
axios(requestParams) axios(requestParams)
.then((resp) => { .then((resp) => {
dialog.dialogButtons[0].loading = false; dialog.dialogButtons[0].loading = false;
emit('addEditDataSubmitAfter', resp.data); emit('afterEditorDataSubmit', resp.data);
NotifyManager.info('操作成功'); NotifyManager.info('操作成功');
dialogRef.value.hide(); dialogRef.value.hide();
onRequest({ pagination: state.pagination }); onRequest({ pagination: state.pagination });
@ -1905,7 +1902,7 @@ const onDrop = (e, scope) => {
removeDragTopStyle(e); removeDragTopStyle(e);
removeDragBottomStyle(e); removeDragBottomStyle(e);
emit('rowDragDropAfter'); emit('afterRowDraggable');
}; };
// form // form
const handlerQueryFormShowField = () => { const handlerQueryFormShowField = () => {

Loading…
Cancel
Save