huangsijun
2025-09-22 a78c011de350b188afb03beb2f26a73f35f71986
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<template>
  <div class="ww100">
    <div class="cash cash_t_common cash_t_brief">
      <div class="common-form">收支记录</div>
      <div class="date_section">
        <div class="mr10">
          <!-- <el-input v-model="searchForm.search" placeholder="请输入商户名称"></el-input> -->
          <el-autocomplete class="inline-input" v-model="searchForm.search" :fetch-suggestions="querySearch"
            placeholder="请输入商户名称"></el-autocomplete>
       </div>
        <div class="block mr10">
          <el-date-picker v-model="searchForm.start_day" type="date" placeholder="开始时间">
          </el-date-picker>
        </div>
        <div class="block mr10">
          <el-date-picker v-model="searchForm.end_day" type="date" placeholder="结束时间">
          </el-date-picker>
        </div>
        <el-button @click="gotoSearch">搜索</el-button>
        <el-button @click="gotoExport">导出</el-button>
      </div>
    <el-tabs v-model="searchForm.flow_type" @tab-click="handleClick">
      <el-tab-pane label="全部" name="0"></el-tab-pane>
      <el-tab-pane label="收入" name="10"></el-tab-pane>
      <el-tab-pane label="支出" name="20"></el-tab-pane>
    </el-tabs>
     <div class="red" style="font-size: 20px; font-weight: bold;" v-if="searchForm.flow_type > 0">总金额:¥{{total_money}}元</div>
      <template>
        <el-table :data="tableData" stripe style="width: 100%;margin: 5px 0;">
          <el-table-column prop="supplier" label="所属商户">
            <template slot-scope="scope">
                <span v-if="scope.row.supplier">{{scope.row.supplier.name}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="money" label="金额(元)"></el-table-column>
          <el-table-column prop="type" label="收支类型">
            <template slot-scope="scope">
                <span v-if="scope.row.flow_type == 10" class="red">收入</span>
                <span v-if="scope.row.flow_type == 20">支出</span>
            </template>
          </el-table-column>
          <el-table-column prop="create_time" label="时间"></el-table-column>
          <el-table-column prop="describe" label="说明"></el-table-column>
        </el-table>
      </template>
      <!--分页-->
      <div class="pagination">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          background
          :current-page="curPage"
          :page-size="pageSize"
          layout="total, prev, pager, next, jumper"
          :total="totalDataNumber"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>
 
<script>
import StatisticsApi from '@/api/statistics.js';
import qs from 'qs';
export default {
  components:{
  },
  data() {
    return {
      /*是否加载完成*/
      loading: true,
      /*一页多少条*/
      pageSize: 15,
      /*一共多少条数据*/
      totalDataNumber: 0,
      /*当前是第几页*/
      curPage: 1,
      tableData: [],
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() > Date.now();
        },
      },
      searchForm:{
        search:'',
        start_day: '',
        end_day: '',
        flow_type:0,
      },
      total_money:'',
      restaurants: [],
      supplier_list: [],
    };
  },
  created() {
     /*获取数据*/
      this.getData();
  },
  methods: {
    /*获取数据*/
    getData() {
      let self = this;
      self.loading = true;
      let Params = self.searchForm;
      Params.page = self.curPage;
      Params.list_rows = self.pageSize;
       StatisticsApi.getSupplierCash(Params, true).then(res => {
          self.tableData = res.data.list.list.data;
          self.totalDataNumber = res.data.list.list.total;
          self.total_money = res.data.list.total_money;
          self.supplier_list = res.data.supplier_list;
          self.loading = false;
        })
        .catch(error => {
          self.loading = false;
        });
    },
    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);
      };
    },
    /*切换菜单*/
    handleClick(tab, event) {
      let self = this;
      self.curPage = 1;
      self.getData();
    },
    /*每页多少条*/
    handleSizeChange(val) {
      this.curPage = 1;
      this.pageSize = val;
      this.getData();
    },
    /*选择第几页*/
    handleCurrentChange(val) {
      this.curPage = val;
      this.getData();
    },
    gotoSearch(){
      this.curPage = 1;
      this.getData();
    },
    gotoExport: function() {
      let baseUrl = window.location.protocol + '//' + window.location.host;
      window.location.href = baseUrl + '/index.php/shop/statistics.supplier/export?' + qs.stringify(this.searchForm);
    }
  }
};
</script>
 
<style lang="scss" scoped>
  .cash_t_common {
    margin-top: 15px;
    margin-bottom: 0;
    box-shadow: initial;
   }
   .cash_t_common .cash_t_title {
      font-size: 16px;
      font-weight: 600;
    }
 
   .cash_t_common .cash-header {
      padding: 10px 20px;
      display: flex;
      justify-content: space-between;
      align-items: center;
    }
 
 
  .cash_t_brief .cash-header {
    border-bottom: 0;
    padding-bottom: 0;
  }
 
  .cash-header {
    position: relative;
    height: 42px;
    line-height: 42px;
    padding: 0 15px;
    border-bottom: 1px solid #f6f6f6;
    color: #333;
    border-radius: 2px 2px 0 0;
    font-size: 14px;
  }
 
  .cash_t_brief .cash_t_title {
    position: relative;
    padding-left: 10px;
  }
 
  .cash_t_brief .cash_t_title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background-color: #3a8ee6;
    position: absolute;
    left: 0;
    top: 50%;
    border-radius: 5px;
    transform: translateY(-50%);
  }
  .date_section {
    display: flex;
    justify-content: flex-end;
    align-items: center;
  }
</style>