From a660db06773007b1be690e0674829c00a57aeb7b Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期三, 24 十二月 2025 16:21:23 +0800
Subject: [PATCH] 订单首页流程卡新增楼层编号显示
---
north-glass-erp/northglass-erp/src/components/BasicTable.vue | 99 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 98 insertions(+), 1 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/components/BasicTable.vue b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
index b21223f..0a6ac2a 100644
--- a/north-glass-erp/northglass-erp/src/components/BasicTable.vue
+++ b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
@@ -122,6 +122,8 @@
pageTotal : 0,//鎬婚〉鏁�
dataTotal : 0,//鏁版嵁鎬绘潯鏁�
})
+
+const isFirstLoad = ref(true);
const sumNum = (list, field) => {
let count = 0
list.forEach(item => {
@@ -129,6 +131,90 @@
})
return count.toFixed(2)
}
+
+//鍚堝苟鏄剧ず鍏朵粬鍒�
+const handleDynamicColumns = (data,title,orderOtherMoney) => {
+ // 1. 鏀堕泦鎵�鏈夎鐨刼therColumns瀛楁锛堝幓閲嶏級
+ /*const allOtherFields = new Set();
+ data.forEach(row => {
+ if (!row || !row.otherColumns) return;
+
+ let parsedOtherColumns;
+ try {
+ // 鏍稿績锛氬皢瀛楃涓茶В鏋愪负JSON
+ parsedOtherColumns = JSON.parse(row.otherColumns);
+ } catch (e) {
+ console.error('瑙f瀽otherColumns澶辫触锛�', e, '鍘熷鏁版嵁锛�', row.otherColumns);
+ return;
+ }
+
+ // 2. 浠庤В鏋愬悗鐨凧SON涓敹闆嗗瓧娈碉紙鏀寔鏁扮粍鎴栧璞℃牸寮忥級
+ if (Array.isArray(parsedOtherColumns)) {
+ // 鏁扮粍鏍煎紡锛歔{ key: 'field1', label: '瀛楁1', value: '鍊�1' }, ...]
+ parsedOtherColumns.forEach(item => {
+ if (item.key) allOtherFields.add(item.key);
+ });
+ } else if (typeof parsedOtherColumns === 'object' && parsedOtherColumns !== null) {
+ // 瀵硅薄鏍煎紡锛歿 field1: { label: '瀛楁1', value: '鍊�1' }, ... }
+ Object.keys(parsedOtherColumns).forEach(key => {
+ allOtherFields.add(key);
+ });
+ }
+ });*/
+
+ // 2. 鐢熸垚鍔ㄦ�佸瓙鍒楋紙浣滀负processList鐨刢hildren锛�
+ /*const otherColumns = Array.from(allOtherFields).map(field => {
+ // 灏濊瘯鑾峰彇瀛楁瀵瑰簲鐨刲abel锛堜紭鍏堝彇绗竴涓嚭鐜扮殑label锛�
+ let label=field;
+ title.forEach(item=>{
+ if(field==item.column){
+ label=item.alias
+ }
+ })
+ return {
+ title: label,
+ field: `otherColumnsJson.${field}`,
+ width: 120,
+ align: 'center',
+ // 澶勭悊瀛楁鍊兼樉绀猴紙鍏煎鏁扮粍/瀵硅薄绫诲瀷鐨刼therColumns锛�
+ formatter: ({ row }) => {
+ return row.otherColumnsJson?.[field] || '';
+
+ }
+ };
+ });*/
+
+ const otherColumns = [];
+ // 瀹归敊锛氱‘淇漮rderOtherMoney鏄湁鏁堟暟缁�
+ if (Array.isArray(orderOtherMoney) && orderOtherMoney.length > 0) {
+ orderOtherMoney.forEach(item => {
+ // 璺宠繃绌烘暟鎹紝閬垮厤鏃犳晥鍒�
+ if (!item || !item.column) return;
+ otherColumns.push({
+ title: item.alias || item.column, // 浼樺厛鐢ㄥ埆鍚嶏紝鏃犲垯鐢ㄥ瓧娈靛悕
+ field: `otherColumnsJson.${item.column}`,
+ width: 120,
+ align: 'center',
+ // 鏍煎紡鍖栧彇鍊硷細鍏煎瑙f瀽鍚庣殑JSON缁撴瀯
+ formatter: ({ row }) => {
+ return row.otherColumnsJson?.[item.column] || '';
+ }
+ });
+ });
+ }
+
+ // 3. 瀹氫箟鐖剁骇鍒梡rocessList锛屽寘鍚姩鎬佸瓙鍒�
+ const processList = {
+ title: t('basicData.otherColumns'),
+ field: 'process',
+ children: otherColumns // 灏嗗姩鎬佸垪浣滀负瀛愬垪
+ };
+
+ // 4. 鍏堢Щ闄ゅ凡瀛樺湪鐨刾rocess鍒楋紙閬垮厤閲嶅锛夛紝鍐嶆坊鍔犳柊鍒�
+ gridOptions.columns = gridOptions.columns.filter(col => col.field !== 'process');
+ gridOptions.columns.push(processList);
+}
+
@@ -180,6 +266,14 @@
basicProp.value.pageTotal = res.data.total.pageTotal
basicProp.value.dataTotal = res.data.total.total
orderInfo.reportFormDate = res.data.selectDate
+
+ //璁㈠崟鏄庣粏鎶ヨ〃
+ if (isFirstLoad.value && props.childrenData.url === '/order/getOrderReport') {
+ const dataList = res.data.data || [];
+ const orderOtherMoney = res.data.orderOtherMoney[0] || [];
+ handleDynamicColumns(dataList,res.data.title,orderOtherMoney)
+ isFirstLoad.value = false; // 棣栨鍔犺浇鍚庣疆涓篺alse
+ }
}
})
return
@@ -190,6 +284,8 @@
basicProp.value.pageTotal = res.data.total.pageTotal
basicProp.value.dataTotal = res.data.total.total
orderInfo.reportFormDate = res.data.selectDate
+
+
}
})
}
@@ -198,7 +294,8 @@
const $table = xGrid.value
if ($table) {
$table.exportData({
- fileName:'1.xlsx',
+ filename: 'order_export',
+ sheetName: 'Sheet1',
type: 'xlsx'
})
}
--
Gitblit v1.8.0