From 33dbc6a161554f3a897f9e9273feb4f2c1b47381 Mon Sep 17 00:00:00 2001
From: chenlu <1320612696@qq.com>
Date: 星期一, 15 十二月 2025 17:04:27 +0800
Subject: [PATCH] Merge branch 'master' of http://10.153.19.25:10105/r/ERP_override
---
north-glass-erp/northglass-erp/src/components/BasicTable.vue | 165 ++++++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 139 insertions(+), 26 deletions(-)
diff --git a/north-glass-erp/northglass-erp/src/components/BasicTable.vue b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
index aa0fbd0..9bd61fa 100644
--- a/north-glass-erp/northglass-erp/src/components/BasicTable.vue
+++ b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
@@ -8,8 +8,13 @@
import deepClone from "@/utils/deepClone";
import {ElMessage} from "element-plus";
import * as XLSX from "xlsx";
+import {useI18n} from "vue-i18n";
+import useOrderInfoStore from "@/stores/sd/order/orderInfo";
+
+const { t } = useI18n()
const xGrid = ref()
let filterData = ref({})
+const orderInfo = useOrderInfoStore()
const gridOptions = reactive({
loading:true,
border: "full",//琛ㄦ牸鍔犺竟妗�
@@ -22,7 +27,8 @@
printConfig: {},
importConfig: {},
exportConfig: {},
- scrollY:{ enabled: true },//寮�鍚櫄鎷熸粴鍔�
+ scrollY:{ enabled: true,gt:0 },//寮�鍚櫄鎷熸粴鍔�
+ scrollX:{ enabled: true,gt:5 },//寮�鍚櫄鎷熸粴鍔�
showOverflow:true,
columnConfig: {
resizable: true,
@@ -44,7 +50,7 @@
options: [
[
- { code: 'exportExcelChecked', name: '瀵煎嚭閫変腑', prefixIcon: 'vxe-icon-download', visible: true }
+ { code: 'exportExcelChecked', name: t('components.exportSelected'), prefixIcon: 'vxe-icon-download', visible: true }
]
]
}
@@ -55,7 +61,8 @@
toolbarConfig: {
buttons: [],
slots: {
- tools: 'toolbar_buttons'
+ tools: 'toolbar_buttons',
+ buttons:'buttons'
},
// import: false,
// export: true,
@@ -69,7 +76,7 @@
return[
columns.map((column, columnIndex) => {
if (columnIndex === 0) {
- return '鍚堣:'
+ return t('basicData.total')
}
if (props.childrenData.footList.includes(column.field)) {
return sumNum(data, column.field)
@@ -109,7 +116,7 @@
}
})
const basicProp = ref({
- pageSize : 100,//椤甸潰鏄剧ず鏁伴噺
+ pageSize : 10000,//椤甸潰鏄剧ず鏁伴噺
pageNum:1,//褰撳墠椤�
selectDate:['',''],//鏌ヨ鐨勬棩鏈�
pageTotal : 0,//鎬婚〉鏁�
@@ -123,6 +130,71 @@
return count.toFixed(2)
}
+//鍚堝苟鏄剧ず鍏朵粬鍒�
+const handleDynamicColumns = (data,title) => {
+ // 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] || '';
+
+ }
+ };
+ });
+
+ // 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);
+}
+
+
watch(props, (newVal) => {
@@ -133,8 +205,6 @@
gridOptions.columns = props.childrenData.columns
getReportData()
addListener(xGrid.value,gridOptions)
-
-
})
function filterChanged(column){
//gridOptions.loading=true
@@ -168,28 +238,57 @@
}
const getReportData = () => {
- request.post(`${props.childrenData.url}/${basicProp.value.pageNum}/${basicProp.value.pageSize}/${basicProp.value.selectDate}`,filterData.value).then(res => {
+ if(props.childrenData.model!=null){
+ request.post(`${props.childrenData.url}/${basicProp.value.pageNum}/${basicProp.value.pageSize}/${orderInfo.reportFormDate}/${props.childrenData.model}/${props.childrenData.scope}`,filterData.value).then(res => {
+ if(res.code === '200'){
+ props.childrenData.data = res.data.data
+ basicProp.value.pageTotal = res.data.total.pageTotal
+ basicProp.value.dataTotal = res.data.total.total
+ orderInfo.reportFormDate = res.data.selectDate
+
+ //璁㈠崟鏄庣粏鎶ヨ〃
+ if (props.childrenData.url === '/order/getOrderReport') {
+ const dataList = res.data.data || [];
+ handleDynamicColumns(dataList,res.data.title)
+ }
+ }
+ })
+ return
+ }
+ request.post(`${props.childrenData.url}/${basicProp.value.pageNum}/${basicProp.value.pageSize}/${orderInfo.reportFormDate}`,filterData.value).then(res => {
if(res.code === '200'){
props.childrenData.data = res.data.data
basicProp.value.pageTotal = res.data.total.pageTotal
basicProp.value.dataTotal = res.data.total.total
- basicProp.value.selectDate = res.data.selectDate
+ orderInfo.reportFormDate = res.data.selectDate
+
+
}
})
}
-
+const exportEvent = () => {
+ const $table = xGrid.value
+ if ($table) {
+ $table.exportData({
+ filename: 'order_export',
+ sheetName: 'Sheet1',
+ type: 'xlsx'
+ })
+ }
+}
</script>
<template>
- <div class="main-div">
+ <div style="width: 100%;height: 100%">
+ <div class="head">
<el-date-picker
- v-model="basicProp.selectDate"
+ v-model="orderInfo.reportFormDate"
type="daterange"
- start-placeholder="寮�濮嬫椂闂�"
- end-placeholder="缁撴潫鏃堕棿"
+ :start-placeholder="$t('basicData.startDate')"
+ :end-placeholder="$t('basicData.endDate')"
format="YYYY-MM-DD"
value-format="YYYY-MM-DD"
/>
@@ -198,11 +297,12 @@
id="searchButton"
type="primary"
style="margin-top: -5px"
- :icon="Search">鏌ヨ</el-button>
- <div class="order-detail">
+ :icon="Search">{{$t('basicData.search')}}</el-button>
+ </div>
+ <div class="main-table">
<vxe-grid
@filter-change="filterChanged"
- height="110%"
+ height="100%"
class="mytable-scrollbar"
ref="xGrid"
v-bind="gridOptions"
@@ -221,18 +321,30 @@
<template #num1_filter="{ column, $panel }">
<div>
<div v-for="(option, index) in column.filters" :key="index">
- <input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
+ <input type="text"
+ v-model="option.data"
+ @keyup.enter.native="$panel.confirmFilter()"
+ @input="changeFilterEvent($event, option, $panel)"/>
</div>
</div>
</template>
<template #toolbar_buttons>
- <vxe-button style="margin-right: 0.5rem"
- @click="exportExcel(props.childrenData.exportUrl,
+ <vxe-button icon="vxe-icon-download" circle
+ style="margin-right: 0.5rem"
+ @click="exportEvent" />
+
+ <vxe-button icon="vxe-icon-cloud-download" style="margin-right: 0.5rem"
+ circle
+ @click="exportExcel(props.childrenData.exportUrl,
props.childrenData.exportName,
- basicProp.selectDate)">
- 瀵煎嚭</vxe-button>
+ orderInfo.reportFormDate)" />
+
</template>
+ <template #buttons>
+ <slot name="buttons"></slot>
+ </template>
+
<template #pager>
<!--浣跨敤 pager 鎻掓Ы-->
@@ -267,13 +379,14 @@
border: none !important;
background-color: transparent;
}
-.order-primary{
+.head{
width: 100%;
+ height: 35px;
}
-.order-detail{
- width: 100%;
- height: calc(100% - 30px);
+.main-table{
+ width: 100%;
+ height: calc(100% - 35px);
}
.vxe-grid {
--
Gitblit v1.8.0