95 lines
3.2 KiB
JavaScript
Vendored
95 lines
3.2 KiB
JavaScript
Vendored
require('./../../bootstrap');
|
|
|
|
import Vue from 'vue';
|
|
import DashboardPlugin from './../../plugins/dashboard-plugin';
|
|
import Global from './../../mixins/global';
|
|
import SupplierPayableMaintenance from './supplier-payable-maintenance';
|
|
|
|
import {
|
|
Table, TableColumn, Pagination, DatePicker, Tag, Button, Input, Message
|
|
} from 'element-ui';
|
|
|
|
Vue.use(DashboardPlugin);
|
|
Vue.component(Table.name, Table);
|
|
Vue.component(TableColumn.name, TableColumn);
|
|
Vue.component(Pagination.name, Pagination);
|
|
Vue.component(DatePicker.name, DatePicker);
|
|
Vue.component(Tag.name, Tag);
|
|
Vue.component(Input.name, Input);
|
|
Vue.component(Button.name, Button);
|
|
Vue.prototype.$message = Message;
|
|
|
|
const app = new Vue({
|
|
el: '#sample-deduction-app',
|
|
|
|
mixins: [Global, SupplierPayableMaintenance],
|
|
|
|
data() {
|
|
return {
|
|
maintenanceDataset: 'sample-deductions',
|
|
baseUrl: url + '/workspace-data/supplier-payables/sample-deductions',
|
|
loading: false,
|
|
tableData: [],
|
|
total: 0,
|
|
currentPage: 1,
|
|
pageSize: 25,
|
|
summary: { totalAmount: 0, totalEstimate: 0, totalCount: 0 },
|
|
filters: {
|
|
supplier: '',
|
|
department: '',
|
|
creator: '',
|
|
sku_id: '',
|
|
date_range: null
|
|
}
|
|
};
|
|
},
|
|
|
|
mounted() { this.fetchData(); },
|
|
|
|
methods: {
|
|
fetchData() {
|
|
this.loading = true;
|
|
const params = this.buildParams();
|
|
Promise.all([
|
|
axios.get(this.baseUrl, { params }),
|
|
axios.get(this.baseUrl + '/summary', { params })
|
|
]).then(([listRes, sumRes]) => {
|
|
this.tableData = listRes.data.data || [];
|
|
this.total = listRes.data.total || 0;
|
|
this.currentPage = listRes.data.page || 1;
|
|
this.pageSize = listRes.data.per_page || 25;
|
|
this.summary = sumRes.data;
|
|
}).catch(() => this.$message.error('获取数据失败'))
|
|
.finally(() => { this.loading = false; });
|
|
},
|
|
|
|
buildParams() {
|
|
const params = { page: this.currentPage, limit: this.pageSize };
|
|
['supplier', 'department', 'creator', 'sku_id'].forEach(f => {
|
|
if (this.filters[f]) params[f] = this.filters[f];
|
|
});
|
|
if (this.filters.date_range && this.filters.date_range.length === 2) {
|
|
params.date_from = this.filters.date_range[0];
|
|
params.date_to = this.filters.date_range[1];
|
|
}
|
|
return params;
|
|
},
|
|
|
|
onFilterChange() { this.currentPage = 1; this.fetchData(); },
|
|
onPageChange(p) { this.currentPage = p; this.fetchData(); },
|
|
onPageSizeChange(s) { this.pageSize = s; this.currentPage = 1; this.fetchData(); },
|
|
onReset() {
|
|
this.filters = { supplier: '', department: '', creator: '', sku_id: '', date_range: null };
|
|
this.currentPage = 1;
|
|
this.fetchData();
|
|
},
|
|
|
|
formatMoney(v) {
|
|
if (v == null || isNaN(v)) return '0.00';
|
|
return '¥' + Number(v).toLocaleString('zh-CN', { minimumFractionDigits: 2, maximumFractionDigits: 2 });
|
|
}
|
|
}
|
|
});
|
|
|
|
export default app;
|