forked from wangjiadong/comp
commit
fd4166882e
3 changed files with 85 additions and 66 deletions
@ -1,77 +1,82 @@ |
|||||||
<template> |
<template> |
||||||
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"> |
<a-modal :title="title" :width="width" :visible="visible" @ok="handleOk" |
||||||
<AwardPersionForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"></AwardPersionForm> |
:okButtonProps="{ class: { 'jee-hidden': disableSubmit } }" @cancel="handleCancel" cancelText="关闭"> |
||||||
|
<AwardPersionForm ref="registerForm" @ok="submitCallback" :formDisabled="disableSubmit" :formBpm="false"> |
||||||
|
</AwardPersionForm> |
||||||
</a-modal> |
</a-modal> |
||||||
</template> |
</template> |
||||||
|
|
||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import { ref, nextTick, defineExpose } from 'vue'; |
import { ref, nextTick, defineExpose, watch } from 'vue'; |
||||||
import AwardPersionForm from './AwardPersionForm.vue' |
import AwardPersionForm from './AwardPersionForm.vue' |
||||||
|
|
||||||
const title = ref<string>(''); |
|
||||||
const width = ref<number>(800); |
|
||||||
const visible = ref<boolean>(false); |
|
||||||
const disableSubmit = ref<boolean>(false); |
|
||||||
const registerForm = ref(); |
|
||||||
const emit = defineEmits(['register', 'success']); |
|
||||||
|
|
||||||
/** |
const title = ref<string>(''); |
||||||
* 新增 |
const width = ref<number>(800); |
||||||
*/ |
const visible = ref<boolean>(false); |
||||||
function add() { |
const disableSubmit = ref<boolean>(false); |
||||||
title.value = '新增'; |
const registerForm = ref(); |
||||||
visible.value = true; |
const emit = defineEmits(['register', 'success']); |
||||||
nextTick(() => { |
watch(() => visible.value, newVal => { |
||||||
registerForm.value.add(); |
if (!newVal) registerForm.value.setIsT(false); |
||||||
registerForm.value.setIsT(false); |
}) |
||||||
}); |
|
||||||
} |
|
||||||
|
|
||||||
/** |
/** |
||||||
* 编辑 |
* 新增 |
||||||
* @param record |
*/ |
||||||
*/ |
function add() { |
||||||
function edit(record) { |
title.value = '新增'; |
||||||
title.value = disableSubmit.value ? '详情' : '编辑'; |
visible.value = true; |
||||||
visible.value = true; |
nextTick(() => { |
||||||
nextTick(() => { |
registerForm.value.add(); |
||||||
registerForm.value.edit(record); |
}); |
||||||
registerForm.value.setIsT(true); |
} |
||||||
}); |
|
||||||
} |
/** |
||||||
|
* 编辑 |
||||||
|
* @param record |
||||||
|
*/ |
||||||
|
function edit(record) { |
||||||
|
title.value = disableSubmit.value ? '详情' : '编辑'; |
||||||
|
visible.value = true; |
||||||
|
nextTick(() => { |
||||||
|
registerForm.value.edit(record); |
||||||
|
registerForm.value.setIsT(true); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 确定按钮点击事件 |
* 确定按钮点击事件 |
||||||
*/ |
*/ |
||||||
function handleOk() { |
function handleOk() { |
||||||
registerForm.value.submitForm(); |
registerForm.value.submitForm(); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* form保存回调事件 |
* form保存回调事件 |
||||||
*/ |
*/ |
||||||
function submitCallback() { |
function submitCallback() { |
||||||
handleCancel(); |
handleCancel(); |
||||||
emit('success'); |
emit('success'); |
||||||
} |
} |
||||||
|
|
||||||
/** |
/** |
||||||
* 取消按钮回调事件 |
* 取消按钮回调事件 |
||||||
*/ |
*/ |
||||||
function handleCancel() { |
function handleCancel() { |
||||||
visible.value = false; |
visible.value = false; |
||||||
} |
} |
||||||
|
|
||||||
defineExpose({ |
defineExpose({ |
||||||
add, |
add, |
||||||
edit, |
edit, |
||||||
disableSubmit, |
disableSubmit, |
||||||
}); |
}); |
||||||
</script> |
</script> |
||||||
|
|
||||||
<style> |
<style> |
||||||
/**隐藏样式-modal确定按钮 */ |
/**隐藏样式-modal确定按钮 */ |
||||||
.jee-hidden { |
.jee-hidden { |
||||||
display: none !important; |
display: none !important; |
||||||
} |
} |
||||||
</style> |
</style> |
||||||
|
Loading…
Reference in new issue