serviceOfflineList.vue 8.97 KB
<!-- 服务商 - 我的分账 - 线下对账 -->
<template>
  <div class="my-off-account">
    <div class="d2-container-content"
         style="padding: 10px 20px;">
      <d2-search ref="showSearch"
                 class="show-search"
                 :search-form="searchForm"
                 :search-select-obj="searchSelectObj"
                 :form-data="showFormData" />
      <div class="up-btns">
        <el-button :id="tableParams.btnId"
                   size="small"
                   type="primary">
          查询
        </el-button>
        <el-button size="small"
                   @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header :left-span="22">
        <span slot="left">共<span class="count-txt">{{ countObj.orderCount }}</span>笔订单,累计线下分账金额<span
          class="count-txt">{{ countObj.divisionMoneyCount }}</span>元。</span>
        <el-button type="primary"
                   size="mini"
                   @click="handleExport">
          导出
        </el-button>
      </d2-table-header>
      <d2-table ref="merchantTable"
                :get-list-api="getListApi"
                :search-form="searchFormSearch"
                :table-params="tableParams"
                :before-search-fn="beforeSearchFn" />
    </div>
  </div>
</template>

<script>
import { mapActions, mapState } from 'vuex'
import { Util, deepClone } from '@/common/util'
// import { divisionTypeList } from '@/common/constants.js'
// getSeviceCountApi, getSeviceListApi, exportSeviceApi,getSeviceExport
import { getPartnerYqListApi, getSeviceList, getSeviceCount } from '@/api/account'
// import { asyncExportExcel } from '@api/sys.base'
export default {
  name: 'ServiceOfflineList',
  data() {
    return {
      countObj: {},
      searchForm: {
        // 线下
        divisionType: '1',
        merchantFlag: '2',
        successDate: '',
        yqMerchantId: '',
        divisionStatus: ''
      },
      searchFormSearch: {},
      searchSelectObj: {
        orderOrTrade: {
          attr: 'orderCode',
          value: ''
        }
      },
      showFormData: [{
        label: '支付时间',
        name: 'successDate',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '园区店',
        name: 'yqMerchantId',
        type: 'select',
        optionList: [],
        optionId: 'yqMerchantId',
        optionLabel: 'yqMerchantName',
        optionsName: 'parkServiceList'
      }, {
        type: 'selectInput',
        selectName: 'orderOrTrade',
        isClear: true,
        selectOption: [{
          label: '主订单编号',
          name: 'orderCode'
        }, {
          label: '交易参考号',
          name: 'tradeNo'
        }],
        handleSelectChange: (value) => {
          this.searchSelectObj.orderOrTrade.value = ''
        }
      }],
      // 表格
      // getListApi: getSeviceListApi,
      getListApi: getSeviceList,
      tableParams: {
        btnId: new Date().getTime() + parseInt(Math.random() * 1000),
        listName: 'list',
        tableOption: false,
        tableColumns: [{
          label: '主订单编号',
          prop: 'orderCode',
          width: '160px'
        }, {
          label: '交易参考号',
          prop: 'tradeNo',
          width: '160px',
          formatter: cellValue => {
            return cellValue.payOrder ? cellValue.payOrder.tradeNo : ''
          }
        },
        // {
        //   label: '子订单编号',
        //   prop: 'subOrderCode'
        // },
        {
          label: '园区店名',
          prop: 'yqMerchantName',
          width: '170'
          // formatter: (cellValue) => {
          //   return cellValue.orderDivision ? cellValue.orderDivision.yqMerchantName : ''
          // }
        }, {
          label: '分账类型',
          prop: 'divisionType',
          width: '100px',
          formatter: (cellValue) => {
            return '线下对账'
          }
        }, {
          label: '分账账户',
          prop: 'serviceDivisionAccount',
          width: '170'
        }, {
          label: '实际分账金额(元)',
          prop: 'serviceDivisionMoney',
          formatter: cellValue => {
            return cellValue.serviceDivisionMoney ? ('¥' + cellValue.serviceDivisionMoney) : '-'
          }
        }, {
          label: '订单支付时间',
          prop: '',
          formatter: (cellValue) => {
            return cellValue.payOrder.successDate ? Util.dateFormate(cellValue.payOrder.successDate, 'YYYY-MM-DD HH:mm:ss') : ''
          }
        }
          // {
          //   label: '商品编号',
          //   prop: '',
          //   formatter: cellValue => {
          //     return cellValue.goodsSubOrder ? cellValue.goodsSubOrder.upgradeGoodsCommodityCode : ''
          //   }
          // }, {
          //   label: '商品名称',
          //   prop: '',
          //   formatter: cellValue => {
          //     return cellValue.goodsSubOrder ? cellValue.goodsSubOrder.upgradeGoodsName : ''
          //   }
          // }
        ]
      },
      baseData: {
        parkServiceList: []
      }
    }
  },

  computed: {
    ...mapState({
      dowloadList: (state) => state.d2admin.user.dowloadList
    })
  },

  mounted() {
    this.getCount()
    getPartnerYqListApi({}).then(res => {
      this.baseData.parkServiceList = res
      this.getOptionsList()
    })
  },

  methods: {
    ...mapActions({
      close: 'd2admin/page/close'
    }),
    ...mapActions('d2admin/user', ['actionSetDownloadList']),

    handleAccTypeChange(value) {
      (value !== '2') && (this.searchForm.divisionStatus = '')
    },

    getMouthLastDate(date) {
      return new Date(date.setMonth(date.getMonth() + 1)).setDate(0)
    },

    getSelectInputParams() {
      const list = Object.keys(this.searchSelectObj)
      var params = {}
      list.forEach(i => {
        const item = this.searchSelectObj[i]
        item.value && (params[item.attr] = item.value)
      })
      return params
    },

    getParams() {
      var params = deepClone(this.searchForm)
      const tempParams = this.getSelectInputParams()
      params = {
        ...params,
        ...tempParams
      }
      if (params.successDate) {
        params.successDateStartDate = new Date(this.searchForm.successDate[0]).toLocaleDateString().replace(/\//g, '-') + ' 00:00:00'
        params.successDateEndDate = new Date(this.searchForm.successDate[1]).toLocaleDateString().replace(/\//g, '-') + ' 23:59:59'
        delete params.successDate
      }
      return params
    },

    beforeSearchFn() {
      this.getCount()
      return new Promise(resolve => {
        this.searchFormSearch = this.getParams()
        resolve()
      })
    },

    getCount() {
      var params = this.getParams()
      // getSeviceCountApi(params).then(res => {
      getSeviceCount(params).then(res => {
        this.countObj = res
        console.log(this.countObj)
      })
    },

    getOptionsList() {
      this.showFormData.forEach((item, index) => {
        if (item.type === 'select') {
          if (this.baseData[item.optionsName].length && this.baseData[item.optionsName][0][this.showFormData[index].optionLabel] !== '全部') {
            const temp = {}
            temp[this.showFormData[index].optionId] = ''
            temp[this.showFormData[index].optionLabel] = '全部'
            this.baseData[item.optionsName].unshift(temp)
          }
          this.$set(this.showFormData[index], 'optionList', this.baseData[item.optionsName])
        }
      })
    },

    handleReset() {
      this.searchForm = {
        // 线下
        divisionType: '1',
        merchantFlag: '2',
        successDate: '',
        yqMerchantId: '',
        divisionStatus: ''
      }
      this.searchSelectObj = {
        orderOrTrade: {
          attr: 'orderCode',
          value: ''
        }
      }
    },

    handleExport() {
      var params = this.getParams()
      // exportSeviceApi(params).then(res => {
      // getSeviceExport(params).then(res => {
      //   this.$open(res)
      // })

      params.method = 'dj.api.smartcarlife.sevicerOrderDivision.export.async'
      // asyncExportExcel({ exportParam: JSON.stringify(params) }).then(res => {
      const list = [
        ...this.dowloadList,
        {
          name: '分账列表-线下分账(服务商)',
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
          // uuid: JSON.parse(res).data,
          // ifSuccess: false
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
      // this.handleClose()
      // })
    }
  }
}

</script>
<style scoped>
.my-off-account .header {
  padding: 0 37px 20px;
}
.my-off-account .header .header-balance {
  position: relative;
}
.my-off-account .header .header-balance .balance-btn {
  position: absolute;
  right: 0;
}
.my-off-account .header .balance-num {
  font-size: 28px;
  font-weight: 400px;
  margin: 16px 0;
}
</style>