<template>
|
<div v-loading="loading" style="min-height: 400px;">
|
<el-form size="small" :inline="true" :model="searchForm" class="demo-form-inline">
|
<el-form-item label="商家名称">
|
<el-autocomplete class="inline-input" v-model="searchForm.supplier_name" :fetch-suggestions="querySearch"
|
placeholder="请输入商户名称"></el-autocomplete>
|
</el-form-item>
|
<el-form-item><el-button size="small" type="primary" icon="el-icon-search" @click="onSubmit">查询</el-button></el-form-item>
|
</el-form>
|
<!--汇总-->
|
<Total v-if="!loading"></Total>
|
<!--交易统计-->
|
<Transaction v-if="!loading"></Transaction>
|
<!--商品统计-->
|
<Product v-if="!loading"></Product>
|
</div>
|
</template>
|
|
<script>
|
import StatisticsApi from '@/api/statistics.js';
|
import Total from './part/Total.vue'
|
import Transaction from './part/Transaction.vue'
|
import Product from './part/Product.vue'
|
export default{
|
components:{
|
Total,
|
Transaction,
|
Product
|
},
|
data(){
|
return{
|
/*是否正在加载*/
|
loading:true,
|
/*数据对象*/
|
dataModel:{},
|
restaurants: [],
|
supplier_list:[],
|
/*横向表单数据模型*/
|
searchForm: {
|
supplier_name:''
|
},
|
}
|
},
|
provide: function () {
|
return {
|
dataModel: this.dataModel,
|
supplier_id: this.$route.query.supplier_id
|
}
|
},
|
created() {
|
if(this.$route.query.supplier_name){
|
this.searchForm.supplier_name =this.$route.query.supplier_name;
|
}
|
this.getData();
|
},
|
methods:{
|
|
/*获取数据*/
|
getData() {
|
let self = this;
|
StatisticsApi.getOrderTotal({
|
shop_supplier_id:this.$route.query.supplier_id
|
}, true)
|
.then(res => {
|
Object.assign(self.dataModel, res.data);
|
self.supplier_list = res.data.supplier_list;
|
self.loading = false;
|
})
|
.catch(error => {});
|
},
|
querySearch(queryString, cb) {
|
let self = this;
|
if (self.restaurants.length == 0) {
|
self.supplier_list.forEach((item, index) => {
|
self.restaurants.push({
|
value: item.name
|
})
|
})
|
}
|
var restaurants = this.restaurants;
|
var results = queryString ? restaurants.filter(this.createFilter(queryString)) : restaurants;
|
// 调用 callback 返回建议列表的数据
|
cb(results);
|
},
|
createFilter(queryString) {
|
return (restaurant) => {
|
return (restaurant.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0);
|
};
|
},
|
/*搜索查询*/
|
onSubmit() {
|
let self = this;
|
var supplier_id = 0;
|
self.supplier_list.forEach((item, index) => {
|
if(item.name == self.searchForm.supplier_name){
|
supplier_id = item.shop_supplier_id;
|
}
|
})
|
if(supplier_id == 0){
|
this.$message.error('该商户不存在');
|
return;
|
}
|
self.$router.push({
|
path: '/statistics/sales/index',
|
query: {
|
supplier_id: supplier_id,
|
supplier_name: self.searchForm.supplier_name
|
}
|
});
|
window.location.reload();
|
// self.getData();
|
},
|
|
}
|
}
|
</script>
|
|
<style>
|
</style>
|