|
|
@ -53,8 +53,8 @@ export default defineComponent({ |
|
|
|
|
|
|
|
|
|
|
|
const { prefixCls } = useDesign('editable-cell') |
|
|
|
const { prefixCls } = useDesign('editable-cell') |
|
|
|
|
|
|
|
|
|
|
|
const getComponent = computed(() => props.column?.editComponent || 'Input') |
|
|
|
const getComponent = computed(() => props.column.edit && props.column?.editComponent || 'Input') |
|
|
|
const getRule = computed(() => props.column?.editRule) |
|
|
|
const getRule = computed(() => props.column.edit && props.column?.editRule) |
|
|
|
|
|
|
|
|
|
|
|
const getRuleOpen = computed(() => { |
|
|
|
const getRuleOpen = computed(() => { |
|
|
|
return unref(ruleMessage) && unref(ruleOpen) |
|
|
|
return unref(ruleMessage) && unref(ruleOpen) |
|
|
@ -65,6 +65,9 @@ export default defineComponent({ |
|
|
|
return ['Checkbox', 'Switch'].includes(component) |
|
|
|
return ['Checkbox', 'Switch'].includes(component) |
|
|
|
}) |
|
|
|
}) |
|
|
|
const getDisable = computed(() => { |
|
|
|
const getDisable = computed(() => { |
|
|
|
|
|
|
|
if (!props.column.edit) |
|
|
|
|
|
|
|
return false |
|
|
|
|
|
|
|
|
|
|
|
const { editDynamicDisabled } = props.column |
|
|
|
const { editDynamicDisabled } = props.column |
|
|
|
let disabled = false |
|
|
|
let disabled = false |
|
|
|
if (isBoolean(editDynamicDisabled)) |
|
|
|
if (isBoolean(editDynamicDisabled)) |
|
|
@ -85,7 +88,7 @@ export default defineComponent({ |
|
|
|
|
|
|
|
|
|
|
|
const value = isCheckValue ? (isNumber(val) || isBoolean(val) ? val : !!val) : val |
|
|
|
const value = isCheckValue ? (isNumber(val) || isBoolean(val) ? val : !!val) : val |
|
|
|
|
|
|
|
|
|
|
|
let compProps = props.column?.editComponentProps ?? ({} as any) |
|
|
|
let compProps = (props.column?.edit && props.column?.editComponentProps) ?? ({} as any) |
|
|
|
const { record, column, index } = props |
|
|
|
const { record, column, index } = props |
|
|
|
|
|
|
|
|
|
|
|
if (isFunction(compProps)) |
|
|
|
if (isFunction(compProps)) |
|
|
@ -122,7 +125,7 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getValues = computed(() => { |
|
|
|
const getValues = computed(() => { |
|
|
|
const { editValueMap } = props.column |
|
|
|
const editValueMap = props.column.edit ? props.column.editValueMap : null |
|
|
|
|
|
|
|
|
|
|
|
const value = unref(currentValueRef) |
|
|
|
const value = unref(currentValueRef) |
|
|
|
|
|
|
|
|
|
|
@ -163,12 +166,18 @@ export default defineComponent({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
watchEffect(() => { |
|
|
|
watchEffect(() => { |
|
|
|
|
|
|
|
if (!props.column.edit) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
const { editable } = props.column |
|
|
|
const { editable } = props.column |
|
|
|
if (isBoolean(editable) || isBoolean(unref(getRowEditable))) |
|
|
|
if (isBoolean(editable) || isBoolean(unref(getRowEditable))) |
|
|
|
isEdit.value = !!editable || unref(getRowEditable) |
|
|
|
isEdit.value = !!editable || unref(getRowEditable) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
function handleEdit() { |
|
|
|
function handleEdit() { |
|
|
|
|
|
|
|
if (!props.column.edit) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
if (unref(getRowEditable) || unref(props.column?.editRow)) |
|
|
|
if (unref(getRowEditable) || unref(props.column?.editRow)) |
|
|
|
return |
|
|
|
return |
|
|
|
ruleMessage.value = '' |
|
|
|
ruleMessage.value = '' |
|
|
@ -211,7 +220,7 @@ export default defineComponent({ |
|
|
|
|
|
|
|
|
|
|
|
async function handleSubmitRule() { |
|
|
|
async function handleSubmitRule() { |
|
|
|
const { column, record } = props |
|
|
|
const { column, record } = props |
|
|
|
const { editRule } = column |
|
|
|
const editRule = column.edit ? column.editRule : false |
|
|
|
const currentValue = unref(currentValueRef) |
|
|
|
const currentValue = unref(currentValueRef) |
|
|
|
|
|
|
|
|
|
|
|
if (editRule) { |
|
|
|
if (editRule) { |
|
|
@ -293,7 +302,7 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
async function handleEnter() { |
|
|
|
async function handleEnter() { |
|
|
|
if (props.column?.editRow) |
|
|
|
if (props.column?.edit && props.column?.editRow) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
handleSubmit() |
|
|
|
handleSubmit() |
|
|
@ -317,7 +326,7 @@ export default defineComponent({ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onClickOutside() { |
|
|
|
function onClickOutside() { |
|
|
|
if (props.column?.editable || unref(getRowEditable)) |
|
|
|
if (props.column?.edit && (props.column?.editable || unref(getRowEditable))) |
|
|
|
return |
|
|
|
return |
|
|
|
|
|
|
|
|
|
|
|
const component = unref(getComponent) |
|
|
|
const component = unref(getComponent) |
|
|
@ -413,7 +422,7 @@ export default defineComponent({ |
|
|
|
onClick={this.handleEdit} |
|
|
|
onClick={this.handleEdit} |
|
|
|
> |
|
|
|
> |
|
|
|
<div class="cell-content" title={this.column.ellipsis ? this.getValues ?? '' : ''}> |
|
|
|
<div class="cell-content" title={this.column.ellipsis ? this.getValues ?? '' : ''}> |
|
|
|
{this.column.editRender |
|
|
|
{(this.column.edit && this.column.editRender) |
|
|
|
? this.column.editRender({ |
|
|
|
? this.column.editRender({ |
|
|
|
text: this.value, |
|
|
|
text: this.value, |
|
|
|
record: this.record as Recordable, |
|
|
|
record: this.record as Recordable, |
|
|
@ -422,7 +431,7 @@ export default defineComponent({ |
|
|
|
}) |
|
|
|
}) |
|
|
|
: this.getValues ?? '\u00A0'} |
|
|
|
: this.getValues ?? '\u00A0'} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{!this.column.editRow && <FormOutlined class={`${this.prefixCls}__normal-icon`} />} |
|
|
|
{(this.column.edit && !this.column.editRow) && <FormOutlined class={`${this.prefixCls}__normal-icon`} />} |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
{this.isEdit && ( |
|
|
|
{this.isEdit && ( |
|
|
|
<Spin spinning={this.spinning}> |
|
|
|
<Spin spinning={this.spinning}> |
|
|
|