freight-list.vue 8.04 KB
<template>
  <div>
    <layout-body>
      <p slot="title">交易服务明细</p>
      <layout-filter ref="filter" :model="filters" class="box-filter" :inline="true" :col="1">
        <filter-item label="起止时间">
          <Date-picker
            v-model="filters.createTime.model"
            type="datetimerange"
            format="yyyy-MM-dd"
            placeholder="选择日期和时间"
            @on-change="createTimeChange"
          ></Date-picker>
          <div class="quick">
            <a
              href="javascript:;"
              @click="
                () => {
                  timeFlag(1);
                }
              "
              >今天</a
            >
            <a
              href="javascript:;"
              @click="
                () => {
                  timeFlag(2);
                }
              "
              >昨天</a
            >
            <a
              href="javascript:;"
              @click="
                () => {
                  timeFlag(3);
                }
              "
              >最近7天</a
            >
            <a
              href="javascript:;"
              @click="
                () => {
                  timeFlag(4);
                }
              "
              >最近30天</a
            >
          </div>
          <!--          <div class="select-container">-->
          <!--            <Input v-model.trim="filters.targetAccount.model" :placeholder="filters.targetAccount.label" />-->
          <!--          </div>-->
        </filter-item>
        <filter-item>
          <div class="select-container">
            <Input v-model.trim="filters.orderCode.model" :placeholder="filters.orderCode.label" />
          </div>
          <!--          <div class="select-container">-->
          <!--            <Select v-model.trim="filters.clearingType.model" :placeholder="filters.clearingType.label">-->
          <!--              <Option v-for="option in filters.clearingType.options" :key="option.value" :value="option.value">{{-->
          <!--                option.label-->
          <!--              }}</Option>-->
          <!--            </Select>-->
          <!--          </div>-->
          <!--          <div class="select-container">-->
          <!--            <Select v-model.trim="filters.subClearingType.model" :placeholder="filters.subClearingType.label">-->
          <!--              <Option v-for="option in filters.subClearingType.options" :key="option.value" :value="option.value">{{-->
          <!--                option.label-->
          <!--              }}</Option>-->
          <!--            </Select>-->
          <!--          </div>-->
          <div class="select-container">
            <Select v-model.trim="filters.status.model" :placeholder="filters.status.label" clearable>
              <Option v-for="option in filters.status.options" :key="option.value" :value="option.value">{{
                option.label
              }}</Option>
            </Select>
          </div>
          <div class="select-container">
            <Button type="primary" @click="search">查询</Button>
            <Button type="primary" @click="reset">全部</Button>
            <Button type="warning" @click="exportList">导出</Button>
          </div>
        </filter-item>
      </layout-filter>
      <layout-list>
        <Table border :columns="tableCols" :data="tableData"></Table>
        <Page
          :total="pageData.total"
          :current="pageData.current"
          :page-size="pageData.pageSize"
          show-total
          @on-change="pageChange"
        ></Page>
      </layout-list>
    </layout-body>
  </div>
</template>

<script>
import _ from 'lodash';
import moment from 'moment';
import { FreightApply } from './store';
import FinanceService from 'services/finance/finance-service';
import baseExportApi from 'util/excel';
import qs from 'querystringify';

export default {
  data() {
    return FreightApply.call(this);
  },
  created() {
    this.financeService = new FinanceService();
    this.search();
  },
  methods: {
    filterValues() {
      const values = {
        pageNo: 1,
        pageSize: 10,
      };
      const fields = this.filters;
      const keysMap = {
        beginTime: 'beginTime',
        endTime: 'endTime',
        timeFlag: 'timeFlag',
        targetAccount: 'targetAccount',
        orderCode: 'orderCode',
        clearingType: 'clearingType',
        subClearingType: 'subClearingType',
        status: 'status',
      };
      _.each(keysMap, (val, key) => {
        values[key] = fields[val].model;
      });
      return values;
    },
    search() {
      let params = {};
      this.filters.timeFlag.model = '';
      params = this.filterValues();
      this.list(params);
      this.pageData.current = 1;
    },
    reset() {
      let params = {};
      _.each(this.filters, value => {
        if (value.hasOwnProperty('model')) {
          value.model = '';
        }
      });
      params = this.filterValues();
      this.list(params);
      this.pageData.current = 1;
    },
    timeFlag(flag) {
      let params = {};
      this.filters.timeFlag.model = flag;
      params = this.filterValues();
      this.list(params);
      this.pageData.current = 1;
    },
    createTimeChange(time) {
      if (!_.isArray(time)) {
        time = time.split(' - ');
      }
      if ((time[0] + '').length) {
        this.filters.beginTime.model = moment(time[0]).format('YYYY-MM-DD');
        this.filters.endTime.model = moment(time[1]).format('YYYY-MM-DD');
      } else {
        this.filters.beginTime.model = '';
        this.filters.endTime.model = '';
      }
    },
    pageChange(page) {
      const params = this.filterValues();
      params.pageNo = page;
      this.pageData.current = page;
      this.list(params);
    },
    list(params) {
      this.financeService.shopWithdrawFreightList(params).then(ret => {
        this.tableData = _.get(ret, 'data.records', []);
        this.pageData.total = _.get(ret, 'data.totalCount', 0);
        this.pageData.current = _.get(ret, 'data.pageNo', 1);
      });
    },
    getDetailById(id) {
      this.$router.push({
        name: 'finance.withdraw.freight-detail',
        params: {
          id,
        },
      });
    },
    exportList() {
      const queryString = { ...this.filterValues(), excelConf: 'shopFreightList' };
      const params = qs.stringify(queryString, true);
      const href = `${baseExportApi}${params}`;
      window.open(href, '_blank');
    },
  },
};
</script>

<style lang="scss">
.layout-container {
  min-height: 200px;
  margin: 15px;
  overflow: hidden;
  background: #fff;
  border-radius: 4px;

  .layout-filter .line {
    border-top: none;
    margin-bottom: 0;
  }
}

.shop-card {
  margin-top: 10px;
  margin-bottom: 10px;
}

.box-title {
  font-weight: 700;
  color: #495060;
  font-size: 16px;
  line-height: 22px;
  margin: 5px;

  &:before {
    content: ' ';
    display: inline-block;
    width: 5px;
    margin-right: 2px;
    height: 22px;
    vertical-align: top;
    background-color: #999;
  }
}

.box-item {
  width: 90%;
  height: 50px;
  padding: 0 0 0 15px;
  line-height: 50px;
  font-size: 14px;
  overflow: hidden;
  border-radius: 5px;
  color: #fff;
  margin-bottom: 10px;

  .box-item-label {
    display: inline-block;
    min-width: 75px;
    vertical-align: top;
    font-weight: normal;
  }

  .box-item-value {
    font-size: 20px;
    font-weight: 600;
  }

  i {
    display: inline-block;
    width: 20px;
    height: 20px;
    font-size: 22px;
    text-align: center;
    margin-top: -7px;
    vertical-align: middle;
    margin-right: 3px;
  }
}

.box-filter {
  .ivu-date-picker {
    margin-left: 0;
    width: 220px !important;
  }

  .quick {
    display: inline-block;
    margin-left: 20px;
    margin-right: 50px;

    a {
      margin-right: 5px;
    }
  }

  .select-container {
    display: inline-block;
    width: 200px;
    margin-right: 15px;
    margin-top: 5px;
  }
}

.ivu-table-cell {
  padding-left: 6px;
  padding-right: 6px;
}

.action-column {
  .cell-action-row {
    margin-top: 10px;

    &:last-child {
      margin-bottom: 10px;
    }
  }
}
</style>