123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328 |
- <template>
- <div class="reconciliation">
- <el-card>
- <div style="margin-bottom:20px;">
- <el-select
- v-model="value"
- placeholder="请选择日期类型"
- style="margin-right:10px" clearable>
- <el-option
- v-for="item in RecTime"
- :key="item.value"
- :label="item.label"
- :value="item.value">
- </el-option>
- </el-select>
- <el-date-picker
- v-model="dataRange"
- clearable
- value-format="timestamp"
- format="yyyy-MM-dd"
- placeholder="请选择日期"
- type="date"
- style="width:260px;"
- @focus="hFocusDate"
- :disabled="isDisabled"></el-date-picker>
- <el-button style="margin-left:10px;" type="primary" @click="onSearch" :loading="searchLoading">查询</el-button>
- <el-button style="margin-left:10px;" type="danger" @click="onReset">重置</el-button>
- <el-button style="margin-left:10px;" type="primary" @click="onExportOrder">导出订单</el-button>
- </div>
- <div style="font-size:16px;margin-bottom:10px;">查询结果</div>
- <el-table :data="tableData" border style="width: 100%;font-size:13px;" v-loading="isLoading">
- <el-table-column align="center" prop="count" label="订单总数" />
- <el-table-column align="center" prop="successCount" label="成功订单数" />
- <el-table-column align="center" prop="errorCount" label="失败订单数" />
- <el-table-column align="center" prop="sendCount" label="充值中订单数"></el-table-column>
- <el-table-column align="center" prop="refill_amounts" label="总充值金额"></el-table-column>
- <el-table-column align="center" prop="mch_amounts" label="总扣款金额"></el-table-column>
- </el-table>
- <el-divider />
- <span style="font-size:16px;margin-right:10px;">导出订单记录</span><el-button type="primary" style="margin-bottom:10px;" @click="getExportOrderList">更新状态</el-button>
- <el-table :data="exportOrderList" border style="width: 100%;font-size:13px;" v-loading="isLoading">
- <el-table-column align="center" prop="title" label="记录名称" width="550" />
- <el-table-column align="center" prop="state" label="状态">
- <template slot-scope="scope">
- <el-tag type="info" v-if="scope.row.state == 1">待处理</el-tag>
- <el-tag v-if="scope.row.state == 2">处理中</el-tag>
- <el-tag type="success" v-if="scope.row.state == 3">已处理</el-tag>
- <el-tag type="danger" v-if="scope.row.state == 4">处理错误</el-tag>
- </template>
- </el-table-column>
- <el-table-column align="center" prop="stage" label="进度" />
- <el-table-column align="center" prop="errorCount" label="操作">
- <template slot-scope="scope">
- <el-button size="mini" disabled v-if="scope.row.state != 3">下载</el-button>
- <el-button type="primary" size="mini" v-if="scope.row.state == 3" @click="downloadfile(scope.row.file_path)">下载</el-button>
- </template>
- </el-table-column>
- </el-table>
- <el-row style="margin-top:10px;" type="flex" justify="end">
- <el-pagination background layout="prev, pager, next" :page-count="total" @current-change="onPageChange" :current-page="curpage"></el-pagination>
- </el-row>
-
-
- </el-card>
- </div>
- </template>
- <script>
- // getRec-对账管理
- import { getRec,getExportOrder,getExportOrderList } from '@/api'
- import { RecTime } from '@/utils/constants'
- export default {
- name: 'reconciliation',
- data () {
- return {
- dataRange: '',
- startTime: '',
- endTime: '',
- value: '',
- RecTime,
- recForm: {
- // 订单总数
- count: 0,
- // 成功
- successCount: 0,
- // 失败
- errorCount: 0,
- // 充值中
- sendCount: 0,
- // 总充值金额
- refill_amounts: 0,
- // 扣款金额
- mch_amounts: 0,
- },
- isDisabled: false,
- tableData: [],
- isLoading: false,
- searchLoading: false,
- exportOrderList: [],
- curpage:1,
- total:5
- }
- },
- created() {
- this.getExportOrderList();
- },
- // 监听器
- watch: {
- dataRange(newVal) {
- // console.log(newVal);
- if (newVal == null) {
- this.startTime = '';
- this.endTime = '';
- }
- },
- value: {
- handler(newVal) {
- // console.log('newVal', newVal);
- if (!newVal) {
- this.isDisabled = true
- } else {
- this.isDisabled = false
- }
- },
- immediate: true
- }
- },
- methods: {
- onPageChange(page){
- if(page == this.curpage) return;
- this.curpage = page;
- this.getExportOrderList();
- },
- async getExportOrderList(){
- this.isLoading = true;
- const res = await getExportOrderList(this.curpage);
- this.isLoading = false;
- if(res && res.code == 200) {
- console.log('getExportOrderList',res.datas);
- this.exportOrderList = res.datas.data;
- this.total = res.datas.total;
- }
- else {
- this.$message.warning('获取导出列表失败')
- }
- },
- async onExportOrder(){
- try {
- if (!this.value) {
- if (this.timer) {
- window.clearTimeout(this.timer)
- }
- this.timer = setTimeout(() => {
- this.$message.warning('请选择日期类型')
- }, 1000)
- return
- }
- if(!this.dataRange) {
- this.$message.warning('请选择日期')
- return;
- }
- this.searchLoading = true
- this.isLoading = true
- console.log('this.dataRange',this.dataRange);
- this.startTime = this.dataRange/1000
- this.endTime = (this.dataRange+86400000)/1000
- let param = new URLSearchParams()
- param.append('time_type', this.value)
- param.append('start_time', this.startTime)
- param.append('end_time', this.endTime)
- let res = await getExportOrder(param)
-
- if (res && res.code == 200) {
- console.log('导出订单', res.datas.file_path);
- if(res.datas.file_path) {
- this.downloadfile(res.datas.file_path)
- }
- else{
- this.$message.warning('导出任务生成成功')
- this.curpage = 1;
- this.getExportOrderList();
- }
-
- }
- this.isLoading = false
- this.searchLoading = false
- } catch (error) {
- console.log(error);
- this.isLoading = false
- this.searchLoading = false
- }
- },
- downloadfile(file_path){
- const a = document.createElement('a');
- a.href = file_path;
- a.download = '导出订单';
- a.style.display = 'none';
- document.body.appendChild(a);
- a.click();
- document.body.removeChild(a);
- },
- // 查询
- async onSearch() {
- try {
- if (!this.value) {
- if (this.timer) {
- window.clearTimeout(this.timer)
- }
- this.timer = setTimeout(() => {
- this.$message.warning('请选择日期类型')
- }, 1000)
- return
- }
- if(!this.dataRange) {
- this.$message.warning('请选择日期')
- return;
- }
- this.searchLoading = true
- this.isLoading = true
- this.startTime = this.dataRange/1000
- this.endTime = (this.dataRange+86400000)/1000
- let param = new URLSearchParams()
- param.append('time_type', this.value)
- param.append('start_time', this.startTime)
- param.append('end_time', this.endTime)
- let res = await getRec(param)
- console.log('对账管理', res);
- if (res && res.code == 200) {
- this.recForm = res.datas
- if (!this.tableData.length) {
- this.tableData.push(res.datas)
- } else {
- const obj = this.tableData[0]
- // console.log('obj', obj);
- this.tableData[0] = Object.assign(obj, res.datas)
- }
- }
- this.isLoading = false
- this.searchLoading = false
- } catch (error) {
- console.log(error);
- this.isLoading = false
- this.searchLoading = false
- }
- },
- // 重置
- onReset() {
- this.dataRange = [];
- this.startTime = ''
- this.endTime = ''
- this.value = ''
- this.recForm.count = 0
- this.recForm.successCount = 0
- this.recForm.errorCount = 0
- this.recForm.sendCount = 0
- this.recForm.refill_amounts = 0
- this.recForm.mch_amounts = 0
- this.tableData = []
- },
- // 时间获取焦点
- hFocusDate() {
- if (!this.value) {
- if (this.timer) {
- window.clearTimeout(this.timer)
- }
- this.timer = setTimeout(() => {
- this.$message.warning('请选择日期类型')
- }, 1000)
- }
- }
- }
- }
- </script>
- <style scoped>
- /deep/.el-date-editor .el-range-separator {
- padding: 0;
- width: 20px;/*no */
- }
- /deep/.el-date-editor .el-range-input {
- width: 100px;/*no */
- }
- /deep/.el-form-item {
- margin-bottom: 5px;/*no */
- }
- /deep/.el-card {
- padding-bottom: 0;
- }
- /deep/.el-date-editor .el-range-input {
- width: 100px;/*no */
- }
- /deep/.el-form-item__label {
- text-align: left;
- }
- /deep/.el-table td,
- /deep/.el-table th {
- padding: 7px 0;
- }
- /deep/.el-table .cell,
- /deep/.el-table--border td:first-child .cell,
- /deep/.el-table--border th:first-child .cell {
- padding-left: 7px;
- }
- /deep/.el-table .cell {
- padding-right: 7px;
- }
- </style>
- <style>
- .el-table td, .el-table th.is-leaf,.el-table--border, .el-table--group{
- border-color: #ccc;
- }
- .el-table--border::after, .el-table--group::after, .el-table::before{
- background-color: #ccc;
- }
- .el-table td, .el-table th.is-leaf {
- border-bottom: 1px solid #ccc;
- border-right: 1px solid #ccc;
- }
- .el-table thead {
- color: #606266;
- }
- </style>
|