<template>
  <a-card :bordered="false" v-if="currUserInfo">
    <x-form-table
      title="用户流水查询"
      :queryParamsName="queryParamsName"
      :fixedQueryForm="fixedQueryForm"
      @action="action"
      serviceName="af-revenue"
      ref="xFormTable">
    </x-form-table>
  </a-card>
</template>

<script>
import { mapState } from 'vuex'
import { getConfigByNameAsync } from '@vue2-client/services/api/common'

export default {
  name: 'UserRecordQuery',
  components: {
    XFormTable: () => import('@vue2-client/base-client/components/common/XFormTable/XFormTable.vue')
  },
  data () {
    return {
      // 查询配置名称
      queryParamsName: 'UserRecordQueryCRUD',
      // 查询表单固定值
      fixedQueryForm: {},
      // 是否显示详情抽屉
      detailVisible: false,
      // 当前记录
      record: {}
    }
  },
  props: {
    currUserInfo: {
      type: Object,
      default: () => undefined
    }
  },
  async mounted () {
    await getConfigByNameAsync('revenueConfig', 'af-revenue').then((res) => {
      const queryCondition = res.recordQueryCondition ? res.recordQueryCondition : res.queryCondition
      if (queryCondition === 'f_userfiles_id') {
        this.fixedQueryForm = { uc_f_userfiles_id: this.currUserInfo.f_userfiles_id }
      } else if (queryCondition === 'f_userinfo_id') {
        this.fixedQueryForm = { uc_f_userinfo_id: this.currUserInfo.f_userinfo_id }
      } else if (queryCondition === 'f_user_id') {
        this.fixedQueryForm = { uc_f_user_id: this.currUserInfo.f_user_id }
      }
    })
    this.$refs.xFormTable.refresh(true)
  },
  methods: {
    action (record, id, actionType) {
      this.detailVisible = true
    },
    onClose () {
      this.detailVisible = false
      // 关闭详情之后重新查询表单
      this.$refs.xFormTable.refreshTable(true)
    }
  },
  computed: {
    ...mapState('account', { currUser: 'user' }),
    ...mapState('setting', { isMobile: 'isMobile' })
  }
  ,
}
</script>

<style scoped>

</style>
