Commit dea0531f authored by WBY1026's avatar WBY1026

修正

parent 222aded9
......@@ -92,5 +92,17 @@ export function getListTotal(data) {
data: data
})
}
// export function testPost(data) {
// return request({
// method: 'post',
// url: '/mixSelect/postTest',
// headers: {
// 'Content-Type': 'application/json'
// },
// data: {
// name: '123'
// }
// })
// }
......@@ -19,8 +19,8 @@
:trigger-on-focus="false" @select="handleSelect"></el-autocomplete> -->
<!-- ddd是3k,这里换成搜索 -->
<el-autocomplete class="inline-input" v-model="inputddd" :fetch-suggestions="querySearch" placeholder="搜索ccc"
@select="handleSelect"></el-autocomplete>
<!-- <el-autocomplete class="inline-input" v-model="inputddd" :fetch-suggestions="querySearch" placeholder="搜索ccc"
:trigger-on-focus="false" @select="handleSelect"></el-autocomplete> -->
<el-select v-model="mycccc" multiple collapse-tags style="margin-left: 20px;" placeholder="请选择cccc">
<el-option v-for="item in cccc" :key="item.cccc" :label="item.cccc" :value="item.cccc">
......@@ -225,113 +225,294 @@ export default {
// 搜索
searchToGetInfo() {
this.loading = true
listDemoData1(this.queryParams).then(
response => {
console.log('数据源', response)
this.demoData1List = response.rows
this.formatData(response.rows)
this.total = response.total
this.loading = false
// console.log(this.myCheckBox);
let temp = this.myCheckBox
if (temp.indexOf('fff') == -1) {
this.fff = false
} else {
this.fff = true
}
if (temp.indexOf('ggg') == -1) {
this.ggg = false
} else {
this.ggg = true
}
if (temp.indexOf('hhh') == -1) {
this.hhh = false
} else {
this.hhh = true
}
if (temp.indexOf('iii') == -1) {
this.iii = false
} else {
this.iii = true
}
if (temp.indexOf('jjj') == -1) {
this.jjj = false
} else {
this.jjj = true
}
if (temp.indexOf('kkk') == -1) {
this.kkk = false
} else {
this.kkk = true
}
const data = {
aaa: this.myaaa,
bbb: this.mybbb,
cccc: this.mycccc,
ddd: this.myddd,
dddd: this.mydddd,
eee: this.myeee,
fff: this.fff,
ggg: this.ggg,
hhh: this.hhh,
iii: this.iii,
jjj: this.jjj,
kkk: this.kkk,
pageSize: this.pageSize,
pageNo: this.currentPage
}
getListTotal(data).then(res => {
this.totalPage = res.data
})
searchTableList(data).then(res => {
console.log(res);
this.mytableList = res.data
// 判断返回的数据,然后调用渲染方法
if (this.myCheckBox.length <= 1) {
this.getDateType1()
} else if (this.myCheckBox.length == 2) {
this.getDateType2()
} else {
this.getDateType3()
}
)
this.loading = false
console.log('数据源', this.demoData1List)
});
},
formatData(data) {
// 遍历数据,提取不重复的月份作为列标签 111
const months = new Set()
data.forEach(item => {
Object.keys(item).forEach(key => {
if (key !== 'ccc' && key !== '__row_number__') {
months.add(key)
}
})
})
console.log('months是:', months)
// 将 Set 对象转换为数组
const sortedMonths = Array.from(months)
// 对数组进行排序
sortedMonths.sort()
console.log('排序后的值:', sortedMonths)
this.dynamicColumns = sortedMonths
console.log('绑定的值', this.dynamicColumns)
handleSizeChange(val) {
console.log(`每页 ${val} 条`);
this.pageSize = val
this.searchToGetInfo()
},
// 取消按钮
cancel() {
this.open = false
this.reset()
handleCurrentChange(val) {
console.log(`当前页: ${val}`);
this.currentPage = val
this.searchToGetInfo()
},
// 表单重置
reset() {
this.form = {
businessId: undefined,
ggg: undefined,
dddd: undefined,
mmm: undefined,
jjj: undefined,
iii: undefined,
lll: undefined,
ccc: undefined,
bbb: undefined,
cccc: undefined,
fff: undefined,
aaa: undefined,
ddd: undefined,
kkk: undefined,
eee: undefined,
hhh: undefined,
flag: '1'
}
this.resetForm('form')
resetForm() {
this.myCheckBox = ['fff'],
this.myaaa = []
this.mybbb = []
this.mycccc = []
this.myddd = []
this.mydddd = []
this.myeee = []
this.fff = true
this.ggg = false
this.hhh = false
this.iii = false
this.jjj = false
this.kkk = false
this.pageSize = 30
this.currentPage = 1
this.searchToGetInfo()
},
test() {
console.log(this.ddd);
},
/** 查询按钮操作 */
handleQuery() {
// this.queryParams.page = 1
this.getList()
// 匹配方法 ======
querySearch(queryString, cb) {
var restaurants = this.ddd;
var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
console.log(results);
// 调用 callback 返回建议列表的数据
cb(results);
},
/** 重置按钮操作 */
resetQuery() {
this.queryParams = {
page: 1,
rows: 100,
ggg: undefined,
dddd: undefined,
mmm: undefined,
jjj: undefined,
iii: undefined,
lll: undefined,
ccc: undefined,
bbb: undefined,
cccc: undefined,
fff: undefined,
aaa: undefined,
ddd: undefined,
kkk: undefined,
eee: undefined,
hhh: undefined
}
this.handleQuery()
createFilter(queryString) {
return (restaurant) => {
return (restaurant.ddd.indexOf(queryString) == 0);
};
},
// ===============
handleSelect(e){
console.log(e);
},
// ==================================================
// 勾选一个参数的方法
getDateType1() {
let dateTypeName = [];
this.dateColData = [];
this.mytableList.forEach(item => {
item.data.forEach(citem => {
// 找到这一项的month,判断目前有没有保存过
const index = dateTypeName.findIndex(
i => i.aaa == citem.aaa
)
// 没保存过就存进去
if (index == -1) {
dateTypeName.push(citem)
}
})
});
console.log(dateTypeName, "一级表头");
// 添加表头数据
// 遍历dateTypeName
dateTypeName.forEach((item, index) => {
// 根据dateType每一个在最后需要的表头数据里面push二级表头
this.dateColData.push({
label: item.aaa,
children: [
{
prop: Object.keys(item)[1] + index,
label: null
}
]
})
})
// 遍历传来的数据
this.mytableList.forEach(data => {
data.data.forEach(item => {
dateTypeName.forEach((citem, cindex) => {
if (item.aaa == citem.aaa) {
let a = Object.keys(item)[1]
data[Object.keys(item)[1] + cindex] = item[a]
}
})
})
})
console.log(this.mytableList, "this.mytableList");
},
/** 导出按钮操作 */
handleExport() {
const queryParams = this.queryParams
this.$confirm('是否确认操作?', '警告', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(function() {
return exportIncomeWmsBox(queryParams).then(response => {
const blob = new Blob([response])
const downloadElement = document.createElement('a')
const href = window.URL.createObjectURL(blob)// 创建下载的链接
downloadElement.href = href
downloadElement.download = '库存管理信息' + '.xls' // 下载后文件名
document.body.appendChild(downloadElement)
downloadElement.click()// 点击下载
document.body.removeChild(downloadElement)// 下载完成移除元素
window.URL.revokeObjectURL(href)// 释放掉blob对象
getDateType2() {
let dateTypeName = [];
this.dateColData = [];
this.mytableList.forEach(item => {
item.data.forEach(citem => {
// 找到这一项的month,判断目前有没有保存过
const index = dateTypeName.findIndex(
i => i.aaa == citem.aaa
)
// 没保存过就存进去
if (index == -1) {
dateTypeName.push(citem)
}
})
});
console.log(dateTypeName, "一级表头");
// 添加表头数据
// 遍历dateTypeName
dateTypeName.forEach((item, index) => {
// 根据dateType每一个在最后需要的表头数据里面push二级表头
this.dateColData.push({
label: item.aaa,
children: [
{
prop: Object.keys(item)[1] + index,
label: Object.keys(item)[1] + "的值"
},
{
prop: Object.keys(item)[2] + index,
label: Object.keys(item)[2] + "的值"
}
]
})
})
// 遍历传来的数据
this.mytableList.forEach(data => {
data.data.forEach(item => {
dateTypeName.forEach((citem, cindex) => {
if (item.aaa == citem.aaa) {
let a = Object.keys(item)[1]
let b = Object.keys(item)[2]
data[Object.keys(item)[1] + cindex] = item[a]
data[Object.keys(item)[2] + cindex] = item[b]
}
})
})
})
console.log(this.mytableList, "this.mytableList");
},
getDateType3() {
let dateTypeName = [];
this.dateColData = [];
this.mytableList.forEach(item => {
item.data.forEach(citem => {
// 找到这一项的month,判断目前有没有保存过
const index = dateTypeName.findIndex(
i => i.aaa == citem.aaa
)
// 没保存过就存进去
if (index == -1) {
dateTypeName.push(citem)
}
})
});
console.log(dateTypeName, "一级表头");
// 添加表头数据
// 遍历dateTypeName
dateTypeName.forEach((item, index) => {
// 根据dateType每一个在最后需要的表头数据里面push二级表头
this.dateColData.push({
label: item.aaa,
children: [
{
prop: Object.keys(item)[1] + index,
label: Object.keys(item)[1] + "的值"
},
{
prop: Object.keys(item)[2] + index,
label: Object.keys(item)[2] + "的值"
},
{
prop: Object.keys(item)[3] + index,
label: Object.keys(item)[3] + "的值"
}
]
})
})
// 遍历传来的数据
this.mytableList.forEach(data => {
data.data.forEach(item => {
dateTypeName.forEach((citem, cindex) => {
if (item.aaa == citem.aaa) {
let a = Object.keys(item)[1]
let b = Object.keys(item)[2]
let c = Object.keys(item)[3]
data[Object.keys(item)[1] + cindex] = item[a]
data[Object.keys(item)[2] + cindex] = item[b]
data[Object.keys(item)[3] + cindex] = item[c]
}
})
})
})
console.log(this.mytableList, "this.mytableList");
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment