| | |
| | | <avue-crud |
| | | :option="option" |
| | | :data="data" |
| | | :page.sync="page1" |
| | | @size-change="sizeChange" |
| | | @current-change="currentChange" |
| | | :page.sync="page" |
| | | :table-loading="loading" |
| | | @row-save="rowSave" |
| | | @search-change="searchChange" |
| | | @search-reset="searchReset" |
| | | @row-update="rowUpdate" |
| | | @row-del="rowDel" |
| | | @refresh-change="refresh" |
| | | ></avue-crud> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import { data, column } from "./data"; |
| | | import { getdata } from "@/api/recruitmentManagement/recruitmentManagement"; |
| | | import { |
| | | getdata, |
| | | adddata, |
| | | update, |
| | | remove, |
| | | } from "@/api/recruitmentManagement/recruitmentManagement"; |
| | | |
| | | export default { |
| | | data() { |
| | | return { |
| | | loading: true, |
| | | Ourdata: "", |
| | | page1: { |
| | | currentPage: 1, |
| | | total: 20, |
| | | layout: "total,pager,prev, next", |
| | | background: false, |
| | | page: { |
| | | pageSize: 10, |
| | | currentPage: 1, |
| | | total: 0, |
| | | }, |
| | | query: {}, |
| | | data: [], |
| | | option: { |
| | | card: true, |
| | |
| | | }; |
| | | }, |
| | | methods: { |
| | | getData(dat) { |
| | | var that = this, |
| | | datas = dat || {}, |
| | | pro = { |
| | | page: that.currentPage, |
| | | size: that.pageSize, |
| | | ...datas, |
| | | }; |
| | | getdata(pro).then((res) => { |
| | | that.data = res.data.data.records; |
| | | console.log(res); |
| | | }); |
| | | // this.page1.total = this.Ourdata.length; |
| | | // var maxi = +this.Ourdata.length / +this.page1.pageSize; |
| | | // var y = String(maxi).indexOf(".") + 1; //判断小数 |
| | | // if (y != 0) { |
| | | // maxi++; |
| | | // } |
| | | // for (var i = 1; i <= maxi; i++) { |
| | | // if (this.page1.currentPage === i) { |
| | | // this.data = this.Ourdata.slice( |
| | | // (i - 1) * this.page1.pageSize, |
| | | // i * this.page1.pageSize |
| | | // ); |
| | | // } |
| | | // } |
| | | }, |
| | | sizeChange(val) { |
| | | this.page1.currentPage = 1; |
| | | this.page1.pageSize = val; |
| | |
| | | }, |
| | | rowSave(form, done, loading) { |
| | | var that = this; |
| | | this.$message.success("模拟网络请求"); |
| | | setTimeout(() => { |
| | | this.$message.success("关闭按钮等待"); |
| | | loading(); |
| | | }, 1000); |
| | | setTimeout(() => { |
| | | this.$message.success("新增数据" + JSON.stringify(form)); |
| | | done(); |
| | | that.Ourdata.push(form); |
| | | this.getData(); |
| | | }, 2000); |
| | | adddata(form).then( |
| | | (res) => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | refresh(val) { |
| | | this.$message.success("刷新回调,当前分页对象" + JSON.stringify(val)); |
| | | searchChange(params, done) { |
| | | this.query = params; |
| | | this.page.currentPage = 1; |
| | | this.onLoad(this.page, params); |
| | | done(); |
| | | }, |
| | | rowDel(form, index) { |
| | | this.$message.success("删除数据" + JSON.stringify(form)); |
| | | searchReset() { |
| | | this.query = {}; |
| | | this.onLoad(this.page); |
| | | }, |
| | | rowUpdate(form, index, done, loading) { |
| | | this.$message.success("模拟网络请求"); |
| | | setTimeout(() => { |
| | | this.$message.success("关闭按钮等待"); |
| | | loading(); |
| | | }, 1000); |
| | | setTimeout(() => { |
| | | this.$message.success( |
| | | "编辑数据" + JSON.stringify(form) + "数据序号" + index |
| | | ); |
| | | done(form); |
| | | }, 2000); |
| | | rowUpdate(row, index, done, loading) { |
| | | console.log(row); |
| | | update(row).then( |
| | | () => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | done(); |
| | | }, |
| | | (error) => { |
| | | window.console.log(error); |
| | | loading(); |
| | | } |
| | | ); |
| | | }, |
| | | rowDel(row) { |
| | | this.$confirm("确定将选择数据删除?", { |
| | | confirmButtonText: "确定", |
| | | cancelButtonText: "取消", |
| | | type: "warning", |
| | | }) |
| | | .then(() => { |
| | | return remove(row.id); |
| | | }) |
| | | .then(() => { |
| | | this.onLoad(this.page); |
| | | this.$message({ |
| | | type: "success", |
| | | message: "操作成功!", |
| | | }); |
| | | }); |
| | | }, |
| | | onLoad(page, params = {}) { |
| | | this.loading = true; |
| | | getdata( |
| | | page.currentPage, |
| | | page.pageSize, |
| | | Object.assign(params, this.query) |
| | | ).then((res) => { |
| | | // console.log(res); |
| | | const data = res.data.data; |
| | | this.page.total = data.total; |
| | | this.data = data.records; |
| | | console.log(this.data); |
| | | this.loading = false; |
| | | }); |
| | | }, |
| | | }, |
| | | mounted() { |
| | | this.Ourdata = data; |
| | | this.getData(); |
| | | // this.Ourdata = data; |
| | | // this.getData(); |
| | | this.onLoad(this.page); |
| | | }, |
| | | }; |
| | | </script> |