Browse Source

表格优化提交

main
likunming 10 months ago
parent
commit
7b0adb48a1
  1. 36
      io.sc.platform.core.frontend/src/platform/components/form/WForm.vue
  2. 4
      io.sc.platform.core.frontend/src/platform/components/form/elements/WCron.vue
  3. 5
      io.sc.platform.core.frontend/src/platform/components/grid/WGrid.vue
  4. 10
      io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue

36
io.sc.platform.core.frontend/src/platform/components/form/WForm.vue

@ -1,8 +1,8 @@
<template> <template>
<div> <div>
<q-form ref="formRef" :autofocus="false" :greedy="true" v-bind="attrs"> <q-form ref="formRef" :autofocus="false" :greedy="true" v-bind="attrs">
<div v-if="fieldsComputed.value.length > 0" class="grid" :class="formLayoutComputed"> <div v-if="fieldsComputed.length > 0" class="grid" :class="formLayoutComputed">
<template v-for="(field, index) in fieldsComputed.value as any" :key="String(index)"> <template v-for="(field, index) in fieldsComputed as any" :key="String(index)">
<component <component
:is="fiedType[field.type] || field.type" :is="fiedType[field.type] || field.type"
v-if="field.name" v-if="field.name"
@ -131,27 +131,35 @@ watch(
}, },
); );
// eventBus.on('localeChanged', (local) => { // eventBus.on('onLocaleChanged', (local) => {
// console.info('localeChanged====0----');
// nextTick(() => { // nextTick(() => {
// console.info('props.fields====', props.fields); // console.info('localeChanged====1----', props.fields);
// fields_ = ref([...props.fields]);
// for (const field of fields_.value as any) {
// if (field.name) {
// formFields[field.name] = field;
// }
// }
// localFlag.value = !localFlag.value;
// console.info('localeChanged====2----', fields_.value);
// }); // });
// }); // });
watch(
const fieldsComputed = computed(() => { () => props.fields.map((item) => item['label']),
localFlag.value; (newVal, oldVal) => {
return fields_;
});
onUpdated(() => {
nextTick(() => {
localFlag.value = !localFlag.value;
fields_ = ref([...props.fields]); fields_ = ref([...props.fields]);
for (const field of fields_.value as any) { for (const field of fields_.value as any) {
if (field.name) { if (field.name) {
formModel[field.name] = defaultValueHandler(field);
formFields[field.name] = field; formFields[field.name] = field;
} }
} }
}); localFlag.value = !localFlag.value;
},
);
const fieldsComputed = computed(() => {
localFlag.value;
return fields_.value;
}); });
for (const field of fields_.value as any) { for (const field of fields_.value as any) {

4
io.sc.platform.core.frontend/src/platform/components/form/elements/WCron.vue

@ -190,13 +190,13 @@ const valueChanged = () => {
const result = Tools.join(values, ' '); const result = Tools.join(values, ' ');
valueRef.value = result; valueRef.value = result;
emit('update:modelValue', result, props.form); emit('update:modelValue', result);
changeValue(result); changeValue(result);
}; };
const updateModelValue = (value) => { const updateModelValue = (value) => {
valueRef.value = value; valueRef.value = value;
emit('update:modelValue', value, props.form); emit('update:modelValue', value);
}; };
const changeValue = (value) => { const changeValue = (value) => {
emit('change', { emit('change', {

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

@ -479,9 +479,9 @@ watch(
); );
eventBus.on('onLocaleChanged', (local) => { eventBus.on('onLocaleChanged', (local) => {
nextTick(() => { nextTick(() => {
table.columns = extractTableColumns.value;
handlerQueryFormShowField(); handlerQueryFormShowField();
localFlag.value = !localFlag.value; localFlag.value = !localFlag.value;
table.columns = extractTableColumns.value;
// label // label
Object.keys(buttonObj).forEach((btn) => { Object.keys(buttonObj).forEach((btn) => {
if (typeof buttonObj[btn] === 'object' && buttonObj[btn].labelI18nKey) { if (typeof buttonObj[btn] === 'object' && buttonObj[btn].labelI18nKey) {
@ -574,7 +574,6 @@ const remove = () => {
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
NotifyManager.error(t('tip.operationFailed'));
}); });
}; };
const resetDefaultValues = () => { const resetDefaultValues = () => {
@ -589,7 +588,6 @@ const resetDefaultValues = () => {
}) })
.catch((error) => { .catch((error) => {
console.error(error); console.error(error);
NotifyManager.error(t('tip.operationFailed'));
}); });
}; };
const buttonObj = reactive({ const buttonObj = reactive({
@ -1510,7 +1508,6 @@ const save = async () => {
.catch((error) => { .catch((error) => {
console.info('error====', error); console.info('error====', error);
dialog.dialogButtons[0].loading = false; dialog.dialogButtons[0].loading = false;
NotifyManager.error(t('tip.operationFailed'));
}); });
} else { } else {
dialog.dialogButtons[0].loading = false; dialog.dialogButtons[0].loading = false;

10
io.sc.platform.core.frontend/src/platform/components/toolbar/WToolbar.vue

@ -317,10 +317,14 @@ const onResize = (size) => {
isActionWidthInitializedRef.value = true; isActionWidthInitializedRef.value = true;
} }
reset(size.width);
};
const reset = (currentWidth) => {
const _baseActions = <any>[]; const _baseActions = <any>[];
const _moreActions = <any>[]; const _moreActions = <any>[];
const length = buttons_.length; const length = buttons_.length;
let availableWidth = size.width; let availableWidth = currentWidth;
let width = 0; let width = 0;
let index = 0; let index = 0;
for (; index < length; index++) { for (; index < length; index++) {
@ -366,8 +370,10 @@ eventBus.on('onLocaleChanged', () => {
extractButton(props.buttons); extractButton(props.buttons);
handleButtons(); handleButtons();
baseActions.value = buttons_; baseActions.value = buttons_;
localFlag.value = !localFlag.value;
isActionWidthInitializedRef.value = false; isActionWidthInitializedRef.value = false;
if (!Tools.isUndefinedOrNull(containerRef.value)) {
reset(containerRef.value.offsetWidth);
}
}); });
}); });
// onUpdated(() => { // onUpdated(() => {

Loading…
Cancel
Save