From fa33b3fa729dea98eb1348a275a264203f8c7f6f Mon Sep 17 00:00:00 2001 From: zmj <1493694146@qq.com> Date: Wed, 10 Apr 2024 16:23:55 +0800 Subject: [PATCH] add --- src/components/salescontract/index.vue | 34 ++++--- src/hooks/usePaging.ts | 39 ++++++-- src/views/bid_bidding_decision/edit.vue | 20 +++- src/views/bid_bidding_decision/index.vue | 35 ++++--- src/views/contract/edit.vue | 32 +++---- src/views/contract/index.vue | 22 +++-- src/views/custom/detail.vue | 99 ++++++++------------ src/views/custom/edit.vue | 33 +++---- src/views/custom/index.vue | 23 ++--- src/views/custom_contacts/index.vue | 17 ++-- src/views/custom_service/index.vue | 43 +++++---- src/views/organization/organization/edit.vue | 4 +- src/views/project/index.vue | 30 +++--- src/views/project_follow_up/edit.vue | 16 ++-- src/views/project_follow_up/index.vue | 23 ++--- src/views/quotation/edit.vue | 28 +++--- src/views/quotation/index.vue | 34 ++++--- 17 files changed, 293 insertions(+), 239 deletions(-) diff --git a/src/components/salescontract/index.vue b/src/components/salescontract/index.vue index fa9a02c..a17be01 100644 --- a/src/components/salescontract/index.vue +++ b/src/components/salescontract/index.vue @@ -2,8 +2,8 @@
- - + + 查询 @@ -16,19 +16,22 @@
- - - - - - - - - - - - - + + + + + + + + + + + + + + + +
@@ -58,6 +61,7 @@ const props = defineProps({ const queryParams = reactive({ contract_code: '', project_id: props.project_id, + contract_name: "", contract_type: props.contract_type, }); const { dictData } = useDictData('contract_type') diff --git a/src/hooks/usePaging.ts b/src/hooks/usePaging.ts index 9db873b..0d3a56c 100644 --- a/src/hooks/usePaging.ts +++ b/src/hooks/usePaging.ts @@ -13,6 +13,23 @@ interface Icolumn { column: { label: String; width: Number; property: string }; } +/** + * @description 计算table中每一项渲染到dom上所需要的宽度 + * @param string:需要渲染到dom上的内容 + * */ +function getWidthOfString(string: String) { + var span = document.createElement("span"); + // @ts-ignore + span.textContent = string; + span.style.visibility = "hidden"; + span.style.position = "absolute"; + span.style.whiteSpace = "nowrap"; + document.body.appendChild(span); + var width = span.offsetWidth; + document.body.removeChild(span); + return width; +} + export function usePaging(options: Options) { const { page = 1, @@ -32,15 +49,19 @@ export function usePaging(options: Options) { lists: [] as any[], extend: {} as Record, calcWidth: ({ column }: Icolumn) => { - // let propWidth = column.label.length * 14 + 24; - // let list = pager.lists.map( - // (item: Object) => (item as any)[column.property] - // ); - // const maxLength = list.reduce((max, str) => { - // return Math.max(max, String(str).length); - // }, 0); - // const columnWidth = maxLength * 14 + 24; - // column.width = Math.max(columnWidth, propWidth); + let propWidth = column.label.length * 14 + 26; + let list = pager.lists.map( + (item: Object) => (item as any)[column.property] + ); + + // start 遍历获取lits每一项所需要的宽度的最大值 + const maxLength = list.reduce((max, str) => { + return Math.max(max, getWidthOfString(str)); + }, 0); + // end + + const columnWidth = maxLength + 27; //27为el-table的cell 自带的padding 12px*2 + border 1px * 2 + 预留2px防止妖魔鬼怪作乱 + column.width = Math.max(columnWidth, propWidth); return column.label; }, }); diff --git a/src/views/bid_bidding_decision/edit.vue b/src/views/bid_bidding_decision/edit.vue index 126132f..bcad080 100644 --- a/src/views/bid_bidding_decision/edit.vue +++ b/src/views/bid_bidding_decision/edit.vue @@ -1,7 +1,7 @@