feat(web-admin): add page variant for contract form in mp webview.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
796b434a28
commit
a33c2d1f2e
2 files changed
+228
-18
No files matched your search
@@ -1,13 +1,20 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
v-model="dialogVisible"
|
||||
:title="formTitle"
|
||||
width="calc(100vw - 48px)"
|
||||
:title="isPageVariant ? undefined : formTitle"
|
||||
:width="isPageVariant ? '100%' : 'calc(100vw - 48px)'"
|
||||
:fullscreen="isPageVariant"
|
||||
:show-close="!isPageVariant"
|
||||
:modal="!isPageVariant"
|
||||
:append-to-body="!isPageVariant"
|
||||
align-center
|
||||
class="dialog-form-layout contract-form-dialog"
|
||||
:class="[
|
||||
'dialog-form-layout',
|
||||
'contract-form-dialog',
|
||||
{ 'contract-form-dialog--page': isPageVariant }
|
||||
]"
|
||||
destroy-on-close
|
||||
append-to-body
|
||||
modal-class="order-module-dialog-mask"
|
||||
:modal-class="isPageVariant ? undefined : 'order-module-dialog-mask'"
|
||||
:close-on-click-modal="false"
|
||||
@opened="handleOpened"
|
||||
>
|
||||
@@ -20,9 +27,10 @@
|
||||
ref="formRef"
|
||||
:model="form"
|
||||
:rules="rules"
|
||||
label-position="right"
|
||||
label-width="120px"
|
||||
:label-position="isPageVariant ? 'top' : 'right'"
|
||||
:label-width="isPageVariant ? undefined : '120px'"
|
||||
class="crm-dialog-form"
|
||||
:class="{ 'crm-dialog-form--page': isPageVariant }"
|
||||
:disabled="formLoading"
|
||||
>
|
||||
<!-- 合同基础信息(一行 4 列) -->
|
||||
@@ -946,18 +954,29 @@ type ExtendedContractProductForm = ContractProductForm & {
|
||||
priceTiers?: PriceTierRow[]
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
editId: string | null
|
||||
/** 复制来源合同(列表选中行,含 products) */
|
||||
copySource?: ContractVO | null
|
||||
}>()
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
visible: boolean
|
||||
editId: string | null
|
||||
/** 复制来源合同(列表选中行,含 products) */
|
||||
copySource?: ContractVO | null
|
||||
/** dialog=桌面弹窗;page=小程序 WebView 全屏页 */
|
||||
variant?: 'dialog' | 'page'
|
||||
}>(),
|
||||
{
|
||||
copySource: null,
|
||||
variant: 'dialog'
|
||||
}
|
||||
)
|
||||
|
||||
const emit = defineEmits<{
|
||||
'update:visible': [value: boolean]
|
||||
success: []
|
||||
'loading-change': [loading: boolean]
|
||||
}>()
|
||||
|
||||
const isPageVariant = computed(() => props.variant === 'page')
|
||||
|
||||
const dialogVisible = computed({
|
||||
get: () => props.visible,
|
||||
set: (val) => emit('update:visible', val)
|
||||
@@ -1098,12 +1117,18 @@ watch(
|
||||
(visible) => {
|
||||
if (visible && (props.editId || props.copySource)) {
|
||||
formLoading.value = true
|
||||
emit('loading-change', true)
|
||||
} else if (!visible) {
|
||||
formLoading.value = false
|
||||
emit('loading-change', false)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
watch(formLoading, (loading) => {
|
||||
if (props.visible) emit('loading-change', loading)
|
||||
})
|
||||
|
||||
// 组件引用
|
||||
const formRef = ref<FormInstance>()
|
||||
const approvalDialogRef = ref()
|
||||
@@ -1368,7 +1393,7 @@ const handleOpened = async () => {
|
||||
resetForm()
|
||||
const isEdit = !!props.editId
|
||||
const isCopy = !!props.copySource
|
||||
if (isEdit || isCopy) {
|
||||
if (isEdit || isCopy || isPageVariant.value) {
|
||||
formLoading.value = true
|
||||
}
|
||||
try {
|
||||
@@ -3024,6 +3049,32 @@ const loadSupplierList = async () => {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
&.contract-form-dialog--page {
|
||||
:deep(.el-dialog__wrapper) {
|
||||
top: 0 !important;
|
||||
height: 100% !important;
|
||||
}
|
||||
|
||||
:deep(.el-dialog) {
|
||||
max-height: 100%;
|
||||
border-radius: 0;
|
||||
box-shadow: none;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__header) {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__body) {
|
||||
padding: 8px 12px 16px;
|
||||
}
|
||||
|
||||
:deep(.el-dialog__footer) {
|
||||
padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
|
||||
border-top: 1px solid #e2e8f0;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.dialog-footer) {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -3053,6 +3104,22 @@ const loadSupplierList = async () => {
|
||||
padding: 0 4px;
|
||||
}
|
||||
|
||||
.crm-dialog-form--page {
|
||||
.contract-basic-info {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
:deep(.el-row) {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.el-col) {
|
||||
width: 100% !important;
|
||||
max-width: 100% !important;
|
||||
}
|
||||
}
|
||||
|
||||
.contract-basic-info {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
|
||||
Reference in new issue
Block a user