提交
This commit is contained in:
1 parent
c9fb39395c
commit
4f364bc9a0
58 files changed
+1040829
-6729
No files matched your search
@@ -159,7 +159,7 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -170,12 +170,17 @@ import type { ContractProductForm, ContractQuery, ContractVO } from '@/api/crm/c
|
||||
import { planApi } from '@/api/pl'
|
||||
import DictTag from '@/components/DictTag/index.vue'
|
||||
import ListPagination from '@/components/ListPagination/index.vue'
|
||||
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
|
||||
import { useDictStore } from '@/store/modules/dict'
|
||||
import { formatPlanProductListText } from '@/utils/pl-display'
|
||||
|
||||
const ContractDetailDialog = defineAsyncComponent(
|
||||
() => import('@/views/crm/contract/components/ContractDetailDialog.vue')
|
||||
)
|
||||
const {
|
||||
ContractDetailDialog,
|
||||
contractDetailRef,
|
||||
openContractDetail,
|
||||
hideProductPrice
|
||||
} = useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
|
||||
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
@@ -220,7 +225,6 @@ const contractList = ref<ContractVO[]>([])
|
||||
const currentRow = ref<ContractVO | null>(null)
|
||||
const selectedId = ref('')
|
||||
const planCountMap = ref<Record<string, number>>({})
|
||||
const contractDetailRef = ref<InstanceType<typeof ContractDetailDialog>>()
|
||||
|
||||
const queryParams = reactive<ContractQuery>({
|
||||
pageNum: 1,
|
||||
@@ -264,32 +268,8 @@ function formatContractProductLine(product: ContractProductForm) {
|
||||
)
|
||||
}
|
||||
|
||||
async function waitForContractDetailDialog() {
|
||||
if (contractDetailRef.value) return contractDetailRef.value
|
||||
await nextTick()
|
||||
if (contractDetailRef.value) return contractDetailRef.value
|
||||
return new Promise<NonNullable<typeof contractDetailRef.value>>((resolve) => {
|
||||
const stop = watch(
|
||||
contractDetailRef,
|
||||
(val) => {
|
||||
if (val) {
|
||||
stop()
|
||||
resolve(val)
|
||||
}
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
async function handleViewContract(row: ContractVO) {
|
||||
const contractId = row?.id
|
||||
if (!contractId) {
|
||||
ElMessage.warning('合同信息无效')
|
||||
return
|
||||
}
|
||||
const dialog = await waitForContractDetailDialog()
|
||||
await dialog.open(contractId)
|
||||
await openContractDetail(row?.id)
|
||||
}
|
||||
|
||||
function isContractSelectable(row: ContractVO): boolean {
|
||||
|
||||
@@ -166,7 +166,7 @@
|
||||
@confirm="handleConfirmSingle"
|
||||
/>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -179,13 +179,18 @@ import { fetchProductDetail } from '@/api/crm/product'
|
||||
import ContractSelector from '@/components/business/contract-selector/index.vue'
|
||||
import MpContractSelectSheet from '@/components/mp/MpContractSelectSheet.vue'
|
||||
import DictTag from '@/components/DictTag/index.vue'
|
||||
import { useContractDetailDialog } from '@/composables/useContractDetailDialog'
|
||||
import { applyAliasDisplayMeta, formatBrandConstraintLabel } from '@/utils/crm-product-brand'
|
||||
import { collectContractProductIds } from '@/utils/pl-plan-contract-product'
|
||||
import { PL_PLAN_FORM_MOBILE_PICKERS_KEY } from '@/utils/pl-plan-form-mobile'
|
||||
|
||||
const ContractDetailDialog = defineAsyncComponent(
|
||||
() => import('@/views/crm/contract/components/ContractDetailDialog.vue')
|
||||
)
|
||||
const {
|
||||
ContractDetailDialog,
|
||||
contractDetailRef,
|
||||
openContractDetail,
|
||||
hideProductPrice
|
||||
} = useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
|
||||
|
||||
export interface PlanContractLinkForm {
|
||||
contractId: string
|
||||
@@ -233,7 +238,6 @@ const useMobileSheet = computed(() => {
|
||||
const selectorVisible = ref(false)
|
||||
const detailRows = ref<ContractVO[]>([])
|
||||
const loadingDetails = ref(false)
|
||||
const contractDetailRef = ref<InstanceType<typeof ContractDetailDialog>>()
|
||||
const expandedContractIds = ref<Set<string>>(new Set())
|
||||
|
||||
function isExpanded(contractId: string) {
|
||||
@@ -379,24 +383,6 @@ function removeContract(id: string) {
|
||||
emitLinksFromDetails(next)
|
||||
}
|
||||
|
||||
async function waitForContractDetailDialog() {
|
||||
if (contractDetailRef.value) return contractDetailRef.value
|
||||
await nextTick()
|
||||
if (contractDetailRef.value) return contractDetailRef.value
|
||||
return new Promise<NonNullable<typeof contractDetailRef.value>>((resolve) => {
|
||||
const stop = watch(
|
||||
contractDetailRef,
|
||||
(val) => {
|
||||
if (val) {
|
||||
stop()
|
||||
resolve(val)
|
||||
}
|
||||
},
|
||||
{ flush: 'post' }
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
async function handleViewContract(contractId: string) {
|
||||
const id = String(contractId || '').trim()
|
||||
if (!id) {
|
||||
@@ -404,8 +390,7 @@ async function handleViewContract(contractId: string) {
|
||||
return
|
||||
}
|
||||
emit('view', id)
|
||||
const dialog = await waitForContractDetailDialog()
|
||||
await dialog.open(id)
|
||||
await openContractDetail(id)
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -1,15 +1,59 @@
|
||||
import { defineAsyncComponent, nextTick, ref, watch } from 'vue'
|
||||
import { computed, defineAsyncComponent, nextTick, ref, watch } from 'vue'
|
||||
import { fetchGetMenuCodes } from '@/api/auth'
|
||||
|
||||
export const ContractDetailDialogAsync = defineAsyncComponent(
|
||||
() => import('@/views/crm/contract/components/ContractDetailDialog.vue')
|
||||
)
|
||||
|
||||
/** 运输管理四页:合同详情弹窗展示产品单价/金额 */
|
||||
export const PL_CONTRACT_VIEW_PRODUCT_PRICE_PERM = 'pl:contract:view-product-price'
|
||||
|
||||
type ContractDetailDialogExpose = {
|
||||
open: (id: string | number) => Promise<void>
|
||||
}
|
||||
|
||||
export function useContractDetailDialog() {
|
||||
export function useContractDetailDialog(options?: {
|
||||
/**
|
||||
* 为 true 时:无 pl:contract:view-product-price(或自定义 productPricePerm)则隐藏产品价格。
|
||||
* 默认 false(CRM 等场景仍展示价格)。
|
||||
*/
|
||||
gateProductPriceByPerm?: boolean
|
||||
productPricePerm?: string
|
||||
}) {
|
||||
const contractDetailRef = ref<ContractDetailDialogExpose>()
|
||||
const permCode = options?.productPricePerm || PL_CONTRACT_VIEW_PRODUCT_PRICE_PERM
|
||||
const canViewProductPrice = ref(!options?.gateProductPriceByPerm)
|
||||
const hideProductPrice = computed(() =>
|
||||
options?.gateProductPriceByPerm ? !canViewProductPrice.value : false
|
||||
)
|
||||
let loadPromise: Promise<void> | null = null
|
||||
|
||||
async function loadProductPricePermission() {
|
||||
if (!options?.gateProductPriceByPerm) return
|
||||
if (loadPromise) {
|
||||
await loadPromise
|
||||
return
|
||||
}
|
||||
loadPromise = (async () => {
|
||||
try {
|
||||
const perm = await fetchGetMenuCodes()
|
||||
canViewProductPrice.value =
|
||||
!!perm?.all ||
|
||||
!!perm?.isSuperAdmin ||
|
||||
(perm?.menuCodes || []).includes(permCode)
|
||||
} catch {
|
||||
canViewProductPrice.value = false
|
||||
} finally {
|
||||
loadPromise = null
|
||||
}
|
||||
})()
|
||||
await loadPromise
|
||||
}
|
||||
|
||||
// setup 阶段立即拉取(避免仅依赖 onMounted:本地 HMR/缓存页可能导致权限一直为默认隐藏)
|
||||
if (options?.gateProductPriceByPerm) {
|
||||
void loadProductPricePermission()
|
||||
}
|
||||
|
||||
async function waitForContractDetailDialog() {
|
||||
if (contractDetailRef.value) return contractDetailRef.value
|
||||
@@ -35,6 +79,9 @@ export function useContractDetailDialog() {
|
||||
ElMessage.warning('暂无关联合同')
|
||||
return
|
||||
}
|
||||
if (options?.gateProductPriceByPerm) {
|
||||
await loadProductPricePermission()
|
||||
}
|
||||
const dialog = await waitForContractDetailDialog()
|
||||
await dialog.open(id)
|
||||
}
|
||||
@@ -42,6 +89,9 @@ export function useContractDetailDialog() {
|
||||
return {
|
||||
ContractDetailDialog: ContractDetailDialogAsync,
|
||||
contractDetailRef,
|
||||
openContractDetail
|
||||
openContractDetail,
|
||||
hideProductPrice,
|
||||
canViewProductPrice,
|
||||
loadProductPricePermission
|
||||
}
|
||||
}
|
||||
@@ -693,7 +693,7 @@
|
||||
</template>
|
||||
</PlPlanViewDialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
|
||||
<PlPlanArchiveDialog
|
||||
v-model:visible="archiveDialogVisible"
|
||||
@@ -766,7 +766,8 @@ import { refreshMenuBadges } from '@/utils/menu-badge-registry'
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail, hideProductPrice } =
|
||||
useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
|
||||
/** 计划区可合并列(顺序须与表格左侧列一致,不含勾选/序号/计划编号) */
|
||||
const PLAN_MERGE_COLUMN_PROPS = [
|
||||
|
||||
@@ -593,7 +593,7 @@
|
||||
</template>
|
||||
</PlPlanViewDialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
|
||||
<PlPlanCertUploadDialog
|
||||
v-model:visible="certDialogVisible"
|
||||
@@ -665,7 +665,8 @@
|
||||
import { useMenuStore } from '@/store/modules/menu'
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail, hideProductPrice } =
|
||||
useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
|
||||
const PLAN_MERGE_COLUMN_PROPS = [
|
||||
'planDate',
|
||||
|
||||
@@ -500,7 +500,7 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -554,7 +554,8 @@ import { useMenuStore } from '@/store/modules/menu'
|
||||
const PLAN_MERGE_COLUMN_PROPS = ['planDate', 'deliveryTimes', 'planType', 'followStatus'] as const
|
||||
|
||||
const menuStore = useMenuStore()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail, hideProductPrice } =
|
||||
useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
const loading = ref(false)
|
||||
const tableData = ref<PlanContractGapItem[]>([])
|
||||
const dateRange = ref<string[]>([])
|
||||
|
||||
@@ -740,7 +740,7 @@
|
||||
</template>
|
||||
</PlPlanViewDialog>
|
||||
|
||||
<ContractDetailDialog ref="contractDetailRef" hide-product-price />
|
||||
<ContractDetailDialog ref="contractDetailRef" :hide-product-price="hideProductPrice" />
|
||||
|
||||
<DbPoundSlipQrcodeDialog
|
||||
v-model:visible="qrcodeVisible"
|
||||
@@ -927,7 +927,8 @@ import { useListTableViewportHeight } from '@/composables/useListTableViewportHe
|
||||
] as const
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail } = useContractDetailDialog()
|
||||
const { ContractDetailDialog, contractDetailRef, openContractDetail, hideProductPrice } =
|
||||
useContractDetailDialog({ gateProductPriceByPerm: true })
|
||||
|
||||
const loading = ref(false)
|
||||
const voidLoading = ref(false)
|
||||
|
||||
Reference in new issue
Block a user