carDamage.vue 9.72 KB
<!-- 车损升级订单 -->
<template>
  <div class="purchase">
    <div class="container">
      <GLCombiForm ref="showSearch" :rowNumber="1" :formObj="searchForm" :formData="showFormData" @handleOk="handleSearch"
        @handleRest="handleReset"></GLCombiForm>
      <div class="table-header">
        <el-button type="primary" class="btn" size="small" @click="exportExcel">导出</el-button>
      </div>

      <!-- 表格区域 开始 -->
      <GLTable ref="orderRef" :getListApi="getListApi" :noDataImg="url" :searchForm="tableSearchForm"
        :tableParams="tableParams" :pageConf="pageConf" :beforeSearchFn="beforeSearchFn"
        @setTableFinishFun="setTableFinishFun">
        <div class="table-btns" slot="auth-button" slot-scope="scope">
          <el-button type="text"
            v-if="([1, 2, 3, -1, 5].includes(scope.scope.orderStatus) || [2].includes(scope.scope.equityOrderStatus)) && scope.scope.mode != 1"
            @click="handlePrint(scope.scope)">打印</el-button>
          <el-button type="text"
            v-if="[2].includes(scope.scope.equityOrderStatus) && [3, 5].includes(scope.scope.orderStatus)"
            @click="handlePrintContract(scope.scope)">打印合同</el-button>
          <el-button type="text" @click="handleDetail(scope.scope)">详情</el-button>
        </div>
      </GLTable>
      <!-- 表格区域 end -->
    </div>
  </div>
</template>

