offlineAccountList.vue 13.2 KB
<!-- 我的分账 - 线下对账列表 -->
<template>
  <div class="offline-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 size="small" type="primary" @click="handleSearch">
          查询
        </el-button>
        <el-button size="small" @click="handleReset">
          重置
        </el-button>
      </div>
    </div>
    <div class="d2-container-content">
      <d2-table-header :left-span="20">
        <span slot="left">共<span class="count-txt">{{ countObj.orderCount }}</span>笔订单,累计线下分账金额<span class="count-txt">{{
          countObj.divisionMoneyCount }}</span>元。</span>
        <auth-button category="Button" />
      </d2-table-header>
      <el-table :data="tableList">
        <el-table-column label="序号" type="index" :index="index => index + (page.currentPage - 1) * page.pageSize + 1"
                         align="center" />
        <el-table-column label="主订单编号" prop="orderCode" align="center" width="150px" />
        <el-table-column label="交易参考号" prop="tradeNo" align="center" width="150px">
          <span slot-scope="scope">{{ scope.row.payOrder ? scope.row.payOrder.tradeNo : '' }}</span>
        </el-table-column>
        <el-table-column label="分账类型" align="center">
          <span>线下对账</span>
        </el-table-column>
        <!-- <el-table-column label="园区店名" -->
        <el-table-column label="服务对接" prop="yqMerchantName" align="center" width="170" />
        <el-table-column label="支付金额" prop="payMoney" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.payMoney ? ('¥' + scope.row.payMoney) : '-' }}</span>
          </template>
        </el-table-column>
        <el-table-column label="总分账金额" prop="" align="center">
          <span slot-scope="scope">{{ '¥' + scope.row.divisionMoney }}</span>
        </el-table-column>
        <el-table-column v-if="userInfo.beSuper" prop="actualIncomeMoney " label="实收金额" align="center">
          <template slot-scope="scope">
            <span>{{ scope.row.actualIncomeMoney ? ('¥' + scope.row.actualIncomeMoney) : '-' }}</span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="嘀加智慧云实际分账金额"
                         prop="glActualDivisionMoney"
                         align="center"
                         width="100px">
          <template slot-scope="scope">
            {{scope.row.glActualDivisionMoney ? ('¥' + scope.row.glActualDivisionMoney) : '-'}}
          </template>
        </el-table-column> -->
        <el-table-column label="平台方" align="center">
          <el-table-column label="名称" prop="actualDivisionPlatform" align="center" width="100px">
            <!-- <span slot-scope="scope">{{scope.row.partnerMerchantName}}</span> -->
          </el-table-column>
          <el-table-column label="实际分账金额" prop="glActualDivisionMoney" width="110px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.glActualDivisionMoney ? ('¥' + scope.row.glActualDivisionMoney) : '-' }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <!-- <el-table-column label="服务商"
                         align="center">
          <el-table-column label="名称"
                           prop="partnerMerchantName1"
                           align="center"
                           width="100px">
          </el-table-column>
          <el-table-column label="实际分账金额"
                           prop="partnerDivisionMoney1"
                           align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partnerDivisionMoney1 ? ('¥' + scope.row.partnerDivisionMoney1) : '-' }}</span>
            </template>
          </el-table-column>
          <el-table-column label="名称"
                           prop="partnerMerchantName2"
                           align="center"
                           width="100px">
          </el-table-column>
          <el-table-column label="实际分账金额"
                           prop="partnerDivisionMoney2"
                           align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.partnerDivisionMoney2 ? ('¥' + scope.row.partnerDivisionMoney2) : '-' }}</span>
            </template>
          </el-table-column>
        </el-table-column> -->
        <el-table-column label="流量方" align="center">
          <el-table-column label="名称" prop="realityShopMerchantName" align="center" width="100px" />
          <!-- <el-table-column label="名称"
                           prop="shopMerchantName"
                           align="center"
                           width="100px" /> -->
          <el-table-column label="实际分账金额" prop="shopDivisionMoney" width="110px" align="center">
            <template slot-scope="scope">
              <span>{{ scope.row.shopDivisionMoney ? ('¥' + scope.row.shopDivisionMoney) : '-' }}</span>
            </template>
          </el-table-column>
        </el-table-column>
        <el-table-column label="订单支付时间" prop="successDateStr" align="center" width="160px" />
        <el-table-column label="订单类型" prop="orderType" align="center">
          <span slot-scope="scope">{{ scope.row.goodsOrder ? baseData.orderTypeList.find(item => +item.confId ===
            scope.row.goodsOrder.orderType).confLabel : '-' }}</span>
        </el-table-column>
      </el-table>
      <el-pagination background @size-change="handleSizeChange" @current-change="handleCurrentChange"
                     :current-page="page.currentPage" :page-sizes="[10, 20, 30, 40]" :page-size="page.pageSize" :total="total"
                     layout="sizes,total,->,prev,pager,next,jumper" />
    </div>
  </div>
</template>

