<script>
import { Getzhuanli } from "@/api/api.js";
export default {
data() {
return {
queryInfo: {
query: "",
pagenum: 1,
pagesize: 10,
},
total: 0,
data: [],
dialogVisible: false,
form: {},
};
},
created() {
this.getPractical();
},
methods: {
getPractical() {
Getzhuanli({ type: "发明专利" })
.then((res) => {
this.getList(res);
})
.catch((error) => {
this.$message.error(error);
});
},
getList(res) {
// es6过滤得到满足搜索条件的展示数据list
let list = res.filter(
(item, index) =>
item.ApplicationID.includes(this.queryInfo.query) ||
item.Name.includes(this.queryInfo.query) ||
item.Type.includes(this.queryInfo.query) ||
item.Designer.includes(this.queryInfo.query)
);
console.log(list);
this.data = list.filter(
(item, index) =>
index < this.queryInfo.pagenum * this.queryInfo.pagesize &&
index >= this.queryInfo.pagesize * (this.queryInfo.pagenum - 1)
);
this.total = list.length;
},
// 搜索过滤数据
search() {
this.queryInfo.pagenum = 1;
this.getList();
},
handleSizeChange(newSize) {
this.queryInfo.pagesize = newSize;
this.queryInfo.pagenum = 1;
this.getList();
},
handleCurrentChange(newPage) {
this.queryInfo.pagenum = newPage;
this.getList();
},
open(row) {
this.form = row;
this.dialogVisible = true;
},
},
};
</script>
网上搜的都是data要有返回值,但是我写了呀。