This commit is contained in:
杰 朱
2021-10-21 11:52:48 +08:00
parent e65a9ca44a
commit 802b5279d4
3 changed files with 161 additions and 35 deletions

View File

@@ -2,7 +2,15 @@
<div>
<Table border :data="filters" :columns="tableColumnsFilters"></Table>
<Table :show-header="false" border :data="data" :columns="columns"></Table>
<Table
:show-header="false"
border
:data="data"
:columns="columns"
show-summary
show-context-menu
:summary-method="handleSummary"
></Table>
</div>
</template>
@@ -13,6 +21,18 @@ export default {
columns: Array, //列描述数据对象
data: Array //表格数据
},
computed: {
custnanme() {
this.data.forEach(item => {
//console.log(1)
this.data3.push(item.cCusAbbName);
});
this.data3 = this.noRepeat(this.data3);
this.data3 = this.data3.slice(0, 10);
//console.log(this.data3);
return this.data3;
}
},
data() {
return {
filters: [
@@ -20,7 +40,7 @@ export default {
title: ""
}
],
data3:[],
data3: [],
tableColumnsFilters: [],
search: {} //过滤条件保存的对象,就是保存Input框和Select中值
};
@@ -68,10 +88,10 @@ export default {
this.columns[index].filter.type,
{
props: {
value: '', //Select选项列表一般 0 为全部
value: "", //Select选项列表一般 0 为全部
transfer: true,
data :this.data3,
filterMethod:this.filterMethod,
data: this.custnanme,
filterMethod: this.filterMethod
},
on: {
"on-change": val => {
@@ -156,11 +176,8 @@ export default {
load() {
//会执行一个load的事件
this.$emit("on-search", this.search);
this.data.forEach(item => {
//console.log(1)
this.data3.push(item)
});
//console.log(data3)
},
//验证输入框的值
validInputValue(index, inputValue) {
@@ -171,10 +188,62 @@ export default {
}
this.$set(this.search, this.columns[index].key, inputValue);
this.load();
},
noRepeat(arr) {
var hash = [];
for (var i = 0; i < arr.length; i++) {
if (arr.indexOf(arr[i]) == i) {
hash.push(arr[i]);
}
}
return hash;
},
handleSummary({ columns, data }) {
const sums = {};
columns.forEach((column, index) => {
const key = column.key;
if (index === 0) {
sums[key] = {
key,
value: "合计"
};
return;
}
if (index != 7) {
sums[key] = {
key,
value: ""
};
return;
}
const values = data.map(item => Number(item[key]));
if (!values.every(value => isNaN(value))) {
const v = values.reduce((prev, curr) => {
const value = Number(curr);
if (!isNaN(value)) {
return prev + curr;
} else {
return prev;
}
}, 0);
sums[key] = {
key,
value: v
};
} else {
sums[key] = {
key,
value: ""
};
}
});
return sums;
}
}
};
</script>
<style scoped>
<style >
</style>

View File

@@ -109,11 +109,11 @@ export default {
components: { FilterTable },
data() {
return {
PageSizeOpts: [10, 15, 20, 30],
PageSizeOpts: [9999],
pageNo: 1,
strfilter: "",
multiple: false,
pageSize: 15,
pageSize: 9999,
datas: [],
filter: {
inv_codes: "",
@@ -148,7 +148,7 @@ export default {
align: "center",
key: "cCusAbbName",
filter: {
type: "Input"
type: "AutoComplete"
}
},
{
@@ -383,10 +383,48 @@ export default {
//alert("查询条件:" + JSON.stringify(search, null, 4));
//console.log(JSON.stringify(search, null, 4));
console.log(search);
//console.log(search);
if(JSON.stringify(search.cCusAbbName)=="{}")
{
search.cCusAbbName=""
}
if(JSON.stringify(search.cSOCode)=="{}")
{
search.cSOCode=""
}
if(JSON.stringify(search.cInvCode)=="{}")
{
search.cInvCode=""
}
if(JSON.stringify(search.cInvName)=="{}")
{
search.cInvName=""
}
if(JSON.stringify(search.cInvStd)=="{}")
{
console.log(123)
search.cInvStd=""
}
if(JSON.stringify(search.wfiQuantity)=="{}")
{
search.wfiQuantity=""
}
if(JSON.stringify(search.kcyl)=="{}")
{
search.kcyl=""
}
if(JSON.stringify(search.datewaring)=="{}")
{
search.datewaring=""
}
if(JSON.stringify(search.cMemo)=="{}")
{
search.cMemo=""
}
let _filert = {
abc:"123",
c_cus_abb_name: search.cCusAbbName,
d_date: search.dDate,
c_so_code: search.cSOCode,
@@ -489,4 +527,8 @@ a {
body {
padding: 10px 1;
}
.ivu-select-dropdown-transfer{
width: 150px;
}
</style>