From 43e115a7de2c763c36d79e610a3abb1d833ea892 Mon Sep 17 00:00:00 2001
From: 廖井涛 <2265517004@qq.com>
Date: 星期一, 05 八月 2024 10:21:52 +0800
Subject: [PATCH] 修改发货报表

---
 north-glass-erp/northglass-erp/src/components/BasicTable.vue |  157 ++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 128 insertions(+), 29 deletions(-)

diff --git a/north-glass-erp/northglass-erp/src/components/BasicTable.vue b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
index 880f902..e49d379 100644
--- a/north-glass-erp/northglass-erp/src/components/BasicTable.vue
+++ b/north-glass-erp/northglass-erp/src/components/BasicTable.vue
@@ -2,9 +2,15 @@
 import {Search} from "@element-plus/icons-vue"
 import {defineEmits, onMounted, reactive, ref, watch} from "vue"
 import {changeFilterEvent} from "@/hook"
-import request from "@/utils/request";
+import request from "@/utils/request"
+import exportExcel  from "@/hook/exportExcel"
+import {addListener,exportData} from "@/hook/mouseMove"
 import deepClone from "@/utils/deepClone";
 import {ElMessage} from "element-plus";
+import * as XLSX from "xlsx";
+import {useI18n} from "vue-i18n";
+
+const { t } = useI18n()
 const xGrid = ref()
 let filterData = ref({})
 const gridOptions = reactive({
@@ -19,7 +25,8 @@
   printConfig: {},
   importConfig: {},
   exportConfig: {},
-  scrollY:{ enabled: true },//寮�鍚櫄鎷熸粴鍔�
+  scrollY:{ enabled: true,gt:0 },//寮�鍚櫄鎷熸粴鍔�
+  scrollX:{ enabled: true,gt:5 },//寮�鍚櫄鎷熸粴鍔�
   showOverflow:true,
   columnConfig: {
     resizable: true,
@@ -36,12 +43,24 @@
     mode: 'row',
     showStatus: true
   },//琛ㄥご鍙傛暟
-  columns:[
+  menuConfig: {
+    body: {
+      options: [
+        [
 
+          { code: 'exportExcelChecked', name: t('components.exportSelected'), prefixIcon: 'vxe-icon-download', visible: true }
+        ]
+      ]
+    }
+  },
+  columns:[
 
   ],//琛ㄥご鎸夐挳
   toolbarConfig: {
     buttons: [],
+    slots: {
+      tools: 'toolbar_buttons'
+    },
     // import: false,
     // export: true,
     // print: true,
@@ -54,7 +73,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)
@@ -65,6 +84,41 @@
   }
 
 })
+const gridEvents = {
+  menuClick ({ menu, row, column }) {
+    const $grid = xGrid.value
+    if ($grid) {
+      switch (menu.code) {
+        case 'exportExcelChecked': {
+          let result = exportData()
+          if(result){
+            // 灏嗘暟鎹浆鎹负 worksheet 瀵硅薄
+            const worksheet = XLSX.utils.aoa_to_sheet(result);
+            const workbook = XLSX.utils.book_new();
+            XLSX.utils.book_append_sheet(workbook, worksheet, 'Sheet1');
+            XLSX.writeFile(workbook, `${props.childrenData.exportName}.xlsx`);
+          }
+          break
+        }
+      }
+    }
+  }
+}
+
+
+const props = defineProps({
+  childrenData:{
+    Object,
+    default: ''
+  }
+})
+const basicProp = ref({
+  pageSize : 100,//椤甸潰鏄剧ず鏁伴噺
+  pageNum:1,//褰撳墠椤�
+  selectDate:['',''],//鏌ヨ鐨勬棩鏈�
+  pageTotal : 0,//鎬婚〉鏁�
+  dataTotal : 0,//鏁版嵁鎬绘潯鏁�
+})
 const sumNum = (list, field) => {
   let count = 0
   list.forEach(item => {
@@ -73,22 +127,19 @@
   return count.toFixed(2)
 }
 
-const props = defineProps({
-  childrenData:{
-    Object,
-    default: ''
-  }
-})
+
+
 watch(props, (newVal) => {
-  gridOptions.loading = true
   xGrid.value.loadData(props.childrenData.data)
   gridOptions.loading = false
 })
 onMounted(() => {
   gridOptions.columns = props.childrenData.columns
+  getReportData()
+  addListener(xGrid.value,gridOptions)
+
 
 })
-const emit = defineEmits(['getData'])
 function filterChanged(column){
   //gridOptions.loading=true
   //绛涢�夋潯浠跺彂鐢熷彉鍖栨潯浠跺彂鐢熷彉鍖�
@@ -103,39 +154,55 @@
   }else{
     filterData.value[column.property] = value
   }
-  const gaveParentData = {
-    selectDate:props.childrenData.selectDate,
-    filterData:filterData.value
-  }
-  emit('getData',filterData.value)
+
+  gridOptions.loading = true
+  getReportData()
 
 }
 
 const handlePageChange = ({ currentPage, pageSize }) => {
-  props.childrenData.pageNum = currentPage
-  props.childrenData.pageTotal = pageSize
-  emit('getData',filterData.value)
+  basicProp.value.pageNum = currentPage
+  basicProp.value.pageTotal = pageSize
+  gridOptions.loading = true
+  getReportData()
 }
 const dateChanged = () => {
-  emit('getData',filterData.value)
+  gridOptions.loading = true
+  getReportData()
 }
+
+const  getReportData = () => {
+  request.post(`${props.childrenData.url}/${basicProp.value.pageNum}/${basicProp.value.pageSize}/${basicProp.value.selectDate}`,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
+    }
+  })
+}
+
+
+
 
 </script>
 
 <template>
   <div class="main-div">
     <el-date-picker
