guoyuji
2024-04-12 1c12d2d1e45e266f3c50ca18aa5ae6b3c5b74cc0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<script setup>
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 deepClone from "@/utils/deepClone";
import {ElMessage} from "element-plus";
const xGrid = ref()
let filterData = ref({})
const gridOptions = reactive({
  loading:true,
  border:  "full",//表格加边框
  keepSource: true,//保持源数据
  align: 'center',//文字居中
  stripe:true,//斑马纹
  rowConfig: {isCurrent: true, isHover: true,height: 30},//鼠标移动或选择高亮
  id: 'OrderReport',
  showFooter: true,//显示脚
  printConfig: {},
  importConfig: {},
  exportConfig: {},
  scrollY:{ enabled: true },//开启虚拟滚动
  showOverflow:true,
  columnConfig: {
    resizable: true,
    useKey: true
  },
  filterConfig: {   //筛选配置项
    remote: true
  },
  customConfig: {
    storage: true
  },
  editConfig: {
    trigger: 'click',
    mode: 'row',
    showStatus: true
  },//表头参数
  columns:[
 
 
  ],//表头按钮
  toolbarConfig: {
    buttons: [],
    // import: false,
    // export: true,
    // print: true,
    zoom: true,
    custom: true
  },
  data:  [
  ],//table body实际数据
  footerMethod ({ columns, data }) {//页脚函数
    return[
      columns.map((column, columnIndex) => {
        if (columnIndex === 0) {
          return '合计:'
        }
        if (props.childrenData.footList.includes(column.field)) {
          return sumNum(data, column.field)
        }
        return ''
      })
    ]
  }
 
})
 
 
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 => {
    count += Number(item[field])
  })
  return count.toFixed(2)
}
 
 
 
watch(props, (newVal) => {
  xGrid.value.loadData(props.childrenData.data)
  gridOptions.loading = false
})
onMounted(() => {
  gridOptions.columns = props.childrenData.columns
  getReportData()
 
 
})
function filterChanged(column){
  //gridOptions.loading=true
  //筛选条件发生变化条件发生变化
  let value = column.datas[0]!=undefined?column.datas[0]:''
  value = value.trim()
  //判断是否存在外键
  if (column.property.indexOf('.')>-1){
    const  columnArr = column.property.split('.')
    filterData.value[columnArr[0]] = {
      [columnArr[1]]:value
    }
  }else{
    filterData.value[column.property] = value
  }
 
  gridOptions.loading = true
  getReportData()
 
}
 
const handlePageChange = ({ currentPage, pageSize }) => {
  basicProp.value.pageNum = currentPage
  basicProp.value.pageTotal = pageSize
  gridOptions.loading = true
  getReportData()
}
const dateChanged = () => {
  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="basicProp.selectDate"
        type="daterange"
        start-placeholder="开始时间"
        end-placeholder="结束时间"
        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>
    <div class="order-detail">
      <vxe-grid
          @filter-change="filterChanged"
          height="110%"
          class="mytable-scrollbar"
          ref="xGrid"
          v-bind="gridOptions"
      >
        <!--      下拉显示所有信息插槽-->
        <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">
              <input type="type" v-model="option.data" @input="changeFilterEvent($event, option, $panel)"/>
            </div>
          </div>
        </template>
        <template #pager>
          <!--使用 pager 插槽-->
          <!--        'PrevJump','NextJump', -->
          <vxe-pager
              @page-change="handlePageChange"
              :layouts="[  'PrevPage', 'Jump','PageCount', 'NextPage',  'Total']"
              v-model:current-page="basicProp.pageNum"
              v-model:page-size="basicProp.pageSize"
              v-model:pager-count="basicProp.pageTotal"
              :total="basicProp.dataTotal"
          >
          </vxe-pager>
        </template>
      </vxe-grid>
 
    </div>
  </div>
</template>
 
<style scoped >
.main-div {
  width: 100%;
  height: 100%;
}
.el-col{
  border: #181818 1px solid;
}
:deep(.el-table .el-input__wrapper) {
  box-shadow: 0 0 0 0 var(--el-input-border-color, var(--el-border-color)) inset;
  cursor: default;
  border: none !important;
  background-color: transparent;
}
.order-primary{
  width: 100%;
}
.order-detail{
  width: 100%;
  height:  calc(100% - 30px);
 
}
</style>