RechargeRecord.vue 9.02 KB
<template>
  <div class="RechargeRecord">
    <div class="searchBox">
      <div class="choosePeople" @click="choosePeople" style="width: 120px">选择成员</div>
      <a-input style="width: 120px;margin-right: 20px;" placeholder="经办人"  v-model="searchSource.agentName"/>
      <!-- <a-select placeholder="经办人" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectAgent">
        <a-select-option v-for="(item, index) in agentList" :key="index" :value="item.ddUserId">{{ item.name }}</a-select-option>
      </a-select> -->
      <a-select placeholder="状态" :allowClear="true" style="width: 120px;margin-right: 20px;" @change="selectHandlestatus">
        <a-select-option value="SUCCESS">已完成</a-select-option>
        <a-select-option value="WAITING_PERMIT">审批中</a-select-option>
        <a-select-option value="FAILED">审批未通过</a-select-option>
      </a-select>
      <a-button type="primary" @click="search()">查询</a-button>
    </div>
    <div class="searchUserMessage" v-if="searchSource.UserMessage.emplId">
      <div class="positionDiv"></div>
      <div class="clearUserMessage"><a href="javascript:;" @click="clearUserMessage">清除</a></div>
      <div class="userListBox">
        <div>
          <img v-if="searchSource.UserMessage.avatar" :src="searchSource.UserMessage.avatar" :alt="searchSource.UserMessage.name"/>
          <img v-else :src="this.avatarCanvasFn(searchSource.UserMessage.name)" :alt="searchSource.UserMessage.name">
          <span>{{ searchSource.UserMessage.name }}</span>
        </div>
      </div>
    </div>
    <a-table :columns="columns" :dataSource="chargeList" :pagination="pagination" @change="handleTableChange" rowKey="orderNo">
        <span slot="userName">姓名</span>
        <span slot="departmentNameList" slot-scope="departmentNameList, record">
          <div v-if="departmentNameList && departmentNameList.length > 0">
            <a-popover v-for="(item,indexOf) in departmentNameList" :key="indexOf">
              <template slot="content">
                <p>{{record.parentSysDeptNameList[indexOf]}}</p>
              </template>
              <span class="deptModel">{{item}}</span>
            </a-popover>
          </div>
        </span>
        <span slot="chargeAmount"></span>
        <span slot="agent" slot-scope="agent, record">
          {{ agent === '' && record.payTypeCode === 'EXTERNAL_ALI_RECHAGE' ? '支付宝自充' : agent }}
        </span>
        <span slot="orderStatus" slot-scope="orderStatus, record">
          <a-badge v-if="orderStatus === MINGPAY_CHARGE_ORDERSTATUS.WAITING_PERMIT" status="processing" text="审批中" />
          <a-badge v-else-if="orderStatus === MINGPAY_CHARGE_ORDERSTATUS.SUCCESS" status="success" text="已完成" />
          <a-badge v-else-if="record.payTypeCode === 'INTERNAL_RECHAGE' && orderStatus === MINGPAY_CHARGE_ORDERSTATUS.FAILED" status="error" text="审批未通过" />
          <a-badge v-else-if="record.payTypeCode === 'EXTERNAL_ALI_RECHAGE' && orderStatus === MINGPAY_CHARGE_ORDERSTATUS.FAILED" status="error" text="充值失败" />
        </span>
        <span slot="createTime">时间</span>
        <span slot="remark">备注</span>
      </a-table>
    </div>
</template>