-        v-model="props.childrenData.selectDate"
+        v-model="basicProp.selectDate"
         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"
     />
     <el-button
         @click="dateChanged"
         id="searchButton"
         type="primary"
         style="margin-top: -5px"
-        :icon="Search">鏌ヨ</el-button>
+        :icon="Search">{{$t('basicData.search')}}</el-button>
     <div class="order-detail">
       <vxe-grid
           @filter-change="filterChanged"
@@ -143,7 +210,18 @@
           class="mytable-scrollbar"
           ref="xGrid"
           v-bind="gridOptions"
+          v-on="gridEvents"
       >
+        <!--      涓嬫媺鏄剧ず鎵�鏈変俊鎭彃妲�-->
+        <template #content="{ row }">
+          <ul class="expand-wrapper">
+            <li  v-for="(item,index) in gridOptions.columns" v-show="item.field!==undefined && index>9">
+              <span style="font-weight: bold">{{item.title+':  '}}</span>
+              <span>{{ row[item.field] }}</span>
+            </li>
+          </ul>
+        </template>
+        <!--      涓嬫媺绛涢�夋彃妲�-->
         <template #num1_filter="{ column, $panel }">
           <div>
             <div v-for="(option, index) in column.filters" :key="index">
@@ -151,16 +229,25 @@
             </div>
           </div>
         </template>
+
+        <template #toolbar_buttons>
+          <vxe-button style="margin-right: 0.5rem"
+                      @click="exportExcel(props.childrenData.exportUrl,
+                                          props.childrenData.exportName,
+                                          basicProp.selectDate)">
+            {{$t('basicData.export')}}</vxe-button>
+        </template>
+
         <template #pager>
           <!--浣跨敤 pager 鎻掓Ы-->
           <!--        'PrevJump','NextJump', -->
           <vxe-pager
               @page-change="handlePageChange"
               :layouts="[  'PrevPage', 'Jump','PageCount', 'NextPage',  'Total']"
-              v-model:current-page="props.childrenData.pageNum"
-              v-model:page-size="props.childrenData.pageSize"
-              v-model:pager-count="props.childrenData.pageTotal"
-              :total="props.childrenData.dataTotal"
+              v-model:current-page="basicProp.pageNum"
+              v-model:page-size="basicProp.pageSize"
+              v-model:pager-count="basicProp.pageTotal"
+              :total="basicProp.dataTotal"
           >
           </vxe-pager>
         </template>
@@ -192,4 +279,16 @@
   height:  calc(100% - 30px);
 
 }
+
+.vxe-grid {
+  /* 绂佺敤娴忚鍣ㄩ粯璁ら�変腑 */
+  -webkit-user-select: none;
+  -moz-user-select: none;
+  -ms-user-select: none;
+  user-select: none;
+}
+:deep(#product .el-dialog__body){
+  height: 90%;
+  width: 100%;
+}
 </style>
\ No newline at end of file

--
Gitblit v1.8.0