diff --git a/config/dev.env.js b/config/dev.env.js index 3f243df..c37ffea 100644 --- a/config/dev.env.js +++ b/config/dev.env.js @@ -5,9 +5,9 @@ const testEnv = require('./test.env') module.exports = merge(prodEnv, testEnv, { NODE_ENV: '"development"', - BASE_API: '"http://localhost:8000"', - NAME: '"开发"' + //BASE_API: '"http://localhost:8000"', + NAME: '"开发"', // BASE_API: '"http://139.224.54.200:8888"' // BASE_API: '"https://api.auauz.net"' - //BASE_API: '"http://139.224.57.82:8015"' + BASE_API: '"http://139.224.57.82:8015"' }) diff --git a/src/mixins/initData2.js b/src/mixins/initData2.js new file mode 100644 index 0000000..a499232 --- /dev/null +++ b/src/mixins/initData2.js @@ -0,0 +1,110 @@ +import { initData } from '@/api/data' + +export default { + data() { + return { + loading: true, data: [], page: 0, size: 10, total: 0, url: '', params: {}, query: {}, time: 50, isAdd: false, downloadLoading: false + } + }, + methods: { + async init(val) { + + if (!await this.beforeInit()) { + return + } + if (val==1){ + this.params.xfProjectnum="" + this.params.xfStartDate="" + } + let params = {} + if(this.url == "api/xySalary"){ + params = {...this.params,sort:'salaryMonth,desc'} + }else{ + params = {...this.params} + } + return new Promise((resolve, reject) => { + this.loading = true + + initData(this.url, params).then(res => { + this.total = res.totalElements + this.data = res.content + setTimeout(() => { + this.loading = false + }, this.time) + resolve(res) + }).catch(err => { + this.loading = false + reject(err) + }) + }) + }, + async init2(val) { + + this.params.page = this.page + if (val==1){ + this.params.xfProjectnum="" + this.params.xfStartDate="" + } + let params = {} + if(this.url == "api/xySalary"){ + params = {...this.params,sort:'salaryMonth,desc'} + }else{ + params = {...this.params} + } + return new Promise((resolve, reject) => { + this.loading = true + + initData(this.url, params).then(res => { + this.total = res.totalElements + this.data = res.content + setTimeout(() => { + this.loading = false + }, this.time) + resolve(res) + }).catch(err => { + this.loading = false + reject(err) + }) + }) + }, + beforeInit() { + return true + }, + pageChange(e) { + + this.page = e - 1 + + if(this.url=='api/douyinAfterSales'){ + this.init() + } + else{ + this.init2() + } + + }, + sizeChange(e) { + this.page = 0 + this.size = e + if(this.url=='api/douyinAfterSales'){ + this.init(1) + } + else{ + this.init2(1) + } + }, + // 预防删除第二页最后一条数据时,或者多选删除第二页的数据时,页码错误导致请求无数据 + dleChangePage(size) { + if (size === undefined) { + size = 1 + } + if (this.data.length === size && this.page !== 0) { + this.page = this.page - 1 + } + }, + toQuery(val) { + + this.page = 0 + this.init(val) + } + } +} diff --git a/src/views/douyin/after_sale/index.vue b/src/views/douyin/after_sale/index.vue index 872f1d3..7f9a7f4 100644 --- a/src/views/douyin/after_sale/index.vue +++ b/src/views/douyin/after_sale/index.vue @@ -257,7 +257,7 @@