<script>
import * as dayjs from 'dayjs'
import url from '@/assets/empty.png'
import { Util, downLoadFile } from '@/common/util'
import { manageTypeList } from '@/common/constant.js'
export default {
  name: 'CarDamage',
  components: {},
  data() {
    return {
      sessionInfo: this.$globalState.session,
      size: 'small',
      url: url,
      searchForm: {
        orderStatus: '',
        merchantName: '',
        goodsName: '',
        createTime: ''
      },
      showFormData: [
        {
          label: '客户姓名',
          name: 'customerName',
          type: 'input',
          isClear: true
        },
        {
          label: '服务状态',
          name: 'orderStatus',
          type: 'select',
          optionList: [],
          optionId: 'severType',
          optionLabel: 'severName',
          optionsName: 'severTypeList'
        },
        {
          label: '商户名称',
          name: 'merchantName',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '商品名称',
          name: 'goodsName',
          type: 'input',
          maxlength: '20',
          isClear: true
        },
        {
          label: '车架号',
          name: 'carVin',
          type: 'input',
          isClear: true
        },
        {
          label: '创建时间',
          name: 'createTime',
          type: 'datePicker',
          isClear: true,
          pickerOptions: 'beforeRangePickerOptions'
        }
      ],
      tableSearchForm: {},
      // 表格
      getListApi: this.$apis.order.getQuotationPageApi,
      tableParams: {
        listName: 'list',
        tableOption: true,
        tableColumns: [
          {
            label: '报价单号',
            prop: 'orderId',
            minWidth: '200'
          },
          {
            label: '客户姓名',
            prop: 'customerName',
            width: '200px'
          },
          {
            label: '车架号',
            prop: 'carVin',
            width: '250px'
          },
          {
            label: '保险公司',
            prop: 'insuranceCompany',
            minWidth: 100
          },
          {
            label: '状态',
            prop: 'orderStatus',
            width: '100',
            formatter: cellValue => {
              if (cellValue.orderStatus == 4) {
                return '已支付'
              } else {
                return this.baseData.severTypeList.map(item => item.severType).includes(cellValue.orderStatus) ? this.baseData.severTypeList.find(item => item.severType === cellValue.orderStatus).severName : '-'
              }
            }
          },
          {
            label: '备注',
            prop: 'remark'
          },
          {
            label: '商品名称',
            prop: 'goodsName',
            width: '200px'
          },
          {
            label: '报价金额/元',
            prop: 'quotedPrice',
            width: '200px',
            formatter: cellValue => {
              return cellValue.quotedPrice ? (cellValue.quotedPrice / 100).toFixed(2) : '-'
            }
          },
          {
            label: '预计权益金额/元',
            prop: 'estEquityPrice',
            width: '250px',
            formatter: cellValue => {
              return cellValue.estEquityPrice ? (cellValue.estEquityPrice / 100).toFixed(2) : '-'
            }
          },
          {
            label: '实际权益金额/元',
            prop: 'equityPrice',
            width: '250px',
            formatter: cellValue => {
              return cellValue.equityPrice ? (cellValue.equityPrice / 100).toFixed(2) : '-'
            }
          },
          {
            label: '商户名称',
            prop: 'merchantName',
            minWidth: 150
          }
        ]
      },
      pageConf: { pageSize: 'pageSize', pageNum: 'pageNum', totalCount: 'total' },
      // 基本数据
      baseData: {
        severTypeList: [
          { severName: '待报价', severType: 0 },
          { severName: '待确认', severType: 1 },
          { severName: '待支付', severType: 2 },
          { severName: '已支付', severType: 3 },
          { severName: '战败', severType: -1 },
          { severName: '已完成', severType: 5 }
        ]
      }
    }
  },

  created() { },

  mounted() {
    this.getOptionsList()
  },

  watch: {},

  methods: {
    getParams() {
      var params = Util.deepClone(this.searchForm)
      if (this.searchForm.createTime?.length) {
        params.minCreateTime = Util.dateFormate(this.searchForm.createTime[0], 'YYYY-MM-DD HH:mm:ss')
        params.maxCreateTime = Util.dateFormate(this.searchForm.createTime[1], 'YYYY-MM-DD') + ' 23:59:59'
      }
      delete params.createTime
      return params
    },
    beforeSearchFn() {
      return new Promise(resolve => {
        this.tableSearchForm = this.getParams()
        delete this.tableSearchForm.createTime
        resolve()
      })
    },

    getOptionsList(formName = 'showFormData', hasAll = true, refreshSigle) {
      if (refreshSigle) {
        var item = this[formName].find(k => k.name == refreshSigle)
        var index = this[formName].findIndex(k => k.name == refreshSigle)
        this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
        if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
          const temp = {}
          temp[this[formName][index].optionId] = ''
          temp[this[formName][index].optionLabel] = '全部'
          this[formName][index].optionList.unshift(temp)
        }
      } else {
        this[formName].forEach((item, index) => {
          if (item.type === 'select' && this.baseData[item.optionsName].length) {
            this.$set(this[formName][index], 'optionList', this.$common.utils.deepClone(this.baseData[item.optionsName]))
            if (hasAll && this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this[formName][index].optionLabel] !== '全部') {
              const temp = {}
              temp[this[formName][index].optionId] = ''
              temp[this[formName][index].optionLabel] = '全部'
              this[formName][index].optionList.unshift(temp)
            }
          }
        })
      }
    },

    handleSearch() {
      this.$refs.orderRef.refreshTable()
    },
    handleReset() {
      this.searchForm = {
        orderStatus: '',
        merchantName: '',
        goodsName: '',
        createTime: ''
      }
      this.handleSearch()
    },

    // 查看详情
    handleDetail(row) {
      this.$router.push({
        path: '/orderManage/carDamageDetail',
        query: row
      })
    },

    exportExcel() {
      var params = this.getParams()
      this.$apis.order.quotationExportApi(params).then(res => {
        downLoadFile(res)
      })
    },

    // 打印报价单
    handlePrint(row) {
      this.$apis.order.quotationPrintApi({ id: row.id }).then(res => {
        console.log(res)
        const oWin = window.open(res)
        oWin.document.fn = function () {
          if (oWin) {
            oWin.print()
            oWin.close()
          }
        }
        const html = '<div style="height: 100%;width: 100%;">' + `<img src="${res}" onload="fn()" style="max-height:100%;max-width: 100%;" />` + '</div>'
        oWin.document.open()
        oWin.document.write(html)
        oWin.document.close()
      })
    },

    // 打印权益合同
    handlePrintContract(row) {
      // 获取权益合同PDF
      this.$apis.order.contractExportApi({ orderId: row.orderId }).then(res => {
        window.open(res)
      })
    }
  }
}
</script>

<style scoped lang="scss">
@import '@/assets/css/mixin.scss';

.purchase {
  .table-header {
    display: flex;
    align-items: center;
    margin-bottom: 25px;
    margin-top: 20px;

    h2 {
      font-weight: 600;
      font-size: 16px;
      color: #333;
    }

    .glbtn {
      left: 46px;
      position: absolute;
    }

    .btn {
      right: 47px;
      position: absolute;
    }
  }

  .greenSpot {
    @include dot;
    background: $color-green;
  }

  .yellowSpot {
    @include dot;
    background: $color-yellow;
  }

  .ashSpot {
    @include dot;
    background: $color-gray;
  }

  .table-btns /deep/.el-button--text {
    min-width: 0 !important;
    padding: 0;
  }

  .priceSpan {
    font-size: 14px;
    color: #909399;
  }
}</style>