雪忆
2024-07-29 ecfe66a0199606241c73a52519bbe800c9aa31f8
src/components/Table/src/components/editable/EditableCell.vue
@@ -17,6 +17,7 @@
  import { treeToList } from '@/utils/helper/treeHelper';
  import { Spin } from 'ant-design-vue';
  import { parseRowKey } from '../../helper';
  import { warn } from '@/utils/log';
  export default defineComponent({
    name: 'EditableCell',
@@ -63,6 +64,19 @@
      const getIsCheckComp = computed(() => {
        const component = unref(getComponent);
        return ['Checkbox', 'Switch'].includes(component);
      });
      const getDisable = computed(() => {
        const { editDynamicDisabled } = props.column;
        let disabled = false;
        if (isBoolean(editDynamicDisabled)) {
          disabled = editDynamicDisabled;
        }
        if (isFunction(editDynamicDisabled)) {
          const { record } = props;
          disabled = editDynamicDisabled({ record, currentValue: currentValueRef.value });
        }
        return disabled;
      });
      const getComponentProps = computed(() => {
@@ -117,18 +131,7 @@
        const dataKey = (dataIndex || key) as string;
        set(record, dataKey, value);
      }
      const getDisable = computed(() => {
        const { editDynamicDisabled } = props.column;
        let disabled = false;
        if (isBoolean(editDynamicDisabled)) {
          disabled = editDynamicDisabled;
        }
        if (isFunction(editDynamicDisabled)) {
          const { record } = props;
          disabled = editDynamicDisabled({ record, currentValue: currentValueRef.value });
        }
        return disabled;
      });
      const getValues = computed(() => {
        const { editValueMap } = props.column;
@@ -149,6 +152,11 @@
        return option?.label ?? value;
      });
      const getRowEditable = computed(() => {
        const { editable } = props.record || {};
        return !!editable;
      });
      const getWrapperStyle = computed((): CSSProperties => {
        if (unref(getIsCheckComp) || unref(getRowEditable)) {
          return {};
@@ -161,11 +169,6 @@
      const getWrapperClass = computed(() => {
        const { align = 'center' } = props.column;
        return `edit-cell-align-${align}`;
      });
      const getRowEditable = computed(() => {
        const { editable } = props.record || {};
        return !!editable;
      });
      watchEffect(() => {
@@ -191,7 +194,7 @@
        });
      }
      async function handleChange(e: any) {
      async function handleChange(e: any, ...rest: any[]) {
        const component = unref(getComponent);
        if (!e) {
          currentValueRef.value = e;
@@ -205,7 +208,7 @@
          currentValueRef.value = e;
        }
        const onChange = unref(getComponentProps)?.onChangeTemp;
        if (onChange && isFunction(onChange)) onChange(...arguments);
        if (onChange && isFunction(onChange)) onChange(e, ...rest);
        table.emit?.('edit-change', {
          column: props.column,
@@ -280,6 +283,7 @@
              });
            } catch (e) {
              result = false;
              warn(e);
            } finally {
              spinning.value = false;
            }
@@ -367,11 +371,9 @@
          if (!props.record.editValueRefs) props.record.editValueRefs = {};
          props.record.editValueRefs[props.column.dataIndex as any] = currentValueRef;
        }
        /* eslint-disable  */
        props.record.onCancelEdit = () => {
          isArray(props.record?.cancelCbs) && props.record?.cancelCbs.forEach((fn) => fn());
        };
        /* eslint-disable */
        props.record.onSubmitEdit = async () => {
          if (isArray(props.record?.submitCbs)) {
            if (!props.record?.onValid?.()) return;
@@ -506,7 +508,7 @@
  }
  .@{prefix-cls} {
    position: relative;
    min-height: 24px; //设置高度让其始终可被hover
    min-height: 24px; // 设置高度让其始终可被hover
    &__wrapper {
      display: flex;