writeOffList.vue 5.24 KB
<template>
  <div class="writeOff">
    <GLButton size="small" style="margin-bottom: 10px;" fn="新增核赔" class="el-icon-plus" type="primary" @click="addWriteOff(1)">新增核赔</GLButton>
    <div class="contain equity-wrap">
      <div class="search-wrap">
        <GLCombiForm :rowNumber="1" ref="showSearch" @handleOk="handleSearch" @handleRest="handleReset('reset')" labelWidth="100px" defaultWidth="230px" :formObj="batchListSearch" :formData="writeOffForm"></GLCombiForm>
      </div>
      <el-button size="small" plain style="float:right;margin-bottom:10px;" @click="handleExport" class="selectBtn">导出</el-button>
      <GLTable ref="writeOffTable" :pageSizes="sizeList" :searchForm="searchForm" :tableParams="batchTableParams" :getListApi="getListApi" :pageConf="batchPageConf" :beforeSearchFn="beforeSearchFn">
        <div class="table-btns" slot="table-btns" slot-scope="scope">
          <GLButton fn="查看" type="text" @click="handleView(scope.scope)">查看</GLButton>
        </div>
      </GLTable>
    </div>
  </div>
</template>

<script type="text/ecmascript-6">
import util from '@/util/util'
export default {
  name: 'writeOffList',
  data() {
    return {
       sizeList: [5, 10, 20, 30, 40],
      getListApi: this.$apis.beforeSale.getWriteOffList,
      batchListSearch: {
        searchText: '',
        activeTime: []
      },
      searchForm: {},
      writeOffForm: [
        {
          label: '搜索内容',
          name: 'searchText',
          type: 'input',
          placeholder: '请输入车主姓名、核销码、合同号',
          isClear: true
        },
        {
          label: '提交时间',
          name: 'activeTime',
          type: 'datePicker',
          valueFormat: 'yyyy-MM-dd',
          pickerOptions: 'beforeRangePickerOptions',
          isClear: true
        }
      ],
      // 序号、核销码、客户名、合同号、价格区间、门店提交时间、服务名称、操作
      batchTableParams: {
        listName: 'list',
        tableOption: false,
        tableColumns: [
          {
            label: '核销码',
            prop: 'writeOffCode',
            formatter: cellValue => {
              return cellValue.writeOffCode || '-'
            }
          },
          {
            label: '客户名',
            prop: 'reporterName',
            formatter: cellValue => {
              return cellValue.reporterName || '-'
            }
          },
          {
            label: '合同号',
            prop: 'contractNo',
            formatter: cellValue => {
              return cellValue.contractNo || '-'
            }
          },
          {
            label: '价格区间',
            prop: 'priceSection',
            formatter: cellValue => {
              return cellValue.priceSection || '-'
            }
          },
          {
            label: '门店提交时间',
            prop: 'commitTime',
            formatter: cellValue => {
              return cellValue.commitTime ? util.dateFormat(cellValue.commitTime, 'YYYY-MM-DD HH:mm:ss') : '-'
            }
          },
          {
            label: '服务名称',
            prop: 'serviceName',
            formatter: cellValue => {
              return cellValue.serviceName || '-'
            }
          },
          {
            label: '操作',
            prop: '',
            width: '70px',
            fixed: 'right',
            addHtml: 'table-btns'
          }
        ]
      },
      batchPageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' }
    }
  },
  mounted() {},
  methods: {
    handleView({ writeOffCode }) {
      this.$router.push(`/ghPreSale/writeOff/writeOffDetail/${writeOffCode}`)
    },
    beforeSearchFn() {
      return new Promise((resolve, reject) => {
        this.searchForm = { ...this.setParams() }
        resolve()
      })
    },
    setParams() {
      const params = {}
      if (Array.isArray(this.batchListSearch.activeTime) && this.batchListSearch.activeTime.length > 0) {
        params.commitTimeStart = util.dateFormat(this.batchListSearch.activeTime[0]) + ' 00:00:00'
        params.commitTimeEnd = util.dateFormat(this.batchListSearch.activeTime[1]) + ' 23:59:59'
      }
      params.searchText = this.batchListSearch.searchText
      return params
    },
    handleExport() {
      const parmas = { ...this.setParams() }
      this.$apis.beforeSale.exportWriteOffData(parmas).then(({ code, data, message }) => {
        if (code == '0') {
          var a = document.createElement('a')
          a.setAttribute('id', 'exportToExport')
          a.setAttribute('href', data)
          a.setAttribute('target', '_blank')
          document.body.appendChild(a)
          a.click()
        } else {
          this.$message.error(message)
        }
      })
    },
    handleSearch() {
      this.$refs.writeOffTable.refreshTable()
    },
    handleReset(type) {
      this.batchListSearch = {
        searchText: '',
        activeTime: []
      }
      if (type === 'reset') {
        this.handleSearch()
      }
    },
    addWriteOff(type) {
      this.$router.push('/ghPreSale/writeOff/addwriteOff')
    }
  }
}
</script>
<style lang="scss" scoped>
.writeOff {
  .equity-wrap {
    background-color: #fff;
    padding: 20px;
    .search-wrap {
      // padding: 20px 20px 0;
    }
  }
}
</style>