
<template>
  <div>
    <basicLayout 
      ref="list" 
      formPath="AccountMoney" 
      tableName="accountMoneyTable" 
      :apiId="{query:20221008145903}"
      :options="options">
      <div slot="custom">
        <el-select 
          v-model="sys_enterpriseid" 
          placeholder="企业筛选" 
          size="mini" 
          @change="enterpriseChange" 
          clearable 
          @clear="enterpriseChange($refs.list.param.content.where.sys_enterpriseid='')"
        >
          <el-option
            v-for="item in enterpriseList"
            :key="item.sys_enterpriseid"
            :label="item.enterprisename"
            :value="item.sys_enterpriseid">
          </el-option>
        </el-select>
        <el-select 
          v-model="accountType" 
          placeholder="账户名称筛选" 
          size="mini" 
          @change="accountChange" 
          clearable 
          @clear="accountChange($refs.list.param.content.where.accountname='')"
        >
          <el-option
            v-for="(item,index) in accountTypeList"
            :key="index"
            :label="item.value"
            :value="item.value">
          </el-option>
        </el-select>
      </div>
      <template v-slot:tbList="scope">
        <div v-if="scope.data.column.columnname == 'province'">
          {{`${scope.data.column.data[[scope.data.column.columnname]]}、${scope.data.column.data.city}、${scope.data.column.data.county}`}}
        </div>
        <div v-else>
          {{scope.data.column.data[[scope.data.column.columnname]]}}
        </div>
      </template>
      <template v-slot:tbOpreation="scope">
        <Detail :rowData="scope.data.data"/>
      </template>
    </basicLayout>
  </div>
</template>

<script>
import Detail from './modules/detail'
export default {
  components:{Detail},
  data () {
    return {
      options:[],
      enterpriseList:'',
      accountType:'',
      accountTypeList:'',
      sys_enterpriseid:''
    }
  },
  async created () {
    this.getEnterprise()
    let res = await this.$store.dispatch('optiontypeselect','accountname')
    this.accountTypeList = res.data
  },
  methods:{
    /** 获取公司数据 */
    async getEnterprise () {
      let res = await this.$api.requested({
        "id": 20221021095802,
        "content": {
            "pageNumber": 1,
            "pageSize": 99999,
            "where": {
                "condition": ""
            }
        },
      })
      this.enterpriseList = res.data
    },
    /* 企业筛选 */
    enterpriseChange () {
      this.$refs.list.param.content.where.sys_enterpriseid = this.sys_enterpriseid
      this.$refs.list.listData()
    },
    accountChange () {
      this.$refs.list.param.content.where.accountname = this.accountType
      this.$refs.list.listData()
    }
  }
}

</script>
<style>
</style>