ZW_MultiSelect/wms-vue/src/components/duochaxun/JianHuoBiaoDan.vue

248 lines
6.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div class="div1">
<div class="div2" style="padding-bottom: 10px">
<el-form ref="form" :model="param" label-width="80px">
<el-button type="success" @click="find"></el-button>
<el-button type="success" @click="down"></el-button>
<el-button type="success" @click="rest"></el-button>&nbsp;&nbsp;
<el-checkbox v-model="checked" @change="Allquesr">是否显示全部查询条件</el-checkbox>
</el-form>
</div>
<el-table
v-loading="this.tableloding"
:height="MaxHeight"
:header-cell-style="{background:'#000',color:'#fff'}"
:span-method="objectSpanMethod"
:data="tableData"
id="educe-table"
ref="tableData"
style="width: 100%;">
<el-table-column v-for="item in columns" :key="item.prop" :prop="item.prop" :label="item.label" :min-width="item.minWidth" />
</el-table>
<el-pagination
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="pageNum"
:page-sizes="[ 50, 100, 200,500]"
:page-size="pageSize"
layout="total, sizes, prev, pager, next, jumper"
:total="total">
</el-pagination>
</div>
</template>
<script>
export default {
data() {
return {
// 表头配置
columns: [
{
prop: 'sapName',
minWidth: '150px',
label: 'SAP类型'
},
{
prop: 'areaName',
minWidth: '150px',
label: '库区'
},
{
prop: 'formattedDate',
minWidth: '150px',
label: 'FormattedDate'
},
{
prop: 'taskCount',
minWidth: '150px',
label: '数量'
}
],
/*columns:[
prop: 'a1',
],*/
tableloding: false,
isShow:false,//是否展示全部搜索条件
tableData: [],
pageSize: 50
,spanArr: [], //每行合并数
pos: 0, //角标索引
pageNum: 1,
total: 3,
param: {
},
loading: false,
checked: false,
}
},
computed:{
MaxHeight(){
return window.innerHeight - 240 +"px";
}
},
mounted: function () {
this.queryUser();
},
updated() {
// 每次更新会重新对 Table 进行重新布局
this.$nextTick(() => {
if (this.$refs.mutipleTable !== undefined) {
this.$refs.mutipleTable.doLayout()
}
})
},
methods: {
// 合并单元格样式,主要是针对要合并列的第一个单元格(有其他需要的可自行更改)
cellStyle({ row, column }) {
// 找到数组中列>1那一个单元格就是需要改变的样式
if (row['mergeData'][column.property] && row['mergeData'][column.property][1] && row['mergeData'][column.property][1] > 1) {
return { 'text-align': 'left' }
} else {
return {}
}
},
objectSpanMethod({ row, column }) {
// 直接返回后端给的对应字段的单元格数据
return row['mergeData'][column.property]
},
handleEdit(index, row) {
console.log(index, row);
},
handleDelete(index, row) {
console.log(index, row);
},
handleSizeChange(val) {
console.log(`每页 ${val}`);
this.pageNum = 1;
this.pageSize = val;
this.queryUser();
},
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.pageNum = val;
this.queryUser();
},
queryUser() {
//列表数据加载
this.$axios.post(this.$httpUrl + '/JianHuoBiaoDan/queryList', {
pageSize: this.pageSize,
pageNum: this.pageNum,
param: this.param,
}).then(res => res.data)
.then(res => {
if (res.code == 200) {
this.tableData = res.data
this.total = res.total
} else {
this.$message.error('获取数据失败');
}
// eslint-disable-next-line no-unused-vars
},err=>{
this.tableloding=false;
})
},
find(){
this.pageNum=1;
this.queryUser();
},
down(){
this.downExcel();
},
downExcel() {
//显示加载图
this.tableloding=true;
//发起请求:/Jianhuojiemian/download请求方式为post类型为 {responseType:'blob'}
//参数和搜索参数一样
this.$axios.post(this.$httpUrl + '/Xuliehaoqingdan/download', {
pageSize: this.pageSize,
pageNum: this.pageNum,
param: this.param,
},{responseType:'blob'}).then(res => {
this.tableloding=false;
//重命名文件
this.downloadFile(res.data,'序列号库存清点'+ '数据', 'xlsx')
});
//列表数据加载
},
downloadFile(obj, name, suffix) {
//解析流文件,进行下载保存
const url = window.URL.createObjectURL(new Blob([obj]))
const link = document.createElement('a')
link.style.display = 'none'
link.href = url
const fileName = this.parseTime(new Date()) + '-' + name + '.' + suffix
link.setAttribute('download', fileName)
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
},
parseTime(time, cFormat) {
//获取当前时间
if (arguments.length === 0) {
return null
}
const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
let date
if (typeof time === 'undefined' || time === null || time === 'null') {
return ''
} else if (typeof time === 'object') {
date = time
} else {
if ((typeof time === 'string') && (/^[0-9]+$/.test(time))) {
time = parseInt(time)
}
if ((typeof time === 'number') && (time.toString().length === 10)) {
time = time * 1000
}
date = new Date(time)
}
const formatObj = {
y: date.getFullYear(),
m: date.getMonth() + 1,
d: date.getDate(),
h: date.getHours(),
i: date.getMinutes(),
s: date.getSeconds(),
a: date.getDay()
}
const time_str = format.replace(/{(y|m|d|h|i|s|a)+}/g, (result, key) => {
let value = formatObj[key]
// Note: getDay() returns 0 on Sunday
if (key === 'a') { return ['日', '一', '二', '三', '四', '五', '六'][value ] }
if (result.length > 0 && value < 10) {
value = '0' + value
}
return value || 0
})
return time_str
},
Allquesr(){
//查询按钮
if(this.checked){
this.isShow=true;
}else {
this.isShow=false;
}
},
rest() {
//条件查询重置
this.checked=false;
this.isShow=false;
this.param={};
}
}
}
</script>
<style scoped>
</style>