
<template>
  <div>
    <div class="normal-margin">
      <add class="inline-16" v-if="tool.checkAuth($route.name,'quotationInfoManage') && mainData.disabled" :data="mainData" @onSuccess="queryfinancialinfo"></add>
      <el-input
          style="width:300px"
          placeholder="请输入内容"
          v-model="search"
          clearable
          @clear="clearData()"
          size="small"
          @keyup.enter.native="queryClick()">
        <i slot="prefix" class="el-icon-search" @click="queryClick()"></i>
      </el-input>
    </div>  
    
    <el-table
        :header-cell-style="{background:'#EEEEEE',color:'#333'}"
      :data="tableData"
      stripe
      size="mini"
      style="width: 100%"
      border>

      <el-table-column
        prop="enterprisename"
        label="开票抬头">
      </el-table-column>
      <el-table-column
        prop="taxno"
        label="纳税识别号">
      </el-table-column>
      <el-table-column
        prop="bank"
        label="开户银行">
      </el-table-column>
      <el-table-column
        prop="bankcardno"
        label="开户账号">
      </el-table-column>
      <el-table-column
          prop="address"
          label="开票地址">
        <!--        <template slot-scope="scope">
                  {{scope.row.address}}&nbsp;<i style="color:red" v-if="scope.row.isdefault === 1" class="el-icon-place"></i>
                </template>-->
      </el-table-column>
      <el-table-column
        prop="phonenumber"
        label="电话">
      </el-table-column>
      <el-table-column
        prop="remarks"
        label="备注">
      </el-table-column>
      <el-table-column
        label="操作"
        width="100">
        <template slot-scope="scope">
          <edit  class="inline-16" :data="scope.row" :disable="mainData.disabled" @onSuccess="queryfinancialinfo"></edit>
          <el-button type="text" size="mini" :disabled="!tool.checkAuth($route.name,'quotationInfoManage') || !mainData.disabled" @click="deleteRow(scope.row)">删 除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="container normal-panel" style="text-align:right">
      <el-pagination
        background
        small
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[20, 50, 100, 200]"
        layout="total,sizes, prev, pager, next, jumper"
        :total="total">
      </el-pagination>
    </div>
  </div>
</template>

<script>
import add from './modules/add.vue'
import edit from './modules/edit.vue'

export default {
  props:['mainData'],
  data () {
    return {
      search:'',
      tableData:[],
      param:{
        "id": 20221013160602,
        "content": {
          "sys_enterpriseid":0,
          "pageNumber": 1,
          "pageSize": 20,
          "where": {
            "condition": ""
          }
        },
      },
      total:0,
      currentPage:0
    }
  },
  components:{
    add,
    edit
  },
  methods:{
    async queryfinancialinfo () {
      this.param.content.sys_enterpriseid = this.mainData.sys_enterpriseid
      const res = await this.$api.requested(this.param)
      this.tableData = res.data
      this.total = res.total
      this.currentPage = res.pageNumber
    },
    handleSizeChange(val) {
      // console.log(`每页 ${val} 条`);
      this.param.content.pageSize = val
      this.queryfinancialinfo()
    },
    handleCurrentChange(val) {
      // console.log(`当前页: ${val}`);
      this.param.content.pageNumber = val
      this.queryfinancialinfo()
    },
    async deleteRow (row) {
      const res = await this.$api.requested({
        "id": 20221013160502,
        "content": {
          "sys_enterprise_financeids": [row.sys_enterprise_financeid]
        },
      })
      this.tool.showMessage(res,()=>{
        this.queryfinancialinfo()
      })
    },
    clearData(){
      this.search = ""
    },
    queryClick(){
      this.params.content.where.condition = this.search
      this.listData()
    }
  },
  mounted () {
    this.queryfinancialinfo()
  }
}

</script>
<style scoped>
/deep/.el-input__prefix {
  display: flex;
  align-items: center;
}
</style>