<script>
// import _ from 'lodash'
import { Util, deepClone } from '@/common/util'
import { mapActions, mapState } from 'vuex'
import { getParkStore } from '@api/editCustomer'
// exportApi
import { getListApi, getCountApi } from '@/api/account'
import { getPlatformMerchantList } from '@api/index'
import { orderTypeList } from '@/common/constants.js'
// import { asyncExportExcel } from '@api/sys.base'
export default {
  name: 'OfflineAccountList',
  data() {
    return {
      userInfo: this.$store.state.d2admin.user.info,
      countObj: {},
      searchForm: {
        // 线下
        divisionType: '1',
        successDate: '',
        yqMerchantId: '',
        merchantNameKeyWord: '',
        orderCode: '',
        realityPlatformMerchantId: ''
      },
      searchSelectObj: {
        orderOrTrade: {
          attr: 'orderCode',
          value: ''
        }
      },
      showFormData: [{
        label: '支付时间',
        name: 'successDate',
        type: 'datePicker',
        isClear: true,
        pickerOptions: 'rangePickerOptions'
      }, {
        label: '服务对接',
        // label: '园区店',
        name: 'yqMerchantId',
        type: 'select',
        isHide: !this.$store.state.d2admin.user.info.beSuper,
        optionList: [],
        optionId: 'merchantId',
        optionLabel: 'merchantName',
        optionsName: 'parkServiceList'
      }, {
        label: '商户名称',
        name: 'merchantNameKeyWord',
        type: 'input',
        placeholder: '请输入服务对接/服务商/导流方名称',
        // placeholder: '请输入园区店/服务商/导流方名称',
        isClear: true,
        keyFn: this.getList
      }, {
        type: 'selectInput',
        // name: 'orderOrTrade',
        selectName: 'orderOrTrade',
        isClear: true,
        selectOption: [{
          label: '主订单编号',
          name: 'orderCode'
        }, {
          label: '交易参考号',
          name: 'tradeNo'
        }],
        handleSelectChange: (value) => {
          this.searchSelectObj.orderOrTrade.value = ''
        }
      }, {
        label: '平台方',
        name: 'realityPlatformMerchantId',
        type: 'select',
        optionList: [],
        optionId: 'merchantId',
        optionLabel: 'merchantName',
        optionsName: 'PlatformMerchantList'
      }],
      // 表格
      tableList: [],
      page: {
        pageSize: 10,
        currentPage: 1
      },
      total: 0,
      baseData: {
        parkServiceList: [],
        orderTypeList: deepClone(orderTypeList),
        PlatformMerchantList: []
      }
    }
  },

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

  mounted() {
    // this.searchForm.successDate = getCurrentSixMonth()
    this.userInfo.beSuper && getParkStore({}).then(res => {
      res.forEach(item => {
        item.merchantId = item.merchantNo
      })
      this.baseData.parkServiceList = res
      this.getOptionsList()
    })
    getPlatformMerchantList({}).then(res => {
      res.unshift({
        merchantId: -1,
        merchantName: '嘀加智慧云'
      })
      this.baseData.PlatformMerchantList = res
      this.getOptionsList()
    })
    this.getList()
  },

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

    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])
        }
      })
    },

    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
    },

    getList() {
      var params = this.getParams()
      this.getCount()
      getListApi({
        ...params,
        ...this.page
      }).then(res => {
        // console.log(res)
        this.tableList = res.list
        this.total = res.total
        this.tableList.forEach(item => {
          item.successDateStr = item.payOrder ? Util.dateFormate(item.payOrder.successDate, 'YYYY-MM-DD HH:mm:ss') : ''
        })
      })
    },

    getCount() {
      var params = this.getParams()
      getCountApi(params).then(res => {
        this.countObj = res
      })
    },

    handleSearch() {
      this.page.currentPage = 1
      this.getList()
    },
    handleReset() {
      this.searchForm = {
        // 线下
        divisionType: '1',
        divisionDate: '',
        yqMerchantId: '',
        merchantNameKeyWord: '',
        orderCode: '',
        realityPlatformMerchantId: ''
      }
      this.searchSelectObj = {
        orderOrTrade: {
          attr: 'orderCode',
          value: ''
        }
      }
    },
    // 每页条数
    handleSizeChange(value) {
      this.page.pageSize = value
      this.getList()
    },

    // 页码
    handleCurrentChange(value) {
      this.page.currentPage = value
      this.getList()
    },

    handleRecord() {
      this.close({ tagName: '/accountRecord' })
      this.$router.push({
        name: 'accountRecord'
      })
    },

    handleExport() {
      var params = this.getParams()
      // exportApi(params).then(res => {
      //   this.$open(res)
      // })
      // params.method = 'dj.api.smartcarlife.orderDivision.export.async'
      params.method = 'dj.api.smartcarlife.orderDivision.exportForAudit.async'

      // asyncExportExcel({ exportParam: JSON.stringify(params) }).then(res => {
      const list = [
        ...this.dowloadList,
        {
          name: '分账列表-线下分账(超管/服务对接)',
          // name: '分账列表-线下分账(超管/园区店)',
          // uuid: JSON.parse(res).data,
          // ifSuccess: false
          exportParam: JSON.stringify(params),
          status: 'waiting',
          timeid: new Date().getTime()
        }
      ]
      this.actionSetDownloadList({ list, type: 'dowloadList' })
      // this.handleClose()
      // })
    }
  }
}

</script>
<style scoped>
.count-txt {
  font-weight: 700;
  color: #2a58ad;
  margin: 0 2px;
}
</style>