<script>
import { config } from './../../../api/config.js'
import { $http } from './../../../api/axios.js'
import { MINGPAY_CHARGE_ORDERSTATUS } from './../../../api/constant'
export default {
  name: 'accountManagement',
  components: {},
  data () {
    return {
      MINGPAY_CHARGE_ORDERSTATUS: MINGPAY_CHARGE_ORDERSTATUS,
      data: [],
      columns: [{
        title: '成员',
        dataIndex: 'userName'
      }, {
        title: '部门',
        dataIndex: 'departmentNameList',
        scopedSlots: { customRender: 'departmentNameList' },
        width: '15%'
      }, {
        title: '充值金额',
        dataIndex: 'chargeAmount'
      }, {
        title: '经办人',
        dataIndex: 'agent',
        scopedSlots: { customRender: 'agent' }
      }, {
        title: '状态',
        dataIndex: 'orderStatus',
        scopedSlots: { customRender: 'orderStatus' }
      }, {
        title: '时间',
        dataIndex: 'createTime'
      }, {
        title: '备注',
        dataIndex: 'remark',
        width: '12%'
      }],
      pagination: {
        current: 1,
        defaultCurrent: 10,
        defaultPageSize: 10,
        hideOnSinglePage: true,
        total: 0
      },
      chargeList: [],
      searchSource: {
        UserMessage: {
          avatar: '',
          emplId: '',
          name: ''
        },
        status: '',
        agentName: ''
      },
      agentList: []
    }
  },
  watch: {},
  computed: {},
  created: function () {
    this.queryRechargeList()
    // this.getAgentList()
  },
  methods: {
    // 获取收银员列表
    // getAgentList () {
    //   let AgentData = {
    //     userType: '1'
    //   }
    //   $http.get(`/mingpay/v1/isv/cashier/list_cashier_all`, AgentData).then((res) => {
    //     this.agentList = res.data.data
    //   })
    // },
    // 选人组件调用
    choosePeople () {
      const _that = this
      config.ddready('ddchooseOne').then((res) => {
        this.searchSource.UserMessage = res[0]
        _that.queryRechargeList()
      })
    },
    // 清理选择帅选人list
    clearUserMessage () {
      this.searchSource.UserMessage = {
        avatar: '',
        emplId: '',
        name: ''
      }
    },
    // 用户头像处理
    avatarCanvasFn (name) {
      let canvas = document.createElement('canvas')
      let con = canvas.getContext('2d')
      let ratio = this.getPixelRatio(con)
      canvas.style.width = 40 + 'px'
      canvas.style.height = 40 + 'px'
      canvas.width = 40 * ratio
      canvas.height = 40 * ratio
      con.scale(ratio, ratio)
      con.fillStyle = '#1890ff'
      con.fillRect(0, 0, 40, 40)
      con.fillStyle = '#ffffff'
      con.font = '12px Arial'
      con.textAlign = 'center'
      con.fillText(name, 20, 25)
      return canvas.toDataURL()
    },
    // 头像模糊处理
    getPixelRatio (context) {
      var backingStore = context.backingStorePixelRatio ||
        context.webkitBackingStorePixelRatio ||
        context.mozBackingStorePixelRatio ||
        context.msBackingStorePixelRatio ||
        context.oBackingStorePixelRatio ||
        context.backingStorePixelRatio || 1
      return (window.devicePixelRatio || 1) / backingStore
    },
    selectHandlestatus (value) {
      this.searchSource.status = value
    },
    selectAgent (value) {
      this.searchSource.agentName = value
    },
    queryRechargeList () {
      let RechargeData = {
        pageNumber: 10,
        currentPage: this.pagination.current,
        agentName: this.searchSource.agentName,
        status: this.searchSource.status,
        ddUserId: this.searchSource.UserMessage.emplId
      }
      $http.get(`/mingpay/v1/isv/charge/list_charge`, RechargeData).then((res) => {
        let data = res.data.data
        this.pagination.total = parseInt(data.totalCount)
        this.chargeList = data.recordList
      })
    },
    // 分页
    handleTableChange (pagination, filters, sorter) {
      this.pagination.current = pagination.current
      this.queryRechargeList()
    },
    departmentNameListToStr (str) {
      let departmentNameListStr = ''
      if (str.length !== 0) {
        str.map((data) => {
          departmentNameListStr = `${departmentNameListStr}${data},`
        })
      }
      departmentNameListStr = departmentNameListStr.substring(0, departmentNameListStr.length - 1)
      return departmentNameListStr
    },
    search () {
      this.pagination.current = 1
      this.queryRechargeList()
    }
  },
  mounted () {}
}
</script>

<style lang="less" scoped>
.searchBox{
  display: flex;
  margin-bottom: 20px;
}
.searchBox > input {
  margin-right: 20px;
  max-width: 180px;
}
.operationTable a{
  margin-right: 8px;
}
.searchUserMessage{
  width: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  font-size: 12px;
  padding: 8px 8px;
  border: 1px solid #cccccc;
  margin-bottom: 15px;
  border-radius: 8px;
  position: relative;
}
.searchUserMessage img{
  width: 32px;
  height: 32px;
  border-radius: 50%;
  margin-bottom: 8px;
}
.positionDiv{
  height: 12px;
  width: 12px;
  transform:rotate(45deg);
  border-left: 1px solid #cccccc;
  border-top: 1px solid #cccccc;
  position: absolute;
  top: -7px;
  left: 30px;
  background: white;
  z-index: 99;
}
.clearUserMessage{
  position: absolute;
  right: 10px;
}
.userListBox{
  text-align: center;
  display: flex;
}
.userListBox>div>img{
  display: block;
  text-align: center;
}
.choosePeople{
  line-height: 32px;
  width: 120px;
  margin-right: 20px;
  padding-left: 11px;
  height: 32px;
  border: 1px solid #d9d9d9;
  border-radius: 4px;
  color: #bfbfbf;
  cursor: pointer;
}
.choosePeople:hover{
  border: 1px solid #1890ff;
}
.deptModel{
  background: #F2F0F0;
  margin: 5px 0;
  margin-right: 5px;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 2;
}
.ant-table-tbody > tr:hover .deptModel{
  background: #CAEEFF;
}
.ant-popover-inner-content>p{
  margin: 0;
}
</style>